Radcli library 1.5.3
A simple radius library
Loading...
Searching...
No Matches
rc-md5.c
1/* MD5 message-digest algorithm */
2
3/* This file is licensed under the BSD License, but is largely derived from
4 * public domain source code
5 */
6
7/*
8 * FORCE MD5 TO USE OUR MD5 HEADER FILE!
9 *
10 * If we don't do this, it might pick up the systems broken MD5.
11 */
12#include "rc-md5.h"
13
14/*- Hash the provided data using MD5
15 *
16 * @param[out] output will hold a 16-byte checksum.
17 * @param[in] input pointer to data to hash.
18 * @param[in] inlen the length of input.
19 -*/
20void rc_md5_calc(unsigned char *output, unsigned char const *input,
21 size_t inlen)
22{
23 MD5_CTX context;
24
25#ifdef HAVE_NETTLE
26 md5_init(&context);
27 md5_update(&context, inlen, input);
28#ifdef HAVE_DIGEST_LENGTH_ARG
29 md5_digest(&context, MD5_DIGEST_SIZE, output);
30#else
31 md5_digest(&context, output);
32#endif
33#else
34 MD5Init(&context);
35 MD5Update(&context, input, inlen);
36 MD5Final(output, &context);
37#endif
38}
39