diff options
Diffstat (limited to 'crypto/aes')
-rw-r--r-- | crypto/aes/aes_cbc.c | 38 | ||||
-rw-r--r-- | crypto/aes/aes_cfb.c | 6 | ||||
-rw-r--r-- | crypto/aes/aes_core.c | 6 | ||||
-rw-r--r-- | crypto/aes/aes_ctr.c | 6 | ||||
-rw-r--r-- | crypto/aes/aes_ecb.c | 6 | ||||
-rw-r--r-- | crypto/aes/aes_ofb.c | 6 |
6 files changed, 52 insertions, 16 deletions
diff --git a/crypto/aes/aes_cbc.c b/crypto/aes/aes_cbc.c index bf1a808cf0..01e965a532 100644 --- a/crypto/aes/aes_cbc.c +++ b/crypto/aes/aes_cbc.c @@ -49,7 +49,13 @@ * */ +#ifndef AES_DEBUG +# ifndef NDEBUG +# define NDEBUG +# endif +#endif #include <assert.h> + #include <openssl/aes.h> #include "aes_locl.h" @@ -57,22 +63,22 @@ void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, const unsigned long length, const AES_KEY *key, unsigned char *ivec, const int enc) { - int n; + unsigned long n; unsigned long len = length; - unsigned char tmp[16]; + unsigned char tmp[AES_BLOCK_SIZE]; assert(in && out && key && ivec); assert((AES_ENCRYPT == enc)||(AES_DECRYPT == enc)); if (AES_ENCRYPT == enc) { while (len >= AES_BLOCK_SIZE) { - for(n=0; n < 16; ++n) + for(n=0; n < AES_BLOCK_SIZE; ++n) tmp[n] = in[n] ^ ivec[n]; AES_encrypt(tmp, out, key); - memcpy(ivec, out, 16); - len -= 16; - in += 16; - out += 16; + memcpy(ivec, out, AES_BLOCK_SIZE); + len -= AES_BLOCK_SIZE; + in += AES_BLOCK_SIZE; + out += AES_BLOCK_SIZE; } if (len) { for(n=0; n < len; ++n) @@ -81,25 +87,25 @@ void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, tmp[n] = ivec[n]; AES_encrypt(tmp, tmp, key); memcpy(out, tmp, len); - memcpy(ivec, tmp, 16); + memcpy(ivec, tmp, AES_BLOCK_SIZE); } } else { while (len >= AES_BLOCK_SIZE) { - memcpy(tmp, in, 16); + memcpy(tmp, in, AES_BLOCK_SIZE); AES_decrypt(in, out, key); - for(n=0; n < 16; ++n) + for(n=0; n < AES_BLOCK_SIZE; ++n) out[n] ^= ivec[n]; - memcpy(ivec, tmp, 16); - len -= 16; - in += 16; - out += 16; + memcpy(ivec, tmp, AES_BLOCK_SIZE); + len -= AES_BLOCK_SIZE; + in += AES_BLOCK_SIZE; + out += AES_BLOCK_SIZE; } if (len) { - memcpy(tmp, in, 16); + memcpy(tmp, in, AES_BLOCK_SIZE); AES_decrypt(tmp, tmp, key); for(n=0; n < len; ++n) out[n] ^= ivec[n]; - memcpy(ivec, tmp, 16); + memcpy(ivec, tmp, AES_BLOCK_SIZE); } } } diff --git a/crypto/aes/aes_cfb.c b/crypto/aes/aes_cfb.c index 41c2a5ec3d..9b569dda90 100644 --- a/crypto/aes/aes_cfb.c +++ b/crypto/aes/aes_cfb.c @@ -105,7 +105,13 @@ * [including the GNU Public Licence.] */ +#ifndef AES_DEBUG +# ifndef NDEBUG +# define NDEBUG +# endif +#endif #include <assert.h> + #include <openssl/aes.h> #include "aes_locl.h" diff --git a/crypto/aes/aes_core.c b/crypto/aes/aes_core.c index 937988dd8c..ea884f6f9e 100644 --- a/crypto/aes/aes_core.c +++ b/crypto/aes/aes_core.c @@ -28,7 +28,13 @@ /* Note: rewritten a little bit to provide error control and an OpenSSL- compatible API */ +#ifndef AES_DEBUG +# ifndef NDEBUG +# define NDEBUG +# endif +#endif #include <assert.h> + #include <stdlib.h> #include <openssl/aes.h> #include "aes_locl.h" diff --git a/crypto/aes/aes_ctr.c b/crypto/aes/aes_ctr.c index 142ca4a142..59088499a0 100644 --- a/crypto/aes/aes_ctr.c +++ b/crypto/aes/aes_ctr.c @@ -49,7 +49,13 @@ * */ +#ifndef AES_DEBUG +# ifndef NDEBUG +# define NDEBUG +# endif +#endif #include <assert.h> + #include <openssl/aes.h> #include "aes_locl.h" diff --git a/crypto/aes/aes_ecb.c b/crypto/aes/aes_ecb.c index 1cb2e07d3d..28aa561c2d 100644 --- a/crypto/aes/aes_ecb.c +++ b/crypto/aes/aes_ecb.c @@ -49,7 +49,13 @@ * */ +#ifndef AES_DEBUG +# ifndef NDEBUG +# define NDEBUG +# endif +#endif #include <assert.h> + #include <openssl/aes.h> #include "aes_locl.h" diff --git a/crypto/aes/aes_ofb.c b/crypto/aes/aes_ofb.c index e33bdaea28..f358bb39e2 100644 --- a/crypto/aes/aes_ofb.c +++ b/crypto/aes/aes_ofb.c @@ -105,7 +105,13 @@ * [including the GNU Public Licence.] */ +#ifndef AES_DEBUG +# ifndef NDEBUG +# define NDEBUG +# endif +#endif #include <assert.h> + #include <openssl/aes.h> #include "aes_locl.h" |