pub struct PrivateKeyInfo<Params, Key, PubKey> {
pub algorithm: AlgorithmIdentifier<Params>,
pub private_key: Key,
pub public_key: Option<PubKey>,
}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) -> Self
pub fn new(algorithm: AlgorithmIdentifier<Params>, private_key: Key) -> Self
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.
Source§impl<'a, Params, Key, PubKey> PrivateKeyInfo<Params, Key, PubKey>
impl<'a, Params, Key, PubKey> PrivateKeyInfo<Params, Key, PubKey>
Sourcefn public_key_bit_string(&self) -> Option<ContextSpecific<BitStringRef<'_>>>
fn public_key_bit_string(&self) -> Option<ContextSpecific<BitStringRef<'_>>>
Get a BIT STRING representation of the public key, if present.
Trait Implementations§
Source§impl<Params: Clone, Key: Clone, PubKey: Clone> Clone for PrivateKeyInfo<Params, Key, PubKey>
impl<Params: Clone, Key: Clone, PubKey: Clone> Clone for PrivateKeyInfo<Params, Key, PubKey>
Source§fn clone(&self) -> PrivateKeyInfo<Params, Key, PubKey>
fn clone(&self) -> PrivateKeyInfo<Params, Key, PubKey>
1.0.0 · 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<'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<'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<Params, Key, PubKey> PemLabel for PrivateKeyInfo<Params, Key, PubKey>
Available on crate feature pem only.
impl<Params, Key, PubKey> PemLabel for PrivateKeyInfo<Params, Key, PubKey>
pem only.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§fn try_from(
private_key: &PrivateKeyInfo<Params, Key, PubKey>,
) -> Result<SecretDocument>
fn try_from( private_key: &PrivateKeyInfo<Params, Key, PubKey>, ) -> Result<SecretDocument>
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.