diff options
author | bcook <> | 2014-08-18 19:15:34 +0000 |
---|---|---|
committer | bcook <> | 2014-08-18 19:15:34 +0000 |
commit | 0f5622cc45b880aa7c514c85c116149c066e8c6a (patch) | |
tree | 7d07556e432d7fe68487ffbfe2b3e4e748b4c680 /src/lib/libcrypto/des | |
parent | 6ee9e8bd1dfefb2512d09447fa41d83947caba6c (diff) | |
download | openbsd-0f5622cc45b880aa7c514c85c116149c066e8c6a.tar.gz openbsd-0f5622cc45b880aa7c514c85c116149c066e8c6a.tar.bz2 openbsd-0f5622cc45b880aa7c514c85c116149c066e8c6a.zip |
replace more ROTATE macros with plain-old C code.
Let the compiler optimize these. Even older versions of gcc generate
equal or better quality code than the inline asm.
ok miod@
Diffstat (limited to 'src/lib/libcrypto/des')
-rw-r--r-- | src/lib/libcrypto/des/des_locl.h | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/src/lib/libcrypto/des/des_locl.h b/src/lib/libcrypto/des/des_locl.h index 477aeb60d9..9480d37489 100644 --- a/src/lib/libcrypto/des/des_locl.h +++ b/src/lib/libcrypto/des/des_locl.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: des_locl.h,v 1.16 2014/07/10 22:45:56 jsing Exp $ */ | 1 | /* $OpenBSD: des_locl.h,v 1.17 2014/08/18 19:15:34 bcook Exp $ */ |
2 | /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -60,6 +60,7 @@ | |||
60 | #define HEADER_DES_LOCL_H | 60 | #define HEADER_DES_LOCL_H |
61 | 61 | ||
62 | #include <math.h> | 62 | #include <math.h> |
63 | #include <stdint.h> | ||
63 | #include <stdio.h> | 64 | #include <stdio.h> |
64 | #include <stdlib.h> | 65 | #include <stdlib.h> |
65 | #include <string.h> | 66 | #include <string.h> |
@@ -131,20 +132,10 @@ | |||
131 | } \ | 132 | } \ |
132 | } | 133 | } |
133 | 134 | ||
134 | #if defined(__GNUC__) && __GNUC__>=2 && !defined(__STRICT_ANSI__) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) | 135 | static inline uint32_t ROTATE(uint32_t a, uint32_t n) |
135 | # if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) | 136 | { |
136 | # define ROTATE(a,n) ({ register unsigned int ret; \ | 137 | return (a>>n)+(a<<(32-n)); |
137 | asm ("rorl %1,%0" \ | 138 | } |
138 | : "=r"(ret) \ | ||
139 | : "I"(n),"0"(a) \ | ||
140 | : "cc"); \ | ||
141 | ret; \ | ||
142 | }) | ||
143 | # endif | ||
144 | #endif | ||
145 | #ifndef ROTATE | ||
146 | #define ROTATE(a,n) (((a)>>(n))+((a)<<(32-(n)))) | ||
147 | #endif | ||
148 | 139 | ||
149 | /* Don't worry about the LOAD_DATA() stuff, that is used by | 140 | /* Don't worry about the LOAD_DATA() stuff, that is used by |
150 | * fcrypt() to add it's little bit to the front */ | 141 | * fcrypt() to add it's little bit to the front */ |