@@ -18,9 +18,13 @@ use elliptic_curve::{
1818    FieldBytesSize , 
1919    PublicKey , 
2020} ; 
21- use  rsa:: { pkcs8:: EncodePublicKey ,  BigUint ,  RsaPublicKey } ; 
21+ 
22+ #[ cfg( feature = "rustcrypto" ) ]  
2223use  x509_cert:: spki:: SubjectPublicKeyInfoOwned ; 
2324
25+ #[ cfg( all( feature = "rustcrypto" ,  feature = "rsa" ) ) ]  
26+ use  rsa:: { pkcs8:: EncodePublicKey ,  BigUint ,  RsaPublicKey } ; 
27+ 
2428/// Default exponent for RSA keys. 
2529// Also known as 0x10001 
2630const  RSA_DEFAULT_EXP :  u64  = 65537 ; 
6670    } 
6771} 
6872
73+ #[ cfg( all( feature = "rustcrypto" ,  feature = "rsa" ) ) ]  
6974impl  TryFrom < & Public >  for  RsaPublicKey  { 
7075    type  Error  = Error ; 
7176
@@ -127,17 +132,17 @@ impl TryFrom<&Public> for SubjectPublicKeyInfoOwned {
127132                    } ; 
128133                } 
129134
130-                 #[ cfg( feature = "p192" ) ]  
135+                 #[ cfg( all ( feature = "rustcrypto"  ,  feature =  " p192") ) ]  
131136                read_key ! ( EccCurve :: NistP192 ,  p192:: NistP192 ) ; 
132-                 #[ cfg( feature = "p224" ) ]  
137+                 #[ cfg( all ( feature = "rustcrypto"  ,  feature =  " p224") ) ]  
133138                read_key ! ( EccCurve :: NistP224 ,  p224:: NistP224 ) ; 
134-                 #[ cfg( feature = "p256" ) ]  
139+                 #[ cfg( all ( feature = "rustcrypto"  ,  feature =  " p256") ) ]  
135140                read_key ! ( EccCurve :: NistP256 ,  p256:: NistP256 ) ; 
136-                 #[ cfg( feature = "p384" ) ]  
141+                 #[ cfg( all ( feature = "rustcrypto"  ,  feature =  " p384") ) ]  
137142                read_key ! ( EccCurve :: NistP384 ,  p384:: NistP384 ) ; 
138-                 #[ cfg( feature = "p521" ) ]  
143+                 #[ cfg( all ( feature = "rustcrypto"  ,  feature =  " p521") ) ]  
139144                read_key ! ( EccCurve :: NistP521 ,  p521:: NistP521 ) ; 
140-                 #[ cfg( feature = "sm2" ) ]  
145+                 #[ cfg( all ( feature = "rustcrypto"  ,  feature =  " sm2") ) ]  
141146                read_key ! ( EccCurve :: Sm2P256 ,  sm2:: Sm2 ) ; 
142147
143148                Err ( Error :: local_error ( WrapperErrorKind :: UnsupportedParam ) ) 
@@ -182,6 +187,7 @@ where
182187    } 
183188} 
184189
190+ #[ cfg( all( feature = "rustcrypto" ,  feature = "rsa" ) ) ]  
185191impl  TryFrom < & TpmPublicKey >  for  RsaPublicKey  { 
186192    type  Error  = Error ; 
187193
@@ -207,32 +213,32 @@ pub trait AssociatedTpmCurve {
207213const  TPM_CURVE :  EccCurve ; 
208214} 
209215
210- #[ cfg( feature = "p192" ) ]  
216+ #[ cfg( all ( feature = "rustcrypto"  ,  feature =  " p192") ) ]  
211217impl  AssociatedTpmCurve  for  p192:: NistP192  { 
212218    const  TPM_CURVE :  EccCurve  = EccCurve :: NistP192 ; 
213219} 
214220
215- #[ cfg( feature = "p224" ) ]  
221+ #[ cfg( all ( feature = "rustcrypto"  ,  feature =  " p224") ) ]  
216222impl  AssociatedTpmCurve  for  p224:: NistP224  { 
217223    const  TPM_CURVE :  EccCurve  = EccCurve :: NistP224 ; 
218224} 
219225
220- #[ cfg( feature = "p256" ) ]  
226+ #[ cfg( all ( feature = "rustcrypto"  ,  feature =  " p256") ) ]  
221227impl  AssociatedTpmCurve  for  p256:: NistP256  { 
222228    const  TPM_CURVE :  EccCurve  = EccCurve :: NistP256 ; 
223229} 
224230
225- #[ cfg( feature = "p384" ) ]  
231+ #[ cfg( all ( feature = "rustcrypto"  ,  feature =  " p384") ) ]  
226232impl  AssociatedTpmCurve  for  p384:: NistP384  { 
227233    const  TPM_CURVE :  EccCurve  = EccCurve :: NistP384 ; 
228234} 
229235
230- #[ cfg( feature = "p521" ) ]  
236+ #[ cfg( all ( feature = "rustcrypto"  ,  feature =  " p521") ) ]  
231237impl  AssociatedTpmCurve  for  p521:: NistP521  { 
232238    const  TPM_CURVE :  EccCurve  = EccCurve :: NistP521 ; 
233239} 
234240
235- #[ cfg( feature = "sm2" ) ]  
241+ #[ cfg( all ( feature = "rustcrypto"  ,  feature =  " sm2") ) ]  
236242impl  AssociatedTpmCurve  for  sm2:: Sm2  { 
237243    const  TPM_CURVE :  EccCurve  = EccCurve :: Sm2P256 ; 
238244} 
0 commit comments