From ca6e66aa5aa1ec21ed7213e8a415fa9bf46b1db9 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Mon, 22 Nov 2021 08:19:09 +0100 Subject: [PATCH] Fingerprint: add new signature method commit c42a54795df332cd778a53ea500b901ae873c81d introcuded a bug by using fp.to_string(). Replace this with fp.signature() which correctly returns the full fingerprint instead of the short version. Signed-off-by: Dietmar Maurer --- pbs-api-types/src/crypto.rs | 3 +++ pbs-config/src/key_config.rs | 2 +- pbs-config/src/tape_encryption_keys.rs | 2 +- src/api2/tape/drive.rs | 2 +- src/tape/drive/lto/mod.rs | 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pbs-api-types/src/crypto.rs b/pbs-api-types/src/crypto.rs index eda92e23..6f931f8f 100644 --- a/pbs-api-types/src/crypto.rs +++ b/pbs-api-types/src/crypto.rs @@ -33,6 +33,9 @@ impl Fingerprint { pub fn bytes(&self) -> &[u8; 32] { &self.bytes } + pub fn signature(&self) -> String { + as_fingerprint(&self.bytes) + } } /// Display as short key ID diff --git a/pbs-config/src/key_config.rs b/pbs-config/src/key_config.rs index def83aba..8c20cff3 100644 --- a/pbs-config/src/key_config.rs +++ b/pbs-config/src/key_config.rs @@ -100,7 +100,7 @@ impl From<&KeyConfig> for KeyInfo { fingerprint: key_config .fingerprint .as_ref() - .map(|fp| fp.to_string()), + .map(|fp| fp.signature()), hint: key_config.hint.clone(), } } diff --git a/pbs-config/src/tape_encryption_keys.rs b/pbs-config/src/tape_encryption_keys.rs index eb34bdd6..e40975c7 100644 --- a/pbs-config/src/tape_encryption_keys.rs +++ b/pbs-config/src/tape_encryption_keys.rs @@ -190,5 +190,5 @@ pub fn complete_key_fingerprint(_arg: &str, _param: &HashMap) -> Err(_) => return Vec::new(), }; - data.keys().map(|fp| fp.to_string()).collect() + data.keys().map(|fp| fp.signature()).collect() } diff --git a/src/api2/tape/drive.rs b/src/api2/tape/drive.rs index 3ef2950c..ba2dad70 100644 --- a/src/api2/tape/drive.rs +++ b/src/api2/tape/drive.rs @@ -696,7 +696,7 @@ pub async fn read_label( flat.encryption_key_fingerprint = set .encryption_key_fingerprint .as_ref() - .map(|fp| fp.to_string()); + .map(|fp| fp.signature()); let encrypt_fingerprint = set.encryption_key_fingerprint.clone() .map(|fp| (fp, set.uuid.clone())); diff --git a/src/tape/drive/lto/mod.rs b/src/tape/drive/lto/mod.rs index 1ba706ef..78413f94 100644 --- a/src/tape/drive/lto/mod.rs +++ b/src/tape/drive/lto/mod.rs @@ -317,7 +317,7 @@ impl TapeDriver for LtoTapeHandle { } let output = if let Some((fingerprint, uuid)) = key_fingerprint { - let fingerprint = fingerprint.to_string(); + let fingerprint = fingerprint.signature(); run_sg_tape_cmd("encryption", &[ "--fingerprint", &fingerprint, "--uuid", &uuid.to_string(),