1
- #[ cfg( feature = "use_aws_lc_rs " ) ]
1
+ #[ cfg( feature = "fips " ) ]
2
2
use aws_lc_rs as ring;
3
3
4
- #[ cfg( not( feature = "use_aws_lc_rs " ) ) ]
4
+ #[ cfg( not( feature = "fips " ) ) ]
5
5
use ring;
6
6
7
7
use ring:: { rand, signature} ;
@@ -47,10 +47,7 @@ pub(crate) fn sign(
47
47
let key_pair = signature:: RsaKeyPair :: from_der ( key)
48
48
. map_err ( |e| ErrorKind :: InvalidRsaKey ( e. to_string ( ) ) ) ?;
49
49
50
- #[ cfg( feature = "use_aws_lc_rs" ) ]
51
- let mut signature = vec ! [ 0 ; key_pair. public_modulus_len( ) ] ;
52
- #[ cfg( not( feature = "use_aws_lc_rs" ) ) ]
53
- let mut signature = vec ! [ 0 ; key_pair. public( ) . modulus_len( ) ] ;
50
+ let mut signature = get_signature ( & key_pair) ;
54
51
55
52
let rng = rand:: SystemRandom :: new ( ) ;
56
53
key_pair. sign ( alg, & rng, message, & mut signature) . map_err ( |_| ErrorKind :: RsaFailedSigning ) ?;
@@ -70,3 +67,13 @@ pub(crate) fn verify_from_components(
70
67
let res = pubkey. verify ( alg, message, & signature_bytes) ;
71
68
Ok ( res. is_ok ( ) )
72
69
}
70
+
71
+ #[ cfg( feature = "fips" ) ]
72
+ fn get_signature ( key_pair : & signature:: RsaKeyPair ) -> Vec < u8 > {
73
+ vec ! [ 0 ; key_pair. public_modulus_len( ) ]
74
+ }
75
+
76
+ #[ cfg( not( feature = "fips" ) ) ]
77
+ fn get_signature ( key_pair : & signature:: RsaKeyPair ) -> Vec < u8 > {
78
+ vec ! [ 0 ; key_pair. public( ) . modulus_len( ) ]
79
+ }
0 commit comments