bjosodium/src/raw.bjo

24 lines
1 KiB
Text
Raw Normal View History

;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;; bjosodium/src/raw.bjo — the module (bjosodium raw): encryption with a
;; nonce that the caller gives, for a format that keeps the nonce in its own
;; place. Use it with (bjosodium core), which has the keys.
;;
;; - A nonce is `AeadNonce`, an opaque type that knows its cipher.
;; `aead-encrypt` and `aead-decrypt` take the cipher from it.
;; - Make each nonce with `make-aead-nonce`. Never encrypt two messages with
;; the same key and nonce: that shows the XOR of the two plaintexts, and
;; lets an attacker forge messages.
;; - `bytes->aead-nonce` is for a nonce read back from stored data, to
;; decrypt. Do not encrypt with a nonce made from bytes.
(import (bjosodium impl))
(re-export AeadNonce)
(export
make-aead-nonce bytes->aead-nonce aead-nonce->bytes aead-nonce-cipher
aead-encrypt aead-decrypt)