Bouncy Castle Cryptography Library 1.87

org.bouncycastle.crypto.generators
Class OneStepKDFBytesGenerator

java.lang.Object
  extended byorg.bouncycastle.crypto.generators.OneStepKDFBytesGenerator
All Implemented Interfaces:
DerivationFunction

public class OneStepKDFBytesGenerator
extends java.lang.Object
implements DerivationFunction

The one-step key derivation function of NIST SP 800-56C Rev. 2, Section 4.1, with any of its three auxiliary functions: a hash (Option 1), HMAC keyed with the salt (Option 2), or KMAC keyed with the salt and customised with "KDF" (Option 3).

For the hash and HMAC options the output is the concatenation of H(counter || Z || FixedInfo) for a 32-bit big-endian counter starting at 1, truncated to the requested length; with the hash option this is the Concatenation KDF of SP 800-56A (ConcatenationKDFGenerator). With the KMAC option the standard sets the KMAC output length to the requested length so that a single call, with the counter at 1, produces the whole output. When no salt is given the default salt of the standard is used: for HMAC an all-zero string the size of the hash block (which HMAC's key padding makes equivalent to an empty key), for KMAC128 164 zero bytes and for KMAC256 132 zero bytes.

Initialise with a KDFParameters carrying the shared secret Z and the FixedInfo.


Constructor Summary
OneStepKDFBytesGenerator(Digest digest)
          Option 1: a hash function as the auxiliary function.
OneStepKDFBytesGenerator(Mac mac, byte[] salt)
          Option 2 or 3: HMAC or KMAC as the auxiliary function, keyed with the salt.
 
Method Summary
 int generateBytes(byte[] out, int outOff, int len)
           
 Digest getDigest()
           
 void init(DerivationParameters param)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OneStepKDFBytesGenerator

public OneStepKDFBytesGenerator(Digest digest)
Option 1: a hash function as the auxiliary function.

Parameters:
digest - the hash function.

OneStepKDFBytesGenerator

public OneStepKDFBytesGenerator(Mac mac,
                                byte[] salt)
Option 2 or 3: HMAC or KMAC as the auxiliary function, keyed with the salt. A KMAC must have been constructed with the customization string "KDF" as the standard requires.

Parameters:
mac - the HMAC or KMAC to use.
salt - the salt, or null for the standard's default salt.
Method Detail

init

public void init(DerivationParameters param)
Specified by:
init in interface DerivationFunction

getDigest

public Digest getDigest()

generateBytes

public int generateBytes(byte[] out,
                         int outOff,
                         int len)
                  throws DataLengthException,
                         java.lang.IllegalArgumentException
Specified by:
generateBytes in interface DerivationFunction
Throws:
DataLengthException
java.lang.IllegalArgumentException

Bouncy Castle Cryptography Library 1.87