node_modules/hybrid-crypto-js/web/hybrid-crypto.js
/**
 * Creates a KDF1 or KDF2 API object.
 *
 * @param md the hash API to use.
 * @param counterStart the starting index for the counter.
 * @param digestLength the digest length to use.
 *
 * @return the KDF API object.
 */
Creates a KDF1 or KDF2 API object.
@param md the hash API to use.
@param counterStart the starting index for the counter.
@param digestLength the digest length to use.

@return the KDF API object.
Creates a KDF1 or KDF2 API object . @param md the hash API to use . @param counterStart the starting index for the counter . @param digestLength the digest length to use . @return the KDF API object .
function _createKDF(kdf, md, counterStart, digestLength) {
  kdf.generate = function(x, length) {
    var key = new forge.util.ByteBuffer();
    var k = Math.ceil(length / digestLength) + counterStart;
    var c = new forge.util.ByteBuffer();
    for(var i = counterStart; i < k; ++i) {
      c.putInt32(i);
      md.start();
      md.update(x + c.getBytes());
      var hash = md.digest();
      key.putBytes(hash.getBytes(digestLength));
    }
    key.truncate(key.length() - length);
    return key.getBytes();
  };
}
function _createKDF ( kdf , md , counterStart , digestLength ) { kdf . generate = function ( x , length ) { var key = new forge . util . ByteBuffer ( ) ; var k = Math . ceil ( length / digestLength ) + counterStart ; var c = new forge . util . ByteBuffer ( ) ; for ( var i = counterStart ; i < k ; ++ i ) { c . putInt32 ( i ) ; md . start ( ) ; md . update ( x + c . getBytes ( ) ) ; var hash = md . digest ( ) ; key . putBytes ( hash . getBytes ( digestLength ) ) ; } key . truncate ( key . length ( ) - length ) ; return key . getBytes ( ) ; } ; }
Creates a KDF1 or KDF2 API object.
Creates a KDF1 or KDF2 API object .
/**
   * Generate a key of the specified length.
   *
   * @param x the binary-encoded byte string to generate a key from.
   * @param length the number of bytes to generate (the size of the key).
   *
   * @return the key as a binary-encoded string.
   */ // run counter from counterStart to ceil(length / Hash.len) // I2OSP(i, 4): convert counter to an octet string of 4 octets // digest 'x' and the counter and add the result to the key // truncate to the correct key length