comparison src/md5.c @ 398:74fd4e045ea6 r21-2-29

Import from CVS: tag r21-2-29
author cvs
date Mon, 13 Aug 2007 11:13:30 +0200
parents 064ab7fed2e0
children b8cc9ab3f761
comparison
equal deleted inserted replaced
397:f4aeb21a5bad 398:74fd4e045ea6
108 /* This array contains the bytes used to pad the buffer to the next 108 /* This array contains the bytes used to pad the buffer to the next
109 64-byte boundary. (RFC 1321, 3.1: Step 1) */ 109 64-byte boundary. (RFC 1321, 3.1: Step 1) */
110 static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ }; 110 static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
111 111
112 112
113 static void md5_process_block (CONST void *, size_t, struct md5_ctx *); 113 static void md5_process_block (const void *, size_t, struct md5_ctx *);
114 114
115 115
116 /* Initialize structure containing state of computation. 116 /* Initialize structure containing state of computation.
117 (RFC 1321, 3.3: Step 3) */ 117 (RFC 1321, 3.3: Step 3) */
118 static void 118 static void
131 must be in little endian byte order. 131 must be in little endian byte order.
132 132
133 IMPORTANT: On some systems it is required that RESBUF is correctly 133 IMPORTANT: On some systems it is required that RESBUF is correctly
134 aligned for a 32 bits value. */ 134 aligned for a 32 bits value. */
135 static void * 135 static void *
136 md5_read_ctx (CONST struct md5_ctx *ctx, void *resbuf) 136 md5_read_ctx (const struct md5_ctx *ctx, void *resbuf)
137 { 137 {
138 ((md5_uint32 *) resbuf)[0] = SWAP (ctx->A); 138 ((md5_uint32 *) resbuf)[0] = SWAP (ctx->A);
139 ((md5_uint32 *) resbuf)[1] = SWAP (ctx->B); 139 ((md5_uint32 *) resbuf)[1] = SWAP (ctx->B);
140 ((md5_uint32 *) resbuf)[2] = SWAP (ctx->C); 140 ((md5_uint32 *) resbuf)[2] = SWAP (ctx->C);
141 ((md5_uint32 *) resbuf)[3] = SWAP (ctx->D); 141 ((md5_uint32 *) resbuf)[3] = SWAP (ctx->D);
249 } 249 }
250 #endif /* not emacs */ 250 #endif /* not emacs */
251 251
252 252
253 static void 253 static void
254 md5_process_bytes (CONST void *buffer, size_t len, struct md5_ctx *ctx) 254 md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx)
255 { 255 {
256 /* When we already have some bits in our internal buffer concatenate 256 /* When we already have some bits in our internal buffer concatenate
257 both inputs first. */ 257 both inputs first. */
258 if (ctx->buflen != 0) 258 if (ctx->buflen != 0)
259 { 259 {
304 304
305 /* Process LEN bytes of BUFFER, accumulating context into CTX. 305 /* Process LEN bytes of BUFFER, accumulating context into CTX.
306 It is assumed that LEN % 64 == 0. */ 306 It is assumed that LEN % 64 == 0. */
307 307
308 static void 308 static void
309 md5_process_block (CONST void *buffer, size_t len, struct md5_ctx *ctx) 309 md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx)
310 { 310 {
311 md5_uint32 correct_words[16]; 311 md5_uint32 correct_words[16];
312 const md5_uint32 *words = (const md5_uint32 *) buffer; 312 const md5_uint32 *words = (const md5_uint32 *) buffer;
313 size_t nwords = len / sizeof (md5_uint32); 313 size_t nwords = len / sizeof (md5_uint32);
314 const md5_uint32 *endp = words + nwords; 314 const md5_uint32 *endp = words + nwords;
480 } 480 }
481 else 481 else
482 { 482 {
483 /* Attempt to autodetect the coding of the string. This is 483 /* Attempt to autodetect the coding of the string. This is
484 VERY hit-and-miss. */ 484 VERY hit-and-miss. */
485 enum eol_type eol = EOL_AUTODETECT; 485 eol_type_t eol = EOL_AUTODETECT;
486 coding_system = Fget_coding_system (Qundecided); 486 coding_system = Fget_coding_system (Qundecided);
487 determine_real_coding_system (XLSTREAM (istream), 487 determine_real_coding_system (XLSTREAM (istream),
488 &coding_system, &eol); 488 &coding_system, &eol);
489 } 489 }
490 if (NILP (coding_system)) 490 if (NILP (coding_system))
580 580
581 /* Get the data while doing the conversion. */ 581 /* Get the data while doing the conversion. */
582 while (1) 582 while (1)
583 { 583 {
584 Bufbyte tempbuf[1024]; /* some random amount */ 584 Bufbyte tempbuf[1024]; /* some random amount */
585 int size_in_bytes = Lstream_read (XLSTREAM (instream), 585 ssize_t size_in_bytes =
586 tempbuf, sizeof (tempbuf)); 586 Lstream_read (XLSTREAM (instream), tempbuf, sizeof (tempbuf));
587 if (!size_in_bytes) 587 if (!size_in_bytes)
588 break; 588 break;
589 589
590 /* Process the bytes. */ 590 /* Process the bytes. */
591 md5_process_bytes (tempbuf, size_in_bytes, &ctx); 591 md5_process_bytes (tempbuf, size_in_bytes, &ctx);