| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
use std::sync::LazyLock; |
| 5 |
|
| 6 |
|
| 7 |
const TEST_PEMS_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../../../../tests/pems/"); |
| 8 |
|
| 9 |
pub static ML_DSA_87: LazyLock<CertMaterials> = LazyLock::new(|| CertMaterials { |
| 10 |
server_key_path: format!("{TEST_PEMS_PATH}mldsa/ML-DSA-87-seed.priv"), |
| 11 |
server_chain_path: format!("{TEST_PEMS_PATH}mldsa/ML-DSA-87.crt"), |
| 12 |
ca_path: format!("{TEST_PEMS_PATH}mldsa/ML-DSA-87.crt"), |
| 13 |
}); |
| 14 |
|
| 15 |
pub static ML_DSA_44: LazyLock<CertMaterials> = LazyLock::new(|| CertMaterials { |
| 16 |
server_key_path: format!("{TEST_PEMS_PATH}mldsa/ML-DSA-44-seed.priv"), |
| 17 |
server_chain_path: format!("{TEST_PEMS_PATH}mldsa/ML-DSA-44.crt"), |
| 18 |
ca_path: format!("{TEST_PEMS_PATH}mldsa/ML-DSA-44.crt"), |
| 19 |
}); |
| 20 |
|
| 21 |
|
| 22 |
pub static BEAVER: LazyLock<CertMaterials> = LazyLock::new(|| CertMaterials { |
| 23 |
server_key_path: format!("{TEST_PEMS_PATH}sni/beaver_key.pem"), |
| 24 |
server_chain_path: format!("{TEST_PEMS_PATH}sni/beaver_cert.pem"), |
| 25 |
ca_path: format!("{TEST_PEMS_PATH}sni/beaver_cert.pem"), |
| 26 |
}); |
| 27 |
|
| 28 |
|
| 29 |
#[derive(Debug, Clone)] |
| 30 |
pub struct CertMaterials { |
| 31 |
pub server_key_path: String, |
| 32 |
pub server_chain_path: String, |
| 33 |
|
| 34 |
|
| 35 |
pub ca_path: String, |
| 36 |
} |
| 37 |
|
| 38 |
impl CertMaterials { |
| 39 |
|
| 40 |
pub fn from_permutation(permutation: &str) -> Self { |
| 41 |
let folder = format!("{TEST_PEMS_PATH}permutations/{permutation}"); |
| 42 |
CertMaterials { |
| 43 |
server_key_path: format!("{folder}/server-key.pem"), |
| 44 |
server_chain_path: format!("{folder}/server-chain.pem"), |
| 45 |
ca_path: format!("{folder}/ca-cert.pem"), |
| 46 |
} |
| 47 |
} |
| 48 |
|
| 49 |
pub fn server_chain(&self) -> Vec<u8> { |
| 50 |
std::fs::read(&self.server_chain_path).unwrap() |
| 51 |
} |
| 52 |
|
| 53 |
pub fn server_key(&self) -> Vec<u8> { |
| 54 |
std::fs::read(&self.server_key_path).unwrap() |
| 55 |
} |
| 56 |
|
| 57 |
pub fn ca(&self) -> Vec<u8> { |
| 58 |
std::fs::read(&self.ca_path).unwrap() |
| 59 |
} |
| 60 |
} |