summaryrefslogtreecommitdiffstats
path: root/crypto/modes
diff options
context:
space:
mode:
authorAndy Polyakov <appro@openssl.org>2012-11-05 10:04:02 +0000
committerBen Laurie <ben@links.org>2013-09-16 14:11:53 +0100
commit09da95542aa8367a5ac164ae78725c8a11849c56 (patch)
tree14b5ff8f40f392a3ecee1af947aef24da9d6c18a /crypto/modes
parentcc53b38574447dd64357c2fb9867d23986f4812b (diff)
cbc128.c: fix strict aliasing warning.
Diffstat (limited to 'crypto/modes')
-rw-r--r--crypto/modes/cbc128.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/crypto/modes/cbc128.c b/crypto/modes/cbc128.c
index 3d3782cbe1..34b2a2ef21 100644
--- a/crypto/modes/cbc128.c
+++ b/crypto/modes/cbc128.c
@@ -117,7 +117,7 @@ void CRYPTO_cbc128_decrypt(const unsigned char *in, unsigned char *out,
unsigned char ivec[16], block128_f block)
{
size_t n;
- union { size_t align; unsigned char c[16]; } tmp;
+ union { size_t t[16/sizeof(size_t)]; unsigned char c[16]; } tmp;
assert(in && out && key && ivec);
@@ -165,19 +165,19 @@ void CRYPTO_cbc128_decrypt(const unsigned char *in, unsigned char *out,
out += 16;
}
}
- else {
- size_t c;
+ else if (16%sizeof(size_t) == 0) { /* always true */
+ size_t c, *out_t=(size_t *)out, *ivec_t=(size_t *)ivec;
+ const size_t *in_t=(const size_t *)in;
while (len>=16) {
- (*block)(in, tmp.c, key);
- for(n=0; n<16; n+=sizeof(size_t)) {
- c = *(size_t *)(in+n);
- *(size_t *)(out+n) =
- *(size_t *)(tmp.c+n) ^ *(size_t *)(ivec+n);
- *(size_t *)(ivec+n) = c;
+ (*block)((const unsigned char *)in_t, tmp.c, key);
+ for(n=0; n<16/sizeof(size_t); n++) {
+ c = in_t[n];
+ out_t[n] = tmp.t[n] ^ ivec_t[n];
+ ivec_t[n] = c;
}
len -= 16;
- in += 16;
- out += 16;
+ in_t += 16/sizeof(size_t);
+ out_t += 16/sizeof(size_t);
}
}
}