Search in sources :

Example 6 with AesCtrHmacAeadKeyFormat

use of com.google.crypto.tink.proto.AesCtrHmacAeadKeyFormat in project tink by google.

the class AeadKeyTemplates method createAesCtrHmacAeadKeyTemplate.

/**
 * @return a {@link KeyTemplate} containing a {@link AesCtrHmacAeadKeyFormat} with some specific
 *     parameters.
 */
public static KeyTemplate createAesCtrHmacAeadKeyTemplate(int aesKeySize, int ivSize, int hmacKeySize, int tagSize, HashType hashType) {
    AesCtrKeyFormat aesCtrKeyFormat = AesCtrKeyFormat.newBuilder().setParams(AesCtrParams.newBuilder().setIvSize(ivSize).build()).setKeySize(aesKeySize).build();
    HmacKeyFormat hmacKeyFormat = HmacKeyFormat.newBuilder().setParams(HmacParams.newBuilder().setHash(hashType).setTagSize(tagSize).build()).setKeySize(hmacKeySize).build();
    AesCtrHmacAeadKeyFormat format = AesCtrHmacAeadKeyFormat.newBuilder().setAesCtrKeyFormat(aesCtrKeyFormat).setHmacKeyFormat(hmacKeyFormat).build();
    return KeyTemplate.newBuilder().setValue(format.toByteString()).setTypeUrl(AesCtrHmacAeadKeyManager.TYPE_URL).setOutputPrefixType(OutputPrefixType.TINK).build();
}
Also used : AesCtrKeyFormat(com.google.crypto.tink.proto.AesCtrKeyFormat) HmacKeyFormat(com.google.crypto.tink.proto.HmacKeyFormat) AesCtrHmacAeadKeyFormat(com.google.crypto.tink.proto.AesCtrHmacAeadKeyFormat)

Aggregations

AesCtrHmacAeadKeyFormat (com.google.crypto.tink.proto.AesCtrHmacAeadKeyFormat)6 KeyTemplate (com.google.crypto.tink.proto.KeyTemplate)4 Test (org.junit.Test)4 AesCtrHmacAeadKey (com.google.crypto.tink.proto.AesCtrHmacAeadKey)1 AesCtrKey (com.google.crypto.tink.proto.AesCtrKey)1 AesCtrKeyFormat (com.google.crypto.tink.proto.AesCtrKeyFormat)1 HashType (com.google.crypto.tink.proto.HashType)1 HmacKey (com.google.crypto.tink.proto.HmacKey)1 HmacKeyFormat (com.google.crypto.tink.proto.HmacKeyFormat)1 KeyData (com.google.crypto.tink.proto.KeyData)1 ByteString (com.google.protobuf.ByteString)1 GeneralSecurityException (java.security.GeneralSecurityException)1 TreeSet (java.util.TreeSet)1