~ubuntu-branches/debian/squeeze/ntp/squeeze-201010051545

« back to all changes in this revision

Viewing changes to libntp/md5c.c

  • Committer: Bazaar Package Importer
  • Author(s): Matt Zimmerman
  • Date: 2004-10-11 16:10:27 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20041011161027-icyjbji8ujym633o
Tags: 1:4.2.0a-10ubuntu2
Use ntp.ubuntulinux.org instead of pool.ntp.org

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 */
25
25
 
26
26
#include "global.h"
27
 
#include "md5.h"
 
27
#ifndef HAVE_MD5INIT
 
28
#include "ntp_md5.h"
28
29
 
29
30
/* Constants for MD5Transform routine.
30
31
 */
122
123
        unsigned int inputLen             /* length of input block */
123
124
        )
124
125
{
125
 
  unsigned int i, index, partLen;
 
126
  unsigned int i, idx, partLen;
126
127
 
127
128
  /* Compute number of bytes mod 64 */
128
 
  index = (unsigned int)((context->count[0] >> 3) & 0x3F);
 
129
  idx = (unsigned int)((context->count[0] >> 3) & 0x3F);
129
130
 
130
131
  /* Update number of bits */
131
132
  if ((context->count[0] += ((UINT4)inputLen << 3))
133
134
    context->count[1]++;
134
135
  context->count[1] += ((UINT4)inputLen >> 29);
135
136
  
136
 
  partLen = 64 - index;
 
137
  partLen = 64 - idx;
137
138
  
138
139
  /* Transform as many times as possible.
139
140
   */
140
141
  if (inputLen >= partLen) {
141
142
    MD5_memcpy
142
 
      ((POINTER)&context->buffer[index], (POINTER)input, partLen);
 
143
      ((POINTER)&context->buffer[idx], (POINTER)input, partLen);
143
144
    MD5Transform (context->state, context->buffer);
144
145
  
145
146
    for (i = partLen; i + 63 < inputLen; i += 64)
146
147
      MD5Transform (context->state, &input[i]);
147
148
    
148
 
    index = 0;
 
149
    idx = 0;
149
150
  }
150
151
  else
151
152
    i = 0;
152
153
  
153
154
  /* Buffer remaining input */
154
155
  MD5_memcpy 
155
 
    ((POINTER)&context->buffer[index], (POINTER)&input[i],
 
156
    ((POINTER)&context->buffer[idx], (POINTER)&input[i],
156
157
     inputLen-i);
157
158
}
158
159
 
166
167
        )
167
168
{
168
169
  unsigned char bits[8];
169
 
  unsigned int index, padLen;
 
170
  unsigned int idx, padLen;
170
171
 
171
172
  /* Save number of bits */
172
173
  Encode (bits, context->count, 8);
173
174
 
174
175
  /* Pad out to 56 mod 64.
175
176
   */
176
 
  index = (unsigned int)((context->count[0] >> 3) & 0x3f);
177
 
  padLen = (index < 56) ? (56 - index) : (120 - index);
 
177
  idx = (unsigned int)((context->count[0] >> 3) & 0x3f);
 
178
  padLen = (idx < 56) ? (56 - idx) : (120 - idx);
178
179
  MD5Update (context, PADDING, padLen);
179
180
  
180
181
  /* Append length (before padding) */
348
349
  for (i = 0; i < len; i++)
349
350
    ((char *)output)[i] = (char)value;
350
351
}
 
352
#else
 
353
int md5_bs;
 
354
#endif