pub enum InMemorySigningKeyPair {
Ecdsa(EcdsaKeyPair, EcdsaCurve, Vec<u8>),
Ed25519(Ed25519KeyPair),
Rsa(RsaKeyPair, Vec<u8>),
}
Expand description
Represents a key pair that exists in memory and can be used to create cryptographic signatures.
This is a wrapper around ring’s various key pair types. It provides abstractions tailored for X.509 certificates.
Variants
Ecdsa(EcdsaKeyPair, EcdsaCurve, Vec<u8>)
ECDSA key pair.
Ed25519(Ed25519KeyPair)
ED25519 key pair.
Rsa(RsaKeyPair, Vec<u8>)
RSA key pair.
Implementations
sourceimpl InMemorySigningKeyPair
impl InMemorySigningKeyPair
sourcepub fn from_pkcs8_der(data: impl AsRef<[u8]>) -> Result<Self, Error>
pub fn from_pkcs8_der(data: impl AsRef<[u8]>) -> Result<Self, Error>
Attempt to instantiate an instance from PKCS#8 DER data.
The DER data should be a OneAsymmetricKey ASN.1 structure.
sourcepub fn from_pkcs8_pem(data: impl AsRef<[u8]>) -> Result<Self, Error>
pub fn from_pkcs8_pem(data: impl AsRef<[u8]>) -> Result<Self, Error>
Attempt to instantiate an instance from PEM encoded PKCS#8.
This is just a wrapper for Self::from_pkcs8_der that does the PEM decoding for you.
sourcepub fn generate_random(
key_algorithm: KeyAlgorithm
) -> Result<(Self, Document), Error>
pub fn generate_random(
key_algorithm: KeyAlgorithm
) -> Result<(Self, Document), Error>
Generate a random key pair given a key algorithm and optional ECDSA signing algorithm.
The raw PKCS#8 document is returned to facilitate access to the private key.
Not attempt is made to protect the private key in memory.
sourcepub fn verification_algorithm(
&self
) -> Result<&'static dyn VerificationAlgorithm, Error>
pub fn verification_algorithm(
&self
) -> Result<&'static dyn VerificationAlgorithm, Error>
Attempt to resolve a verification algorithm for this key pair.
This is a wrapper around SignatureAlgorithm::resolve_verification_algorithm()
with our bound KeyAlgorithm. However, since there are no parameters
that can result in wrong choices, this is guaranteed to always work
and doesn’t require Result
.
Trait Implementations
sourceimpl Debug for InMemorySigningKeyPair
impl Debug for InMemorySigningKeyPair
sourceimpl From<&'_ InMemorySigningKeyPair> for KeyAlgorithm
impl From<&'_ InMemorySigningKeyPair> for KeyAlgorithm
sourcefn from(key: &InMemorySigningKeyPair) -> Self
fn from(key: &InMemorySigningKeyPair) -> Self
Converts to this type from the input type.
sourceimpl From<Ed25519KeyPair> for InMemorySigningKeyPair
impl From<Ed25519KeyPair> for InMemorySigningKeyPair
sourcefn from(key: Ed25519KeyPair) -> Self
fn from(key: Ed25519KeyPair) -> Self
Converts to this type from the input type.
sourceimpl Sign for InMemorySigningKeyPair
impl Sign for InMemorySigningKeyPair
sourcefn sign(&self, message: &[u8]) -> Result<(Vec<u8>, SignatureAlgorithm), Error>
👎 Deprecated since 0.13.0: use the signature::Signer trait instead
fn sign(&self, message: &[u8]) -> Result<(Vec<u8>, SignatureAlgorithm), Error>
use the signature::Signer trait instead
This will use a new instance of ring’s SystemRandom. The RSA padding algorithm is hard-coded to RSA_PCS1_SHA256.
If you want total control over signing parameters, obtain the
underlying ring keypair and call its .sign()
.
sourcefn key_algorithm(&self) -> Option<KeyAlgorithm>
fn key_algorithm(&self) -> Option<KeyAlgorithm>
Obtain the algorithm of the private key. Read more
sourcefn public_key_data(&self) -> Bytes
fn public_key_data(&self) -> Bytes
Obtain the raw bytes constituting the public key of the signing certificate. Read more
sourcefn signature_algorithm(&self) -> Result<SignatureAlgorithm, Error>
fn signature_algorithm(&self) -> Result<SignatureAlgorithm, Error>
Obtain the SignatureAlgorithm that this signer will use. Read more
sourcefn private_key_data(&self) -> Option<Vec<u8>>
fn private_key_data(&self) -> Option<Vec<u8>>
Obtain the raw private key data.
sourceimpl Signer<Signature> for InMemorySigningKeyPair
impl Signer<Signature> for InMemorySigningKeyPair
impl KeyInfoSigner for InMemorySigningKeyPair
Auto Trait Implementations
impl RefUnwindSafe for InMemorySigningKeyPair
impl Send for InMemorySigningKeyPair
impl Sync for InMemorySigningKeyPair
impl Unpin for InMemorySigningKeyPair
impl UnwindSafe for InMemorySigningKeyPair
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more