Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use AlgorithmIdentifier values from rustls-pki-types #304

Merged
merged 1 commit into from
Jan 27, 2025
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
4 changes: 2 additions & 2 deletions Cargo.lock

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

4 changes: 1 addition & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ include = [
"src/verify_cert.rs",
"src/lib.rs",

"src/data/**/*",

"tests/**",
]

Expand All @@ -82,7 +80,7 @@ std = ["alloc", "pki-types/std"]

[dependencies]
aws-lc-rs = { version = "1.9", optional = true, default-features = false }
pki-types = { package = "rustls-pki-types", version = "1.7", default-features = false }
pki-types = { package = "rustls-pki-types", version = "1.11", default-features = false }
ring = { version = "0.17", default-features = false, optional = true }
untrusted = "0.9"

Expand Down
4 changes: 1 addition & 3 deletions src/aws_lc_rs_algs.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use aws_lc_rs::{signature, try_fips_mode};
use pki_types::{AlgorithmIdentifier, InvalidSignature, SignatureVerificationAlgorithm};

use crate::signed_data::alg_id;
use pki_types::{alg_id, AlgorithmIdentifier, InvalidSignature, SignatureVerificationAlgorithm};

// nb. aws-lc-rs has an API that is broadly compatible with *ring*,
// so this is very similar to ring_algs.rs.
Expand Down
21 changes: 0 additions & 21 deletions src/data/README.md

This file was deleted.

1 change: 0 additions & 1 deletion src/data/alg-ecdsa-p256.der

This file was deleted.

Binary file removed src/data/alg-ecdsa-p384.der
Binary file not shown.
Binary file removed src/data/alg-ecdsa-p521.der
Binary file not shown.
1 change: 0 additions & 1 deletion src/data/alg-ecdsa-sha256.der

This file was deleted.

1 change: 0 additions & 1 deletion src/data/alg-ecdsa-sha384.der

This file was deleted.

1 change: 0 additions & 1 deletion src/data/alg-ecdsa-sha512.der

This file was deleted.

1 change: 0 additions & 1 deletion src/data/alg-ed25519.der

This file was deleted.

