mirror of
https://gitlab.com/chrony/chrony.git
synced 2026-03-11 00:59:38 -04:00
cmac+hash: add support for Nettle 4.0
Support for truncated digests was removed in Nettle 4.0. The digest functions no longer accept the output length. Provide a full-length buffer and copy the requested length of the digest, same as with the other crypto providers.
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
#include "sysincl.h"
|
||||
|
||||
#include <nettle/nettle-meta.h>
|
||||
#include <nettle/version.h>
|
||||
|
||||
#include "hash.h"
|
||||
#include "memory.h"
|
||||
@@ -91,6 +92,7 @@ int
|
||||
HSH_Hash(int id, const void *in1, int in1_len, const void *in2, int in2_len,
|
||||
unsigned char *out, int out_len)
|
||||
{
|
||||
unsigned char buf[MAX_HASH_LENGTH];
|
||||
const struct nettle_hash *hash;
|
||||
void *context;
|
||||
|
||||
@@ -103,11 +105,20 @@ HSH_Hash(int id, const void *in1, int in1_len, const void *in2, int in2_len,
|
||||
if (out_len > hash->digest_size)
|
||||
out_len = hash->digest_size;
|
||||
|
||||
if (hash->digest_size > sizeof (buf))
|
||||
return 0;
|
||||
|
||||
hash->init(context);
|
||||
hash->update(context, in1_len, in1);
|
||||
if (in2)
|
||||
hash->update(context, in2_len, in2);
|
||||
hash->digest(context, out_len, out);
|
||||
hash->digest(context,
|
||||
#if NETTLE_VERSION_MAJOR < 4
|
||||
hash->digest_size,
|
||||
#endif
|
||||
buf);
|
||||
|
||||
memcpy(out, buf, out_len);
|
||||
|
||||
return out_len;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user