Module EverCrypt.AEAD
Agile, multiplexing AEAD interface exposing AES128-GCM, AES256-GCM, and Chacha20-Poly1305
To use the agile AEAD interface, users first need to initialise an internal state using init. This state will then need to be passed to every call to encrypt and decrypt. It can be reused as many times as needed. Users are not required to manually free the state.
The tag buffer must be 16 bytes long. For key and iv, each algorithm has different constraints:
- AES128-GCM:
key= 16 bytes ,iv> 0 bytes - AES256-GCM:
key= 32 bytes,iv> 0 bytes - Chacha20-Poly1305:
key= 32 bytes,iv= 12 bytes
val init : alg:SharedDefs.AEADDefs.alg -> key:bytes -> t Error.resultinit alg keytries to allocate the internal state for algorithmalgwithkeyand returns atif successful or anError.error_codeotherwise.
val encrypt : st:t -> iv:bytes -> ad:bytes -> pt:bytes -> (bytes * bytes) Error.resultencrypt key iv ad pttakes akey, an initial valueiv, additional dataad, and plaintextptand, if successful, returns a tuple containing the encryptedptand the authentication tag for the plaintext and the associated data.
val decrypt : st:t -> iv:bytes -> ad:bytes -> ct:bytes -> tag:bytes -> bytes Error.resultdecrypt key iv ad ct tagtakes akey, the initial valueiv, additional dataad, ciphertextct, and authentication tagtag, and, if successful, returns the decryptedct.
module Noalloc : sig ... endVersions of these functions which write their output in a buffer passed in as an argument