Skip to content

Commit c11a7da

Browse files
committed
Normalise passphrase in the Vault generator, not inside the crypto API
1 parent 23663ac commit c11a7da

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

lib/crypto/node_crypto.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ module.exports = {
88

99
pbkdf2: {
1010
async digest (password, salt, iterations, size) {
11-
let pw = password.normalize('NFKD')
1211
let fn = promisify(crypto.pbkdf2)
1312
let bytes = Math.ceil(size / 8)
14-
return fn(pw, salt, iterations, bytes, 'sha1')
13+
return fn(password, salt, iterations, bytes, 'sha1')
1514
}
1615
},
1716

lib/crypto/web_crypto.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = {
1414

1515
pbkdf2: {
1616
async digest (password, salt, iterations, size) {
17-
let pw = Buffer.from(password.normalize('NFKD'), 'utf8')
17+
let pw = Buffer.from(password, 'utf8')
1818
pw = await subtle.importKey('raw', pw, 'PBKDF2', false, ['deriveKey'])
1919

2020
salt = Buffer.from(salt, 'utf8')

lib/vault.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ CHARS.ALL = CHARS.ALPHANUM.concat(CHARS.SPACE).concat(CHARS.SYMBOL)
2121
const TYPES = 'LOWER UPPER NUMBER SPACE DASH SYMBOL'.split(' ')
2222

2323
function createHash (key, message, entropy) {
24+
key = key.normalize('NFC')
2425
return crypto.pbkdf2.digest(key, message, 8, entropy || 256)
2526
}
2627

0 commit comments

Comments
 (0)