Mercurial > hg > octave-kai > gnulib-hg
annotate lib/sha1.h @ 17342:c75939cb6254
merge with default branch
author | Michael Goffioul <michael.goffioul@gmail.com> |
---|---|
date | Thu, 21 Feb 2013 14:57:31 +0000 |
parents | e542fd46ad6f |
children |
rev | line source |
---|---|
5165
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
1 /* Declarations of functions and data types used for SHA1 sum |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
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) 2000-2001, 2003, 2005-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. |
5165
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
5 |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
6 This program is free software; you can redistribute it and/or modify it |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
7 under the terms of the GNU General Public License as published by the |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
8 Free Software Foundation; either version 2, or (at your option) any |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
9 later version. |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
10 |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
11 This program is distributed in the hope that it will be useful, |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
14 GNU General Public License for more details. |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
15 |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
16 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:
16201
diff
changeset
|
17 along with this program; if not, see <http://www.gnu.org/licenses/>. */ |
5165
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
18 |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
19 #ifndef SHA1_H |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
20 # define SHA1_H 1 |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
21 |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
22 # include <stdio.h> |
6381
865e2ea2dde4
Separate sha1 from md5. Use stdint.h in both modules.
Simon Josefsson <simon@josefsson.org>
parents:
6222
diff
changeset
|
23 # include <stdint.h> |
5165
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
24 |
11731
2ddd55967fe9
C++: wrap md2,md5,sha1,etc. function declarations in extern "C" scope
Peter Simons <simons@cryp.to>
parents:
9663
diff
changeset
|
25 # ifdef __cplusplus |
2ddd55967fe9
C++: wrap md2,md5,sha1,etc. function declarations in extern "C" scope
Peter Simons <simons@cryp.to>
parents:
9663
diff
changeset
|
26 extern "C" { |
2ddd55967fe9
C++: wrap md2,md5,sha1,etc. function declarations in extern "C" scope
Peter Simons <simons@cryp.to>
parents:
9663
diff
changeset
|
27 # endif |
2ddd55967fe9
C++: wrap md2,md5,sha1,etc. function declarations in extern "C" scope
Peter Simons <simons@cryp.to>
parents:
9663
diff
changeset
|
28 |
9663
701f448527a4
Add SHA1_DIGEST_SIZE #define to sha1.h.
Simon Josefsson <simon@josefsson.org>
parents:
9656
diff
changeset
|
29 #define SHA1_DIGEST_SIZE 20 |
701f448527a4
Add SHA1_DIGEST_SIZE #define to sha1.h.
Simon Josefsson <simon@josefsson.org>
parents:
9656
diff
changeset
|
30 |
5165
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
31 /* Structure to save state of computation between the single steps. */ |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
32 struct sha1_ctx |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
33 { |
6381
865e2ea2dde4
Separate sha1 from md5. Use stdint.h in both modules.
Simon Josefsson <simon@josefsson.org>
parents:
6222
diff
changeset
|
34 uint32_t A; |
865e2ea2dde4
Separate sha1 from md5. Use stdint.h in both modules.
Simon Josefsson <simon@josefsson.org>
parents:
6222
diff
changeset
|
35 uint32_t B; |
865e2ea2dde4
Separate sha1 from md5. Use stdint.h in both modules.
Simon Josefsson <simon@josefsson.org>
parents:
6222
diff
changeset
|
36 uint32_t C; |
865e2ea2dde4
Separate sha1 from md5. Use stdint.h in both modules.
Simon Josefsson <simon@josefsson.org>
parents:
6222
diff
changeset
|
37 uint32_t D; |
865e2ea2dde4
Separate sha1 from md5. Use stdint.h in both modules.
Simon Josefsson <simon@josefsson.org>
parents:
6222
diff
changeset
|
38 uint32_t E; |
5165
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
39 |
6381
865e2ea2dde4
Separate sha1 from md5. Use stdint.h in both modules.
Simon Josefsson <simon@josefsson.org>
parents:
6222
diff
changeset
|
40 uint32_t total[2]; |
865e2ea2dde4
Separate sha1 from md5. Use stdint.h in both modules.
Simon Josefsson <simon@josefsson.org>
parents:
6222
diff
changeset
|
41 uint32_t buflen; |
6553 | 42 uint32_t buffer[32]; |
5165
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
43 }; |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
44 |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
45 |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
46 /* Initialize structure containing state of computation. */ |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
47 extern void sha1_init_ctx (struct sha1_ctx *ctx); |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
48 |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
49 /* Starting with the result of former calls of this function (or the |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
50 initialization function update the context for the next LEN bytes |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
51 starting at BUFFER. |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
52 It is necessary that LEN is a multiple of 64!!! */ |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
53 extern void sha1_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
|
54 struct sha1_ctx *ctx); |
5165
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
55 |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
56 /* Starting with the result of former calls of this function (or the |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
57 initialization function update the context for the next LEN bytes |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
58 starting at BUFFER. |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
59 It is NOT required that LEN is a multiple of 64. */ |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
60 extern void sha1_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
|
61 struct sha1_ctx *ctx); |
5165
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
62 |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
63 /* Process the remaining bytes in the buffer and put result from CTX |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
64 in first 20 bytes following RESBUF. The result is always in little |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
65 endian byte order, so that a byte-wise output yields to the wanted |
9656
9a9b67d137e3
sha1: remove the result buffer alignment constraint
Peter Palfrader <weasel@debian.org>
parents:
6553
diff
changeset
|
66 ASCII representation of the message digest. */ |
5165
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
67 extern void *sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf); |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
68 |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
69 |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
70 /* Put result from CTX in first 20 bytes following RESBUF. The result is |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
71 always in little endian byte order, so that a byte-wise output yields |
9656
9a9b67d137e3
sha1: remove the result buffer alignment constraint
Peter Palfrader <weasel@debian.org>
parents:
6553
diff
changeset
|
72 to the wanted ASCII representation of the message digest. */ |
5165
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
73 extern void *sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf); |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
74 |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
75 |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
76 /* Compute SHA1 message digest for bytes read from STREAM. The |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
77 resulting message digest number will be written into the 20 bytes |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
78 beginning at RESBLOCK. */ |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
79 extern int sha1_stream (FILE *stream, void *resblock); |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
80 |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
81 /* Compute SHA1 message digest for LEN bytes beginning at BUFFER. The |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
82 result is always in little endian byte order, so that a byte-wise |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
83 output yields to the wanted ASCII representation of the message |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
84 digest. */ |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
85 extern void *sha1_buffer (const char *buffer, size_t len, void *resblock); |
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
86 |
11731
2ddd55967fe9
C++: wrap md2,md5,sha1,etc. function declarations in extern "C" scope
Peter Simons <simons@cryp.to>
parents:
9663
diff
changeset
|
87 # ifdef __cplusplus |
2ddd55967fe9
C++: wrap md2,md5,sha1,etc. function declarations in extern "C" scope
Peter Simons <simons@cryp.to>
parents:
9663
diff
changeset
|
88 } |
2ddd55967fe9
C++: wrap md2,md5,sha1,etc. function declarations in extern "C" scope
Peter Simons <simons@cryp.to>
parents:
9663
diff
changeset
|
89 # endif |
2ddd55967fe9
C++: wrap md2,md5,sha1,etc. function declarations in extern "C" scope
Peter Simons <simons@cryp.to>
parents:
9663
diff
changeset
|
90 |
5165
9d7fe6ace357
Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff
changeset
|
91 #endif |