From 4e34d3d0cabf352eae06b77784327600736821bc Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Fri, 12 Feb 2016 15:41:48 -0800 Subject: [PATCH] use native pbkdf2. --- lib/bcoin/hd.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/bcoin/hd.js b/lib/bcoin/hd.js index f32385d1..0e6296cd 100644 --- a/lib/bcoin/hd.js +++ b/lib/bcoin/hd.js @@ -1123,12 +1123,16 @@ function array32(data) { /** * PDKBF2 * Credit to: https://github.com/stayradiated/pbkdf2-sha512 - * Copyright (c) 2014, JP Richardson Copyright (c) 2010-2011 Intalio Pte, All Rights Reserved + * Copyright (c) 2010-2011 Intalio Pte, All Rights Reserved + * Copyright (c) 2014, JP Richardson */ function pbkdf2(key, salt, iterations, dkLen) { 'use strict'; + if (bcoin.crypto && bcoin.crypto.pbkdf2Sync) + return bcoin.crypto.pbkdf2Sync(key, salt, iterations, dkLen, 'sha512'); + var hLen = 64; if (dkLen > (Math.pow(2, 32) - 1) * hLen) @@ -1191,7 +1195,7 @@ var cache = { cache.set = function(key, index, value) { key = key + '/' + index; - if (this.count > 200) { + if (this.count > 500) { this.data = {}; this.count = 0; }