test_class.file: java_src/src/test/java/com/google/crypto/tink/subtle/HkdfTest.java
test_class.identifier: HkdfTest
test_case.body: @Test
    public void testInvalidCodeSize() throws Exception {
      try {
        Hkdf.computeHkdf("HmacSha256", new byte[0], new byte[0], new byte[0], 32 * 256);
        fail("Invalid size, should have thrown exception");
      } catch (GeneralSecurityException expected) {
        // Expected
      }
    }
test_case.class_method_signature: HkdfTest.testInvalidCodeSize()
test_case.full_signature: @Test public void testInvalidCodeSize()
test_case.identifier: testInvalidCodeSize
test_case.invocations: computeHkdf fail
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testInvalidCodeSize()
focal_class.file: java_src/src/main/java/com/google/crypto/tink/subtle/Hkdf.java
focal_class.identifier: Hkdf
focal_class.class_method_signature: Hkdf.computeHkdf(
        String macAlgorithm, final byte[] ikm, final byte[] salt, final byte[] info, int size)
focal_class.full_signature: public static byte[] computeHkdf(
        String macAlgorithm, final byte[] ikm, final byte[] salt, final byte[] info, int size)
focal_class.identifier: computeHkdf
focal_class.modifiers: public static
focal_class.parameters: (
        String macAlgorithm, final byte[] ikm, final byte[] salt, final byte[] info, int size)
focal_class.return: byte[]
focal_class.signature: byte[] computeHkdf(
        String macAlgorithm, final byte[] ikm, final byte[] salt, final byte[] info, int size)
focal_class.class_method_signature: Hkdf.computeEciesHkdfSymmetricKey(
        final byte[] ephemeralPublicKeyBytes,
        final byte[] sharedSecret,
        String hmacAlgo,
        final byte[] hkdfSalt,
        final byte[] hkdfInfo,
        int keySizeInBytes)
focal_class.full_signature: public static byte[] computeEciesHkdfSymmetricKey(
        final byte[] ephemeralPublicKeyBytes,
        final byte[] sharedSecret,
        String hmacAlgo,
        final byte[] hkdfSalt,
        final byte[] hkdfInfo,
        int keySizeInBytes)
focal_class.identifier: computeEciesHkdfSymmetricKey
focal_class.modifiers: public static
focal_class.parameters: (
        final byte[] ephemeralPublicKeyBytes,
        final byte[] sharedSecret,
        String hmacAlgo,
        final byte[] hkdfSalt,
        final byte[] hkdfInfo,
        int keySizeInBytes)
focal_class.return: byte[]
focal_class.signature: byte[] computeEciesHkdfSymmetricKey(
        final byte[] ephemeralPublicKeyBytes,
        final byte[] sharedSecret,
        String hmacAlgo,
        final byte[] hkdfSalt,
        final byte[] hkdfInfo,
        int keySizeInBytes)
focal_method.body: public static byte[] computeHkdf(
        String macAlgorithm, final byte[] ikm, final byte[] salt, final byte[] info, int size)
        throws GeneralSecurityException {
      Mac mac = EngineFactory.MAC.getInstance(macAlgorithm);
      if (size > 255 * mac.getMacLength()) {
        throw new GeneralSecurityException("size too large");
      }
      if (salt == null || salt.length == 0) {
        // According to RFC 5869, Section 2.2 the salt is optional. If no salt is provided
        // then HKDF uses a salt that is an array of zeros of the same length as the hash digest.
        mac.init(new SecretKeySpec(new byte[mac.getMacLength()], macAlgorithm));
      } else {
        mac.init(new SecretKeySpec(salt, macAlgorithm));
      }
      byte[] prk = mac.doFinal(ikm);
      byte[] result = new byte[size];
      int ctr = 1;
      int pos = 0;
      mac.init(new SecretKeySpec(prk, macAlgorithm));
      byte[] digest = new byte[0];
      while (true) {
        mac.update(digest);
        mac.update(info);
        mac.update((byte) ctr);
        digest = mac.doFinal();
        if (pos + digest.length < size) {
          System.arraycopy(digest, 0, result, pos, digest.length);
          pos += digest.length;
          ctr++;
        } else {
          System.arraycopy(digest, 0, result, pos, size - pos);
          break;
        }
      }
      return result;
    }
focal_method.class_method_signature: Hkdf.computeHkdf(
        String macAlgorithm, final byte[] ikm, final byte[] salt, final byte[] info, int size)
focal_method.full_signature: public static byte[] computeHkdf(
        String macAlgorithm, final byte[] ikm, final byte[] salt, final byte[] info, int size)
focal_method.identifier: computeHkdf
focal_method.invocations: getInstance getMacLength init getMacLength init doFinal init update update update doFinal arraycopy arraycopy
focal_method.modifiers: public static
focal_method.parameters: (
        String macAlgorithm, final byte[] ikm, final byte[] salt, final byte[] info, int size)
focal_method.return: byte[]
focal_method.signature: byte[] computeHkdf(
        String macAlgorithm, final byte[] ikm, final byte[] salt, final byte[] info, int size)