Debian Codegraph @

third_party/rust/mls-rs-crypto-traits/src/lib.rs

raw
1 // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 // Copyright by contributors to this project.
3 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
4
5 #![cfg_attr(not(feature = "std"), no_std)]
6 extern crate alloc;
7
8 mod aead;
9 mod dh;
10 mod ec;
11 mod kdf;
12 mod kem;
13
14 pub use aead::{AeadId, AeadType, AEAD_ID_EXPORT_ONLY, AES_TAG_LEN};
15 pub use dh::{DhType, SamplingMethod};
16 pub use ec::Curve;
17 pub use kdf::{KdfId, KdfType};
18 pub use kem::{KemId, KemResult, KemType};
19 use mls_rs_core::error::IntoAnyError;
20
21 #[cfg(feature = "mock")]
22 pub mod mock;
23
24 use alloc::vec::Vec;
25
26 #[cfg_attr(feature = "mock", mockall::automock(type Error = crate::mock::TestError;))]
27 pub trait Hash: Send + Sync {
28 type Error: IntoAnyError + Send + Sync;
29
30 fn hash(&self, input: &[u8]) -> Result<Vec<u8>, Self::Error>;
31 }
32
33 #[cfg_attr(feature = "mock", mockall::automock(type Error = crate::mock::TestError;))]
34 pub trait VariableLengthHash: Send + Sync {
35 type Error: IntoAnyError + Send + Sync;
36
37 fn hash(&self, input: &[u8], out_len: usize) -> Result<Vec<u8>, Self::Error>;
38 }