File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,8 @@ use crate::{
77} ;
88
99use ed25519_dalek:: pkcs8:: DecodePrivateKey ;
10- use ed25519_dalek:: Signer ;
10+ use ed25519_dalek:: { Signer , SigningKey } ;
11+ use rand:: RngCore ;
1112use rsa:: pkcs1:: DecodeRsaPrivateKey ;
1213use serde:: { Deserialize , Serialize } ;
1314use sha2:: { Digest , Sha256 , Sha384 , Sha512 } ;
@@ -493,6 +494,19 @@ pub struct CoreEdDsaPrivateSigningKey {
493494 key_pair : ed25519_dalek:: SigningKey ,
494495}
495496impl CoreEdDsaPrivateSigningKey {
497+ /// Generate a new `CoreEdDsaPrivateSigningKey`
498+ pub fn generate ( kid : Option < JsonWebKeyId > ) -> Self {
499+ let mut rng = rand:: rngs:: OsRng ;
500+
501+ let mut secret = ed25519_dalek:: SecretKey :: default ( ) ;
502+ rng. fill_bytes ( & mut secret) ;
503+
504+ Self {
505+ kid,
506+ key_pair : SigningKey :: from_bytes ( & secret) ,
507+ }
508+ }
509+
496510 /// Converts an EdDSA private key (in PEM format) to a JWK representing its public key.
497511 pub fn from_ed25519_pem ( pem : & str , kid : Option < JsonWebKeyId > ) -> Result < Self , String > {
498512 Ok ( Self {
You can’t perform that action at this time.
0 commit comments