From 4e1c69ba133d7a53321f8c1f82ac197892d17abe Mon Sep 17 00:00:00 2001 From: Jim Pick Date: Sat, 3 Mar 2018 09:19:06 -0800 Subject: [PATCH] Change crypto_kdf_KEYBYTES to be 32 and use subarray instead of slice Thanks to Emil Bayes for the advice. --- crypto_kdf.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crypto_kdf.js b/crypto_kdf.js index a9dd697..aad5183 100644 --- a/crypto_kdf.js +++ b/crypto_kdf.js @@ -6,7 +6,7 @@ module.exports.crypto_kdf_PRIMITIVE = 'blake2b' module.exports.crypto_kdf_BYTES_MIN = 16 module.exports.crypto_kdf_BYTES_MAX = 64 module.exports.crypto_kdf_CONTEXTBYTES = 8 -module.exports.crypto_kdf_KEYBYTES = 64 +module.exports.crypto_kdf_KEYBYTES = 32 function STORE64_LE(dest, int) { var mul = 1 @@ -29,7 +29,7 @@ module.exports.crypto_kdf_derive_from_key = function crypto_kdf_derive_from_key STORE64_LE(salt, subkey_id) var outlen = Math.min(subkey.length, module.exports.crypto_kdf_BYTES_MAX) - blake2b(outlen, key.slice(0, blake2b.KEYBYTES), salt, ctx_padded, true) + blake2b(outlen, key.subarray(0, module.exports.crypto_kdf_KEYBYTES), salt, ctx_padded, true) .final(subkey) }