/ [pam-modules] / trunk / pam_sql / md5.h
To checkout: svn checkout http://svn.gnu.org.ua/sources/pam-modules/trunk/pam_sql/md5.h
Puszcza

Contents of /trunk/pam_sql/md5.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 61 - (show annotations)
Mon Aug 27 22:38:35 2007 UTC (14 years, 5 months ago) by gray
File MIME type: text/plain
File size: 4194 byte(s)
Lots of fixes in pam_mysql
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 #ifndef _MD5_H
22 #define _MD5_H 1
23
24 #include <stdio.h>
25 #include <stdint.h>
26
27 #define MD5_DIGEST_SIZE 16
28 #define MD5_BLOCK_SIZE 64
29
30 #ifndef __GNUC_PREREQ
31 # if defined __GNUC__ && defined __GNUC_MINOR__
32 # define __GNUC_PREREQ(maj, min) \
33 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
34 # else
35 # define __GNUC_PREREQ(maj, min) 0
36 # endif
37 #endif
38
39 #ifndef __THROW
40 # if defined __cplusplus && __GNUC_PREREQ (2,8)
41 # define __THROW throw ()
42 # else
43 # define __THROW
44 # endif
45 #endif
46
47 #define md5_buffer _pam_sql_md5_buffer
48 #define md5_finish_ctx _pam_sql_md5_finish_ctx
49 #define md5_init_ctx _pam_sql_md5_init_ctx
50 #define md5_process_block _pam_sql_md5_process_block
51 #define md5_process_bytes _pam_sql_md5_process_bytes
52 #define md5_read_ctx _pam_sql_md5_read_ctx
53 #define md5_stream _pam_sql_md5_stream
54
55 /* Structure to save state of computation between the single steps. */
56 struct md5_ctx
57 {
58 uint32_t A;
59 uint32_t B;
60 uint32_t C;
61 uint32_t D;
62
63 uint32_t total[2];
64 uint32_t buflen;
65 uint32_t buffer[32];
66 };
67
68 /*
69 * The following three functions are build up the low level used in
70 * the functions `md5_stream' and `md5_buffer'.
71 */
72
73 /* Initialize structure containing state of computation.
74 (RFC 1321, 3.3: Step 3) */
75 extern void md5_init_ctx (struct md5_ctx *ctx) __THROW;
76
77 /* Starting with the result of former calls of this function (or the
78 initialization function update the context for the next LEN bytes
79 starting at BUFFER.
80 It is necessary that LEN is a multiple of 64!!! */
81 extern void md5_process_block (const void *buffer, size_t len,
82 struct md5_ctx *ctx) __THROW;
83
84 /* Starting with the result of former calls of this function (or the
85 initialization function update the context for the next LEN bytes
86 starting at BUFFER.
87 It is NOT required that LEN is a multiple of 64. */
88 extern void md5_process_bytes (const void *buffer, size_t len,
89 struct md5_ctx *ctx) __THROW;
90
91 /* Process the remaining bytes in the buffer and put result from CTX
92 in first 16 bytes following RESBUF. The result is always in little
93 endian byte order, so that a byte-wise output yields to the wanted
94 ASCII representation of the message digest.
95
96 IMPORTANT: On some systems, RESBUF must be aligned to a 32-bit
97 boundary. */
98 extern void *md5_finish_ctx (struct md5_ctx *ctx, void *resbuf) __THROW;
99
100
101 /* Put result from CTX in first 16 bytes following RESBUF. The result is
102 always in little endian byte order, so that a byte-wise output yields
103 to the wanted ASCII representation of the message digest.
104
105 IMPORTANT: On some systems, RESBUF must be aligned to a 32-bit
106 boundary. */
107 extern void *md5_read_ctx (const struct md5_ctx *ctx, void *resbuf) __THROW;
108
109
110 /* Compute MD5 message digest for bytes read from STREAM. The
111 resulting message digest number will be written into the 16 bytes
112 beginning at RESBLOCK. */
113 extern int md5_stream (FILE *stream, void *resblock) __THROW;
114
115 /* Compute MD5 message digest for LEN bytes beginning at BUFFER. The
116 result is always in little endian byte order, so that a byte-wise
117 output yields to the wanted ASCII representation of the message
118 digest. */
119 extern void *md5_buffer (const char *buffer, size_t len,
120 void *resblock) __THROW;
121
122 #endif /* md5.h */

Send suggestions and bug reports to Sergey Poznyakoff
ViewVC Help
Powered by ViewVC 1.1.20