public AesCtrHmacStreamingParameters build() throws GeneralSecurityException {
      if (keySizeBytes == null) {
        throw new GeneralSecurityException("keySizeBytes needs to be set");
      }
      if (derivedKeySizeBytes == null) {
        throw new GeneralSecurityException("derivedKeySizeBytes needs to be set");
      }
      if (hkdfHashType == null) {
        throw new GeneralSecurityException("hkdfHashType needs to be set");
      }
      if (hmacHashType == null) {
        throw new GeneralSecurityException("hmacHashType needs to be set");
      }
      if (hmacTagSizeBytes == null) {
        throw new GeneralSecurityException("hmacTagSizeBytes needs to be set");
      }
      if (ciphertextSegmentSizeBytes == null) {
        throw new GeneralSecurityException("ciphertextSegmentSizeBytes needs to be set");
      }

      if (derivedKeySizeBytes != 16 && derivedKeySizeBytes != 32) {
        throw new GeneralSecurityException(
            "derivedKeySizeBytes needs to be 16 or 32, not " + derivedKeySizeBytes);
      }
      if (keySizeBytes < derivedKeySizeBytes) {
        throw new GeneralSecurityException(
            "keySizeBytes needs to be at least derivedKeySizeBytes, i.e., " + derivedKeySizeBytes);
      }
      if (ciphertextSegmentSizeBytes <= derivedKeySizeBytes + hmacTagSizeBytes + 8) {
        throw new GeneralSecurityException(
            "ciphertextSegmentSizeBytes needs to be at least derivedKeySizeBytes + hmacTagSizeBytes"
                + " + 9, i.e., "
                + (derivedKeySizeBytes + hmacTagSizeBytes + 9));
      }

      int hmacTagSizeLowerBound = 10;
      int hmacTagSizeUpperBound = 0;
      if (hmacHashType == HashType.SHA1) {
        hmacTagSizeUpperBound = 20;
      }
      if (hmacHashType == HashType.SHA256) {
        hmacTagSizeUpperBound = 32;
      }
      if (hmacHashType == HashType.SHA512) {
        hmacTagSizeUpperBound = 64;
      }
      if (hmacTagSizeBytes < hmacTagSizeLowerBound || hmacTagSizeBytes > hmacTagSizeUpperBound) {
        throw new GeneralSecurityException(
            "hmacTagSize must be in range ["
                + hmacTagSizeLowerBound
                + ", "
                + hmacTagSizeUpperBound
                + "], but is "
                + hmacTagSizeBytes);
      }
      return new AesCtrHmacStreamingParameters(
          keySizeBytes,
          derivedKeySizeBytes,
          hkdfHashType,
          hmacHashType,
          hmacTagSizeBytes,
          ciphertextSegmentSizeBytes);
    }
Checks restrictions as on the devsite
java_src/src/main/java/com/google/crypto/tink/streamingaead/AesCtrHmacStreamingParameters.java