Requesting an example
Open
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 961
- Forks
- 200
- Avg merge
- 1h 30m
- Merged PRs (30d)
- 6
Description
Hi! Does anyone have an example of basic operation, that includes a function or struct field containing each relevant type (key, poly, nonce)? Thank you!
Here is my non-compiling attempt:
Cargo.toml:
crypto = { package = "chacha20poly1305", version = "^0.10.1", default-features = false, features = ["rand_core"] }
rand_core = "^0.6.4"
generic-array = "^1.0.0"
Program:
use chacha20poly1305::{
aead::{AeadCore, KeyInit},
ChaCha20Poly1305 as Poly, Nonce
};
use generic_array::GenericArray;
type Key = GenericArray<u8, 12>;
type Nonce2 = GenericArray<u8, 12>;
pub fn make_cipher(rng: &mut Rng) -> (Key, Poly, Nonce) {
let key = Poly::generate_key(rng);
let cipher = Poly::new(&key);
// The nonce is unique per message. 96-bits.
let nonce = Poly::generate_nonce(rng);
(key, cipher, nonce)
}
pub fn encrypt(data: &mut [u8], cipher: &Poly, nonce: &Nonce) {
let ciphertext = cipher.encrypt(&nonce, data).unwrap();
}
pub fn decrypt(data: &mut [u8], cipher: &Poly, nonce: &Nonce) {
let ciphertext = cipher.decrypt(&nonce, data).unwrap();
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue's Cargo.toml and non-compiling Rust program are the starting points; review the chacha20poly1305 usage of Key, Poly, and Nonce and determine what example should be documented. Done means a basic compiling operation example covers those types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cryptography, documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100