private static void createTestKeys() {
    HmacParameters noPrefixHmacParameters =
        createDefaultHmacParameters(HmacParameters.Variant.NO_PREFIX);
    HmacParameters legacyHmacParameters =
        createDefaultHmacParameters(HmacParameters.Variant.LEGACY);
    HmacParameters crunchyHmacParameters =
        createDefaultHmacParameters(HmacParameters.Variant.CRUNCHY);
    HmacParameters tinkHmacParameters =
        createDefaultHmacParameters(HmacParameters.Variant.TINK);
    AesCmacParameters noPrefixAesCmacParameters =
        createDefaultAesCmacParameters(AesCmacParameters.Variant.NO_PREFIX);
    AesCmacParameters legacyAesCmacParameters =
        createDefaultAesCmacParameters(AesCmacParameters.Variant.LEGACY);
    AesCmacParameters crunchyAesCmacParameters =
        createDefaultAesCmacParameters(AesCmacParameters.Variant.CRUNCHY);
    AesCmacParameters tinkAesCmacParameters =
        createDefaultAesCmacParameters(AesCmacParameters.Variant.TINK);

    try {
      keys =
          new Key[] {
            HmacKey.builder()
                .setParameters(noPrefixHmacParameters)
                .setKeyBytes(SecretBytes.randomBytes(HMAC_KEY_SIZE))
                .setIdRequirement(null)
                .build(),
            AesCmacKey.builder()
                .setParameters(noPrefixAesCmacParameters)
                .setAesKeyBytes(SecretBytes.randomBytes(AES_CMAC_KEY_SIZE))
                .setIdRequirement(null)
                .build(),
            HmacKey.builder()
                .setParameters(tinkHmacParameters)
                .setKeyBytes(SecretBytes.randomBytes(HMAC_KEY_SIZE))
                .setIdRequirement(4)
                .build(),
            AesCmacKey.builder()
                .setParameters(tinkAesCmacParameters)
                .setAesKeyBytes(SecretBytes.randomBytes(AES_CMAC_KEY_SIZE))
                .setIdRequirement(5)
                .build(),
            HmacKey.builder()
                .setParameters(crunchyHmacParameters)
                .setKeyBytes(SecretBytes.randomBytes(HMAC_KEY_SIZE))
                .setIdRequirement(6)
                .build(),
            AesCmacKey.builder()
                .setParameters(crunchyAesCmacParameters)
                .setAesKeyBytes(SecretBytes.randomBytes(AES_CMAC_KEY_SIZE))
                .setIdRequirement(7)
                .build(),
            HmacKey.builder()
                .setParameters(legacyHmacParameters)
                .setKeyBytes(SecretBytes.randomBytes(HMAC_KEY_SIZE))
                .setIdRequirement(8)
                .build(),
            AesCmacKey.builder()
                .setParameters(legacyAesCmacParameters)
                .setAesKeyBytes(SecretBytes.randomBytes(AES_CMAC_KEY_SIZE))
                .setIdRequirement(9)
                .build(),
          };
    } catch (GeneralSecurityException e) {
      throw new IllegalStateException(e);
    }
  }
These tests ensure interoperability between the new ChunkedMac implementations and the old Mac
implementations.
java_src/src/test/java/com/google/crypto/tink/mac/ChunkedMacTest.java