@SuppressWarnings("UnusedException")
  private static AesCtrHmacAeadKey parseKey(
      ProtoKeySerialization serialization, @Nullable SecretKeyAccess access)
      throws GeneralSecurityException {
    if (!serialization.getTypeUrl().equals(TYPE_URL)) {
      throw new IllegalArgumentException(
          "Wrong type URL in call to AesCtrHmacAeadProtoSerialization.parseKey");
    }
    try {
      com.google.crypto.tink.proto.AesCtrHmacAeadKey protoKey =
          com.google.crypto.tink.proto.AesCtrHmacAeadKey.parseFrom(
              serialization.getValue(), ExtensionRegistryLite.getEmptyRegistry());
      if (protoKey.getVersion() != 0) {
        throw new GeneralSecurityException("Only version 0 keys are accepted");
      }
      if (protoKey.getAesCtrKey().getVersion() != 0) {
        throw new GeneralSecurityException("Only version 0 keys inner AES CTR keys are accepted");
      }
      if (protoKey.getHmacKey().getVersion() != 0) {
        throw new GeneralSecurityException("Only version 0 keys inner HMAC keys are accepted");
      }
      AesCtrHmacAeadParameters parameters =
          AesCtrHmacAeadParameters.builder()
              .setAesKeySizeBytes(protoKey.getAesCtrKey().getKeyValue().size())
              .setHmacKeySizeBytes(protoKey.getHmacKey().getKeyValue().size())
              .setIvSizeBytes(protoKey.getAesCtrKey().getParams().getIvSize())
              .setTagSizeBytes(protoKey.getHmacKey().getParams().getTagSize())
              .setHashType(toHashType(protoKey.getHmacKey().getParams().getHash()))
              .setVariant(toVariant(serialization.getOutputPrefixType()))
              .build();
      return AesCtrHmacAeadKey.builder()
          .setParameters(parameters)
          .setAesKeyBytes(
              SecretBytes.copyFrom(
                  protoKey.getAesCtrKey().getKeyValue().toByteArray(),
                  SecretKeyAccess.requireAccess(access)))
          .setHmacKeyBytes(
              SecretBytes.copyFrom(
                  protoKey.getHmacKey().getKeyValue().toByteArray(),
                  SecretKeyAccess.requireAccess(access)))
          .setIdRequirement(serialization.getIdRequirementOrNull())
          .build();
    } catch (InvalidProtocolBufferException e) {
      throw new GeneralSecurityException("Parsing AesCtrHmacAeadKey failed");
    }
  }
Methods to serialize and parse {@link AesCtrHmacAeadKey} objects and {@link
AesCtrHmacAeadParameters} objects.
java_src/src/main/java/com/google/crypto/tink/aead/internal/AesCtrHmacAeadProtoSerialization.java