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

source

pub fn from_components(verifying_key: VerifyingKey, x: BigUint) -> Result<Self>

Construct a new private key from the public key and private component

source

pub fn generate( rng: &mut impl CryptoRngCore, components: Components ) -> SigningKey

Generate a new DSA keypair

source

pub const fn verifying_key(&self) -> &VerifyingKey

DSA public key

source

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

source

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

source§

fn clone(&self) -> SigningKey

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for SigningKey

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<D> DigestSigner<D, Signature> for SigningKey
where D: Digest + BlockSizeUser + FixedOutputReset,

source§

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

Sign the given prehashed message Digest, returning a signature. Read more
source§

impl EncodePrivateKey for SigningKey

source§

fn to_pkcs8_der(&self) -> Result<SecretDocument>

Serialize a [SecretDocument] containing a PKCS#8-encoded private key.
source§

impl PartialEq for SigningKey

source§

fn eq(&self, other: &SigningKey) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PrehashSigner<Signature> for SigningKey

source§

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 SigningKey
where D: Digest,

source§

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

Sign the given prehashed message Digest, returning a signature. Read more
source§

impl RandomizedPrehashSigner<Signature> for SigningKey

source§

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

source§

fn try_sign(&self, msg: &[u8]) -> Result<Signature, Error>

Attempt to sign the given message, returning a digital signature on success, or an error if something went wrong. Read more
source§

fn sign(&self, msg: &[u8]) -> S

Sign the given message and return a digital signature
source§

impl<'a> TryFrom<PrivateKeyInfo<'a>> for SigningKey

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(value: PrivateKeyInfo<'a>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl StructuralPartialEq for SigningKey

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> DecodePrivateKey for T
where T: for<'a> TryFrom<PrivateKeyInfo<'a>, Error = Error>,

source§

fn from_pkcs8_der(bytes: &[u8]) -> Result<T, Error>

Deserialize PKCS#8 private key from ASN.1 DER-encoded data (binary format).
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<S, T> SignerMut<S> for T
where T: Signer<S>,

source§

fn try_sign(&mut self, msg: &[u8]) -> Result<S, Error>

Attempt to sign the given message, updating the state, and returning a digital signature on success, or an error if something went wrong. Read more
source§

fn sign(&mut self, msg: &[u8]) -> S

Sign the given message, update the state, and return a digital signature.
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V