title: Symmetric key generation after ECDHC using KDF with SHA-256
body: <p>I want to generate a Symmetric key using Single-step Key Derivation Function (KDF) based on SHA-256.
  I think key derivations are in the lightweight API of Bouncy Castle since 1.50.</p>
  
  <p>I have successfully generated the <strong>secret key "Z"</strong>.And have a code for generating KDF from Z.</p>
  
  <p>Please kind the code below</p>
  
  <pre><code>    byte[] data = new byte[16];
      SecretKey secretKeyA = generateSharedSecretZ(keyPairA.getPrivate(),
              keyPairB.getPublic());
      System.out.println(bytesToHex(secretKeyA.getEncoded()));
  
      //Single-Step KDF specification using SHA256
      Digest digest = new SHA256Digest();
      System.out.println(digest.getDigestSize());
      HKDFBytesGenerator kDF1BytesGenerator = new HKDFBytesGenerator(digest);     
      kDF1BytesGenerator.init(new HKDFParameters(secretKeyA.getEncoded(),
              generateSalt(), null));
      kDF1BytesGenerator.generateBytes(data, 0, 16);
      System.out.println(new String(data));
      System.out.println(data.length);
  </code></pre>
  
  <p>Using the below method for generating the salt</p>
  
  <pre><code>private static byte[] generateSalt() throws NoSuchAlgorithmException {
      SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
      byte[] salt = new byte[32];
      random.nextBytes(salt);
  
      return salt;
  }
  </code></pre>
  
  <p>I am using org.bouncycastle.crypto.generators.HKDFBytesGenerator for generating the Symmetric key using sha-256. Is the above implemention, a single-step KDF? Am I missing any relevant steps in generating the Symmetric key using single-step KDF using sha-256 according to the NIST 800-56A document.</p>
  
  <p>Is there any standard size for the Symmetric key. Iam using the Symmetric key for Generates the MAC as per GCM-GMAC specification.</p>