Skip to content

Commit 9e6c2eb

Browse files
authored
Tweak guard in set_key, set_nonce to conform with copy_from_slice contract
1 parent aa1281a commit 9e6c2eb

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

capsules/core/src/virtualizers/virtual_aes_ccm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ impl<'a, A: AES128<'a> + AES128Ctr + AES128CBC + AES128ECB> symmetric_encryption
667667
}
668668

669669
fn set_key(&self, key: &[u8]) -> Result<(), ErrorCode> {
670-
if key.len() < AES128_KEY_SIZE {
670+
if key.len() != AES128_KEY_SIZE {
671671
Err(ErrorCode::INVAL)
672672
} else {
673673
let mut new_key = [0u8; AES128_KEY_SIZE];
@@ -678,7 +678,7 @@ impl<'a, A: AES128<'a> + AES128Ctr + AES128CBC + AES128ECB> symmetric_encryption
678678
}
679679

680680
fn set_nonce(&self, nonce: &[u8]) -> Result<(), ErrorCode> {
681-
if nonce.len() < CCM_NONCE_LENGTH {
681+
if nonce.len() != CCM_NONCE_LENGTH {
682682
Err(ErrorCode::INVAL)
683683
} else {
684684
let mut new_nonce = [0u8; CCM_NONCE_LENGTH];

0 commit comments

Comments
 (0)