diff options
author | Bernd Edlinger <bernd.edlinger@hotmail.de> | 2018-04-24 21:10:13 +0200 |
---|---|---|
committer | Bernd Edlinger <bernd.edlinger@hotmail.de> | 2020-05-27 20:11:20 +0200 |
commit | 77286fe3ec6b9777934e67e35f3b7007143b0734 (patch) | |
tree | 47f39fa07cd9979b57ad14f58bc39123133da115 /crypto/aes | |
parent | Rename EVP_PKEY_cmp() to EVP_PKEY_eq() and EVP_PKEY_cmp_parameters() to EVP_P... (diff) | |
download | openssl-77286fe3ec6b9777934e67e35f3b7007143b0734.tar.xz openssl-77286fe3ec6b9777934e67e35f3b7007143b0734.zip |
Avoid undefined behavior with unaligned accesses
Fixes: #4983
[extended tests]
Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/6074)
Diffstat (limited to 'crypto/aes')
-rw-r--r-- | crypto/aes/aes_ige.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/crypto/aes/aes_ige.c b/crypto/aes/aes_ige.c index 51119186de..bbe9bcd4f8 100644 --- a/crypto/aes/aes_ige.c +++ b/crypto/aes/aes_ige.c @@ -18,11 +18,6 @@ #include <openssl/aes.h> #include "aes_local.h" -#define N_WORDS (AES_BLOCK_SIZE / sizeof(unsigned long)) -typedef struct { - unsigned long data[N_WORDS]; -} aes_block_t; - /* XXX: probably some better way to do this */ #if defined(__i386__) || defined(__x86_64__) # define UNALIGNED_MEMOPS_ARE_FAST 1 @@ -30,6 +25,15 @@ typedef struct { # define UNALIGNED_MEMOPS_ARE_FAST 0 #endif +#define N_WORDS (AES_BLOCK_SIZE / sizeof(unsigned long)) +typedef struct { + unsigned long data[N_WORDS]; +#if defined(__GNUC__) && UNALIGNED_MEMOPS_ARE_FAST +} aes_block_t __attribute((__aligned__(1))); +#else +} aes_block_t; +#endif + #if UNALIGNED_MEMOPS_ARE_FAST # define load_block(d, s) (d) = *(const aes_block_t *)(s) # define store_block(d, s) *(aes_block_t *)(d) = (s) |