blob: 16058e1ca17621cf3e08c8967ae6b57157384a28 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.security.hpke;
/**
* Key derivation function (KDF)
*
* @author vekterli
*/
public interface Kdf {
/**
* Extract a pseudorandom key of fixed length {@link #nH()} bytes from input keying material
* <code>ikm</code> and an optional byte string <code>salt</code>.
*
* @param salt non-secret salt used as input to KDF
* @param labeledIkm secret input keying material
* @return nH bytes of PRK data
*/
byte[] extract(byte[] salt, byte[] labeledIkm);
/**
* Expand a pseudorandom key <code>prk</code> using optional string <code>info</code> into
* <code>nBytesToExpand</code> bytes of output keying material.
*
* @param prk pseudo random key previously gotten from a call to extract.
* @param info contextual info for expansion; useful for key domain separation
* @param nBytesToExpand number of bytes to return
*
* @return <code>nBytesToExpand</code> bytes of output keying material.
*/
byte[] expand(byte[] prk, byte[] info, int nBytesToExpand);
/** Output size of the extract() function in bytes */
short nH();
/** Predefined KDF ID, as given in RFC 9180 section 7.2 */
short kdfId();
static Kdf hkdfSha256() {
return HkdfSha256.getInstance();
}
}
|