test_class.declarator: KEY_SIZE = 16
test_class.modifier: private static final
test_class.original_string: private static final int KEY_SIZE = 16;
test_class.type: int
test_class.var_name: KEY_SIZE
test_class.declarator: IV_SIZE = 16
test_class.modifier: private static final
test_class.original_string: private static final int IV_SIZE = 16;
test_class.type: int
test_class.var_name: IV_SIZE
test_class.declarator: keySizeInBytes
test_class.modifier: private
test_class.original_string: private Integer[] keySizeInBytes;
test_class.type: Integer[]
test_class.var_name: keySizeInBytes
test_class.declarator: ivSizeInBytes
test_class.modifier: private
test_class.original_string: private Integer[] ivSizeInBytes;
test_class.type: Integer[]
test_class.var_name: ivSizeInBytes
test_class.file: java_src/src/test/java/com/google/crypto/tink/subtle/AesEaxJceTest.java
test_class.identifier: AesEaxJceTest
test_case.body: @Test
    public void testWycheproofVectors() throws Exception {
      JSONObject json =
          WycheproofTestUtil.readJson("../wycheproof/testvectors/aes_eax_test.json");
      int errors = 0;
      int cntSkippedTests = 0;
      JSONArray testGroups = json.getJSONArray("testGroups");
      for (int i = 0; i < testGroups.length(); i++) {
        JSONObject group = testGroups.getJSONObject(i);
        int keySize = group.getInt("keySize");
        int ivSize = group.getInt("ivSize");
        JSONArray tests = group.getJSONArray("tests");
        if (!Arrays.asList(keySizeInBytes).contains(keySize / 8)
            || !Arrays.asList(ivSizeInBytes).contains(ivSize / 8)) {
          cntSkippedTests += tests.length();
          continue;
        }
        for (int j = 0; j < tests.length(); j++) {
          JSONObject testcase = tests.getJSONObject(j);
          String tcId =
              String.format(
                  "testcase %d (%s)", testcase.getInt("tcId"), testcase.getString("comment"));
          byte[] iv = Hex.decode(testcase.getString("iv"));
          byte[] key = Hex.decode(testcase.getString("key"));
          byte[] msg = Hex.decode(testcase.getString("msg"));
          byte[] aad = Hex.decode(testcase.getString("aad"));
          byte[] ct = Hex.decode(testcase.getString("ct"));
          byte[] tag = Hex.decode(testcase.getString("tag"));
          byte[] ciphertext = Bytes.concat(iv, ct, tag);
          String result = testcase.getString("result");
          try {
            AesEaxJce eax = new AesEaxJce(key, iv.length);
            byte[] decrypted = eax.decrypt(ciphertext, aad);
            boolean eq = TestUtil.arrayEquals(decrypted, msg);
            if (result.equals("invalid")) {
              System.out.printf(
                  "FAIL %s: accepting invalid ciphertext, cleartext: %s, decrypted: %s%n",
                  tcId, Hex.encode(msg), Hex.encode(decrypted));
              errors++;
            } else {
              if (!eq) {
                System.out.printf(
                    "FAIL %s: incorrect decryption, result: %s, expected: %s%n",
                    tcId, Hex.encode(decrypted), Hex.encode(msg));
                errors++;
              }
            }
          } catch (GeneralSecurityException ex) {
            if (result.equals("valid")) {
              System.out.printf("FAIL %s: cannot decrypt, exception %s%n", tcId, ex);
              errors++;
            }
          }
        }
      }
      System.out.printf("Number of tests skipped: %d", cntSkippedTests);
      assertEquals(0, errors);
    }
test_case.class_method_signature: AesEaxJceTest.testWycheproofVectors()
test_case.full_signature: @Test public void testWycheproofVectors()
test_case.identifier: testWycheproofVectors
test_case.invocations: readJson getJSONArray length getJSONObject getInt getInt getJSONArray contains asList contains asList length length getJSONObject format getInt getString decode getString decode getString decode getString decode getString decode getString decode getString concat getString decrypt arrayEquals equals printf encode encode printf encode encode equals printf printf assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testWycheproofVectors()
focal_class.declarator: localEcbCipher =
        new ThreadLocal<Cipher>() {
          @Override
          protected Cipher initialValue() {
            try {
              return EngineFactory.CIPHER.getInstance("AES/ECB/NOPADDING");
            } catch (GeneralSecurityException ex) {
              throw new IllegalStateException(ex);
            }
          }
        }
