The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
md4.c
Go to the documentation of this file.
1/** A local MD4 implementation
2 *
3 * @note license is LGPL, but largely derived from a public domain source.
4 *
5 * @file src/lib/util/md4.c
6 */
7RCSID("$Id: 041a5475b03843098de143e61cca8af5b7bab0e0 $")
8
9#include <freeradius-devel/util/debug.h>
10#include <freeradius-devel/util/strerror.h>
11#include <freeradius-devel/util/atexit.h>
12
13/*
14 * FORCE MD4 TO USE OUR MD4 HEADER FILE!
15 * If we don't do this, it might pick up the systems broken MD4.
16 */
17#include <freeradius-devel/util/md4.h>
18
19/** The thread local free list
20 *
21 * Any entries remaining in the list will be freed when the thread is joined
22 */
23#define ARRAY_SIZE (8)
24typedef struct {
25 bool used;
28static _Thread_local fr_md4_free_list_t *md4_array;
29
30static void fr_md4_local_ctx_reset(fr_md4_ctx_t *ctx);
31static void fr_md4_local_ctx_copy(fr_md4_ctx_t *dst, fr_md4_ctx_t const *src);
33static void fr_md4_local_ctx_free(fr_md4_ctx_t **ctx);
34static void fr_md4_local_update(fr_md4_ctx_t *ctx, uint8_t const *in, size_t inlen);
36
46
47/*
48 * If we have OpenSSL's EVP API available, then build wrapper functions.
49 *
50 * We always need to build the local MD4 functions as OpenSSL could
51 * be operating in FIPS mode where MD4 digest functions are unavailable.
52 */
53#ifdef HAVE_OPENSSL_EVP_H
54# include <freeradius-devel/tls/openssl_user_macros.h>
55# include <openssl/evp.h>
56# include <openssl/crypto.h>
57# include <openssl/err.h>
58# include <openssl/provider.h>
59
60/** @copydoc fr_md4_ctx_reset
61 *
62 */
63static void fr_md4_openssl_ctx_reset(fr_md4_ctx_t *ctx)
64{
65 EVP_MD_CTX *md_ctx = ctx;
66
67 EVP_MD_CTX_reset(md_ctx);
68 EVP_DigestInit_ex(md_ctx, EVP_md4(), NULL);
69}
70
71/** @copydoc fr_md4_ctx_copy
72 *
73 */
74static void fr_md4_openssl_ctx_copy(fr_md4_ctx_t *dst, fr_md4_ctx_t const *src)
75{
76 EVP_MD_CTX_copy_ex(dst, src);
77}
78
79/** @copydoc fr_md4_ctx_alloc
80 *
81 */
82static fr_md4_ctx_t *fr_md4_openssl_ctx_alloc(void)
83{
84 EVP_MD_CTX *md_ctx;
85
86 md_ctx = EVP_MD_CTX_new();
87 if (unlikely(!md_ctx)) return NULL;
88
89 if (EVP_DigestInit_ex(md_ctx, EVP_md4(), NULL) != 1) {
90 char buffer[256];
91
92 ERR_error_string_n(ERR_get_error(), buffer, sizeof(buffer));
93 fr_strerror_printf("Failed initialising md4 ctx: %s", buffer);
94 EVP_MD_CTX_free(md_ctx);
95
96 return NULL;
97 }
98
99 return md_ctx;
100}
101
102/** @copydoc fr_md4_ctx_free
103 *
104 */
105static void fr_md4_openssl_ctx_free(fr_md4_ctx_t **ctx)
106{
107 EVP_MD_CTX_free(*ctx);
108 *ctx = NULL;
109}
110
111/** @copydoc fr_md4_update
112 *
113 */
114static void fr_md4_openssl_update(fr_md4_ctx_t *ctx, uint8_t const *in, size_t inlen)
115{
116 EVP_DigestUpdate(ctx, in, inlen);
117}
118
119/** @copydoc fr_md4_final
120 *
121 */
122static void fr_md4_openssl_final(uint8_t out[static MD4_DIGEST_LENGTH], fr_md4_ctx_t *ctx)
123{
124 unsigned int len;
125
126 EVP_DigestFinal(ctx, out, &len);
127
128 if (!fr_cond_assert(len == MD4_DIGEST_LENGTH)) return;
129}
130
131static fr_md4_funcs_t md4_openssl_funcs = {
132 .reset = fr_md4_openssl_ctx_reset,
133 .copy = fr_md4_openssl_ctx_copy,
134 .alloc = fr_md4_openssl_ctx_alloc,
135 .free = fr_md4_openssl_ctx_free,
136 .update = fr_md4_openssl_update,
137 .final = fr_md4_openssl_final
138};
139#endif
140
141/*
142 * This code implements the MD4 message-digest algorithm.
143 * The algorithm is due to Ron Rivest. This code was
144 * written by Colin Plumb in 1993, no copyright is claimed.
145 * This code is in the public domain; do with it what you wish.
146 * Todd C. Miller modified the md4 code to do MD4 based on RFC 1186.
147 *
148 * Equivalent code is available from RSA Data Security, Inc.
149 * This code has been tested against that, and is equivalent,
150 * except that you don't need to include two pages of legalese
151 * with every copy.
152 *
153 * To compute the message digest of a chunk of bytes, declare an
154 * MD4Context structure, pass it to fr_md4_init, call fr_md4_update as
155 * needed on buffers full of bytes, and then call fr_md4_final, which
156 * will fill a supplied 16-byte array with the digest.
157 */
158#ifndef WORDS_BIGENDIAN
159# define htole32_4(buf) /* Nothing */
160# define htole32_14(buf) /* Nothing */
161# define htole32_16(buf) /* Nothing */
162#else
163/* Sometimes defined by endian.h */
164# ifndef htole32
165# define htole32(x)\
166 (((((uint32_t)x) & 0xff000000) >> 24) |\
167 ((((uint32_t)x) & 0x00ff0000) >> 8) |\
168 ((((uint32_t)x) & 0x0000ff00) << 8) |\
169 ((((uint32_t)x) & 0x000000ff) << 24))
170# endif
171# define htole32_4(buf) do {\
172 (buf)[0] = htole32((buf)[0]);\
173 (buf)[1] = htole32((buf)[1]);\
174 (buf)[2] = htole32((buf)[2]);\
175 (buf)[3] = htole32((buf)[3]);\
176} while (0)
177
178# define htole32_14(buf) do {\
179 (buf)[0] = htole32((buf)[0]);\
180 (buf)[1] = htole32((buf)[1]);\
181 (buf)[2] = htole32((buf)[2]);\
182 (buf)[3] = htole32((buf)[3]);\
183 (buf)[4] = htole32((buf)[4]);\
184 (buf)[5] = htole32((buf)[5]);\
185 (buf)[6] = htole32((buf)[6]);\
186 (buf)[7] = htole32((buf)[7]);\
187 (buf)[8] = htole32((buf)[8]);\
188 (buf)[9] = htole32((buf)[9]);\
189 (buf)[10] = htole32((buf)[10]);\
190 (buf)[11] = htole32((buf)[11]);\
191 (buf)[12] = htole32((buf)[12]);\
192 (buf)[13] = htole32((buf)[13]);\
193} while (0)
194
195# define htole32_16(buf) do {\
196 (buf)[0] = htole32((buf)[0]);\
197 (buf)[1] = htole32((buf)[1]);\
198 (buf)[2] = htole32((buf)[2]);\
199 (buf)[3] = htole32((buf)[3]);\
200 (buf)[4] = htole32((buf)[4]);\
201 (buf)[5] = htole32((buf)[5]);\
202 (buf)[6] = htole32((buf)[6]);\
203 (buf)[7] = htole32((buf)[7]);\
204 (buf)[8] = htole32((buf)[8]);\
205 (buf)[9] = htole32((buf)[9]);\
206 (buf)[10] = htole32((buf)[10]);\
207 (buf)[11] = htole32((buf)[11]);\
208 (buf)[12] = htole32((buf)[12]);\
209 (buf)[13] = htole32((buf)[13]);\
210 (buf)[14] = htole32((buf)[14]);\
211 (buf)[15] = htole32((buf)[15]);\
212} while (0)
213#endif
214
215#define MD4_BLOCK_LENGTH 64
216
217/* The three core functions - F1 is optimized somewhat */
218#define MD4_F1(x, y, z) (z ^ (x & (y ^ z)))
219#define MD4_F2(x, y, z) ((x & y) | (x & z) | (y & z))
220#define MD4_F3(x, y, z) (x ^ y ^ z)
221
222/* This is the central step in the MD4 algorithm. */
223#define MD4STEP(f, w, x, y, z, data, s) (w += f(x, y, z) + data, w = w << s | w >> (32 - s))
224
225/** The core of the MD4 algorithm
226 *
227 * This alters an existing MD4 hash to reflect the addition of 16
228 * longwords of new data. fr_md4_update blocks the data and converts bytes
229 * into longwords for this routine.
230 *
231 * @param[in] state 16 bytes of data to feed into the hashing function.
232 * @param[in,out] block MD4 digest block to update.
233 */
234static void fr_md4_local_transform(uint32_t state[static 4], uint8_t const block[static MD4_BLOCK_LENGTH])
235{
236 uint32_t a, b, c, d;
237 uint32_t const *in = (uint32_t const *)block;
238
239 a = state[0];
240 b = state[1];
241 c = state[2];
242 d = state[3];
243
244 MD4STEP(MD4_F1, a, b, c, d, in[ 0], 3);
245 MD4STEP(MD4_F1, d, a, b, c, in[ 1], 7);
246 MD4STEP(MD4_F1, c, d, a, b, in[ 2], 11);
247 MD4STEP(MD4_F1, b, c, d, a, in[ 3], 19);
248 MD4STEP(MD4_F1, a, b, c, d, in[ 4], 3);
249 MD4STEP(MD4_F1, d, a, b, c, in[ 5], 7);
250 MD4STEP(MD4_F1, c, d, a, b, in[ 6], 11);
251 MD4STEP(MD4_F1, b, c, d, a, in[ 7], 19);
252 MD4STEP(MD4_F1, a, b, c, d, in[ 8], 3);
253 MD4STEP(MD4_F1, d, a, b, c, in[ 9], 7);
254 MD4STEP(MD4_F1, c, d, a, b, in[10], 11);
255 MD4STEP(MD4_F1, b, c, d, a, in[11], 19);
256 MD4STEP(MD4_F1, a, b, c, d, in[12], 3);
257 MD4STEP(MD4_F1, d, a, b, c, in[13], 7);
258 MD4STEP(MD4_F1, c, d, a, b, in[14], 11);
259 MD4STEP(MD4_F1, b, c, d, a, in[15], 19);
260
261 MD4STEP(MD4_F2, a, b, c, d, in[ 0] + 0x5a827999, 3);
262 MD4STEP(MD4_F2, d, a, b, c, in[ 4] + 0x5a827999, 5);
263 MD4STEP(MD4_F2, c, d, a, b, in[ 8] + 0x5a827999, 9);
264 MD4STEP(MD4_F2, b, c, d, a, in[12] + 0x5a827999, 13);
265 MD4STEP(MD4_F2, a, b, c, d, in[ 1] + 0x5a827999, 3);
266 MD4STEP(MD4_F2, d, a, b, c, in[ 5] + 0x5a827999, 5);
267 MD4STEP(MD4_F2, c, d, a, b, in[ 9] + 0x5a827999, 9);
268 MD4STEP(MD4_F2, b, c, d, a, in[13] + 0x5a827999, 13);
269 MD4STEP(MD4_F2, a, b, c, d, in[ 2] + 0x5a827999, 3);
270 MD4STEP(MD4_F2, d, a, b, c, in[ 6] + 0x5a827999, 5);
271 MD4STEP(MD4_F2, c, d, a, b, in[10] + 0x5a827999, 9);
272 MD4STEP(MD4_F2, b, c, d, a, in[14] + 0x5a827999, 13);
273 MD4STEP(MD4_F2, a, b, c, d, in[ 3] + 0x5a827999, 3);
274 MD4STEP(MD4_F2, d, a, b, c, in[ 7] + 0x5a827999, 5);
275 MD4STEP(MD4_F2, c, d, a, b, in[11] + 0x5a827999, 9);
276 MD4STEP(MD4_F2, b, c, d, a, in[15] + 0x5a827999, 13);
277
278 MD4STEP(MD4_F3, a, b, c, d, in[ 0] + 0x6ed9eba1, 3);
279 MD4STEP(MD4_F3, d, a, b, c, in[ 8] + 0x6ed9eba1, 9);
280 MD4STEP(MD4_F3, c, d, a, b, in[ 4] + 0x6ed9eba1, 11);
281 MD4STEP(MD4_F3, b, c, d, a, in[12] + 0x6ed9eba1, 15);
282 MD4STEP(MD4_F3, a, b, c, d, in[ 2] + 0x6ed9eba1, 3);
283 MD4STEP(MD4_F3, d, a, b, c, in[10] + 0x6ed9eba1, 9);
284 MD4STEP(MD4_F3, c, d, a, b, in[ 6] + 0x6ed9eba1, 11);
285 MD4STEP(MD4_F3, b, c, d, a, in[14] + 0x6ed9eba1, 15);
286 MD4STEP(MD4_F3, a, b, c, d, in[ 1] + 0x6ed9eba1, 3);
287 MD4STEP(MD4_F3, d, a, b, c, in[ 9] + 0x6ed9eba1, 9);
288 MD4STEP(MD4_F3, c, d, a, b, in[ 5] + 0x6ed9eba1, 11);
289 MD4STEP(MD4_F3, b, c, d, a, in[13] + 0x6ed9eba1, 15);
290 MD4STEP(MD4_F3, a, b, c, d, in[ 3] + 0x6ed9eba1, 3);
291 MD4STEP(MD4_F3, d, a, b, c, in[11] + 0x6ed9eba1, 9);
292 MD4STEP(MD4_F3, c, d, a, b, in[ 7] + 0x6ed9eba1, 11);
293 MD4STEP(MD4_F3, b, c, d, a, in[15] + 0x6ed9eba1, 15);
294
295 state[0] += a;
296 state[1] += b;
297 state[2] += c;
298 state[3] += d;
299}
300
301typedef struct {
302 uint32_t state[4]; //!< State.
303 uint32_t count[2]; //!< Number of bits, mod 2^64.
304 uint8_t buffer[MD4_BLOCK_LENGTH]; //!< Input buffer.
306
307/** @copydoc fr_md4_ctx_reset
308 *
309 */
311{
312 fr_md4_ctx_local_t *ctx_local = talloc_get_type_abort(ctx, fr_md4_ctx_local_t);
313
314 ctx_local->count[0] = 0;
315 ctx_local->count[1] = 0;
316 ctx_local->state[0] = 0x67452301;
317 ctx_local->state[1] = 0xefcdab89;
318 ctx_local->state[2] = 0x98badcfe;
319 ctx_local->state[3] = 0x10325476;
320}
321
322/** @copydoc fr_md4_ctx_copy
323 *
324 */
326{
328 fr_md4_ctx_local_t *ctx_local_dst = talloc_get_type_abort(dst, fr_md4_ctx_local_t);
329
330 memcpy(ctx_local_dst, ctx_local_src, sizeof(*ctx_local_dst));
331}
332
333/** @copydoc fr_md4_ctx_alloc
334 *
335 */
337{
338 fr_md4_ctx_local_t *ctx_local;
339
340 ctx_local = talloc(NULL, fr_md4_ctx_local_t);
341 if (unlikely(!ctx_local)) return NULL;
342 fr_md4_local_ctx_reset(ctx_local);
343
344 return ctx_local;
345}
346
347
348/** @copydoc fr_md4_ctx_free
349 *
350 */
352{
353 talloc_free(*ctx);
354 *ctx = NULL;
355}
356
357static const uint8_t *zero = (uint8_t[]){ 0x00 };
358
359/** @copydoc fr_md4_update
360 *
361 */
362static void fr_md4_local_update(fr_md4_ctx_t *ctx, uint8_t const *in, size_t inlen)
363{
365 fr_md4_ctx_local_t *ctx_local = talloc_get_type_abort(ctx, fr_md4_ctx_local_t);
366
367 /*
368 * Needed so we can calculate the zero
369 * length md4 hash correctly.
370 * ubsan doesn't like arithmetic on
371 * NULL pointers.
372 */
373 if (!in) {
374 in = zero;
375 inlen = 0;
376 }
377
378 /* Bytes already stored in ctx_local->buffer */
379 count = (uint32_t)((ctx_local->count[0] >> 3) & 0x3f);
380
381 /* Update bitcount */
382/* ctx_local->count += (uint64_t)inlen << 3;*/
383 if ((ctx_local->count[0] += ((uint32_t)inlen << 3)) < (uint32_t)inlen) {
384 /* Overflowed ctx_local->count[0] */
385 ctx_local->count[1]++;
386 }
387 ctx_local->count[1] += ((uint32_t)inlen >> 29);
388
389 /* Handle any leading odd-sized chunks */
390 if (count) {
391 unsigned char *p = (unsigned char *)ctx_local->buffer + count;
392
394 if (inlen < count) {
395 memcpy(p, in, inlen);
396 return;
397 }
398 memcpy(p, in, count);
399 htole32_16((uint32_t *)ctx_local->buffer);
400 fr_md4_local_transform(ctx_local->state, ctx_local->buffer);
401 in += count;
402 inlen -= count;
403 }
404
405 /* Process data in MD4_BLOCK_LENGTH-byte chunks */
406 while (inlen >= MD4_BLOCK_LENGTH) {
407 memcpy(ctx_local->buffer, in, MD4_BLOCK_LENGTH);
408 htole32_16((uint32_t *)ctx_local->buffer);
409 fr_md4_local_transform(ctx_local->state, ctx_local->buffer);
412 }
413
414 /* Handle any remaining bytes of data. */
415 memcpy(ctx_local->buffer, in, inlen);
416}
417
418/** @copydoc fr_md4_final
419 *
420 */
422{
424 unsigned char *p;
425 fr_md4_ctx_local_t *ctx_local = talloc_get_type_abort(ctx, fr_md4_ctx_local_t);
426
427 /* number of bytes mod 64 */
428 count = (uint32_t)(ctx_local->count[0] >> 3) & 0x3f;
429
430 /*
431 * Set the first char of padding to 0x80.
432 * This is safe since there is always at least one byte free.
433 */
434 p = ctx_local->buffer + count;
435 *p++ = 0x80;
436
437 /* Bytes of padding needed to make 64 bytes */
438 count = 64 - 1 - count;
439
440 /* Pad out to 56 mod 64 */
441 if (count < 8) {
442 /* Two lots of padding: Pad the first block to 64 bytes */
443 memset(p, 0, count);
444 htole32_16((uint32_t *)ctx_local->buffer);
445 fr_md4_local_transform(ctx_local->state, ctx_local->buffer);
446
447 /* Now fill the next block with 56 bytes */
448 memset(ctx_local->buffer, 0, 56);
449 } else {
450 /* Pad block to 56 bytes */
451 memset(p, 0, count - 8);
452 }
453 htole32_14((uint32_t *)ctx_local->buffer);
454
455 /* Append bit count and transform */
456 ((uint32_t *)ctx_local->buffer)[14] = ctx_local->count[0];
457 ((uint32_t *)ctx_local->buffer)[15] = ctx_local->count[1];
458
459 fr_md4_local_transform(ctx_local->state, ctx_local->buffer);
460 htole32_4(ctx_local->state);
461 memcpy(out, ctx_local->state, MD4_DIGEST_LENGTH);
462 memset(ctx_local, 0, sizeof(*ctx_local)); /* in case it's sensitive */
463}
464
465/** Calculate the MD4 hash of the contents of a buffer
466 *
467 * @param[out] out Where to write the MD4 digest. Must be a minimum of MD4_DIGEST_LENGTH.
468 * @param[in] in Data to hash.
469 * @param[in] inlen Length of the data.
470 */
472{
473 fr_md4_ctx_t *ctx;
474
476 fr_md4_update(ctx, in, inlen);
477 fr_md4_final(out, ctx);
479}
480
481static int _md4_ctx_free_on_exit(void *arg)
482{
483 int i;
484 fr_md4_free_list_t *free_list = arg;
485
486 for (i = 0; i < ARRAY_SIZE; i++) {
487 if (free_list[i].used) continue;
488
489 fr_md4_ctx_free(&free_list[i].md_ctx);
490 }
491 return talloc_free(free_list);
492}
493
494/** @copydoc fr_md4_ctx_alloc
495 *
496 */
498{
499 int i;
500 fr_md4_ctx_t *md_ctx;
501 fr_md4_free_list_t *free_list;
502
503 if (unlikely(!md4_array)) {
504 free_list = talloc_zero_array(NULL, fr_md4_free_list_t, ARRAY_SIZE);
505 if (unlikely(!free_list)) {
506 oom:
507 fr_strerror_const("Out of Memory");
508 return NULL;
509 }
510
512
513 /*
514 * Initialize all md4 contexts
515 */
516 for (i = 0; i < ARRAY_SIZE; i++) {
517 md_ctx = fr_md4_ctx_alloc();
518 if (unlikely(md_ctx == NULL)) goto oom;
519
520 free_list[i].md_ctx = md_ctx;
521 }
522 } else {
523 free_list = md4_array;
524 }
525
526 for (i = 0; i < ARRAY_SIZE; i++) {
527 if (free_list[i].used) continue;
528
529 free_list[i].used = true;
530 return free_list[i].md_ctx;
531 }
532
533 /*
534 * No more free contexts, just allocate a new one.
535 */
536 return fr_md4_ctx_alloc();
537}
538
539/** @copydoc fr_md4_ctx_free
540 *
541 */
543{
544 int i;
545 fr_md4_free_list_t *free_list = md4_array;
546
547 if (free_list) {
548 for (i = 0; i < ARRAY_SIZE; i++) {
549 if (free_list[i].md_ctx == *ctx) {
550 free_list[i].used = false;
551 fr_md4_ctx_reset(*ctx);
552 *ctx = NULL;
553 return;
554 }
555 }
556 }
557
558 fr_md4_ctx_free(*ctx);
559 *ctx = NULL;
560}
561
562#ifdef HAVE_OPENSSL_EVP_H
563void fr_md4_openssl_init(void)
564{
565 /*
566 * If we are in FIPS mode, then we still use the local
567 * allocator.
568 */
569 if (!EVP_default_properties_is_fips_enabled(NULL)) return;
570
571 /*
572 * OpenSSL isn't in FIPS mode. Swap out the functions
573 * pointers for the OpenSSL versions.
574 *
575 * We do this by swapping out a pointer to a structure
576 * containing the functions, as this prevents possible
577 * skew where some threads see a mixture of functions.
578 */
579 fr_md4_funcs = &md4_openssl_funcs;
580}
581
582void fr_md4_openssl_free(void)
583{
585}
586#endif
static int const char char buffer[256]
Definition acutest.h:578
#define fr_atexit_thread_local(_name, _free, _uctx)
Definition atexit.h:221
#define RCSID(id)
Definition build.h:485
#define unlikely(_x)
Definition build.h:383
#define fr_cond_assert(_x)
Calls panic_action ifndef NDEBUG, else logs error and evaluates to value of _x.
Definition debug.h:131
static fr_slen_t in
Definition dict.h:887
talloc_free(reap)
uint8_t buffer[MD4_BLOCK_LENGTH]
Input buffer.
Definition md4.c:304
static int _md4_ctx_free_on_exit(void *arg)
Definition md4.c:481
static void fr_md4_local_transform(uint32_t state[static 4], uint8_t const block[static MD4_BLOCK_LENGTH])
The core of the MD4 algorithm.
Definition md4.c:234
#define MD4_F1(x, y, z)
Definition md4.c:218
uint32_t state[4]
State.
Definition md4.c:302
#define MD4STEP(f, w, x, y, z, data, s)
Definition md4.c:223
#define htole32_16(buf)
Definition md4.c:161
#define htole32_4(buf)
Definition md4.c:159
#define MD4_F3(x, y, z)
Definition md4.c:220
static void fr_md4_local_ctx_free(fr_md4_ctx_t **ctx)
Free function for MD4 digest ctx.
Definition md4.c:351
#define ARRAY_SIZE
The thread local free list.
Definition md4.c:23
void fr_md4_calc(uint8_t out[static MD4_DIGEST_LENGTH], uint8_t const *in, size_t inlen)
Calculate the MD4 hash of the contents of a buffer.
Definition md4.c:471
static fr_md4_ctx_t * fr_md4_local_ctx_alloc(void)
Allocation function for MD4 digest context.
Definition md4.c:336
fr_md4_ctx_t * fr_md4_ctx_alloc_from_list(void)
Allocation function for MD4 digest context.
Definition md4.c:497
uint32_t count[2]
Number of bits, mod 2^64.
Definition md4.c:303
static void fr_md4_local_update(fr_md4_ctx_t *ctx, uint8_t const *in, size_t inlen)
Ingest plaintext into the digest.
Definition md4.c:362
#define htole32_14(buf)
Definition md4.c:160
#define MD4_F2(x, y, z)
Definition md4.c:219
static _Thread_local fr_md4_free_list_t * md4_array
Definition md4.c:28
static void fr_md4_local_ctx_copy(fr_md4_ctx_t *dst, fr_md4_ctx_t const *src)
Copy the contents of a ctx.
Definition md4.c:325
static void fr_md4_local_final(uint8_t out[static MD4_DIGEST_LENGTH], fr_md4_ctx_t *ctx)
Finalise the ctx, producing the digest.
Definition md4.c:421
static fr_md4_funcs_t md4_local_funcs
Definition md4.c:37
fr_md4_ctx_t * md_ctx
Definition md4.c:26
void fr_md4_ctx_free_from_list(fr_md4_ctx_t **ctx)
Free function for MD4 digest ctx.
Definition md4.c:542
#define MD4_BLOCK_LENGTH
Definition md4.c:215
fr_md4_funcs_t const * fr_md4_funcs
Swap a single pointer, so all functions get swapped as an atomic operation.
Definition md4.c:45
static void fr_md4_local_ctx_reset(fr_md4_ctx_t *ctx)
Reset the ctx to allow reuse.
Definition md4.c:310
static const uint8_t * zero
Definition md4.c:357
fr_md4_ctx_reset_t reset
Definition md4.h:40
#define fr_md4_ctx_reset(_ctx)
Reset the ctx to allow reuse.
Definition md4.h:56
#define fr_md4_ctx_alloc()
Allocation function for MD4 digest context.
Definition md4.h:71
#define fr_md4_final(_out, _ctx)
Finalise the ctx, producing the digest.
Definition md4.h:93
#define MD4_DIGEST_LENGTH
Definition md4.h:25
void fr_md4_ctx_t
Definition md4.h:28
#define fr_md4_ctx_free(_ctx)
Free function for MD4 digest ctx.
Definition md4.h:78
#define fr_md4_update(_ctx, _in, _inlen)
Ingest plaintext into the digest.
Definition md4.h:86
unsigned int uint32_t
unsigned char uint8_t
static size_t used
return count
Definition module.c:155
#define talloc_get_type_abort_const
Definition talloc.h:244
#define fr_strerror_printf(_fmt,...)
Log to thread local error buffer.
Definition strerror.h:64
#define fr_strerror_const(_msg)
Definition strerror.h:223
static size_t char fr_sbuff_t size_t inlen
Definition value.h:1023
static size_t char ** out
Definition value.h:1023