Mercurial > hg > octave-shane > gnulib-hg
annotate lib/md5.h @ 17255:d81be792518a
update from texinfo
author | Karl Berry <karl@freefriends.org> |
---|---|
date | Tue, 01 Jan 2013 15:51:49 -0800 |
parents | e542fd46ad6f |
children | 0c8459454095 |
rev | line source |
---|---|
6222
3bdede13630a
Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
1 /* Declaration of functions and data types used for MD5 sum computing |
3bdede13630a
Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
2 library functions. |
17249
e542fd46ad6f
maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents:
16366
diff
changeset
|
3 Copyright (C) 1995-1997, 1999-2001, 2004-2006, 2008-2013 Free Software |
12559
c2cbabec01dd
update nearly all FSF copyright year lists to include 2010
Jim Meyering <meyering@redhat.com>
parents:
12421
diff
changeset
|
4 Foundation, Inc. |
6381
865e2ea2dde4
Separate sha1 from md5. Use stdint.h in both modules.
Simon Josefsson <simon@josefsson.org>
parents:
6335
diff
changeset
|
5 This file is part of the GNU C Library. |
464 | 6 |
771 | 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. | |
464 | 11 |
771 | 12 This program is distributed in the hope that it will be useful, |
755 | 13 but WITHOUT ANY WARRANTY; without even the implied warranty of |
771 | 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 GNU General Public License for more details. | |
464 | 16 |
771 | 17 You should have received a copy of the GNU General Public License |
16366
bb182ee4a09d
maint: replace FSF snail-mail addresses with URLs
Paul Eggert <eggert@cs.ucla.edu>
parents:
16235
diff
changeset
|
18 along with this program; if not, see <http://www.gnu.org/licenses/>. */ |
464 | 19 |
20 #ifndef _MD5_H | |
745 | 21 #define _MD5_H 1 |
464 | 22 |
23 #include <stdio.h> | |
6381
865e2ea2dde4
Separate sha1 from md5. Use stdint.h in both modules.
Simon Josefsson <simon@josefsson.org>
parents:
6335
diff
changeset
|
24 #include <stdint.h> |
464 | 25 |
6381
865e2ea2dde4
Separate sha1 from md5. Use stdint.h in both modules.
Simon Josefsson <simon@josefsson.org>
parents:
6335
diff
changeset
|
26 #define MD5_DIGEST_SIZE 16 |
865e2ea2dde4
Separate sha1 from md5. Use stdint.h in both modules.
Simon Josefsson <simon@josefsson.org>
parents:
6335
diff
changeset
|
27 #define MD5_BLOCK_SIZE 64 |
5159 | 28 |
6222
3bdede13630a
Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
29 #ifndef __GNUC_PREREQ |
3bdede13630a
Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
30 # if defined __GNUC__ && defined __GNUC_MINOR__ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11749
diff
changeset
|
31 # define __GNUC_PREREQ(maj, min) \ |
6381
865e2ea2dde4
Separate sha1 from md5. Use stdint.h in both modules.
Simon Josefsson <simon@josefsson.org>
parents:
6335
diff
changeset
|
32 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) |
6222
3bdede13630a
Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
33 # else |
3bdede13630a
Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
34 # define __GNUC_PREREQ(maj, min) 0 |
3bdede13630a
Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
35 # endif |
3bdede13630a
Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
36 #endif |
3bdede13630a
Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
37 |
3bdede13630a
Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
38 #ifndef __THROW |
3bdede13630a
Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
39 # if defined __cplusplus && __GNUC_PREREQ (2,8) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11749
diff
changeset
|
40 # define __THROW throw () |
6222
3bdede13630a
Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
41 # else |
3bdede13630a
Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
42 # define __THROW |
3bdede13630a
Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
43 # endif |
3bdede13630a
Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
44 #endif |
3bdede13630a
Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
45 |
3bdede13630a
Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
46 #ifndef _LIBC |
3bdede13630a
Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
47 # define __md5_buffer md5_buffer |
3bdede13630a
Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
48 # define __md5_finish_ctx md5_finish_ctx |
3bdede13630a
Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
49 # define __md5_init_ctx md5_init_ctx |
3bdede13630a
Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
50 # define __md5_process_block md5_process_block |
3bdede13630a
Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
51 # define __md5_process_bytes md5_process_bytes |
3bdede13630a
Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
52 # define __md5_read_ctx md5_read_ctx |
3bdede13630a
Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
53 # define __md5_stream md5_stream |
3bdede13630a
Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
54 #endif |
3bdede13630a
Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
55 |
11731
2ddd55967fe9
C++: wrap md2,md5,sha1,etc. function declarations in extern "C" scope
Peter Simons <simons@cryp.to>
parents:
9657
diff
changeset
|
56 # ifdef __cplusplus |
2ddd55967fe9
C++: wrap md2,md5,sha1,etc. function declarations in extern "C" scope
Peter Simons <simons@cryp.to>
parents:
9657
diff
changeset
|
57 extern "C" { |
2ddd55967fe9
C++: wrap md2,md5,sha1,etc. function declarations in extern "C" scope
Peter Simons <simons@cryp.to>
parents:
9657
diff
changeset
|
58 # endif |
2ddd55967fe9
C++: wrap md2,md5,sha1,etc. function declarations in extern "C" scope
Peter Simons <simons@cryp.to>
parents:
9657
diff
changeset
|
59 |
464 | 60 /* Structure to save state of computation between the single steps. */ |
61 struct md5_ctx | |
62 { | |
6381
865e2ea2dde4
Separate sha1 from md5. Use stdint.h in both modules.
Simon Josefsson <simon@josefsson.org>
parents:
6335
diff
changeset
|
63 uint32_t A; |
865e2ea2dde4
Separate sha1 from md5. Use stdint.h in both modules.
Simon Josefsson <simon@josefsson.org>
parents:
6335
diff
changeset
|
64 uint32_t B; |
865e2ea2dde4
Separate sha1 from md5. Use stdint.h in both modules.
Simon Josefsson <simon@josefsson.org>
parents:
6335
diff
changeset
|
65 uint32_t C; |
865e2ea2dde4
Separate sha1 from md5. Use stdint.h in both modules.
Simon Josefsson <simon@josefsson.org>
parents:
6335
diff
changeset
|
66 uint32_t D; |
745 | 67 |
6381
865e2ea2dde4
Separate sha1 from md5. Use stdint.h in both modules.
Simon Josefsson <simon@josefsson.org>
parents:
6335
diff
changeset
|
68 uint32_t total[2]; |
865e2ea2dde4
Separate sha1 from md5. Use stdint.h in both modules.
Simon Josefsson <simon@josefsson.org>
parents:
6335
diff
changeset
|
69 uint32_t buflen; |
6433
9ae35a6dccf5
* md5.h, md5.c: Simplify buffer handling visavi alignment,
Simon Josefsson <simon@josefsson.org>
parents:
6381
diff
changeset
|
70 uint32_t buffer[32]; |
464 | 71 }; |
72 | |
73 /* | |
74 * The following three functions are build up the low level used in | |
16235
18a38c9615f0
In commentary, do not use ` to quote.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
75 * the functions 'md5_stream' and 'md5_buffer'. |
464 | 76 */ |
77 | |
78 /* Initialize structure containing state of computation. | |
79 (RFC 1321, 3.3: Step 3) */ | |
6222
3bdede13630a
Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
80 extern void __md5_init_ctx (struct md5_ctx *ctx) __THROW; |
745 | 81 |
82 /* Starting with the result of former calls of this function (or the | |
83 initialization function update the context for the next LEN bytes | |
84 starting at BUFFER. | |
85 It is necessary that LEN is a multiple of 64!!! */ | |
6222
3bdede13630a
Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
86 extern void __md5_process_block (const void *buffer, size_t len, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11749
diff
changeset
|
87 struct md5_ctx *ctx) __THROW; |
464 | 88 |
89 /* Starting with the result of former calls of this function (or the | |
745 | 90 initialization function update the context for the next LEN bytes |
464 | 91 starting at BUFFER. |
745 | 92 It is NOT required that LEN is a multiple of 64. */ |
6222
3bdede13630a
Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
93 extern void __md5_process_bytes (const void *buffer, size_t len, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11749
diff
changeset
|
94 struct md5_ctx *ctx) __THROW; |
745 | 95 |
96 /* Process the remaining bytes in the buffer and put result from CTX | |
97 in first 16 bytes following RESBUF. The result is always in little | |
98 endian byte order, so that a byte-wise output yields to the wanted | |
9657
267c66b59eec
md5: adapt alignment constraint fix from sha1.
Simon Josefsson <simon@josefsson.org>
parents:
6553
diff
changeset
|
99 ASCII representation of the message digest. */ |
6222
3bdede13630a
Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
100 extern void *__md5_finish_ctx (struct md5_ctx *ctx, void *resbuf) __THROW; |
745 | 101 |
464 | 102 |
103 /* Put result from CTX in first 16 bytes following RESBUF. The result is | |
104 always in little endian byte order, so that a byte-wise output yields | |
9657
267c66b59eec
md5: adapt alignment constraint fix from sha1.
Simon Josefsson <simon@josefsson.org>
parents:
6553
diff
changeset
|
105 to the wanted ASCII representation of the message digest. */ |
6222
3bdede13630a
Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
106 extern void *__md5_read_ctx (const struct md5_ctx *ctx, void *resbuf) __THROW; |
464 | 107 |
108 | |
109 /* Compute MD5 message digest for bytes read from STREAM. The | |
110 resulting message digest number will be written into the 16 bytes | |
111 beginning at RESBLOCK. */ | |
6222
3bdede13630a
Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
112 extern int __md5_stream (FILE *stream, void *resblock) __THROW; |
464 | 113 |
114 /* Compute MD5 message digest for LEN bytes beginning at BUFFER. The | |
115 result is always in little endian byte order, so that a byte-wise | |
116 output yields to the wanted ASCII representation of the message | |
117 digest. */ | |
6222
3bdede13630a
Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
118 extern void *__md5_buffer (const char *buffer, size_t len, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11749
diff
changeset
|
119 void *resblock) __THROW; |
464 | 120 |
11731
2ddd55967fe9
C++: wrap md2,md5,sha1,etc. function declarations in extern "C" scope
Peter Simons <simons@cryp.to>
parents:
9657
diff
changeset
|
121 # ifdef __cplusplus |
2ddd55967fe9
C++: wrap md2,md5,sha1,etc. function declarations in extern "C" scope
Peter Simons <simons@cryp.to>
parents:
9657
diff
changeset
|
122 } |
2ddd55967fe9
C++: wrap md2,md5,sha1,etc. function declarations in extern "C" scope
Peter Simons <simons@cryp.to>
parents:
9657
diff
changeset
|
123 # endif |
2ddd55967fe9
C++: wrap md2,md5,sha1,etc. function declarations in extern "C" scope
Peter Simons <simons@cryp.to>
parents:
9657
diff
changeset
|
124 |
6222
3bdede13630a
Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
125 #endif /* md5.h */ |