fixes signedness of salt in dav_pw2key()

Tue, 26 Feb 2019 10:40:23 +0100

author
Mike Becker <universe@uap-core.de>
date
Tue, 26 Feb 2019 10:40:23 +0100
changeset 515
2465dd550bb5
parent 514
4b84437b2167
child 516
39f5f17c3bc3

fixes signedness of salt in dav_pw2key()

dav/pwd.c file | annotate | diff | comparison | revisions
libidav/crypto.c file | annotate | diff | comparison | revisions
libidav/crypto.h file | annotate | diff | comparison | revisions
test/crypto.c file | annotate | diff | comparison | revisions
--- a/dav/pwd.c	Tue Feb 26 10:34:10 2019 +0100
+++ b/dav/pwd.c	Tue Feb 26 10:40:23 2019 +0100
@@ -232,7 +232,7 @@
 int pwdstore_setpassword(PwdStore *p, const char *password) {
     DavKey *key = dav_pw2key(
             password,
-            p->content->space + 4,
+            (unsigned char*)(p->content->space + 4),
             16,
             PWDS_PWFUNC(p),
             PWDS_ENC(p));
--- a/libidav/crypto.c	Tue Feb 26 10:34:10 2019 +0100
+++ b/libidav/crypto.c	Tue Feb 26 10:40:23 2019 +0100
@@ -359,7 +359,7 @@
     return util_hexstr(hash, DAV_SHA256_DIGEST_LENGTH);
 }
 
-DavKey* dav_pw2key(const char *password, const char *salt, int saltlen, int pwfunc, int enc) {
+DavKey* dav_pw2key(const char *password, const unsigned char *salt, int saltlen, int pwfunc, int enc) {
     if(!password) {
         return NULL;
     }
@@ -779,7 +779,7 @@
     return util_hexstr(hash, DAV_SHA256_DIGEST_LENGTH);
 }
 
-DavKey* dav_pw2key(const char *password, const char *salt, int saltlen, int pwfunc, int enc) {
+DavKey* dav_pw2key(const char *password, const unsigned char *salt, int saltlen, int pwfunc, int enc) {
     if(!password) {
         return NULL;
     }
@@ -804,7 +804,7 @@
                     kCCPBKDF2,
                     password,
                     len,
-                    (uint8_t*)salt,
+                    salt,
                     saltlen,
                     kCCPRFHmacAlgSHA256,
                     DAV_CRYPTO_ITERATION_COUNT,
@@ -820,7 +820,7 @@
                     kCCPBKDF2,
                     password,
                     len,
-                    (uint8_t*)salt,
+                    salt,
                     saltlen,
                     kCCPRFHmacAlgSHA512,
                     DAV_CRYPTO_ITERATION_COUNT,
--- a/libidav/crypto.h	Tue Feb 26 10:34:10 2019 +0100
+++ b/libidav/crypto.h	Tue Feb 26 10:40:23 2019 +0100
@@ -116,7 +116,7 @@
 
 char* dav_create_hash(const char *data, size_t len);
 
-DavKey* dav_pw2key(const char *password, const char *salt, int saltlen, int pwfunc, int enc);
+DavKey* dav_pw2key(const char *password, const unsigned char *salt, int saltlen, int pwfunc, int enc);
 
 UcxBuffer* aes_encrypt_buffer(UcxBuffer *buf, DavKey *key);
 UcxBuffer* aes_decrypt_buffer(UcxBuffer *buf, DavKey *key);
--- a/test/crypto.c	Tue Feb 26 10:34:10 2019 +0100
+++ b/test/crypto.c	Tue Feb 26 10:40:23 2019 +0100
@@ -418,25 +418,25 @@
             DavKey *keys[4];
             keys[0] =  dav_pw2key(
                     pws[p],
-                    (char*)salt[s],
+                    salt[s],
                     saltlen[s],
                     DAV_PWFUNC_PBKDF2_SHA256,
                     DAV_KEY_AES128);
             keys[1] = dav_pw2key(
                     pws[p],
-                    (char*)salt[s],
+                    salt[s],
                     saltlen[s],
                     DAV_PWFUNC_PBKDF2_SHA256,
                     DAV_KEY_AES256);
             keys[2] = dav_pw2key(
                     pws[p],
-                    (char*)salt[s],
+                    salt[s],
                     saltlen[s],
                     DAV_PWFUNC_PBKDF2_SHA512,
                     DAV_KEY_AES128);
             keys[3] = dav_pw2key(
                     pws[p],
-                    (char*)salt[s],
+                    salt[s],
                     saltlen[s],
                     DAV_PWFUNC_PBKDF2_SHA512,
                     DAV_KEY_AES256);

mercurial