Skip to content

Commit

Permalink
WIP: sec1: adopt pkcs8 API changes
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Gautier <[email protected]>
  • Loading branch information
baloo committed Aug 19, 2024
1 parent 5c7ed62 commit 5e9b14d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions sec1/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use {crate::LineEnding, alloc::string::String, der::pem::PemLabel};
#[cfg(feature = "pkcs8")]
use {
crate::{EcPrivateKey, ALGORITHM_OID},
der::Decode,
der::{asn1::OctetStringRef, Decode},
};

#[cfg(feature = "std")]
Expand Down Expand Up @@ -100,6 +100,8 @@ where
parameters: params_oid.as_ref().map(Into::into),
};

let private_key = OctetStringRef::new(private_key)?;

Ok(Self::try_from(pkcs8::PrivateKeyInfo {
algorithm,
private_key,
Expand All @@ -115,7 +117,8 @@ impl<T: pkcs8::EncodePrivateKey> EncodeEcPrivateKey for T {
let pkcs8_key = pkcs8::PrivateKeyInfo::from_der(doc.as_bytes())?;
pkcs8_key.algorithm.assert_algorithm_oid(ALGORITHM_OID)?;

let mut pkcs1_key = EcPrivateKey::from_der(pkcs8_key.private_key)?;
// TODO: untested
let mut pkcs1_key = EcPrivateKey::from_der(pkcs8_key.private_key.as_bytes())?;
pkcs1_key.parameters = Some(pkcs8_key.algorithm.parameters_oid()?.into());
pkcs1_key.try_into()
}
Expand Down

0 comments on commit 5e9b14d

Please sign in to comment.