From ceed393687853e4f8f2f38397ebbf6a58d50dbd2 Mon Sep 17 00:00:00 2001 From: Dmitry Baryshkov Date: Sat, 15 Apr 2023 05:11:38 +0300 Subject: [PATCH] pss: add random key generation for BlindedSigningKey Signed-off-by: Dmitry Baryshkov --- src/pss.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/pss.rs b/src/pss.rs index bc34bbe0..ebb245fd 100644 --- a/src/pss.rs +++ b/src/pss.rs @@ -842,6 +842,27 @@ where } } + /// Create a new random RSASSA-PSS signing key which produces "blinded" + /// signatures. + /// Digest output size is used as a salt length. + pub fn random(rng: &mut R, bit_size: usize) -> Result { + Self::random_with_salt_len(rng, bit_size, ::output_size()) + } + + /// Create a new random RSASSA-PSS signing key which produces "blinded" + /// signatures with a salt of the given length. + pub fn random_with_salt_len( + rng: &mut R, + bit_size: usize, + salt_len: usize, + ) -> Result { + Ok(Self { + inner: RsaPrivateKey::new(rng, bit_size)?, + salt_len, + phantom: Default::default(), + }) + } + /// Return specified salt length for this key pub fn salt_len(&self) -> usize { self.salt_len