cbc128.c: fix strict aliasing warning.
This commit is contained in:
parent
7cb81398b7
commit
c0832990f5
@ -16,8 +16,6 @@ CFLAGS= $(INCLUDES) $(CFLAG)
|
|||||||
ASFLAGS= $(INCLUDES) $(ASFLAG)
|
ASFLAGS= $(INCLUDES) $(ASFLAG)
|
||||||
AFLAGS= $(ASFLAGS)
|
AFLAGS= $(ASFLAGS)
|
||||||
|
|
||||||
CFLAGS += -fno-strict-aliasing
|
|
||||||
|
|
||||||
GENERAL=Makefile
|
GENERAL=Makefile
|
||||||
TEST=
|
TEST=
|
||||||
APPS=
|
APPS=
|
||||||
|
@ -117,7 +117,7 @@ void CRYPTO_cbc128_decrypt(const unsigned char *in, unsigned char *out,
|
|||||||
unsigned char ivec[16], block128_f block)
|
unsigned char ivec[16], block128_f block)
|
||||||
{
|
{
|
||||||
size_t n;
|
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);
|
assert(in && out && key && ivec);
|
||||||
|
|
||||||
@ -165,19 +165,19 @@ void CRYPTO_cbc128_decrypt(const unsigned char *in, unsigned char *out,
|
|||||||
out += 16;
|
out += 16;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else if (16%sizeof(size_t) == 0) { /* always true */
|
||||||
size_t c;
|
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) {
|
while (len>=16) {
|
||||||
(*block)(in, tmp.c, key);
|
(*block)((const unsigned char *)in_t, tmp.c, key);
|
||||||
for(n=0; n<16; n+=sizeof(size_t)) {
|
for(n=0; n<16/sizeof(size_t); n++) {
|
||||||
c = *(size_t *)(in+n);
|
c = in_t[n];
|
||||||
*(size_t *)(out+n) =
|
out_t[n] = tmp.t[n] ^ ivec_t[n];
|
||||||
*(size_t *)(tmp.c+n) ^ *(size_t *)(ivec+n);
|
ivec_t[n] = c;
|
||||||
*(size_t *)(ivec+n) = c;
|
|
||||||
}
|
}
|
||||||
len -= 16;
|
len -= 16;
|
||||||
in += 16;
|
in_t += 16/sizeof(size_t);
|
||||||
out += 16;
|
out_t += 16/sizeof(size_t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user