in src/crypto.js [82:102]
export async function hkdfExpand(prk, info, length) {
// Ref https://tools.ietf.org/html/rfc5869#section-2.3
const N = Math.ceil(length / HASH_LENGTH);
if (N <= 0) {
throw new TLSError(ALERT_DESCRIPTION.INTERNAL_ERROR);
}
if (N >= 255) {
throw new TLSError(ALERT_DESCRIPTION.INTERNAL_ERROR);
}
const input = new BufferWriter();
const output = new BufferWriter();
let T = new Uint8Array(0);
for (let i = 1; i <= N; i++) {
input.writeBytes(T);
input.writeBytes(info);
input.writeUint8(i);
T = await hmac(prk, input.flush());
output.writeBytes(T);
}
return output.slice(0, length);
}