Skip to main content

webpki/
lib.rs

1// Copyright 2015 Brian Smith.
2//
3// Permission to use, copy, modify, and/or distribute this software for any
4// purpose with or without fee is hereby granted, provided that the above
5// copyright notice and this permission notice appear in all copies.
6//
7// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
8// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
10// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14
15//! webpki: Web PKI X.509 Certificate Validation.
16//!
17//! See `EndEntityCert`'s documentation for a description of the certificate
18//! processing steps necessary for a TLS connection.
19//!
20//! # Features
21//!
22//! | Feature | Description |
23//! | ------- | ----------- |
24//! | `alloc` | Enable features that require use of the heap. Currently all RSA signature algorithms require this feature. |
25//! | `std` | Enable features that require libstd. Implies `alloc`. |
26
27#![no_std]
28#![warn(
29    clippy::alloc_instead_of_core,
30    clippy::use_self,
31    clippy::std_instead_of_core
32)]
33#![deny(missing_docs, clippy::as_conversions)]
34// Enable documentation for all features on docs.rs
35#![cfg_attr(webpki_docsrs, feature(doc_cfg))]
36
37#[cfg(any(feature = "std", test))]
38extern crate std;
39
40#[cfg(any(test, feature = "alloc"))]
41#[cfg_attr(test, macro_use)]
42extern crate alloc;
43
44#[macro_use]
45mod der;
46
47#[cfg(test)]
48mod aws_lc_rs_algs;
49mod cert;
50mod end_entity;
51mod error;
52#[cfg(test)]
53mod ring_algs;
54mod rpk_entity;
55/// Processing of certificate transparency SCTs.
56pub mod sct;
57mod signed_data;
58mod subject_name;
59mod time;
60mod trust_anchor;
61
62mod crl;
63mod verify_cert;
64mod x509;
65
66#[cfg(test)]
67pub(crate) mod test_utils;
68
69pub use {
70    cert::Cert,
71    crl::{
72        BorrowedCertRevocationList, BorrowedRevokedCert, CertRevocationList, CrlsRequired,
73        ExpirationPolicy, RevocationCheckDepth, RevocationOptions, RevocationOptionsBuilder,
74        RevocationReason, UnknownStatusPolicy,
75    },
76    der::DerIterator,
77    end_entity::EndEntityCert,
78    error::{
79        DerTypeId, Error, InvalidNameContext, UnsupportedSignatureAlgorithmContext,
80        UnsupportedSignatureAlgorithmForPublicKeyContext,
81    },
82    rpk_entity::RawPublicKeyEntity,
83    trust_anchor::anchor_from_trusted_cert,
84    verify_cert::{
85        ExtendedKeyUsage, ExtendedKeyUsageValidator, IntermediateIterator, KeyPurposeId,
86        KeyPurposeIdIter, RequiredEkuNotFoundContext, VerifiedPath,
87    },
88};
89
90#[cfg(feature = "alloc")]
91pub use trust_anchor::spki_for_anchor;
92
93#[cfg(feature = "alloc")]
94pub use crl::{OwnedCertRevocationList, OwnedRevokedCert};
95
96fn public_values_eq(a: untrusted::Input<'_>, b: untrusted::Input<'_>) -> bool {
97    a.as_slice_less_safe() == b.as_slice_less_safe()
98}