Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(crypto_box): add consts like SecretBox #151

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions crypto_box/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,17 @@ pub struct CryptoBox<C> {
secretbox: SecretBox<C>,
}

impl<C> CryptoBox<C> {
/// Size of an XSalsa20Poly1305 key in bytes
pub const KEY_SIZE: usize = SecretBox::<C>::KEY_SIZE;

/// Size of an XSalsa20Poly1305 nonce in bytes
pub const NONCE_SIZE: usize = SecretBox::<C>::NONCE_SIZE;

/// Size of a Poly1305 tag in bytes
pub const TAG_SIZE: usize = SecretBox::<C>::TAG_SIZE;
}

// Handwritten instead of derived to avoid `C: Clone` bound
impl<C> Clone for CryptoBox<C> {
fn clone(&self) -> Self {
Expand Down