All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.google.crypto.tink.aead.PredefinedAeadParameters Maven / Gradle / Ivy

Go to download

Tink is a small cryptographic library that provides a safe, simple, agile and fast way to accomplish some common cryptographic tasks.

There is a newer version: 1.2.2
Show newest version
// Copyright 2023 Google LLC
//
// 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.aead;

import static com.google.crypto.tink.internal.TinkBugException.exceptionIsBug;


/**
 * Pre-generated {@link com.google.crypto.tink.Parameters} objects for creating new instances of
 * {@link AeadKey}.
 *
 * 

Note: if you want to keep dependencies small, consider inlining the constants here. */ public final class PredefinedAeadParameters { /** * A {@link com.google.crypto.tink.Parameters} object for generating new instances of {@link * AesGcmKey} with the following parameters: * *

    *
  • Key size: 16 bytes *
* *

On Android KitKat (API level 19), the {@link com.google.crypto.tink.Aead} instance generated * by this key template does not support associated data. It might not work at all in older * versions. */ public static final AesGcmParameters AES128_GCM = exceptionIsBug( () -> AesGcmParameters.builder() .setIvSizeBytes(12) .setKeySizeBytes(16) .setTagSizeBytes(16) .setVariant(AesGcmParameters.Variant.TINK) .build()); /** * A {@link com.google.crypto.tink.Parameters} object for generating new instances of {@link * AesGcmKey} with the following parameters: * *

    *
  • Key size: 32 bytes *
* *

On Android KitKat (API level 19), the {@link com.google.crypto.tink.Aead} instance generated * by this key template does not support associated data. It might not work at all in older * versions. */ public static final AesGcmParameters AES256_GCM = exceptionIsBug( () -> AesGcmParameters.builder() .setIvSizeBytes(12) .setKeySizeBytes(32) .setTagSizeBytes(16) .setVariant(AesGcmParameters.Variant.TINK) .build()); /** * A {@link com.google.crypto.tink.Parameters} object for generating new instances of {@link * AesEaxKey} with the following parameters: * *

    *
  • Key size: 16 bytes *
  • IV size: 16 bytes *
*/ public static final AesEaxParameters AES128_EAX = exceptionIsBug( () -> AesEaxParameters.builder() .setIvSizeBytes(16) .setKeySizeBytes(16) .setTagSizeBytes(16) .setVariant(AesEaxParameters.Variant.TINK) .build()); /** * A {@link com.google.crypto.tink.Parameters} object for generating new instances of {@link * AesEaxKey} with the following parameters: * *
    *
  • Key size: 32 bytes *
  • IV size: 16 bytes *
*/ public static final AesEaxParameters AES256_EAX = exceptionIsBug( () -> AesEaxParameters.builder() .setIvSizeBytes(16) .setKeySizeBytes(32) .setTagSizeBytes(16) .setVariant(AesEaxParameters.Variant.TINK) .build()); /** * A {@link com.google.crypto.tink.Parameters} object for generating new instances of {@link * AesCtrHmacAeadKey} with the following parameters: * *
    *
  • AES key size: 16 bytes *
  • AES CTR IV size: 16 byte *
  • HMAC key size: 32 bytes *
  • HMAC tag size: 16 bytes *
  • HMAC hash function: SHA256 *
*/ public static final AesCtrHmacAeadParameters AES128_CTR_HMAC_SHA256 = exceptionIsBug( () -> AesCtrHmacAeadParameters.builder() .setAesKeySizeBytes(16) .setHmacKeySizeBytes(32) .setTagSizeBytes(16) .setIvSizeBytes(16) .setHashType(AesCtrHmacAeadParameters.HashType.SHA256) .setVariant(AesCtrHmacAeadParameters.Variant.TINK) .build()); /** * A {@link com.google.crypto.tink.Parameters} object for generating new instances of {@link * AesCtrHmacAeadKey} with the following parameters: * *
    *
  • AES key size: 32 bytes *
  • AES CTR IV size: 16 byte *
  • HMAC key size: 32 bytes *
  • HMAC tag size: 32 bytes *
  • HMAC hash function: SHA256 *
*/ public static final AesCtrHmacAeadParameters AES256_CTR_HMAC_SHA256 = exceptionIsBug( () -> AesCtrHmacAeadParameters.builder() .setAesKeySizeBytes(32) .setHmacKeySizeBytes(32) .setTagSizeBytes(32) .setIvSizeBytes(16) .setHashType(AesCtrHmacAeadParameters.HashType.SHA256) .setVariant(AesCtrHmacAeadParameters.Variant.TINK) .build()); /** * A {@link com.google.crypto.tink.Parameters} object that generates new instances of {@link * ChaCha20Poly1305Key}. */ public static final ChaCha20Poly1305Parameters CHACHA20_POLY1305 = ChaCha20Poly1305Parameters.create(ChaCha20Poly1305Parameters.Variant.TINK); /** * A {@link com.google.crypto.tink.Parameters} object that generates new instances of {@link * XChaCha20Poly1305Key}. */ public static final XChaCha20Poly1305Parameters XCHACHA20_POLY1305 = XChaCha20Poly1305Parameters.create(XChaCha20Poly1305Parameters.Variant.TINK); /** * A {@link com.google.crypto.tink.Parameters} object for generating new instances of {@link * XAesGcmKey}. This follows the algorithm defined in the XAES-256-GCM specification * *
    *
  • Key size: 32 bytes *
  • Nonce size: 24 bytes (12 bytes of salt, 12 bytes of AES-GCM IV) *
  • Salt size: 12 bytes *
  • Tag size: 16 bytes *
  • Output prefix: TINK *
*/ public static final XAesGcmParameters XAES_256_GCM_192_BIT_NONCE = exceptionIsBug( () -> XAesGcmParameters.create(XAesGcmParameters.Variant.TINK, /* saltSizeBytes= */ 12)); /** * A {@link com.google.crypto.tink.Parameters} object for generating new instances of {@link * XAesGcmKey}. This follows the algorithm defined in the XAES-256-GCM specification * *
    *
  • Key size: 32 bytes *
  • Nonce size: 24 bytes (12 bytes of salt, 12 bytes of AES-GCM IV) *
  • Salt size: 12 bytes *
  • Tag size: 16 bytes *
  • Output prefix: NO_PREFIX *
*/ public static final XAesGcmParameters XAES_256_GCM_192_BIT_NONCE_NO_PREFIX = exceptionIsBug( () -> XAesGcmParameters.create( XAesGcmParameters.Variant.NO_PREFIX, /* saltSizeBytes= */ 12)); /** * A {@link com.google.crypto.tink.Parameters} object for generating new instances of {@link * XAesGcmKey}. This follows the algorithm defined in the XAES-256-GCM specification, * except that the nonce size is 160 bits instead of 192 bits. The remaining 4 bytes are padded * with zeros. * *
    *
  • Key size: 32 bytes *
  • Nonce size: 20 bytes (8 bytes of salt, 12 bytes of AES-GCM IV) *
  • Salt size: 8 bytes *
  • Tag size: 16 bytes *
  • Output prefix: NO_PREFIX *
*/ public static final XAesGcmParameters XAES_256_GCM_160_BIT_NONCE_NO_PREFIX = exceptionIsBug( () -> XAesGcmParameters.create( XAesGcmParameters.Variant.NO_PREFIX, /* saltSizeBytes= */ 8)); /** * @deprecated Use {@link #XAES_256_GCM_160_BIT_NONCE_NO_PREFIX} instead. */ @Deprecated public static final XAesGcmParameters X_AES_GCM_8_BYTE_SALT_NO_PREFIX = XAES_256_GCM_160_BIT_NONCE_NO_PREFIX; private PredefinedAeadParameters() {} }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy