10
void Pbkdf2Hmac(const Byte *pwd, size_t pwdSize, const Byte *salt, size_t saltSize,
11
UInt32 numIterations, Byte *key, size_t keySize)
14
baseCtx.SetKey(pwd, pwdSize);
15
for (UInt32 i = 1; keySize > 0; i++)
18
ctx.Update(salt, saltSize);
19
Byte u[kDigestSize] = { (Byte)(i >> 24), (Byte)(i >> 16), (Byte)(i >> 8), (Byte)(i) };
20
const unsigned int curSize = (keySize < kDigestSize) ? (unsigned int)keySize : kDigestSize;
22
ctx.Final(u, kDigestSize);
25
for (s = 0; s < curSize; s++)
28
for (UInt32 j = numIterations; j > 1; j--)
31
ctx.Update(u, kDigestSize);
32
ctx.Final(u, kDigestSize);
33
for (s = 0; s < curSize; s++)
42
void Pbkdf2Hmac32(const Byte *pwd, size_t pwdSize, const UInt32 *salt, size_t saltSize,
43
UInt32 numIterations, UInt32 *key, size_t keySize)
46
baseCtx.SetKey(pwd, pwdSize);
47
for (UInt32 i = 1; keySize > 0; i++)
49
CHmac32 ctx = baseCtx;
50
ctx.Update(salt, saltSize);
51
UInt32 u[kDigestSizeInWords] = { i };
52
const unsigned int curSize = (keySize < kDigestSizeInWords) ? (unsigned int)keySize : kDigestSizeInWords;
54
ctx.Final(u, kDigestSizeInWords);
56
// Speed-optimized code start
58
ctx.GetLoopXorDigest(u, numIterations - 1);
59
// Speed-optimized code end
62
for (s = 0; s < curSize; s++)
67
for (UInt32 j = numIterations; j > 1; j--)
70
ctx.Update(u, kDigestSizeInWords);
71
ctx.Final(u, kDigestSizeInWords);
72
for (s = 0; s < curSize; s++)