annotate lib/sha1.c @ 36940:c741bc27922a

maint: update all copyright year number ranges Run "make update-copyright". Compare to commit 1602f0a from last year. Signed-off-by: Eric Blake <eblake@redhat.com>
author Eric Blake <eblake@redhat.com>
date Tue, 01 Jan 2013 00:50:58 +0000
parents 024e48bc0b1d
children 0c8459454095
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
1 /* sha1.c - Functions to compute SHA1 message digest of files or
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
2 memory blocks according to the NIST specification FIPS-180-1.
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
3
36940
c741bc27922a maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents: 36874
diff changeset
4 Copyright (C) 2000-2001, 2003-2006, 2008-2013 Free Software Foundation, Inc.
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
5
d1bd730b77d7 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
d1bd730b77d7 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
d1bd730b77d7 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
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
9 later version.
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
10
d1bd730b77d7 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,
d1bd730b77d7 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
d1bd730b77d7 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
d1bd730b77d7 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.
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
15
d1bd730b77d7 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
36057
81b1562e3d8b maint: replace FSF snail-mail addresses with URLs
Paul Eggert <eggert@cs.ucla.edu>
parents: 35892
diff changeset
17 along with this program; if not, see <http://www.gnu.org/licenses/>. */
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
18
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
19 /* Written by Scott G. Miller
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
20 Credits:
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
21 Robert Klep <robert@ilse.nl> -- Expansion function fix
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
22 */
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
23
26993
8aa31e5d3ec4 * _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents: 26478
diff changeset
24 #include <config.h>
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
25
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
26 #include "sha1.h"
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
27
35688
5fe530331127 crypto libraries: use stdalign
Paul Eggert <eggert@cs.ucla.edu>
parents: 33770
diff changeset
28 #include <stdalign.h>
5fe530331127 crypto libraries: use stdalign
Paul Eggert <eggert@cs.ucla.edu>
parents: 33770
diff changeset
29 #include <stdint.h>
31889
59a9e6ad38f8 digests, copy-file: increase the IO buffer size from 4KiB to 32KiB
Pádraig Brady <P@draigBrady.com>
parents: 29487
diff changeset
30 #include <stdlib.h>
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
31 #include <string.h>
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
32
25009
ea3c229c77ea Remove dependencies on unlocked-io.
Paul Eggert <eggert@cs.ucla.edu>
parents: 24856
diff changeset
33 #if USE_UNLOCKED_IO
ea3c229c77ea Remove dependencies on unlocked-io.
Paul Eggert <eggert@cs.ucla.edu>
parents: 24856
diff changeset
34 # include "unlocked-io.h"
ea3c229c77ea Remove dependencies on unlocked-io.
Paul Eggert <eggert@cs.ucla.edu>
parents: 24856
diff changeset
35 #endif
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
36
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
37 #ifdef WORDS_BIGENDIAN
25913
299e806d4eb9 Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents: 25539
diff changeset
38 # define SWAP(n) (n)
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
39 #else
25913
299e806d4eb9 Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents: 25539
diff changeset
40 # define SWAP(n) \
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
41 (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24))
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
42 #endif
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
43
31889
59a9e6ad38f8 digests, copy-file: increase the IO buffer size from 4KiB to 32KiB
Pádraig Brady <P@draigBrady.com>
parents: 29487
diff changeset
44 #define BLOCKSIZE 32768
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
45 #if BLOCKSIZE % 64 != 0
25913
299e806d4eb9 Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents: 25539
diff changeset
46 # error "invalid BLOCKSIZE"
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
47 #endif
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
48
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
49 /* This array contains the bytes used to pad the buffer to the next
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
50 64-byte boundary. (RFC 1321, 3.1: Step 1) */
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
51 static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
52
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
53
26244
3655e550b688 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 26231
diff changeset
54 /* Take a pointer to a 160 bit block of data (five 32 bit ints) and
3655e550b688 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 26231
diff changeset
55 initialize it to the start constants of the SHA1 algorithm. This
3655e550b688 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 26231
diff changeset
56 must be called before using hash in the call to sha1_hash. */
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
57 void
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
58 sha1_init_ctx (struct sha1_ctx *ctx)
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
59 {
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
60 ctx->A = 0x67452301;
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
61 ctx->B = 0xefcdab89;
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
62 ctx->C = 0x98badcfe;
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
63 ctx->D = 0x10325476;
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
64 ctx->E = 0xc3d2e1f0;
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
65
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
66 ctx->total[0] = ctx->total[1] = 0;
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
67 ctx->buflen = 0;
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
68 }
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
69
29347
49c64d003ba6 sha1: remove the result buffer alignment constraint
Peter Palfrader <weasel@debian.org>
parents: 26993
diff changeset
70 /* Copy the 4 byte value from v into the memory location pointed to by *cp,
49c64d003ba6 sha1: remove the result buffer alignment constraint
Peter Palfrader <weasel@debian.org>
parents: 26993
diff changeset
71 If your architecture allows unaligned access this is equivalent to
49c64d003ba6 sha1: remove the result buffer alignment constraint
Peter Palfrader <weasel@debian.org>
parents: 26993
diff changeset
72 * (uint32_t *) cp = v */
36874
024e48bc0b1d arctwo, md4, md5, sha1, sha256, sha512: no 'static inline'
Paul Eggert <eggert@cs.ucla.edu>
parents: 36551
diff changeset
73 static void
29347
49c64d003ba6 sha1: remove the result buffer alignment constraint
Peter Palfrader <weasel@debian.org>
parents: 26993
diff changeset
74 set_uint32 (char *cp, uint32_t v)
49c64d003ba6 sha1: remove the result buffer alignment constraint
Peter Palfrader <weasel@debian.org>
parents: 26993
diff changeset
75 {
29353
f9475e9874b4 Prefer "sizeof v" over the equivalent "4".
Jim Meyering <meyering@redhat.com>
parents: 29351
diff changeset
76 memcpy (cp, &v, sizeof v);
29347
49c64d003ba6 sha1: remove the result buffer alignment constraint
Peter Palfrader <weasel@debian.org>
parents: 26993
diff changeset
77 }
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
78
29347
49c64d003ba6 sha1: remove the result buffer alignment constraint
Peter Palfrader <weasel@debian.org>
parents: 26993
diff changeset
79 /* Put result from CTX in first 20 bytes following RESBUF. The result
49c64d003ba6 sha1: remove the result buffer alignment constraint
Peter Palfrader <weasel@debian.org>
parents: 26993
diff changeset
80 must be in little endian byte order. */
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
81 void *
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
82 sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf)
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
83 {
29347
49c64d003ba6 sha1: remove the result buffer alignment constraint
Peter Palfrader <weasel@debian.org>
parents: 26993
diff changeset
84 char *r = resbuf;
29357
e7c097072524 Use "sizeof VAR", rather than a literal "4".
Jim Meyering <meyering@redhat.com>
parents: 29353
diff changeset
85 set_uint32 (r + 0 * sizeof ctx->A, SWAP (ctx->A));
e7c097072524 Use "sizeof VAR", rather than a literal "4".
Jim Meyering <meyering@redhat.com>
parents: 29353
diff changeset
86 set_uint32 (r + 1 * sizeof ctx->B, SWAP (ctx->B));
e7c097072524 Use "sizeof VAR", rather than a literal "4".
Jim Meyering <meyering@redhat.com>
parents: 29353
diff changeset
87 set_uint32 (r + 2 * sizeof ctx->C, SWAP (ctx->C));
e7c097072524 Use "sizeof VAR", rather than a literal "4".
Jim Meyering <meyering@redhat.com>
parents: 29353
diff changeset
88 set_uint32 (r + 3 * sizeof ctx->D, SWAP (ctx->D));
e7c097072524 Use "sizeof VAR", rather than a literal "4".
Jim Meyering <meyering@redhat.com>
parents: 29353
diff changeset
89 set_uint32 (r + 4 * sizeof ctx->E, SWAP (ctx->E));
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
90
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
91 return resbuf;
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
92 }
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
93
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
94 /* Process the remaining bytes in the internal buffer and the usual
29347
49c64d003ba6 sha1: remove the result buffer alignment constraint
Peter Palfrader <weasel@debian.org>
parents: 26993
diff changeset
95 prolog according to the standard and write the result to RESBUF. */
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
96 void *
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
97 sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf)
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
98 {
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
99 /* Take yet unprocessed bytes into account. */
26072
56e6483a97ab Separate sha1 from md5. Use stdint.h in both modules.
Simon Josefsson <simon@josefsson.org>
parents: 25913
diff changeset
100 uint32_t bytes = ctx->buflen;
26244
3655e550b688 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 26231
diff changeset
101 size_t size = (bytes < 56) ? 64 / 4 : 64 * 2 / 4;
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
102
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
103 /* Now count remaining bytes. */
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
104 ctx->total[0] += bytes;
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
105 if (ctx->total[0] < bytes)
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
106 ++ctx->total[1];
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
107
26244
3655e550b688 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 26231
diff changeset
108 /* Put the 64-bit file length in *bits* at the end of the buffer. */
3655e550b688 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 26231
diff changeset
109 ctx->buffer[size - 2] = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29));
3655e550b688 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 26231
diff changeset
110 ctx->buffer[size - 1] = SWAP (ctx->total[0] << 3);
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
111
26244
3655e550b688 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 26231
diff changeset
112 memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes);
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
113
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
114 /* Process last bytes. */
26244
3655e550b688 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 26231
diff changeset
115 sha1_process_block (ctx->buffer, size * 4, ctx);
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
116
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
117 return sha1_read_ctx (ctx, resbuf);
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
118 }
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
119
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
120 /* Compute SHA1 message digest for bytes read from STREAM. The
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
121 resulting message digest number will be written into the 16 bytes
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
122 beginning at RESBLOCK. */
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
123 int
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
124 sha1_stream (FILE *stream, void *resblock)
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
125 {
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
126 struct sha1_ctx ctx;
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
127 size_t sum;
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
128
31889
59a9e6ad38f8 digests, copy-file: increase the IO buffer size from 4KiB to 32KiB
Pádraig Brady <P@draigBrady.com>
parents: 29487
diff changeset
129 char *buffer = malloc (BLOCKSIZE + 72);
59a9e6ad38f8 digests, copy-file: increase the IO buffer size from 4KiB to 32KiB
Pádraig Brady <P@draigBrady.com>
parents: 29487
diff changeset
130 if (!buffer)
59a9e6ad38f8 digests, copy-file: increase the IO buffer size from 4KiB to 32KiB
Pádraig Brady <P@draigBrady.com>
parents: 29487
diff changeset
131 return 1;
59a9e6ad38f8 digests, copy-file: increase the IO buffer size from 4KiB to 32KiB
Pádraig Brady <P@draigBrady.com>
parents: 29487
diff changeset
132
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
133 /* Initialize the computation context. */
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
134 sha1_init_ctx (&ctx);
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
135
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
136 /* Iterate over full file contents. */
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
137 while (1)
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
138 {
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
139 /* We read the file in blocks of BLOCKSIZE bytes. One call of the
32112
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
140 computation function processes the whole buffer so that with the
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
141 next round of the loop another block can be read. */
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
142 size_t n;
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
143 sum = 0;
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
144
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
145 /* Read block. Take care for partial reads. */
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
146 while (1)
32112
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
147 {
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
148 n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream);
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
149
32112
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
150 sum += n;
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
151
32112
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
152 if (sum == BLOCKSIZE)
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
153 break;
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
154
32112
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
155 if (n == 0)
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
156 {
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
157 /* Check for the error flag IFF N == 0, so that we don't
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
158 exit the loop after a partial read due to e.g., EAGAIN
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
159 or EWOULDBLOCK. */
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
160 if (ferror (stream))
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
161 {
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
162 free (buffer);
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
163 return 1;
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
164 }
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
165 goto process_partial_block;
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
166 }
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
167
32112
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
168 /* We've read at least one byte, so ignore errors. But always
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
169 check for EOF, since feof may be true even though N > 0.
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
170 Otherwise, we could end up calling fread after EOF. */
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
171 if (feof (stream))
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
172 goto process_partial_block;
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
173 }
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
174
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
175 /* Process buffer with BLOCKSIZE bytes. Note that
32112
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
176 BLOCKSIZE % 64 == 0
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
177 */
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
178 sha1_process_block (buffer, BLOCKSIZE, &ctx);
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
179 }
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
180
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
181 process_partial_block:;
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
182
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
183 /* Process any remaining bytes. */
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
184 if (sum > 0)
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
185 sha1_process_bytes (buffer, sum, &ctx);
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
186
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
187 /* Construct result in desired memory. */
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
188 sha1_finish_ctx (&ctx, resblock);
31889
59a9e6ad38f8 digests, copy-file: increase the IO buffer size from 4KiB to 32KiB
Pádraig Brady <P@draigBrady.com>
parents: 29487
diff changeset
189 free (buffer);
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
190 return 0;
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
191 }
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
192
26478
e0a5d2c96f89 sha1.c (sha1_buffer): Correct comment: s/MD5/SHA1/. From James Lemley.
Jim Meyering <jim@meyering.net>
parents: 26475
diff changeset
193 /* Compute SHA1 message digest for LEN bytes beginning at BUFFER. The
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
194 result is always in little endian byte order, so that a byte-wise
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
195 output yields to the wanted ASCII representation of the message
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
196 digest. */
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
197 void *
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
198 sha1_buffer (const char *buffer, size_t len, void *resblock)
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
199 {
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
200 struct sha1_ctx ctx;
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
201
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
202 /* Initialize the computation context. */
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
203 sha1_init_ctx (&ctx);
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
204
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
205 /* Process whole buffer but last len % 64 bytes. */
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
206 sha1_process_bytes (buffer, len, &ctx);
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
207
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
208 /* Put result in desired memory area. */
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
209 return sha1_finish_ctx (&ctx, resblock);
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
210 }
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
211
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
212 void
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
213 sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx)
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
214 {
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
215 /* When we already have some bits in our internal buffer concatenate
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
216 both inputs first. */
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
217 if (ctx->buflen != 0)
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
218 {
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
219 size_t left_over = ctx->buflen;
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
220 size_t add = 128 - left_over > len ? len : 128 - left_over;
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
221
26244
3655e550b688 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 26231
diff changeset
222 memcpy (&((char *) ctx->buffer)[left_over], buffer, add);
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
223 ctx->buflen += add;
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
224
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
225 if (ctx->buflen > 64)
32112
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
226 {
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
227 sha1_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
29487
6852b588fd27 Undo last change.
Jim Meyering <meyering@redhat.com>
parents: 29486
diff changeset
228
32112
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
229 ctx->buflen &= 63;
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
230 /* The regions in the following copy operation cannot overlap. */
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
231 memcpy (ctx->buffer,
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
232 &((char *) ctx->buffer)[(left_over + add) & ~63],
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
233 ctx->buflen);
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
234 }
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
235
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
236 buffer = (const char *) buffer + add;
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
237 len -= add;
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
238 }
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
239
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
240 /* Process available complete blocks. */
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
241 if (len >= 64)
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
242 {
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
243 #if !_STRING_ARCH_unaligned
35688
5fe530331127 crypto libraries: use stdalign
Paul Eggert <eggert@cs.ucla.edu>
parents: 33770
diff changeset
244 # define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0)
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
245 if (UNALIGNED_P (buffer))
32112
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
246 while (len > 64)
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
247 {
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
248 sha1_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx);
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
249 buffer = (const char *) buffer + 64;
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
250 len -= 64;
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
251 }
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
252 else
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
253 #endif
32112
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
254 {
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
255 sha1_process_block (buffer, len & ~63, ctx);
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
256 buffer = (const char *) buffer + (len & ~63);
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
257 len &= 63;
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
258 }
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
259 }
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
260
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
261 /* Move remaining bytes in internal buffer. */
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
262 if (len > 0)
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
263 {
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
264 size_t left_over = ctx->buflen;
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
265
26244
3655e550b688 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 26231
diff changeset
266 memcpy (&((char *) ctx->buffer)[left_over], buffer, len);
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
267 left_over += len;
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
268 if (left_over >= 64)
32112
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
269 {
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
270 sha1_process_block (ctx->buffer, 64, ctx);
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
271 left_over -= 64;
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
272 memcpy (ctx->buffer, &ctx->buffer[16], left_over);
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
273 }
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
274 ctx->buflen = left_over;
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
275 }
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
276 }
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
277
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
278 /* --- Code below is the primary difference between md5.c and sha1.c --- */
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
279
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
280 /* SHA1 round constants */
26475
61306c7a6237 2006-05-10 Paul Eggert <eggert@cs.ucla.edu>
Simon Josefsson <simon@josefsson.org>
parents: 26244
diff changeset
281 #define K1 0x5a827999
61306c7a6237 2006-05-10 Paul Eggert <eggert@cs.ucla.edu>
Simon Josefsson <simon@josefsson.org>
parents: 26244
diff changeset
282 #define K2 0x6ed9eba1
61306c7a6237 2006-05-10 Paul Eggert <eggert@cs.ucla.edu>
Simon Josefsson <simon@josefsson.org>
parents: 26244
diff changeset
283 #define K3 0x8f1bbcdc
61306c7a6237 2006-05-10 Paul Eggert <eggert@cs.ucla.edu>
Simon Josefsson <simon@josefsson.org>
parents: 26244
diff changeset
284 #define K4 0xca62c1d6
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
285
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
286 /* Round functions. Note that F2 is the same as F4. */
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
287 #define F1(B,C,D) ( D ^ ( B & ( C ^ D ) ) )
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
288 #define F2(B,C,D) (B ^ C ^ D)
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
289 #define F3(B,C,D) ( ( B & C ) | ( D & ( B | C ) ) )
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
290 #define F4(B,C,D) (B ^ C ^ D)
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
291
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
292 /* Process LEN bytes of BUFFER, accumulating context into CTX.
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
293 It is assumed that LEN % 64 == 0.
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
294 Most of this code comes from GnuPG's cipher/sha1.c. */
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
295
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
296 void
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
297 sha1_process_block (const void *buffer, size_t len, struct sha1_ctx *ctx)
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
298 {
26072
56e6483a97ab Separate sha1 from md5. Use stdint.h in both modules.
Simon Josefsson <simon@josefsson.org>
parents: 25913
diff changeset
299 const uint32_t *words = buffer;
56e6483a97ab Separate sha1 from md5. Use stdint.h in both modules.
Simon Josefsson <simon@josefsson.org>
parents: 25913
diff changeset
300 size_t nwords = len / sizeof (uint32_t);
56e6483a97ab Separate sha1 from md5. Use stdint.h in both modules.
Simon Josefsson <simon@josefsson.org>
parents: 25913
diff changeset
301 const uint32_t *endp = words + nwords;
56e6483a97ab Separate sha1 from md5. Use stdint.h in both modules.
Simon Josefsson <simon@josefsson.org>
parents: 25913
diff changeset
302 uint32_t x[16];
56e6483a97ab Separate sha1 from md5. Use stdint.h in both modules.
Simon Josefsson <simon@josefsson.org>
parents: 25913
diff changeset
303 uint32_t a = ctx->A;
56e6483a97ab Separate sha1 from md5. Use stdint.h in both modules.
Simon Josefsson <simon@josefsson.org>
parents: 25913
diff changeset
304 uint32_t b = ctx->B;
56e6483a97ab Separate sha1 from md5. Use stdint.h in both modules.
Simon Josefsson <simon@josefsson.org>
parents: 25913
diff changeset
305 uint32_t c = ctx->C;
56e6483a97ab Separate sha1 from md5. Use stdint.h in both modules.
Simon Josefsson <simon@josefsson.org>
parents: 25913
diff changeset
306 uint32_t d = ctx->D;
56e6483a97ab Separate sha1 from md5. Use stdint.h in both modules.
Simon Josefsson <simon@josefsson.org>
parents: 25913
diff changeset
307 uint32_t e = ctx->E;
36551
e44534a69277 crypto: fix bug in large buffer handling
Paul Eggert <eggert@cs.ucla.edu>
parents: 36057
diff changeset
308 uint32_t lolen = len;
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
309
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
310 /* First increment the byte count. RFC 1321 specifies the possible
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
311 length of the file up to 2^64 bits. Here we only compute the
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
312 number of bytes. Do a double word increment. */
36551
e44534a69277 crypto: fix bug in large buffer handling
Paul Eggert <eggert@cs.ucla.edu>
parents: 36057
diff changeset
313 ctx->total[0] += lolen;
e44534a69277 crypto: fix bug in large buffer handling
Paul Eggert <eggert@cs.ucla.edu>
parents: 36057
diff changeset
314 ctx->total[1] += (len >> 31 >> 1) + (ctx->total[0] < lolen);
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
315
26475
61306c7a6237 2006-05-10 Paul Eggert <eggert@cs.ucla.edu>
Simon Josefsson <simon@josefsson.org>
parents: 26244
diff changeset
316 #define rol(x, n) (((x) << (n)) | ((uint32_t) (x) >> (32 - (n))))
25913
299e806d4eb9 Merge glibc and coreutils changes into gnulib, plus a few
Paul Eggert <eggert@cs.ucla.edu>
parents: 25539
diff changeset
317
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
318 #define M(I) ( tm = x[I&0x0f] ^ x[(I-14)&0x0f] \
32112
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
319 ^ x[(I-8)&0x0f] ^ x[(I-3)&0x0f] \
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
320 , (x[I&0x0f] = rol(tm, 1)) )
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
321
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
322 #define R(A,B,C,D,E,F,K,M) do { E += rol( A, 5 ) \
32112
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
323 + F( B, C, D ) \
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
324 + K \
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
325 + M; \
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
326 B = rol( B, 30 ); \
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
327 } while(0)
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
328
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
329 while (words < endp)
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
330 {
26072
56e6483a97ab Separate sha1 from md5. Use stdint.h in both modules.
Simon Josefsson <simon@josefsson.org>
parents: 25913
diff changeset
331 uint32_t tm;
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
332 int t;
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
333 for (t = 0; t < 16; t++)
32112
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
334 {
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
335 x[t] = SWAP (*words);
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
336 words++;
dc7644a1c024 Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 31889
diff changeset
337 }
24856
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
338
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
339 R( a, b, c, d, e, F1, K1, x[ 0] );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
340 R( e, a, b, c, d, F1, K1, x[ 1] );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
341 R( d, e, a, b, c, F1, K1, x[ 2] );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
342 R( c, d, e, a, b, F1, K1, x[ 3] );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
343 R( b, c, d, e, a, F1, K1, x[ 4] );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
344 R( a, b, c, d, e, F1, K1, x[ 5] );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
345 R( e, a, b, c, d, F1, K1, x[ 6] );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
346 R( d, e, a, b, c, F1, K1, x[ 7] );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
347 R( c, d, e, a, b, F1, K1, x[ 8] );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
348 R( b, c, d, e, a, F1, K1, x[ 9] );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
349 R( a, b, c, d, e, F1, K1, x[10] );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
350 R( e, a, b, c, d, F1, K1, x[11] );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
351 R( d, e, a, b, c, F1, K1, x[12] );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
352 R( c, d, e, a, b, F1, K1, x[13] );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
353 R( b, c, d, e, a, F1, K1, x[14] );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
354 R( a, b, c, d, e, F1, K1, x[15] );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
355 R( e, a, b, c, d, F1, K1, M(16) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
356 R( d, e, a, b, c, F1, K1, M(17) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
357 R( c, d, e, a, b, F1, K1, M(18) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
358 R( b, c, d, e, a, F1, K1, M(19) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
359 R( a, b, c, d, e, F2, K2, M(20) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
360 R( e, a, b, c, d, F2, K2, M(21) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
361 R( d, e, a, b, c, F2, K2, M(22) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
362 R( c, d, e, a, b, F2, K2, M(23) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
363 R( b, c, d, e, a, F2, K2, M(24) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
364 R( a, b, c, d, e, F2, K2, M(25) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
365 R( e, a, b, c, d, F2, K2, M(26) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
366 R( d, e, a, b, c, F2, K2, M(27) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
367 R( c, d, e, a, b, F2, K2, M(28) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
368 R( b, c, d, e, a, F2, K2, M(29) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
369 R( a, b, c, d, e, F2, K2, M(30) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
370 R( e, a, b, c, d, F2, K2, M(31) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
371 R( d, e, a, b, c, F2, K2, M(32) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
372 R( c, d, e, a, b, F2, K2, M(33) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
373 R( b, c, d, e, a, F2, K2, M(34) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
374 R( a, b, c, d, e, F2, K2, M(35) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
375 R( e, a, b, c, d, F2, K2, M(36) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
376 R( d, e, a, b, c, F2, K2, M(37) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
377 R( c, d, e, a, b, F2, K2, M(38) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
378 R( b, c, d, e, a, F2, K2, M(39) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
379 R( a, b, c, d, e, F3, K3, M(40) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
380 R( e, a, b, c, d, F3, K3, M(41) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
381 R( d, e, a, b, c, F3, K3, M(42) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
382 R( c, d, e, a, b, F3, K3, M(43) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
383 R( b, c, d, e, a, F3, K3, M(44) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
384 R( a, b, c, d, e, F3, K3, M(45) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
385 R( e, a, b, c, d, F3, K3, M(46) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
386 R( d, e, a, b, c, F3, K3, M(47) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
387 R( c, d, e, a, b, F3, K3, M(48) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
388 R( b, c, d, e, a, F3, K3, M(49) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
389 R( a, b, c, d, e, F3, K3, M(50) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
390 R( e, a, b, c, d, F3, K3, M(51) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
391 R( d, e, a, b, c, F3, K3, M(52) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
392 R( c, d, e, a, b, F3, K3, M(53) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
393 R( b, c, d, e, a, F3, K3, M(54) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
394 R( a, b, c, d, e, F3, K3, M(55) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
395 R( e, a, b, c, d, F3, K3, M(56) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
396 R( d, e, a, b, c, F3, K3, M(57) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
397 R( c, d, e, a, b, F3, K3, M(58) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
398 R( b, c, d, e, a, F3, K3, M(59) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
399 R( a, b, c, d, e, F4, K4, M(60) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
400 R( e, a, b, c, d, F4, K4, M(61) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
401 R( d, e, a, b, c, F4, K4, M(62) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
402 R( c, d, e, a, b, F4, K4, M(63) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
403 R( b, c, d, e, a, F4, K4, M(64) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
404 R( a, b, c, d, e, F4, K4, M(65) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
405 R( e, a, b, c, d, F4, K4, M(66) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
406 R( d, e, a, b, c, F4, K4, M(67) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
407 R( c, d, e, a, b, F4, K4, M(68) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
408 R( b, c, d, e, a, F4, K4, M(69) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
409 R( a, b, c, d, e, F4, K4, M(70) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
410 R( e, a, b, c, d, F4, K4, M(71) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
411 R( d, e, a, b, c, F4, K4, M(72) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
412 R( c, d, e, a, b, F4, K4, M(73) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
413 R( b, c, d, e, a, F4, K4, M(74) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
414 R( a, b, c, d, e, F4, K4, M(75) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
415 R( e, a, b, c, d, F4, K4, M(76) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
416 R( d, e, a, b, c, F4, K4, M(77) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
417 R( c, d, e, a, b, F4, K4, M(78) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
418 R( b, c, d, e, a, F4, K4, M(79) );
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
419
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
420 a = ctx->A += a;
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
421 b = ctx->B += b;
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
422 c = ctx->C += c;
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
423 d = ctx->D += d;
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
424 e = ctx->E += e;
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
425 }
d1bd730b77d7 Add uint32_t.m4, uintptr_t.m4, and finish renaming sha->sha1.
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
426 }