Skip to content

Commit 13d2c97

Browse files
committed
Remove useless sodium_memzero, add one that makes sense
1 parent e18eee6 commit 13d2c97

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

src/libsodium/crypto_box/crypto_box_seal.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ crypto_box_seal(unsigned char *c, const unsigned char *m,
3737
nonce, pk, esk);
3838
memcpy(c, epk, crypto_box_PUBLICKEYBYTES);
3939
sodium_memzero(esk, sizeof esk);
40-
sodium_memzero(epk, sizeof epk);
41-
sodium_memzero(nonce, sizeof nonce);
4240

4341
return ret;
4442
}

src/libsodium/crypto_box/curve25519xchacha20poly1305/box_curve25519xchacha20poly1305.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ crypto_box_curve25519xchacha20poly1305_beforenm(unsigned char *k,
4848
if (crypto_scalarmult_curve25519(s, sk, pk) != 0) {
4949
return -1;
5050
}
51-
return crypto_core_hchacha20(k, zero, s, NULL);
51+
crypto_core_hchacha20(k, zero, s, NULL);
52+
sodium_memzero(s, sizeof s);
53+
54+
return 0;
5255
}
5356

5457
int

src/libsodium/crypto_box/curve25519xchacha20poly1305/box_seal_curve25519xchacha20poly1305.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ crypto_box_curve25519xchacha20poly1305_seal(unsigned char *c, const unsigned cha
4444
nonce, pk, esk);
4545
memcpy(c, epk, crypto_box_curve25519xchacha20poly1305_PUBLICKEYBYTES);
4646
sodium_memzero(esk, sizeof esk);
47-
sodium_memzero(epk, sizeof epk);
48-
sodium_memzero(nonce, sizeof nonce);
4947

5048
return ret;
5149
}

src/libsodium/crypto_box/curve25519xsalsa20poly1305/box_curve25519xsalsa20poly1305.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ crypto_box_curve25519xsalsa20poly1305_beforenm(unsigned char *k,
4242
if (crypto_scalarmult_curve25519(s, sk, pk) != 0) {
4343
return -1;
4444
}
45-
return crypto_core_hsalsa20(k, zero, s, NULL);
45+
crypto_core_hsalsa20(k, zero, s, NULL);
46+
sodium_memzero(s, sizeof s);
47+
48+
return 0;
4649
}
4750

4851
int

0 commit comments

Comments
 (0)