#[non_exhaustive]pub enum SigningKey {
RsaWithSha1(SigningKey<Sha1>),
RsaWithSha256(SigningKey<Sha256>),
RsaWithSha384(SigningKey<Sha384>),
EcP256(SigningKey),
EcP384(SigningKey),
}Expand description
A signing key for any algorithm supported by the crate.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
RsaWithSha1(SigningKey<Sha1>)
PKCS#1 v1.5 RSA signing key which uses SHA-1 as the digest.
RsaWithSha256(SigningKey<Sha256>)
PKCS#1 v1.5 RSA signing key which uses SHA-256 as the digest.
RsaWithSha384(SigningKey<Sha384>)
PKCS#1 v1.5 RSA signing key which uses SHA-384 as the digest.
EcP256(SigningKey)
ECDSA/P-256 signing key (uses SHA-256 as the digest primitive).
EcP384(SigningKey)
ECDSA/P-384 signing key (uses SHA-384 as the digest primitive).
Implementations§
Source§impl SigningKey
impl SigningKey
Sourcepub fn from_key_and_algo(
key: PrivateKey,
algo: Option<DigestAlgo>,
) -> Result<Self, UnsupportedDigest>
pub fn from_key_and_algo( key: PrivateKey, algo: Option<DigestAlgo>, ) -> Result<Self, UnsupportedDigest>
Creates a new SigningKey from a PrivateKey and a DigestAlgo.
If no digest algorithm is provided, a default one is used.
For RSA PKCS#1 v1.5 signatures the default is SHA-384, for elliptic curve algorithms the default and the only supported digest algorithms are SHA-256 for NIST P-256 and SHA-384 for NIST P-384.
Trait Implementations§
Source§impl Clone for SigningKey
impl Clone for SigningKey
Source§fn clone(&self) -> SigningKey
fn clone(&self) -> SigningKey
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SigningKey
impl Debug for SigningKey
Source§impl DynSignatureAlgorithmIdentifier for SigningKey
impl DynSignatureAlgorithmIdentifier for SigningKey
Source§fn signature_algorithm_identifier(&self) -> Result<AlgorithmIdentifierOwned>
fn signature_algorithm_identifier(&self) -> Result<AlgorithmIdentifierOwned>
AlgorithmIdentifier for the corresponding singature system.Source§impl EncodePrivateKey for SigningKey
impl EncodePrivateKey for SigningKey
Source§fn to_pkcs8_der(&self) -> Result<SecretDocument>
fn to_pkcs8_der(&self) -> Result<SecretDocument>
Serialize a
SecretDocument containing a PKCS#8-encoded private key.Source§fn to_pkcs8_pem(
&self,
line_ending: LineEnding,
) -> Result<Zeroizing<String>, Error>
fn to_pkcs8_pem( &self, line_ending: LineEnding, ) -> Result<Zeroizing<String>, Error>
Serialize this private key as PEM-encoded PKCS#8 with the given
LineEnding.Source§fn write_pkcs8_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>
fn write_pkcs8_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>
Write ASN.1 DER-encoded PKCS#8 private key to the given path
Source§fn write_pkcs8_pem_file(
&self,
path: impl AsRef<Path>,
line_ending: LineEnding,
) -> Result<(), Error>
fn write_pkcs8_pem_file( &self, path: impl AsRef<Path>, line_ending: LineEnding, ) -> Result<(), Error>
Write ASN.1 DER-encoded PKCS#8 private key to the given path
Source§impl From<SigningKey> for PrivateKey
impl From<SigningKey> for PrivateKey
Source§fn from(value: SigningKey) -> Self
fn from(value: SigningKey) -> Self
Converts to this type from the input type.
Source§impl Keypair for SigningKey
impl Keypair for SigningKey
Source§type VerifyingKey = VerifyingKey
type VerifyingKey = VerifyingKey
Verifying key type for this keypair.
Source§fn verifying_key(&self) -> Self::VerifyingKey
fn verifying_key(&self) -> Self::VerifyingKey
Get the verifying key which can verify signatures produced by the
signing key portion of this keypair.
Source§impl Signer<Signature> for SigningKey
impl Signer<Signature> for SigningKey
Auto Trait Implementations§
impl Freeze for SigningKey
impl RefUnwindSafe for SigningKey
impl Send for SigningKey
impl Sync for SigningKey
impl Unpin for SigningKey
impl UnsafeUnpin for SigningKey
impl UnwindSafe for SigningKey
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> EncodeEcPrivateKey for Twhere
T: EncodePrivateKey,
impl<T> EncodeEcPrivateKey for Twhere
T: EncodePrivateKey,
Source§fn to_sec1_der(&self) -> Result<SecretDocument, Error>
fn to_sec1_der(&self) -> Result<SecretDocument, Error>
Serialize a
SecretDocument containing a SEC1-encoded private key.Source§fn to_sec1_pem(
&self,
line_ending: LineEnding,
) -> Result<Zeroizing<String>, Error>
fn to_sec1_pem( &self, line_ending: LineEnding, ) -> Result<Zeroizing<String>, Error>
Serialize this private key as PEM-encoded SEC1 with the given
LineEnding. Read moreSource§fn write_sec1_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>
fn write_sec1_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>
Write ASN.1 DER-encoded SEC1 private key to the given path.
Source§fn write_sec1_pem_file(
&self,
path: impl AsRef<Path>,
line_ending: LineEnding,
) -> Result<(), Error>
fn write_sec1_pem_file( &self, path: impl AsRef<Path>, line_ending: LineEnding, ) -> Result<(), Error>
Write ASN.1 DER-encoded SEC1 private key to the given path.
Source§impl<T> EncodeRsaPrivateKey for Twhere
T: EncodePrivateKey,
impl<T> EncodeRsaPrivateKey for Twhere
T: EncodePrivateKey,
Source§fn to_pkcs1_der(&self) -> Result<SecretDocument, Error>
fn to_pkcs1_der(&self) -> Result<SecretDocument, Error>
Serialize a
SecretDocument containing a PKCS#1-encoded private key.Source§fn to_pkcs1_pem(
&self,
line_ending: LineEnding,
) -> Result<Zeroizing<String>, Error>
fn to_pkcs1_pem( &self, line_ending: LineEnding, ) -> Result<Zeroizing<String>, Error>
Serialize this private key as PEM-encoded PKCS#1 with the given
LineEnding.Source§fn write_pkcs1_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>
fn write_pkcs1_der_file(&self, path: impl AsRef<Path>) -> Result<(), Error>
Write ASN.1 DER-encoded PKCS#1 private key to the given path.
Source§fn write_pkcs1_pem_file(
&self,
path: impl AsRef<Path>,
line_ending: LineEnding,
) -> Result<(), Error>
fn write_pkcs1_pem_file( &self, path: impl AsRef<Path>, line_ending: LineEnding, ) -> Result<(), Error>
Write ASN.1 DER-encoded PKCS#1 private key to the given path.