mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-03 16:35:06 -05:00
hash: add support for older nettle versions
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.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user