Reject impossible lengths in crypto_box

This commit is contained in:
Frank Denis
2026-04-09 22:17:50 +02:00
parent 51be825e1a
commit 35df98abf0
2 changed files with 6 additions and 0 deletions
@@ -29,6 +29,9 @@ crypto_box_seal(unsigned char *c, const unsigned char *m,
unsigned char esk[crypto_box_SECRETKEYBYTES];
int ret;
if (mlen > crypto_box_MESSAGEBYTES_MAX) {
sodium_misuse(); /* LCOV_EXCL_LINE */
}
if (crypto_box_keypair(epk, esk) != 0) {
return -1; /* LCOV_EXCL_LINE */
}
@@ -35,6 +35,9 @@ crypto_box_curve25519xchacha20poly1305_seal(unsigned char *c, const unsigned cha
unsigned char esk[crypto_box_curve25519xchacha20poly1305_SECRETKEYBYTES];
int ret;
if (mlen > crypto_box_curve25519xchacha20poly1305_MESSAGEBYTES_MAX) {
sodium_misuse(); /* LCOV_EXCL_LINE */
}
if (crypto_box_curve25519xchacha20poly1305_keypair(epk, esk) != 0) {
return -1; /* LCOV_EXCL_LINE */
}