Skip to content

Commit

Permalink
final review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmicexplorer committed Oct 4, 2021
1 parent 5e95fcb commit cf048dd
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions rust/protocol/src/sealed_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -754,8 +754,7 @@ mod sealed_sender_v1 {
&recipient_eph_keys.cipher_key,
&recipient_eph_keys.mac_key,
)?;
let sender_public_key: PublicKey =
PublicKey::try_from(recipient_message_key_bytes.as_ref())?;
let sender_public_key: PublicKey = PublicKey::try_from(&recipient_message_key_bytes[..])?;
assert_eq!(sender_identity.public_key(), &sender_public_key);

let recipient_static_keys = StaticKeys::calculate(
Expand Down Expand Up @@ -970,11 +969,11 @@ mod sealed_sender_v2 {
}
.concat();

let boxed_result =
HKDF::new(3)?.derive_secrets(&agreement_key_input, LABEL_DH, MESSAGE_KEY_LEN)?;
let mut result: [u8; MESSAGE_KEY_LEN] = boxed_result.as_ref().try_into().map_err(|_| {
SignalProtocolError::BadKeyLength(curve::KeyType::Djb, boxed_result.len())
})?;
let mut result: [u8; MESSAGE_KEY_LEN] = HKDF::new(3)?
.derive_secrets(&agreement_key_input, LABEL_DH, MESSAGE_KEY_LEN)?
.as_ref()
.try_into()
.expect("requested correct key size from HKDF");

result
.iter_mut()
Expand Down Expand Up @@ -1015,12 +1014,11 @@ mod sealed_sender_v2 {
}
}

let boxed_result =
HKDF::new(3)?.derive_secrets(&agreement_key_input, LABEL_DH_S, AUTH_TAG_LEN)?;
boxed_result
Ok(HKDF::new(3)?
.derive_secrets(&agreement_key_input, LABEL_DH_S, AUTH_TAG_LEN)?
.as_ref()
.try_into()
.map_err(|_| SignalProtocolError::BadKeyLength(curve::KeyType::Djb, boxed_result.len()))
.expect("requested correct key size from HKDF"))
}

#[test]
Expand Down

0 comments on commit cf048dd

Please sign in to comment.