Commit 00c5dcca authored by Niels Möller's avatar Niels Möller

Avoid >= 32 bit shifts when size_t is only 32 bits.

parent fe869abe
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.
......
......@@ -135,6 +135,7 @@ ccm_set_nonce(struct ccm_ctx *ctx, const void *cipher, nettle_cipher_func *f,
/* 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;
......@@ -146,7 +147,9 @@ ccm_set_nonce(struct ccm_ctx *ctx, const void *cipher, nettle_cipher_func *f,
ctx->tag.b[ctx->blength++] ^= (authlen >> 24) & 0xff;
ctx->tag.b[ctx->blength++] ^= (authlen >> 16) & 0xff;
}
else if (authlen >= ((0x1ULL << 16) - (0x1ULL << 8))) {
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;
......
......@@ -630,6 +630,7 @@ AC_TYPE_UID_T
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(size_t)
AC_CHECK_HEADERS([openssl/blowfish.h openssl/des.h openssl/cast.h openssl/aes.h openssl/ecdsa.h],,
[enable_openssl=no
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment