Commit 43baab490c88e80307014b623ce55d96d8a172f1

Thomas de Grivel 2024-10-28T13:22:13

fix crypt on linux

diff --git a/libkc3/crypt.c b/libkc3/crypt.c
index 459dd75..aa78a1d 100644
--- a/libkc3/crypt.c
+++ b/libkc3/crypt.c
@@ -18,6 +18,7 @@
 #include "config.h"
 #include "crypt.h"
 #include "str.h"
+#include "tag.h"
 
 #if HAVE_CRYPT_NEWHASH
 
@@ -66,7 +67,6 @@ s_str * crypt_hash_password (const s_str *pass, s_str *dest)
 bool * crypt_check_password (const s_str *pass, const s_str *hash,
                              bool *dest)
 {
-  sw e;
   s_str str;
   assert(pass);
   assert(hash);
@@ -83,11 +83,13 @@ bool * crypt_check_password (const s_str *pass, const s_str *hash,
 
 s_str * crypt_hash_password (const s_str *pass, s_str *dest)
 {
-  s_str prefix = {{NULL}, 17, {"$6$rounds=123456$"}};
-  s_str salt;
   s_str config;
   s_str hash;
-  if (! str_init_random_base64(&salt, 16))
+  s_str prefix = {{NULL}, 17, {"$6$rounds=123456$"}};
+  s_str salt;
+  s_tag tag;
+  tag_init_uw(&tag, 16);
+  if (! str_init_random_base64(&salt, &tag))
     return NULL;
   if (! str_init_concatenate(&config, &prefix, &salt)) {
     str_clean(&salt);
diff --git a/libkc3/crypt_sha512.c b/libkc3/crypt_sha512.c
index f475663..d3ff2b4 100644
--- a/libkc3/crypt_sha512.c
+++ b/libkc3/crypt_sha512.c
@@ -339,7 +339,7 @@ static char * sha512_crypt(const char *key, const char *setting, char *output)
 
   /* DS = sha(repeat-salt) */
   sha512_init(&ctx);
-  for (i = 0; i < 16 + md[0]; i++)
+  for (i = 0; (s32) i < 16 + md[0]; i++)
     sha512_update(&ctx, salt, slen);
   sha512_sum(&ctx, smd);