Skip to main content

craton_hsm/
lib.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 Craton Software Company
3//! Craton HSM — a PKCS#11 v3.0-compliant Software HSM in pure Rust.
4//!
5//! This crate provides a complete software HSM implementation with classical
6//! and post-quantum cryptography, FIPS 140-3 readiness, and a C ABI compatible
7//! with any PKCS#11 consumer.
8
9#![warn(missing_docs)]
10#![allow(missing_docs)]
11#![allow(clippy::unnecessary_cast)]
12#![allow(clippy::not_unsafe_ptr_arg_deref)]
13#![allow(clippy::type_complexity)]
14#![allow(clippy::module_inception)]
15#![allow(clippy::field_reassign_with_default)]
16#![allow(clippy::doc_lazy_continuation)]
17#![allow(dead_code)]
18#![allow(clippy::too_many_arguments)]
19
20/// Tamper-evident audit logging with chained SHA-256.
21pub mod audit;
22/// Configuration — TOML-based `HsmConfig` with algorithm policy.
23pub mod config;
24/// Core HSM state — the central `HsmCore` struct shared by all entry points.
25pub mod core;
26/// Cryptographic operations — keygen, sign, encrypt, digest, PQC, DRBG, self-tests, backends.
27pub mod crypto;
28/// Error types — `HsmError` enum with `CK_RV` mapping.
29pub mod error;
30/// PKCS#11 C ABI layer — types, constants, and 70+ `#[no_mangle]` function exports.
31///
32/// This module uses PKCS#11 naming conventions (e.g., `CK_RV`, `CKR_OK`, `C_Initialize`)
33/// which require `non_camel_case_types`, `non_snake_case`, and `non_upper_case_globals`.
34#[allow(non_camel_case_types, non_snake_case, non_upper_case_globals)]
35pub mod pkcs11_abi;
36/// Platform-specific file ACL helpers (Windows DACL restriction).
37#[cfg(windows)]
38pub(crate) mod platform_acl;
39/// Session management — `SessionManager`, session state machine, handle allocation.
40pub mod session;
41/// Object storage — in-memory `ObjectStore`, encrypted persistence, key material, backups.
42pub mod store;
43/// Token and slot management — PIN hashing, login state, multi-slot support.
44pub mod token;