22//! Module containing the definition of the private key container
33//!
44
5- use crate :: { Components , OID , Signature , VerifyingKey } ;
5+ #![ cfg( feature = "hazmat" ) ]
6+
7+ use crate :: { Signature , VerifyingKey } ;
68use core:: {
79 cmp:: min,
810 fmt:: { self , Debug } ,
@@ -12,21 +14,27 @@ use crypto_bigint::{
1214 modular:: { BoxedMontyForm , BoxedMontyParams } ,
1315} ;
1416use digest:: { Digest , FixedOutputReset , block_api:: BlockSizeUser } ;
15- use pkcs8:: {
16- AlgorithmIdentifierRef , EncodePrivateKey , PrivateKeyInfoRef , SecretDocument ,
17- der:: {
18- AnyRef , Decode , Encode ,
19- asn1:: { OctetStringRef , UintRef } ,
20- } ,
21- } ;
22- #[ cfg( feature = "hazmat" ) ]
23- use signature:: rand_core:: CryptoRng ;
2417use signature:: {
2518 DigestSigner , MultipartSigner , RandomizedDigestSigner , Signer ,
2619 hazmat:: { PrehashSigner , RandomizedPrehashSigner } ,
2720 rand_core:: TryCryptoRng ,
2821} ;
29- use zeroize:: { Zeroize , ZeroizeOnDrop , Zeroizing } ;
22+ use zeroize:: { ZeroizeOnDrop , Zeroizing } ;
23+
24+ #[ cfg( feature = "hazmat" ) ]
25+ use { crate :: Components , signature:: rand_core:: CryptoRng } ;
26+ #[ cfg( feature = "pkcs8" ) ]
27+ use {
28+ crate :: OID ,
29+ pkcs8:: {
30+ AlgorithmIdentifierRef , EncodePrivateKey , PrivateKeyInfoRef , SecretDocument ,
31+ der:: {
32+ AnyRef , Decode , Encode ,
33+ asn1:: { OctetStringRef , UintRef } ,
34+ } ,
35+ } ,
36+ zeroize:: Zeroize ,
37+ } ;
3038
3139/// DSA private key.
3240///
@@ -208,6 +216,7 @@ where
208216 }
209217}
210218
219+ #[ cfg( feature = "pkcs8" ) ]
211220impl EncodePrivateKey for SigningKey {
212221 fn to_pkcs8_der ( & self ) -> pkcs8:: Result < SecretDocument > {
213222 let parameters = self . verifying_key ( ) . components ( ) . to_der ( ) ?;
@@ -232,6 +241,7 @@ impl EncodePrivateKey for SigningKey {
232241 }
233242}
234243
244+ #[ cfg( feature = "pkcs8" ) ]
235245impl < ' a > TryFrom < PrivateKeyInfoRef < ' a > > for SigningKey {
236246 type Error = pkcs8:: Error ;
237247
0 commit comments