Skip to main content

GenericSigningKey

Struct GenericSigningKey 

Source
pub struct GenericSigningKey<D, T, M>
where D: Digest, T: UnsignedModularInt + Zeroize, M: ModulusParams<Modulus = T>,
{ /* private fields */ }
Expand description

Signing key for RSASSA-PKCS1-v1_5 signatures — heapless variant.

Generic over the digest D, integer type T, and Montgomery parameters M. Holds a GenericRsaPrivateKey<T, M> plus the precomputed DigestInfo prefix for D.

Implementations§

Source§

impl<D, T, M> GenericSigningKey<D, T, M>
where D: Digest + AssociatedOid, T: UnsignedModularInt + Zeroize, M: ModulusParams<Modulus = T>,

Source

pub fn new(key: GenericRsaPrivateKey<T, M>) -> Self

Create a new signing key with a precomputed prefix for digest D.

Source§

impl<D, T, M> GenericSigningKey<D, T, M>
where D: Digest, T: UnsignedModularInt + Zeroize, M: ModulusParams<Modulus = T>,

Source

pub fn new_unprefixed(key: GenericRsaPrivateKey<T, M>) -> Self

Create a new signing key with an empty prefix (raw signatures, no DigestInfo wrapper). Unusual — most callers want [new] instead.

Source§

impl<D, T, M> GenericSigningKey<D, T, M>
where D: Digest, T: UnsignedModularInt + Zeroize, T::Bytes: Zeroize, M: ModulusParams<Modulus = T> + CtModulusParams, M::MontgomeryForm: Pow<M> + PowBoundedExp<M>,

Source

pub fn try_sign_into<'sig>( &self, msg: &[u8], em_storage: &mut [u8], sig_storage: &'sig mut [u8], ) -> Result<&'sig [u8]>

Sign msg (hashed internally with D) into sig_storage. Uses em_storage as scratch for the EM encoding.

Both buffers must be at least self.inner.size() bytes. Mirrors the shape of crate::traits::RandomizedEncryptor::encrypt_with_rng_into on the encrypt side: caller owns storage, returned slice borrows from sig_storage with the same lifetime.

Source

pub fn try_sign_prehash_into<'sig>( &self, prehash: &[u8], em_storage: &mut [u8], sig_storage: &'sig mut [u8], ) -> Result<&'sig [u8]>

Sign a precomputed prehash (D::output_size() bytes) into sig_storage. The caller is responsible for the hash; this skips the internal D::digest(msg) step.

Returns [Error::InputNotHashed] if prehash.len() doesn’t match D::output_size() — a mismatch would silently produce malformed PKCS#1 v1.5 padding rather than a usable signature.

Source§

impl<D, T, M> GenericSigningKey<D, T, M>
where D: Digest, T: UnsignedModularInt + Zeroize + TryRandomMod, T::Bytes: Zeroize, M: ModulusParams<Modulus = T> + CtModulusParams, M::MontgomeryForm: Pow<M> + PowBoundedExp<M> + InvertCt<M> + MulCt<M>,

Source

pub fn try_sign_with_rng_into<'sig, R: TryCryptoRng + ?Sized>( &self, rng: &mut R, msg: &[u8], em_storage: &mut [u8], sig_storage: &'sig mut [u8], ) -> Result<&'sig [u8]>

RNG-driven blinded variant of Self::try_sign_into. Uses rng to sample a fresh blinding factor per signature.

Source

pub fn try_sign_prehash_with_rng_into<'sig, R: TryCryptoRng + ?Sized>( &self, rng: &mut R, prehash: &[u8], em_storage: &mut [u8], sig_storage: &'sig mut [u8], ) -> Result<&'sig [u8]>

RNG-driven blinded variant of Self::try_sign_prehash_into.

Source§

impl<D, T, M> GenericSigningKey<D, T, M>
where D: Digest, T: UnsignedModularInt + Zeroize, M: ModulusParams<Modulus = T>,

Source

pub fn to_verifying_key(&self) -> GenericVerifyingKey<D, T, M>

Derive the matching GenericVerifyingKey from this signing key, preserving the existing DigestInfo prefix (so unprefixed signing keys yield unprefixed verifying keys). Not named verifying_key because that would shadow signature::Keypair::verifying_key for callers using method-call syntax.

Source§

impl<D> GenericSigningKey<D, BoxedUint, BoxedMontyParams>
where D: Digest + AssociatedOid,

Source

pub fn random<R: CryptoRng + ?Sized>( rng: &mut R, bit_size: usize, ) -> Result<Self>

Available on crate features alloc and keygen only.

Generate a new signing key with a prefix for the digest D.

Source§

impl<D> GenericSigningKey<D, BoxedUint, BoxedMontyParams>
where D: Digest,

Source

pub fn random_unprefixed<R: CryptoRng + ?Sized>( rng: &mut R, bit_size: usize, ) -> Result<Self>

Available on crate features alloc and keygen only.

Generate a new signing key with an empty prefix.

Trait Implementations§

Source§

impl<D, T, M> AsRef<GenericRsaPrivateKey<T, M>> for GenericSigningKey<D, T, M>
where D: Digest, T: UnsignedModularInt + Zeroize, M: ModulusParams<Modulus = T>,

