Skip to main content

noxtls_crypto/hash/mdigest/
digest.rs

1// Copyright (c) 2019-2026, Argenox Technologies LLC
2// All rights reserved.
3//
4// SPDX-License-Identifier: GPL-2.0-only OR LicenseRef-Argenox-Commercial-License
5//
6// This file is part of the NoxTLS Library.
7//
8// This program is free software: you can redistribute it and/or modify
9// it under the terms of the GNU General Public License as published by the
10// Free Software Foundation; version 2 of the License.
11//
12// Alternatively, this file may be used under the terms of a commercial
13// license from Argenox Technologies LLC.
14//
15// See `noxtls/LICENSE` and `noxtls/LICENSE.md` in this repository for full details.
16// CONTACT: info@argenox.com
17
18use crate::internal_alloc::Vec;
19
20/// Defines the streaming digest contract used by hash implementations.
21pub trait Digest {
22    /// Feeds additional bytes into the digest state.
23    ///
24    /// # Arguments
25    /// * `data`: Additional message bytes to absorb into the hash state.
26    ///
27    /// # Panics
28    ///
29    /// This function does not panic for conforming implementations in this crate.
30    fn update(&mut self, data: &[u8]);
31
32    /// Finalizes the digest and returns the resulting hash bytes.
33    ///
34    /// # Returns
35    /// Final digest bytes for all input provided through `update`.
36    ///
37    /// # Panics
38    ///
39    /// This function does not panic for conforming implementations in this crate.
40    fn finalize(self) -> Vec<u8>;
41}