Debian Codegraph @

deps/libneon/src/ne_md5.h

raw
1 /* Declaration of functions and data types used for MD5 sum computing
2 library functions.
3 Copyright (C) 2006, Joe Orton <[email protected]>
4 Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
5 This file is part of the GNU C Library.
6
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public License as
9 published by the Free Software Foundation; either version 2 of the
10 License, or (at your option) any later version.
11
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public
18 License along with the GNU C Library; see the file COPYING.LIB. If not,
19 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22 #ifndef NE_MD5_H
23 #define NE_MD5_H 1
24
25 #include <stdio.h>
26
27 #include "ne_defs.h"
28
29 NE_BEGIN_DECLS
30
31 /*
32 * The following three functions are build up the low level used in
33 * the functions `md5_stream' and `md5_buffer'.
34 */
35 struct ne_md5_ctx;
36
37 /* Create structure containing state of computation. */
38 extern struct ne_md5_ctx *ne_md5_create_ctx(void);
39
40 /* Starting with the result of former calls of this function (or the
41 initialization function update the context for the next LEN bytes
42 starting at BUFFER.
43 It is necessary that LEN is a multiple of 64!!! */
44 extern void ne_md5_process_block(const void *buffer, size_t len,
45 struct ne_md5_ctx *ctx);
46
47 /* Starting with the result of former calls of this function (or the
48 initialization function update the context for the next LEN bytes
49 starting at BUFFER.
50 It is NOT required that LEN is a multiple of 64. */
51 extern void ne_md5_process_bytes(const void *buffer, size_t len,
52 struct ne_md5_ctx *ctx);
53
54 /* Process the remaining bytes in the buffer and put result from CTX
55 in first 16 bytes following RESBUF. The result is always in little
56 endian byte order, so that a byte-wise output yields to the wanted
57 ASCII representation of the message digest.
58
59 IMPORTANT: On some systems it is required that RESBUF is correctly
60 aligned for a 32 bits value. */
61 extern void *ne_md5_finish_ctx(struct ne_md5_ctx *ctx, void *resbuf);
62
63
64 /* Put result from CTX in first 16 bytes following RESBUF. The result is
65 always in little endian byte order, so that a byte-wise output yields
66 to the wanted ASCII representation of the message digest.
67
68 IMPORTANT: On some systems it is required that RESBUF is correctly
69 aligned for a 32 bits value. */
70 extern void *ne_md5_read_ctx(const struct ne_md5_ctx *ctx, void *resbuf);
71
72 /* Take a copy of the state structure. */
73 extern struct ne_md5_ctx *ne_md5_dup_ctx(struct ne_md5_ctx *ctx);
74
75 /* Re-initialize the context structure. */
76 extern void ne_md5_reset_ctx(struct ne_md5_ctx *ctx);
77
78 /* Destroy the context structure. */
79 extern void ne_md5_destroy_ctx(struct ne_md5_ctx *ctx);
80
81 /* Compute MD5 message digest for bytes read from STREAM. The
82 resulting message digest number will be written into the 16 bytes
83 beginning at RESBLOCK. */
84 extern int ne_md5_stream(FILE *stream, void *resblock);
85
86 /* Process the remaining bytes in the buffer and put ASCII
87 representation of the resulting message digest from CTX in the
88 first 33 bytes of BUFFER, including a trailing NUL terminator
89 byte. Returns pointer to buffer. */
90 char *ne_md5_finish_ascii(struct ne_md5_ctx *ctx, char buffer[33]);
91
92 /* MD5 ascii->binary conversion */
93 void ne_md5_to_ascii(const unsigned char md5_buf[16], char *buffer);
94 void ne_ascii_to_md5(const char *buffer, unsigned char md5_buf[16]);
95
96 NE_END_DECLS
97
98 #endif /* NE_MD5_H */