private byte[] CryptRaw(byte[] inputBytes, byte[] saltBytes, int logRounds)
{
uint[] cdata = new uint[_BfCryptCiphertext.Length];
Array.Copy(_BfCryptCiphertext, cdata, _BfCryptCiphertext.Length);
int clen = cdata.Length;
if (logRounds < 4 || logRounds > 31)
throw new ArgumentException("Bad number of rounds", "logRounds");
if (saltBytes.Length != BCRYPT_SALT_LEN)
throw new ArgumentException("Bad salt Length", "saltBytes");
uint rounds = 1u << logRounds;
Debug.Assert(rounds > 0, "Rounds must be > 0"); // We overflowed rounds at 31 - added safety check
InitializeKey();
EKSKey(saltBytes, inputBytes);
for (int i = 0; i < rounds; i++)
{
Key(inputBytes);
Key(saltBytes);
}
for (int i = 0; i < 64; i++)
{
for (int j = 0; j < (clen >> 1); j++)
Encipher(cdata, j << 1);
}
byte[] ret = new byte[clen * 4];
for (int i = 0, j = 0; i < clen; i++)
{
ret[j++] = (byte)((cdata[i] >> 24) & 0xff);
ret[j++] = (byte)((cdata[i] >> 16) & 0xff);
ret[j++] = (byte)((cdata[i] >> 8) & 0xff);
ret[j++] = (byte)(cdata[i] & 0xff);
}
return ret;
}
}