packages/js-crypto-pbkdf/src/pbkdf.js
function assertPbkdf(p, s, c, dkLen, hash){
  if (typeof p !== 'string' && !(p instanceof Uint8Array)) throw new Error('PasswordIsNotUint8ArrayNorString');
  if (!(s instanceof Uint8Array)) throw new Error('SaltMustBeUint8Array');
  if (typeof c !== 'number' || c <= 0)throw new Error('InvalidIterationCount');
  if (typeof dkLen !== 'number' || dkLen <= 0) throw new Error('InvalidDerivedKeyLength');
  if (Object.keys(params.hashes).indexOf(hash) < 0) throw new Error('UnsupportedHashAlgorithm');
  return true;
}
function assertPbkdf(p, s, c, dkLen, hash){
  if (typeof p !== 'string' && !(p instanceof Uint8Array)) throw new Error('PasswordIsNotUint8ArrayNorString');
  if (!(s instanceof Uint8Array)) throw new Error('SaltMustBeUint8Array');
  if (typeof c !== 'number' || c <= 0)throw new Error('InvalidIterationCount');
  if (typeof dkLen !== 'number' || dkLen <= 0) throw new Error('InvalidDerivedKeyLength');
  if (Object.keys(params.hashes).indexOf(hash) < 0) throw new Error('UnsupportedHashAlgorithm');
  return true;
}
function assertPbkdf ( p , s , c , dkLen , hash ) { if ( typeof p !== 'string' && ! ( p instanceof Uint8Array ) ) throw new Error ( 'PasswordIsNotUint8ArrayNorString' ) ; if ( ! ( s instanceof Uint8Array ) ) throw new Error ( 'SaltMustBeUint8Array' ) ; if ( typeof c !== 'number' || c <= 0 ) throw new Error ( 'InvalidIterationCount' ) ; if ( typeof dkLen !== 'number' || dkLen <= 0 ) throw new Error ( 'InvalidDerivedKeyLength' ) ; if ( Object . keys ( params . hashes ) . indexOf ( hash ) < 0 ) throw new Error ( 'UnsupportedHashAlgorithm' ) ; return true ; }
Assertion for PBKDF 1 and 2
@param {Uint8Array|String} p - Byte array or string of password. if string is given, it will be converted to Uint8Array.
@param {Uint8Array} s - Byte array of salt.
@param {Number} c - Iteration count.
@param {Number} dkLen - Intended output key length in octet.
@param {String} hash - Name of underlying hash function for HMAC like 'SHA-256'
@return {boolean} - True if given params pass the assertion check. Otherwise, throw (not false).
@throws {Error} - Throws if the params doesn't pass the assertion checks for given conditions.
Assertion for PBKDF 1 and 2