Beryl::Crypto::V1::HashBasedKeyDerivationFunction(D)
HKDF (RFC 5869): turns key material that is secret but uneven, such as a
shared secret from a key exchange, into as many independent keys as a
protocol needs. D is SHA256, SHA384 or SHA512; Compatibility::SHA1
is accepted for formats that already use it.
hkdf = Beryl::Crypto::V1::HKDF(Beryl::Crypto::V1::SHA256)
key = hkdf.derive_key(shared_secret, salt: salt, info: "session cookies", bytesize: 32)
derive_key is the whole function. extract and expand are its two
steps, for protocols such as TLS 1.3 that call them separately.
Constants
RFC 5869 §2.3 counts output blocks in one byte.
Class methods
Returns bytesize bytes of key derived from input_key_material:
extract, then expand.
Returns bytesize bytes of key derived from pseudorandom_key, which
should be one hash output long (the result of extract). info names
the purpose, so that different purposes get unrelated keys.
Raises DerivedKeyTooLong when bytesize is over 255 hash outputs.