Class OneStepKDFBytesGenerator

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

public class OneStepKDFBytesGenerator extends 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 Details

    • 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 Details