The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
md4.h
Go to the documentation of this file.
1 #pragma once
2 /** Structures and prototypes for our local MD4 implementation
3  *
4  * @note license is LGPL, but largely derived from a public domain source.
5  *
6  * @file src/lib/util/md4.h
7  * @brief Structures and declarations for md4.
8  */
9 RCSIDH(md4_h, "$Id: 8ae9010f53065f9ecbd6a0a8a9d5311891538d52 $")
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 #include <freeradius-devel/build.h>
16 #include <freeradius-devel/missing.h>
17 
18 #include <inttypes.h>
19 #include <sys/types.h>
20 #include <stdint.h>
21 #include <stdbool.h>
22 #include <string.h>
23 
24 #ifndef MD4_DIGEST_LENGTH
25 # define MD4_DIGEST_LENGTH 16
26 #endif
27 
28 typedef void fr_md4_ctx_t;
29 
30 /* md4.c */
31 
32 /** Reset the ctx to allow reuse
33  *
34  * @param[in] ctx To reuse.
35  */
36 typedef void (*fr_md4_ctx_reset_t)(fr_md4_ctx_t *ctx);
38 
39 /** Copy the contents of a ctx
40  *
41  * @param[in] dst Where to copy the context to.
42  * @param[in] src Where to copy the context from.
43  */
44 typedef void (*fr_md4_ctx_copy_t)(fr_md4_ctx_t *dst, fr_md4_ctx_t const *src);
46 
47 /** Allocation function for MD4 digest context
48  *
49  * @return
50  * - An MD4 ctx.
51  * - NULL if out of memory.
52  */
53 typedef fr_md4_ctx_t *(*fr_md4_ctx_alloc_t)(void);
55 
56 /** Free function for MD4 digest ctx
57  *
58  * @param[in] ctx MD4 ctx to free. If the shared ctx is passed in
59  * then the ctx is reset but not freed.
60  */
61 typedef void (*fr_md4_ctx_free_t)(fr_md4_ctx_t **ctx);
63 
64 
65 /** Ingest plaintext into the digest
66  *
67  * @param[in] ctx To ingest data into.
68  * @param[in] in Data to ingest.
69  * @param[in] inlen Length of data to ingest.
70  */
71 typedef void (*fr_md4_update_t)(fr_md4_ctx_t *ctx, uint8_t const *in, size_t inlen);
73 
74 /** Finalise the ctx, producing the digest
75  *
76  * @param[out] out The MD4 digest.
77  * @param[in] ctx To finalise.
78  */
79 typedef void (*fr_md4_final_t)(uint8_t out[static MD4_DIGEST_LENGTH], fr_md4_ctx_t *ctx);
81 
82 /** Perform a single digest operation on a single input buffer
83  *
84  */
85 void fr_md4_calc(uint8_t out[static MD4_DIGEST_LENGTH], uint8_t const *in, size_t inlen);
86 
87 /** Allocate an md4 context from a free list
88  *
89  */
91 
92 /** Release an md4 context back to a free list
93  *
94  */
96 #ifdef __cplusplus
97 }
98 #endif
#define RCSIDH(h, id)
Definition: build.h:445
static fr_slen_t in
Definition: dict.h:645
fr_md4_ctx_t *(* fr_md4_ctx_alloc_t)(void)
Allocation function for MD4 digest context.
Definition: md4.h:53
void(* fr_md4_final_t)(uint8_t out[static MD4_DIGEST_LENGTH], fr_md4_ctx_t *ctx)
Finalise the ctx, producing the digest.
Definition: md4.h:79
fr_md4_ctx_alloc_t fr_md4_ctx_alloc
Definition: md4.c:478
fr_md4_update_t fr_md4_update
Definition: md4.c:480
void fr_md4_calc(uint8_t out[static MD4_DIGEST_LENGTH], uint8_t const *in, size_t inlen)
Perform a single digest operation on a single input buffer.
Definition: md4.c:489
fr_md4_ctx_reset_t fr_md4_ctx_reset
Definition: md4.c:476
fr_md4_ctx_copy_t fr_md4_ctx_copy
Definition: md4.c:477
fr_md4_final_t fr_md4_final
Definition: md4.c:481
fr_md4_ctx_t * fr_md4_ctx_alloc_from_list(void)
Allocate an md4 context from a free list.
Definition: md4.c:515
void(* fr_md4_ctx_free_t)(fr_md4_ctx_t **ctx)
Free function for MD4 digest ctx.
Definition: md4.h:61
void(* fr_md4_ctx_copy_t)(fr_md4_ctx_t *dst, fr_md4_ctx_t const *src)
Copy the contents of a ctx.
Definition: md4.h:44
#define MD4_DIGEST_LENGTH
Definition: md4.h:25
void(* fr_md4_ctx_reset_t)(fr_md4_ctx_t *ctx)
Reset the ctx to allow reuse.
Definition: md4.h:36
void fr_md4_ctx_t
Definition: md4.h:28
void fr_md4_ctx_free_from_list(fr_md4_ctx_t **ctx)
Release an md4 context back to a free list.
Definition: md4.c:560
void(* fr_md4_update_t)(fr_md4_ctx_t *ctx, uint8_t const *in, size_t inlen)
Ingest plaintext into the digest.
Definition: md4.h:71
fr_md4_ctx_free_t fr_md4_ctx_free
Definition: md4.c:479
unsigned char uint8_t
Definition: merged_model.c:30
static size_t char fr_sbuff_t size_t inlen
Definition: value.h:984
static size_t char ** out
Definition: value.h:984