cryptlib  3.4.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros
md32com.h
Go to the documentation of this file.
1 /* crypto/md32_common.h */
2 /* ====================================================================
3  * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in
14  * the documentation and/or other materials provided with the
15  * distribution.
16  *
17  * 3. All advertising materials mentioning features or use of this
18  * software must display the following acknowledgment:
19  * "This product includes software developed by the OpenSSL Project
20  * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
21  *
22  * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23  * endorse or promote products derived from this software without
24  * prior written permission. For written permission, please contact
26  *
27  * 5. Products derived from this software may not be called "OpenSSL"
28  * nor may "OpenSSL" appear in their names without prior written
29  * permission of the OpenSSL Project.
30  *
31  * 6. Redistributions of any form whatsoever must retain the following
32  * acknowledgment:
33  * "This product includes software developed by the OpenSSL Project
34  * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
35  *
36  * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47  * OF THE POSSIBILITY OF SUCH DAMAGE.
48  * ====================================================================
49  *
50  * This product includes cryptographic software written by Eric Young
51  * ([email protected]). This product includes software written by Tim
52  * Hudson ([email protected]).
53  *
54  */
55 
56 /*
57  * This is a generic 32 bit "collector" for message digest algorithms.
58  * Whenever needed it collects input character stream into chunks of
59  * 32 bit values and invokes a block function that performs actual hash
60  * calculations.
61  *
62  * Porting guide.
63  *
64  * Obligatory macros:
65  *
66  * DATA_ORDER_IS_BIG_ENDIAN or DATA_ORDER_IS_LITTLE_ENDIAN
67  * this macro defines byte order of input stream.
68  * HASH_CBLOCK
69  * size of a unit chunk HASH_BLOCK operates on.
70  * HASH_LONG
71  * has to be at lest 32 bit wide, if it's wider, then
72  * HASH_LONG_LOG2 *has to* be defined along
73  * HASH_CTX
74  * context structure that at least contains following
75  * members:
76  * typedef struct {
77  * ...
78  * HASH_LONG Nl,Nh;
79  * HASH_LONG data[HASH_LBLOCK];
80  * int num;
81  * ...
82  * } HASH_CTX;
83  * HASH_UPDATE
84  * name of "Update" function, implemented here.
85  * HASH_TRANSFORM
86  * name of "Transform" function, implemented here.
87  * HASH_FINAL
88  * name of "Final" function, implemented here.
89  * HASH_BLOCK_HOST_ORDER
90  * name of "block" function treating *aligned* input message
91  * in host byte order, implemented externally.
92  * HASH_BLOCK_DATA_ORDER
93  * name of "block" function treating *unaligned* input message
94  * in original (data) byte order, implemented externally (it
95  * actually is optional if data and host are of the same
96  * "endianess").
97  * HASH_MAKE_STRING
98  * macro convering context variables to an ASCII hash string.
99  *
100  * Optional macros:
101  *
102  * B_ENDIAN or L_ENDIAN
103  * defines host byte-order.
104  * HASH_LONG_LOG2
105  * defaults to 2 if not states otherwise.
106  * HASH_LBLOCK
107  * assumed to be HASH_CBLOCK/4 if not stated otherwise.
108  * HASH_BLOCK_DATA_ORDER_ALIGNED
109  * alternative "block" function capable of treating
110  * aligned input message in original (data) order,
111  * implemented externally.
112  *
113  * MD5 example:
114  *
115  * #define DATA_ORDER_IS_LITTLE_ENDIAN
116  *
117  * #define HASH_LONG MD5_LONG
118  * #define HASH_LONG_LOG2 MD5_LONG_LOG2
119  * #define HASH_CTX MD5_CTX
120  * #define HASH_CBLOCK MD5_CBLOCK
121  * #define HASH_LBLOCK MD5_LBLOCK
122  * #define HASH_UPDATE MD5_Update
123  * #define HASH_TRANSFORM MD5_Transform
124  * #define HASH_FINAL MD5_Final
125  * #define HASH_BLOCK_HOST_ORDER md5_block_host_order
126  * #define HASH_BLOCK_DATA_ORDER md5_block_data_order
127  *
129  */
130 
131 #if defined( _MSC_VER )
132  #pragma warning( disable: 4311 ) /* Warning about ugly 32-bit align ptr.cast - pcg */
133 #endif /* VC++ */
134 
135 #if !defined(DATA_ORDER_IS_BIG_ENDIAN) && !defined(DATA_ORDER_IS_LITTLE_ENDIAN)
136 #error "DATA_ORDER must be defined!"
137 #endif
138 
139 #ifndef HASH_CBLOCK
140 #error "HASH_CBLOCK must be defined!"
141 #endif
142 #ifndef HASH_LONG
143 #error "HASH_LONG must be defined!"
144 #endif
145 #ifndef HASH_CTX
146 #error "HASH_CTX must be defined!"
147 #endif
148 
149 #ifndef HASH_UPDATE
150 #error "HASH_UPDATE must be defined!"
151 #endif
152 #ifndef HASH_TRANSFORM
153 #error "HASH_TRANSFORM must be defined!"
154 #endif
155 #ifndef HASH_FINAL
156 #error "HASH_FINAL must be defined!"
157 #endif
158 
159 #ifndef HASH_BLOCK_HOST_ORDER
160 #error "HASH_BLOCK_HOST_ORDER must be defined!"
161 #endif
162 
163 #if 0
164 /*
165  * Moved below as it's required only if HASH_BLOCK_DATA_ORDER_ALIGNED
166  * isn't defined.
167  */
168 #ifndef HASH_BLOCK_DATA_ORDER
169 #error "HASH_BLOCK_DATA_ORDER must be defined!"
170 #endif
171 #endif
172 
173 #ifndef HASH_LBLOCK
174 #define HASH_LBLOCK (HASH_CBLOCK/4)
175 #endif
176 
177 #ifndef HASH_LONG_LOG2
178 #define HASH_LONG_LOG2 2
179 #endif
180 
181 /*
182  * Engage compiler specific rotate intrinsic function if available.
183  */
184 #undef ROTATE
185 #ifndef PEDANTIC
186 # if defined(_MSC_VER) || defined( __BORLANDC__ )
187 # define ROTATE(a,n) _lrotl(a,n)
188 # elif defined(__MWERKS__)
189 # if defined(__POWERPC__)
190 # define ROTATE(a,n) __rlwinm(a,n,0,31)
191 # elif defined(__MC68K__)
192  /* Motorola specific tweak. <[email protected]> */
193 # define ROTATE(a,n) ( n<24 ? __rol(a,n) : __ror(a,32-n) )
194 # else
195 # define ROTATE(a,n) __rol(a,n)
196 # endif
197 # elif defined(__GNUC__) && __GNUC__>=2 && !defined(NO_ASM) && !defined(NO_INLINE_ASM)
198  /*
199  * Some GNU C inline assembler templates. Note that these are
200  * rotates by *constant* number of bits! But that's exactly
201  * what we need here...
202  *
204  */
205 # if defined(__i386) || defined(__i386__)
206 # define ROTATE(a,n) ({ register unsigned int ret; \
207  asm ( \
208  "roll %1,%0" \
209  : "=r"(ret) \
210  : "I"(n), "0"(a) \
211  : "cc"); \
212  ret; \
213  })
214 # elif defined(__powerpc) || defined(__ppc)
215 # define ROTATE(a,n) ({ register unsigned int ret; \
216  asm ( \
217  "rlwinm %0,%1,%2,0,31" \
218  : "=r"(ret) \
219  : "r"(a), "I"(n)); \
220  ret; \
221  })
222 # endif
223 # endif
224 
225 /*
226  * Engage compiler specific "fetch in reverse byte order"
227  * intrinsic function if available.
228  */
229 # if defined(__GNUC__) && __GNUC__>=2 && !defined(NO_ASM) && !defined(NO_INLINE_ASM)
230  /* some GNU C inline assembler templates by <[email protected]> */
231 # if (defined(__i386) || defined(__i386__)) && !defined(I386_ONLY)
232 # define BE_FETCH32(a) ({ register unsigned int l=(a);\
233  asm ( \
234  "bswapl %0" \
235  : "=r"(l) : "0"(l)); \
236  l; \
237  })
238 # elif defined(__powerpc)
239 # define LE_FETCH32(a) ({ register unsigned int l; \
240  asm ( \
241  "lwbrx %0,0,%1" \
242  : "=r"(l) \
243  : "r"(a)); \
244  l; \
245  })
246 
247 # elif defined(__sparc) && defined(ULTRASPARC)
248 # define LE_FETCH32(a) ({ register unsigned int l; \
249  asm ( \
250  "lda [%1]#ASI_PRIMARY_LITTLE,%0"\
251  : "=r"(l) \
252  : "r"(a)); \
253  l; \
254  })
255 # endif
256 # endif
257 #endif /* PEDANTIC */
258 
259 #if HASH_LONG_LOG2==2 /* Engage only if sizeof(HASH_LONG)== 4 */
260 /* A nice byte order reversal from Wei Dai <[email protected]> */
261 #ifdef ROTATE
262 /* 5 instructions with rotate instruction, else 9 */
263 #define REVERSE_FETCH32(a,l) ( \
264  l=*(const HASH_LONG *)(a), \
265  ((ROTATE(l,8)&0x00FF00FF)|(ROTATE((l&0x00FF00FF),24))) \
266  )
267 #else
268 /* 6 instructions with rotate instruction, else 8 */
269 #define REVERSE_FETCH32(a,l) ( \
270  l=*(const HASH_LONG *)(a), \
271  l=(((l>>8)&0x00FF00FF)|((l&0x00FF00FF)<<8)), \
272  ROTATE(l,16) \
273  )
274 /*
275  * Originally the middle line started with l=(((l&0xFF00FF00)>>8)|...
276  * It's rewritten as above for two reasons:
277  * - RISCs aren't good at long constants and have to explicitely
278  * compose 'em with several (well, usually 2) instructions in a
279  * register before performing the actual operation and (as you
280  * already realized:-) having same constant should inspire the
281  * compiler to permanently allocate the only register for it;
282  * - most modern CPUs have two ALUs, but usually only one has
283  * circuitry for shifts:-( this minor tweak inspires compiler
284  * to schedule shift instructions in a better way...
285  *
287  */
288 #endif
289 #endif
290 
291 #ifndef ROTATE
292 #define ROTATE(a,n) (((a)<<(n))|(((a)&0xffffffff)>>(32-(n))))
293 #endif
294 
295 /*
296  * Make some obvious choices. E.g., HASH_BLOCK_DATA_ORDER_ALIGNED
297  * and HASH_BLOCK_HOST_ORDER ought to be the same if input data
298  * and host are of the same "endianess". It's possible to mask
299  * this with blank #define HASH_BLOCK_DATA_ORDER though...
300  *
302  */
303 #if defined(B_ENDIAN)
304 # if defined(DATA_ORDER_IS_BIG_ENDIAN)
305 # if !defined(HASH_BLOCK_DATA_ORDER_ALIGNED) && HASH_LONG_LOG2==2
306 # define HASH_BLOCK_DATA_ORDER_ALIGNED HASH_BLOCK_HOST_ORDER
307 # endif
308 # elif defined(DATA_ORDER_IS_LITTLE_ENDIAN)
309 # ifndef HOST_FETCH32
310 # ifdef LE_FETCH32
311 # define HOST_FETCH32(p,l) LE_FETCH32(p)
312 # elif defined(REVERSE_FETCH32)
313 # define HOST_FETCH32(p,l) REVERSE_FETCH32(p,l)
314 # endif
315 # endif
316 # endif
317 #elif defined(L_ENDIAN)
318 # if defined(DATA_ORDER_IS_LITTLE_ENDIAN)
319 # if !defined(HASH_BLOCK_DATA_ORDER_ALIGNED) && HASH_LONG_LOG2==2
320 # define HASH_BLOCK_DATA_ORDER_ALIGNED HASH_BLOCK_HOST_ORDER
321 # endif
322 # elif defined(DATA_ORDER_IS_BIG_ENDIAN)
323 # ifndef HOST_FETCH32
324 # ifdef BE_FETCH32
325 # define HOST_FETCH32(p,l) BE_FETCH32(p)
326 # elif defined(REVERSE_FETCH32)
327 # define HOST_FETCH32(p,l) REVERSE_FETCH32(p,l)
328 # endif
329 # endif
330 # endif
331 #endif
332 
333 #if !defined(HASH_BLOCK_DATA_ORDER_ALIGNED)
334 #ifndef HASH_BLOCK_DATA_ORDER
335 #error "HASH_BLOCK_DATA_ORDER must be defined!"
336 #endif
337 #endif
338 
339 #if defined(DATA_ORDER_IS_BIG_ENDIAN)
340 
341 #define HOST_c2l(c,l) (l =(((unsigned long)(*((c)++)))<<24), \
342  l|=(((unsigned long)(*((c)++)))<<16), \
343  l|=(((unsigned long)(*((c)++)))<< 8), \
344  l|=(((unsigned long)(*((c)++))) ), \
345  l)
346 #define HOST_p_c2l(c,l,n) { \
347  switch (n) { \
348  case 0: l =((unsigned long)(*((c)++)))<<24; \
349  case 1: l|=((unsigned long)(*((c)++)))<<16; \
350  case 2: l|=((unsigned long)(*((c)++)))<< 8; \
351  case 3: l|=((unsigned long)(*((c)++))); \
352  } }
353 #define HOST_p_c2l_p(c,l,sc,len) { \
354  switch (sc) { \
355  case 0: l =((unsigned long)(*((c)++)))<<24; \
356  if (--len == 0) break; \
357  case 1: l|=((unsigned long)(*((c)++)))<<16; \
358  if (--len == 0) break; \
359  case 2: l|=((unsigned long)(*((c)++)))<< 8; \
360  } }
361 /* NOTE the pointer is not incremented at the end of this */
362 #define HOST_c2l_p(c,l,n) { \
363  l=0; (c)+=n; \
364  switch (n) { \
365  case 3: l =((unsigned long)(*(--(c))))<< 8; \
366  case 2: l|=((unsigned long)(*(--(c))))<<16; \
367  case 1: l|=((unsigned long)(*(--(c))))<<24; \
368  } }
369 #define HOST_l2c(l,c) (*((c)++)=(unsigned char)(((l)>>24)&0xff), \
370  *((c)++)=(unsigned char)(((l)>>16)&0xff), \
371  *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
372  *((c)++)=(unsigned char)(((l) )&0xff), \
373  l)
374 
375 #elif defined(DATA_ORDER_IS_LITTLE_ENDIAN)
376 
377 #define HOST_c2l(c,l) (l =(((unsigned long)(*((c)++))) ), \
378  l|=(((unsigned long)(*((c)++)))<< 8), \
379  l|=(((unsigned long)(*((c)++)))<<16), \
380  l|=(((unsigned long)(*((c)++)))<<24), \
381  l)
382 #define HOST_p_c2l(c,l,n) { \
383  switch (n) { \
384  case 0: l =((unsigned long)(*((c)++))); \
385  case 1: l|=((unsigned long)(*((c)++)))<< 8; \
386  case 2: l|=((unsigned long)(*((c)++)))<<16; \
387  case 3: l|=((unsigned long)(*((c)++)))<<24; \
388  } }
389 #define HOST_p_c2l_p(c,l,sc,len) { \
390  switch (sc) { \
391  case 0: l =((unsigned long)(*((c)++))); \
392  if (--len == 0) break; \
393  case 1: l|=((unsigned long)(*((c)++)))<< 8; \
394  if (--len == 0) break; \
395  case 2: l|=((unsigned long)(*((c)++)))<<16; \
396  } }
397 /* NOTE the pointer is not incremented at the end of this */
398 #define HOST_c2l_p(c,l,n) { \
399  l=0; (c)+=n; \
400  switch (n) { \
401  case 3: l =((unsigned long)(*(--(c))))<<16; \
402  case 2: l|=((unsigned long)(*(--(c))))<< 8; \
403  case 1: l|=((unsigned long)(*(--(c)))); \
404  } }
405 #define HOST_l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
406  *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
407  *((c)++)=(unsigned char)(((l)>>16)&0xff), \
408  *((c)++)=(unsigned char)(((l)>>24)&0xff), \
409  l)
410 
411 #endif
412 
413 /*
414  * Time for some action:-)
415  */
416 
417 void HASH_UPDATE (HASH_CTX *c, const void *data_, unsigned long len)
418  {
419  const unsigned char *data=data_;
420  register HASH_LONG * p;
421  register unsigned long l;
422  int sw,sc,ew,ec;
423 
424  if (len==0) return;
425 
426  l=(c->Nl+(len<<3))&0xffffffffL;
427  /* 95-05-24 eay Fixed a bug with the overflow handling, thanks to
428  * Wei Dai <[email protected]> for pointing it out. */
429  if (l < c->Nl) /* overflow */
430  c->Nh++;
431  c->Nh+=(len>>29);
432  c->Nl=l;
433 
434  if (c->num != 0)
435  {
436  p=c->data;
437  sw=c->num>>2;
438  sc=c->num&0x03;
439 
440  if ((c->num+len) >= HASH_CBLOCK)
441  {
442  l=p[sw]; HOST_p_c2l(data,l,sc); p[sw++]=l;
443  for (; sw<HASH_LBLOCK; sw++)
444  {
445  HOST_c2l(data,l); p[sw]=l;
446  }
447  HASH_BLOCK_HOST_ORDER (c,p,1);
448  len-=(HASH_CBLOCK-c->num);
449  c->num=0;
450  /* drop through and do the rest */
451  }
452  else
453  {
454  c->num+=len;
455  if ((sc+len) < 4) /* ugly, add char's to a word */
456  {
457  l=p[sw]; HOST_p_c2l_p(data,l,sc,len); p[sw]=l;
458  }
459  else
460  {
461  ew=(c->num>>2);
462  ec=(c->num&0x03);
463  l=p[sw]; HOST_p_c2l(data,l,sc); p[sw++]=l;
464  for (; sw < ew; sw++)
465  {
466  HOST_c2l(data,l); p[sw]=l;
467  }
468  if (ec)
469  {
470  HOST_c2l_p(data,l,ec); p[sw]=l;
471  }
472  }
473  return;
474  }
475  }
476 
477  sw=len/HASH_CBLOCK;
478  if (sw > 0)
479  {
480 #if defined(HASH_BLOCK_DATA_ORDER_ALIGNED)
481  /*
482  * Note that HASH_BLOCK_DATA_ORDER_ALIGNED gets defined
483  * only if sizeof(HASH_LONG)==4.
484  *
485  * Masking is needed to suppress warnings from VS in 64-bit
486  * mode - pcg
487  */
488  #if defined( _WIN32 ) && defined( _M_X64 )
489  if ((((__int64)data)%4) == 0)
490  #else
491  if ((((unsigned long)data)%4) == 0)
492  #endif /* Win64 vs. standard */
493  {
494  /* data is properly aligned so that we can cast it: */
495  HASH_BLOCK_DATA_ORDER_ALIGNED (c,(HASH_LONG *)data,sw);
496  sw*=HASH_CBLOCK;
497  data+=sw;
498  len-=sw;
499  }
500  else
501 #if !defined(HASH_BLOCK_DATA_ORDER)
502  while (sw--)
503  {
504  memcpy (p=c->data,data,HASH_CBLOCK);
505  HASH_BLOCK_DATA_ORDER_ALIGNED(c,p,1);
506  data+=HASH_CBLOCK;
507  len-=HASH_CBLOCK;
508  }
509 #endif
510 #endif
511 #if defined(HASH_BLOCK_DATA_ORDER)
512  {
513  HASH_BLOCK_DATA_ORDER(c,data,sw);
514  sw*=HASH_CBLOCK;
515  data+=sw;
516  len-=sw;
517  }
518 #endif
519  }
520 
521  if (len!=0)
522  {
523  p = c->data;
524  c->num = len;
525  ew=len>>2; /* words to copy */
526  ec=len&0x03;
527  for (; ew; ew--,p++)
528  {
529  HOST_c2l(data,l); *p=l;
530  }
531  HOST_c2l_p(data,l,ec);
532  *p=l;
533  }
534  }
535 
536 
537 void HASH_TRANSFORM (HASH_CTX *c, const unsigned char *data)
538  {
539 #if defined(HASH_BLOCK_DATA_ORDER_ALIGNED)
540  if ((((unsigned long)data)%4) == 0)
541  /* data is properly aligned so that we can cast it: */
542  HASH_BLOCK_DATA_ORDER_ALIGNED (c,(HASH_LONG *)data,1);
543  else
544 #if !defined(HASH_BLOCK_DATA_ORDER)
545  {
546  memcpy (c->data,data,HASH_CBLOCK);
547  HASH_BLOCK_DATA_ORDER_ALIGNED (c,c->data,1);
548  }
549 #endif
550 #endif
551 #if defined(HASH_BLOCK_DATA_ORDER)
552  HASH_BLOCK_DATA_ORDER (c,data,1);
553 #endif
554  }
555 
556 
557 void HASH_FINAL (unsigned char *md, HASH_CTX *c)
558  {
559  register HASH_LONG *p;
560  register unsigned long l;
561  register int i,j;
562  static const unsigned char end[4]={0x80,0x00,0x00,0x00};
563  const unsigned char *cp=end;
564 
565  /* c->num should definitly have room for at least one more byte. */
566  p=c->data;
567  i=c->num>>2;
568  j=c->num&0x03;
569 
570 #if 0
571  /* purify often complains about the following line as an
572  * Uninitialized Memory Read. While this can be true, the
573  * following p_c2l macro will reset l when that case is true.
574  * This is because j&0x03 contains the number of 'valid' bytes
575  * already in p[i]. If and only if j&0x03 == 0, the UMR will
576  * occur but this is also the only time p_c2l will do
577  * l= *(cp++) instead of l|= *(cp++)
578  * Many thanks to Alex Tang <[email protected]> for pickup this
579  * 'potential bug' */
580 #ifdef PURIFY
581  if (j==0) p[i]=0; /* Yeah, but that's not the way to fix it:-) */
582 #endif
583  l=p[i];
584 #else
585  l = (j==0) ? 0 : p[i];
586 #endif
587  HOST_p_c2l(cp,l,j); p[i++]=l; /* i is the next 'undefined word' */
588 
589  if (i>(HASH_LBLOCK-2)) /* save room for Nl and Nh */
590  {
591  if (i<HASH_LBLOCK) p[i]=0;
592  HASH_BLOCK_HOST_ORDER (c,p,1);
593  i=0;
594  }
595  for (; i<(HASH_LBLOCK-2); i++)
596  p[i]=0;
597 
598 #if defined(DATA_ORDER_IS_BIG_ENDIAN)
599  p[HASH_LBLOCK-2]=c->Nh;
600  p[HASH_LBLOCK-1]=c->Nl;
601 #elif defined(DATA_ORDER_IS_LITTLE_ENDIAN)
602  p[HASH_LBLOCK-2]=c->Nl;
603  p[HASH_LBLOCK-1]=c->Nh;
604 #endif
605  HASH_BLOCK_HOST_ORDER (c,p,1);
606 
607 #ifndef HASH_MAKE_STRING
608 #error "HASH_MAKE_STRING must be defined!"
609 #else
610  HASH_MAKE_STRING(c,md);
611 #endif
612 
613  c->num=0;
614  /* clear stuff, HASH_BLOCK may be leaving some stuff on the stack
615  * but I'm not worried :-)
616  memset((void *)c,0,sizeof(HASH_CTX));
617  */
618  }