2014-05-03 Niels Möller <nisse@lysator.liu.se>
+ * configure.ac: Check for SIZEOF_SIZE_T.
+ * ccm.c (ccm_set_nonce): Skip code for 64-bit encoding when size_t
+ is only 32 bits.
+
* nettle.texinfo (CCM): Document new ccm macros and constants.
Describe ccm restrictions.
/* Encrypt B0 (with the adata flag), and input L(a) to the CBC-MAC. */
ctx->tag.b[CCM_OFFSET_FLAGS] |= CCM_FLAG_ADATA;
f(cipher, CCM_BLOCK_SIZE, ctx->tag.b, ctx->tag.b);
+#if SIZEOF_SIZE_T > 4
if (authlen >= (0x01ULL << 32)) {
/* Encode L(a) as 0xff || 0xff || <64-bit integer> */
ctx->tag.b[ctx->blength++] ^= 0xff;
ctx->tag.b[ctx->blength++] ^= (authlen >> 24) & 0xff;
ctx->tag.b[ctx->blength++] ^= (authlen >> 16) & 0xff;
}
- else if (authlen >= ((0x1ULL << 16) - (0x1ULL << 8))) {
- /* Encode L(a) as 0xff || 0xfe || <32-bit integer> */
- ctx->tag.b[ctx->blength++] ^= 0xff;
- ctx->tag.b[ctx->blength++] ^= 0xfe;
- ctx->tag.b[ctx->blength++] ^= (authlen >> 24) & 0xff;
- ctx->tag.b[ctx->blength++] ^= (authlen >> 16) & 0xff;
- }
+ else
+#endif
+ if (authlen >= ((0x1ULL << 16) - (0x1ULL << 8))) {
+ /* Encode L(a) as 0xff || 0xfe || <32-bit integer> */
+ ctx->tag.b[ctx->blength++] ^= 0xff;
+ ctx->tag.b[ctx->blength++] ^= 0xfe;
+ ctx->tag.b[ctx->blength++] ^= (authlen >> 24) & 0xff;
+ ctx->tag.b[ctx->blength++] ^= (authlen >> 16) & 0xff;
+ }
ctx->tag.b[ctx->blength++] ^= (authlen >> 8) & 0xff;
ctx->tag.b[ctx->blength++] ^= (authlen >> 0) & 0xff;
}