Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' into address-labels
Browse files Browse the repository at this point in the history
  • Loading branch information
Sjors committed Mar 15, 2017
2 parents 50828ad + 93b47ad commit 81aec2b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/wallet-crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,7 @@ function stretchPassword (password, salt, iterations, keylen) {

function pbkdf2 (password, salt, iterations, keylen, algorithm) {
algorithm = algorithm || ALGO.SHA1;
var iv = salt.toString('binary');
return crypto.pbkdf2Sync(password, iv, iterations, keylen, algorithm);
return crypto.pbkdf2Sync(password, salt, iterations, keylen, algorithm);
}

function hashNTimes (data, iterations) {
Expand Down
13 changes: 13 additions & 0 deletions tests/wallet_crypto_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,19 @@ describe('WalletCrypto', () => {
it('should not modify the operation is unknown', () => expect(WalletCrypto.cipherFunction('password', 'key', 1000, 'nop')('toto')).toEqual('toto'));
});

describe('pbkdf2', () => {
it('should compute the correct result', () => {
let password = 'password123';
let salt = new Buffer('acf98ce0f6fb15ac868f0c2cdbc2c263', 'hex');
let iterations = 5000;
let keylen = 32;

let result = WalletCrypto.pbkdf2(password, salt, iterations, keylen);
let resultHex = 'f32463775c57e37148b4f54010c794403b34847e99e0b6f381418df09e281900';
expect(result.toString('hex')).toEqual(resultHex);
});
});

describe('scrypt', () => {
let observer =
{callback (hash) {}};
Expand Down

0 comments on commit 81aec2b

Please sign in to comment.