Search in sources :

Example 1 with ChaCha20Poly1305

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

the class ChaCha20Poly1305KeyManager method getPrimitive.

@Override
public Aead getPrimitive(MessageLite key) throws GeneralSecurityException {
    if (!(key instanceof ChaCha20Poly1305Key)) {
        throw new GeneralSecurityException("expected ChaCha20Poly1305Key proto");
    }
    ChaCha20Poly1305Key keyProto = (ChaCha20Poly1305Key) key;
    validate(keyProto);
    return new ChaCha20Poly1305(keyProto.getKeyValue().toByteArray());
}
Also used : ChaCha20Poly1305(com.google.crypto.tink.subtle.ChaCha20Poly1305) ChaCha20Poly1305Key(com.google.crypto.tink.proto.ChaCha20Poly1305Key) GeneralSecurityException(java.security.GeneralSecurityException)

Aggregations

ChaCha20Poly1305Key (com.google.crypto.tink.proto.ChaCha20Poly1305Key)1 ChaCha20Poly1305 (com.google.crypto.tink.subtle.ChaCha20Poly1305)1 GeneralSecurityException (java.security.GeneralSecurityException)1