1 /* md5.c - Compute MD5 checksum of files or strings according to the
2 * definition of MD5 in RFC 1321 from April 1992.
3 * Copyright (C) 1995-1999 Free Software Foundation, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software Foundation,
17 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 /* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu> */
21 /* Hacked to work with BusyBox by Alfred M. Szmidt <ams@trillian.itslinux.org> */
23 /* Sucked directly into opkg since the md5sum functions aren't in libbb
24 Dropped a few functions since opkg only needs md5_stream.
25 Got rid of evil, twisted defines of FALSE=1 and TRUE=0
26 6 March 2002 Carl Worth <cworth@east.isi.edu>
30 * June 29, 2001 Manuel Novoa III
32 * Added MD5SUM_SIZE_VS_SPEED configuration option.
34 * Current valid values, with data from my system for comparison, are:
35 * (using uClibc and running on linux-2.4.4.tar.bz2)
36 * user times (sec) text size (386)
37 * 0 (fastest) 1.1 6144
40 * 3 (smallest) 5.1 4912
43 #define MD5SUM_SIZE_VS_SPEED 3
45 /**********************************************************************/
54 #include <sys/types.h>
55 #if defined HAVE_LIMITS_H
61 //----------------------------------------------------------------------------
63 //----------------------------------------------------------------------------
65 /* md5.c - Functions to compute MD5 message digest of files or memory blocks
66 * according to the definition of MD5 in RFC 1321 from April 1992.
69 /* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. */
71 //----------------------------------------------------------------------------
73 //----------------------------------------------------------------------------
75 /* md5.h - Declaration of functions and data types used for MD5 sum
76 computing library functions. */
78 typedef u_int32_t md5_uint32
;
80 /* Structure to save state of computation between the single steps. */
94 * The following three functions are build up the low level used in
95 * the functions `md5_stream' and `md5_buffer'.
98 /* Initialize structure containing state of computation.
99 (RFC 1321, 3.3: Step 3) */
100 static void md5_init_ctx
__P ((struct md5_ctx
*ctx
));
102 /* Starting with the result of former calls of this function (or the
103 initialization function update the context for the next LEN bytes
105 It is necessary that LEN is a multiple of 64!!! */
106 static void md5_process_block
__P ((const void *buffer
, size_t len
,
107 struct md5_ctx
*ctx
));
109 /* Starting with the result of former calls of this function (or the
110 initialization function update the context for the next LEN bytes
112 It is NOT required that LEN is a multiple of 64. */
113 static void md5_process_bytes
__P ((const void *buffer
, size_t len
,
114 struct md5_ctx
*ctx
));
116 /* Process the remaining bytes in the buffer and put result from CTX
117 in first 16 bytes following RESBUF. The result is always in little
118 endian byte order, so that a byte-wise output yields to the wanted
119 ASCII representation of the message digest.
121 IMPORTANT: On some systems it is required that RESBUF is correctly
122 aligned for a 32 bits value. */
123 static void *md5_finish_ctx
__P ((struct md5_ctx
*ctx
, void *resbuf
));
125 //----------------------------------------------------------------------------
126 //--------end of md5.h
127 //----------------------------------------------------------------------------
129 /* Handle endian-ness */
130 #if __BYTE_ORDER == __LITTLE_ENDIAN
133 #define SWAP(n) ((n << 24) | ((n&65280)<<8) | ((n&16711680)>>8) | (n>>24))
138 #if MD5SUM_SIZE_VS_SPEED == 0
139 /* This array contains the bytes used to pad the buffer to the next
140 64-byte boundary. (RFC 1321, 3.1: Step 1) */
141 static const unsigned char fillbuf
[64] = { 0x80, 0 /* , 0, 0, ... */ };
144 /* Initialize structure containing state of computation.
145 (RFC 1321, 3.3: Step 3) */
146 void md5_init_ctx(struct md5_ctx
*ctx
)
153 ctx
->total
[0] = ctx
->total
[1] = 0;
157 /* Process the remaining bytes in the internal buffer and the usual
158 prolog according to the standard and write the result to RESBUF.
160 IMPORTANT: On some systems it is required that RESBUF is correctly
161 aligned for a 32 bits value. */
162 static void *md5_finish_ctx(struct md5_ctx
*ctx
, void *resbuf
)
164 /* Take yet unprocessed bytes into account. */
165 md5_uint32 bytes
= ctx
->buflen
;
168 /* Now count remaining bytes. */
169 ctx
->total
[0] += bytes
;
170 if (ctx
->total
[0] < bytes
)
173 pad
= bytes
>= 56 ? 64 + 56 - bytes
: 56 - bytes
;
174 #if MD5SUM_SIZE_VS_SPEED > 0
175 memset(&ctx
->buffer
[bytes
], 0, pad
);
176 ctx
->buffer
[bytes
] = 0x80;
178 memcpy(&ctx
->buffer
[bytes
], fillbuf
, pad
);
181 /* Put the 64-bit file length in *bits* at the end of the buffer. */
182 *(md5_uint32
*) & ctx
->buffer
[bytes
+ pad
] = SWAP(ctx
->total
[0] << 3);
183 *(md5_uint32
*) & ctx
->buffer
[bytes
+ pad
+ 4] =
184 SWAP( ((ctx
->total
[1] << 3) | (ctx
->total
[0] >> 29)) );
186 /* Process last bytes. */
187 md5_process_block(ctx
->buffer
, bytes
+ pad
+ 8, ctx
);
189 /* Put result from CTX in first 16 bytes following RESBUF. The result is
190 always in little endian byte order, so that a byte-wise output yields
191 to the wanted ASCII representation of the message digest.
193 IMPORTANT: On some systems it is required that RESBUF is correctly
194 aligned for a 32 bits value. */
195 ((md5_uint32
*) resbuf
)[0] = SWAP(ctx
->A
);
196 ((md5_uint32
*) resbuf
)[1] = SWAP(ctx
->B
);
197 ((md5_uint32
*) resbuf
)[2] = SWAP(ctx
->C
);
198 ((md5_uint32
*) resbuf
)[3] = SWAP(ctx
->D
);
203 /* Compute MD5 message digest for bytes read from STREAM. The
204 resulting message digest number will be written into the 16 bytes
205 beginning at RESBLOCK. */
206 int md5_stream(FILE *stream
, void *resblock
)
208 /* Important: BLOCKSIZE must be a multiple of 64. */
209 static const int BLOCKSIZE
= 4096;
211 char buffer
[BLOCKSIZE
+ 72];
214 /* Initialize the computation context. */
217 /* Iterate over full file contents. */
219 /* We read the file in blocks of BLOCKSIZE bytes. One call of the
220 computation function processes the whole buffer so that with the
221 next round of the loop another block can be read. */
225 /* Read block. Take care for partial reads. */
227 n
= fread(buffer
+ sum
, 1, BLOCKSIZE
- sum
, stream
);
231 while (sum
< BLOCKSIZE
&& n
!= 0);
232 if (n
== 0 && ferror(stream
))
235 /* If end of file is reached, end the loop. */
239 /* Process buffer with BLOCKSIZE bytes. Note that
242 md5_process_block(buffer
, BLOCKSIZE
, &ctx
);
245 /* Add the last bytes if necessary. */
247 md5_process_bytes(buffer
, sum
, &ctx
);
249 /* Construct result in desired memory. */
250 md5_finish_ctx(&ctx
, resblock
);
254 /* Compute MD5 message digest for LEN bytes beginning at BUFFER. The
255 result is always in little endian byte order, so that a byte-wise
256 output yields to the wanted ASCII representation of the message
258 void *md5_buffer(const char *buffer
, size_t len
, void *resblock
)
262 /* Initialize the computation context. */
265 /* Process whole buffer but last len % 64 bytes. */
266 md5_process_bytes(buffer
, len
, &ctx
);
268 /* Put result in desired memory area. */
269 return md5_finish_ctx(&ctx
, resblock
);
272 static void md5_process_bytes(const void *buffer
, size_t len
, struct md5_ctx
*ctx
)
274 /* When we already have some bits in our internal buffer concatenate
275 both inputs first. */
276 if (ctx
->buflen
!= 0) {
277 size_t left_over
= ctx
->buflen
;
278 size_t add
= 128 - left_over
> len
? len
: 128 - left_over
;
280 memcpy(&ctx
->buffer
[left_over
], buffer
, add
);
283 if (left_over
+ add
> 64) {
284 md5_process_block(ctx
->buffer
, (left_over
+ add
) & ~63, ctx
);
285 /* The regions in the following copy operation cannot overlap. */
286 memcpy(ctx
->buffer
, &ctx
->buffer
[(left_over
+ add
) & ~63],
287 (left_over
+ add
) & 63);
288 ctx
->buflen
= (left_over
+ add
) & 63;
291 buffer
= (const char *) buffer
+ add
;
295 /* Process available complete blocks. */
297 md5_process_block(buffer
, len
& ~63, ctx
);
298 buffer
= (const char *) buffer
+ (len
& ~63);
302 /* Move remaining bytes in internal buffer. */
304 memcpy(ctx
->buffer
, buffer
, len
);
309 /* These are the four functions used in the four steps of the MD5 algorithm
310 and defined in the RFC 1321. The first function is a little bit optimized
311 (as found in Colin Plumbs public domain implementation). */
312 /* #define FF(b, c, d) ((b & c) | (~b & d)) */
313 #define FF(b, c, d) (d ^ (b & (c ^ d)))
314 #define FG(b, c, d) FF (d, b, c)
315 #define FH(b, c, d) (b ^ c ^ d)
316 #define FI(b, c, d) (c ^ (b | ~d))
318 /* Process LEN bytes of BUFFER, accumulating context into CTX.
319 It is assumed that LEN % 64 == 0. */
320 static void md5_process_block(const void *buffer
, size_t len
, struct md5_ctx
*ctx
)
322 md5_uint32 correct_words
[16];
323 const md5_uint32
*words
= buffer
;
324 size_t nwords
= len
/ sizeof(md5_uint32
);
325 const md5_uint32
*endp
= words
+ nwords
;
326 #if MD5SUM_SIZE_VS_SPEED > 0
327 static const md5_uint32 C_array
[] = {
329 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
330 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
331 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
332 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
334 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa,
335 0xd62f105d, 0x2441453, 0xd8a1e681, 0xe7d3fbc8,
336 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,
337 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
339 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c,
340 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
341 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x4881d05,
342 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
344 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039,
345 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
346 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
347 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391
350 static const char P_array
[] = {
351 #if MD5SUM_SIZE_VS_SPEED > 1
352 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 1 */
354 1, 6, 11, 0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12, /* 2 */
355 5, 8, 11, 14, 1, 4, 7, 10, 13, 0, 3, 6, 9, 12, 15, 2, /* 3 */
356 0, 7, 14, 5, 12, 3, 10, 1, 8, 15, 6, 13, 4, 11, 2, 9 /* 4 */
359 #if MD5SUM_SIZE_VS_SPEED > 1
360 static const char S_array
[] = {
369 md5_uint32 A
= ctx
->A
;
370 md5_uint32 B
= ctx
->B
;
371 md5_uint32 C
= ctx
->C
;
372 md5_uint32 D
= ctx
->D
;
374 /* First increment the byte count. RFC 1321 specifies the possible
375 length of the file up to 2^64 bits. Here we only compute the
376 number of bytes. Do a double word increment. */
377 ctx
->total
[0] += len
;
378 if (ctx
->total
[0] < len
)
381 /* Process all bytes in the buffer with 64 bytes in each round of
383 while (words
< endp
) {
384 md5_uint32
*cwp
= correct_words
;
385 md5_uint32 A_save
= A
;
386 md5_uint32 B_save
= B
;
387 md5_uint32 C_save
= C
;
388 md5_uint32 D_save
= D
;
390 #if MD5SUM_SIZE_VS_SPEED > 1
391 #define CYCLIC(w, s) (w = (w << s) | (w >> (32 - s)))
393 const md5_uint32
*pc
;
399 for ( i
=0 ; i
< 16 ; i
++ ) {
400 cwp
[i
] = SWAP(words
[i
]);
404 #if MD5SUM_SIZE_VS_SPEED > 2
405 pc
= C_array
; pp
= P_array
; ps
= S_array
- 4;
407 for ( i
= 0 ; i
< 64 ; i
++ ) {
408 if ((i
&0x0f) == 0) ps
+= 4;
423 temp
+= cwp
[(int)(*pp
++)] + *pc
++;
424 temp
= CYCLIC (temp
, ps
[i
&3]);
426 A
= D
; D
= C
; C
= B
; B
= temp
;
429 pc
= C_array
; pp
= P_array
; ps
= S_array
;
431 for ( i
= 0 ; i
< 16 ; i
++ ) {
432 temp
= A
+ FF(B
,C
,D
) + cwp
[(int)(*pp
++)] + *pc
++;
433 temp
= CYCLIC (temp
, ps
[i
&3]);
435 A
= D
; D
= C
; C
= B
; B
= temp
;
439 for ( i
= 0 ; i
< 16 ; i
++ ) {
440 temp
= A
+ FG(B
,C
,D
) + cwp
[(int)(*pp
++)] + *pc
++;
441 temp
= CYCLIC (temp
, ps
[i
&3]);
443 A
= D
; D
= C
; C
= B
; B
= temp
;
446 for ( i
= 0 ; i
< 16 ; i
++ ) {
447 temp
= A
+ FH(B
,C
,D
) + cwp
[(int)(*pp
++)] + *pc
++;
448 temp
= CYCLIC (temp
, ps
[i
&3]);
450 A
= D
; D
= C
; C
= B
; B
= temp
;
453 for ( i
= 0 ; i
< 16 ; i
++ ) {
454 temp
= A
+ FI(B
,C
,D
) + cwp
[(int)(*pp
++)] + *pc
++;
455 temp
= CYCLIC (temp
, ps
[i
&3]);
457 A
= D
; D
= C
; C
= B
; B
= temp
;
462 /* First round: using the given function, the context and a constant
463 the next context is computed. Because the algorithms processing
464 unit is a 32-bit word and it is determined to work on words in
465 little endian byte order we perhaps have to change the byte order
466 before the computation. To reduce the work for the next steps
467 we store the swapped words in the array CORRECT_WORDS. */
469 #define OP(a, b, c, d, s, T) \
472 a += FF (b, c, d) + (*cwp++ = SWAP (*words)) + T; \
479 /* It is unfortunate that C does not provide an operator for
480 cyclic rotation. Hope the C compiler is smart enough. */
481 /* gcc 2.95.4 seems to be --aaronl */
482 #define CYCLIC(w, s) (w = (w << s) | (w >> (32 - s)))
484 /* Before we start, one word to the strange constants.
485 They are defined in RFC 1321 as
487 T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64
490 #if MD5SUM_SIZE_VS_SPEED == 1
491 const md5_uint32
*pc
;
497 #if MD5SUM_SIZE_VS_SPEED == 1
499 for ( i
=0 ; i
< 4 ; i
++ ) {
500 OP(A
, B
, C
, D
, 7, *pc
++);
501 OP(D
, A
, B
, C
, 12, *pc
++);
502 OP(C
, D
, A
, B
, 17, *pc
++);
503 OP(B
, C
, D
, A
, 22, *pc
++);
506 OP(A
, B
, C
, D
, 7, 0xd76aa478);
507 OP(D
, A
, B
, C
, 12, 0xe8c7b756);
508 OP(C
, D
, A
, B
, 17, 0x242070db);
509 OP(B
, C
, D
, A
, 22, 0xc1bdceee);
510 OP(A
, B
, C
, D
, 7, 0xf57c0faf);
511 OP(D
, A
, B
, C
, 12, 0x4787c62a);
512 OP(C
, D
, A
, B
, 17, 0xa8304613);
513 OP(B
, C
, D
, A
, 22, 0xfd469501);
514 OP(A
, B
, C
, D
, 7, 0x698098d8);
515 OP(D
, A
, B
, C
, 12, 0x8b44f7af);
516 OP(C
, D
, A
, B
, 17, 0xffff5bb1);
517 OP(B
, C
, D
, A
, 22, 0x895cd7be);
518 OP(A
, B
, C
, D
, 7, 0x6b901122);
519 OP(D
, A
, B
, C
, 12, 0xfd987193);
520 OP(C
, D
, A
, B
, 17, 0xa679438e);
521 OP(B
, C
, D
, A
, 22, 0x49b40821);
524 /* For the second to fourth round we have the possibly swapped words
525 in CORRECT_WORDS. Redefine the macro to take an additional first
526 argument specifying the function to use. */
528 #define OP(f, a, b, c, d, k, s, T) \
531 a += f (b, c, d) + correct_words[k] + T; \
538 #if MD5SUM_SIZE_VS_SPEED == 1
540 for ( i
=0 ; i
< 4 ; i
++ ) {
541 OP(FG
, A
, B
, C
, D
, (int)(*pp
++), 5, *pc
++);
542 OP(FG
, D
, A
, B
, C
, (int)(*pp
++), 9, *pc
++);
543 OP(FG
, C
, D
, A
, B
, (int)(*pp
++), 14, *pc
++);
544 OP(FG
, B
, C
, D
, A
, (int)(*pp
++), 20, *pc
++);
547 OP(FG
, A
, B
, C
, D
, 1, 5, 0xf61e2562);
548 OP(FG
, D
, A
, B
, C
, 6, 9, 0xc040b340);
549 OP(FG
, C
, D
, A
, B
, 11, 14, 0x265e5a51);
550 OP(FG
, B
, C
, D
, A
, 0, 20, 0xe9b6c7aa);
551 OP(FG
, A
, B
, C
, D
, 5, 5, 0xd62f105d);
552 OP(FG
, D
, A
, B
, C
, 10, 9, 0x02441453);
553 OP(FG
, C
, D
, A
, B
, 15, 14, 0xd8a1e681);
554 OP(FG
, B
, C
, D
, A
, 4, 20, 0xe7d3fbc8);
555 OP(FG
, A
, B
, C
, D
, 9, 5, 0x21e1cde6);
556 OP(FG
, D
, A
, B
, C
, 14, 9, 0xc33707d6);
557 OP(FG
, C
, D
, A
, B
, 3, 14, 0xf4d50d87);
558 OP(FG
, B
, C
, D
, A
, 8, 20, 0x455a14ed);
559 OP(FG
, A
, B
, C
, D
, 13, 5, 0xa9e3e905);
560 OP(FG
, D
, A
, B
, C
, 2, 9, 0xfcefa3f8);
561 OP(FG
, C
, D
, A
, B
, 7, 14, 0x676f02d9);
562 OP(FG
, B
, C
, D
, A
, 12, 20, 0x8d2a4c8a);
566 #if MD5SUM_SIZE_VS_SPEED == 1
567 for ( i
=0 ; i
< 4 ; i
++ ) {
568 OP(FH
, A
, B
, C
, D
, (int)(*pp
++), 4, *pc
++);
569 OP(FH
, D
, A
, B
, C
, (int)(*pp
++), 11, *pc
++);
570 OP(FH
, C
, D
, A
, B
, (int)(*pp
++), 16, *pc
++);
571 OP(FH
, B
, C
, D
, A
, (int)(*pp
++), 23, *pc
++);
574 OP(FH
, A
, B
, C
, D
, 5, 4, 0xfffa3942);
575 OP(FH
, D
, A
, B
, C
, 8, 11, 0x8771f681);
576 OP(FH
, C
, D
, A
, B
, 11, 16, 0x6d9d6122);
577 OP(FH
, B
, C
, D
, A
, 14, 23, 0xfde5380c);
578 OP(FH
, A
, B
, C
, D
, 1, 4, 0xa4beea44);
579 OP(FH
, D
, A
, B
, C
, 4, 11, 0x4bdecfa9);
580 OP(FH
, C
, D
, A
, B
, 7, 16, 0xf6bb4b60);
581 OP(FH
, B
, C
, D
, A
, 10, 23, 0xbebfbc70);
582 OP(FH
, A
, B
, C
, D
, 13, 4, 0x289b7ec6);
583 OP(FH
, D
, A
, B
, C
, 0, 11, 0xeaa127fa);
584 OP(FH
, C
, D
, A
, B
, 3, 16, 0xd4ef3085);
585 OP(FH
, B
, C
, D
, A
, 6, 23, 0x04881d05);
586 OP(FH
, A
, B
, C
, D
, 9, 4, 0xd9d4d039);
587 OP(FH
, D
, A
, B
, C
, 12, 11, 0xe6db99e5);
588 OP(FH
, C
, D
, A
, B
, 15, 16, 0x1fa27cf8);
589 OP(FH
, B
, C
, D
, A
, 2, 23, 0xc4ac5665);
593 #if MD5SUM_SIZE_VS_SPEED == 1
594 for ( i
=0 ; i
< 4 ; i
++ ) {
595 OP(FI
, A
, B
, C
, D
, (int)(*pp
++), 6, *pc
++);
596 OP(FI
, D
, A
, B
, C
, (int)(*pp
++), 10, *pc
++);
597 OP(FI
, C
, D
, A
, B
, (int)(*pp
++), 15, *pc
++);
598 OP(FI
, B
, C
, D
, A
, (int)(*pp
++), 21, *pc
++);
601 OP(FI
, A
, B
, C
, D
, 0, 6, 0xf4292244);
602 OP(FI
, D
, A
, B
, C
, 7, 10, 0x432aff97);
603 OP(FI
, C
, D
, A
, B
, 14, 15, 0xab9423a7);
604 OP(FI
, B
, C
, D
, A
, 5, 21, 0xfc93a039);
605 OP(FI
, A
, B
, C
, D
, 12, 6, 0x655b59c3);
606 OP(FI
, D
, A
, B
, C
, 3, 10, 0x8f0ccc92);
607 OP(FI
, C
, D
, A
, B
, 10, 15, 0xffeff47d);
608 OP(FI
, B
, C
, D
, A
, 1, 21, 0x85845dd1);
609 OP(FI
, A
, B
, C
, D
, 8, 6, 0x6fa87e4f);
610 OP(FI
, D
, A
, B
, C
, 15, 10, 0xfe2ce6e0);
611 OP(FI
, C
, D
, A
, B
, 6, 15, 0xa3014314);
612 OP(FI
, B
, C
, D
, A
, 13, 21, 0x4e0811a1);
613 OP(FI
, A
, B
, C
, D
, 4, 6, 0xf7537e82);
614 OP(FI
, D
, A
, B
, C
, 11, 10, 0xbd3af235);
615 OP(FI
, C
, D
, A
, B
, 2, 15, 0x2ad7d2bb);
616 OP(FI
, B
, C
, D
, A
, 9, 21, 0xeb86d391);
620 /* Add the starting values of the context. */
627 /* Put checksum in context given as argument. */
634 //----------------------------------------------------------------------------
635 //--------end of md5.c
636 //----------------------------------------------------------------------------
638 #define ISWHITE(c) ((c) == ' ' || (c) == '\t')
639 #define ISXDIGIT(c) (isxdigit (c))
641 /* The minimum length of a valid digest line in a file produced
642 by `md5sum FILE' and read by `md5sum -c'. This length does
643 not include any newline character at the end of a line. */
644 static const int MIN_DIGEST_LINE_LENGTH
= 35; /* 32 - message digest length
645 2 - blank and binary indicator
646 1 - minimum filename length */
648 static inline int hex_digits(unsigned char const *s
)