Skip to content

Commit

Permalink
fix get_calib_key_type and revert configuration_is_locked changes to …
Browse files Browse the repository at this point in the history
…released rust-calib crate version

Signed-off-by: artur.kazimierski <artur.kazimierski@globallogic.com>
  • Loading branch information
akazimierskigl committed Mar 17, 2021
1 parent eac58b0 commit f08a666
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/providers/cryptoauthlib/key_management.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ impl Provider {
// }

/// Get CryptoAuthLib's key type based on PARSEC's KeyInfoManager type.
pub fn get_calib_key_type(attributes: &Attributes) -> Result<rust_cryptoauthlib::KeyType, ResponseStatus> {
pub fn get_calib_key_type(
attributes: &Attributes,
) -> Result<rust_cryptoauthlib::KeyType, ResponseStatus> {
match attributes.key_type {
Type::RawData => Ok(rust_cryptoauthlib::KeyType::ShaOrText),
Type::Aes => Ok(rust_cryptoauthlib::KeyType::Aes),
Expand All @@ -48,7 +50,7 @@ impl Provider {
Err(ResponseStatus::PsaErrorInvalidArgument)
}
}
_ => return Err(ResponseStatus::PsaErrorInvalidArgument),
_ => Err(ResponseStatus::PsaErrorInvalidArgument),
}
}
}
16 changes: 13 additions & 3 deletions src/providers/cryptoauthlib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,19 @@ impl Provider {
let device = rust_cryptoauthlib::AteccDevice::new(atca_iface).ok()?;
let provider_id = ProviderID::CryptoAuthLib;
// ATECC is useful for non-trivial usage only when its configuration is locked
if !device.configuration_is_locked().ok()? {
error!("Error, configuration is not locked.");
return None;
let mut is_locked = false;
let err = device.configuration_is_locked(&mut is_locked);
match err {
rust_cryptoauthlib::AtcaStatus::AtcaSuccess => {
if !is_locked {
error!("Error, configuration is not locked.");
return None;
}
}
_ => {
error!("Configuration error: {}", err);
return None;
}
}

// This will be returned when everything succeedes
Expand Down

0 comments on commit f08a666

Please sign in to comment.