web_modules/forge.bundle.js
function _createKDF(kdf, md, counterStart, digestLength) {
  /**
   * 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.
   */
  kdf.generate = function(x, length) {
    var key = new forge.util.ByteBuffer();

    // run counter from counterStart to ceil(length / Hash.len)
    var k = Math.ceil(length / digestLength) + counterStart;

    var c = new forge.util.ByteBuffer();
    for(var i = counterStart; i < k; ++i) {
      // I2OSP(i, 4): convert counter to an octet string of 4 octets
      c.putInt32(i);

      // digest 'x' and the counter and add the result to the key
      md.start();
      md.update(x + c.getBytes());
      var hash = md.digest();
      key.putBytes(hash.getBytes(digestLength));
    }

    // truncate to the correct key length
    key.truncate(key.length() - length);
    return key.getBytes();
  };
}
function _createKDF(kdf, md, counterStart, digestLength) {
  /**
   * 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.
   */
  kdf.generate = function(x, length) {
    var key = new forge.util.ByteBuffer();

    // run counter from counterStart to ceil(length / Hash.len)
    var k = Math.ceil(length / digestLength) + counterStart;

    var c = new forge.util.ByteBuffer();
    for(var i = counterStart; i < k; ++i) {
      // I2OSP(i, 4): convert counter to an octet string of 4 octets
      c.putInt32(i);

      // digest 'x' and the counter and add the result to the key
      md.start();
      md.update(x + c.getBytes());
      var hash = md.digest();
      key.putBytes(hash.getBytes(digestLength));
    }

    // truncate to the correct key length
    key.truncate(key.length() - length);
    return key.getBytes();
  };
}
function _createKDF ( kdf , md , counterStart , digestLength ) { /**
   * 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.
   */ kdf . generate = function ( x , length ) { var key = new forge . util . ByteBuffer ( ) ; // run counter from counterStart to ceil(length / Hash.len)
 var k = Math . ceil ( length / digestLength ) + counterStart ; var c = new forge . util . ByteBuffer ( ) ; for ( var i = counterStart ; i < k ; ++ i ) { // I2OSP(i, 4): convert counter to an octet string of 4 octets
 c . putInt32 ( i ) ; // digest 'x' and the counter and add the result to the key
 md . start ( ) ; md . update ( x + c . getBytes ( ) ) ; var hash = md . digest ( ) ; key . putBytes ( hash . getBytes ( digestLength ) ) ; } // truncate to the correct key length
 key . truncate ( key . length ( ) - length ) ; return key . getBytes ( ) ; } ; }
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 .