ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/libcpjit/md5.h
Revision: 1.2
Committed: Fri Oct 14 01:29:45 2005 UTC (18 years, 9 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +93 -13 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.2 /* md5.h - Declaration of functions and data types used for MD5 sum
2     computing library functions.
3     Copyright (C) 1995, 1996, 1999, 2000, 2003 Free Software Foundation, Inc.
4     NOTE: The canonical source of this file is maintained with the GNU C
5     Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20    
21     #ifndef _MD5_H
22     #define _MD5_H 1
23    
24 root 1.1 #include <inttypes.h>
25    
26 root 1.2 /* The following contortions are an attempt to use the C preprocessor
27     to determine an unsigned integral type that is 32 bits wide. An
28     alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but
29     doing that would require that the configure script compile and *run*
30     the resulting executable. Locally running cross-compiled executables
31     is usually not possible. */
32    
33     typedef uint32_t md5_uint32;
34     typedef uintptr_t md5_uintptr;
35    
36     /* Structure to save state of computation between the single steps. */
37     struct md5_ctx
38     {
39     md5_uint32 A;
40     md5_uint32 B;
41     md5_uint32 C;
42     md5_uint32 D;
43    
44     md5_uint32 total[2];
45     md5_uint32 buflen;
46     char buffer[128];
47     };
48    
49     /*
50     * The following three functions are build up the low level used in
51     * the functions `md5_stream' and `md5_buffer'.
52     */
53    
54     /* Initialize structure containing state of computation.
55     (RFC 1321, 3.3: Step 3) */
56     extern void md5_init_ctx (struct md5_ctx *ctx);
57    
58     /* Starting with the result of former calls of this function (or the
59     initialization function update the context for the next LEN bytes
60     starting at BUFFER.
61     It is necessary that LEN is a multiple of 64!!! */
62     extern void md5_process_block (const void *buffer, int len,
63     struct md5_ctx *ctx);
64    
65     /* Starting with the result of former calls of this function (or the
66     initialization function update the context for the next LEN bytes
67     starting at BUFFER.
68     It is NOT required that LEN is a multiple of 64. */
69     extern void md5_process_bytes (const void *buffer, int len,
70     struct md5_ctx *ctx);
71    
72     /* Process the remaining bytes in the buffer and put result from CTX
73     in first 16 bytes following RESBUF. The result is always in little
74     endian byte order, so that a byte-wise output yields to the wanted
75     ASCII representation of the message digest.
76    
77     IMPORTANT: On some systems it is required that RESBUF be correctly
78     aligned for a 32 bits value. */
79     extern void *md5_finish_ctx (struct md5_ctx *ctx, void *resbuf);
80    
81    
82     /* Put result from CTX in first 16 bytes following RESBUF. The result is
83     always in little endian byte order, so that a byte-wise output yields
84     to the wanted ASCII representation of the message digest.
85    
86     IMPORTANT: On some systems it is required that RESBUF is correctly
87     aligned for a 32 bits value. */
88     extern void *md5_read_ctx (const struct md5_ctx *ctx, void *resbuf);
89    
90 root 1.1
91 root 1.2 /* Compute MD5 message digest for LEN bytes beginning at BUFFER. The
92     result is always in little endian byte order, so that a byte-wise
93     output yields to the wanted ASCII representation of the message
94     digest. */
95     extern void *md5_buffer (const char *buffer, int len, void *resblock);
96 root 1.1
97 root 1.2 #endif