@@ -5,8 +5,7 @@ use std::os::unix::prelude::OpenOptionsExt;
5
5
use std:: path:: PathBuf ;
6
6
7
7
use clap:: Parser ;
8
- use ed25519_dalek:: { KEYPAIR_LENGTH , SigningKey } ;
9
- use rand_core:: OsRng ;
8
+ use ed25519_dalek:: { KEYPAIR_LENGTH , SecretKey , SigningKey } ;
10
9
11
10
/// Generate a signing key
12
11
#[ derive( Debug , Parser , Clone ) ]
@@ -35,6 +34,8 @@ pub(crate) enum Error {
35
34
Read ( #[ source] std:: io:: Error , PathBuf ) ,
36
35
#[ error( "no valid key found in from {1:?}" ) ]
37
36
IllegalKey ( #[ source] ed25519_dalek:: SignatureError , PathBuf ) ,
37
+ #[ error( "could not get random data" ) ]
38
+ Random ( #[ source] getrandom:: Error ) ,
38
39
}
39
40
40
41
pub ( crate ) fn main ( args : Cli ) -> Result < ( ) , Error > {
@@ -53,7 +54,10 @@ pub(crate) fn main(args: Cli) -> Result<(), Error> {
53
54
Err ( err) => return Err ( Error :: IllegalKey ( err, args. private_key ) ) ,
54
55
}
55
56
} else {
56
- let key: SigningKey = SigningKey :: generate ( & mut OsRng ) ;
57
+ let mut secret = SecretKey :: default ( ) ;
58
+ getrandom:: fill ( secret. as_mut_slice ( ) ) . map_err ( Error :: Random ) ?;
59
+ let key = SigningKey :: from_bytes ( & { secret } ) ;
60
+
57
61
let result = OpenOptions :: new ( )
58
62
. write ( true )
59
63
. create ( true )
0 commit comments