diff --git a/consts/src/lib.rs b/consts/src/lib.rs index 5f05a09d..f7ff32ff 100644 --- a/consts/src/lib.rs +++ b/consts/src/lib.rs @@ -10,9 +10,12 @@ mod consts { // TODO: find a way to configure the buffer size // need 128 to handle EAD fields, and 256 for the EAD_1 voucher pub const MAX_MESSAGE_SIZE_LEN: usize = 128 + 64; - pub const MAX_EAD_SIZE_LEN: usize = 64; pub type EADMessageBuffer = EdhocMessageBuffer; // TODO: make it of size MAX_EAD_SIZE_LEN + + pub const MAX_EAD_SIZE_LEN: usize = 64; pub const EAD_ZEROCONF_LABEL: u8 = 0x1; // NOTE: in lake-authz-draft-02 it is still TBD1 + pub const EAD_ZEROCONF_INFO_K_1_LABEL: u8 = 0x0; + pub const EAD_ZEROCONF_INFO_IV_1_LABEL: u8 = 0x1; pub const ID_CRED_LEN: usize = 4; pub const SUITES_LEN: usize = 9; diff --git a/ead/edhoc-ead-zeroconf/src/lib.rs b/ead/edhoc-ead-zeroconf/src/lib.rs index 84db138b..e197f303 100644 --- a/ead/edhoc-ead-zeroconf/src/lib.rs +++ b/ead/edhoc-ead-zeroconf/src/lib.rs @@ -174,13 +174,25 @@ fn compute_prk(a: &BytesP256ElemLen, g_b: &BytesP256ElemLen) -> BytesHashLen { fn compute_k_1_iv_1(prk: &BytesHashLen) -> (BytesCcmKeyLen, BytesCcmIvLen) { // K_1 = EDHOC-Expand(PRK, info = (0, h'', AES_CCM_KEY_LEN), length) let mut k_1: BytesCcmKeyLen = [0x00; AES_CCM_KEY_LEN]; - let k_1_buf = edhoc_kdf(prk, 0, &[0x00; MAX_KDF_CONTEXT_LEN], 0, AES_CCM_KEY_LEN); + let k_1_buf = edhoc_kdf( + prk, + EAD_ZEROCONF_INFO_K_1_LABEL, + &[0x00; MAX_KDF_CONTEXT_LEN], + 0, + AES_CCM_KEY_LEN, + ); k_1[..].copy_from_slice(&k_1_buf[..AES_CCM_KEY_LEN]); // IV_1 = EDHOC-Expand(PRK, info = (1, h'', AES_CCM_KEY_LEN), length) let mut iv_1: BytesCcmIvLen = [0x00; AES_CCM_IV_LEN]; // NOTE (FIXME?): here we actually generate AES_CCM_KEY_LEN bytes, but then we only use AES_CCM_IV_LEN of them (next line) - let iv_1_buf = edhoc_kdf(prk, 1, &[0x00; MAX_KDF_CONTEXT_LEN], 0, AES_CCM_KEY_LEN); + let iv_1_buf = edhoc_kdf( + prk, + EAD_ZEROCONF_INFO_IV_1_LABEL, + &[0x00; MAX_KDF_CONTEXT_LEN], + 0, + AES_CCM_KEY_LEN, + ); iv_1[..].copy_from_slice(&iv_1_buf[..AES_CCM_IV_LEN]); (k_1, iv_1)