#![no_std]
#[cfg(feature = "alloc")]
extern crate alloc;
#[cfg(feature = "std")]
extern crate std;
pub mod ct;
#[cfg(feature = "bignum")]
pub mod bignum;
#[cfg(feature = "cipher")]
pub mod cipher;
#[cfg(feature = "der")]
pub mod der;
#[cfg(feature = "ec")]
pub mod ec;
#[cfg(feature = "ffi")]
pub mod ffi;
#[cfg(feature = "hash")]
pub mod hash;
#[cfg(feature = "kdf")]
pub mod kdf;
#[cfg(feature = "mldsa")]
pub mod mldsa;
#[cfg(feature = "mlkem")]
pub mod mlkem;
#[cfg(feature = "quic")]
pub mod quic;
#[cfg(feature = "slhdsa")]
pub mod slhdsa;
#[cfg(feature = "rng")]
pub mod rng;
#[cfg(feature = "rsa")]
pub mod rsa;
#[cfg(feature = "x509")]
pub mod signature_registry;
#[cfg(feature = "tls")]
pub mod tls;
#[cfg(feature = "dtls")]
pub mod dtls;
#[cfg(feature = "x509")]
pub mod x509;
#[cfg(test)]
pub(crate) mod test_util {
pub(crate) fn from_hex<const N: usize>(s: &str) -> [u8; N] {
let bytes = s.as_bytes();
assert_eq!(bytes.len(), 2 * N, "hex string has wrong length");
let mut out = [0u8; N];
let mut i = 0;
while i < N {
let hi = (bytes[2 * i] as char).to_digit(16).expect("invalid hex") as u8;
let lo = (bytes[2 * i + 1] as char)
.to_digit(16)
.expect("invalid hex") as u8;
out[i] = (hi << 4) | lo;
i += 1;
}
out
}
#[cfg(feature = "alloc")]
pub(crate) fn from_hex_vec(s: &str) -> alloc::vec::Vec<u8> {
let digits: alloc::vec::Vec<u8> = s.bytes().filter(|b| !b.is_ascii_whitespace()).collect();
assert_eq!(digits.len() % 2, 0, "hex string has odd length");
digits
.chunks(2)
.map(|pair| {
let hi = (pair[0] as char).to_digit(16).expect("invalid hex") as u8;
let lo = (pair[1] as char).to_digit(16).expect("invalid hex") as u8;
(hi << 4) | lo
})
.collect()
}
#[cfg(all(feature = "rsa", feature = "der", feature = "alloc"))]
pub(crate) fn rsa_test_key_a() -> crate::rsa::RsaPrivateKey<32> {
crate::rsa::RsaPrivateKey::from_pkcs1_pem(include_str!("../testdata/rsa2048_test_a.pem"))
.expect("parse RSA-2048 test key A")
}
#[cfg(all(feature = "rsa", feature = "der", feature = "alloc"))]
pub(crate) fn rsa_test_key_b() -> crate::rsa::RsaPrivateKey<32> {
crate::rsa::RsaPrivateKey::from_pkcs1_pem(include_str!("../testdata/rsa2048_test_b.pem"))
.expect("parse RSA-2048 test key B")
}
}