diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2021-04-30 15:09:43 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2021-04-30 15:12:09 +0200 |
commit | 9e7b58e610dab6e97bba8adbe661ed3fb954ed2b (patch) | |
tree | 3d0750c7de046681f936eec26ebb097414aae6b9 /openpgp/src/cert | |
parent | a5395138020eaf5b2681e539e449c4042cbff706 (diff) |
openpgp: Reuse the signer.
Diffstat (limited to 'openpgp/src/cert')
-rw-r--r-- | openpgp/src/cert/builder.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/openpgp/src/cert/builder.rs b/openpgp/src/cert/builder.rs index 0864a0fb..7f65c5ab 100644 --- a/openpgp/src/cert/builder.rs +++ b/openpgp/src/cert/builder.rs @@ -12,7 +12,7 @@ use crate::packet::Signature; use crate::packet::signature; use crate::cert::prelude::*; use crate::Error; -use crate::crypto::Password; +use crate::crypto::{Password, Signer}; use crate::types::{ Features, HashAlgorithm, @@ -965,8 +965,7 @@ impl CertBuilder<'_> { } // Generate & self-sign primary key. - let (primary, sig) = self.primary_key(creation_time)?; - let mut signer = primary.clone().into_keypair().unwrap(); + let (primary, sig, mut signer) = self.primary_key(creation_time)?; let mut cert = Cert::try_from(vec![ Packet::SecretKey({ @@ -1067,8 +1066,9 @@ impl CertBuilder<'_> { Ok((cert, revocation)) } + /// Creates the primary key and a direct key signature. fn primary_key(&self, creation_time: std::time::SystemTime) - -> Result<(key::SecretKey, Signature)> + -> Result<(key::SecretKey, Signature, Box<dyn Signer>)> { let mut key = self.primary.ciphersuite .unwrap_or(self.ciphersuite) @@ -1098,7 +1098,7 @@ impl CertBuilder<'_> { .expect("key generated above has a secret"); let sig = sig.sign_direct_key(&mut signer, key.parts_as_public())?; - Ok((key, sig)) + Ok((key, sig, Box::new(signer))) } } |