// Copyright 2023 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// package com.google.crypto.tink.hybrid; import static com.google.crypto.tink.internal.TinkBugException.exceptionIsBug; import com.google.crypto.tink.aead.AesCtrHmacAeadParameters; import com.google.crypto.tink.aead.AesGcmParameters; /** * Pre-generated {@link Parameter} objects for {@link com.google.crypto.tink.HybridEncrypt} and * {@link com.google.crypto.tink.HybridDecrypt} keys. * *
Note: if you want to keep dependencies small, consider inlining the constants here. */ public final class PredefinedHybridParameters { /** * A {@link KeyTemplate} that generates new instances of {@link * com.google.crypto.tink.proto.EciesAeadHkdfPrivateKey} with the following parameters: * *
Unlike other key templates that use AES-GCM, the instances of {@link HybridDecrypt} * generated by this key template has no limitation on Android KitKat (API level 19). They might * not work in older versions though. */ public static final EciesParameters ECIES_P256_HKDF_HMAC_SHA256_AES128_GCM = exceptionIsBug( () -> EciesParameters.builder() .setCurveType(EciesParameters.CurveType.NIST_P256) .setHashType(EciesParameters.HashType.SHA256) .setNistCurvePointFormat(EciesParameters.PointFormat.UNCOMPRESSED) .setVariant(EciesParameters.Variant.TINK) .setDemParameters( AesGcmParameters.builder() .setIvSizeBytes(12) .setKeySizeBytes(16) .setTagSizeBytes(16) .setVariant(AesGcmParameters.Variant.NO_PREFIX) .build()) .build()); /** * A {@link KeyTemplate} that generates new instances of {@link * com.google.crypto.tink.proto.EciesAeadHkdfPrivateKey} with the following parameters: * *
Unlike other key templates that use AES-GCM, the instances of {@link HybridDecrypt} * generated by this key template has no limitation on Android KitKat (API level 19). They might * not work in older versions though. */ public static final EciesParameters ECIES_P256_HKDF_HMAC_SHA256_AES128_GCM_COMPRESSED_WITHOUT_PREFIX = exceptionIsBug( () -> EciesParameters.builder() .setCurveType(EciesParameters.CurveType.NIST_P256) .setHashType(EciesParameters.HashType.SHA256) .setNistCurvePointFormat(EciesParameters.PointFormat.COMPRESSED) .setVariant(EciesParameters.Variant.NO_PREFIX) .setDemParameters( AesGcmParameters.builder() .setIvSizeBytes(12) .setKeySizeBytes(16) .setTagSizeBytes(16) .setVariant(AesGcmParameters.Variant.NO_PREFIX) .build()) .build()); /** * A {@link KeyTemplate} that generates new instances of {@link * com.google.crypto.tink.proto.EciesAeadHkdfPrivateKey} with the following parameters: * *