uselesskey_core/lib.rs
1#![forbid(unsafe_code)]
2#![cfg_attr(not(feature = "std"), no_std)]
3
4//! Core building blocks for `uselesskey`.
5//!
6//! Most users should depend on the `uselesskey` facade crate instead.
7//!
8//! This crate provides:
9//! - deterministic, order-independent artifact derivation
10//! - a concurrency-friendly cache
11//! - tempfile sinks
12//! - generic "negative fixture" helpers (corrupt PEM, truncate DER)
13//!
14//! # Architecture
15//!
16//! The core concept is the [`Factory`], which manages artifact generation and caching.
17//! It operates in two modes:
18//!
19//! - **Random mode**: Artifacts are generated with OS randomness, cached per-process.
20//! - **Deterministic mode**: Artifacts are derived from a master seed using BLAKE3,
21//! ensuring the same `(domain, label, spec, variant)` always produces the same artifact.
22//!
23//! # Extension Pattern
24//!
25//! Key types (RSA, ECDSA, etc.) are added via extension traits that add methods to `Factory`.
26//! See `uselesskey-rsa` for an example implementation.
27//!
28//! ```
29//! use uselesskey_core::Factory;
30//!
31//! let fx = Factory::random();
32//! // Extension crates add methods like: fx.rsa("label", spec)
33//! ```
34
35mod error;
36mod factory;
37mod id;
38pub mod negative;
39#[cfg(feature = "std")]
40pub mod sink;
41
42pub use crate::error::Error;
43pub use crate::factory::{Factory, Mode};
44pub use crate::id::{ArtifactDomain, ArtifactId, DerivationVersion, Seed};
45
46extern crate alloc;