Skip to main content

hmac_verify

Function hmac_verify 

Source
pub fn hmac_verify(
    algorithm: &str,
    key: &[u8],
    data: &[u8],
    expected: &[u8],
) -> PyResult<()>
Expand description

Verify an HMAC digest in constant time.

Raises :exc:ValueError if the computed HMAC does not match expected. Uses constant-time comparison to prevent timing side-channels.

import synta

synta.hmac_verify("sha256", key, data, expected_mac)
# raises ValueError on mismatch