Skip to content

Secure finishing for Hasher #1768

Open
Open
@Ericson2314

Description

@Ericson2314

With sufficiently expressive associated constants (including rust-lang/rust#34344), it would be nice to provide scaffolding for secure hashing without allocation by extending Hasher like:

pub trait Hasher {
    const DigestSize: usize = 8;

    /// Completes a round of hashing, producing the untruncated output hash generated.
    fn untruncated_finish(&self) -> [u8; Self::DigestSize] {
        self.finish()
    }

    ...
}

[I think specialization might also be required to write that default method; I forget what syntax is needed.]

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-libs-apiRelevant to the library API team, which will review and decide on the RFC.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions