]> git.proxmox.com Git - mirror_frr.git/blob - lib/md5.h
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / lib / md5.h
1 // SPDX-License-Identifier: BSD-3-Clause
2 /*
3 * Copyright (C) 2004 6WIND
4 * <Vincent.Jardin@6WIND.com>
5 * All rights reserved.
6 *
7 * This MD5 code is Big endian and Little Endian compatible.
8 */
9
10 /*
11 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
12 * All rights reserved.
13 */
14
15 #ifndef _LIBZEBRA_MD5_H_
16 #define _LIBZEBRA_MD5_H_
17
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21
22 #define MD5_BUFLEN 64
23
24 typedef struct {
25 union {
26 uint32_t md5_state32[4];
27 uint8_t md5_state8[16];
28 } md5_st;
29
30 #define md5_sta md5_st.md5_state32[0]
31 #define md5_stb md5_st.md5_state32[1]
32 #define md5_stc md5_st.md5_state32[2]
33 #define md5_std md5_st.md5_state32[3]
34 #define md5_st8 md5_st.md5_state8
35
36 union {
37 uint64_t md5_count64;
38 uint8_t md5_count8[8];
39 } md5_count;
40 #define md5_n md5_count.md5_count64
41 #define md5_n8 md5_count.md5_count8
42
43 uint md5_i;
44 uint8_t md5_buf[MD5_BUFLEN];
45 } md5_ctxt;
46
47 extern void md5_init(md5_ctxt *);
48 extern void md5_loop(md5_ctxt *, const void *, unsigned int);
49 extern void md5_pad(md5_ctxt *);
50 extern void md5_result(uint8_t *, md5_ctxt *);
51
52 /* compatibility */
53 #define MD5_CTX md5_ctxt
54 #define MD5Init(x) md5_init((x))
55 #define MD5Update(x, y, z) md5_loop((x), (y), (z))
56 #define MD5Final(x, y) \
57 do { \
58 md5_pad((y)); \
59 md5_result((x), (y)); \
60 } while (0)
61
62 /* From RFC 2104 */
63 void hmac_md5(unsigned char *text, int text_len, unsigned char *key,
64 int key_len, uint8_t *digest);
65
66 #ifdef __cplusplus
67 }
68 #endif
69
70 #endif /* ! _LIBZEBRA_MD5_H_*/