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