diff options
author | tb <> | 2025-09-15 07:36:12 +0000 |
---|---|---|
committer | tb <> | 2025-09-15 07:36:12 +0000 |
commit | 1f8d0b443d28c5e431333f56e1a6384d8123e15c (patch) | |
tree | 7eac98841ac36bde93b8241e083a947fd34332fa /src/lib | |
parent | 0eed5822a87e695248d6828aca5291e4b942d39a (diff) | |
download | openbsd-1f8d0b443d28c5e431333f56e1a6384d8123e15c.tar.gz openbsd-1f8d0b443d28c5e431333f56e1a6384d8123e15c.tar.bz2 openbsd-1f8d0b443d28c5e431333f56e1a6384d8123e15c.zip |
aes: move explicit_bzero() after NULL check
CID 621601 621602
ok djm jsg jsing miod
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libcrypto/aes/aes.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/lib/libcrypto/aes/aes.c b/src/lib/libcrypto/aes/aes.c index 6ac1983968..9cffe6b7cd 100644 --- a/src/lib/libcrypto/aes/aes.c +++ b/src/lib/libcrypto/aes/aes.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: aes.c,v 1.16 2025/09/08 12:50:02 jsing Exp $ */ | 1 | /* $OpenBSD: aes.c,v 1.17 2025/09/15 07:36:12 tb Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright (c) 2002-2006 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 2002-2006 The OpenSSL Project. All rights reserved. |
4 | * | 4 | * |
@@ -88,10 +88,11 @@ aes_rounds_for_key_length(int bits) | |||
88 | int | 88 | int |
89 | AES_set_encrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key) | 89 | AES_set_encrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key) |
90 | { | 90 | { |
91 | explicit_bzero(key->rd_key, sizeof(key->rd_key)); | ||
92 | |||
93 | if (userKey == NULL || key == NULL) | 91 | if (userKey == NULL || key == NULL) |
94 | return -1; | 92 | return -1; |
93 | |||
94 | explicit_bzero(key->rd_key, sizeof(key->rd_key)); | ||
95 | |||
95 | if ((key->rounds = aes_rounds_for_key_length(bits)) <= 0) | 96 | if ((key->rounds = aes_rounds_for_key_length(bits)) <= 0) |
96 | return -2; | 97 | return -2; |
97 | 98 | ||
@@ -102,10 +103,11 @@ LCRYPTO_ALIAS(AES_set_encrypt_key); | |||
102 | int | 103 | int |
103 | AES_set_decrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key) | 104 | AES_set_decrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key) |
104 | { | 105 | { |
105 | explicit_bzero(key->rd_key, sizeof(key->rd_key)); | ||
106 | |||
107 | if (userKey == NULL || key == NULL) | 106 | if (userKey == NULL || key == NULL) |
108 | return -1; | 107 | return -1; |
108 | |||
109 | explicit_bzero(key->rd_key, sizeof(key->rd_key)); | ||
110 | |||
109 | if ((key->rounds = aes_rounds_for_key_length(bits)) <= 0) | 111 | if ((key->rounds = aes_rounds_for_key_length(bits)) <= 0) |
110 | return -2; | 112 | return -2; |
111 | 113 | ||