Module Noalloc.Detached
The detached interface uses 2 separate buffers for the ciphertext and the message authentication tag. This allows users to encrypt and decrypt data in-place, by passing the same buffer for both plaintext and ciphertext.
Buffers have the following size requirements:
tag
: 16 bytespk
,sk
,ck
: 32 bytesn
: 24 bytes
Box
One-shot interface
val box : pt:bytes -> n:bytes -> pk:bytes -> sk:bytes -> ct:bytes -> tag:bytes -> bool
box pt n pk sk ct tag
authenticates and encrypts plaintextpt
using public keypk
, secret keysk
, and noncen
and writes the ciphertext inct
and the message authentication tag intag
. Returns true if successful.
val box_open : ct:bytes -> tag:bytes -> n:bytes -> pk:bytes -> sk:bytes -> pt:bytes -> bool
box_open ct tag n pk sk pt
attempts to verify and decrypt ciphertextct
and message authentication tagtag
using public keypk
, secret keysk
, and noncen
and if successful writes the plaintext inpt
and returns true.
Precomputation interface
The shared key ck
is obtained using NaCl.box_beforenm
or NaCl.Noalloc.box_beforenm
.