summaryrefslogtreecommitdiffstats
path: root/vendor/spki/src
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/spki/src')
-rw-r--r--vendor/spki/src/spki.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/vendor/spki/src/spki.rs b/vendor/spki/src/spki.rs
index 3d949f887..b7e4c9280 100644
--- a/vendor/spki/src/spki.rs
+++ b/vendor/spki/src/spki.rs
@@ -181,6 +181,7 @@ impl<Params, Key> PemLabel for SubjectPublicKeyInfo<Params, Key> {
#[cfg(feature = "alloc")]
mod allocating {
use super::*;
+ use crate::EncodePublicKey;
use der::referenced::*;
impl<'a> RefToOwned<'a> for SubjectPublicKeyInfoRef<'a> {
@@ -202,4 +203,15 @@ mod allocating {
}
}
}
+
+ impl SubjectPublicKeyInfoOwned {
+ /// Create a [`SubjectPublicKeyInfoOwned`] from any object that implements
+ /// [`EncodePublicKey`].
+ pub fn from_key<T>(source: T) -> Result<Self>
+ where
+ T: EncodePublicKey,
+ {
+ Ok(source.to_public_key_der()?.decode_msg::<Self>()?)
+ }
+ }
}