File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -563,6 +563,17 @@ pub struct CoreRsaPrivateSigningKey {
563563 kid : Option < JsonWebKeyId > ,
564564}
565565impl CoreRsaPrivateSigningKey {
566+ /// Generate a new `CoreRsaPrivateSigningKey` where N denotes its bit size.
567+ pub fn generate < const N : usize > ( kid : Option < JsonWebKeyId > ) -> Result < Self , rsa:: Error > {
568+ let mut rng = rand:: rngs:: OsRng ;
569+
570+ Ok ( Self {
571+ key_pair : rsa:: RsaPrivateKey :: new ( & mut rng, 2048 ) ?,
572+ rng : Box :: new ( rng) ,
573+ kid,
574+ } )
575+ }
576+
566577 /// Converts an RSA private key (in PEM format) to a JWK representing its public key.
567578 pub fn from_pem ( pem : & str , kid : Option < JsonWebKeyId > ) -> Result < Self , String > {
568579 Self :: from_pem_internal ( pem, Box :: new ( rand:: rngs:: OsRng ) , kid)
You can’t perform that action at this time.
0 commit comments