Crates.io | monosodium |
lib.rs | monosodium |
version | 0.1.0-pre.1 |
source | src |
created_at | 2019-03-22 21:49:29.166752 |
updated_at | 2019-07-18 22:26:44.241033 |
description | Plain bindings to libsodium |
homepage | |
repository | https://github.com/peterhj/monosodium |
max_upload_size | |
id | 123196 |
size | 1,961,745 |
These are bindings to libsodium.
Unlike its namesake, monosodium
is rather plain and boring.
Other than the direct bindings to libsodium, the only other abstractions in
this crate are in the util
module and are centered around a CryptoBuf
type for wrapping sensitive bytes; this is described below.
util::CryptoBuf
is a simple wrapper struct around an inner Vec<u8>
buffer.
util::CryptoBuf
implements PartialEq
and Eq
(using libsodium's
constant-time comparison function sodium_memcmp
), implements Drop
by
zeroing its inner Vec<u8>
buffer (using sodium_memzero
), and has
constructors that initialize its inner buffer with zero-valued bytes or random
bytes (using randombytes_buf
).
There is a related struct, util::HashCryptoBuf
, that additionally implements
Hash
.
A public/secret pair of key buffers is encapsulated in a util::KeyPair
.
This is also the return type of gen_sign_keypair
, which is the wrapper around
libsodium's crypto_sign_keypair
.