fix build on Solaris 10

Tue, 13 Aug 2019 20:23:23 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 13 Aug 2019 20:23:23 +0200
changeset 624
27985062cd2c
parent 623
7870656d302d
child 625
e1a85fbf68f9

fix build on Solaris 10

libidav/crypto.c file | annotate | diff | comparison | revisions
libidav/utils.c file | annotate | diff | comparison | revisions
libidav/versioning.c file | annotate | diff | comparison | revisions
--- a/libidav/crypto.c	Sun Aug 11 18:41:06 2019 +0200
+++ b/libidav/crypto.c	Tue Aug 13 20:23:23 2019 +0200
@@ -355,7 +355,10 @@
 
 char* dav_create_hash(const char *data, size_t len) {
     unsigned char hash[DAV_SHA256_DIGEST_LENGTH];
-    SHA256((const unsigned char*)data, len, hash);
+    DAV_SHA_CTX ctx;
+    SHA256_Init(&ctx);
+    SHA256_Update(&ctx, data, len);
+    SHA256_Final(hash, &ctx);
     return util_hexstr(hash, DAV_SHA256_DIGEST_LENGTH);
 }
 
@@ -374,6 +377,17 @@
     free(ctx);
 }
 
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+static int crypto_pw2key_error = 0;
+DavKey* dav_pw2key(const char *password, const unsigned char *salt, int saltlen, int pwfunc, int enc) {
+    if(!crypto_pw2key_error) {
+        fprintf(stderr, "Error: password key derivation not supported on this platform: openssl to old\n");
+        crypto_pw2key_error = 1;
+    }
+    return 0;
+}
+
+#else
 DavKey* dav_pw2key(const char *password, const unsigned char *salt, int saltlen, int pwfunc, int enc) {
     if(!password) {
         return NULL;
@@ -430,6 +444,7 @@
     memcpy(key->data, keydata, keylen);
     return key;
 }
+#endif
 
 #endif
 
--- a/libidav/utils.c	Sun Aug 11 18:41:06 2019 +0200
+++ b/libidav/utils.c	Tue Aug 13 20:23:23 2019 +0200
@@ -1066,4 +1066,4 @@
     fclose(in);
     
     return util_hexstr(hash, DAV_SHA256_DIGEST_LENGTH);    
-}
\ No newline at end of file
+}
--- a/libidav/versioning.c	Sun Aug 11 18:41:06 2019 +0200
+++ b/libidav/versioning.c	Tue Aug 13 20:23:23 2019 +0200
@@ -170,4 +170,4 @@
     }
     
     return versions;
-}
\ No newline at end of file
+}

mercurial