We use SHA512 instead of MD5 and SHA1.
*/
-static bool prf_xor(int nid, const char *secret, size_t secretlen, char *seed, size_t seedlen, char *out, size_t outlen) {
- digest_t *digest = digest_open_by_nid(nid, -1);
+static bool prf_xor(int nid, const uint8_t *secret, size_t secretlen, uint8_t *seed, size_t seedlen, uint8_t *out, size_t outlen) {
+ digest_t *digest = digest_open_by_nid(nid, DIGEST_ALGO_SIZE);
if(!digest) {
return false;
memset(data, 0, len);
memcpy(data + len, seed, seedlen);
- char hash[len];
+ uint8_t hash[len];
while(outlen > 0) {
/* Inner HMAC */
}
/* XOR the results of the outer HMAC into the out buffer */
- for(size_t i = 0; i < len && i < outlen; i++) {
+ size_t i;
+
+ for(i = 0; i < len && i < outlen; i++) {
*out++ ^= hash[i];
}
- outlen -= len;
+ outlen -= i;
}
digest_close(digest);
return true;
}
-bool prf(const char *secret, size_t secretlen, char *seed, size_t seedlen, char *out, size_t outlen) {
+bool prf(const uint8_t *secret, size_t secretlen, uint8_t *seed, size_t seedlen, uint8_t *out, size_t outlen) {
/* This construction allows us to easily switch back to a scheme where the PRF is calculated using two different digest algorithms. */
memset(out, 0, outlen);