Struct dsa::SigningKey
source · 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 copy of the value. Read more
1.0.0 · 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§impl PartialEq for SigningKey
impl PartialEq for SigningKey
source§fn eq(&self, other: &SigningKey) -> bool
fn eq(&self, other: &SigningKey) -> bool
This method 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 RefUnwindSafe for SigningKey
impl Send for SigningKey
impl Sync for SigningKey
impl Unpin 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