diff --git a/card-functionality/src/tests.rs b/card-functionality/src/tests.rs index 809c7a2..2eba414 100644 --- a/card-functionality/src/tests.rs +++ b/card-functionality/src/tests.rs @@ -18,7 +18,6 @@ use openpgp_card_sequoia::Card; use sequoia_openpgp::parse::Parse; use sequoia_openpgp::policy::StandardPolicy; use sequoia_openpgp::serialize::SerializeInto; -use sequoia_openpgp::types::{HashAlgorithm, SymmetricAlgorithm}; use sequoia_openpgp::Cert; use thiserror; @@ -225,13 +224,7 @@ pub fn test_keygen(tx: &mut Card, param: &[&str]) -> Result> { self.card().key_import(key, key_type) } - /// Wrapper fn for `public_to_fingerprint` that uses SHA256/AES128 as default parameters. - /// - /// FIXME: This is a hack. - /// These parameters should probably be automatically determined based on the algorithm used? - fn ptf( - pkm: &PublicKeyMaterial, - time: KeyGenerationTime, - key_type: KeyType, - ) -> Result { - public_to_fingerprint( - pkm, - &time, - key_type, - Some(HashAlgorithm::SHA256), // FIXME - Some(SymmetricAlgorithm::AES128), // FIXME - ) - } - /// Configure the `algorithm_attributes` for key slot `key_type` based on /// the algorithm `algo`. /// This can be useful in preparation for [`Self::generate_key`]. @@ -1241,6 +1220,7 @@ impl Card> { &mut self, key_type: KeyType, ) -> Result<(PublicKeyMaterial, KeyGenerationTime), Error> { - self.card().generate_key(Self::ptf, key_type) + self.card() + .generate_key(crate::util::public_to_fingerprint, key_type) } } diff --git a/openpgp-card-sequoia/src/util.rs b/openpgp-card-sequoia/src/util.rs index e62bff9..2c19caf 100644 --- a/openpgp-card-sequoia/src/util.rs +++ b/openpgp-card-sequoia/src/util.rs @@ -321,16 +321,16 @@ pub fn public_key_material_to_key( /// Mapping function to get a fingerprint from "PublicKeyMaterial + /// timestamp + KeyType" (intended for use with `CardApp.generate_key()`). /// -/// For ECC decryption keys, `hash` and `sym` can be optionally specified. +/// For ECC decryption keys, `hash` and `sym` are set by Sequoia. +/// This fingerprint calculation is based on the parameters that get +/// selected in [`public_key_material_to_key`]. pub(crate) fn public_to_fingerprint( pkm: &PublicKeyMaterial, - time: &KeyGenerationTime, + time: KeyGenerationTime, kt: KeyType, - hash: Option, - sym: Option, ) -> Result { // Transform PublicKeyMaterial into a Sequoia Key - let key = public_key_material_to_key(pkm, kt, time, hash, sym)?; + let key = public_key_material_to_key(pkm, kt, &time, None, None)?; // Get fingerprint from the Sequoia Key let fp = key.fingerprint();