pub struct SigningKey { /* private fields */ }Expand description
DSA private key.
The (try_)sign_digest_with_rng API uses regular non-deterministic signatures,
while the (try_)sign_digest API uses deterministic signatures as described in RFC 6979
Implementations§
Source§impl SigningKey
impl SigningKey
Sourcepub fn from_components(verifying_key: VerifyingKey, x: BigUint) -> Result<Self>
pub fn from_components(verifying_key: VerifyingKey, x: BigUint) -> Result<Self>
Construct a new private key from the public key and private component
Sourcepub fn generate(
rng: &mut impl CryptoRngCore,
components: Components,
) -> SigningKey
pub fn generate( rng: &mut impl CryptoRngCore, components: Components, ) -> SigningKey
Generate a new DSA keypair
Sourcepub const fn verifying_key(&self) -> &VerifyingKey
pub const fn verifying_key(&self) -> &VerifyingKey
DSA public key
Sourcepub fn x(&self) -> &BigUint
pub fn x(&self) -> &BigUint
DSA private component
If you decide to clone this value, please consider using Zeroize::zeroize to zero out the memory after you’re done using the clone
Sourcepub fn sign_prehashed_rfc6979<D>(
&self,
prehash: &[u8],
) -> Result<Signature, Error>where
D: Digest + BlockSizeUser + FixedOutputReset,
pub fn sign_prehashed_rfc6979<D>(
&self,
prehash: &[u8],
) -> Result<Signature, Error>where
D: Digest + BlockSizeUser + FixedOutputReset,
Try to sign the given message digest deterministically with a prehashed digest.
The parameter D must match the hash function used to sign the digest.
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<D> DigestSigner<D, Signature> for SigningKeywhere
D: Digest + BlockSizeUser + FixedOutputReset,
impl<D> DigestSigner<D, Signature> for SigningKeywhere
D: Digest + BlockSizeUser + FixedOutputReset,
Source§fn try_sign_digest(&self, digest: D) -> Result<Signature, Error>
fn try_sign_digest(&self, digest: D) -> Result<Signature, Error>
Attempt to sign the given prehashed message
Digest, returning a
digital signature on success, or an error if something went wrong.Source§fn sign_digest(&self, digest: D) -> S
fn sign_digest(&self, digest: D) -> S
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 PartialEq for SigningKey
impl PartialEq for SigningKey
Source§fn eq(&self, other: &SigningKey) -> bool
fn eq(&self, other: &SigningKey) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PrehashSigner<Signature> for SigningKey
impl PrehashSigner<Signature> for SigningKey
Source§fn sign_prehash(&self, prehash: &[u8]) -> Result<Signature, Error>
fn sign_prehash(&self, prehash: &[u8]) -> Result<Signature, Error>
Warning: This uses sha2::Sha256 as the hash function for the digest. If you need to use a different one, use SigningKey::sign_prehashed_rfc6979.
Source§impl<D> RandomizedDigestSigner<D, Signature> for SigningKeywhere
D: Digest,
impl<D> RandomizedDigestSigner<D, Signature> for SigningKeywhere
D: Digest,
Source§fn try_sign_digest_with_rng(
&self,
rng: &mut impl CryptoRngCore,
digest: D,
) -> Result<Signature, Error>
fn try_sign_digest_with_rng( &self, rng: &mut impl CryptoRngCore, digest: D, ) -> Result<Signature, Error>
Attempt to sign the given prehashed message
Digest, returning a
digital signature on success, or an error if something went wrong.Source§fn sign_digest_with_rng(&self, rng: &mut impl CryptoRngCore, digest: D) -> S
fn sign_digest_with_rng(&self, rng: &mut impl CryptoRngCore, digest: D) -> S
Sign the given prehashed message
Digest, returning a signature. Read moreSource§impl RandomizedPrehashSigner<Signature> for SigningKey
impl RandomizedPrehashSigner<Signature> for SigningKey
Source§fn sign_prehash_with_rng(
&self,
rng: &mut impl CryptoRngCore,
prehash: &[u8],
) -> Result<Signature, Error>
fn sign_prehash_with_rng( &self, rng: &mut impl CryptoRngCore, prehash: &[u8], ) -> Result<Signature, Error>
Attempt to sign the given message digest, returning a digital signature
on success, or an error if something went wrong. Read more
Source§impl Signer<Signature> for SigningKey
impl Signer<Signature> for SigningKey
Source§impl<'a> TryFrom<PrivateKeyInfo<'a>> for SigningKey
impl<'a> TryFrom<PrivateKeyInfo<'a>> for SigningKey
impl StructuralPartialEq 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> DecodePrivateKey for T
impl<T> DecodePrivateKey for T
Source§fn from_pkcs8_der(bytes: &[u8]) -> Result<T, Error>
fn from_pkcs8_der(bytes: &[u8]) -> Result<T, Error>
Deserialize PKCS#8 private key from ASN.1 DER-encoded data
(binary format).
Source§fn from_pkcs8_pem(s: &str) -> Result<Self, Error>
fn from_pkcs8_pem(s: &str) -> Result<Self, Error>
Deserialize PKCS#8-encoded private key from PEM. Read more