~ubuntu-branches/debian/sid/gnubg/sid

« back to all changes in this revision

Viewing changes to lib/md5.c

  • Committer: Bazaar Package Importer
  • Author(s): Russ Allbery
  • Date: 2006-12-28 10:45:05 UTC
  • mfrom: (2.1.5 feisty)
  • Revision ID: james.westby@ubuntu.com-20061228104505-4p6sxxdosrlvhgpr
Tags: 0.14.3+20060923-4
* Translation updates:
  - French, thanks Thomas Huriaux.  (Closes: #404254)
  - Spanish, thanks Javier Ruano.  (Closes: #404613)

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 * along with this program; if not, write to the Free Software
23
23
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24
24
 *
25
 
 * $Id: md5.c,v 1.2 2001/03/29 17:25:36 gtw Exp $
 
25
 * $Id: md5.c,v 1.4 2006/09/21 22:24:45 Superfly_Jon Exp $
26
26
 */
27
27
 
28
28
/* License changed from the GNU LGPL to the GNU GPL (as permitted
62
62
 
63
63
/* This array contains the bytes used to pad the buffer to the next
64
64
   64-byte boundary.  (RFC 1321, 3.1: Step 1)  */
 
65
/* But this isn't used ???? */
65
66
static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ...  */ };
66
67
 
67
68
 
68
69
/* Initialize structure containing state of computation.
69
70
   (RFC 1321, 3.3: Step 3)  */
70
71
void
71
 
md5_init_ctx (ctx)
72
 
     struct md5_ctx *ctx;
 
72
md5_init_ctx (struct md5_ctx *ctx)
73
73
{
74
74
  ctx->A = 0x67452301;
75
75
  ctx->B = 0xefcdab89;
86
86
   IMPORTANT: On some systems it is required that RESBUF is correctly
87
87
   aligned for a 32 bits value.  */
88
88
void *
89
 
md5_read_ctx (ctx, resbuf)
90
 
     const struct md5_ctx *ctx;
91
 
     void *resbuf;
 
89
md5_read_ctx (const struct md5_ctx *ctx, void *resbuf)
92
90
{
93
91
  char *r = resbuf;
94
92
  WRITE (r, ctx->A);
230
228
      add -= add % sizeof (md5_uint32);
231
229
 
232
230
      memcpy (&ctx->buffer[left_over], buffer, add);
233
 
      ctx->buflen += add;
 
231
      ctx->buflen += (md5_uint32)add;
234
232
 
235
233
      if (ctx->buflen > 64)
236
234
        {
267
265
          left_over -= 64;
268
266
          memcpy (ctx->buffer, &ctx->buffer[64], left_over);
269
267
        }
270
 
      ctx->buflen = left_over;
 
268
      ctx->buflen = (md5_uint32)left_over;
271
269
    }
272
270
}
273
271
 
302
300
  /* First increment the byte count.  RFC 1321 specifies the possible
303
301
     length of the file up to 2^64 bits.  Here we only compute the
304
302
     number of bytes.  Do a double word increment.  */
305
 
  ctx->total[0] += len;
 
303
  ctx->total[0] += (md5_uint32)len;
306
304
  if (ctx->total[0] < len)
307
305
    ++ctx->total[1];
308
306