Crates.io | recordbox |
lib.rs | recordbox |
version | 0.1.1 |
source | src |
created_at | 2021-10-18 16:30:01.052708 |
updated_at | 2021-10-21 03:01:35.531988 |
description | This crate offers a simple API to encrypt ID:payload-style records like packets or files etc. |
homepage | |
repository | https://github.com/KizzyCode/recordbox-rust |
max_upload_size | |
id | 466886 |
size | 37,119 |
recordbox
Welcome to recordbox
🎉
This crate offers a simple API to encrypt id:payload
-style records like network packets or files etc.
Records are pretty common and often consist of two main elements:
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.
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.
Not randomized: Because the implementation uses a fixed nonce, the same ID+plaintext-combination will always result in the same ciphertext. This may leak information about equal records and in certain circumstances can be enough to completely break a protocol.
Slow: Most if not all current SIV constructions are significantly slower than e.g. AES-GCM. Even though in most cases this is not a problem, it can be a dealbreaker in certain settings.
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).
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).
Self
to the nonce. This also means that your record IDs usually cannot be larger
than 8 to 12 bytes.RecordBox
UniqueRecordBox
FastRecordBox