X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fopenssl%2Fprf.c;h=f1f3d172a5d7f2801716cd33cb2adacf73e63763;hb=df687b5ca86b93e0801db54ba4bca0f81ff02548;hp=4f5a52befc65a98bbaf8338aa7dda5d4fe2a3d11;hpb=214060ef20499332b0369030b664a8e239518661;p=tinc diff --git a/src/openssl/prf.c b/src/openssl/prf.c index 4f5a52be..f1f3d172 100644 --- a/src/openssl/prf.c +++ b/src/openssl/prf.c @@ -29,11 +29,12 @@ 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, ssize_t outlen) { +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); - if(!digest) + if(!digest) { return false; + } if(!digest_set_key(digest, secret, secretlen)) { digest_close(digest); @@ -66,10 +67,13 @@ static bool prf_xor(int nid, const char *secret, size_t secretlen, char *seed, s } /* XOR the results of the outer HMAC into the out buffer */ - for(int 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);