MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / hmac_inner

Function hmac_inner

src/expr/src/scalar/func/variadic.rs:797–826  ·  view source on GitHub ↗
(to_digest: &[u8], key: &[u8], typ: &str)

Source from the content-addressed store, hash-verified

795}
796
797pub fn hmac_inner(to_digest: &[u8], key: &[u8], typ: &str) -> Result<Vec<u8>, EvalError> {
798 match typ {
799 "md5" => {
800 let mut mac = Hmac::<Md5>::new_from_slice(key).expect("HMAC accepts any key size");
801 mac.update(to_digest);
802 Ok(mac.finalize().into_bytes().to_vec())
803 }
804 "sha1" => {
805 let k = aws_hmac::Key::new(aws_hmac::HMAC_SHA1_FOR_LEGACY_USE_ONLY, key);
806 Ok(aws_hmac::sign(&k, to_digest).as_ref().to_vec())
807 }
808 "sha224" => {
809 let k = aws_hmac::Key::new(aws_hmac::HMAC_SHA224, key);
810 Ok(aws_hmac::sign(&k, to_digest).as_ref().to_vec())
811 }
812 "sha256" => {
813 let k = aws_hmac::Key::new(aws_hmac::HMAC_SHA256, key);
814 Ok(aws_hmac::sign(&k, to_digest).as_ref().to_vec())
815 }
816 "sha384" => {
817 let k = aws_hmac::Key::new(aws_hmac::HMAC_SHA384, key);
818 Ok(aws_hmac::sign(&k, to_digest).as_ref().to_vec())
819 }
820 "sha512" => {
821 let k = aws_hmac::Key::new(aws_hmac::HMAC_SHA512, key);
822 Ok(aws_hmac::sign(&k, to_digest).as_ref().to_vec())
823 }
824 other => Err(EvalError::InvalidHashAlgorithm(other.into())),
825 }
826}
827
828#[sqlfunc]
829fn jsonb_build_array<'a>(datums: Variadic<Datum<'a>>, temp_storage: &'a RowArena) -> JsonbRef<'a> {

Callers 2

hmac_stringFunction · 0.85
hmac_bytesFunction · 0.85

Calls 7

signFunction · 0.85
expectMethod · 0.80
to_vecMethod · 0.80
into_bytesMethod · 0.80
updateMethod · 0.45
finalizeMethod · 0.45
as_refMethod · 0.45

Tested by

no test coverage detected