Library
Module
Module type
Parameter
Class
Class type
Authenticated encryption with associated data.
This defines a uniform interface of symmetrics cryptographic algorithms which encrypt, and also protect the integrity of the data. Additional data, only used for integrity protection, not encrypted and not part of the ciphertext, can be passed in optionally. This prevents the same ciphertext being used at a different location. See RFC 5116 for further description.
of_secret secret
constructs the encryption key corresponding to secret
.
authenticate_encrypt ~key ~nonce ~adata msg
encrypts msg
with key
and nonce
, and appends an authentication tag computed over the encrypted msg
, using key
, nonce
, and adata
.
val authenticate_decrypt :
key:key ->
nonce:Cstruct.t ->
?adata:Cstruct.t ->
Cstruct.t ->
Cstruct.t option
authenticate_decrypt ~key ~nonce ~adata msg
splits msg
into encrypted data and authentication tag, computes the authentication tag using key
, nonce
, and adata
, and decrypts the encrypted data. If the authentication tags match, the decrypted data is returned.
val authenticate_encrypt_tag :
key:key ->
nonce:Cstruct.t ->
?adata:Cstruct.t ->
Cstruct.t ->
Cstruct.t * Cstruct.t
authenticate_encrypt_tag ~key ~nonce ~adata msg
encrypts msg
with key
and nonce
. The computed authentication tag is returned separately as second part of the tuple.
val authenticate_decrypt_tag :
key:key ->
nonce:Cstruct.t ->
?adata:Cstruct.t ->
tag:Cstruct.t ->
Cstruct.t ->
Cstruct.t option
authenticate_decrypt ~key ~nonce ~adata ~tag msg
computes the authentication tag using key
, nonce
, and adata
, and decrypts the encrypted data. If the authentication tags match, the decrypted data is returned.