c2pa_raw_crypto/lib.rs
1// Copyright 2026 Adobe. All rights reserved.
2// This file is licensed to you under the Apache License,
3// Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
4// or the MIT license (http://opensource.org/licenses/MIT),
5// at your option.
6
7// Unless required by applicable law or agreed to in writing,
8// this software is distributed on an "AS IS" BASIS, WITHOUT
9// WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or
10// implied. See the LICENSE-MIT and LICENSE-APACHE files for the
11// specific language governing permissions and limitations under
12// each license.
13
14#![doc = include_str!("../README.md")]
15#![deny(missing_docs)]
16
17// Note: `SigningAlg` is defined in this crate, so `#[non_exhaustive]` does not
18// force a wildcard arm on the matches below; downstream crates, however, must
19// account for future algorithms.
20//
21// Backend selection: `rust_native_crypto` takes precedence. When both features
22// are enabled (which can happen through Cargo feature unification in a
23// workspace), the signer/validator dispatch uses the rust-native backend; the
24// OpenSSL backend is still compiled but goes unused. The OpenSSL backend is
25// exercised only when `openssl` is enabled and `rust_native_crypto` is not.
26
27pub mod ec_utils;
28pub mod oids;
29
30mod oid;
31pub use oid::Oid;
32
33// The OpenSSL backend is *compiled* whenever the `openssl` feature is enabled,
34// but the runtime dispatch (see `signer.rs` / `validator.rs`) only selects it
35// when `rust_native_crypto` is not also enabled. This split keeps the API
36// surface (e.g. `OpenSslMutex`) consistent for downstream crates regardless of
37// how Cargo unifies features.
38#[cfg(feature = "openssl")]
39mod openssl;
40#[cfg(feature = "openssl")]
41pub use openssl::{OpenSslMutex, OpenSslMutexUnavailable};
42
43#[cfg(feature = "rust_native_crypto")]
44mod rust_native;
45
46mod signer;
47pub use signer::{RawSigner, RawSignerError, signer_from_private_key};
48
49mod signing_alg;
50pub use signing_alg::{SigningAlg, UnknownAlgorithmError};
51
52#[cfg(test)]
53mod tests;
54
55mod validator;
56pub use validator::{
57 RawSignatureValidationError, RawSignatureValidator, validator_for_sig_and_hash_algs,
58 validator_for_signing_alg,
59};