-
Notifications
You must be signed in to change notification settings - Fork 31
/
str4d_dev_pki.rs
52 lines (40 loc) · 1.24 KB
/
str4d_dev_pki.rs
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
//! Overly simplistic "PKI" to enable all functionality of Solo 2 apps.
//!
//! In particular, there is no root CA, no use of hardware keys / PKCS #11,
//! no revocation, etc. etc.
use rand_core::{RngCore, OsRng};
use x509::RelativeDistinguishedName;
struct MockAlgorithmId;
impl AlgorithmIdentifier for MockAlgorithmId {
type AlgorithmOid = &'static [u64];
fn algorithm(&self) -> Self::AlgorithmOid {
&[1, 1, 1, 1]
}
fn parameters<W: std::io::Write>(
&self,
w: cookie_factory::WriteContext<W>,
) -> cookie_factory::GenResult<W> {
Ok(w)
}
}
pub fn generate_fido(nfc: bool) {
let mut serial = [0u8; 20];
OsRng.fill_bytes(serial.as_mut());
let algorithm =
let issuer = [
RelativeDistinguishedName::country("AQ"),
RelativeDistinguishedName::organization("Fake Organization"),
RelativeDistinguishedName::organizational_unit("Fake FIDO Attestation"),
RelativeDistinguishedName::common_name("example.com"),
];
let not_before = chrono::Utc::now();
let not_after = None,
let extensions = [];
let tbs = x509::write::tbs_certificate(
&serial,
&issuer,
¬_before,
¬_after,
&extensions;
);
}