Skip to content

Commit f2a459e

Browse files
src: Fix formatting and linting errors
Signed-off-by: Tomás González <[email protected]>
1 parent ccb851d commit f2a459e

File tree

3 files changed

+21
-37
lines changed

3 files changed

+21
-37
lines changed

src/key_info_managers/on_disk_manager/mod.rs

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ impl TryFrom<(KeyTriple, ProviderIdentity, Auth)> for KeyIdentity {
241241
};
242242
Ok(KeyIdentity {
243243
provider: ProviderIdentity::new(provider_uuid, provider_identity.name().clone()),
244-
application: app_identity.clone(),
245-
key_name: key_triple.key_name.to_string(),
244+
application: app_identity,
245+
key_name: key_triple.key_name,
246246
})
247247
}
248248
}
@@ -599,12 +599,9 @@ impl OnDiskKeyInfoManager {
599599
let prov_key_name =
600600
base64::engine::general_purpose::URL_SAFE.encode(prov_key_name.as_bytes());
601601
// INTERNAL_KEYS_PARSEC_DIR has already been created with the necessary permissions
602-
let key_name_file_path = self
603-
.mappings_dir_path
602+
self.mappings_dir_path
604603
.join(INTERNAL_KEYS_PARSEC_DIR)
605-
.join(prov_key_name);
606-
607-
key_name_file_path
604+
.join(prov_key_name)
608605
}
609606
Auth::Client(_) => {
610607
// Create the directories with base64 names.
@@ -659,20 +656,15 @@ impl OnDiskKeyInfoManager {
659656
let prov_key_name = prov_and_key_to_str(key_triple.provider_id, &key_name);
660657

661658
// INTERNAL_KEYS_PARSEC_DIR has already been created with the necessary permissions
662-
let key_name_file_path = self
663-
.mappings_dir_path
659+
self.mappings_dir_path
664660
.join(INTERNAL_KEYS_PARSEC_DIR)
665-
.join(prov_key_name);
666-
key_name_file_path
667-
}
668-
Auth::Client(_) => {
669-
let key_name_file_path = self
670-
.mappings_dir_path
671-
.join(app_name)
672-
.join(prov)
673-
.join(key_name);
674-
key_name_file_path
661+
.join(prov_key_name)
675662
}
663+
Auth::Client(_) => self
664+
.mappings_dir_path
665+
.join(app_name)
666+
.join(prov)
667+
.join(key_name),
676668
};
677669
if key_name_file_path.exists() {
678670
fs::remove_file(key_name_file_path)
@@ -747,12 +739,10 @@ impl ManageKeyInfo for OnDiskKeyInfoManager {
747739
self.save_mapping(&key_triple, &key_info, key_identity.application().auth())
748740
{
749741
Err(err.to_string())
742+
} else if key_identity.application().is_internal() {
743+
Ok(self.key_store_internal.insert(key_triple, key_info))
750744
} else {
751-
if key_identity.application().is_internal() {
752-
Ok(self.key_store_internal.insert(key_triple, key_info))
753-
} else {
754-
Ok(self.key_store.insert(key_triple, key_info))
755-
}
745+
Ok(self.key_store.insert(key_triple, key_info))
756746
}
757747
}
758748

@@ -772,9 +762,9 @@ impl ManageKeyInfo for OnDiskKeyInfoManager {
772762

773763
fn exists(&self, key_identity: &KeyIdentity) -> Result<bool, String> {
774764
let key_triple = KeyTriple::try_from(key_identity.clone())?;
775-
match key_identity.application().auth() {
776-
&Auth::Internal => Ok(self.key_store_internal.contains_key(&key_triple)),
777-
&Auth::Client(_) => Ok(self.key_store.contains_key(&key_triple)),
765+
match *key_identity.application().auth() {
766+
Auth::Internal => Ok(self.key_store_internal.contains_key(&key_triple)),
767+
Auth::Client(_) => Ok(self.key_store.contains_key(&key_triple)),
778768
}
779769
}
780770
}

src/providers/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl TryFrom<ProviderIdentity> for ProviderId {
8888

8989
fn try_from(provider_identity: ProviderIdentity) -> std::result::Result<Self, Self::Error> {
9090
let provider_id = match provider_identity.uuid.as_str() {
91-
crate::providers::core::Provider::PROVIDER_UUID => Ok(ProviderId::Core),
91+
core::Provider::PROVIDER_UUID => Ok(ProviderId::Core),
9292
#[cfg(feature = "cryptoauthlib-provider")]
9393
crate::providers::cryptoauthlib::Provider::PROVIDER_UUID => Ok(ProviderId::CryptoAuthLib),
9494
#[cfg(feature = "mbed-crypto-provider")]

src/providers/tpm/mod.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -468,10 +468,7 @@ impl ProviderBuilder {
468468

469469
let root_key_name = esapi_context.get_root_key_name().map_err(|e| {
470470
format_error!("Error getting the Root Key's name", e);
471-
std::io::Error::new(
472-
ErrorKind::InvalidData,
473-
"failed getting Root Key's Name",
474-
)
471+
std::io::Error::new(ErrorKind::InvalidData, "failed getting Root Key's Name")
475472
})?;
476473

477474
if root_key_name.value().to_vec() != stored_root_key_name {
@@ -490,10 +487,7 @@ impl ProviderBuilder {
490487

491488
let root_key_name = esapi_context.get_root_key_name().map_err(|e| {
492489
format_error!("Error getting the the Root Key's Name", e);
493-
std::io::Error::new(
494-
ErrorKind::InvalidData,
495-
"failed getting Root Key's Name",
496-
)
490+
std::io::Error::new(ErrorKind::InvalidData, "failed getting Root Key's Name")
497491
})?;
498492

499493
let attributes = Attributes {
@@ -617,7 +611,7 @@ mod test {
617611
// the previously created one.
618612
{
619613
let builder = ProviderBuilder::new()
620-
.with_key_info_store(kim_factory.build_client(provider_identity.clone()))
614+
.with_key_info_store(kim_factory.build_client(provider_identity))
621615
.with_tcti(tcti)
622616
.with_provider_name("Tpm".to_string())
623617
.with_owner_hierarchy_auth(owner_hierarchy_auth.to_string())

0 commit comments

Comments
 (0)