Binary file removed src/data/alg-rsa-encryption.der
Binary file not shown.
Binary file removed src/data/alg-rsa-pkcs1-sha256.der
Binary file not shown.
Binary file removed src/data/alg-rsa-pkcs1-sha384.der
Binary file not shown.
Binary file removed src/data/alg-rsa-pkcs1-sha512.der
Binary file not shown.
Binary file removed src/data/alg-rsa-pss-sha256.der
Binary file not shown.
Binary file removed src/data/alg-rsa-pss-sha384.der
Binary file not shown.
Binary file removed src/data/alg-rsa-pss-sha512.der
Binary file not shown.
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ pub use {
end_entity::EndEntityCert,
error::{DerTypeId, Error, InvalidNameContext},
rpk_entity::RawPublicKeyEntity,
signed_data::alg_id,
trust_anchor::anchor_from_trusted_cert,
verify_cert::KeyUsage,
verify_cert::VerifiedPath,
Expand Down
4 changes: 1 addition & 3 deletions src/ring_algs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

use pki_types::{AlgorithmIdentifier, InvalidSignature, SignatureVerificationAlgorithm};
use pki_types::{alg_id, AlgorithmIdentifier, InvalidSignature, SignatureVerificationAlgorithm};
use ring::signature;

use crate::signed_data::alg_id;

/// A `SignatureVerificationAlgorithm` implemented using *ring*.
#[derive(Debug)]
struct RingAlgorithm {
Expand Down
80 changes: 1 addition & 79 deletions src/signed_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::der::{self, FromDer};
use crate::error::{DerTypeId, Error};
use crate::verify_cert::Budget;

use pki_types::{AlgorithmIdentifier, SignatureVerificationAlgorithm};
use pki_types::SignatureVerificationAlgorithm;

#[cfg(feature = "alloc")]
use alloc::vec::Vec;
Expand Down Expand Up @@ -249,81 +249,3 @@ impl<'a> FromDer<'a> for SubjectPublicKeyInfo<'a> {

const TYPE_ID: DerTypeId = DerTypeId::SubjectPublicKeyInfo;
}

/// Encodings of the PKIX AlgorithmIdentifier type.
///
/// This module contains a set of common values, and exists to keep the
/// names of these separate from the actual algorithm implementations.
pub mod alg_id {
use super::AlgorithmIdentifier;

// See src/data/README.md.

/// AlgorithmIdentifier for `id-ecPublicKey` with named curve `secp256r1`.
pub const ECDSA_P256: AlgorithmIdentifier =
AlgorithmIdentifier::from_slice(include_bytes!("data/alg-ecdsa-p256.der"));

/// AlgorithmIdentifier for `id-ecPublicKey` with named curve `secp384r1`.
pub const ECDSA_P384: AlgorithmIdentifier =
AlgorithmIdentifier::from_slice(include_bytes!("data/alg-ecdsa-p384.der"));

/// AlgorithmIdentifier for `id-ecPublicKey` with named curve `secp521r1`.
pub const ECDSA_P521: AlgorithmIdentifier =
AlgorithmIdentifier::from_slice(include_bytes!("data/alg-ecdsa-p521.der"));

/// AlgorithmIdentifier for `ecdsa-with-SHA256`.
pub const ECDSA_SHA256: AlgorithmIdentifier =
AlgorithmIdentifier::from_slice(include_bytes!("data/alg-ecdsa-sha256.der"));

/// AlgorithmIdentifier for `ecdsa-with-SHA384`.
pub const ECDSA_SHA384: AlgorithmIdentifier =
AlgorithmIdentifier::from_slice(include_bytes!("data/alg-ecdsa-sha384.der"));

/// AlgorithmIdentifier for `ecdsa-with-SHA512`.
pub const ECDSA_SHA512: AlgorithmIdentifier =
AlgorithmIdentifier::from_slice(include_bytes!("data/alg-ecdsa-sha512.der"));

/// AlgorithmIdentifier for `rsaEncryption`.
pub const RSA_ENCRYPTION: AlgorithmIdentifier =
AlgorithmIdentifier::from_slice(include_bytes!("data/alg-rsa-encryption.der"));

/// AlgorithmIdentifier for `sha256WithRSAEncryption`.
pub const RSA_PKCS1_SHA256: AlgorithmIdentifier =
AlgorithmIdentifier::from_slice(include_bytes!("data/alg-rsa-pkcs1-sha256.der"));

/// AlgorithmIdentifier for `sha384WithRSAEncryption`.
pub const RSA_PKCS1_SHA384: AlgorithmIdentifier =
AlgorithmIdentifier::from_slice(include_bytes!("data/alg-rsa-pkcs1-sha384.der"));

/// AlgorithmIdentifier for `sha512WithRSAEncryption`.
pub const RSA_PKCS1_SHA512: AlgorithmIdentifier =
AlgorithmIdentifier::from_slice(include_bytes!("data/alg-rsa-pkcs1-sha512.der"));

/// AlgorithmIdentifier for `rsassaPss` with:
///
/// - hashAlgorithm: sha256
/// - maskGenAlgorithm: mgf1 with sha256
/// - saltLength: 32
pub const RSA_PSS_SHA256: AlgorithmIdentifier =
AlgorithmIdentifier::from_slice(include_bytes!("data/alg-rsa-pss-sha256.der"));

/// AlgorithmIdentifier for `rsassaPss` with:
///
/// - hashAlgorithm: sha384
/// - maskGenAlgorithm: mgf1 with sha384
/// - saltLength: 48
pub const RSA_PSS_SHA384: AlgorithmIdentifier =
AlgorithmIdentifier::from_slice(include_bytes!("data/alg-rsa-pss-sha384.der"));

/// AlgorithmIdentifier for `rsassaPss` with:
///
/// - hashAlgorithm: sha512
/// - maskGenAlgorithm: mgf1 with sha512
/// - saltLength: 64
pub const RSA_PSS_SHA512: AlgorithmIdentifier =
AlgorithmIdentifier::from_slice(include_bytes!("data/alg-rsa-pss-sha512.der"));

/// AlgorithmIdentifier for `ED25519`.
pub const ED25519: AlgorithmIdentifier =
AlgorithmIdentifier::from_slice(include_bytes!("data/alg-ed25519.der"));
}
Loading