Skip to content

Commit

Permalink
feat(crypto_box): add consts like SecretBox (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
Direktor799 authored Dec 20, 2023
1 parent 9890e14 commit a7f32e4
Showing 1 changed file with 11 additions and 0 deletions.
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

0 comments on commit a7f32e4

Please sign in to comment.