update sodium_memzero function to arr.fill(0)

This commit is contained in:
Christophe Diederichs 2020-06-16 16:57:58 +02:00
parent 79273d499e
commit e69a73279a
2 changed files with 3 additions and 4 deletions

View File

@ -4,7 +4,6 @@ const { randombytes } = require('./randombytes')
const { crypto_generichash_batch } = require('./crypto_generichash')
const { crypto_secretbox_open_easy, crypto_secretbox_easy } = require('./crypto_secretbox')
const xsalsa20 = require('xsalsa20')
const { memzero } = require('./')
var crypto_box_PUBLICKEYBYTES = 32,
crypto_box_SECRETKEYBYTES = 32,
@ -47,7 +46,7 @@ function crypto_box_seed_keypair(pk, sk, seed) {
const hash = Buffer.alloc(64)
crypto_hash_sha512(hash, seed, 32)
hash.copy(sk, 0, 0, 32)
memzero(hash)
hash.fill(0)
return crypto_scalarmult_base(pk, sk)
}

View File

@ -13,8 +13,8 @@ var sodium = module.exports
// also forwarded at the bottom but randombytes is non-enumerable
var randombytes = require('./randombytes').randombytes
sodium.sodium_memzero = function (len, offset) {
for (var i = offset; i < len; i++) arr[i] = 0;
sodium.sodium_memzero = function (arr) {
arr.fill(0)
}
sodium.sodium_malloc = function (n) {