code: function initModule(forge) {
  
  forge.mgf = forge.mgf || {};
  var mgf1 = forge.mgf.mgf1 = forge.mgf1 = forge.mgf1 || {};
  
  /**
   * Creates a MGF1 mask generation function object.
   *
   * @return a mask generation function object.
   */
  mgf1.create = function(md) {
    var mgf = {
      /**
       * Generate mask of specified length.
       *
       * @param {String} seed The seed for mask generation.
       * @param maskLen Number of bytes to generate.
       * @return {String} The generated mask.
       */
      generate: function(seed, maskLen) {
        /* 2. Let T be the empty octet string. */
        var t = new forge.util.ByteBuffer();
  
        /* 3. For counter from 0 to ceil(maskLen / hLen), do the following: */
        var len = Math.ceil(maskLen / md.digestLength);
        for(var i = 0; i < len; i++) {
          /* a. Convert counter to an octet string C of length 4 octets */
          var c = new forge.util.ByteBuffer();
          c.putInt32(i);
  
          /* b. Concatenate the hash of the seed mgfSeed and C to the octet
           * string T: */
          md.start();
          md.update(seed + c.getBytes());
          t.putBuffer(md.digest());
        }
  
        /* Output the leading maskLen octets of T as the octet string mask. */
        t.truncate(t.length() - maskLen);
        return t.getBytes();
      }
    };
  
    return mgf;
  };
  
  }
docs: /* ########## Begin module implementation ##########