focal_class.modifier: private static final
focal_class.original_string: private static final ThreadLocal<Cipher> localEcbCipher =
        new ThreadLocal<Cipher>() {
          @Override
          protected Cipher initialValue() {
            try {
              return EngineFactory.CIPHER.getInstance("AES/ECB/NOPADDING");
            } catch (GeneralSecurityException ex) {
              throw new IllegalStateException(ex);
            }
          }
        };
focal_class.type: ThreadLocal<Cipher>
focal_class.var_name: localEcbCipher
focal_class.declarator: localCtrCipher =
        new ThreadLocal<Cipher>() {
          @Override
          protected Cipher initialValue() {
            try {
              return EngineFactory.CIPHER.getInstance("AES/CTR/NOPADDING");
            } catch (GeneralSecurityException ex) {
              throw new IllegalStateException(ex);
            }
          }
        }
focal_class.modifier: private static final
focal_class.original_string: private static final ThreadLocal<Cipher> localCtrCipher =
        new ThreadLocal<Cipher>() {
          @Override
          protected Cipher initialValue() {
            try {
              return EngineFactory.CIPHER.getInstance("AES/CTR/NOPADDING");
            } catch (GeneralSecurityException ex) {
              throw new IllegalStateException(ex);
            }
          }
        };
focal_class.type: ThreadLocal<Cipher>
focal_class.var_name: localCtrCipher
focal_class.declarator: BLOCK_SIZE_IN_BYTES = 16
focal_class.modifier: static final
focal_class.original_string: static final int BLOCK_SIZE_IN_BYTES = 16;
focal_class.type: int
focal_class.var_name: BLOCK_SIZE_IN_BYTES
focal_class.declarator: TAG_SIZE_IN_BYTES = 16
focal_class.modifier: static final
focal_class.original_string: static final int TAG_SIZE_IN_BYTES = 16;
focal_class.type: int
focal_class.var_name: TAG_SIZE_IN_BYTES
focal_class.declarator: b
focal_class.modifier: private final
focal_class.original_string: private final byte[] b;
focal_class.type: byte[]
focal_class.var_name: b
focal_class.declarator: p
focal_class.modifier: private final
focal_class.original_string: private final byte[] p;
focal_class.type: byte[]
focal_class.var_name: p
focal_class.declarator: keySpec
focal_class.modifier: private final
focal_class.original_string: private final SecretKeySpec keySpec;
focal_class.type: SecretKeySpec
focal_class.var_name: keySpec
focal_class.declarator: ivSizeInBytes
focal_class.modifier: private final
focal_class.original_string: private final int ivSizeInBytes;
focal_class.type: int
focal_class.var_name: ivSizeInBytes
focal_class.file: java_src/src/main/java/com/google/crypto/tink/subtle/AesEaxJce.java
focal_class.identifier: AesEaxJce
focal_class.interfaces: implements Aead
focal_class.class_method_signature: AesEaxJce.AesEaxJce(final byte[] key, int ivSizeInBytes)
focal_class.full_signature: @SuppressWarnings("InsecureCryptoUsage") public  AesEaxJce(final byte[] key, int ivSizeInBytes)
focal_class.identifier: AesEaxJce
focal_class.modifiers: @SuppressWarnings("InsecureCryptoUsage") public
focal_class.parameters: (final byte[] key, int ivSizeInBytes)
focal_class.signature:  AesEaxJce(final byte[] key, int ivSizeInBytes)
focal_class.class_method_signature: AesEaxJce.xor(final byte[] x, final byte[] y)
focal_class.full_signature: private static byte[] xor(final byte[] x, final byte[] y)
focal_class.identifier: xor
focal_class.modifiers: private static
focal_class.parameters: (final byte[] x, final byte[] y)
focal_class.return: byte[]
focal_class.signature: byte[] xor(final byte[] x, final byte[] y)
focal_class.class_method_signature: AesEaxJce.multiplyByX(final byte[] block)
focal_class.full_signature: private static byte[] multiplyByX(final byte[] block)
focal_class.identifier: multiplyByX
focal_class.modifiers: private static
focal_class.parameters: (final byte[] block)
focal_class.return: byte[]
focal_class.signature: byte[] multiplyByX(final byte[] block)
focal_class.class_method_signature: AesEaxJce.pad(final byte[] data)
focal_class.full_signature: private byte[] pad(final byte[] data)
focal_class.identifier: pad
focal_class.modifiers: private
focal_class.parameters: (final byte[] data)
focal_class.return: byte[]
focal_class.signature: byte[] pad(final byte[] data)
focal_class.class_method_signature: AesEaxJce.omac(Cipher ecb, int tag, final byte[] data, int offset, int length)
focal_class.full_signature: private byte[] omac(Cipher ecb, int tag, final byte[] data, int offset, int length)
focal_class.identifier: omac
focal_class.modifiers: private
focal_class.parameters: (Cipher ecb, int tag, final byte[] data, int offset, int length)
focal_class.return: byte[]
focal_class.signature: byte[] omac(Cipher ecb, int tag, final byte[] data, int offset, int length)
focal_class.class_method_signature: AesEaxJce.encrypt(final byte[] plaintext, final byte[] associatedData)
focal_class.full_signature: @SuppressWarnings("InsecureCryptoUsage") @Override public byte[] encrypt(final byte[] plaintext, final byte[] associatedData)
focal_class.identifier: encrypt
focal_class.modifiers: @SuppressWarnings("InsecureCryptoUsage") @Override public
focal_class.parameters: (final byte[] plaintext, final byte[] associatedData)
focal_class.return: byte[]
focal_class.signature: byte[] encrypt(final byte[] plaintext, final byte[] associatedData)
focal_class.class_method_signature: AesEaxJce.decrypt(final byte[] ciphertext, final byte[] associatedData)
focal_class.full_signature: @SuppressWarnings("InsecureCryptoUsage") @Override public byte[] decrypt(final byte[] ciphertext, final byte[] associatedData)
focal_class.identifier: decrypt
focal_class.modifiers: @SuppressWarnings("InsecureCryptoUsage") @Override public
focal_class.parameters: (final byte[] ciphertext, final byte[] associatedData)
focal_class.return: byte[]
focal_class.signature: byte[] decrypt(final byte[] ciphertext, final byte[] associatedData)
focal_method.body: @SuppressWarnings("InsecureCryptoUsage")
    @Override
    public byte[] decrypt(final byte[] ciphertext, final byte[] associatedData)
        throws GeneralSecurityException {
      int plaintextLength = ciphertext.length - ivSizeInBytes - TAG_SIZE_IN_BYTES;
      if (plaintextLength < 0) {
        throw new GeneralSecurityException("ciphertext too short");
      }
      Cipher ecb = localEcbCipher.get();
      ecb.init(Cipher.ENCRYPT_MODE, keySpec);
      byte[] n = omac(ecb, 0, ciphertext, 0, ivSizeInBytes);
      byte[] aad = associatedData;
      if (aad == null) {
        aad = new byte[0];
      }
      byte[] h = omac(ecb, 1, aad, 0, aad.length);
      byte[] t = omac(ecb, 2, ciphertext, ivSizeInBytes, plaintextLength);
      byte res = 0;
      int offset = ciphertext.length - TAG_SIZE_IN_BYTES;
      for (int i = 0; i < TAG_SIZE_IN_BYTES; i++) {
        res = (byte) (res | (ciphertext[offset + i] ^ h[i] ^ n[i] ^ t[i]));
      }
      if (res != 0) {
        throw new AEADBadTagException("tag mismatch");
      }
      Cipher ctr = localCtrCipher.get();
      ctr.init(Cipher.ENCRYPT_MODE, keySpec, new IvParameterSpec(n));
      return ctr.doFinal(ciphertext, ivSizeInBytes, plaintextLength);
    }
focal_method.class_method_signature: AesEaxJce.decrypt(final byte[] ciphertext, final byte[] associatedData)
focal_method.full_signature: @SuppressWarnings("InsecureCryptoUsage") @Override public byte[] decrypt(final byte[] ciphertext, final byte[] associatedData)
focal_method.identifier: decrypt
focal_method.invocations: get init omac omac omac get init doFinal
focal_method.modifiers: @SuppressWarnings("InsecureCryptoUsage") @Override public
focal_method.parameters: (final byte[] ciphertext, final byte[] associatedData)
focal_method.return: byte[]
focal_method.signature: byte[] decrypt(final byte[] ciphertext, final byte[] associatedData)