use osproxy_core::CursorSigner;
#[cfg(feature = "fips")]
use aws_lc_rs::hmac;
#[cfg(feature = "non-fips")]
use ring::hmac;
pub struct HmacCursorSigner {
key: hmac::Key,
}
impl std::fmt::Debug for HmacCursorSigner {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("HmacCursorSigner").finish_non_exhaustive()
}
}
impl HmacCursorSigner {
#[must_use]
pub fn new(secret: &[u8]) -> Self {
Self {
key: hmac::Key::new(hmac::HMAC_SHA256, secret),
}
}
}
impl CursorSigner for HmacCursorSigner {
fn tag(&self, msg: &[u8]) -> Vec<u8> {
hmac::sign(&self.key, msg).as_ref().to_vec()
}
}
#[cfg(test)]
#[path = "cursor_tests.rs"]
mod tests;