File chrony-refid-internal-md5.patch of Package chrony.19955

--- util.c.orig
+++ util.c
@@ -32,7 +32,8 @@
 #include "logging.h"
 #include "memory.h"
 #include "util.h"
-#include "hash.h"
+/* We do md5 on our own, to avoid FIPS troubles (md5 is not real crypto) */
+#include "md5.c"
 
 #define NSEC_PER_SEC 1000000000
 
@@ -361,23 +362,17 @@ UTI_StringToIP(const char *addr, IPAddr
 uint32_t
 UTI_IPToRefid(IPAddr *ip)
 {
-  static int MD5_hash = -1;
-  unsigned char buf[16];
+  static MD5_CTX ctx;
+  unsigned char *buf = &ctx.digest;
 
   switch (ip->family) {
     case IPADDR_INET4:
       return ip->addr.in4;
     case IPADDR_INET6:
-      if (MD5_hash < 0) {
-        MD5_hash = HSH_GetHashId("MD5");
-        assert(MD5_hash >= 0);
-      }
-
-      if (HSH_Hash(MD5_hash, (unsigned const char *)ip->addr.in6, sizeof
-            (ip->addr.in6), NULL, 0, buf, 16) != 16) {
-        assert(0);
-        return 0;
-      };
+      MD5Init(&ctx);
+      MD5Update(&ctx, (unsigned const char *)ip->addr.in6,
+		      sizeof(ip->addr.in6));
+      MD5Final(&ctx);
       return (uint32_t)buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3];
   }
   return 0;
openSUSE Build Service is sponsored by