Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Error('Malformed OpenSSH private key');
if (kdfOptions.length) {
switch (kdfName) {
case 'none':
return new Error('Malformed OpenSSH private key');
case 'bcrypt':
/*
string salt
uint32 rounds
*/
var salt = utils.readString(kdfOptions, 0);
if (salt === false || kdfOptions._pos + 4 > kdfOptions.length)
return new Error('Malformed OpenSSH private key');
var rounds = readUInt32BE(kdfOptions, kdfOptions._pos);
var gen = Buffer.allocUnsafe(encInfo.keyLen + encInfo.ivLen);
var r = bcrypt_pbkdf(passphrase,
passphrase.length,
salt,
salt.length,
gen,
gen.length,
rounds);
if (r !== 0)
return new Error('Failed to generate information to decrypt key');
cipherKey = gen.slice(0, encInfo.keyLen);
cipherIV = gen.slice(encInfo.keyLen);
break;
}
} else if (kdfName !== 'none') {
return new Error('Malformed OpenSSH private key');
}