Top Description Fields Constructors Methods
org.bouncycastle.crypto.generators

public Class HKDFBytesGenerator

extends Object
implements DerivationFunction
Class Inheritance
All Implemented Interfaces
org.bouncycastle.crypto.DerivationFunction
Imports
org.bouncycastle.crypto.DataLengthException, .DerivationFunction, .DerivationParameters, .Digest, org.bouncycastle.crypto.macs.HMac, org.bouncycastle.crypto.params.HKDFParameters, .KeyParameter

HMAC-based Extract-and-Expand Key Derivation Function (HKDF) implemented according to IETF RFC 5869, May 2010 as specified by H. Krawczyk, IBM Research & P. Eronen, Nokia. It uses a HMac internally to compute de OKM (output keying material) and is likely to have better security properties than KDF's based on just a hash function.

Field Summary

Modifier and TypeField and Description
private byte[]
private int
private int
private HMac
private byte[]

Constructor Summary

AccessConstructor and Description
public
HKDFBytesGenerator(Digest
the digest to be used as the source of generatedBytes bytes
hash
)

Creates a HKDFBytesGenerator based on the given hash function.

Method Summary

Modifier and TypeMethod and Description
private void
expandNext()

Performs the expand part of the key derivation function, using currentT as input and output buffer.

public byte[]

Returns:

the PRK as KeyParameter
extractPRK
(byte[]
the salt to use
salt
,
byte[]
the input keying material
ikm
)

Performs the extract part of the key derivation function.

public int
generateBytes(byte[] out, int outOff, int len)

Implements org.bouncycastle.crypto.DerivationFunction.generateBytes.

public Digest
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

currentTback to summary
private byte[] currentT
generatedBytesback to summary
private int generatedBytes
hashLenback to summary
private int hashLen
hMacHashback to summary
private HMac hMacHash
infoback to summary
private byte[] info

Constructor Detail

HKDFBytesGeneratorback to summary
public HKDFBytesGenerator(Digest hash)

Creates a HKDFBytesGenerator based on the given hash function.

Parameters
hash:Digest

the digest to be used as the source of generatedBytes bytes

Method Detail

expandNextback to summary
private void expandNext() throws DataLengthException

Performs the expand part of the key derivation function, using currentT as input and output buffer.

Exceptions
DataLengthException:
if the total number of bytes generated is larger than the one specified by RFC 5869 (255 * HashLen)
extractPRKback to summary
public byte[] extractPRK(byte[] salt, byte[] ikm)

Performs the extract part of the key derivation function.

Parameters
salt:byte[]

the salt to use

ikm:byte[]

the input keying material

Returns:byte[]

the PRK as KeyParameter

generateBytesback to summary
public int generateBytes(byte[] out, int outOff, int len) throws DataLengthException, IllegalArgumentException

Implements org.bouncycastle.crypto.DerivationFunction.generateBytes.

getDigestback to summary
public Digest getDigest()
initback to summary
public void init(DerivationParameters param)

Implements org.bouncycastle.crypto.DerivationFunction.init.