/*
* Copyright (C) 2000, 2001, 2004-2007, 2009, 2013-2018 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* $Id: hmacmd5.c,v 1.16 2009/02/06 23:47:42 tbox Exp $ */
/*! \file
* This code implements the HMAC-MD5 keyed hash algorithm
* described in RFC2104.
*/
#include "config.h"
#ifndef PK11_MD5_DISABLE
#include <isc/assertions.h>
#include <isc/platform.h>
#if PKCS11CRYPTO
#include <pk11/internal.h>
#endif
#ifdef ISC_PLATFORM_OPENSSLHASH
#endif
void
unsigned int len)
{
}
void
return;
}
void
unsigned int len)
{
}
void
}
#ifndef PK11_MD5_HMAC_REPLACE
void
unsigned int len)
{
{
};
#ifdef PK11_PAD_HMAC_KEYS
if (len < ISC_MD5_DIGESTLENGTH) {
} else
#else
#endif
}
void
return;
}
void
unsigned int len)
{
}
void
}
#else
/* Replace missing CKM_MD5_HMAC PKCS#11 mechanism */
void
unsigned int len)
{
unsigned int i;
} else
for (i = 0; i < PADLEN; i++)
}
void
}
void
unsigned int len)
{
}
void
unsigned int i;
(CK_ULONG_PTR) &len));
for (i = 0; i < PADLEN; i++)
(CK_ULONG_PTR) &len));
}
#endif
#else
/*!
* Start HMAC-MD5 process. Initialize an md5 context and digest the key.
*/
void
unsigned int len)
{
int i;
} else
for (i = 0; i < PADLEN; i++)
}
void
}
/*!
* Update context to reflect the concatenation of another buffer full
* of bytes.
*/
void
unsigned int len)
{
}
/*!
* Compute signature - finalize MD5 operation and reapply MD5.
*/
void
int i;
for (i = 0; i < PADLEN; i++)
}
#endif /* !ISC_PLATFORM_OPENSSLHASH */
/*!
* Verify signature - finalize MD5 operation and reapply MD5, then
* compare to the supplied digest.
*/
}
}
/*
* Check for MD5 support; if it does not work, raise a fatal error.
*
* Use the first test vector from RFC 2104, with a second round using
* a too-short key.
*
* Standard use is testing 0 and expecting result true.
* Testing use is testing 1..4 and expecting result false.
*/
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b
};
0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65
};
unsigned char expected[] = {
0x92, 0x94, 0x72, 0x7a, 0x36, 0x38, 0xbb, 0x1c,
0x13, 0xf4, 0x8e, 0xf8, 0x15, 0x8b, 0xfc, 0x9d
};
unsigned char expected2[] = {
0xad, 0xb8, 0x48, 0x05, 0xb8, 0x8d, 0x03, 0xe5,
0x90, 0x1e, 0x4b, 0x05, 0x69, 0xce, 0x35, 0xea
};
/*
* Introduce a fault for testing.
*/
switch (testing) {
case 0:
default:
break;
case 1:
key[0] ^= 0x01;
break;
case 2:
input[0] ^= 0x01;
break;
case 3:
expected[0] ^= 0x01;
break;
case 4:
expected2[0] ^= 0x01;
break;
}
/*
* These functions do not return anything; any failure will be fatal.
*/
if (!result) {
return (result);
}
/* Second round using a byte key */
}
#else /* !PK11_MD5_DISABLE */
#ifdef WIN32
/* Make the Visual Studio linker happy */
#endif
#endif /* PK11_MD5_DISABLE */