annotate md5.c @ 87:1a6394166cce src

Document warnings generated by DVDs made with the VDR-to-DVD device LG RC590M. Patch by Paul Menzel <paulepanter AT users DOT sourceforge DOT net>.
author rathann
date Tue, 12 Nov 2013 00:10:38 +0000
parents 9f1804080f76
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
1 /* md5.c - Functions to compute MD5 message digest of files or memory blocks
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
2 according to the definition of MD5 in RFC 1321 from April 1992.
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
3 Copyright (C) 1995, 1996, 2001 Free Software Foundation, Inc.
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
4 NOTE: The canonical source of this file is maintained with the GNU C
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
5 Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu.
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
6
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
7 This program is free software; you can redistribute it and/or modify it
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
10 later version.
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
11
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
12 This program is distributed in the hope that it will be useful,
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
15 GNU General Public License for more details.
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
16
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
18 along with this program; if not, write to the Free Software Foundation,
21
4aa618ae094f Use consistent license headers everywhere: Fix FSF address and boilerplate.
diego
parents: 3
diff changeset
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
3
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
20
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
21 /* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
22
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
23 #include <sys/types.h>
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
24
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
25 #include <stdlib.h>
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
26 #include <string.h>
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
27
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
28 #include "md5.h"
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
29 /* #include "unlocked-io.h" */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
30
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
31 #ifdef _LIBC
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
32 # include <endian.h>
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
33 # if __BYTE_ORDER == __BIG_ENDIAN
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
34 # define WORDS_BIGENDIAN 1
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
35 # endif
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
36 #endif
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
37
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
38 #ifdef WORDS_BIGENDIAN
26
0d82d0f30c98 cosmetics: Convert all tabs to spaces.
diego
parents: 21
diff changeset
39 # define SWAP(n) \
27
98951f8ec89c cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents: 26
diff changeset
40 (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24))
3
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
41 #else
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
42 # define SWAP(n) (n)
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
43 #endif
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
44
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
45
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
46 /* This array contains the bytes used to pad the buffer to the next
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
47 64-byte boundary. (RFC 1321, 3.1: Step 1) */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
48 static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
49
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
50
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
51 /* Initialize structure containing state of computation.
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
52 (RFC 1321, 3.3: Step 3) */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
53 void
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
54 md5_init_ctx (ctx)
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
55 struct md5_ctx *ctx;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
56 {
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
57 ctx->A = 0x67452301;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
58 ctx->B = 0xefcdab89;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
59 ctx->C = 0x98badcfe;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
60 ctx->D = 0x10325476;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
61
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
62 ctx->total[0] = ctx->total[1] = 0;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
63 ctx->buflen = 0;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
64 }
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
65
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
66 /* Put result from CTX in first 16 bytes following RESBUF. The result
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
67 must be in little endian byte order.
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
68
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
69 IMPORTANT: On some systems it is required that RESBUF is correctly
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
70 aligned for a 32 bits value. */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
71 void *
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
72 md5_read_ctx (ctx, resbuf)
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
73 const struct md5_ctx *ctx;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
74 void *resbuf;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
75 {
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
76 ((md5_uint32 *) resbuf)[0] = SWAP (ctx->A);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
77 ((md5_uint32 *) resbuf)[1] = SWAP (ctx->B);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
78 ((md5_uint32 *) resbuf)[2] = SWAP (ctx->C);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
79 ((md5_uint32 *) resbuf)[3] = SWAP (ctx->D);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
80
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
81 return resbuf;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
82 }
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
83
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
84 /* Process the remaining bytes in the internal buffer and the usual
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
85 prolog according to the standard and write the result to RESBUF.
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
86
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
87 IMPORTANT: On some systems it is required that RESBUF is correctly
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
88 aligned for a 32 bits value. */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
89 void *
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
90 md5_finish_ctx (ctx, resbuf)
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
91 struct md5_ctx *ctx;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
92 void *resbuf;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
93 {
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
94 /* Take yet unprocessed bytes into account. */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
95 md5_uint32 bytes = ctx->buflen;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
96 size_t pad;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
97
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
98 /* Now count remaining bytes. */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
99 ctx->total[0] += bytes;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
100 if (ctx->total[0] < bytes)
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
101 ++ctx->total[1];
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
102
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
103 pad = bytes >= 56 ? 64 + 56 - bytes : 56 - bytes;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
104 memcpy (&ctx->buffer[bytes], fillbuf, pad);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
105
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
106 /* Put the 64-bit file length in *bits* at the end of the buffer. */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
107 *(md5_uint32 *) &ctx->buffer[bytes + pad] = SWAP (ctx->total[0] << 3);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
108 *(md5_uint32 *) &ctx->buffer[bytes + pad + 4] = SWAP ((ctx->total[1] << 3) |
26
0d82d0f30c98 cosmetics: Convert all tabs to spaces.
diego
parents: 21
diff changeset
109 (ctx->total[0] >> 29));
3
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
110
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
111 /* Process last bytes. */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
112 md5_process_block (ctx->buffer, bytes + pad + 8, ctx);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
113
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
114 return md5_read_ctx (ctx, resbuf);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
115 }
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
116
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
117 /* Compute MD5 message digest for bytes read from STREAM. The
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
118 resulting message digest number will be written into the 16 bytes
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
119 beginning at RESBLOCK. */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
120 int
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
121 md5_stream (stream, resblock)
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
122 FILE *stream;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
123 void *resblock;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
124 {
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
125 /* Important: BLOCKSIZE must be a multiple of 64. */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
126 #define BLOCKSIZE 4096
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
127 struct md5_ctx ctx;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
128 char buffer[BLOCKSIZE + 72];
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
129 size_t sum;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
130
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
131 /* Initialize the computation context. */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
132 md5_init_ctx (&ctx);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
133
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
134 /* Iterate over full file contents. */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
135 while (1)
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
136 {
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
137 /* We read the file in blocks of BLOCKSIZE bytes. One call of the
26
0d82d0f30c98 cosmetics: Convert all tabs to spaces.
diego
parents: 21
diff changeset
138 computation function processes the whole buffer so that with the
0d82d0f30c98 cosmetics: Convert all tabs to spaces.
diego
parents: 21
diff changeset
139 next round of the loop another block can be read. */
3
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
140 size_t n;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
141 sum = 0;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
142
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
143 /* Read block. Take care for partial reads. */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
144 do
26
0d82d0f30c98 cosmetics: Convert all tabs to spaces.
diego
parents: 21
diff changeset
145 {
0d82d0f30c98 cosmetics: Convert all tabs to spaces.
diego
parents: 21
diff changeset
146 n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream);
3
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
147
26
0d82d0f30c98 cosmetics: Convert all tabs to spaces.
diego
parents: 21
diff changeset
148 sum += n;
0d82d0f30c98 cosmetics: Convert all tabs to spaces.
diego
parents: 21
diff changeset
149 }
3
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
150 while (sum < BLOCKSIZE && n != 0);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
151 if (n == 0 && ferror (stream))
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
152 return 1;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
153
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
154 /* If end of file is reached, end the loop. */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
155 if (n == 0)
26
0d82d0f30c98 cosmetics: Convert all tabs to spaces.
diego
parents: 21
diff changeset
156 break;
3
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
157
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
158 /* Process buffer with BLOCKSIZE bytes. Note that
27
98951f8ec89c cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents: 26
diff changeset
159 BLOCKSIZE % 64 == 0
3
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
160 */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
161 md5_process_block (buffer, BLOCKSIZE, &ctx);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
162 }
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
163
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
164 /* Add the last bytes if necessary. */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
165 if (sum > 0)
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
166 md5_process_bytes (buffer, sum, &ctx);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
167
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
168 /* Construct result in desired memory. */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
169 md5_finish_ctx (&ctx, resblock);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
170 return 0;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
171 }
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
172
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
173 /* Compute MD5 message digest for LEN bytes beginning at BUFFER. The
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
174 result is always in little endian byte order, so that a byte-wise
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
175 output yields to the wanted ASCII representation of the message
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
176 digest. */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
177 void *
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
178 md5_buffer (buffer, len, resblock)
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
179 const char *buffer;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
180 size_t len;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
181 void *resblock;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
182 {
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
183 struct md5_ctx ctx;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
184
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
185 /* Initialize the computation context. */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
186 md5_init_ctx (&ctx);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
187
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
188 /* Process whole buffer but last len % 64 bytes. */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
189 md5_process_bytes (buffer, len, &ctx);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
190
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
191 /* Put result in desired memory area. */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
192 return md5_finish_ctx (&ctx, resblock);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
193 }
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
194
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
195
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
196 void
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
197 md5_process_bytes (buffer, len, ctx)
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
198 const void *buffer;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
199 size_t len;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
200 struct md5_ctx *ctx;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
201 {
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
202 /* When we already have some bits in our internal buffer concatenate
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
203 both inputs first. */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
204 if (ctx->buflen != 0)
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
205 {
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
206 size_t left_over = ctx->buflen;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
207 size_t add = 128 - left_over > len ? len : 128 - left_over;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
208
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
209 memcpy (&ctx->buffer[left_over], buffer, add);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
210 ctx->buflen += add;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
211
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
212 if (left_over + add > 64)
26
0d82d0f30c98 cosmetics: Convert all tabs to spaces.
diego
parents: 21
diff changeset
213 {
0d82d0f30c98 cosmetics: Convert all tabs to spaces.
diego
parents: 21
diff changeset
214 md5_process_block (ctx->buffer, (left_over + add) & ~63, ctx);
0d82d0f30c98 cosmetics: Convert all tabs to spaces.
diego
parents: 21
diff changeset
215 /* The regions in the following copy operation cannot overlap. */
0d82d0f30c98 cosmetics: Convert all tabs to spaces.
diego
parents: 21
diff changeset
216 memcpy (ctx->buffer, &ctx->buffer[(left_over + add) & ~63],
0d82d0f30c98 cosmetics: Convert all tabs to spaces.
diego
parents: 21
diff changeset
217 (left_over + add) & 63);
0d82d0f30c98 cosmetics: Convert all tabs to spaces.
diego
parents: 21
diff changeset
218 ctx->buflen = (left_over + add) & 63;
0d82d0f30c98 cosmetics: Convert all tabs to spaces.
diego
parents: 21
diff changeset
219 }
3
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
220
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
221 buffer = (const char *) buffer + add;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
222 len -= add;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
223 }
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
224
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
225 /* Process available complete blocks. */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
226 if (len > 64)
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
227 {
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
228 md5_process_block (buffer, len & ~63, ctx);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
229 buffer = (const char *) buffer + (len & ~63);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
230 len &= 63;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
231 }
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
232
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
233 /* Move remaining bytes in internal buffer. */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
234 if (len > 0)
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
235 {
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
236 memcpy (ctx->buffer, buffer, len);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
237 ctx->buflen = len;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
238 }
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
239 }
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
240
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
241
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
242 /* These are the four functions used in the four steps of the MD5 algorithm
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
243 and defined in the RFC 1321. The first function is a little bit optimized
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
244 (as found in Colin Plumbs public domain implementation). */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
245 /* #define FF(b, c, d) ((b & c) | (~b & d)) */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
246 #define FF(b, c, d) (d ^ (b & (c ^ d)))
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
247 #define FG(b, c, d) FF (d, b, c)
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
248 #define FH(b, c, d) (b ^ c ^ d)
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
249 #define FI(b, c, d) (c ^ (b | ~d))
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
250
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
251 /* Process LEN bytes of BUFFER, accumulating context into CTX.
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
252 It is assumed that LEN % 64 == 0. */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
253
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
254 void
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
255 md5_process_block (buffer, len, ctx)
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
256 const void *buffer;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
257 size_t len;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
258 struct md5_ctx *ctx;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
259 {
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
260 md5_uint32 correct_words[16];
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
261 const md5_uint32 *words = buffer;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
262 size_t nwords = len / sizeof (md5_uint32);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
263 const md5_uint32 *endp = words + nwords;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
264 md5_uint32 A = ctx->A;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
265 md5_uint32 B = ctx->B;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
266 md5_uint32 C = ctx->C;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
267 md5_uint32 D = ctx->D;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
268
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
269 /* First increment the byte count. RFC 1321 specifies the possible
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
270 length of the file up to 2^64 bits. Here we only compute the
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
271 number of bytes. Do a double word increment. */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
272 ctx->total[0] += len;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
273 if (ctx->total[0] < len)
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
274 ++ctx->total[1];
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
275
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
276 /* Process all bytes in the buffer with 64 bytes in each round of
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
277 the loop. */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
278 while (words < endp)
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
279 {
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
280 md5_uint32 *cwp = correct_words;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
281 md5_uint32 A_save = A;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
282 md5_uint32 B_save = B;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
283 md5_uint32 C_save = C;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
284 md5_uint32 D_save = D;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
285
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
286 /* First round: using the given function, the context and a constant
26
0d82d0f30c98 cosmetics: Convert all tabs to spaces.
diego
parents: 21
diff changeset
287 the next context is computed. Because the algorithms processing
0d82d0f30c98 cosmetics: Convert all tabs to spaces.
diego
parents: 21
diff changeset
288 unit is a 32-bit word and it is determined to work on words in
0d82d0f30c98 cosmetics: Convert all tabs to spaces.
diego
parents: 21
diff changeset
289 little endian byte order we perhaps have to change the byte order
0d82d0f30c98 cosmetics: Convert all tabs to spaces.
diego
parents: 21
diff changeset
290 before the computation. To reduce the work for the next steps
0d82d0f30c98 cosmetics: Convert all tabs to spaces.
diego
parents: 21
diff changeset
291 we store the swapped words in the array CORRECT_WORDS. */
3
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
292
27
98951f8ec89c cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents: 26
diff changeset
293 #define OP(a, b, c, d, s, T) \
98951f8ec89c cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents: 26
diff changeset
294 do \
98951f8ec89c cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents: 26
diff changeset
295 { \
98951f8ec89c cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents: 26
diff changeset
296 a += FF (b, c, d) + (*cwp++ = SWAP (*words)) + T; \
98951f8ec89c cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents: 26
diff changeset
297 ++words; \
98951f8ec89c cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents: 26
diff changeset
298 a = rol (a, s); \
98951f8ec89c cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents: 26
diff changeset
299 a += b; \
98951f8ec89c cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents: 26
diff changeset
300 } \
3
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
301 while (0)
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
302
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
303 /* Before we start, one word to the strange constants.
26
0d82d0f30c98 cosmetics: Convert all tabs to spaces.
diego
parents: 21
diff changeset
304 They are defined in RFC 1321 as
3
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
305
26
0d82d0f30c98 cosmetics: Convert all tabs to spaces.
diego
parents: 21
diff changeset
306 T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64, or
0d82d0f30c98 cosmetics: Convert all tabs to spaces.
diego
parents: 21
diff changeset
307 perl -e 'foreach(1..64){printf "0x%08x\n", int (4294967296 * abs (sin $_))}'
3
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
308 */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
309
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
310 /* Round 1. */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
311 OP (A, B, C, D, 7, 0xd76aa478);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
312 OP (D, A, B, C, 12, 0xe8c7b756);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
313 OP (C, D, A, B, 17, 0x242070db);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
314 OP (B, C, D, A, 22, 0xc1bdceee);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
315 OP (A, B, C, D, 7, 0xf57c0faf);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
316 OP (D, A, B, C, 12, 0x4787c62a);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
317 OP (C, D, A, B, 17, 0xa8304613);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
318 OP (B, C, D, A, 22, 0xfd469501);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
319 OP (A, B, C, D, 7, 0x698098d8);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
320 OP (D, A, B, C, 12, 0x8b44f7af);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
321 OP (C, D, A, B, 17, 0xffff5bb1);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
322 OP (B, C, D, A, 22, 0x895cd7be);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
323 OP (A, B, C, D, 7, 0x6b901122);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
324 OP (D, A, B, C, 12, 0xfd987193);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
325 OP (C, D, A, B, 17, 0xa679438e);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
326 OP (B, C, D, A, 22, 0x49b40821);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
327
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
328 /* For the second to fourth round we have the possibly swapped words
26
0d82d0f30c98 cosmetics: Convert all tabs to spaces.
diego
parents: 21
diff changeset
329 in CORRECT_WORDS. Redefine the macro to take an additional first
0d82d0f30c98 cosmetics: Convert all tabs to spaces.
diego
parents: 21
diff changeset
330 argument specifying the function to use. */
3
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
331 #undef OP
27
98951f8ec89c cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents: 26
diff changeset
332 #define OP(f, a, b, c, d, k, s, T) \
98951f8ec89c cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents: 26
diff changeset
333 do \
98951f8ec89c cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents: 26
diff changeset
334 { \
98951f8ec89c cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents: 26
diff changeset
335 a += f (b, c, d) + correct_words[k] + T; \
98951f8ec89c cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents: 26
diff changeset
336 a = rol (a, s); \
98951f8ec89c cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents: 26
diff changeset
337 a += b; \
98951f8ec89c cosmetics: Sync indentation and similar changes from libdvdread 0.9.5.
diego
parents: 26
diff changeset
338 } \
3
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
339 while (0)
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
340
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
341 /* Round 2. */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
342 OP (FG, A, B, C, D, 1, 5, 0xf61e2562);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
343 OP (FG, D, A, B, C, 6, 9, 0xc040b340);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
344 OP (FG, C, D, A, B, 11, 14, 0x265e5a51);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
345 OP (FG, B, C, D, A, 0, 20, 0xe9b6c7aa);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
346 OP (FG, A, B, C, D, 5, 5, 0xd62f105d);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
347 OP (FG, D, A, B, C, 10, 9, 0x02441453);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
348 OP (FG, C, D, A, B, 15, 14, 0xd8a1e681);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
349 OP (FG, B, C, D, A, 4, 20, 0xe7d3fbc8);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
350 OP (FG, A, B, C, D, 9, 5, 0x21e1cde6);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
351 OP (FG, D, A, B, C, 14, 9, 0xc33707d6);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
352 OP (FG, C, D, A, B, 3, 14, 0xf4d50d87);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
353 OP (FG, B, C, D, A, 8, 20, 0x455a14ed);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
354 OP (FG, A, B, C, D, 13, 5, 0xa9e3e905);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
355 OP (FG, D, A, B, C, 2, 9, 0xfcefa3f8);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
356 OP (FG, C, D, A, B, 7, 14, 0x676f02d9);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
357 OP (FG, B, C, D, A, 12, 20, 0x8d2a4c8a);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
358
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
359 /* Round 3. */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
360 OP (FH, A, B, C, D, 5, 4, 0xfffa3942);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
361 OP (FH, D, A, B, C, 8, 11, 0x8771f681);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
362 OP (FH, C, D, A, B, 11, 16, 0x6d9d6122);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
363 OP (FH, B, C, D, A, 14, 23, 0xfde5380c);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
364 OP (FH, A, B, C, D, 1, 4, 0xa4beea44);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
365 OP (FH, D, A, B, C, 4, 11, 0x4bdecfa9);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
366 OP (FH, C, D, A, B, 7, 16, 0xf6bb4b60);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
367 OP (FH, B, C, D, A, 10, 23, 0xbebfbc70);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
368 OP (FH, A, B, C, D, 13, 4, 0x289b7ec6);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
369 OP (FH, D, A, B, C, 0, 11, 0xeaa127fa);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
370 OP (FH, C, D, A, B, 3, 16, 0xd4ef3085);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
371 OP (FH, B, C, D, A, 6, 23, 0x04881d05);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
372 OP (FH, A, B, C, D, 9, 4, 0xd9d4d039);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
373 OP (FH, D, A, B, C, 12, 11, 0xe6db99e5);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
374 OP (FH, C, D, A, B, 15, 16, 0x1fa27cf8);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
375 OP (FH, B, C, D, A, 2, 23, 0xc4ac5665);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
376
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
377 /* Round 4. */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
378 OP (FI, A, B, C, D, 0, 6, 0xf4292244);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
379 OP (FI, D, A, B, C, 7, 10, 0x432aff97);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
380 OP (FI, C, D, A, B, 14, 15, 0xab9423a7);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
381 OP (FI, B, C, D, A, 5, 21, 0xfc93a039);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
382 OP (FI, A, B, C, D, 12, 6, 0x655b59c3);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
383 OP (FI, D, A, B, C, 3, 10, 0x8f0ccc92);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
384 OP (FI, C, D, A, B, 10, 15, 0xffeff47d);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
385 OP (FI, B, C, D, A, 1, 21, 0x85845dd1);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
386 OP (FI, A, B, C, D, 8, 6, 0x6fa87e4f);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
387 OP (FI, D, A, B, C, 15, 10, 0xfe2ce6e0);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
388 OP (FI, C, D, A, B, 6, 15, 0xa3014314);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
389 OP (FI, B, C, D, A, 13, 21, 0x4e0811a1);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
390 OP (FI, A, B, C, D, 4, 6, 0xf7537e82);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
391 OP (FI, D, A, B, C, 11, 10, 0xbd3af235);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
392 OP (FI, C, D, A, B, 2, 15, 0x2ad7d2bb);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
393 OP (FI, B, C, D, A, 9, 21, 0xeb86d391);
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
394
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
395 /* Add the starting values of the context. */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
396 A += A_save;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
397 B += B_save;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
398 C += C_save;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
399 D += D_save;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
400 }
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
401
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
402 /* Put checksum in context given as argument. */
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
403 ctx->A = A;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
404 ctx->B = B;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
405 ctx->C = C;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
406 ctx->D = D;
fdbae45c30fc moved to src/ the sources files
nicodvb
parents:
diff changeset
407 }