summaryrefslogtreecommitdiffstats
path: root/openpgp
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-11-22 17:55:05 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-11-22 17:55:05 +0100
commit4e8b4a32e995d0a761dda5202bbdac9987b2ffb9 (patch)
treef1c04c955f5cdfa3a7dd966226329e9249f231c9 /openpgp
parentc2115cf5a9af460e04cacc1723b61df5ab9c0343 (diff)
openpgp: Make it possible to bind secret keys.
Diffstat (limited to 'openpgp')
-rw-r--r--openpgp/src/crypto/hash.rs10
-rw-r--r--openpgp/src/packet/signature/mod.rs9
2 files changed, 11 insertions, 8 deletions
diff --git a/openpgp/src/crypto/hash.rs b/openpgp/src/crypto/hash.rs
index d35394b9..e9e80459 100644
--- a/openpgp/src/crypto/hash.rs
+++ b/openpgp/src/crypto/hash.rs
@@ -1,6 +1,7 @@
//! Functionality to hash packets, and generate hashes.
use crate::HashAlgorithm;
+use crate::packet::Key;
use crate::packet::UserID;
use crate::packet::UserAttribute;
use crate::packet::key;
@@ -388,11 +389,12 @@ impl Signature {
/// Returns the message digest of the subkey binding over the
/// specified primary key and subkey.
- pub fn subkey_binding_hash<'a, S>(sig: S,
- key: &key::PublicKey,
- subkey: &key::PublicSubkey)
+ pub fn subkey_binding_hash<'a, P, S>(sig: S,
+ key: &key::PublicKey,
+ subkey: &Key<P, key::SubordinateRole>)
-> Result<Vec<u8>>
- where S: Into<&'a signature::Builder>
+ where P: key::KeyParts,
+ S: Into<&'a signature::Builder>
{
let sig = sig.into();
diff --git a/openpgp/src/packet/signature/mod.rs b/openpgp/src/packet/signature/mod.rs
index 211a4447..7b9e52f3 100644
--- a/openpgp/src/packet/signature/mod.rs
+++ b/openpgp/src/packet/signature/mod.rs
@@ -172,11 +172,12 @@ 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_subkey_binding<R>(mut self, signer: &mut dyn Signer<R>,
- primary: &key::PublicKey,
- subkey: &key::PublicSubkey)
+ pub fn sign_subkey_binding<P, R>(mut self, signer: &mut dyn Signer<R>,
+ primary: &key::PublicKey,
+ subkey: &Key<P, key::SubordinateRole>)
-> Result<Signature>
- where R: key::KeyRole
+ where P: key:: KeyParts,
+ R: key::KeyRole
{
self.pk_algo = signer.public().pk_algo();
let digest = Signature::subkey_binding_hash(&self, primary, subkey)?;