pub struct PrivateKeyInfo<Params, Key, PubKey> {
pub algorithm: AlgorithmIdentifier<Params>,
pub private_key: Key,
pub public_key: Option<PubKey>,
}pkcs8 only.Expand description
PKCS#8 PrivateKeyInfo.
ASN.1 structure containing an AlgorithmIdentifier, private key
data in an algorithm specific format, and optional attributes
(ignored by this implementation).
Supports PKCS#8 v1 as described in RFC 5208 and PKCS#8 v2 as described in RFC 5958. PKCS#8 v2 keys include an additional public key field.
§PKCS#8 v1 PrivateKeyInfo
Described in RFC 5208 Section 5:
PrivateKeyInfo ::= SEQUENCE {
version Version,
privateKeyAlgorithm PrivateKeyAlgorithmIdentifier,
privateKey PrivateKey,
attributes [0] IMPLICIT Attributes OPTIONAL }
Version ::= INTEGER
PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier
PrivateKey ::= OCTET STRING
Attributes ::= SET OF Attribute§PKCS#8 v2 OneAsymmetricKey
PKCS#8 OneAsymmetricKey as described in RFC 5958 Section 2:
PrivateKeyInfo ::= OneAsymmetricKey
OneAsymmetricKey ::= SEQUENCE {
version Version,
privateKeyAlgorithm PrivateKeyAlgorithmIdentifier,
privateKey PrivateKey,
attributes [0] Attributes OPTIONAL,
...,
[[2: publicKey [1] PublicKey OPTIONAL ]],
...
}
Version ::= INTEGER { v1(0), v2(1) } (v1, ..., v2)
PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier
PrivateKey ::= OCTET STRING
Attributes ::= SET OF Attribute
PublicKey ::= BIT STRINGFields§
§algorithm: AlgorithmIdentifier<Params>X.509 AlgorithmIdentifier for the private key type.
private_key: KeyPrivate key data. Exact content format is different between algorithms.
public_key: Option<PubKey>Public key data, optionally available if version is V2.
Implementations§
Source§impl<Params, Key, PubKey> PrivateKeyInfo<Params, Key, PubKey>
impl<Params, Key, PubKey> PrivateKeyInfo<Params, Key, PubKey>
Sourcepub fn new(
algorithm: AlgorithmIdentifier<Params>,
private_key: Key,
) -> PrivateKeyInfo<Params, Key, PubKey>
pub fn new( algorithm: AlgorithmIdentifier<Params>, private_key: Key, ) -> PrivateKeyInfo<Params, Key, PubKey>
Create a new PKCS#8 PrivateKeyInfo message.
This is a helper method which initializes attributes and public_key
to None, helpful if you aren’t using those.
Sourcepub fn version(&self) -> Version
pub fn version(&self) -> Version
Get the PKCS#8 Version for this structure.
Version::V1 if public_key is None, Version::V2 if Some.
Trait Implementations§
Source§impl<Params, Key, PubKey> Clone for PrivateKeyInfo<Params, Key, PubKey>
impl<Params, Key, PubKey> Clone for PrivateKeyInfo<Params, Key, PubKey>
Source§fn clone(&self) -> PrivateKeyInfo<Params, Key, PubKey>
fn clone(&self) -> PrivateKeyInfo<Params, Key, PubKey>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<Params, Key, PubKey> Debug for PrivateKeyInfo<Params, Key, PubKey>
impl<Params, Key, PubKey> Debug for PrivateKeyInfo<Params, Key, PubKey>
Source§impl DecodePrivateKey for PrivateKeyInfo<Any, OctetString, BitString>
impl DecodePrivateKey for PrivateKeyInfo<Any, OctetString, BitString>
Source§fn from_pkcs8_der(
bytes: &[u8],
) -> Result<PrivateKeyInfo<Any, OctetString, BitString>, Error>
fn from_pkcs8_der( bytes: &[u8], ) -> Result<PrivateKeyInfo<Any, OctetString, BitString>, Error>
Source§impl<'a, Params, Key, PubKey> DecodeValue<'a> for PrivateKeyInfo<Params, Key, PubKey>where
Params: Choice<'a, Error = Error> + Encode,
Key: DecodeValue<'a, Error = Error> + FixedTag + 'a,
PubKey: DecodeValue<'a, Error = Error> + FixedTag + 'a,
impl<'a, Params, Key, PubKey> DecodeValue<'a> for PrivateKeyInfo<Params, Key, PubKey>where
Params: Choice<'a, Error = Error> + Encode,
Key: DecodeValue<'a, Error = Error> + FixedTag + 'a,
PubKey: DecodeValue<'a, Error = Error> + FixedTag + 'a,
Source§impl EncodePrivateKey for PrivateKeyInfo<Any, OctetString, BitString>
impl EncodePrivateKey for PrivateKeyInfo<Any, OctetString, BitString>
Source§fn to_pkcs8_der(&self) -> Result<SecretDocument, Error>
fn to_pkcs8_der(&self) -> Result<SecretDocument, Error>
SecretDocument containing a PKCS#8-encoded private key. Read moreSource§impl EncodePrivateKey for PrivateKeyInfo<AnyRef<'_>, &OctetStringRef, BitStringRef<'_>>
impl EncodePrivateKey for PrivateKeyInfo<AnyRef<'_>, &OctetStringRef, BitStringRef<'_>>
Source§fn to_pkcs8_der(&self) -> Result<SecretDocument, Error>
fn to_pkcs8_der(&self) -> Result<SecretDocument, Error>
SecretDocument containing a PKCS#8-encoded private key. Read moreSource§impl<'a, Params, Key, PubKey> EncodeValue for PrivateKeyInfo<Params, Key, PubKey>where
Params: Choice<'a, Error = Error> + Encode,
Key: EncodeValue + FixedTag,
PubKey: BitStringLike,
impl<'a, Params, Key, PubKey> EncodeValue for PrivateKeyInfo<Params, Key, PubKey>where
Params: Choice<'a, Error = Error> + Encode,
Key: EncodeValue + FixedTag,
PubKey: BitStringLike,
Source§impl OwnedToRef for PrivateKeyInfo<Any, OctetString, BitString>
impl OwnedToRef for PrivateKeyInfo<Any, OctetString, BitString>
Source§type Borrowed<'a> = PrivateKeyInfo<AnyRef<'a>, &'a OctetStringRef, BitStringRef<'a>>
type Borrowed<'a> = PrivateKeyInfo<AnyRef<'a>, &'a OctetStringRef, BitStringRef<'a>>
Source§fn owned_to_ref(
&self,
) -> <PrivateKeyInfo<Any, OctetString, BitString> as OwnedToRef>::Borrowed<'_>
fn owned_to_ref( &self, ) -> <PrivateKeyInfo<Any, OctetString, BitString> as OwnedToRef>::Borrowed<'_>
Source§impl<'a> RefToOwned<'a> for PrivateKeyInfo<AnyRef<'a>, &'a OctetStringRef, BitStringRef<'a>>
impl<'a> RefToOwned<'a> for PrivateKeyInfo<AnyRef<'a>, &'a OctetStringRef, BitStringRef<'a>>
Source§type Owned = PrivateKeyInfo<Any, OctetString, BitString>
type Owned = PrivateKeyInfo<Any, OctetString, BitString>
Source§fn ref_to_owned(
&self,
) -> <PrivateKeyInfo<AnyRef<'a>, &'a OctetStringRef, BitStringRef<'a>> as RefToOwned<'a>>::Owned
fn ref_to_owned( &self, ) -> <PrivateKeyInfo<AnyRef<'a>, &'a OctetStringRef, BitStringRef<'a>> as RefToOwned<'a>>::Owned
Source§impl<'a, Params, Key, PubKey> TryFrom<&'a [u8]> for PrivateKeyInfo<Params, Key, PubKey>where
Params: Choice<'a, Error = Error> + Encode,
Key: DecodeValue<'a, Error = Error> + FixedTag + 'a + EncodeValue,
PubKey: DecodeValue<'a, Error = Error> + FixedTag + 'a + BitStringLike,
impl<'a, Params, Key, PubKey> TryFrom<&'a [u8]> for PrivateKeyInfo<Params, Key, PubKey>where
Params: Choice<'a, Error = Error> + Encode,
Key: DecodeValue<'a, Error = Error> + FixedTag + 'a + EncodeValue,
PubKey: DecodeValue<'a, Error = Error> + FixedTag + 'a + BitStringLike,
Source§impl<'a, Params, Key, PubKey> TryFrom<&PrivateKeyInfo<Params, Key, PubKey>> for SecretDocumentwhere
Params: Choice<'a, Error = Error> + Encode,
Key: DecodeValue<'a, Error = Error> + FixedTag + 'a + EncodeValue,
PubKey: DecodeValue<'a, Error = Error> + FixedTag + 'a + BitStringLike,
Available on crate feature alloc only.
impl<'a, Params, Key, PubKey> TryFrom<&PrivateKeyInfo<Params, Key, PubKey>> for SecretDocumentwhere
Params: Choice<'a, Error = Error> + Encode,
Key: DecodeValue<'a, Error = Error> + FixedTag + 'a + EncodeValue,
PubKey: DecodeValue<'a, Error = Error> + FixedTag + 'a + BitStringLike,
alloc only.Source§impl<P> TryFrom<PrivateKeyInfo<AnyRef<'_>, &OctetStringRef, BitStringRef<'_>>> for ExpandedSigningKey<P>
impl<P> TryFrom<PrivateKeyInfo<AnyRef<'_>, &OctetStringRef, BitStringRef<'_>>> for ExpandedSigningKey<P>
Source§impl<P> TryFrom<PrivateKeyInfo<AnyRef<'_>, &OctetStringRef, BitStringRef<'_>>> for SigningKey<P>
impl<P> TryFrom<PrivateKeyInfo<AnyRef<'_>, &OctetStringRef, BitStringRef<'_>>> for SigningKey<P>
Source§impl<'a, Params, Key, PubKey> TryFrom<PrivateKeyInfo<Params, Key, PubKey>> for SecretDocumentwhere
Params: Choice<'a, Error = Error> + Encode,
Key: DecodeValue<'a, Error = Error> + FixedTag + 'a + EncodeValue,
PubKey: DecodeValue<'a, Error = Error> + FixedTag + 'a + BitStringLike,
Available on crate feature alloc only.
impl<'a, Params, Key, PubKey> TryFrom<PrivateKeyInfo<Params, Key, PubKey>> for SecretDocumentwhere
Params: Choice<'a, Error = Error> + Encode,
Key: DecodeValue<'a, Error = Error> + FixedTag + 'a + EncodeValue,
PubKey: DecodeValue<'a, Error = Error> + FixedTag + 'a + BitStringLike,
alloc only.