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
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion rcgen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rcgen"
version = "0.14.6"
version = "0.14.7"
documentation = "https://docs.rs/rcgen"
description.workspace = true
repository.workspace = true
Expand Down
14 changes: 13 additions & 1 deletion rcgen/src/key_pair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,19 @@ impl KeyPair {
KeyPairKind::Rsa(rsakp, &signature::RSA_PSS_SHA256)
} else {
#[cfg(feature = "aws_lc_rs")]
if alg == &PKCS_ECDSA_P521_SHA512 {
if alg == &PKCS_ECDSA_P521_SHA256 {
KeyPairKind::Ec(ecdsa_from_pkcs8(
&signature::ECDSA_P521_SHA256_ASN1_SIGNING,
&serialized_der,
rng,
)?)
} else if alg == &PKCS_ECDSA_P521_SHA384 {
KeyPairKind::Ec(ecdsa_from_pkcs8(
&signature::ECDSA_P521_SHA384_ASN1_SIGNING,
&serialized_der,
rng,
)?)
} else if alg == &PKCS_ECDSA_P521_SHA512 {
KeyPairKind::Ec(ecdsa_from_pkcs8(
&signature::ECDSA_P521_SHA512_ASN1_SIGNING,
&serialized_der,
Expand Down
46 changes: 45 additions & 1 deletion rcgen/src/sign_algo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ impl fmt::Debug for SignatureAlgorithm {
} else if self == &PKCS_ED25519 {
write!(f, "PKCS_ED25519")
} else {
#[cfg(feature = "aws_lc_rs")]
if self == &PKCS_ECDSA_P521_SHA256 {
return write!(f, "PKCS_ECDSA_P521_SHA256");
}
#[cfg(feature = "aws_lc_rs")]
if self == &PKCS_ECDSA_P521_SHA384 {
return write!(f, "PKCS_ECDSA_P521_SHA384");
}
#[cfg(feature = "aws_lc_rs")]
if self == &PKCS_ECDSA_P521_SHA512 {
return write!(f, "PKCS_ECDSA_P521_SHA512");
Expand Down Expand Up @@ -99,6 +107,10 @@ impl SignatureAlgorithm {
&PKCS_ECDSA_P256_SHA256,
&PKCS_ECDSA_P384_SHA384,
#[cfg(feature = "aws_lc_rs")]
&PKCS_ECDSA_P521_SHA256,
#[cfg(feature = "aws_lc_rs")]
&PKCS_ECDSA_P521_SHA384,
#[cfg(feature = "aws_lc_rs")]
&PKCS_ECDSA_P521_SHA512,
&PKCS_ED25519,
];
Expand Down Expand Up @@ -191,8 +203,40 @@ pub(crate) mod algo {
oid_components: &[1, 2, 840, 10045, 4, 3, 3],
params: SignatureAlgorithmParams::None,
};

/// ECDSA signing using the P-521 curves and SHA-256 hashing as per [RFC 5758](https://tools.ietf.org/html/rfc5758#section-3.2)
///
/// Note that this algorithm is not widely supported, and is not supported in TLS 1.3.
///
/// Only supported with the `aws_lc_rs` backend.
#[cfg(feature = "aws_lc_rs")]
pub static PKCS_ECDSA_P521_SHA256: SignatureAlgorithm = SignatureAlgorithm {
oids_sign_alg: &[EC_PUBLIC_KEY, EC_SECP_521_R1],
#[cfg(feature = "crypto")]
sign_alg: SignAlgo::EcDsa(&signature::ECDSA_P521_SHA256_ASN1_SIGNING),
// ecdsa-with-SHA256 in RFC 5758
oid_components: &[1, 2, 840, 10045, 4, 3, 2],
params: SignatureAlgorithmParams::None,
};

/// ECDSA signing using the P-521 curves and SHA-384 hashing as per [RFC 5758](https://tools.ietf.org/html/rfc5758#section-3.2)
///
/// Note that this algorithm is not widely supported, and is not supported in TLS 1.3.
///
/// Only supported with the `aws_lc_rs` backend.
#[cfg(feature = "aws_lc_rs")]
pub static PKCS_ECDSA_P521_SHA384: SignatureAlgorithm = SignatureAlgorithm {
oids_sign_alg: &[EC_PUBLIC_KEY, EC_SECP_521_R1],
#[cfg(feature = "crypto")]
sign_alg: SignAlgo::EcDsa(&signature::ECDSA_P521_SHA384_ASN1_SIGNING),
// ecdsa-with-SHA384 in RFC 5758
oid_components: &[1, 2, 840, 10045, 4, 3, 3],
params: SignatureAlgorithmParams::None,
};

/// ECDSA signing using the P-521 curves and SHA-512 hashing as per [RFC 5758](https://tools.ietf.org/html/rfc5758#section-3.2)
/// Currently this is only supported with the `aws_lc_rs` feature
///
/// Only supported with the `aws_lc_rs` backend.
#[cfg(feature = "aws_lc_rs")]
pub static PKCS_ECDSA_P521_SHA512: SignatureAlgorithm = SignatureAlgorithm {
oids_sign_alg: &[EC_PUBLIC_KEY, EC_SECP_521_R1],
Expand Down
15 changes: 14 additions & 1 deletion verify-tests/tests/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ mod test_key_params_mismatch {
&rcgen::PKCS_ECDSA_P256_SHA256,
&rcgen::PKCS_ECDSA_P384_SHA384,
#[cfg(feature = "aws_lc_rs")]
&rcgen::PKCS_ECDSA_P521_SHA256,
#[cfg(feature = "aws_lc_rs")]
&rcgen::PKCS_ECDSA_P521_SHA384,
#[cfg(feature = "aws_lc_rs")]
&rcgen::PKCS_ECDSA_P521_SHA512,
&rcgen::PKCS_ED25519,
];
Expand All @@ -28,7 +32,16 @@ mod test_key_params_mismatch {
}

assert_ne!(*kalg_1, *kalg_2);
assert_ne!(generate_hash(*kalg_1), generate_hash(*kalg_2));
let names = [format!("{kalg_1:?}"), format!("{kalg_2:?}")];
if names.into_iter().all(|n| n.starts_with("PKCS_ECDSA_P521")) {
continue;
}

assert_ne!(
generate_hash(*kalg_1),
generate_hash(*kalg_2),
"{kalg_1:?} vs {kalg_2:?}",
);
}
}
}
Expand Down