Loading crates/tor-netdoc/semver.md +1 −0 Original line number Diff line number Diff line Loading @@ -32,3 +32,4 @@ ADDED: `impl From<std::convert::Infallible> for Error` ADDED: `RouterStatus` fields `r.dir_port`, `p`, `id`, `stats` ADDED: `plain::NetworkStatus` and `md::NetworkStatus` implement `NetdocEncodable` ADDED: `plain::NetworkStatus` and `md::NetworkStatus` have `verify` methods ADDED: `EmbeddedCert` implements `NetdocEncodable` and `NetdocParseable` crates/tor-netdoc/src/doc/netstatus.rs +1 −1 Original line number Diff line number Diff line Loading @@ -1357,7 +1357,7 @@ pub struct VoteAuthoritySection { /// Authority key certificate #[deftly(constructor)] pub cert: EncodedAuthCert, pub cert: EmbeddedCert<AuthCert, EncodedAuthCert>, #[doc(hidden)] #[deftly(netdoc(skip))] Loading crates/tor-netdoc/src/parse2/poc/netstatus/flavoured.rs +5 −1 Original line number Diff line number Diff line Loading @@ -160,9 +160,11 @@ ns_choose! { ( impl NetworkStatus { /// Parse the embedded authcert // // TODO DIRAUTH abolish/move fn parse_authcert(&self) -> Result<crate::doc::authcert::AuthCertUnverified, EP> { let cert_input = ParseInput::new( self.authority.cert.as_str(), self.authority.cert.raw_unverified().as_str(), "<embedded auth cert>", ); parse_netdoc(&cert_input).map_err(|e| e.problem) Loading @@ -177,6 +179,8 @@ ns_choose! { ( /// /// It is up to the caller to decide whether this identity is actually /// a voter, count up votes, etc. // // TODO DIRAUTH use EmbeddedCert::get pub fn h_kp_auth_id_rsa(&self) -> pk::rsa::RsaIdentity { *self.parse_authcert() // SECURITY: if the user calls this function, they have a bare Loading crates/tor-netdoc/src/types/embedded_cert.rs +38 −2 Original line number Diff line number Diff line //! Types related to certificates use crate::encode::{ItemEncoder, ItemObjectEncodable, ItemValueEncodable}; use crate::parse2::{ErrorProblem as P2EP, ItemObjectParseable, ItemValueParseable, UnparsedItem}; use crate::encode::{ ItemEncoder, ItemObjectEncodable, ItemValueEncodable, NetdocEncodable, NetdocEncoder, }; use crate::parse2::{ ErrorProblem as P2EP, IsStructural, ItemObjectParseable, ItemStream, ItemValueParseable, KeywordRef, NetdocParseable, UnparsedItem, }; use tor_bytes::{Writeable, Writer}; use tor_error::{Bug, internal}; Loading Loading @@ -207,6 +212,15 @@ where } } impl<VD, UR> NetdocEncodable for EmbeddedCert<VD, UR> where UR: NetdocEncodable, { fn encode_unsigned(&self, out: &mut NetdocEncoder) -> Result<(), Bug> { self.unverified.encode_unsigned(out) } } impl<VD, UR> ItemObjectParseable for EmbeddedCert<VD, UR> where VD: EmbeddableCertObject<UR>, Loading Loading @@ -237,5 +251,27 @@ where } } impl<VD, UR> NetdocParseable for EmbeddedCert<VD, UR> where UR: NetdocParseable, { fn doctype_for_error() -> &'static str { UR::doctype_for_error() } fn is_intro_item_keyword(kw: KeywordRef<'_>) -> bool { UR::is_intro_item_keyword(kw) } fn is_structural_keyword(kw: KeywordRef<'_>) -> Option<IsStructural> { UR::is_structural_keyword(kw) } fn from_items(input: &mut ItemStream<'_>, stop_at: stop_at!()) -> Result<Self, P2EP> { let unverified = UR::from_items(input, stop_at)?; Ok(EmbeddedCert::new_unverified_hazardous(unverified)) } } #[cfg(test)] mod test; Loading
crates/tor-netdoc/semver.md +1 −0 Original line number Diff line number Diff line Loading @@ -32,3 +32,4 @@ ADDED: `impl From<std::convert::Infallible> for Error` ADDED: `RouterStatus` fields `r.dir_port`, `p`, `id`, `stats` ADDED: `plain::NetworkStatus` and `md::NetworkStatus` implement `NetdocEncodable` ADDED: `plain::NetworkStatus` and `md::NetworkStatus` have `verify` methods ADDED: `EmbeddedCert` implements `NetdocEncodable` and `NetdocParseable`
crates/tor-netdoc/src/doc/netstatus.rs +1 −1 Original line number Diff line number Diff line Loading @@ -1357,7 +1357,7 @@ pub struct VoteAuthoritySection { /// Authority key certificate #[deftly(constructor)] pub cert: EncodedAuthCert, pub cert: EmbeddedCert<AuthCert, EncodedAuthCert>, #[doc(hidden)] #[deftly(netdoc(skip))] Loading
crates/tor-netdoc/src/parse2/poc/netstatus/flavoured.rs +5 −1 Original line number Diff line number Diff line Loading @@ -160,9 +160,11 @@ ns_choose! { ( impl NetworkStatus { /// Parse the embedded authcert // // TODO DIRAUTH abolish/move fn parse_authcert(&self) -> Result<crate::doc::authcert::AuthCertUnverified, EP> { let cert_input = ParseInput::new( self.authority.cert.as_str(), self.authority.cert.raw_unverified().as_str(), "<embedded auth cert>", ); parse_netdoc(&cert_input).map_err(|e| e.problem) Loading @@ -177,6 +179,8 @@ ns_choose! { ( /// /// It is up to the caller to decide whether this identity is actually /// a voter, count up votes, etc. // // TODO DIRAUTH use EmbeddedCert::get pub fn h_kp_auth_id_rsa(&self) -> pk::rsa::RsaIdentity { *self.parse_authcert() // SECURITY: if the user calls this function, they have a bare Loading
crates/tor-netdoc/src/types/embedded_cert.rs +38 −2 Original line number Diff line number Diff line //! Types related to certificates use crate::encode::{ItemEncoder, ItemObjectEncodable, ItemValueEncodable}; use crate::parse2::{ErrorProblem as P2EP, ItemObjectParseable, ItemValueParseable, UnparsedItem}; use crate::encode::{ ItemEncoder, ItemObjectEncodable, ItemValueEncodable, NetdocEncodable, NetdocEncoder, }; use crate::parse2::{ ErrorProblem as P2EP, IsStructural, ItemObjectParseable, ItemStream, ItemValueParseable, KeywordRef, NetdocParseable, UnparsedItem, }; use tor_bytes::{Writeable, Writer}; use tor_error::{Bug, internal}; Loading Loading @@ -207,6 +212,15 @@ where } } impl<VD, UR> NetdocEncodable for EmbeddedCert<VD, UR> where UR: NetdocEncodable, { fn encode_unsigned(&self, out: &mut NetdocEncoder) -> Result<(), Bug> { self.unverified.encode_unsigned(out) } } impl<VD, UR> ItemObjectParseable for EmbeddedCert<VD, UR> where VD: EmbeddableCertObject<UR>, Loading Loading @@ -237,5 +251,27 @@ where } } impl<VD, UR> NetdocParseable for EmbeddedCert<VD, UR> where UR: NetdocParseable, { fn doctype_for_error() -> &'static str { UR::doctype_for_error() } fn is_intro_item_keyword(kw: KeywordRef<'_>) -> bool { UR::is_intro_item_keyword(kw) } fn is_structural_keyword(kw: KeywordRef<'_>) -> Option<IsStructural> { UR::is_structural_keyword(kw) } fn from_items(input: &mut ItemStream<'_>, stop_at: stop_at!()) -> Result<Self, P2EP> { let unverified = UR::from_items(input, stop_at)?; Ok(EmbeddedCert::new_unverified_hazardous(unverified)) } } #[cfg(test)] mod test;