Dibbler - a portable DHCPv6  1.0.2RC1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Misc/md5.h
Go to the documentation of this file.
1 /* Declaration of functions and data types used for MD5 sum computing
2  library functions.
3  Copyright (C) 1995-1997,1999,2000,2001,2004,2005,2006
4  Free Software Foundation, Inc.
5  This file is part of the GNU C Library.
6 
7  This program is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2, or (at your option) any
10  later version.
11 
12  This program 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
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software Foundation,
19  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
20 
21 /* This file is taken from coreutils-6.2 (lib/md5.h) and adapted for dibbler
22  * by Michal Kowalczuk <michal@kowalczuk.eu> */
23 
24 #ifndef _MD5_H
25 #define _MD5_H 1
26 
27 #include <stdio.h>
28 #include <stdint.h>
29 
30 #define MD5_BLOCKSIZE 64
31 #define MD5_DIGESTSIZE 16
32 
33 #ifndef __GNUC_PREREQ
34 # if defined __GNUC__ && defined __GNUC_MINOR__
35 # define __GNUC_PREREQ(maj, min) \
36  ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
37 # else
38 # define __GNUC_PREREQ(maj, min) 0
39 # endif
40 #endif
41 
42 #ifndef __THROW
43 # if defined __cplusplus && __GNUC_PREREQ (2,8)
44 # define __THROW throw ()
45 # else
46 # define __THROW
47 # endif
48 #endif
49 
50 #ifndef _LIBC
51 # define __md5_buffer md5_buffer
52 # define __md5_finish_ctx md5_finish_ctx
53 # define __md5_init_ctx md5_init_ctx
54 # define __md5_process_block md5_process_block
55 # define __md5_process_bytes md5_process_bytes
56 # define __md5_read_ctx md5_read_ctx
57 #endif
58 
59 /* Structure to save state of computation between the single steps. */
60 struct md5_ctx
61 {
66 
70 };
71 
72 /* Initialize structure containing state of computation.
73  (RFC 1321, 3.3: Step 3) */
74 extern void __md5_init_ctx (struct md5_ctx *ctx) __THROW;
75 
76 /* Starting with the result of former calls of this function (or the
77  initialization function update the context for the next LEN bytes
78  starting at BUFFER.
79  It is necessary that LEN is a multiple of 64!!! */
80 extern void __md5_process_block (const void *buffer, size_t len,
81  struct md5_ctx *ctx) __THROW;
82 
83 /* Starting with the result of former calls of this function (or the
84  initialization function update the context for the next LEN bytes
85  starting at BUFFER.
86  It is NOT required that LEN is a multiple of 64. */
87 extern void __md5_process_bytes (const void *buffer, size_t len,
88  struct md5_ctx *ctx) __THROW;
89 
90 /* Process the remaining bytes in the buffer and put result from CTX
91  in first 16 bytes following RESBUF. The result is always in little
92  endian byte order, so that a byte-wise output yields to the wanted
93  ASCII representation of the message digest.
94 
95  IMPORTANT: On some systems, RESBUF must be aligned to a 32-bit
96  boundary. */
97 extern void *__md5_finish_ctx (struct md5_ctx *ctx, void *resbuf) __THROW;
98 
99 
100 /* Put result from CTX in first 16 bytes following RESBUF. The result is
101  always in little endian byte order, so that a byte-wise output yields
102  to the wanted ASCII representation of the message digest.
103 
104  IMPORTANT: On some systems, RESBUF must be aligned to a 32-bit
105  boundary. */
106 extern void *__md5_read_ctx (const struct md5_ctx *ctx, void *resbuf) __THROW;
107 
108 
109 #endif /* md5.h */
110