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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
//! Ed448 digital signatures implementation
//!
//! # Example
//! Creating an ed448 signature.
//!
//! Generate a [`SigningKey`], which includes both the public and secret halves, using
//! a cryptographically secure pseudorandom number generator (CSPRNG). Next sign a message
//! to produce a [`Signature`]. Then verify the signature using the corresponding
//! [`VerifyingKey`].
//!
//! ```
//! use cx448::*;
//!
//! let mut rng = rand::rngs::OsRng;
//! let signing_key = SigningKey::generate(&mut rng);
//! let signature = signing_key.sign_raw(b"Hello, world!");
//! let verifying_key = signing_key.verifying_key();
//!
//! assert!(verifying_key.verify_raw(&signature, b"Hello, world!").is_ok());
//! ```
//!
//! This crate also supports using context specific strings when creating and verifying signatures.
//! In addition, it supports the PKCS#8 standard for encoding and decoding keys, or raw byte forms
//! using `to_bytes` and `from_bytes` methods. These store the [`SecretKey`] which is the prehash
//! seed of the [`SigningKey`].
//!
//! # PKCS#8 Key Encoding
//! PKCS#8 is a private key format with support for multiple algorithms. It can be encoded as
//! binary (DER) or text (PEM). Use the `pkcs8` feature to enable this option.
//!
//! # Using Serde
//! This crate supports serialization and deserialization using the `serde` if the preference
//! is to encode the keys as other formats. Use the `serde` feature to enable this option.
//!
//! # Using Signature
//! This crate supports signing using the traits defined in the `signature` crate like
//! - [`Signer`]
//! - [`DigestSigner`]
//! - [`PrehashSigner`]
//! - [`Verifier`]
//! - [`DigestVerifier`]
//!
//! The crate is re-exported as `crypto-signature` for use in other crates.
//!
//! # Other Features
//! Signing and verifying also supports custom digest and prehash algorithms.
//! Any algorith that implements [`PreHash`] and [`Digest`] can be used.
//! However, there are two implementations provided in this crate:
//!
//! - [`PreHasherXmd`] which supports any implementation of a fixed length digest like SHA3-512.
//! - [`PreHasherXof`] which supports any implementation of expandable output functions like SHAKE-256.
//!
//! # Example
//! This is an example of using the SHAKE-256 algorithm to sign and verify a message
//! which is the normal default anyway but performed explicitly.
//! ```
//! use cx448::*;
//! use sha3::{Shake256, digest::Update};
//!
//! let mut rng = rand::rngs::OsRng;
//! let msg = b"Hello World";
//! let signing_key = SigningKey::generate(&mut rng);
//! let signature = signing_key.sign_prehashed::<PreHasherXof<Shake256>>(
//! None,
//! Shake256::default().chain(msg).into(),
//! ).unwrap();
//! let verifying_key = signing_key.verifying_key();
//! assert!(verifying_key.verify_prehashed::<PreHasherXof<Shake256>>(
//! &signature, None, Shake256::default().chain(msg).into()).is_ok());
//! ```
pub use *;
pub use crypto_signature;
pub use *;
pub use pkcs8;
pub use *;
pub use *;
pub use *;
/// Length of a secret key in bytes
pub const SECRET_KEY_LENGTH: usize = 57;
/// Length of a public key in bytes
pub const PUBLIC_KEY_LENGTH: usize = 57;
/// Length of a signature in bytes
pub const SIGNATURE_LENGTH: usize = 114;
/// Constant string "SigEd448".
pub const HASH_HEAD: = ;
/// The OID for Ed448 as defined in [RFC8410 §2]
pub const ALGORITHM_OID: ObjectIdentifier =
new_unwrap;
/// The `AlgorithmIdentifier` for Ed448 as defined in [RFC8410 §2]
pub const ALGORITHM_ID: AlgorithmIdentifierRef = AlgorithmIdentifierRef ;