1#![no_std]
30#![warn(
31 elided_lifetimes_in_paths,
32 unnameable_types,
33 unreachable_pub,
34 clippy::alloc_instead_of_core,
35 clippy::use_self,
36 clippy::std_instead_of_core
37)]
38#![deny(missing_docs, clippy::as_conversions)]
39#![allow(
40 clippy::len_without_is_empty,
41 clippy::manual_let_else,
42 clippy::new_without_default,
43 clippy::single_match,
44 clippy::single_match_else,
45 clippy::type_complexity,
46 clippy::upper_case_acronyms
47)]
48#![cfg_attr(webpki_docsrs, feature(doc_cfg))]
50
51#[cfg(any(feature = "std", test))]
52extern crate std;
53
54#[cfg(any(test, feature = "alloc"))]
55#[cfg_attr(test, macro_use)]
56extern crate alloc;
57
58#[macro_use]
59mod der;
60
61#[cfg(feature = "aws-lc-rs")]
62mod aws_lc_rs_algs;
63mod cert;
64mod end_entity;
65mod error;
66#[cfg(feature = "ring")]
67mod ring_algs;
68mod rpk_entity;
69mod signed_data;
70mod subject_name;
71mod time;
72mod trust_anchor;
73
74mod crl;
75mod verify_cert;
76mod x509;
77
78#[cfg(test)]
79pub(crate) mod test_utils;
80
81pub use {
82 cert::Cert,
83 crl::{
84 BorrowedCertRevocationList, BorrowedRevokedCert, CertRevocationList, CrlsRequired,
85 ExpirationPolicy, RevocationCheckDepth, RevocationOptions, RevocationOptionsBuilder,
86 RevocationReason, UnknownStatusPolicy,
87 },
88 der::DerIterator,
89 end_entity::EndEntityCert,
90 error::{
91 DerTypeId, Error, InvalidNameContext, UnsupportedSignatureAlgorithmContext,
92 UnsupportedSignatureAlgorithmForPublicKeyContext,
93 },
94 rpk_entity::RawPublicKeyEntity,
95 trust_anchor::anchor_from_trusted_cert,
96 verify_cert::{
97 ExtendedKeyUsage, ExtendedKeyUsageValidator, IntermediateIterator, KeyPurposeId,
98 KeyPurposeIdIter, RequiredEkuNotFoundContext, VerifiedPath,
99 },
100};
101
102#[cfg(feature = "alloc")]
103pub use crl::{OwnedCertRevocationList, OwnedRevokedCert};
104
105#[cfg(feature = "ring")]
106pub mod ring {
108 pub use super::ring_algs::{
109 ECDSA_P256_SHA256, ECDSA_P256_SHA384, ECDSA_P384_SHA256, ECDSA_P384_SHA384, ED25519,
110 };
111
112 #[cfg(feature = "alloc")]
113 pub use super::ring_algs::{
114 RSA_PKCS1_2048_8192_SHA256, RSA_PKCS1_2048_8192_SHA256_ABSENT_PARAMS,
115 RSA_PKCS1_2048_8192_SHA384, RSA_PKCS1_2048_8192_SHA384_ABSENT_PARAMS,
116 RSA_PKCS1_2048_8192_SHA512, RSA_PKCS1_2048_8192_SHA512_ABSENT_PARAMS,
117 RSA_PKCS1_3072_8192_SHA384, RSA_PSS_2048_8192_SHA256_LEGACY_KEY,
118 RSA_PSS_2048_8192_SHA384_LEGACY_KEY, RSA_PSS_2048_8192_SHA512_LEGACY_KEY,
119 };
120}
121
122#[cfg(feature = "aws-lc-rs")]
123pub mod aws_lc_rs {
125 pub use super::aws_lc_rs_algs::{
126 ECDSA_P256_SHA256, ECDSA_P256_SHA384, ECDSA_P256_SHA512, ECDSA_P384_SHA256,
127 ECDSA_P384_SHA384, ECDSA_P384_SHA512, ECDSA_P521_SHA256, ECDSA_P521_SHA384,
128 ECDSA_P521_SHA512, ED25519, RSA_PKCS1_2048_8192_SHA256,
129 RSA_PKCS1_2048_8192_SHA256_ABSENT_PARAMS, RSA_PKCS1_2048_8192_SHA384,
130 RSA_PKCS1_2048_8192_SHA384_ABSENT_PARAMS, RSA_PKCS1_2048_8192_SHA512,
131 RSA_PKCS1_2048_8192_SHA512_ABSENT_PARAMS, RSA_PKCS1_3072_8192_SHA384,
132 RSA_PSS_2048_8192_SHA256_LEGACY_KEY, RSA_PSS_2048_8192_SHA384_LEGACY_KEY,
133 RSA_PSS_2048_8192_SHA512_LEGACY_KEY,
134 };
135 #[cfg(all(feature = "aws-lc-rs-unstable", not(feature = "aws-lc-rs-fips")))]
136 pub use super::aws_lc_rs_algs::{ML_DSA_44, ML_DSA_65, ML_DSA_87};
137}
138
139pub static ALL_VERIFICATION_ALGS: &[&dyn pki_types::SignatureVerificationAlgorithm] = &[
143 #[cfg(feature = "ring")]
144 ring::ECDSA_P256_SHA256,
145 #[cfg(feature = "ring")]
146 ring::ECDSA_P256_SHA384,
147 #[cfg(feature = "ring")]
148 ring::ECDSA_P384_SHA256,
149 #[cfg(feature = "ring")]
150 ring::ECDSA_P384_SHA384,
151 #[cfg(feature = "ring")]
152 ring::ED25519,
153 #[cfg(all(feature = "ring", feature = "alloc"))]
154 ring::RSA_PKCS1_2048_8192_SHA256,
155 #[cfg(all(feature = "ring", feature = "alloc"))]
156 ring::RSA_PKCS1_2048_8192_SHA384,
157 #[cfg(all(feature = "ring", feature = "alloc"))]
158 ring::RSA_PKCS1_2048_8192_SHA512,
159 #[cfg(all(feature = "ring", feature = "alloc"))]
160 ring::RSA_PKCS1_2048_8192_SHA256_ABSENT_PARAMS,
161 #[cfg(all(feature = "ring", feature = "alloc"))]
162 ring::RSA_PKCS1_2048_8192_SHA384_ABSENT_PARAMS,
163 #[cfg(all(feature = "ring", feature = "alloc"))]
164 ring::RSA_PKCS1_2048_8192_SHA512_ABSENT_PARAMS,
165 #[cfg(all(feature = "ring", feature = "alloc"))]
166 ring::RSA_PKCS1_3072_8192_SHA384,
167 #[cfg(all(feature = "ring", feature = "alloc"))]
168 ring::RSA_PSS_2048_8192_SHA256_LEGACY_KEY,
169 #[cfg(all(feature = "ring", feature = "alloc"))]
170 ring::RSA_PSS_2048_8192_SHA384_LEGACY_KEY,
171 #[cfg(all(feature = "ring", feature = "alloc"))]
172 ring::RSA_PSS_2048_8192_SHA512_LEGACY_KEY,
173 #[cfg(feature = "aws-lc-rs")]
174 aws_lc_rs::ECDSA_P256_SHA256,
175 #[cfg(feature = "aws-lc-rs")]
176 aws_lc_rs::ECDSA_P256_SHA384,
177 #[cfg(feature = "aws-lc-rs")]
178 aws_lc_rs::ECDSA_P256_SHA512,
179 #[cfg(feature = "aws-lc-rs")]
180 aws_lc_rs::ECDSA_P384_SHA256,
181 #[cfg(feature = "aws-lc-rs")]
182 aws_lc_rs::ECDSA_P384_SHA384,
183 #[cfg(feature = "aws-lc-rs")]
184 aws_lc_rs::ECDSA_P384_SHA512,
185 #[cfg(feature = "aws-lc-rs")]
186 aws_lc_rs::ECDSA_P521_SHA256,
187 #[cfg(feature = "aws-lc-rs")]
188 aws_lc_rs::ECDSA_P521_SHA384,
189 #[cfg(feature = "aws-lc-rs")]
190 aws_lc_rs::ECDSA_P521_SHA512,
191 #[cfg(feature = "aws-lc-rs")]
192 aws_lc_rs::ED25519,
193 #[cfg(feature = "aws-lc-rs")]
194 aws_lc_rs::RSA_PKCS1_2048_8192_SHA256,
195 #[cfg(feature = "aws-lc-rs")]
196 aws_lc_rs::RSA_PKCS1_2048_8192_SHA384,
197 #[cfg(feature = "aws-lc-rs")]
198 aws_lc_rs::RSA_PKCS1_2048_8192_SHA512,
199 #[cfg(feature = "aws-lc-rs")]
200 aws_lc_rs::RSA_PKCS1_2048_8192_SHA256_ABSENT_PARAMS,
201 #[cfg(feature = "aws-lc-rs")]
202 aws_lc_rs::RSA_PKCS1_2048_8192_SHA384_ABSENT_PARAMS,
203 #[cfg(feature = "aws-lc-rs")]
204 aws_lc_rs::RSA_PKCS1_2048_8192_SHA512_ABSENT_PARAMS,
205 #[cfg(feature = "aws-lc-rs")]
206 aws_lc_rs::RSA_PKCS1_3072_8192_SHA384,
207 #[cfg(feature = "aws-lc-rs")]
208 aws_lc_rs::RSA_PSS_2048_8192_SHA256_LEGACY_KEY,
209 #[cfg(feature = "aws-lc-rs")]
210 aws_lc_rs::RSA_PSS_2048_8192_SHA384_LEGACY_KEY,
211 #[cfg(feature = "aws-lc-rs")]
212 aws_lc_rs::RSA_PSS_2048_8192_SHA512_LEGACY_KEY,
213 #[cfg(all(feature = "aws-lc-rs-unstable", not(feature = "aws-lc-rs-fips")))]
214 aws_lc_rs::ML_DSA_44,
215 #[cfg(all(feature = "aws-lc-rs-unstable", not(feature = "aws-lc-rs-fips")))]
216 aws_lc_rs::ML_DSA_65,
217 #[cfg(all(feature = "aws-lc-rs-unstable", not(feature = "aws-lc-rs-fips")))]
218 aws_lc_rs::ML_DSA_87,
219];
220
221fn public_values_eq(a: untrusted::Input<'_>, b: untrusted::Input<'_>) -> bool {
222 a.as_slice_less_safe() == b.as_slice_less_safe()
223}