Commit 63869dcc authored by Ian Jackson's avatar Ian Jackson
Browse files

tor-netdoc: Rename variants in VerifyGeneralTrustedAuthorities

In a wip branch I added a variant, and clippy complained.  In this
case, I agree with clippy.

warning: all variants have the same postfix: `Authorities`
    --> crates/tor-netdoc/src/doc/netstatus.rs:2335:1
     |
2335 | / pub(crate) enum VerifyGeneralTrustedAuthorities<'r> {
2336 | |     /// Trust these authorities.
2337 | |     TrustTheseAuthorities {
2338 | |         /// The HKP_auth_id_rsa
...    |
2357 | |     },
2358 | | }
     | |_^
     |
     = help: remove the postfixes and use full paths to the variants instead of glob imports
     = help: for further information visit https://rust-lang.github.io/rust-clippy/beta/index.html#enum_variant_names
note: the lint level is defined here
    --> crates/tor-netdoc/src/lib.rs:9:9
     |
   9 | #![warn(clippy::all)]
     |         ^^^^^^^^^^^
     = note: `#[warn(clippy::enum_variant_names)]` implied by `#[warn(clippy::all)]`
parent f4054647
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -2266,7 +2266,7 @@ impl<'r> ConsensusSignatureToVerify<'r> {
#[derive(Debug, Clone, Copy)]
pub(crate) enum VerifyGeneralTrustedAuthorities<'r> {
    /// Trust these authorities.
    TrustTheseAuthorities {
    TrustThese {
        /// The HKP_auth_id_rsa
        trusted: &'r [RsaIdentity],
    },
@@ -2275,7 +2275,7 @@ pub(crate) enum VerifyGeneralTrustedAuthorities<'r> {
    ///
    /// Every `AuthCert` passed to `verify_general` is a real authority (!)
    /// (But not necessarily a different one!)
    HazardouslyAssumeAllAuthCertsAreRealAuthorities {
    HazardouslyAssumeAllAuthCertsAreReal {
        /// Total number of authorities that we trust
        ///
        /// Used only to calculate the threshold
@@ -2335,9 +2335,9 @@ impl SignatureGroup {
    /// to a real authority.
    fn validate(&self, n_authorities: usize, certs: &[AuthCert]) -> Result<(), VerifyFailed> {
        // TODO we ought to take the set of trusted authorities as an argument,
        // rather than use VGTA::HazardouslyAssumeAllAuthCertsAreRealAuthorities.
        // rather than use VGTA::HazardouslyAssumeAllAuthCertsAreReal.
        self.verify_general(
            VerifyGeneralTrustedAuthorities::HazardouslyAssumeAllAuthCertsAreRealAuthorities {
            VerifyGeneralTrustedAuthorities::HazardouslyAssumeAllAuthCertsAreReal {
                n_authorities,
            },
            certs,
@@ -2408,12 +2408,12 @@ impl SignatureGroup {
            } = sig;

            match trusted_authorities {
                TA::TrustTheseAuthorities { trusted } => {
                TA::TrustThese { trusted } => {
                    if !trusted.contains(id_fingerprint) {
                        continue;
                    }
                }
                TA::HazardouslyAssumeAllAuthCertsAreRealAuthorities { .. } => {
                TA::HazardouslyAssumeAllAuthCertsAreReal { .. } => {
                    // OK then!
                }
            }
@@ -2445,8 +2445,8 @@ impl SignatureGroup {
        }

        let n_authorities = match trusted_authorities {
            TA::TrustTheseAuthorities { trusted } => trusted.len(),
            TA::HazardouslyAssumeAllAuthCertsAreRealAuthorities { n_authorities: n } => n,
            TA::TrustThese { trusted } => trusted.len(),
            TA::HazardouslyAssumeAllAuthCertsAreReal { n_authorities: n } => n,
        };
        let threshold = (n_authorities / 2) + 1; // strict majority

+1 −1
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ fn verify_general_timeless(
    };

    group.verify_general(
        VerifyGeneralTrustedAuthorities::TrustTheseAuthorities { trusted },
        VerifyGeneralTrustedAuthorities::TrustThese { trusted },
        &certs.iter().copied().cloned().collect_vec(),
        |tv| tv.verify(),
    )