annotate Modules/md5.h @ 5817:48b94de85bf3 legacy-trunk

Extensive changes by AMK.
author Guido van Rossum <guido@python.org>
date Thu, 17 Jul 1997 16:29:42 +0000
parents ab110b1e92ff
children 8424ec4c4bb2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1385
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 /* MD5.H - header file for MD5C.C
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 */
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
3
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 /* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 rights reserved.
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
6
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 License to copy and use this software is granted provided that it
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 is identified as the "RSA Data Security, Inc. MD5 Message-Digest
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 Algorithm" in all material mentioning or referencing this software
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
10 or this function.
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
11
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 License is also granted to make and use derivative works provided
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
13 that such works are identified as "derived from the RSA Data
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 Security, Inc. MD5 Message-Digest Algorithm" in all material
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
15 mentioning or referencing the derived work.
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
16
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
17 RSA Data Security, Inc. makes no representations concerning either
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
18 the merchantability of this software or the suitability of this
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 software for any particular purpose. It is provided "as is"
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 without express or implied warranty of any kind.
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
21
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
22 These notices must be retained in any copies of any part of this
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
23 documentation and/or software.
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
24 */
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
25
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
26 /* ========== include global.h ========== */
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
27 /* GLOBAL.H - RSAREF types and constants
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
28 */
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
29
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
30 /* PROTOTYPES should be set to one if and only if the compiler supports
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
31 function argument prototyping.
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
32 The following makes PROTOTYPES default to 0 if it has not already
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
33 been defined with C compiler flags.
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
34 */
1746
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1385
diff changeset
35 #ifdef HAVE_PROTOTYPES
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1385
diff changeset
36 #define PROTOTYPES 1
1940892d2fe3 Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents: 1385
diff changeset
37 #endif
1385
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
38 #ifndef PROTOTYPES
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
39 #define PROTOTYPES 0
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
40 #endif
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
41
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
42 /* POINTER defines a generic pointer type */
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
43 typedef unsigned char *POINTER;
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
44
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
45 /* UINT2 defines a two byte word */
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
46 typedef unsigned short int UINT2;
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
47
3338
2db585ea218b 64-bit patch
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
48 #ifdef HAVE_LIMITS_H
2db585ea218b 64-bit patch
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
49 #include <limits.h>
2db585ea218b 64-bit patch
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
50 #else
3775
ab110b1e92ff Use INT_MAX/LONG_MAX instead of non-ANSI LONG_BIT
Guido van Rossum <guido@python.org>
parents: 3612
diff changeset
51 /* Wild guess */
ab110b1e92ff Use INT_MAX/LONG_MAX instead of non-ANSI LONG_BIT
Guido van Rossum <guido@python.org>
parents: 3612
diff changeset
52 #define LONG_MAX 2147483647L
3338
2db585ea218b 64-bit patch
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
53 #endif
2db585ea218b 64-bit patch
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
54
1385
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
55 /* UINT4 defines a four byte word */
3775
ab110b1e92ff Use INT_MAX/LONG_MAX instead of non-ANSI LONG_BIT
Guido van Rossum <guido@python.org>
parents: 3612
diff changeset
56 #if defined(INT_MAX) && INT_MAX == 2147483647
3338
2db585ea218b 64-bit patch
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
57 typedef unsigned int UINT4;
2db585ea218b 64-bit patch
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
58 #else
3775
ab110b1e92ff Use INT_MAX/LONG_MAX instead of non-ANSI LONG_BIT
Guido van Rossum <guido@python.org>
parents: 3612
diff changeset
59 #if defined(LONG_MAX) && LONG_MAX == 2147483647L
1385
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
60 typedef unsigned long int UINT4;
3338
2db585ea218b 64-bit patch
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
61 #endif
2db585ea218b 64-bit patch
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
62 /* Too bad if neither is */
2db585ea218b 64-bit patch
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
63 #endif
1385
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
64
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
65 /* PROTO_LIST is defined depending on how PROTOTYPES is defined above.
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
66 If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
67 returns an empty list.
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
68 */
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
69 #if PROTOTYPES
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
70 #define PROTO_LIST(list) list
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
71 #else
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
72 #define PROTO_LIST(list) ()
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
73 #endif
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
74 /* ========== End global.h; continue md5.h ========== */
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
75
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
76 /* MD5 context. */
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
77 typedef struct {
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
78 UINT4 state[4]; /* state (ABCD) */
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
79 UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
80 unsigned char buffer[64]; /* input buffer */
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
81 } MD5_CTX;
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
82
3612
4866a0fc2bbd rename exported symbols with _Py_ prefix
Guido van Rossum <guido@python.org>
parents: 3338
diff changeset
83 /* Rename all exported symbols to avoid conflicts with similarly named
4866a0fc2bbd rename exported symbols with _Py_ prefix
Guido van Rossum <guido@python.org>
parents: 3338
diff changeset
84 symbols in some systems' standard C libraries... */
4866a0fc2bbd rename exported symbols with _Py_ prefix
Guido van Rossum <guido@python.org>
parents: 3338
diff changeset
85
4866a0fc2bbd rename exported symbols with _Py_ prefix
Guido van Rossum <guido@python.org>
parents: 3338
diff changeset
86 #define MD5Init _Py_MD5Init
4866a0fc2bbd rename exported symbols with _Py_ prefix
Guido van Rossum <guido@python.org>
parents: 3338
diff changeset
87 #define MD5Update _Py_MD5Update
4866a0fc2bbd rename exported symbols with _Py_ prefix
Guido van Rossum <guido@python.org>
parents: 3338
diff changeset
88 #define MD5Final _Py_MD5Final
4866a0fc2bbd rename exported symbols with _Py_ prefix
Guido van Rossum <guido@python.org>
parents: 3338
diff changeset
89
1385
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
90 void MD5Init PROTO_LIST ((MD5_CTX *));
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
91 void MD5Update PROTO_LIST
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
92 ((MD5_CTX *, unsigned char *, unsigned int));
158f0d9cdd40 Simplify life for md5: include (slightly modified) md5.h and md5c.c
Guido van Rossum <guido@python.org>
parents:
diff changeset
93 void MD5Final PROTO_LIST ((unsigned char [16], MD5_CTX *));