Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,8 @@ opt-level = 2

[profile.bench]
debug = true


[patch.crates-io]
# pkcs1: split RsaPublicKey into RsaPublicKeyRef and RsaPublicKeyOwned - #2411
pkcs1 = { git = "https://github.com/RustCrypto/formats.git", rev = "0072dd7246ce370e7b89047b1389f44b67ab63b7" }
10 changes: 5 additions & 5 deletions src/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl pkcs1::DecodeRsaPrivateKey for RsaPrivateKey {

impl pkcs1::DecodeRsaPublicKey for RsaPublicKey {
fn from_pkcs1_der(bytes: &[u8]) -> pkcs1::Result<Self> {
pkcs1::RsaPublicKey::from_der(bytes)?.try_into()
pkcs1::RsaPublicKeyRef::from_der(bytes)?.try_into()
}
}

Expand Down Expand Up @@ -67,10 +67,10 @@ impl TryFrom<pkcs1::RsaPrivateKey<'_>> for RsaPrivateKey {
}
}

impl TryFrom<pkcs1::RsaPublicKey<'_>> for RsaPublicKey {
impl TryFrom<pkcs1::RsaPublicKeyRef<'_>> for RsaPublicKey {
type Error = pkcs1::Error;

fn try_from(pkcs1_key: pkcs1::RsaPublicKey<'_>) -> pkcs1::Result<Self> {
fn try_from(pkcs1_key: pkcs1::RsaPublicKeyRef<'_>) -> pkcs1::Result<Self> {
use pkcs1::Error::KeyMalformed;

let bits = u32::try_from(pkcs1_key.modulus.as_bytes().len()).map_err(|_| KeyMalformed)? * 8;
Expand Down Expand Up @@ -140,7 +140,7 @@ impl pkcs1::EncodeRsaPublicKey for RsaPublicKey {
let modulus = self.n().to_be_bytes();
let public_exponent = self.e().to_be_bytes();

Ok(Document::encode_msg(&pkcs1::RsaPublicKey {
Ok(Document::encode_msg(&pkcs1::RsaPublicKeyRef {
modulus: pkcs1::UintRef::new(&modulus)?,
public_exponent: pkcs1::UintRef::new(&public_exponent)?,
})?)
Expand Down Expand Up @@ -188,7 +188,7 @@ impl TryFrom<pkcs8::SubjectPublicKeyInfoRef<'_>> for RsaPublicKey {

verify_algorithm_id(&spki.algorithm)?;

pkcs1::RsaPublicKey::try_from(spki.subject_public_key.as_bytes().ok_or(KeyMalformed)?)
pkcs1::RsaPublicKeyRef::try_from(spki.subject_public_key.as_bytes().ok_or(KeyMalformed)?)
.and_then(TryInto::try_into)
.map_err(pkcs1_error_to_spki)
}
Expand Down