Source§

fn as_ref(&self) -> &GenericRsaPrivateKey<T, M>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<D, T, M> Clone for GenericSigningKey<D, T, M>
where D: Digest, T: UnsignedModularInt + Zeroize + Clone, M: ModulusParams<Modulus = T> + Clone, M::MontgomeryForm: Clone,

Available on crate feature alloc only.
Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<D, T, M> Debug for GenericSigningKey<D, T, M>
where D: Digest, T: UnsignedModularInt + Zeroize, M: ModulusParams<Modulus = T>, GenericRsaPrivateKey<T, M>: Debug,

Source§

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

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

impl<D> From<GenericSigningKey<D, BoxedUint, BoxedMontyParams>> for RsaPrivateKey
where D: Digest,

Available on crate feature alloc only.
Source§

fn from(key: SigningKey<D>) -> Self

Converts to this type from the input type.
Source§

impl<D, T, M> Zeroize for GenericSigningKey<D, T, M>
where D: Digest, T: UnsignedModularInt + Zeroize, M: ModulusParams<Modulus = T>,

Source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.

Auto Trait Implementations§

§

impl<D, T, M> Freeze for GenericSigningKey<D, T, M>
where T: Freeze, M: Freeze, <M as ModulusParams>::MontgomeryForm: Freeze,

§

impl<D, T, M> RefUnwindSafe for GenericSigningKey<D, T, M>
where T: RefUnwindSafe, D: RefUnwindSafe, M: RefUnwindSafe, <M as ModulusParams>::MontgomeryForm: RefUnwindSafe,

§

impl<D, T, M> Send for GenericSigningKey<D, T, M>
where T: Send, D: Send, M: Send, <M as ModulusParams>::MontgomeryForm: Send,

§

impl<D, T, M> Sync for GenericSigningKey<D, T, M>
where T: Sync, D: Sync, M: Sync, <M as ModulusParams>::MontgomeryForm: Sync,

§

impl<D, T, M> Unpin for GenericSigningKey<D, T, M>
where T: Unpin, D: Unpin, M: Unpin, <M as ModulusParams>::MontgomeryForm: Unpin,

§

impl<D, T, M> UnsafeUnpin for GenericSigningKey<D, T, M>
where T: UnsafeUnpin, M: UnsafeUnpin, <M as ModulusParams>::MontgomeryForm: UnsafeUnpin,

§

impl<D, T, M> UnwindSafe for GenericSigningKey<D, T, M>
where T: UnwindSafe, D: UnwindSafe, M: UnwindSafe, <M as ModulusParams>::MontgomeryForm: UnwindSafe,

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<S, T> AsyncRandomizedSigner<S> for T
where T: RandomizedSigner<S>,

Source§

async fn try_sign_with_rng_async<R>( &self, rng: &mut R, msg: &[u8], ) -> Result<S, Error>
where R: TryCryptoRng + ?Sized,

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

async fn sign_with_rng_async<R>(&self, rng: &mut R, msg: &[u8]) -> S
where R: CryptoRng + ?Sized,

Sign the given message and return a digital signature. Read more
Source§

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

Source§

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

Attempt to sign the given message, returning a digital signature on success, or an error if something went wrong. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DecodePrivateKey for T
where T: for<'a> TryFrom<PrivateKeyInfo<AnyRef<'a>, &'a OctetStringRef, BitStringRef<'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). Read more
Source§

fn from_pkcs8_pem(s: &str) -> Result<Self, Error>

Available on crate feature pem only.
Deserialize PKCS#8-encoded private key from PEM. Read more
Source§

fn read_pkcs8_der_file(path: impl AsRef<Path>) -> Result<Self, Error>

Available on crate feature std only.
Load PKCS#8 private key from an ASN.1 DER-encoded file (binary format) on the local filesystem. Read more
Source§

fn read_pkcs8_pem_file(path: impl AsRef<Path>) -> Result<Self, Error>

Available on crate features pem and std only.
Load PKCS#8 private key from a PEM-encoded file on the local filesystem. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynAssociatedAlgorithmIdentifier for T

Source§

fn algorithm_identifier(&self) -> Result<AlgorithmIdentifier<Any>, Error>

AlgorithmIdentifier for this structure. Read more
Source§

impl<T> DynSignatureAlgorithmIdentifier for T

Source§

fn signature_algorithm_identifier( &self, ) -> Result<AlgorithmIdentifier<Any>, Error>

AlgorithmIdentifier for the corresponding signature system. Read more
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> MontStorage for T
where T: Zeroize,

Source§

impl<S, T> RandomizedSignerMut<S> for T
where T: RandomizedSigner<S>,

Source§

fn try_sign_with_rng<R>(&mut self, rng: &mut R, msg: &[u8]) -> Result<S, Error>
where R: TryCryptoRng + ?Sized,

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_with_rng<R>(&mut self, rng: &mut R, msg: &[u8]) -> S
where R: CryptoRng + ?Sized,

Sign the given message, update the state, and return a digital signature. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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>,

Source§

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.