From b7d298d544afaca714bf07aca72c125c16192c72 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Wed, 19 Dec 2018 13:26:46 +0100 Subject: openpgp: Make primary_key_binding use Signer. --- openpgp/src/packet/signature/mod.rs | 11 +++++------ openpgp/src/tpk/builder.rs | 4 +++- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'openpgp') diff --git a/openpgp/src/packet/signature/mod.rs b/openpgp/src/packet/signature/mod.rs index fb947cc4..bc7239c5 100644 --- a/openpgp/src/packet/signature/mod.rs +++ b/openpgp/src/packet/signature/mod.rs @@ -119,16 +119,15 @@ impl Builder { /// The Signature's public-key algorithm field is set to the /// algorithm used by `signer`, the hash-algorithm field is set to /// `hash_algo`. - pub fn sign_primary_key_binding(mut self, signer: &Key, signer_sec: &mpis::SecretKey, + pub fn sign_primary_key_binding(mut self, signer: &mut Signer, algo: HashAlgorithm) -> Result { - - self.pk_algo = signer.pk_algo(); + self.pk_algo = signer.public().pk_algo(); self.hash_algo = algo; - let digest = Signature::primary_key_binding_hash(&self, signer); + let digest = + Signature::primary_key_binding_hash(&self, signer.public()); - let mut signer = KeyPair::new(signer, signer_sec)?; - self.sign(&mut signer, digest) + self.sign(signer, digest) } /// Signs binding between `userid` and `key` using `signer`. diff --git a/openpgp/src/tpk/builder.rs b/openpgp/src/tpk/builder.rs index 3ef3acc2..3ef14856 100644 --- a/openpgp/src/tpk/builder.rs +++ b/openpgp/src/tpk/builder.rs @@ -244,7 +244,9 @@ impl TPKBuilder { Some(uid) => sig.sign_userid_binding( &mut KeyPair::new(&key, mpis)?, &key, &uid, HashAlgorithm::SHA512)?, - None => sig.sign_primary_key_binding(&key, mpis, HashAlgorithm::SHA512)?, + None => sig.sign_primary_key_binding( + &mut KeyPair::new(&key, mpis)?, + HashAlgorithm::SHA512)?, } } Some(SecretKey::Encrypted{ .. }) => { -- cgit v1.2.3