tor_netdoc/parse2/poc/
authcert.rs1use super::*;
4
5type DirKeyCertificateHash = [u8; 20];
9
10pub use crate::doc::authcert::AuthCert as DirAuthKeyCert;
11pub use crate::doc::authcert::AuthCertSigned as DirAuthKeyCertSigned;
12
13impl DirAuthKeyCertSigned {
14 pub fn verify_selfcert(self, now: SystemTime) -> Result<DirAuthKeyCert, VF> {
20 let hash = self.signatures.dir_key_certification.hash;
22 let body = &self.inspect_unverified().0;
23
24 let validity = body.dir_key_published.0..=body.dir_key_expires.0;
25 check_validity_time(now, validity)?;
26 body.dir_identity_key
27 .verify(&hash, &self.signatures.dir_key_certification.signature)?;
28
29 if *body.fingerprint != body.dir_identity_key.to_rsa_identity() {
31 return Err(VF::Inconsistent);
32 }
33
34 let h_kp_auth_id_rsa: DirKeyCertificateHash =
36 tor_llcrypto::d::Sha1::digest(body.dir_identity_key.to_der()).into();
37 body.dir_signing_key
39 .verify(&h_kp_auth_id_rsa, &body.dir_key_crosscert.signature)?;
40
41 Ok(self.unwrap_unverified().0)
42 }
43}