Skip to content
Snippets Groups Projects
Unverified Commit 3fd8276c authored by Wentao Shang's avatar Wentao Shang Committed by Gaëtan Harter
Browse files

crypto/ccm: fix auth_data_len upperbound value

RFC3610 states that len_encoding is only valid for "0x0001 ... 0xFEFF"

   If 0 < l(a) < (2^16 - 2^8), then the length field is encoded as two
   octets which contain the value l(a) in most-significant-byte first
   order.
parent f0e785a4
No related branches found
No related tags found
No related merge requests found
......@@ -108,13 +108,17 @@ int ccm_compute_adata_mac(cipher_t* cipher, uint8_t* auth_data,
/* 16 octet block size + max. 10 len encoding */
uint8_t auth_data_encoded[26], len_encoding = 0;
if ( auth_data_len < (((uint32_t) 2) << 16)) { /* length (0x0001 ... 0xFEFF) */
/* If 0 < l(a) < (2^16 - 2^8), then the length field is encoded as two
* octets. (RFC3610 page 2)
*/
if (auth_data_len <= 0xFEFF) {
/* length (0x0001 ... 0xFEFF) */
len_encoding = 2;
auth_data_encoded[1] = auth_data_len & 0xFF;
auth_data_encoded[0] = (auth_data_len >> 8) & 0xFF;
} else {
DEBUG("UNSUPPORTED Adata length\n");
DEBUG("UNSUPPORTED Adata length: %" PRIu32 "\n", auth_data_len);
return -1;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment