提交 d8803d5a 编写于 作者: A Andy Polyakov

aes_ige suffered SIGBUS on RISC platforms.

上级 acfb4b5b
...@@ -62,9 +62,11 @@ typedef struct { ...@@ -62,9 +62,11 @@ typedef struct {
/* XXX: probably some better way to do this */ /* XXX: probably some better way to do this */
#if defined(__i386__) || defined(__x86_64__) #if defined(__i386__) || defined(__x86_64__)
#define UNALIGNED_MEMOPS_ARE_FAST 1 #define UNALIGNED_MEMOPS_ARE_FAST 1
#else
#define UNALIGNED_MEMOPS_ARE_FAST 0
#endif #endif
#ifdef UNALIGNED_MEMOPS_ARE_FAST #if UNALIGNED_MEMOPS_ARE_FAST
#define load_block(d, s) (d) = *(const aes_block_t *)(s) #define load_block(d, s) (d) = *(const aes_block_t *)(s)
#define store_block(d, s) *(aes_block_t *)(d) = (s) #define store_block(d, s) *(aes_block_t *)(d) = (s)
#else #else
...@@ -89,7 +91,8 @@ void AES_ige_encrypt(const unsigned char *in, unsigned char *out, ...@@ -89,7 +91,8 @@ void AES_ige_encrypt(const unsigned char *in, unsigned char *out,
if (AES_ENCRYPT == enc) if (AES_ENCRYPT == enc)
{ {
if (in != out) if (in != out &&
(UNALIGNED_MEMOPS_ARE_FAST || ((size_t)in|(size_t)out|(size_t)ivec)%sizeof(long)==0))
{ {
aes_block_t *ivp = (aes_block_t *)ivec; aes_block_t *ivp = (aes_block_t *)ivec;
aes_block_t *iv2p = (aes_block_t *)(ivec + AES_BLOCK_SIZE); aes_block_t *iv2p = (aes_block_t *)(ivec + AES_BLOCK_SIZE);
...@@ -143,7 +146,8 @@ void AES_ige_encrypt(const unsigned char *in, unsigned char *out, ...@@ -143,7 +146,8 @@ void AES_ige_encrypt(const unsigned char *in, unsigned char *out,
} }
else else
{ {
if(in != out) if (in != out &&
(UNALIGNED_MEMOPS_ARE_FAST || ((size_t)in|(size_t)out|(size_t)ivec)%sizeof(long)==0))
{ {
aes_block_t *ivp = (aes_block_t *)ivec; aes_block_t *ivp = (aes_block_t *)ivec;
aes_block_t *iv2p = (aes_block_t *)(ivec + AES_BLOCK_SIZE); aes_block_t *iv2p = (aes_block_t *)(ivec + AES_BLOCK_SIZE);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册