diff options
author | tb <> | 2020-04-30 18:43:11 +0000 |
---|---|---|
committer | tb <> | 2020-04-30 18:43:11 +0000 |
commit | 829a3b5141fe5548704743974f88860479a8ed2b (patch) | |
tree | 31008db35db83f672b3145620571428037be39f4 | |
parent | 67bcde095983086d567f3b4aa1efe982b30b587c (diff) | |
download | openbsd-829a3b5141fe5548704743974f88860479a8ed2b.tar.gz openbsd-829a3b5141fe5548704743974f88860479a8ed2b.tar.bz2 openbsd-829a3b5141fe5548704743974f88860479a8ed2b.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)
-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; |