File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ extern crate test;
5
5
use base64ct:: { Base64 , Encoding } ;
6
6
use crypto_bigint:: BoxedUint ;
7
7
use hex_literal:: hex;
8
- use rand_chacha:: { rand_core:: SeedableRng , ChaCha8Rng } ;
8
+ use rand_chacha:: { ChaCha8Rng , rand_core:: SeedableRng } ;
9
9
use rsa:: { Pkcs1v15Encrypt , Pkcs1v15Sign , RsaPrivateKey } ;
10
10
use sha2:: { Digest , Sha256 } ;
11
11
use test:: Bencher ;
@@ -75,6 +75,26 @@ fn get_key() -> RsaPrivateKey {
75
75
. unwrap ( )
76
76
}
77
77
78
+ #[ bench]
79
+ fn bench_rsa_1024_gen_key ( b : & mut Bencher ) {
80
+ let mut rng = ChaCha8Rng :: from_seed ( [ 42 ; 32 ] ) ;
81
+
82
+ b. iter ( || {
83
+ let key = RsaPrivateKey :: new ( & mut rng, 1024 ) . unwrap ( ) ;
84
+ test:: black_box ( key) ;
85
+ } ) ;
86
+ }
87
+
88
+ #[ bench]
89
+ fn bench_rsa_2048_gen_key ( b : & mut Bencher ) {
90
+ let mut rng = ChaCha8Rng :: from_seed ( [ 42 ; 32 ] ) ;
91
+
92
+ b. iter ( || {
93
+ let key = RsaPrivateKey :: new ( & mut rng, 2048 ) . unwrap ( ) ;
94
+ test:: black_box ( key) ;
95
+ } ) ;
96
+ }
97
+
78
98
#[ bench]
79
99
fn bench_rsa_2048_pkcsv1_decrypt ( b : & mut Bencher ) {
80
100
let priv_key = get_key ( ) ;
You can’t perform that action at this time.
0 commit comments