xref: /dflybsd-src/contrib/gcc-8.0/libiberty/sha1.c (revision 38fd149817dfbff97799f62fcb70be98c4e32523)
1*38fd1498Szrj /* sha1.c - Functions to compute SHA1 message digest of files or
2*38fd1498Szrj    memory blocks according to the NIST specification FIPS-180-1.
3*38fd1498Szrj 
4*38fd1498Szrj    Copyright (C) 2000-2018 Free Software Foundation, Inc.
5*38fd1498Szrj 
6*38fd1498Szrj    This program is free software; you can redistribute it and/or modify it
7*38fd1498Szrj    under the terms of the GNU General Public License as published by the
8*38fd1498Szrj    Free Software Foundation; either version 2, or (at your option) any
9*38fd1498Szrj    later version.
10*38fd1498Szrj 
11*38fd1498Szrj    This program is distributed in the hope that it will be useful,
12*38fd1498Szrj    but WITHOUT ANY WARRANTY; without even the implied warranty of
13*38fd1498Szrj    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*38fd1498Szrj    GNU General Public License for more details.
15*38fd1498Szrj 
16*38fd1498Szrj    You should have received a copy of the GNU General Public License
17*38fd1498Szrj    along with this program; if not, write to the Free Software Foundation,
18*38fd1498Szrj    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
19*38fd1498Szrj 
20*38fd1498Szrj /* Written by Scott G. Miller
21*38fd1498Szrj    Credits:
22*38fd1498Szrj       Robert Klep <robert@ilse.nl>  -- Expansion function fix
23*38fd1498Szrj */
24*38fd1498Szrj 
25*38fd1498Szrj #include <config.h>
26*38fd1498Szrj 
27*38fd1498Szrj #include "sha1.h"
28*38fd1498Szrj 
29*38fd1498Szrj #include <stddef.h>
30*38fd1498Szrj #include <string.h>
31*38fd1498Szrj 
32*38fd1498Szrj #if USE_UNLOCKED_IO
33*38fd1498Szrj # include "unlocked-io.h"
34*38fd1498Szrj #endif
35*38fd1498Szrj 
36*38fd1498Szrj #ifdef WORDS_BIGENDIAN
37*38fd1498Szrj # define SWAP(n) (n)
38*38fd1498Szrj #else
39*38fd1498Szrj # define SWAP(n) \
40*38fd1498Szrj     (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24))
41*38fd1498Szrj #endif
42*38fd1498Szrj 
43*38fd1498Szrj #define BLOCKSIZE 4096
44*38fd1498Szrj #if BLOCKSIZE % 64 != 0
45*38fd1498Szrj # error "invalid BLOCKSIZE"
46*38fd1498Szrj #endif
47*38fd1498Szrj 
48*38fd1498Szrj /* This array contains the bytes used to pad the buffer to the next
49*38fd1498Szrj    64-byte boundary.  (RFC 1321, 3.1: Step 1)  */
50*38fd1498Szrj static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ...  */ };
51*38fd1498Szrj 
52*38fd1498Szrj 
53*38fd1498Szrj /* Take a pointer to a 160 bit block of data (five 32 bit ints) and
54*38fd1498Szrj    initialize it to the start constants of the SHA1 algorithm.  This
55*38fd1498Szrj    must be called before using hash in the call to sha1_hash.  */
56*38fd1498Szrj void
sha1_init_ctx(struct sha1_ctx * ctx)57*38fd1498Szrj sha1_init_ctx (struct sha1_ctx *ctx)
58*38fd1498Szrj {
59*38fd1498Szrj   ctx->A = 0x67452301;
60*38fd1498Szrj   ctx->B = 0xefcdab89;
61*38fd1498Szrj   ctx->C = 0x98badcfe;
62*38fd1498Szrj   ctx->D = 0x10325476;
63*38fd1498Szrj   ctx->E = 0xc3d2e1f0;
64*38fd1498Szrj 
65*38fd1498Szrj   ctx->total[0] = ctx->total[1] = 0;
66*38fd1498Szrj   ctx->buflen = 0;
67*38fd1498Szrj }
68*38fd1498Szrj 
69*38fd1498Szrj /* Put result from CTX in first 20 bytes following RESBUF.  The result
70*38fd1498Szrj    must be in little endian byte order.
71*38fd1498Szrj 
72*38fd1498Szrj    IMPORTANT: On some systems it is required that RESBUF is correctly
73*38fd1498Szrj    aligned for a 32-bit value.  */
74*38fd1498Szrj void *
sha1_read_ctx(const struct sha1_ctx * ctx,void * resbuf)75*38fd1498Szrj sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf)
76*38fd1498Szrj {
77*38fd1498Szrj   ((sha1_uint32 *) resbuf)[0] = SWAP (ctx->A);
78*38fd1498Szrj   ((sha1_uint32 *) resbuf)[1] = SWAP (ctx->B);
79*38fd1498Szrj   ((sha1_uint32 *) resbuf)[2] = SWAP (ctx->C);
80*38fd1498Szrj   ((sha1_uint32 *) resbuf)[3] = SWAP (ctx->D);
81*38fd1498Szrj   ((sha1_uint32 *) resbuf)[4] = SWAP (ctx->E);
82*38fd1498Szrj 
83*38fd1498Szrj   return resbuf;
84*38fd1498Szrj }
85*38fd1498Szrj 
86*38fd1498Szrj /* Process the remaining bytes in the internal buffer and the usual
87*38fd1498Szrj    prolog according to the standard and write the result to RESBUF.
88*38fd1498Szrj 
89*38fd1498Szrj    IMPORTANT: On some systems it is required that RESBUF is correctly
90*38fd1498Szrj    aligned for a 32-bit value.  */
91*38fd1498Szrj void *
sha1_finish_ctx(struct sha1_ctx * ctx,void * resbuf)92*38fd1498Szrj sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf)
93*38fd1498Szrj {
94*38fd1498Szrj   /* Take yet unprocessed bytes into account.  */
95*38fd1498Szrj   sha1_uint32 bytes = ctx->buflen;
96*38fd1498Szrj   size_t size = (bytes < 56) ? 64 / 4 : 64 * 2 / 4;
97*38fd1498Szrj 
98*38fd1498Szrj   /* Now count remaining bytes.  */
99*38fd1498Szrj   ctx->total[0] += bytes;
100*38fd1498Szrj   if (ctx->total[0] < bytes)
101*38fd1498Szrj     ++ctx->total[1];
102*38fd1498Szrj 
103*38fd1498Szrj   /* Put the 64-bit file length in *bits* at the end of the buffer.  */
104*38fd1498Szrj   ctx->buffer[size - 2] = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29));
105*38fd1498Szrj   ctx->buffer[size - 1] = SWAP (ctx->total[0] << 3);
106*38fd1498Szrj 
107*38fd1498Szrj   memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes);
108*38fd1498Szrj 
109*38fd1498Szrj   /* Process last bytes.  */
110*38fd1498Szrj   sha1_process_block (ctx->buffer, size * 4, ctx);
111*38fd1498Szrj 
112*38fd1498Szrj   return sha1_read_ctx (ctx, resbuf);
113*38fd1498Szrj }
114*38fd1498Szrj 
115*38fd1498Szrj /* Compute SHA1 message digest for bytes read from STREAM.  The
116*38fd1498Szrj    resulting message digest number will be written into the 16 bytes
117*38fd1498Szrj    beginning at RESBLOCK.  */
118*38fd1498Szrj int
sha1_stream(FILE * stream,void * resblock)119*38fd1498Szrj sha1_stream (FILE *stream, void *resblock)
120*38fd1498Szrj {
121*38fd1498Szrj   struct sha1_ctx ctx;
122*38fd1498Szrj   char buffer[BLOCKSIZE + 72];
123*38fd1498Szrj   size_t sum;
124*38fd1498Szrj 
125*38fd1498Szrj   /* Initialize the computation context.  */
126*38fd1498Szrj   sha1_init_ctx (&ctx);
127*38fd1498Szrj 
128*38fd1498Szrj   /* Iterate over full file contents.  */
129*38fd1498Szrj   while (1)
130*38fd1498Szrj     {
131*38fd1498Szrj       /* We read the file in blocks of BLOCKSIZE bytes.  One call of the
132*38fd1498Szrj 	 computation function processes the whole buffer so that with the
133*38fd1498Szrj 	 next round of the loop another block can be read.  */
134*38fd1498Szrj       size_t n;
135*38fd1498Szrj       sum = 0;
136*38fd1498Szrj 
137*38fd1498Szrj       /* Read block.  Take care for partial reads.  */
138*38fd1498Szrj       while (1)
139*38fd1498Szrj 	{
140*38fd1498Szrj 	  n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream);
141*38fd1498Szrj 
142*38fd1498Szrj 	  sum += n;
143*38fd1498Szrj 
144*38fd1498Szrj 	  if (sum == BLOCKSIZE)
145*38fd1498Szrj 	    break;
146*38fd1498Szrj 
147*38fd1498Szrj 	  if (n == 0)
148*38fd1498Szrj 	    {
149*38fd1498Szrj 	      /* Check for the error flag IFF N == 0, so that we don't
150*38fd1498Szrj 		 exit the loop after a partial read due to e.g., EAGAIN
151*38fd1498Szrj 		 or EWOULDBLOCK.  */
152*38fd1498Szrj 	      if (ferror (stream))
153*38fd1498Szrj 		return 1;
154*38fd1498Szrj 	      goto process_partial_block;
155*38fd1498Szrj 	    }
156*38fd1498Szrj 
157*38fd1498Szrj 	  /* We've read at least one byte, so ignore errors.  But always
158*38fd1498Szrj 	     check for EOF, since feof may be true even though N > 0.
159*38fd1498Szrj 	     Otherwise, we could end up calling fread after EOF.  */
160*38fd1498Szrj 	  if (feof (stream))
161*38fd1498Szrj 	    goto process_partial_block;
162*38fd1498Szrj 	}
163*38fd1498Szrj 
164*38fd1498Szrj       /* Process buffer with BLOCKSIZE bytes.  Note that
165*38fd1498Szrj 			BLOCKSIZE % 64 == 0
166*38fd1498Szrj        */
167*38fd1498Szrj       sha1_process_block (buffer, BLOCKSIZE, &ctx);
168*38fd1498Szrj     }
169*38fd1498Szrj 
170*38fd1498Szrj  process_partial_block:;
171*38fd1498Szrj 
172*38fd1498Szrj   /* Process any remaining bytes.  */
173*38fd1498Szrj   if (sum > 0)
174*38fd1498Szrj     sha1_process_bytes (buffer, sum, &ctx);
175*38fd1498Szrj 
176*38fd1498Szrj   /* Construct result in desired memory.  */
177*38fd1498Szrj   sha1_finish_ctx (&ctx, resblock);
178*38fd1498Szrj   return 0;
179*38fd1498Szrj }
180*38fd1498Szrj 
181*38fd1498Szrj /* Compute SHA1 message digest for LEN bytes beginning at BUFFER.  The
182*38fd1498Szrj    result is always in little endian byte order, so that a byte-wise
183*38fd1498Szrj    output yields to the wanted ASCII representation of the message
184*38fd1498Szrj    digest.  */
185*38fd1498Szrj void *
sha1_buffer(const char * buffer,size_t len,void * resblock)186*38fd1498Szrj sha1_buffer (const char *buffer, size_t len, void *resblock)
187*38fd1498Szrj {
188*38fd1498Szrj   struct sha1_ctx ctx;
189*38fd1498Szrj 
190*38fd1498Szrj   /* Initialize the computation context.  */
191*38fd1498Szrj   sha1_init_ctx (&ctx);
192*38fd1498Szrj 
193*38fd1498Szrj   /* Process whole buffer but last len % 64 bytes.  */
194*38fd1498Szrj   sha1_process_bytes (buffer, len, &ctx);
195*38fd1498Szrj 
196*38fd1498Szrj   /* Put result in desired memory area.  */
197*38fd1498Szrj   return sha1_finish_ctx (&ctx, resblock);
198*38fd1498Szrj }
199*38fd1498Szrj 
200*38fd1498Szrj void
sha1_process_bytes(const void * buffer,size_t len,struct sha1_ctx * ctx)201*38fd1498Szrj sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx)
202*38fd1498Szrj {
203*38fd1498Szrj   /* When we already have some bits in our internal buffer concatenate
204*38fd1498Szrj      both inputs first.  */
205*38fd1498Szrj   if (ctx->buflen != 0)
206*38fd1498Szrj     {
207*38fd1498Szrj       size_t left_over = ctx->buflen;
208*38fd1498Szrj       size_t add = 128 - left_over > len ? len : 128 - left_over;
209*38fd1498Szrj 
210*38fd1498Szrj       memcpy (&((char *) ctx->buffer)[left_over], buffer, add);
211*38fd1498Szrj       ctx->buflen += add;
212*38fd1498Szrj 
213*38fd1498Szrj       if (ctx->buflen > 64)
214*38fd1498Szrj 	{
215*38fd1498Szrj 	  sha1_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
216*38fd1498Szrj 
217*38fd1498Szrj 	  ctx->buflen &= 63;
218*38fd1498Szrj 	  /* The regions in the following copy operation cannot overlap.  */
219*38fd1498Szrj 	  memcpy (ctx->buffer,
220*38fd1498Szrj 		  &((char *) ctx->buffer)[(left_over + add) & ~63],
221*38fd1498Szrj 		  ctx->buflen);
222*38fd1498Szrj 	}
223*38fd1498Szrj 
224*38fd1498Szrj       buffer = (const char *) buffer + add;
225*38fd1498Szrj       len -= add;
226*38fd1498Szrj     }
227*38fd1498Szrj 
228*38fd1498Szrj   /* Process available complete blocks.  */
229*38fd1498Szrj   if (len >= 64)
230*38fd1498Szrj     {
231*38fd1498Szrj #if !_STRING_ARCH_unaligned
232*38fd1498Szrj # define alignof(type) offsetof (struct { char c; type x; }, x)
233*38fd1498Szrj # define UNALIGNED_P(p) (((size_t) p) % alignof (sha1_uint32) != 0)
234*38fd1498Szrj       if (UNALIGNED_P (buffer))
235*38fd1498Szrj 	while (len > 64)
236*38fd1498Szrj 	  {
237*38fd1498Szrj 	    sha1_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx);
238*38fd1498Szrj 	    buffer = (const char *) buffer + 64;
239*38fd1498Szrj 	    len -= 64;
240*38fd1498Szrj 	  }
241*38fd1498Szrj       else
242*38fd1498Szrj #endif
243*38fd1498Szrj 	{
244*38fd1498Szrj 	  sha1_process_block (buffer, len & ~63, ctx);
245*38fd1498Szrj 	  buffer = (const char *) buffer + (len & ~63);
246*38fd1498Szrj 	  len &= 63;
247*38fd1498Szrj 	}
248*38fd1498Szrj     }
249*38fd1498Szrj 
250*38fd1498Szrj   /* Move remaining bytes in internal buffer.  */
251*38fd1498Szrj   if (len > 0)
252*38fd1498Szrj     {
253*38fd1498Szrj       size_t left_over = ctx->buflen;
254*38fd1498Szrj 
255*38fd1498Szrj       memcpy (&((char *) ctx->buffer)[left_over], buffer, len);
256*38fd1498Szrj       left_over += len;
257*38fd1498Szrj       if (left_over >= 64)
258*38fd1498Szrj 	{
259*38fd1498Szrj 	  sha1_process_block (ctx->buffer, 64, ctx);
260*38fd1498Szrj 	  left_over -= 64;
261*38fd1498Szrj 	  memcpy (ctx->buffer, &ctx->buffer[16], left_over);
262*38fd1498Szrj 	}
263*38fd1498Szrj       ctx->buflen = left_over;
264*38fd1498Szrj     }
265*38fd1498Szrj }
266*38fd1498Szrj 
267*38fd1498Szrj /* --- Code below is the primary difference between md5.c and sha1.c --- */
268*38fd1498Szrj 
269*38fd1498Szrj /* SHA1 round constants */
270*38fd1498Szrj #define K1 0x5a827999
271*38fd1498Szrj #define K2 0x6ed9eba1
272*38fd1498Szrj #define K3 0x8f1bbcdc
273*38fd1498Szrj #define K4 0xca62c1d6
274*38fd1498Szrj 
275*38fd1498Szrj /* Round functions.  Note that F2 is the same as F4.  */
276*38fd1498Szrj #define F1(B,C,D) ( D ^ ( B & ( C ^ D ) ) )
277*38fd1498Szrj #define F2(B,C,D) (B ^ C ^ D)
278*38fd1498Szrj #define F3(B,C,D) ( ( B & C ) | ( D & ( B | C ) ) )
279*38fd1498Szrj #define F4(B,C,D) (B ^ C ^ D)
280*38fd1498Szrj 
281*38fd1498Szrj /* Process LEN bytes of BUFFER, accumulating context into CTX.
282*38fd1498Szrj    It is assumed that LEN % 64 == 0.
283*38fd1498Szrj    Most of this code comes from GnuPG's cipher/sha1.c.  */
284*38fd1498Szrj 
285*38fd1498Szrj void
sha1_process_block(const void * buffer,size_t len,struct sha1_ctx * ctx)286*38fd1498Szrj sha1_process_block (const void *buffer, size_t len, struct sha1_ctx *ctx)
287*38fd1498Szrj {
288*38fd1498Szrj   const sha1_uint32 *words = (const sha1_uint32*) buffer;
289*38fd1498Szrj   size_t nwords = len / sizeof (sha1_uint32);
290*38fd1498Szrj   const sha1_uint32 *endp = words + nwords;
291*38fd1498Szrj   sha1_uint32 x[16];
292*38fd1498Szrj   sha1_uint32 a = ctx->A;
293*38fd1498Szrj   sha1_uint32 b = ctx->B;
294*38fd1498Szrj   sha1_uint32 c = ctx->C;
295*38fd1498Szrj   sha1_uint32 d = ctx->D;
296*38fd1498Szrj   sha1_uint32 e = ctx->E;
297*38fd1498Szrj 
298*38fd1498Szrj   /* First increment the byte count.  RFC 1321 specifies the possible
299*38fd1498Szrj      length of the file up to 2^64 bits.  Here we only compute the
300*38fd1498Szrj      number of bytes.  Do a double word increment.  */
301*38fd1498Szrj   ctx->total[0] += len;
302*38fd1498Szrj   ctx->total[1] += ((len >> 31) >> 1) + (ctx->total[0] < len);
303*38fd1498Szrj 
304*38fd1498Szrj #define rol(x, n) (((x) << (n)) | ((sha1_uint32) (x) >> (32 - (n))))
305*38fd1498Szrj 
306*38fd1498Szrj #define M(I) ( tm =   x[I&0x0f] ^ x[(I-14)&0x0f] \
307*38fd1498Szrj 		    ^ x[(I-8)&0x0f] ^ x[(I-3)&0x0f] \
308*38fd1498Szrj 	       , (x[I&0x0f] = rol(tm, 1)) )
309*38fd1498Szrj 
310*38fd1498Szrj #define R(A,B,C,D,E,F,K,M)  do { E += rol( A, 5 )     \
311*38fd1498Szrj 				      + F( B, C, D )  \
312*38fd1498Szrj 				      + K	      \
313*38fd1498Szrj 				      + M;	      \
314*38fd1498Szrj 				 B = rol( B, 30 );    \
315*38fd1498Szrj 			       } while(0)
316*38fd1498Szrj 
317*38fd1498Szrj   while (words < endp)
318*38fd1498Szrj     {
319*38fd1498Szrj       sha1_uint32 tm;
320*38fd1498Szrj       int t;
321*38fd1498Szrj       for (t = 0; t < 16; t++)
322*38fd1498Szrj 	{
323*38fd1498Szrj 	  x[t] = SWAP (*words);
324*38fd1498Szrj 	  words++;
325*38fd1498Szrj 	}
326*38fd1498Szrj 
327*38fd1498Szrj       R( a, b, c, d, e, F1, K1, x[ 0] );
328*38fd1498Szrj       R( e, a, b, c, d, F1, K1, x[ 1] );
329*38fd1498Szrj       R( d, e, a, b, c, F1, K1, x[ 2] );
330*38fd1498Szrj       R( c, d, e, a, b, F1, K1, x[ 3] );
331*38fd1498Szrj       R( b, c, d, e, a, F1, K1, x[ 4] );
332*38fd1498Szrj       R( a, b, c, d, e, F1, K1, x[ 5] );
333*38fd1498Szrj       R( e, a, b, c, d, F1, K1, x[ 6] );
334*38fd1498Szrj       R( d, e, a, b, c, F1, K1, x[ 7] );
335*38fd1498Szrj       R( c, d, e, a, b, F1, K1, x[ 8] );
336*38fd1498Szrj       R( b, c, d, e, a, F1, K1, x[ 9] );
337*38fd1498Szrj       R( a, b, c, d, e, F1, K1, x[10] );
338*38fd1498Szrj       R( e, a, b, c, d, F1, K1, x[11] );
339*38fd1498Szrj       R( d, e, a, b, c, F1, K1, x[12] );
340*38fd1498Szrj       R( c, d, e, a, b, F1, K1, x[13] );
341*38fd1498Szrj       R( b, c, d, e, a, F1, K1, x[14] );
342*38fd1498Szrj       R( a, b, c, d, e, F1, K1, x[15] );
343*38fd1498Szrj       R( e, a, b, c, d, F1, K1, M(16) );
344*38fd1498Szrj       R( d, e, a, b, c, F1, K1, M(17) );
345*38fd1498Szrj       R( c, d, e, a, b, F1, K1, M(18) );
346*38fd1498Szrj       R( b, c, d, e, a, F1, K1, M(19) );
347*38fd1498Szrj       R( a, b, c, d, e, F2, K2, M(20) );
348*38fd1498Szrj       R( e, a, b, c, d, F2, K2, M(21) );
349*38fd1498Szrj       R( d, e, a, b, c, F2, K2, M(22) );
350*38fd1498Szrj       R( c, d, e, a, b, F2, K2, M(23) );
351*38fd1498Szrj       R( b, c, d, e, a, F2, K2, M(24) );
352*38fd1498Szrj       R( a, b, c, d, e, F2, K2, M(25) );
353*38fd1498Szrj       R( e, a, b, c, d, F2, K2, M(26) );
354*38fd1498Szrj       R( d, e, a, b, c, F2, K2, M(27) );
355*38fd1498Szrj       R( c, d, e, a, b, F2, K2, M(28) );
356*38fd1498Szrj       R( b, c, d, e, a, F2, K2, M(29) );
357*38fd1498Szrj       R( a, b, c, d, e, F2, K2, M(30) );
358*38fd1498Szrj       R( e, a, b, c, d, F2, K2, M(31) );
359*38fd1498Szrj       R( d, e, a, b, c, F2, K2, M(32) );
360*38fd1498Szrj       R( c, d, e, a, b, F2, K2, M(33) );
361*38fd1498Szrj       R( b, c, d, e, a, F2, K2, M(34) );
362*38fd1498Szrj       R( a, b, c, d, e, F2, K2, M(35) );
363*38fd1498Szrj       R( e, a, b, c, d, F2, K2, M(36) );
364*38fd1498Szrj       R( d, e, a, b, c, F2, K2, M(37) );
365*38fd1498Szrj       R( c, d, e, a, b, F2, K2, M(38) );
366*38fd1498Szrj       R( b, c, d, e, a, F2, K2, M(39) );
367*38fd1498Szrj       R( a, b, c, d, e, F3, K3, M(40) );
368*38fd1498Szrj       R( e, a, b, c, d, F3, K3, M(41) );
369*38fd1498Szrj       R( d, e, a, b, c, F3, K3, M(42) );
370*38fd1498Szrj       R( c, d, e, a, b, F3, K3, M(43) );
371*38fd1498Szrj       R( b, c, d, e, a, F3, K3, M(44) );
372*38fd1498Szrj       R( a, b, c, d, e, F3, K3, M(45) );
373*38fd1498Szrj       R( e, a, b, c, d, F3, K3, M(46) );
374*38fd1498Szrj       R( d, e, a, b, c, F3, K3, M(47) );
375*38fd1498Szrj       R( c, d, e, a, b, F3, K3, M(48) );
376*38fd1498Szrj       R( b, c, d, e, a, F3, K3, M(49) );
377*38fd1498Szrj       R( a, b, c, d, e, F3, K3, M(50) );
378*38fd1498Szrj       R( e, a, b, c, d, F3, K3, M(51) );
379*38fd1498Szrj       R( d, e, a, b, c, F3, K3, M(52) );
380*38fd1498Szrj       R( c, d, e, a, b, F3, K3, M(53) );
381*38fd1498Szrj       R( b, c, d, e, a, F3, K3, M(54) );
382*38fd1498Szrj       R( a, b, c, d, e, F3, K3, M(55) );
383*38fd1498Szrj       R( e, a, b, c, d, F3, K3, M(56) );
384*38fd1498Szrj       R( d, e, a, b, c, F3, K3, M(57) );
385*38fd1498Szrj       R( c, d, e, a, b, F3, K3, M(58) );
386*38fd1498Szrj       R( b, c, d, e, a, F3, K3, M(59) );
387*38fd1498Szrj       R( a, b, c, d, e, F4, K4, M(60) );
388*38fd1498Szrj       R( e, a, b, c, d, F4, K4, M(61) );
389*38fd1498Szrj       R( d, e, a, b, c, F4, K4, M(62) );
390*38fd1498Szrj       R( c, d, e, a, b, F4, K4, M(63) );
391*38fd1498Szrj       R( b, c, d, e, a, F4, K4, M(64) );
392*38fd1498Szrj       R( a, b, c, d, e, F4, K4, M(65) );
393*38fd1498Szrj       R( e, a, b, c, d, F4, K4, M(66) );
394*38fd1498Szrj       R( d, e, a, b, c, F4, K4, M(67) );
395*38fd1498Szrj       R( c, d, e, a, b, F4, K4, M(68) );
396*38fd1498Szrj       R( b, c, d, e, a, F4, K4, M(69) );
397*38fd1498Szrj       R( a, b, c, d, e, F4, K4, M(70) );
398*38fd1498Szrj       R( e, a, b, c, d, F4, K4, M(71) );
399*38fd1498Szrj       R( d, e, a, b, c, F4, K4, M(72) );
400*38fd1498Szrj       R( c, d, e, a, b, F4, K4, M(73) );
401*38fd1498Szrj       R( b, c, d, e, a, F4, K4, M(74) );
402*38fd1498Szrj       R( a, b, c, d, e, F4, K4, M(75) );
403*38fd1498Szrj       R( e, a, b, c, d, F4, K4, M(76) );
404*38fd1498Szrj       R( d, e, a, b, c, F4, K4, M(77) );
405*38fd1498Szrj       R( c, d, e, a, b, F4, K4, M(78) );
406*38fd1498Szrj       R( b, c, d, e, a, F4, K4, M(79) );
407*38fd1498Szrj 
408*38fd1498Szrj       a = ctx->A += a;
409*38fd1498Szrj       b = ctx->B += b;
410*38fd1498Szrj       c = ctx->C += c;
411*38fd1498Szrj       d = ctx->D += d;
412*38fd1498Szrj       e = ctx->E += e;
413*38fd1498Szrj     }
414*38fd1498Szrj }
415