pub trait DerPrivateKey: PrivateKey + DerKey {
// Provided methods
fn marshal_to_der(&self) -> Vec<u8> { ... }
fn parse_from_der(bytes: &[u8]) -> Result<Self, Error> { ... }
}
Expand description
A private key which can be encoded as a DER object.
Provided Methods§
Sourcefn marshal_to_der(&self) -> Vec<u8>
fn marshal_to_der(&self) -> Vec<u8>
Marshals a private key in DER format.
marshal_to_der
marshal a private key as a DER-encoded structure. The
exact structure encoded depends on the type of key:
Sourcefn parse_from_der(bytes: &[u8]) -> Result<Self, Error>
fn parse_from_der(bytes: &[u8]) -> Result<Self, Error>
Parses a private key in DER format.
parse_from_der
parses a private key from a DER-encoded format. The
exact structure expected depends on the type of key:
- For an EC key, it is an ECPrivateKey structure as defined in RFC 5915.
- For an RSA key, it is an RSAPrivateKey structure as defined in RFC 3447.
§Elliptic Curve Keys
For Elliptic Curve keys (EcPrivKey
), the curve itself is validated. If
the curve is not known ahead of time, and any curve must be supported at
runtime, use the EcPrivKeyAnyCurve::parse_from_der
function.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.