Skip to content

Commit c7924e5

Browse files
committed
add in null checks on key material
1 parent 6727837 commit c7924e5

File tree

1 file changed

+6
-0
lines changed
  • crypto/fipsmodule/kem

1 file changed

+6
-0
lines changed

crypto/fipsmodule/kem/kem.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,12 @@ int KEM_KEY_set_raw_keypair_from_seed(KEM_KEY *key, const CBS *seed) {
331331
uint8_t *public_key = OPENSSL_malloc(key->kem->public_key_len);
332332
uint8_t *secret_key = OPENSSL_malloc(key->kem->secret_key_len);
333333

334+
if (public_key == NULL || secret_key == NULL) {
335+
OPENSSL_free(public_key);
336+
OPENSSL_free(secret_key);
337+
OPENSSL_PUT_ERROR(EVP, ERR_R_MALLOC_FAILURE);
338+
return 0;
339+
}
334340
size_t public_len = key->kem->public_key_len;
335341
size_t secret_len = key->kem->secret_key_len;
336342

0 commit comments

Comments
 (0)