internal static byte[] RsaOaepEncrypt(RSA rsa, HashAlgorithm hash, PKCS1MaskGenerationMethod mgf, RandomNumberGenerator rng, byte[] data)
{
int length1 = rsa.KeySize / 8;
int length2 = hash.HashSize / 8;
if (data.Length + 2 + 2 * length2 > length1)
{
throw new CryptographicException(string.Format((IFormatProvider)null, Environment.GetResourceString("Cryptography_Padding_EncDataTooBig"), (object)(length1 - 2 - 2 * length2)));
}
hash.ComputeHash(EmptyArray <byte> .Value);
byte[] rgbSeed = new byte[length1 - length2];
Buffer.InternalBlockCopy((Array)hash.Hash, 0, (Array)rgbSeed, 0, length2);
byte[] numArray1 = rgbSeed;
int index1 = numArray1.Length - data.Length - 1;
int num = 1;
numArray1[index1] = (byte)num;
Buffer.InternalBlockCopy((Array)data, 0, (Array)rgbSeed, rgbSeed.Length - data.Length, data.Length);
byte[] numArray2 = new byte[length2];
rng.GetBytes(numArray2);
byte[] mask1 = mgf.GenerateMask(numArray2, rgbSeed.Length);
for (int index2 = 0; index2 < rgbSeed.Length; ++index2)
{
rgbSeed[index2] = (byte)((uint)rgbSeed[index2] ^ (uint)mask1[index2]);
}
byte[] mask2 = mgf.GenerateMask(rgbSeed, length2);
for (int index2 = 0; index2 < numArray2.Length; ++index2)
{
numArray2[index2] ^= mask2[index2];
}
byte[] rgb = new byte[length1];
Buffer.InternalBlockCopy((Array)numArray2, 0, (Array)rgb, 0, numArray2.Length);
Buffer.InternalBlockCopy((Array)rgbSeed, 0, (Array)rgb, numArray2.Length, rgbSeed.Length);
return(rsa.EncryptValue(rgb));
}