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//! | `ring` | Enable use of the *ring* crate for cryptography. |
27//! | `aws-lc-rs` | Enable use of the aws-lc-rs crate for cryptography. Previously this feature was named `aws_lc_rs`. |
28
29#![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// Enable documentation for all features on docs.rs
37#![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(test)]
50mod aws_lc_rs_algs;
51mod cert;
52mod end_entity;
53mod error;
54#[cfg(test)]
55mod ring_algs;
56mod rpk_entity;
57/// Processing of certificate transparency SCTs.
58pub 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
98fn public_values_eq(a: untrusted::Input<'_>, b: untrusted::Input<'_>) -> bool {
99    a.as_slice_less_safe() == b.as_slice_less_safe()
100}