Skip to content

Commit

Permalink
Use constants for key sizes when applicable
Browse files Browse the repository at this point in the history
  • Loading branch information
sosthene-nitrokey authored and daringer committed Nov 23, 2022
1 parent 482e5d3 commit be33405
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/mechanisms/aes256cbc.rs
Expand Up @@ -150,7 +150,7 @@ impl UnsafeInjectKey for super::Aes256Cbc {
keystore: &mut impl Keystore,
request: &request::UnsafeInjectKey,
) -> Result<reply::UnsafeInjectKey, Error> {
if request.raw_key.len() != 32 {
if request.raw_key.len() != AES256_KEY_SIZE {
return Err(Error::InvalidSerializedKey);
}

Expand Down
4 changes: 2 additions & 2 deletions src/mechanisms/tdes.rs
Expand Up @@ -72,7 +72,7 @@ impl Decrypt for super::Tdes {

let key_id = request.key;

let symmetric_key: [u8; 24] = keystore
let symmetric_key: [u8; TDES_KEY_SIZE] = keystore
.load_key(key::Secrecy::Secret, None, &key_id)?
.material
.as_slice()
Expand All @@ -95,7 +95,7 @@ impl UnsafeInjectKey for super::Tdes {
keystore: &mut impl Keystore,
request: &request::UnsafeInjectKey,
) -> Result<reply::UnsafeInjectKey, Error> {
if request.raw_key.len() != 24 {
if request.raw_key.len() != TDES_KEY_SIZE {
return Err(Error::InvalidSerializedKey);
}

Expand Down

0 comments on commit be33405

Please sign in to comment.