/// <summary>
        /// Mask generation function.
        /// </summary>
        /// <param name="seed">Seed</param>
        /// <param name="maskLen">Length of generated mask</param>
        /// <param name="hashLength">Length of the hash produced by the supplied hash provider</param>
        /// <param name="hashProvider">Hash provider to use in mask generation</param>
        /// <returns>Generated mask of specified length</returns>
        internal static byte[] OAEPMGF( byte[] seed, int maskLen, int hashLength, HashProviders.IHashProvider hashProvider )
        {
            byte[] result = new byte[maskLen];

            //Determine how many interations we have to do.  We'll be appending
            //m_hLen (hash length) bytes for every iteration, so the size of the generated byte array
            //will be m_hLen * iNum (number of iterations).
            int iNum = (int)Math.Floor( (double)( maskLen / hashLength ) ) + 1;

            //Mask that will be truncated to create the final
            //resulting mask returned by this function.
            byte[] bytLongMask = new byte[( iNum * hashLength )];

            byte[] bytAppend = new byte[4];
            byte[] bytTmp = null;
            int iPadLen = 0;
            byte[] bytSeedHash = new byte[hashLength];

            //Padded pseudorandom seed to be hashed.
            byte[] bytPadSeed = new byte[( seed.Length + 4 )];
            seed.CopyTo( bytPadSeed, 0 );

            for( int i = 0; i <= iNum - 1; i++ ) {
                //Convert the iterator to an Octet String byte array
                bytTmp = CryptoMathematics.I2OSP( i, 4 );

                //Calculate the needed padding zeros, and add
                //them to the resulting Array.  Result must be 4 bytes long.
                iPadLen = bytAppend.Length - bytTmp.Length;

                bytTmp.CopyTo( bytAppend, 0 );

                //Hash the pseudorandom padded seed and append it to the
                //long version of the mask.
                bytAppend.CopyTo( bytPadSeed, seed.Length );
                bytSeedHash = hashProvider.ComputeHash( bytPadSeed );
                bytSeedHash.CopyTo( bytLongMask, i * hashLength );
            }

            //Copy the first maskLen bytes of bytLongMask to the result
            //and return the result.
            Array.Copy( bytLongMask, result, maskLen );

            return result;
        }