computeHkdf

fun computeHkdf(macAlgorithm: String, ikm: ByteArray, salt: ByteArray?, info: ByteArray?, size: Int): ByteArray

Computes an HKDF.

This is based on https://github.com/google/tink/blob/master/java/src/main/java/com/google /crypto/tink/subtle/Hkdf.java which is also Copyright (c) Google and also licensed under the Apache 2 license.

Return

size pseudorandom bytes.

Parameters

macAlgorithm

the MAC algorithm used for computing the Hkdf. I.e., "HMACSHA1" or "HMACSHA256".

ikm

the input keying material.

salt

optional salt. A possibly non-secret random value. If no salt is provided (i.e. if salt has length 0) then an array of 0s of the same size as the hash digest is used as salt.

info

optional context and application specific information.

size

The length of the generated pseudorandom string in bytes. The maximal size is 255.DigestSize, where DigestSize is the size of the underlying HMAC.