From 672a8033c7bc82b859cc923bf9cc603532cbab2a Mon Sep 17 00:00:00 2001 From: Ken Takayama <82209758+kentakayama@users.noreply.github.com> Date: Thu, 18 Jul 2024 03:10:36 +0000 Subject: [PATCH] Fix nonce sizes for various AES-based encryption algorithms * fix: IV size for AES-GCM * del: IV size for AES-KW --- src/t_cose_util.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/t_cose_util.c b/src/t_cose_util.c index 3b0729d9..10d99dc2 100644 --- a/src/t_cose_util.c +++ b/src/t_cose_util.c @@ -256,20 +256,20 @@ uint32_t bits_iv_alg(int32_t cose_algorithm_id) { switch(cose_algorithm_id) { - case T_COSE_ALGORITHM_AES128CCM_16_128: - case T_COSE_ALGORITHM_A128KW: case T_COSE_ALGORITHM_A128GCM: + case T_COSE_ALGORITHM_A192GCM: + case T_COSE_ALGORITHM_A256GCM: + return 96; /* 12 bytes, 4.1 of RFC 9053 */ + case T_COSE_ALGORITHM_AES128CCM_16_128: + case T_COSE_ALGORITHM_AES256CCM_16_128: + return 104; /* 13 bytes, 4.2 of RFC 9053 */ case T_COSE_ALGORITHM_A128CTR: case T_COSE_ALGORITHM_A128CBC: case T_COSE_ALGORITHM_A192CTR: case T_COSE_ALGORITHM_A192CBC: case T_COSE_ALGORITHM_A256CTR: - case T_COSE_ALGORITHM_A256CBC: return 128; - case T_COSE_ALGORITHM_A192KW: - case T_COSE_ALGORITHM_A192GCM: return 192; - case T_COSE_ALGORITHM_AES256CCM_16_128: - case T_COSE_ALGORITHM_A256KW: - case T_COSE_ALGORITHM_A256GCM: return 256; + case T_COSE_ALGORITHM_A256CBC: + return 128; /* 16 bytes, the same length of the AES block size */ default: return UINT32_MAX; } }