]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
hash: add support for older nettle versions
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 15 Mar 2018 07:18:29 +0000 (08:18 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 15 Mar 2018 08:00:09 +0000 (09:00 +0100)
Use nettle_hashes[] instead of nettle_get_hashes(), which is available
only in nettle >= 3.4. nettle_hashes[] is a symbol available in older
versions and may be renamed in future. In nettle >= 3.4 it is a macro
using nettle_get_hashes() for compatibility.

configure
hash_nettle.c

index d8b876e576828bfe5215edfaa6e1fe0ddee4d82d..a97ac786735fd4216e8d54fd0c99fad71c11f554 100755 (executable)
--- a/configure
+++ b/configure
@@ -867,7 +867,7 @@ if [ $feat_sechash = "1" ] && [ "x$HASH_LINK" = "x" ]  && [ $try_nettle = "1" ];
   test_link="`pkg_config --libs nettle`"
   if test_code 'nettle' 'nettle/nettle-meta.h nettle/sha2.h' \
     "$test_cflags" "$test_link" \
-    'return nettle_get_hashes()[0]->context_size;'
+    'return nettle_hashes[0]->context_size;'
   then
     HASH_OBJ="hash_nettle.o"
     HASH_LINK="$test_link"
index cc9b8ad310b4cc020c45d895ab84c17e4c533740..2c3501d8e97ee97c2d19b479596aeec1d9abc6cc 100644 (file)
@@ -58,7 +58,6 @@ static struct hash hashes[] = {
 int
 HSH_GetHashId(const char *name)
 {
-  const struct nettle_hash *const *nhashes;
   int id, nid;
 
   for (id = 0; hashes[id].name; id++) {
@@ -72,19 +71,15 @@ HSH_GetHashId(const char *name)
   if (hashes[id].context)
     return id;
 
-  nhashes = nettle_get_hashes();
-  if (!nhashes)
-    return -1;
-
-  for (nid = 0; nhashes[nid]; nid++) {
-    if (!strcmp(hashes[id].int_name, nhashes[nid]->name))
+  for (nid = 0; nettle_hashes[nid]; nid++) {
+    if (!strcmp(hashes[id].int_name, nettle_hashes[nid]->name))
       break;
   }
 
-  if (!nhashes[nid] || !nhashes[nid]->context_size || !nhashes[nid]->init)
+  if (!nettle_hashes[nid] || !nettle_hashes[nid]->context_size || !nettle_hashes[nid]->init)
     return -1;
 
-  hashes[id].nettle_hash = nhashes[nid];
+  hashes[id].nettle_hash = nettle_hashes[nid];
   hashes[id].context = Malloc(hashes[id].nettle_hash->context_size);
 
   return id;