summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/modes
diff options
context:
space:
mode:
authortb <>2019-05-08 14:18:25 +0000
committertb <>2019-05-08 14:18:25 +0000
commite2fd9b50b051176bc9fc27ecbc752d95d22b9959 (patch)
tree99ca5809c24567b3cf206bd6bfc75611551ec4f9 /src/lib/libcrypto/modes
parent1290f53f998d9ec300bcdf5c33e31d6000cf2266 (diff)
downloadopenbsd-e2fd9b50b051176bc9fc27ecbc752d95d22b9959.tar.gz
openbsd-e2fd9b50b051176bc9fc27ecbc752d95d22b9959.tar.bz2
openbsd-e2fd9b50b051176bc9fc27ecbc752d95d22b9959.zip
Make sure that the tag buffer size is equal to the tag size
in CRYPTO_ccm128_tag(). Otherwise the caller might end up using the part of the tag buffer that was left uninitialized. Issue found by Guido Vranken. ok inoguchi
Diffstat (limited to 'src/lib/libcrypto/modes')
-rw-r--r--src/lib/libcrypto/modes/ccm128.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/libcrypto/modes/ccm128.c b/src/lib/libcrypto/modes/ccm128.c
index 58cc4f44c6..12c6e61659 100644
--- a/src/lib/libcrypto/modes/ccm128.c
+++ b/src/lib/libcrypto/modes/ccm128.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ccm128.c,v 1.4 2015/02/10 09:46:30 miod Exp $ */ 1/* $OpenBSD: ccm128.c,v 1.5 2019/05/08 14:18:25 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 2011 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 2011 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -435,7 +435,7 @@ size_t CRYPTO_ccm128_tag(CCM128_CONTEXT *ctx,unsigned char *tag,size_t len)
435{ unsigned int M = (ctx->nonce.c[0]>>3)&7; /* the M parameter */ 435{ unsigned int M = (ctx->nonce.c[0]>>3)&7; /* the M parameter */
436 436
437 M *= 2; M += 2; 437 M *= 2; M += 2;
438 if (len<M) return 0; 438 if (len != M) return 0;
439 memcpy(tag,ctx->cmac.c,M); 439 memcpy(tag,ctx->cmac.c,M);
440 return M; 440 return M;
441} 441}