lkml.org 
[lkml]   [2023]   [Jul]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH RFC 04/11] rust: siphash: Add a simple siphash abstraction
From
On 7/14/23 06:13, Asahi Lina wrote:
> This simple wrapper allows Rust code to use the Hasher interface with
> the kernel siphash implementation. No fancy features supported for now,
> just basic bag-of-bytes hashing. No guarantee that hash outputs will
> remain stable in the future either.
>
> Signed-off-by: Asahi Lina <lina@asahilina.net>
> ---
> [...]
> --- /dev/null
> +++ b/rust/kernel/siphash.rs
> @@ -0,0 +1,39 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +//! A core::hash::Hasher wrapper for the kernel siphash implementation.
> +//!
> +//! This module allows Rust code to use the kernel's siphash implementation
> +//! to hash Rust objects.
> +
> +use core::hash::Hasher;
> +
> +/// A Hasher implementation that uses the kernel siphash implementation.
> +#[derive(Default)]
> +pub struct SipHasher {
> + // SipHash state is 4xu64, but the Linux implementation
> + // doesn't expose incremental hashing so let's just chain
> + // individual SipHash calls for now, which return a u64
> + // hash.

Isn't this detail relevant to mention in the doc comment? At least to
explain the difference between them.

> + state: u64,
> +}
> [...]

\
 
 \ /
  Last update: 2023-07-16 20:51    [W:0.886 / U:4.340 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site