Commit 8bcf8d44 authored by Ian Jackson's avatar Ian Jackson
Browse files

tor-netdoc: Promote hash_slice_for_verification to prod

This function is not right, yet.  We're going to fix it later.

Review with --color-moved.
parent 8ff11d45
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -593,6 +593,18 @@ define_derive_deftly! {
                Some(KeywordOrString::Unknown(..)) => {}
            }
        }

        /// Return the hash value for a specific algorithm, as a slice
        ///
        /// `None` if the value wasn't computed.
        /// That shouldn't happen.
        // XXXX make no longer pub(crate)
        pub(crate) fn hash_slice_for_verification(&self, algo: $ttype) -> Option<&[u8]> {
            // XXXX handle sha1_unnamed correctly
            match algo { $(
                $vtype => Some(self.$FNAME.as_ref()?),
            ) }
        }
    }
}

+1 −13
Original line number Diff line number Diff line
@@ -112,18 +112,6 @@ define_derive_deftly! {

            Some(algo.into())
        }

        /// Return the hash value for a specific algorithm, as a slice
        ///
        /// `None` if the value wasn't computed.
        /// That shouldn't happen.
        // XXXX make no longer pub(crate)
        pub(crate) fn hash_slice_for_verification(&self, algo: $ttype) -> Option<&[u8]> {
            // XXXX handle sha1_unnamed correctly
            match algo { $(
                $vtype => Some(self.$FNAME.as_ref()?),
            ) }
        }
    }

    // XXXX we have two DirectorySignatureHashAlgo types, which we, briefly,
@@ -254,7 +242,7 @@ fn verify_general_timeless(
                };

                let h = hashes
                    .hash_slice_for_verification(*hash_algo)
                    .hash_slice_for_verification((*hash_algo).into())
                    .ok_or(VF::Bug)?;

                let () = cert.dir_signing_key.verify(h, rsa_signature)?;