From a7f32e455273ed713535237727e78f7b6385b0c6 Mon Sep 17 00:00:00 2001 From: Wenyu Su Date: Thu, 21 Dec 2023 03:45:47 +0800 Subject: [PATCH] feat(crypto_box): add consts like SecretBox (#151) --- crypto_box/src/lib.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crypto_box/src/lib.rs b/crypto_box/src/lib.rs index 0e749db..e639ce2 100644 --- a/crypto_box/src/lib.rs +++ b/crypto_box/src/lib.rs @@ -233,6 +233,17 @@ pub struct CryptoBox { secretbox: SecretBox, } +impl CryptoBox { + /// Size of an XSalsa20Poly1305 key in bytes + pub const KEY_SIZE: usize = SecretBox::::KEY_SIZE; + + /// Size of an XSalsa20Poly1305 nonce in bytes + pub const NONCE_SIZE: usize = SecretBox::::NONCE_SIZE; + + /// Size of a Poly1305 tag in bytes + pub const TAG_SIZE: usize = SecretBox::::TAG_SIZE; +} + // Handwritten instead of derived to avoid `C: Clone` bound impl Clone for CryptoBox { fn clone(&self) -> Self {