make sure to always check mp_to_*, normal math could fail

This commit is contained in:
toddouska
2013-10-29 17:38:12 -07:00
parent f402d7eed9
commit 3d19604bfb
3 changed files with 23 additions and 15 deletions

View File

@@ -325,15 +325,15 @@ int PKCS12_PBKDF(byte* output, const byte* passwd, int passLen,const byte* salt,
if (outSz > (int)v) {
/* take off MSB */
byte tmp[129];
mp_to_unsigned_bin(&res, tmp);
ret = mp_to_unsigned_bin(&res, tmp);
XMEMCPY(I + i, tmp + 1, v);
}
else if (outSz < (int)v) {
XMEMSET(I + i, 0, v - outSz);
mp_to_unsigned_bin(&res, I + i + v - outSz);
ret = mp_to_unsigned_bin(&res, I + i + v - outSz);
}
else
mp_to_unsigned_bin(&res, I + i);
ret = mp_to_unsigned_bin(&res, I + i);
}
mp_clear(&i1);