Skip to content

Commit 842c1f6

Browse files
authored
pss: add random key generation for BlindedSigningKey (#295)
Signed-off-by: Dmitry Baryshkov <[email protected]>
1 parent e7201ed commit 842c1f6

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/pss.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,27 @@ where
842842
}
843843
}
844844

845+
/// Create a new random RSASSA-PSS signing key which produces "blinded"
846+
/// signatures.
847+
/// Digest output size is used as a salt length.
848+
pub fn random<R: CryptoRngCore + ?Sized>(rng: &mut R, bit_size: usize) -> Result<Self> {
849+
Self::random_with_salt_len(rng, bit_size, <D as Digest>::output_size())
850+
}
851+
852+
/// Create a new random RSASSA-PSS signing key which produces "blinded"
853+
/// signatures with a salt of the given length.
854+
pub fn random_with_salt_len<R: CryptoRngCore + ?Sized>(
855+
rng: &mut R,
856+
bit_size: usize,
857+
salt_len: usize,
858+
) -> Result<Self> {
859+
Ok(Self {
860+
inner: RsaPrivateKey::new(rng, bit_size)?,
861+
salt_len,
862+
phantom: Default::default(),
863+
})
864+
}
865+
845866
/// Return specified salt length for this key
846867
pub fn salt_len(&self) -> usize {
847868
self.salt_len

0 commit comments

Comments
 (0)