HSH_SHA3_512 = 9,
HSH_TIGER = 10,
HSH_WHIRLPOOL = 11,
+ HSH_MD5_NONCRYPTO = 10000, /* For NTPv4 reference ID */
} HSH_Algorithm;
extern int HSH_GetHashId(HSH_Algorithm algorithm);
};
static struct hash hashes[] = {
+ { HSH_MD5_NONCRYPTO, GNUTLS_DIG_MD5, NULL },
{ HSH_MD5, GNUTLS_DIG_MD5, NULL },
{ HSH_SHA1, GNUTLS_DIG_SHA1, NULL },
{ HSH_SHA256, GNUTLS_DIG_SHA256, NULL },
if (hashes[id].handle)
return id;
+ if (algorithm == HSH_MD5_NONCRYPTO)
+ GNUTLS_FIPS140_SET_LAX_MODE();
+
r = gnutls_hash_init(&hashes[id].handle, hashes[id].type);
+
+ if (algorithm == HSH_MD5_NONCRYPTO)
+ GNUTLS_FIPS140_SET_STRICT_MODE();
+
if (r < 0) {
DEBUG_LOG("Could not initialise %s : %s", "hash", gnutls_strerror(r));
hashes[id].handle = NULL;
HSH_GetHashId(HSH_Algorithm algorithm)
{
/* only MD5 is supported */
- if (algorithm != HSH_MD5)
+ if (algorithm != HSH_MD5 && algorithm != HSH_MD5_NONCRYPTO)
return -1;
return 0;
{
int id, nid;
+ if (algorithm == HSH_MD5_NONCRYPTO)
+ algorithm = HSH_MD5;
+
for (id = 0; hashes[id].algorithm != 0; id++) {
if (hashes[id].algorithm == algorithm)
break;
{
int i;
+ if (algorithm == HSH_MD5_NONCRYPTO)
+ algorithm = HSH_MD5;
+
for (i = 0; hashes[i].algorithm != 0; i++) {
if (hashes[i].algorithm == algorithm)
break;
{
int i, h;
+ if (algorithm == HSH_MD5_NONCRYPTO)
+ algorithm = HSH_MD5;
+
for (i = 0; hashes[i].algorithm != 0; i++) {
if (hashes[i].algorithm == algorithm)
break;
unsigned char data2[] = "12345678910";
unsigned char out[MAX_HASH_LENGTH];
struct hash_test tests[] = {
+ { "MD5-NC", "\xfc\x24\x97\x1b\x52\x66\xdc\x46\xef\xe0\xe8\x08\x46\x89\xb6\x88", 16 },
{ "MD5", "\xfc\x24\x97\x1b\x52\x66\xdc\x46\xef\xe0\xe8\x08\x46\x89\xb6\x88", 16 },
{ "SHA1", "\xd8\x85\xb3\x86\xce\xea\x93\xeb\x92\xcd\x7b\x94\xb9\x8d\xc2\x8e"
"\x3e\x31\x13\xdd", 20},
for (i = 0; tests[i].name[0] != '\0'; i++) {
algorithm = UTI_HashNameToAlgorithm(tests[i].name);
- TEST_CHECK(algorithm != 0);
+ if (strcmp(tests[i].name, "MD5-NC") == 0) {
+ TEST_CHECK(algorithm == 0);
+ algorithm = HSH_MD5_NONCRYPTO;
+ } else {
+ TEST_CHECK(algorithm != 0);
+ }
hash_id = HSH_GetHashId(algorithm);
if (hash_id < 0) {
+ TEST_CHECK(algorithm != HSH_MD5_NONCRYPTO);
TEST_CHECK(algorithm != HSH_MD5);
#ifdef FEAT_SECHASH
TEST_CHECK(algorithm != HSH_SHA1);
return ip->addr.in4;
case IPADDR_INET6:
if (MD5_hash < 0)
- MD5_hash = HSH_GetHashId(HSH_MD5);
+ MD5_hash = HSH_GetHashId(HSH_MD5_NONCRYPTO);
if (MD5_hash < 0 ||
HSH_Hash(MD5_hash, (const unsigned char *)ip->addr.in6, sizeof (ip->addr.in6),