Skip to content

Commit 1b1bbce

Browse files
flihpFawazTirmizi
authored andcommitted
lib-dice: Replace START / END with Range in cert templates. (oxidecomputer#761)
This simplifies the get / set functions in the Cert trait. This resolves oxidecomputer#747
1 parent 1c737c3 commit 1b1bbce

File tree

7 files changed

+123
-211
lines changed

7 files changed

+123
-211
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/dice/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ serde-big-array = "0.4"
1212
sha3 = { version = "0.10", default-features = false }
1313
unwrap-lite = { path = "../unwrap-lite" }
1414
zeroize = { version = "1.5.7", default-features = false, features = ["zeroize_derive"] }
15+
zerocopy = "0.6"
1516

1617
[dependencies.salty]
1718
git = "https://github.com/oxidecomputer/salty"

lib/dice/src/alias_cert_tmpl.rs

Lines changed: 10 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,48 +10,17 @@
1010
// validity etc) are then removed.
1111
//
1212
// TODO: generate cert template DER from ASN.1 & text config
13-
#[allow(dead_code)]
13+
14+
use core::ops::Range;
15+
1416
pub const SIZE: usize = 608;
15-
#[allow(dead_code)]
16-
pub const SERIAL_NUMBER_START: usize = 15;
17-
#[allow(dead_code)]
18-
pub const SERIAL_NUMBER_END: usize = 16;
19-
#[allow(dead_code)]
20-
pub const ISSUER_SN_START: usize = 169;
21-
#[allow(dead_code)]
22-
pub const ISSUER_SN_END: usize = 181;
23-
#[allow(dead_code)]
24-
pub const SN_LENGTH: usize = 12;
25-
#[allow(dead_code)]
26-
pub const NOTBEFORE_START: usize = 185;
27-
#[allow(dead_code)]
28-
pub const NOTBEFORE_END: usize = 198;
29-
#[allow(dead_code)]
30-
pub const NOTBEFORE_LENGTH: usize = 13;
31-
#[allow(dead_code)]
32-
pub const SUBJECT_SN_START: usize = 357;
33-
#[allow(dead_code)]
34-
pub const SUBJECT_SN_END: usize = 369;
35-
#[allow(dead_code)]
36-
pub const PUB_START: usize = 381;
37-
#[allow(dead_code)]
38-
pub const PUB_END: usize = 413;
39-
#[allow(dead_code)]
40-
pub const SIG_START: usize = 544;
41-
#[allow(dead_code)]
42-
pub const SIG_END: usize = 608;
43-
#[allow(dead_code)]
44-
pub const SIGNDATA_START: usize = 4;
45-
#[allow(dead_code)]
46-
pub const SIGNDATA_END: usize = 534;
47-
#[allow(dead_code)]
48-
pub const SIGNDATA_LENGTH: usize = 530;
49-
#[allow(dead_code)]
50-
pub const FWID_START: usize = 502;
51-
#[allow(dead_code)]
52-
pub const FWID_END: usize = 534;
53-
#[allow(dead_code)]
54-
pub const FWID_LENGTH: usize = 32;
17+
pub const SERIAL_NUMBER_RANGE: Range<usize> = 15..16;
18+
pub const ISSUER_SN_RANGE: Range<usize> = 169..181;
19+
pub const SUBJECT_SN_RANGE: Range<usize> = 357..369;
20+
pub const PUB_RANGE: Range<usize> = 381..413;
21+
pub const SIG_RANGE: Range<usize> = 544..608;
22+
pub const SIGNDATA_RANGE: Range<usize> = 4..534;
23+
pub const FWID_RANGE: Range<usize> = 502..534;
5524
pub const CERT_TMPL: [u8; 608] = [
5625
0x30, 0x82, 0x02, 0x5c, 0x30, 0x82, 0x02, 0x0e, 0xa0, 0x03, 0x02, 0x01,
5726
0x02, 0x02, 0x01, 0x00, 0x30, 0x05, 0x06, 0x03, 0x2b, 0x65, 0x70, 0x30,

0 commit comments

Comments
 (0)