diff options
author | tb <> | 2020-04-27 19:31:02 +0000 |
---|---|---|
committer | tb <> | 2020-04-27 19:31:02 +0000 |
commit | 30a0f6e6eb2e9f8944e28e141ddfa6f640033c2c (patch) | |
tree | 690e769e57ab9ebb2919a9465adde8c1621ffb33 /src/lib/libcrypto/evp/e_aes.c | |
parent | 241295e8155a67d455196dd25c2c9728ad04ca61 (diff) | |
download | openbsd-30a0f6e6eb2e9f8944e28e141ddfa6f640033c2c.tar.gz openbsd-30a0f6e6eb2e9f8944e28e141ddfa6f640033c2c.tar.bz2 openbsd-30a0f6e6eb2e9f8944e28e141ddfa6f640033c2c.zip |
Disallow the use of zero length IVs in AES-GCM via
EVP_AEAD_CTX_{open,seal}, as this leaks the authentication key.
Issue reported and fix tested by Guido Vranken.
ok beck, jsing
This commit adds a constant to a public header despite library lock,
as discussed with deraadt and sthen.
Diffstat (limited to 'src/lib/libcrypto/evp/e_aes.c')
-rw-r--r-- | src/lib/libcrypto/evp/e_aes.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/lib/libcrypto/evp/e_aes.c b/src/lib/libcrypto/evp/e_aes.c index 8fddeaaa40..e1b53c2ce7 100644 --- a/src/lib/libcrypto/evp/e_aes.c +++ b/src/lib/libcrypto/evp/e_aes.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: e_aes.c,v 1.39 2019/05/12 15:52:46 tb Exp $ */ | 1 | /* $OpenBSD: e_aes.c,v 1.40 2020/04/27 19:31:02 tb Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright (c) 2001-2011 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 2001-2011 The OpenSSL Project. All rights reserved. |
4 | * | 4 | * |
@@ -1441,6 +1441,11 @@ aead_aes_gcm_seal(const EVP_AEAD_CTX *ctx, unsigned char *out, size_t *out_len, | |||
1441 | } | 1441 | } |
1442 | 1442 | ||
1443 | memcpy(&gcm, &gcm_ctx->gcm, sizeof(gcm)); | 1443 | memcpy(&gcm, &gcm_ctx->gcm, sizeof(gcm)); |
1444 | |||
1445 | if (nonce_len == 0) { | ||
1446 | EVPerror(EVP_R_INVALID_IV_LENGTH); | ||
1447 | return 0; | ||
1448 | } | ||
1444 | CRYPTO_gcm128_setiv(&gcm, nonce, nonce_len); | 1449 | CRYPTO_gcm128_setiv(&gcm, nonce, nonce_len); |
1445 | 1450 | ||
1446 | if (ad_len > 0 && CRYPTO_gcm128_aad(&gcm, ad, ad_len)) | 1451 | if (ad_len > 0 && CRYPTO_gcm128_aad(&gcm, ad, ad_len)) |
@@ -1487,6 +1492,11 @@ aead_aes_gcm_open(const EVP_AEAD_CTX *ctx, unsigned char *out, size_t *out_len, | |||
1487 | } | 1492 | } |
1488 | 1493 | ||
1489 | memcpy(&gcm, &gcm_ctx->gcm, sizeof(gcm)); | 1494 | memcpy(&gcm, &gcm_ctx->gcm, sizeof(gcm)); |
1495 | |||
1496 | if (nonce_len == 0) { | ||
1497 | EVPerror(EVP_R_INVALID_IV_LENGTH); | ||
1498 | return 0; | ||
1499 | } | ||
1490 | CRYPTO_gcm128_setiv(&gcm, nonce, nonce_len); | 1500 | CRYPTO_gcm128_setiv(&gcm, nonce, nonce_len); |
1491 | 1501 | ||
1492 | if (CRYPTO_gcm128_aad(&gcm, ad, ad_len)) | 1502 | if (CRYPTO_gcm128_aad(&gcm, ad, ad_len)) |