Skip to content
Merged
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
88 changes: 58 additions & 30 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ readme = "README.md"
[dependencies]
once_cell = "1.8.0"
pkcs1 = { version = "0.7.5", features = ["std"] }
pkcs8 = "0.10.2"
pkcs8 = "0.11.0"
rustls = { version = "0.23.20", default-features = false, features = ["std"] }
sec1 = "0.7.3"
sec1 = "0.8.1"
windows = { version = "0.61.3", features = [
"Win32_Security_Cryptography",
"Win32_System_WinRT",
Expand Down
10 changes: 7 additions & 3 deletions LICENSE-3rdparty.csv
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
Component,Origin,License,Copyright
aws-lc-rs,https://github.com/aws/aws-lc-rs,ISC AND (Apache-2.0 OR ISC),AWS-LibCrypto
aws-lc-sys,https://github.com/aws/aws-lc-rs,ISC AND (Apache-2.0 OR ISC) AND Apache-2.0 AND MIT AND BSD-3-Clause AND (Apache-2.0 OR ISC OR MIT) AND (Apache-2.0 OR ISC OR MIT-0),AWS-LC
base16ct,https://github.com/RustCrypto/formats/tree/master/base16ct,Apache-2.0 OR MIT,RustCrypto Developers
base16ct,https://github.com/RustCrypto/formats,Apache-2.0 OR MIT,RustCrypto Developers
base64ct,https://github.com/RustCrypto/formats,Apache-2.0 OR MIT,RustCrypto Developers
cfg-if,https://github.com/rust-lang/cfg-if,MIT OR Apache-2.0,Alex Crichton <alex@alexcrichton.com>
const-oid,https://github.com/RustCrypto/formats,Apache-2.0 OR MIT,RustCrypto Developers
const-oid,https://github.com/RustCrypto/formats/tree/master/const-oid,Apache-2.0 OR MIT,RustCrypto Developers
der,https://github.com/RustCrypto/formats,Apache-2.0 OR MIT,RustCrypto Developers
der,https://github.com/RustCrypto/formats/tree/master/der,Apache-2.0 OR MIT,RustCrypto Developers
generic-array,https://github.com/fizyk20/generic-array,MIT,"Bartłomiej Kamiński <fizyk20@gmail.com>, Aaron Trent <novacrazy@gmail.com>"
getrandom,https://github.com/rust-random/getrandom,MIT OR Apache-2.0,The Rand Project Developers
hybrid-array,https://github.com/RustCrypto/hybrid-array,MIT OR Apache-2.0,RustCrypto Developers
libc,https://github.com/rust-lang/libc,MIT OR Apache-2.0,The Rust Project Developers
once_cell,https://github.com/matklad/once_cell,MIT OR Apache-2.0,Aleksey Kladov <aleksey.kladov@gmail.com>
pkcs1,https://github.com/RustCrypto/formats/tree/master/pkcs1,Apache-2.0 OR MIT,RustCrypto Developers
pkcs8,https://github.com/RustCrypto/formats,Apache-2.0 OR MIT,RustCrypto Developers
pkcs8,https://github.com/RustCrypto/formats/tree/master/pkcs8,Apache-2.0 OR MIT,RustCrypto Developers
proc-macro2,https://github.com/dtolnay/proc-macro2,MIT OR Apache-2.0,"David Tolnay <dtolnay@gmail.com>, Alex Crichton <alex@alexcrichton.com>"
quote,https://github.com/dtolnay/quote,MIT OR Apache-2.0,David Tolnay <dtolnay@gmail.com>
ring,https://github.com/briansmith/ring,Apache-2.0 AND ISC,The ring Authors
rustls,https://github.com/rustls/rustls,Apache-2.0 OR ISC OR MIT,The rustls Authors
rustls-pki-types,https://github.com/rustls/pki-types,MIT OR Apache-2.0,The rustls-pki-types Authors
rustls-webpki,https://github.com/rustls/webpki,ISC,The rustls-webpki Authors
sec1,https://github.com/RustCrypto/formats/tree/master/sec1,Apache-2.0 OR MIT,RustCrypto Developers
sec1,https://github.com/RustCrypto/formats,Apache-2.0 OR MIT,RustCrypto Developers
spki,https://github.com/RustCrypto/formats,Apache-2.0 OR MIT,RustCrypto Developers
spki,https://github.com/RustCrypto/formats/tree/master/spki,Apache-2.0 OR MIT,RustCrypto Developers
subtle,https://github.com/dalek-cryptography/subtle,BSD-3-Clause,"Isis Lovecruft <isis@patternsinthevoid.net>, Henry de Valence <hdevalence@hdevalence.ca>"
syn,https://github.com/dtolnay/syn,MIT OR Apache-2.0,David Tolnay <dtolnay@gmail.com>
Expand Down
11 changes: 5 additions & 6 deletions src/signer/ec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@

use crate::hash::{SHA256, SHA384, SHA512};
use crate::keys::{import_ecdsa_private_key, KeyWrapper};
use pkcs1::der::Decode as _;
use pkcs1::ObjectIdentifier;
use pkcs8::PrivateKeyInfo;
use pkcs8::der::{asn1::ObjectIdentifier, Decode as _};
use pkcs8::PrivateKeyInfoRef;
use rustls::crypto::hash::Hash;
use rustls::pki_types::PrivateKeyDer;
use rustls::sign::SigningKey;
Expand Down Expand Up @@ -55,7 +54,7 @@ impl EcKey {
Ok((private_key, scheme))
}
PrivateKeyDer::Pkcs8(private_pkcs8_key_der) => {
let pki = PrivateKeyInfo::from_der(private_pkcs8_key_der.secret_pkcs8_der())
let pki = PrivateKeyInfoRef::from_der(private_pkcs8_key_der.secret_pkcs8_der())
.map_err(|e| {
Error::General(format!("Failed to parse PKCS#8 private key: {e:?}"))
})?;
Expand All @@ -80,8 +79,8 @@ impl EcKey {
)),
}?;
// ...but get the private key bytes by parsing the key as sec1
let private_bytes =
EcPrivateKey::from_der(pki.private_key).map_err(|e| {
let private_bytes = EcPrivateKey::from_der(pki.private_key.as_bytes())
.map_err(|e| {
Error::General(format!("Failed to parse ECDSA private key: {e:?}"))
})?;
Ok((private_bytes.private_key, scheme))
Expand Down
11 changes: 8 additions & 3 deletions src/signer/rsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

use pkcs1::der::Decode as _;
use pkcs1::RsaPrivateKey;
use pkcs8::PrivateKeyInfo;
use pkcs8::der::Decode as _;
use pkcs8::PrivateKeyInfoRef;
use rustls::pki_types::PrivateKeyDer;
use rustls::{Error, SignatureAlgorithm, SignatureScheme};
use std::sync::Arc;
Expand Down Expand Up @@ -57,9 +58,13 @@ impl RsaSigningKey {
.map_err(|e| Error::General(format!("Failed to parse PKCS1 key: {e}")))
}
PrivateKeyDer::Pkcs8(private_pkcs8_key_der) => {
PrivateKeyInfo::from_der(private_pkcs8_key_der.secret_pkcs8_der())
.and_then(|pki| RsaPrivateKey::from_der(pki.private_key))
PrivateKeyInfoRef::from_der(private_pkcs8_key_der.secret_pkcs8_der())
.map_err(|e| Error::General(format!("Failed to parse PKCS8 key: {e}")))
.and_then(|pki| {
RsaPrivateKey::from_der(pki.private_key.as_bytes()).map_err(|e| {
Error::General(format!("Failed to parse PKCS8 RSA key: {e}"))
})
})
}
_ => Err(Error::General("Unsupported key format".to_string())),
}?;
Expand Down
Loading