]> git.meshlink.io Git - meshlink/blobdiff - src/prf.c
Fix more compiler warnings.
[meshlink] / src / prf.c
index ec8d0c60e58c2a33b666abbb7e301cb9919a66ac..e6fdcb60ea1ffeebf4351dc77249631649a59027 100644 (file)
--- a/src/prf.c
+++ b/src/prf.c
 #include "ed25519/sha512.h"
 
 static void memxor(char *buf, char c, size_t len) {
+       assert(buf);
+       assert(len);
+
        for(size_t i = 0; i < len; i++) {
                buf[i] ^= c;
        }
 }
 
-static const size_t mdlen = 64;
+#define mdlen 64
 
 // TODO: separate key setup from hmac_sha512
 
 static bool hmac_sha512(const char *key, size_t keylen, const char *msg, size_t msglen, char *out) {
+       assert(msg);
+       assert(msglen);
+
        char tmp[2 * mdlen];
        sha512_context md;
 
@@ -79,7 +85,14 @@ static bool hmac_sha512(const char *key, size_t keylen, const char *msg, size_t
    We use SHA512 instead of MD5 and SHA1.
  */
 
-bool prf(const char *secret, size_t secretlen, char *seed, size_t seedlen, char *out, size_t outlen) {
+bool prf(const char *secret, size_t secretlen, const char *seed, size_t seedlen, char *out, size_t outlen) {
+       assert(secret);
+       assert(secretlen);
+       assert(seed);
+       assert(seedlen);
+       assert(out);
+       assert(outlen);
+
        /* Data is what the "inner" HMAC function processes.
           It consists of the previous HMAC result plus the seed.
         */