Skip to main content

hkdf_extract_py

Function hkdf_extract_py 

Source
pub fn hkdf_extract_py<'py>(
    py: Python<'py>,
    algorithm: &str,
    salt: Option<&[u8]>,
    ikm: &[u8],
) -> PyResult<Bound<'py, PyBytes>>
Expand description

HKDF-Extract (RFC 5869 §2.2).

Returns the pseudorandom key PRK = HMAC-Hash(salt, ikm).

algorithm must be one of "sha256", "sha384", "sha512", etc. When salt is None or omitted, the default salt is a string of HashLen zero bytes as specified by RFC 5869.

import synta

prk = synta.hkdf_extract("sha256", b"salt", b"input keying material")
# or with default salt:
prk = synta.hkdf_extract("sha256", None, b"ikm")