Skip to content

Commit 739e362

Browse files
committed
upki: use aws-lc-rs for hashing
1 parent 8f6babd commit 739e362

5 files changed

Lines changed: 44 additions & 88 deletions

File tree

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ aws-lc-rs = "1.15.2"
1313
base64 = "0.22.1"
1414
chrono = { version = "0.4.42", features = ["alloc"], default-features = false }
1515
clap = { version = "4.5", features = ["derive"] }
16-
clubcard-crlite = "0.5"
16+
clubcard-crlite = { version = "0.5", default-features = false, features = ["bincode"] }
1717
criterion = "0.8"
1818
csv = "1.4"
1919
directories = "6"

rustls-upki/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,16 @@ impl ServerVerifier {
117117
return self.policy.cert_has_no_scts.as_result();
118118
}
119119

120-
let input = RevocationCheckInput {
121-
cert_serial: CertSerial(
120+
let input = RevocationCheckInput::new(
121+
CertSerial(
122122
verified_path
123123
.end_entity()
124124
.serial()
125125
.to_vec(),
126126
),
127-
issuer_spki_hash: IssuerSpkiHash(issuer_spki_hash),
127+
IssuerSpkiHash(issuer_spki_hash),
128128
sct_timestamps,
129-
};
129+
);
130130

131131
match Index::from_cache(&self.config).and_then(|mut index| index.check(&input)) {
132132
Ok(rs) => Ok(rs),

upki/src/revocation/index.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -449,14 +449,14 @@ mod tests {
449449
}
450450

451451
fn test_input() -> RevocationCheckInput {
452-
RevocationCheckInput {
453-
cert_serial: CertSerial(vec![1, 2, 3]),
454-
issuer_spki_hash: IssuerSpkiHash([0xaa; 32]),
455-
sct_timestamps: vec![CtTimestamp {
452+
RevocationCheckInput::new(
453+
CertSerial(vec![1, 2, 3]),
454+
IssuerSpkiHash([0xaa; 32]),
455+
vec![CtTimestamp {
456456
log_id: [0xbb; 32],
457457
timestamp: 1000,
458458
}],
459-
}
459+
)
460460
}
461461

462462
#[expect(clippy::type_complexity)]

upki/src/revocation/mod.rs

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ pub struct RevocationCheckInput {
126126
pub issuer_spki_hash: IssuerSpkiHash,
127127
/// CT log IDs and inclusion timestamps present in the end-entity certificate.
128128
pub sct_timestamps: Vec<CtTimestamp>,
129+
issuer_serial_hash: [u8; 32],
129130
}
130131

131132
impl RevocationCheckInput {
@@ -151,7 +152,7 @@ impl RevocationCheckInput {
151152
digest::digest(&digest::SHA256, &webpki::spki_for_anchor(&issuer))
152153
.as_ref()
153154
.try_into()
154-
.expect("sha256 output must be [u8;32]"),
155+
.expect("sha256 output must be [u8; 32]"),
155156
);
156157

157158
let mut sct_timestamps = vec![];
@@ -167,15 +168,42 @@ impl RevocationCheckInput {
167168
});
168169
}
169170

170-
Ok(Self {
171-
cert_serial: CertSerial(end_entity.serial().into()),
171+
Ok(Self::new(
172+
CertSerial(end_entity.serial().to_vec()),
172173
issuer_spki_hash,
173174
sct_timestamps,
174-
})
175+
))
176+
}
177+
178+
/// Construct a `RevocationCheckInput` from its constituent parts.
179+
pub fn new(
180+
cert_serial: CertSerial,
181+
issuer_spki_hash: IssuerSpkiHash,
182+
sct_timestamps: Vec<CtTimestamp>,
183+
) -> Self {
184+
let mut issuer_serial_context = digest::Context::new(&digest::SHA256);
185+
issuer_serial_context.update(&cert_serial.0);
186+
issuer_serial_context.update(&issuer_spki_hash.0);
187+
let issuer_serial_hash = issuer_serial_context
188+
.finish()
189+
.as_ref()
190+
.try_into()
191+
.expect("sha256 output must be [u8; 32]");
192+
193+
Self {
194+
cert_serial,
195+
issuer_spki_hash,
196+
sct_timestamps,
197+
issuer_serial_hash,
198+
}
175199
}
176200

177201
fn key(&self) -> CRLiteKey<'_> {
178-
CRLiteKey::new(&self.issuer_spki_hash, &self.cert_serial.0)
202+
CRLiteKey::with_hash(
203+
&self.issuer_spki_hash,
204+
&self.cert_serial.0,
205+
self.issuer_serial_hash,
206+
)
179207
}
180208
}
181209

0 commit comments

Comments
 (0)