License BSD-2-Clause License MIT AppVeyor CI docs.rs crates.io Download numbers Dependency status

recordbox

Welcome to recordbox 🎉

This crate offers a simple API to encrypt id:payload-style records like network packets or files etc.

Why?

Records are pretty common and often consist of two main elements: 1. An ID which identifies/addresses the record; e.g. a filename or a sequence number (even if implicit) or an entry UUID etc. 2. The associated payload

This crate offers an easy and uniform API to encrypt a record payload and tie the resulting ciphertext to the record ID, so that you don't have to implement the same basics by yourself everytime.

Encryption

There are three different kinds of boxes; which one is the best depends on your usecase:

Recordbox

The most versatile format is the Recordbox. It works by using a SIV implementation which uses the ID as associated data and a fixed nonce.

Advantages:

Disadvantages:

UniqueRecordbox

The UniqueRecordbox is a randomized record box which uses the record ID as (indirect) nonce. It works by deriving a record-specific subkey from the provided key and the record ID and a deterministic or fixed nonce. This is similar to the XChaCha-construction and allows the use of arbitrarily long record IDs (as long as they are unique for each record payload).

Advantages:

Disadvantages:

Note:

This is a fallback scheme because as of today, SIV implementations are not easily available in every language. However in most circumstances you should probably either use a Recordbox if you can afford a few more CPU cycles or a FastRecordBox if performance is critical.

FastRecordBox

The FastRecordBox is a randomized record box which directly maps the record ID into a nonce (i.e. without deriving a record-specific subkey).

Advantages:

Disadvantages:

TODO