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

tor-netdoc: impl SignatureItemParseable for netstatus::Signature

This is now pretty straightforward.  The functions it calls need some
work - we have blocking TODOs for that.
parent 5aa7b82f
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -658,7 +658,6 @@ impl NormalItemArgument for DirectorySignatureHashAlgo {}
///
/// Implements `ItemValueParseable` which parses without hashing anything;
/// this is mostly useful for use by the `SignatureItemParseable` implementation.
// XXXX that impl doesn't exist yet
#[derive(Debug, Clone, Deftly)]
#[derive_deftly(ItemValueEncodable, ItemValueParseable)]
#[non_exhaustive]
@@ -677,6 +676,20 @@ pub struct Signature {
    pub signature: Vec<u8>,
}

impl SignatureItemParseable for Signature {
    type HashAccu = DirectorySignaturesHashesAccu;

    fn from_unparsed_and_body(
        item: UnparsedItem,
        body: &SignatureHashInputs<'_>,
        hash: &mut Self::HashAccu,
    ) -> StdResult<Self, ErrorProblem> {
        let signature = Signature::from_unparsed(item)?;
        hash.update_from(&signature.digest_algo, body);
        Ok(signature)
    }
}

/// A collection of signatures that can be checked on a networkstatus document
#[derive(Debug, Clone)]
#[non_exhaustive]