Remove useless sodium_memzero, add one that makes sense

This commit is contained in:
Frank Denis
2026-03-08 15:27:35 +01:00
parent c948d3d2c6
commit 7035cb0e27
4 changed files with 8 additions and 6 deletions
@@ -37,8 +37,6 @@ crypto_box_seal(unsigned char *c, const unsigned char *m,
nonce, pk, esk);
memcpy(c, epk, crypto_box_PUBLICKEYBYTES);
sodium_memzero(esk, sizeof esk);
sodium_memzero(epk, sizeof epk);
sodium_memzero(nonce, sizeof nonce);
return ret;
}
@@ -48,7 +48,10 @@ crypto_box_curve25519xchacha20poly1305_beforenm(unsigned char *k,
if (crypto_scalarmult_curve25519(s, sk, pk) != 0) {
return -1;
}
return crypto_core_hchacha20(k, zero, s, NULL);
crypto_core_hchacha20(k, zero, s, NULL);
sodium_memzero(s, sizeof s);
return 0;
}
int
@@ -44,8 +44,6 @@ crypto_box_curve25519xchacha20poly1305_seal(unsigned char *c, const unsigned cha
nonce, pk, esk);
memcpy(c, epk, crypto_box_curve25519xchacha20poly1305_PUBLICKEYBYTES);
sodium_memzero(esk, sizeof esk);
sodium_memzero(epk, sizeof epk);
sodium_memzero(nonce, sizeof nonce);
return ret;
}
@@ -42,7 +42,10 @@ crypto_box_curve25519xsalsa20poly1305_beforenm(unsigned char *k,
if (crypto_scalarmult_curve25519(s, sk, pk) != 0) {
return -1;
}
return crypto_core_hsalsa20(k, zero, s, NULL);
crypto_core_hsalsa20(k, zero, s, NULL);
sodium_memzero(s, sizeof s);
return 0;
}
int