fix code format, only spaces added, no code has been modified.
This commit is contained in:
parent
eaaf0a7c28
commit
fc24dca12d
@ -778,32 +778,32 @@ int HKDF(int type, const byte* inKey, word32 inKeySz,
|
|||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
while (outIdx < outSz) {
|
while (outIdx < outSz) {
|
||||||
int tmpSz = (n == 1) ? 0 : hashSz;
|
int tmpSz = (n == 1) ? 0 : hashSz;
|
||||||
word32 left = outSz - outIdx;
|
word32 left = outSz - outIdx;
|
||||||
|
|
||||||
ret = HmacSetKey(&myHmac, type, prk, hashSz);
|
ret = HmacSetKey(&myHmac, type, prk, hashSz);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
break;
|
break;
|
||||||
ret = HmacUpdate(&myHmac, tmp, tmpSz);
|
ret = HmacUpdate(&myHmac, tmp, tmpSz);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
break;
|
break;
|
||||||
ret = HmacUpdate(&myHmac, info, infoSz);
|
ret = HmacUpdate(&myHmac, info, infoSz);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
break;
|
break;
|
||||||
ret = HmacUpdate(&myHmac, &n, 1);
|
ret = HmacUpdate(&myHmac, &n, 1);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
break;
|
break;
|
||||||
ret = HmacFinal(&myHmac, tmp);
|
ret = HmacFinal(&myHmac, tmp);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
left = min(left, (word32)hashSz);
|
left = min(left, (word32)hashSz);
|
||||||
XMEMCPY(out+outIdx, tmp, left);
|
XMEMCPY(out+outIdx, tmp, left);
|
||||||
|
|
||||||
outIdx += hashSz;
|
outIdx += hashSz;
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CYASSL_SMALL_STACK
|
#ifdef CYASSL_SMALL_STACK
|
||||||
|
@ -158,51 +158,51 @@ int PBKDF2(byte* output, const byte* passwd, int pLen, const byte* salt,
|
|||||||
ret = HmacSetKey(&hmac, hashType, passwd, pLen);
|
ret = HmacSetKey(&hmac, hashType, passwd, pLen);
|
||||||
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
while (kLen) {
|
while (kLen) {
|
||||||
int currentLen;
|
int currentLen;
|
||||||
|
|
||||||
ret = HmacUpdate(&hmac, salt, sLen);
|
ret = HmacUpdate(&hmac, salt, sLen);
|
||||||
if (ret != 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* encode i */
|
|
||||||
for (j = 0; j < 4; j++) {
|
|
||||||
byte b = (byte)(i >> ((3-j) * 8));
|
|
||||||
|
|
||||||
ret = HmacUpdate(&hmac, &b, 1);
|
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
/* check ret from inside for loop */
|
/* encode i */
|
||||||
if (ret != 0)
|
for (j = 0; j < 4; j++) {
|
||||||
break;
|
byte b = (byte)(i >> ((3-j) * 8));
|
||||||
|
|
||||||
ret = HmacFinal(&hmac, buffer);
|
ret = HmacUpdate(&hmac, &b, 1);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
currentLen = min(kLen, hLen);
|
/* check ret from inside for loop */
|
||||||
XMEMCPY(output, buffer, currentLen);
|
|
||||||
|
|
||||||
for (j = 1; j < iterations; j++) {
|
|
||||||
ret = HmacUpdate(&hmac, buffer, hLen);
|
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
ret = HmacFinal(&hmac, buffer);
|
ret = HmacFinal(&hmac, buffer);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
break;
|
break;
|
||||||
xorbuf(output, buffer, currentLen);
|
|
||||||
|
currentLen = min(kLen, hLen);
|
||||||
|
XMEMCPY(output, buffer, currentLen);
|
||||||
|
|
||||||
|
for (j = 1; j < iterations; j++) {
|
||||||
|
ret = HmacUpdate(&hmac, buffer, hLen);
|
||||||
|
if (ret != 0)
|
||||||
|
break;
|
||||||
|
ret = HmacFinal(&hmac, buffer);
|
||||||
|
if (ret != 0)
|
||||||
|
break;
|
||||||
|
xorbuf(output, buffer, currentLen);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check ret from inside for loop */
|
||||||
|
if (ret != 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
output += currentLen;
|
||||||
|
kLen -= currentLen;
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check ret from inside for loop */
|
|
||||||
if (ret != 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
output += currentLen;
|
|
||||||
kLen -= currentLen;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CYASSL_SMALL_STACK
|
#ifdef CYASSL_SMALL_STACK
|
||||||
|
Loading…
Reference in New Issue
Block a user