From 7306a9765ebe6d09d753e8d7a902a199500198ce Mon Sep 17 00:00:00 2001 From: Pol Henarejos Date: Sun, 6 Mar 2022 01:29:39 +0100 Subject: [PATCH] Fix AES key generation for other 128 and 192 bits. Signed-off-by: Pol Henarejos --- sc_hsm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sc_hsm.c b/sc_hsm.c index 4c115d9..8ee7a27 100644 --- a/sc_hsm.c +++ b/sc_hsm.c @@ -1189,7 +1189,7 @@ static int cmd_key_gen() { if (!isUserAuthenticated) return SW_SECURITY_STATUS_NOT_SATISFIED(); //at this moment, we do not use the template, as only CBC is supported by the driver (encrypt, decrypt and CMAC) - const uint8_t *aes_key = random_bytes_get(32); + const uint8_t *aes_key = random_bytes_get(key_size); file_t *fpk = file_new((KEY_PREFIX << 8) | key_id); int r = flash_write_data_to_file(fpk, aes_key, key_size); if (r != HSM_OK)