summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/modes/ccm128.c
diff options
context:
space:
mode:
authormiod <>2014-05-07 22:05:48 +0000
committermiod <>2014-05-07 22:05:48 +0000
commit55b870bc0442258199f29518a1c056569c6cff35 (patch)
treedeb34c5a4686fe5f3219b9c2cc98fdf18af20a2d /src/lib/libcrypto/modes/ccm128.c
parent6e694fdc39d16d30d31406ef82c6b069d9d005d9 (diff)
downloadopenbsd-55b870bc0442258199f29518a1c056569c6cff35.tar.gz
openbsd-55b870bc0442258199f29518a1c056569c6cff35.tar.bz2
openbsd-55b870bc0442258199f29518a1c056569c6cff35.zip
Get __STRICT_ALIGNMENT from <machine/endian.h> and decide upon it, rather
than defining it for not (i386 and amd64 (and sometimes s390)) only. Compile-time tests remain compile-time tests, and runtime-test remain runtime-test instead of being converted to compile-time tests, per matthew@'s explicit demand (rationale: this makes sure the compiler checks your code even if you won't run it). No functional change except on s390 (which we don't run on) and vax (which we run on, but noone cares about) ok matthew@
Diffstat (limited to 'src/lib/libcrypto/modes/ccm128.c')
-rw-r--r--src/lib/libcrypto/modes/ccm128.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/lib/libcrypto/modes/ccm128.c b/src/lib/libcrypto/modes/ccm128.c
index 3ce11d0d98..13bc7adf31 100644
--- a/src/lib/libcrypto/modes/ccm128.c
+++ b/src/lib/libcrypto/modes/ccm128.c
@@ -197,7 +197,7 @@ int CRYPTO_ccm128_encrypt(CCM128_CONTEXT *ctx,
197 if (ctx->blocks > (U64(1)<<61)) return -2; /* too much data */ 197 if (ctx->blocks > (U64(1)<<61)) return -2; /* too much data */
198 198
199 while (len>=16) { 199 while (len>=16) {
200#if defined(STRICT_ALIGNMENT) 200#ifdef __STRICT_ALIGNMENT
201 union { u64 u[2]; u8 c[16]; } temp; 201 union { u64 u[2]; u8 c[16]; } temp;
202 202
203 memcpy (temp.c,inp,16); 203 memcpy (temp.c,inp,16);
@@ -210,7 +210,7 @@ int CRYPTO_ccm128_encrypt(CCM128_CONTEXT *ctx,
210 (*block)(ctx->cmac.c,ctx->cmac.c,key); 210 (*block)(ctx->cmac.c,ctx->cmac.c,key);
211 (*block)(ctx->nonce.c,scratch.c,key); 211 (*block)(ctx->nonce.c,scratch.c,key);
212 ctr64_inc(ctx->nonce.c); 212 ctr64_inc(ctx->nonce.c);
213#if defined(STRICT_ALIGNMENT) 213#ifdef __STRICT_ALIGNMENT
214 temp.u[0] ^= scratch.u[0]; 214 temp.u[0] ^= scratch.u[0];
215 temp.u[1] ^= scratch.u[1]; 215 temp.u[1] ^= scratch.u[1];
216 memcpy(out,temp.c,16); 216 memcpy(out,temp.c,16);
@@ -268,12 +268,12 @@ int CRYPTO_ccm128_decrypt(CCM128_CONTEXT *ctx,
268 if (n!=len) return -1; 268 if (n!=len) return -1;
269 269
270 while (len>=16) { 270 while (len>=16) {
271#if defined(STRICT_ALIGNMENT) 271#ifdef __STRICT_ALIGNMENT
272 union { u64 u[2]; u8 c[16]; } temp; 272 union { u64 u[2]; u8 c[16]; } temp;
273#endif 273#endif
274 (*block)(ctx->nonce.c,scratch.c,key); 274 (*block)(ctx->nonce.c,scratch.c,key);
275 ctr64_inc(ctx->nonce.c); 275 ctr64_inc(ctx->nonce.c);
276#if defined(STRICT_ALIGNMENT) 276#ifdef __STRICT_ALIGNMENT
277 memcpy (temp.c,inp,16); 277 memcpy (temp.c,inp,16);
278 ctx->cmac.u[0] ^= (scratch.u[0] ^= temp.u[0]); 278 ctx->cmac.u[0] ^= (scratch.u[0] ^= temp.u[0]);
279 ctx->cmac.u[1] ^= (scratch.u[1] ^= temp.u[1]); 279 ctx->cmac.u[1] ^= (scratch.u[1] ^= temp.u[1]);