dryoc: Don't Roll Your Own Crypto
dryoc is a pure-Rust implementation of the excellent libsodium library.
The purpose of this project is to provide a pure-Rust, mostly drop-in replacement for libsodium. This library has nearly the same ergonomics as libsodium (referred to in dryoc as the Classic API), so that people familiar with libsodium can use this library nearly interchangeably. While the API is not 100% identical to libsodium, most functions have the same or very similar signatures.
In addition to the Classic API, there's a Rustaceous API which aims to bring an idiomatic Rust implementation of libsodium's core features: public and secret key authenticated cryptography.
Not all features from libsodium are implemented here, such as advanced "under the hood" features of libsodium. For those specific features, it's recommended you rely on other crates directly.
This project prefers to rely on existing well-known implementations of cryptographic functions where possible, rather than succumbing to NIH syndrome. This library leverages existing vetted projects in the Rust ecosystem to provide high quality and easy to use cryptography.
Usage
In cargo.toml
:
[]
= "0.2"
With optional features:
[]
= { = "0.2", = ["serde", "base64", "simd_backend"]
Features
- Many libsodium implemented with both Classic and Rustaceous API
- Serde support, including optional base64 encoding (with
dryoc = {version = "0.2", features = ["serde", "base64"]}
) - SIMD optimizations, nightly only (with
dryoc = {version = "0.2", features = ["simd_backend"]}
)
Project status
The following libsodium features are currently implemented, or awaiting implementation:
- Public-key cryptography (
crypto_box_*
) - Secret-key cryptography (
crypto_secretbox_*
) - Point*scalar multiplication
- Zeroing memory with zeroize
- Encrypted streams
- Encrypting related message
- Generating random data
- Key derivation
- Generic hashing
- Short-input hashing
- Password hashing
- Key exchange
- One-time authentication
- Public-key signatures
- Sealed boxes
- Authentication
The following libsodium features are not implemented, and there's no plan to implement them:
- Stream ciphers (use salsa20 crate)
- Helpers and padding utilities
- Memory locking
- Advanced features:
- SHA-2 (use sha2 crate)
- HMAC-SHA-2 (use hmac crate)
- Scrypt (use scrypt crate)
- Ed25519 to Curve25519 (use dalek.rs)
- Finite field arithmetic (use dalek.rs)