1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//! # age‑setup – Simple, Secure X25519 Key Pair Generation for Age
//!
//! This crate provides a one‑function API for generating X25519 key pairs
//! compatible with the [**age** encryption tool](https://age-encryption.org/).
//! Every generated key pair is automatically validated and protected by
//! memory‑zeroisation, so you can focus on encrypting data without worrying
//! about cryptographic details or secret leakage.
//!
//! ## Design
//!
//! The crate is organised into small, focused modules:
//!
//! | Module | Responsibility |
//! |--------|----------------|
//! | [`generator`] | The main entry point – generates a fresh [`KeyPair`]. |
//! | [`keypair`] | The [`KeyPair`] struct that holds a [`PublicKey`] and a [`SecretKey`]. |
//! | [`public_key`] | A validated wrapper for age public keys (prefix `age1`). |
//! | [`secret_key`] | A validated wrapper for age secret keys, with zeroisation on drop. |
//! | [`security`] | Low‑level memory‑zeroisation helpers (public, reusable). |
//! | [`validation`] | Internal sanity checks used by [`PublicKey`] and [`SecretKey`]. |
//! | [`errors`] | All error types returned by the crate. |
//!
//! ## Quick start
//!
//! ```rust
//! use age_setup::build_keypair;
//!
//! fn main() -> age_setup::Result<()> {
//! let kp = build_keypair()?;
//! println!("Public key: {}", kp.public); // age1...
//! println!("Secret key: {}", kp.secret); // [REDACTED]
//! Ok(())
//! }
//! ```
//!
//! ## Feature flags
//!
//! This crate does not expose any feature flags itself; it inherits the
//! default TLS backend from the `age` crate (`rustls`). You can switch to
//! native‑TLS by enabling the corresponding feature in `age`.
// ---------------------------------------------------------------------------
// Public re‑exports – everything you need to generate and work with key pairs
// ---------------------------------------------------------------------------
/// All error types used by the crate.
///
/// Re‑exports:
/// - [`errors::Error`] – the main error enum (generation + validation).
/// - [`errors::GenerationError`] – errors that can occur during key creation.
/// - [`errors::ValidationError`] – errors for invalid public/secret key formats.
/// - [`errors::Result`] – a convenience alias for `std::result::Result<T, Error>`.
pub use ;
/// The core function that generates a new X25519 key pair.
///
/// See [`generator::build_keypair`] for detailed documentation.
pub use build_keypair;
/// A validated, memory‑safe age key pair.
///
/// Contains a [`PublicKey`] and a [`SecretKey`]. Obtained exclusively via
/// [`build_keypair`].
pub use KeyPair;
/// A validated age public key that always starts with `age1`.
///
/// Safe to display, share, and clone.
pub use PublicKey;
/// A validated age secret key that is automatically zeroised when dropped.
///
/// Its [`Display`] and [`Debug`] implementations print `[REDACTED]` to prevent
/// accidental exposure.
pub use SecretKey;