implemented password key support for Solaris 10

Sat, 03 Oct 2015 20:10:54 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sat, 03 Oct 2015 20:10:54 +0200
changeset 149
509e9e1cbdcc
parent 148
f21ee22170bf
child 150
37fb12574acd

implemented password key support for Solaris 10

libidav/utils.c file | annotate | diff | comparison | revisions
suncc.mk file | annotate | diff | comparison | revisions
--- a/libidav/utils.c	Sat Oct 03 19:55:43 2015 +0200
+++ b/libidav/utils.c	Sat Oct 03 20:10:54 2015 +0200
@@ -49,6 +49,9 @@
 #include "crypto.h"
 #include "webdav.h"
 
+#ifdef __sun
+#include <sha2.h>
+#endif
 
 time_t util_parse_creationdate(char *str) {
     // example: 2012-11-29T21:35:35Z
@@ -453,14 +456,20 @@
 }
 
 void util_generate_key(DavKey *key, char *password) {
-    //key->data = malloc(SHA256_DIGEST_LENGTH);
-    //key->length = SHA256_DIGEST_LENGTH;
+    key->data = malloc(SHA256_DIGEST_LENGTH);
+    key->length = SHA256_DIGEST_LENGTH;
     key->type =  DAV_KEY_AES256;
-    
-    //SHA256_CTX sha256;
-    //SHA256_Init(&sha256);
-    //SHA256_Update(&sha256, password, strlen(password));
-    //SHA256_Final(key->data, &sha256);
+#ifdef __sun
+    SHA256_CTX sha256;
+    SHA256Init(&sha256);
+    SHA256Update(&sha256, password, strlen(password));
+    SHA256Final(key->data, &sha256);
+#else
+    SHA256_CTX sha256;
+    SHA256_Init(&sha256);
+    SHA256_Update(&sha256, password, strlen(password));
+    SHA256_Final(key->data, &sha256);
+#endif
 }
 
 char* util_key_input(DavContext *ctx, DavKey *key) {
--- a/suncc.mk	Sat Oct 03 19:55:43 2015 +0200
+++ b/suncc.mk	Sat Oct 03 20:10:54 2015 +0200
@@ -33,7 +33,7 @@
 
 CFLAGS  = -g -c -xc99 -D_REENTRANT
 COFLAGS = -o
-LDFLAGS =
+LDFLAGS = -lmd
 LOFLAGS = -o
 ARFLAGS = -r
 RMFLAGS = -f

mercurial