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

Conversation

Direktor799
Copy link
Contributor

In crypto_secretbox, there are pub consts we can use.

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

    /// Size of an XSalsa20Poly1305 nonce in bytes
    pub const NONCE_SIZE: usize = 24;

    /// Size of a Poly1305 tag in bytes
    pub const TAG_SIZE: usize = 16;
}

Maybe it's better to bring these consts to crypto_box too? So we don't have to use magic numbers without import the crypto_secretbox.

@tarcieri
Copy link
Member

tarcieri commented Dec 20, 2023

So we don't have to use magic numbers

FWIW, these are all defined via the AeadCore trait: https://docs.rs/crypto_box/0.9.1/crypto_box/struct.CryptoBox.html#impl-AeadCore-for-CryptoBox%3CC%3E

But I agree the inherent constants are also useful and consistent with SecretBox.

@tarcieri tarcieri merged commit a7f32e4 into RustCrypto:master Dec 20, 2023
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants