@@ -2,7 +2,7 @@ use rsa::{
22 RsaPrivateKey ,
33 RsaPublicKey ,
44 PublicKey ,
5- pkcs8:: { FromPrivateKey , ToPrivateKey , ToPublicKey }
5+ pkcs8:: { EncodePrivateKey , DecodePrivateKey , EncodePublicKey }
66} ;
77
88use crate :: api:: * ;
@@ -12,6 +12,10 @@ use crate::error::Error;
1212use crate :: service:: * ;
1313use crate :: types:: * ;
1414
15+ //TODO:alt3r-3go: sign() and verify() are the only two methods that are actually different between -pkcs and -pss.
16+ // Moreover, the key::Kind::Rsa2K could also probably be parametrized, instead of having a dedicated kind
17+ // for each. Overall this means the class structure can probably be simplified - need to decide.
18+
1519#[ cfg( feature = "rsa2k-pkcs" ) ]
1620impl DeriveKey for super :: Rsa2kPkcs
1721{
@@ -31,7 +35,7 @@ impl DeriveKey for super::Rsa2kPkcs
3135 // std::println!("Loaded key material: {}", delog::hex_str!(&priv_key_der));
3236 // std::println!("Key material length is {}", priv_key_der.len());
3337
34- let priv_key = FromPrivateKey :: from_pkcs8_der ( & priv_key_der)
38+ let priv_key = DecodePrivateKey :: from_pkcs8_der ( & priv_key_der)
3539 . expect ( "Failed to deserialize an RSA 2K private key from PKCS#8 DER" ) ;
3640
3741 // Derive and store public key
@@ -66,7 +70,7 @@ impl DeserializeKey for super::Rsa2kPkcs
6670 return Err ( Error :: InternalError ) ;
6771 }
6872
69- let private_key: RsaPrivateKey = FromPrivateKey :: from_pkcs8_der ( & request. serialized_key )
73+ let private_key: RsaPrivateKey = DecodePrivateKey :: from_pkcs8_der ( & request. serialized_key )
7074 . map_err ( |_| Error :: InvalidSerializedKey ) ?;
7175
7276 // We store our keys in PKCS#8 DER format as well
@@ -180,7 +184,7 @@ impl Sign for super::Rsa2kPkcs
180184 . expect ( "Failed to load an RSA 2K private key with the given ID" )
181185 . material ;
182186
183- let priv_key: RsaPrivateKey = FromPrivateKey :: from_pkcs8_der ( & priv_key_der)
187+ let priv_key: RsaPrivateKey = DecodePrivateKey :: from_pkcs8_der ( & priv_key_der)
184188 . expect ( "Failed to deserialize an RSA 2K private key from PKCS#8 DER" ) ;
185189
186190 // RSA lib takes in a hash value to sign, not raw data.
@@ -230,7 +234,7 @@ impl Verify for super::Rsa2kPkcs
230234 . expect ( "Failed to load an RSA 2K private key with the given ID" )
231235 . material ;
232236
233- let priv_key = FromPrivateKey :: from_pkcs8_der ( & priv_key_der)
237+ let priv_key = DecodePrivateKey :: from_pkcs8_der ( & priv_key_der)
234238 . expect ( "Failed to deserialize an RSA 2K private key from PKCS#8 DER" ) ;
235239
236240 // Get the public key
0 commit comments