diff options
| author | tb <> | 2020-04-30 18:43:11 +0000 |
|---|---|---|
| committer | tb <> | 2020-04-30 18:43:11 +0000 |
| commit | 1813a9138ee882b675662d47ed9fe6974bd433f3 (patch) | |
| tree | 31008db35db83f672b3145620571428037be39f4 /src | |
| parent | cbd0a539eed34c8b6b65717c68d01a47aa9aa314 (diff) | |
| download | openbsd-1813a9138ee882b675662d47ed9fe6974bd433f3.tar.gz openbsd-1813a9138ee882b675662d47ed9fe6974bd433f3.tar.bz2 openbsd-1813a9138ee882b675662d47ed9fe6974bd433f3.zip | |
Disallow setting the AES-GCM IV length to 0
It is possible to do this by abusing the EVP_CTRL_INIT API.
Pointed out by jsing.
ok inoguchi jsing (as part of a larger diff)
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/evp/e_aes.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/lib/libcrypto/evp/e_aes.c b/src/lib/libcrypto/evp/e_aes.c index e1b53c2ce7..80eba80244 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.40 2020/04/27 19:31:02 tb Exp $ */ | 1 | /* $OpenBSD: e_aes.c,v 1.41 2020/04/30 18:43:11 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 | * |
| @@ -721,6 +721,10 @@ aes_gcm_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr) | |||
| 721 | case EVP_CTRL_INIT: | 721 | case EVP_CTRL_INIT: |
| 722 | gctx->key_set = 0; | 722 | gctx->key_set = 0; |
| 723 | gctx->iv_set = 0; | 723 | gctx->iv_set = 0; |
| 724 | if (c->cipher->iv_len == 0) { | ||
| 725 | EVPerror(EVP_R_INVALID_IV_LENGTH); | ||
| 726 | return 0; | ||
| 727 | } | ||
| 724 | gctx->ivlen = c->cipher->iv_len; | 728 | gctx->ivlen = c->cipher->iv_len; |
| 725 | gctx->iv = c->iv; | 729 | gctx->iv = c->iv; |
| 726 | gctx->taglen = -1; | 730 | gctx->taglen = -1; |
