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;
55use base64ct:: { Base64 , Encoding } ;
66use crypto_bigint:: BoxedUint ;
77use hex_literal:: hex;
8- use rand_chacha:: { rand_core:: SeedableRng , ChaCha8Rng } ;
8+ use rand_chacha:: { ChaCha8Rng , rand_core:: SeedableRng } ;
99use rsa:: { Pkcs1v15Encrypt , Pkcs1v15Sign , RsaPrivateKey } ;
1010use sha2:: { Digest , Sha256 } ;
1111use test:: Bencher ;
@@ -75,6 +75,26 @@ fn get_key() -> RsaPrivateKey {
7575 . unwrap ( )
7676}
7777
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+
7898#[ bench]
7999fn bench_rsa_2048_pkcsv1_decrypt ( b : & mut Bencher ) {
80100 let priv_key = get_key ( ) ;
You can’t perform that action at this time.
0 commit comments