chore: checkpoint before Python removal

This commit is contained in:
2026-03-26 22:33:59 +00:00
parent 683cec9307
commit e568ddf82a
29972 changed files with 11269302 additions and 2 deletions

97
vendor/hkdf/src/sealed.rs vendored Normal file
View File

@@ -0,0 +1,97 @@
use hmac::digest::{
block_buffer::Eager,
core_api::{
BlockSizeUser, BufferKindUser, CoreProxy, CoreWrapper, FixedOutputCore, OutputSizeUser,
UpdateCore,
},
generic_array::typenum::{IsLess, Le, NonZero, U256},
Digest, FixedOutput, HashMarker, KeyInit, Output, Update,
};
use hmac::{Hmac, HmacCore, SimpleHmac};
pub trait Sealed<H: OutputSizeUser> {
type Core: Clone;
fn new_from_slice(key: &[u8]) -> Self;
fn new_core(key: &[u8]) -> Self::Core;
fn from_core(core: &Self::Core) -> Self;
fn update(&mut self, data: &[u8]);
fn finalize(self) -> Output<H>;
}
impl<H> Sealed<H> for Hmac<H>
where
H: CoreProxy + OutputSizeUser,
H::Core: HashMarker
+ UpdateCore
+ FixedOutputCore
+ BufferKindUser<BufferKind = Eager>
+ Default
+ Clone,
<H::Core as BlockSizeUser>::BlockSize: IsLess<U256>,
Le<<H::Core as BlockSizeUser>::BlockSize, U256>: NonZero,
{
type Core = HmacCore<H>;
#[inline(always)]
fn new_from_slice(key: &[u8]) -> Self {
KeyInit::new_from_slice(key).expect("HMAC can take a key of any size")
}
#[inline(always)]
fn new_core(key: &[u8]) -> Self::Core {
HmacCore::new_from_slice(key).expect("HMAC can take a key of any size")
}
#[inline(always)]
fn from_core(core: &Self::Core) -> Self {
CoreWrapper::from_core(core.clone())
}
#[inline(always)]
fn update(&mut self, data: &[u8]) {
Update::update(self, data);
}
#[inline(always)]
fn finalize(self) -> Output<H> {
// Output<H> and Output<H::Core> are always equal to each other,
// but we can not prove it at type level
Output::<H>::clone_from_slice(&self.finalize_fixed())
}
}
impl<H: Digest + BlockSizeUser + Clone> Sealed<H> for SimpleHmac<H> {
type Core = Self;
#[inline(always)]
fn new_from_slice(key: &[u8]) -> Self {
KeyInit::new_from_slice(key).expect("HMAC can take a key of any size")
}
#[inline(always)]
fn new_core(key: &[u8]) -> Self::Core {
KeyInit::new_from_slice(key).expect("HMAC can take a key of any size")
}
#[inline(always)]
fn from_core(core: &Self::Core) -> Self {
core.clone()
}
#[inline(always)]
fn update(&mut self, data: &[u8]) {
Update::update(self, data);
}
#[inline(always)]
fn finalize(self) -> Output<H> {
// Output<H> and Output<H::Core> are always equal to each other,
// but we can not prove it at type level
Output::<H>::clone_from_slice(&self.finalize_fixed())
}
}