Search in sources :

Example 1 with EncryptThenAuthenticate

use of com.google.crypto.tink.subtle.EncryptThenAuthenticate in project tink by google.

the class AesCtrHmacAeadKeyManager method getPrimitive.

/**
 * @param key  {@code AesCtrHmacAeadKey} proto
 */
@Override
public Aead getPrimitive(MessageLite key) throws GeneralSecurityException {
    if (!(key instanceof AesCtrHmacAeadKey)) {
        throw new GeneralSecurityException("expected AesCtrHmacAeadKey proto");
    }
    AesCtrHmacAeadKey keyProto = (AesCtrHmacAeadKey) key;
    validate(keyProto);
    return new EncryptThenAuthenticate((IndCpaCipher) Registry.getPrimitive(AesCtrKeyManager.TYPE_URL, keyProto.getAesCtrKey()), (Mac) Registry.getPrimitive(MacConfig.HMAC_TYPE_URL, keyProto.getHmacKey()), keyProto.getHmacKey().getParams().getTagSize());
}
Also used : GeneralSecurityException(java.security.GeneralSecurityException) EncryptThenAuthenticate(com.google.crypto.tink.subtle.EncryptThenAuthenticate) AesCtrHmacAeadKey(com.google.crypto.tink.proto.AesCtrHmacAeadKey)

Aggregations

AesCtrHmacAeadKey (com.google.crypto.tink.proto.AesCtrHmacAeadKey)1 EncryptThenAuthenticate (com.google.crypto.tink.subtle.EncryptThenAuthenticate)1 GeneralSecurityException (java.security.GeneralSecurityException)1