]> git.pld-linux.org Git - packages/util-linux.git/blob - util-linux-cipher.patch
- adapterized (avoid macros with /usr/include/{ncurses,freetype}*)
[packages/util-linux.git] / util-linux-cipher.patch
1 diff -urN util-linux-2.9w/mount/Makefile util-linux-2.9w.int/mount/Makefile
2 --- util-linux-2.9w/mount/Makefile      Fri Jul  9 04:56:39 1999
3 +++ util-linux-2.9w.int/mount/Makefile  Mon Sep  6 14:05:07 1999
4 @@ -36,7 +36,7 @@
5  GEN_FILES = nfsmount.x nfsmount.h nfsmount_xdr.c nfsmount_clnt.c
6  
7  # comment these out if you are not compiling in loop support
8 -LO_OBJS=lomount.o
9 +LO_OBJS=lomount.o rmd160.o
10  
11  all: $(PROGS)
12  
13 @@ -64,7 +64,7 @@
14  swapon:        swapon.o version.o
15         $(LINK) $^ -o $@
16  
17 -losetup: losetup.o
18 +losetup: losetup.o rmd160.o
19         $(LINK) $^ -o $@
20  
21  mount.o umount.o nfsmount.o losetup.o fstab.o sundries.o: sundries.h
22 diff -urN util-linux-2.9w/mount/lomount.c util-linux-2.9w.int/mount/lomount.c
23 --- util-linux-2.9w/mount/lomount.c     Fri Jul  9 04:56:39 1999
24 +++ util-linux-2.9w.int/mount/lomount.c Mon Sep  6 14:05:07 1999
25 @@ -26,6 +26,7 @@
26  
27  #include "loop.h"
28  #include "lomount.h"
29 +#include "rmd160.h"
30  #include "nls.h"
31  
32  char *xstrdup (const char *s);         /* not: #include "sundries.h" */
33 @@ -40,6 +41,14 @@
34    { LO_CRYPT_NONE, "none" },
35    { LO_CRYPT_XOR, "xor" },
36    { LO_CRYPT_DES, "DES" },
37 +  { LO_CRYPT_FISH2, "twofish" },
38 +  { LO_CRYPT_BLOW, "blowfish"},
39 +  { LO_CRYPT_CAST128, "cast128"},
40 +  { LO_CRYPT_SERPENT, "serpent"},
41 +  { LO_CRYPT_MARS, "mars" },
42 +  { LO_CRYPT_RC6, "rc6" },
43 +  { LO_CRYPT_DFC, "dfc" },
44 +  { LO_CRYPT_IDEA, "idea"},
45    { -1, NULL   }
46  };
47  
48 @@ -218,6 +227,24 @@
49         return 1;
50        }
51      break;
52 +  case LO_CRYPT_FISH2:
53 +  case LO_CRYPT_BLOW:
54 +    pass = getpass("Password :");
55 +    MDcalc((byte *)loopinfo.lo_encrypt_key,pass,strlen(pass));
56 +    loopinfo.lo_encrypt_key_size=20; /* 160 Bit key */
57 +    break;
58 +    
59 +  case LO_CRYPT_IDEA:
60 +  case LO_CRYPT_CAST128:
61 +  case LO_CRYPT_SERPENT:
62 +  case LO_CRYPT_MARS:
63 +  case LO_CRYPT_RC6:
64 +  case LO_CRYPT_DFC:
65 +    pass = getpass("Password :");
66 +    MDcalc((byte *)loopinfo.lo_encrypt_key,pass,strlen(pass));
67 +    loopinfo.lo_encrypt_key_size=16; /* 128 Bit key */
68 +    break;
69 +    
70    default:
71      fprintf (stderr,
72              _("Don't know how to get key for encryption system %d\n"),
73 diff -urN util-linux-2.9w/mount/losetup.8 util-linux-2.9w.int/mount/losetup.8
74 --- util-linux-2.9w/mount/losetup.8     Fri Jul  9 04:56:39 1999
75 +++ util-linux-2.9w.int/mount/losetup.8 Mon Sep  6 14:05:24 1999
76 @@ -36,11 +36,47 @@
77  .PD 0
78  .IP \fBXOR\fP
79  use a simple XOR encryption.
80 +.IP \fBBlowfish\fP
81 +use Blowfish encryption. Blowfish encryption is only available if you
82 +are using the international kernel and Blowfish encryption has been
83 +enabled in the Crypto API.
84 +.IP \fBTwofish\fP
85 +use Twofish encryption. Twofish encryption is only available if you
86 +are using the international kernel and Twofish encryption has been
87 +enabled in the Crypto API.
88 +.IP \fBCAST\fP
89 +use CAST encryption. CAST encryption is only available if you
90 +are using the international kernel and CAST encryption has been
91 +enabled in the Crypto API.
92  .IP \fBDES\fP
93  use DES encryption. DES encryption is only available if the optional
94  DES package has been added to the kernel. DES encryption uses an additional
95  start value that is used to protect passwords against dictionary
96 -attacks.
97 +attacks. Use of DES is deprecated.
98 +.IP \fBDFC\fP
99 +use DFC encryption. DFC encryption is only available if you
100 +are using the international kernel and DFC encryption has been
101 +enabled in the Crypto API.
102 +.IP \fBIDEA\fP
103 +use IDEA encryption. IDEA encryption is only available if you
104 +are using the international kernel and IDEA encryption has been
105 +enabled in the Crypto API.
106 +.IP \fBMARS\fP
107 +use MARS encryption. MARS encryption is only available if you
108 +are using the international kernel and MARS encryption has been
109 +enabled in the Crypto API.
110 +.IP \fBRC5\fP
111 +use RC5 encryption. RC5 encryption is only available if you
112 +are using the international kernel and RC5 encryption has been
113 +enabled in the Crypto API.
114 +.IP \fBRC6\fP
115 +use RC6 encryption. RC6 encryption is only available if you
116 +are using the international kernel and RC6 encryption has been
117 +enabled in the Crypto API.
118 +.IP \fBSerpent\fP
119 +use Serpent encryption. Serpent encryption is only available if you
120 +are using the international kernel and Serpent encryption has been
121 +enabled in the Crypto API.
122  .PD
123  .RE
124  .IP "\fB\-o \fIoffset\fP"
125 @@ -49,6 +85,7 @@
126  .SH FILES
127  .nf
128  /dev/loop0,/dev/loop1,...   loop devices (major=7)
129 +/proc/cipher/*              available ciphers
130  .fi
131  .SH EXAMPLE
132  If you are using the loadable module you must have the module loaded
133 @@ -60,9 +97,8 @@
134  .nf
135  .IP
136  dd if=/dev/zero of=/file bs=1k count=100
137 -losetup -e des /dev/loop0 /file
138 -Password:
139 -Init (up to 16 hex digits):
140 +losetup -e blowfish /dev/loop0 /file
141 +Password :
142  mkfs -t ext2 /dev/loop0 100
143  mount -t ext2 /dev/loop0 /mnt
144   ...
145 @@ -76,8 +112,12 @@
146  # rmmod loop
147  .LP
148  .fi
149 -.SH RESTRICTION
150 -DES encryption is painfully slow. On the other hand, XOR is terribly weak.
151 +.SH RESTRICTIONS
152 +DES encryption is painfully slow. On the other hand, XOR is terribly
153 +weak. Both are insecure nowadays. Some ciphers require a licence for
154 +you to be allowed to use them.
155 +.SH BUGS
156 +CAST, DES, RC5 and Twofish are currently broken and cannot be used.
157  .SH AUTHORS
158  .nf
159  Original version: Theodore Ts'o <tytso@athena.mit.edu>
160 diff -urN util-linux-2.9w/mount/losetup.c util-linux-2.9w.int/mount/losetup.c
161 --- util-linux-2.9w/mount/losetup.c     Fri Jul  9 04:56:39 1999
162 +++ util-linux-2.9w.int/mount/losetup.c Mon Sep  6 14:19:53 1999
163 @@ -17,6 +17,7 @@
164  
165  #include "loop.h"
166  #include "lomount.h"
167 +#include "rmd160.h"
168  #include "nls.h"
169  
170  #ifdef LOOP_SET_FD
171 @@ -31,6 +32,14 @@
172         { LO_CRYPT_NONE,"none" },
173         { LO_CRYPT_XOR, "xor" },
174         { LO_CRYPT_DES, "DES" },
175 +       { LO_CRYPT_FISH2, "twofish" },
176 +       { LO_CRYPT_BLOW, "blowfish" },
177 +       { LO_CRYPT_CAST128, "cast128" },
178 +       { LO_CRYPT_SERPENT, "serpent" },
179 +       { LO_CRYPT_MARS, "mars" },
180 +       { LO_CRYPT_RC6, "rc6" },
181 +       { LO_CRYPT_DFC, "dfc" },
182 +       { LO_CRYPT_IDEA, "idea" },
183         { -1,           NULL }
184  };
185  
186 @@ -85,7 +94,7 @@
187         struct loop_info loopinfo;
188         int     fd, ffd, mode, i;
189         char    *pass;
190 -
191 +        
192         mode = *loopro ? O_RDONLY : O_RDWR;
193         if ((ffd = open (file, mode)) < 0 && !*loopro
194             && (errno != EROFS || (ffd = open (file, mode = O_RDONLY)) < 0)) {
195 @@ -118,6 +127,7 @@
196                 loopinfo.lo_encrypt_key_size = strlen(loopinfo.lo_encrypt_key);
197                 break;
198         case LO_CRYPT_DES:
199 +               printf(_("WARNING: Use of DES is depreciated.\n"));
200                 pass = getpass(_("Password: "));
201                 strncpy(loopinfo.lo_encrypt_key, pass, 8);
202                 loopinfo.lo_encrypt_key[8] = 0;
203 @@ -133,6 +143,22 @@
204                                 exit(1);
205                         }
206                 break;
207 +       case LO_CRYPT_FISH2:
208 +       case LO_CRYPT_BLOW:
209 +               pass = getpass("Password :");
210 +               MDcalc((byte *)loopinfo.lo_encrypt_key,pass,strlen(pass));
211 +               loopinfo.lo_encrypt_key_size=20; /* 160 Bit key */
212 +               break;
213 +       case LO_CRYPT_CAST128:
214 +       case LO_CRYPT_SERPENT:
215 +       case LO_CRYPT_MARS:
216 +       case LO_CRYPT_RC6:
217 +       case LO_CRYPT_DFC:
218 +       case LO_CRYPT_IDEA:
219 +               pass = getpass("Passphrase :");
220 +               MDcalc((byte *)loopinfo.lo_encrypt_key,pass,strlen(pass));
221 +               loopinfo.lo_encrypt_key_size=16; /* 128 Bit key */
222 +               break;
223         default:
224                 fprintf(stderr,
225                         _("Don't know how to get key for encryption system %d\n"),
226 @@ -171,11 +197,18 @@
227  
228  static int usage(void)
229  {
230 +        struct crypt_type_struct *c;
231         fprintf(stderr, _("usage:\n\
232    %s loop_device                                      # give info\n\
233    %s -d loop_device                                   # delete\n\
234    %s [ -e encryption ] [ -o offset ] loop_device file # setup\n"),
235                 progname, progname, progname);
236 +       fprintf(stderr, "    where encryption is one of:\n");
237 +       c = &crypt_type_tbl[0];
238 +       while(c->name) {
239 +               fprintf(stderr, "       %s\n", c->name);
240 +               c++;
241 +       }
242         exit(1);
243  }
244  
245 diff -urN util-linux-2.9w/mount/rmd160.c util-linux-2.9w.int/mount/rmd160.c
246 --- util-linux-2.9w/mount/rmd160.c      Thu Jan  1 01:00:00 1970
247 +++ util-linux-2.9w.int/mount/rmd160.c  Mon Sep  6 14:05:07 1999
248 @@ -0,0 +1,371 @@
249 +/********************************************************************\
250 + *
251 + *      FILE:     rmd160.c
252 + *
253 + *      CONTENTS: A sample C-implementation of the RIPEMD-160
254 + *                hash-function.
255 + *      TARGET:   any computer with an ANSI C compiler
256 + *
257 + *      AUTHOR:   Antoon Bosselaers, ESAT-COSIC
258 + *      DATE:     1 March 1996
259 + *      VERSION:  1.0
260 + *
261 + *      Copyright (c) Katholieke Universiteit Leuven
262 + *      1996, All Rights Reserved
263 + *
264 +\********************************************************************/
265 +
266 +/*  header files */
267 +#include <stdio.h>
268 +#include <stdlib.h>
269 +#include <string.h>
270 +#include "rmd160.h"      
271 +
272 +/********************************************************************/
273 +
274 +/* macro definitions */
275 +
276 +/* collect four bytes into one word: */
277 +#define BYTES_TO_DWORD(strptr)                    \
278 +            (((dword) *((strptr)+3) << 24) | \
279 +             ((dword) *((strptr)+2) << 16) | \
280 +             ((dword) *((strptr)+1) <<  8) | \
281 +             ((dword) *(strptr)))
282 +
283 +/* ROL(x, n) cyclically rotates x over n bits to the left */
284 +/* x must be of an unsigned 32 bits type and 0 <= n < 32. */
285 +#define ROL(x, n)        (((x) << (n)) | ((x) >> (32-(n))))
286 +
287 +/* the five basic functions F(), G() and H() */
288 +#define F(x, y, z)        ((x) ^ (y) ^ (z)) 
289 +#define G(x, y, z)        (((x) & (y)) | (~(x) & (z))) 
290 +#define H(x, y, z)        (((x) | ~(y)) ^ (z))
291 +#define I(x, y, z)        (((x) & (z)) | ((y) & ~(z))) 
292 +#define J(x, y, z)        ((x) ^ ((y) | ~(z)))
293 +  
294 +/* the ten basic operations FF() through III() */
295 +#define FF(a, b, c, d, e, x, s)        {\
296 +      (a) += F((b), (c), (d)) + (x);\
297 +      (a) = ROL((a), (s)) + (e);\
298 +      (c) = ROL((c), 10);\
299 +   }
300 +#define GG(a, b, c, d, e, x, s)        {\
301 +      (a) += G((b), (c), (d)) + (x) + 0x5a827999UL;\
302 +      (a) = ROL((a), (s)) + (e);\
303 +      (c) = ROL((c), 10);\
304 +   }
305 +#define HH(a, b, c, d, e, x, s)        {\
306 +      (a) += H((b), (c), (d)) + (x) + 0x6ed9eba1UL;\
307 +      (a) = ROL((a), (s)) + (e);\
308 +      (c) = ROL((c), 10);\
309 +   }
310 +#define II(a, b, c, d, e, x, s)        {\
311 +      (a) += I((b), (c), (d)) + (x) + 0x8f1bbcdcUL;\
312 +      (a) = ROL((a), (s)) + (e);\
313 +      (c) = ROL((c), 10);\
314 +   }
315 +#define JJ(a, b, c, d, e, x, s)        {\
316 +      (a) += J((b), (c), (d)) + (x) + 0xa953fd4eUL;\
317 +      (a) = ROL((a), (s)) + (e);\
318 +      (c) = ROL((c), 10);\
319 +   }
320 +#define FFF(a, b, c, d, e, x, s)        {\
321 +      (a) += F((b), (c), (d)) + (x);\
322 +      (a) = ROL((a), (s)) + (e);\
323 +      (c) = ROL((c), 10);\
324 +   }
325 +#define GGG(a, b, c, d, e, x, s)        {\
326 +      (a) += G((b), (c), (d)) + (x) + 0x7a6d76e9UL;\
327 +      (a) = ROL((a), (s)) + (e);\
328 +      (c) = ROL((c), 10);\
329 +   }
330 +#define HHH(a, b, c, d, e, x, s)        {\
331 +      (a) += H((b), (c), (d)) + (x) + 0x6d703ef3UL;\
332 +      (a) = ROL((a), (s)) + (e);\
333 +      (c) = ROL((c), 10);\
334 +   }
335 +#define III(a, b, c, d, e, x, s)        {\
336 +      (a) += I((b), (c), (d)) + (x) + 0x5c4dd124UL;\
337 +      (a) = ROL((a), (s)) + (e);\
338 +      (c) = ROL((c), 10);\
339 +   }
340 +#define JJJ(a, b, c, d, e, x, s)        {\
341 +      (a) += J((b), (c), (d)) + (x) + 0x50a28be6UL;\
342 +      (a) = ROL((a), (s)) + (e);\
343 +      (c) = ROL((c), 10);\
344 +   }
345 +
346 +
347 +/********************************************************************/
348 +
349 +void MDinit(dword *MDbuf)
350 +{
351 +   MDbuf[0] = 0x67452301UL;
352 +   MDbuf[1] = 0xefcdab89UL;
353 +   MDbuf[2] = 0x98badcfeUL;
354 +   MDbuf[3] = 0x10325476UL;
355 +   MDbuf[4] = 0xc3d2e1f0UL;
356 +
357 +   return;
358 +}
359 +
360 +/********************************************************************/
361 +
362 +void compress(dword *MDbuf, dword *X)
363 +{
364 +   dword aa = MDbuf[0],  bb = MDbuf[1],  cc = MDbuf[2],
365 +         dd = MDbuf[3],  ee = MDbuf[4];
366 +   dword aaa = MDbuf[0], bbb = MDbuf[1], ccc = MDbuf[2],
367 +         ddd = MDbuf[3], eee = MDbuf[4];
368 +
369 +   /* round 1 */
370 +   FF(aa, bb, cc, dd, ee, X[ 0], 11);
371 +   FF(ee, aa, bb, cc, dd, X[ 1], 14);
372 +   FF(dd, ee, aa, bb, cc, X[ 2], 15);
373 +   FF(cc, dd, ee, aa, bb, X[ 3], 12);
374 +   FF(bb, cc, dd, ee, aa, X[ 4],  5);
375 +   FF(aa, bb, cc, dd, ee, X[ 5],  8);
376 +   FF(ee, aa, bb, cc, dd, X[ 6],  7);
377 +   FF(dd, ee, aa, bb, cc, X[ 7],  9);
378 +   FF(cc, dd, ee, aa, bb, X[ 8], 11);
379 +   FF(bb, cc, dd, ee, aa, X[ 9], 13);
380 +   FF(aa, bb, cc, dd, ee, X[10], 14);
381 +   FF(ee, aa, bb, cc, dd, X[11], 15);
382 +   FF(dd, ee, aa, bb, cc, X[12],  6);
383 +   FF(cc, dd, ee, aa, bb, X[13],  7);
384 +   FF(bb, cc, dd, ee, aa, X[14],  9);
385 +   FF(aa, bb, cc, dd, ee, X[15],  8);
386 +                             
387 +   /* round 2 */
388 +   GG(ee, aa, bb, cc, dd, X[ 7],  7);
389 +   GG(dd, ee, aa, bb, cc, X[ 4],  6);
390 +   GG(cc, dd, ee, aa, bb, X[13],  8);
391 +   GG(bb, cc, dd, ee, aa, X[ 1], 13);
392 +   GG(aa, bb, cc, dd, ee, X[10], 11);
393 +   GG(ee, aa, bb, cc, dd, X[ 6],  9);
394 +   GG(dd, ee, aa, bb, cc, X[15],  7);
395 +   GG(cc, dd, ee, aa, bb, X[ 3], 15);
396 +   GG(bb, cc, dd, ee, aa, X[12],  7);
397 +   GG(aa, bb, cc, dd, ee, X[ 0], 12);
398 +   GG(ee, aa, bb, cc, dd, X[ 9], 15);
399 +   GG(dd, ee, aa, bb, cc, X[ 5],  9);
400 +   GG(cc, dd, ee, aa, bb, X[ 2], 11);
401 +   GG(bb, cc, dd, ee, aa, X[14],  7);
402 +   GG(aa, bb, cc, dd, ee, X[11], 13);
403 +   GG(ee, aa, bb, cc, dd, X[ 8], 12);
404 +
405 +   /* round 3 */
406 +   HH(dd, ee, aa, bb, cc, X[ 3], 11);
407 +   HH(cc, dd, ee, aa, bb, X[10], 13);
408 +   HH(bb, cc, dd, ee, aa, X[14],  6);
409 +   HH(aa, bb, cc, dd, ee, X[ 4],  7);
410 +   HH(ee, aa, bb, cc, dd, X[ 9], 14);
411 +   HH(dd, ee, aa, bb, cc, X[15],  9);
412 +   HH(cc, dd, ee, aa, bb, X[ 8], 13);
413 +   HH(bb, cc, dd, ee, aa, X[ 1], 15);
414 +   HH(aa, bb, cc, dd, ee, X[ 2], 14);
415 +   HH(ee, aa, bb, cc, dd, X[ 7],  8);
416 +   HH(dd, ee, aa, bb, cc, X[ 0], 13);
417 +   HH(cc, dd, ee, aa, bb, X[ 6],  6);
418 +   HH(bb, cc, dd, ee, aa, X[13],  5);
419 +   HH(aa, bb, cc, dd, ee, X[11], 12);
420 +   HH(ee, aa, bb, cc, dd, X[ 5],  7);
421 +   HH(dd, ee, aa, bb, cc, X[12],  5);
422 +
423 +   /* round 4 */
424 +   II(cc, dd, ee, aa, bb, X[ 1], 11);
425 +   II(bb, cc, dd, ee, aa, X[ 9], 12);
426 +   II(aa, bb, cc, dd, ee, X[11], 14);
427 +   II(ee, aa, bb, cc, dd, X[10], 15);
428 +   II(dd, ee, aa, bb, cc, X[ 0], 14);
429 +   II(cc, dd, ee, aa, bb, X[ 8], 15);
430 +   II(bb, cc, dd, ee, aa, X[12],  9);
431 +   II(aa, bb, cc, dd, ee, X[ 4],  8);
432 +   II(ee, aa, bb, cc, dd, X[13],  9);
433 +   II(dd, ee, aa, bb, cc, X[ 3], 14);
434 +   II(cc, dd, ee, aa, bb, X[ 7],  5);
435 +   II(bb, cc, dd, ee, aa, X[15],  6);
436 +   II(aa, bb, cc, dd, ee, X[14],  8);
437 +   II(ee, aa, bb, cc, dd, X[ 5],  6);
438 +   II(dd, ee, aa, bb, cc, X[ 6],  5);
439 +   II(cc, dd, ee, aa, bb, X[ 2], 12);
440 +
441 +   /* round 5 */
442 +   JJ(bb, cc, dd, ee, aa, X[ 4],  9);
443 +   JJ(aa, bb, cc, dd, ee, X[ 0], 15);
444 +   JJ(ee, aa, bb, cc, dd, X[ 5],  5);
445 +   JJ(dd, ee, aa, bb, cc, X[ 9], 11);
446 +   JJ(cc, dd, ee, aa, bb, X[ 7],  6);
447 +   JJ(bb, cc, dd, ee, aa, X[12],  8);
448 +   JJ(aa, bb, cc, dd, ee, X[ 2], 13);
449 +   JJ(ee, aa, bb, cc, dd, X[10], 12);
450 +   JJ(dd, ee, aa, bb, cc, X[14],  5);
451 +   JJ(cc, dd, ee, aa, bb, X[ 1], 12);
452 +   JJ(bb, cc, dd, ee, aa, X[ 3], 13);
453 +   JJ(aa, bb, cc, dd, ee, X[ 8], 14);
454 +   JJ(ee, aa, bb, cc, dd, X[11], 11);
455 +   JJ(dd, ee, aa, bb, cc, X[ 6],  8);
456 +   JJ(cc, dd, ee, aa, bb, X[15],  5);
457 +   JJ(bb, cc, dd, ee, aa, X[13],  6);
458 +
459 +   /* parallel round 1 */
460 +   JJJ(aaa, bbb, ccc, ddd, eee, X[ 5],  8);
461 +   JJJ(eee, aaa, bbb, ccc, ddd, X[14],  9);
462 +   JJJ(ddd, eee, aaa, bbb, ccc, X[ 7],  9);
463 +   JJJ(ccc, ddd, eee, aaa, bbb, X[ 0], 11);
464 +   JJJ(bbb, ccc, ddd, eee, aaa, X[ 9], 13);
465 +   JJJ(aaa, bbb, ccc, ddd, eee, X[ 2], 15);
466 +   JJJ(eee, aaa, bbb, ccc, ddd, X[11], 15);
467 +   JJJ(ddd, eee, aaa, bbb, ccc, X[ 4],  5);
468 +   JJJ(ccc, ddd, eee, aaa, bbb, X[13],  7);
469 +   JJJ(bbb, ccc, ddd, eee, aaa, X[ 6],  7);
470 +   JJJ(aaa, bbb, ccc, ddd, eee, X[15],  8);
471 +   JJJ(eee, aaa, bbb, ccc, ddd, X[ 8], 11);
472 +   JJJ(ddd, eee, aaa, bbb, ccc, X[ 1], 14);
473 +   JJJ(ccc, ddd, eee, aaa, bbb, X[10], 14);
474 +   JJJ(bbb, ccc, ddd, eee, aaa, X[ 3], 12);
475 +   JJJ(aaa, bbb, ccc, ddd, eee, X[12],  6);
476 +
477 +   /* parallel round 2 */
478 +   III(eee, aaa, bbb, ccc, ddd, X[ 6],  9); 
479 +   III(ddd, eee, aaa, bbb, ccc, X[11], 13);
480 +   III(ccc, ddd, eee, aaa, bbb, X[ 3], 15);
481 +   III(bbb, ccc, ddd, eee, aaa, X[ 7],  7);
482 +   III(aaa, bbb, ccc, ddd, eee, X[ 0], 12);
483 +   III(eee, aaa, bbb, ccc, ddd, X[13],  8);
484 +   III(ddd, eee, aaa, bbb, ccc, X[ 5],  9);
485 +   III(ccc, ddd, eee, aaa, bbb, X[10], 11);
486 +   III(bbb, ccc, ddd, eee, aaa, X[14],  7);
487 +   III(aaa, bbb, ccc, ddd, eee, X[15],  7);
488 +   III(eee, aaa, bbb, ccc, ddd, X[ 8], 12);
489 +   III(ddd, eee, aaa, bbb, ccc, X[12],  7);
490 +   III(ccc, ddd, eee, aaa, bbb, X[ 4],  6);
491 +   III(bbb, ccc, ddd, eee, aaa, X[ 9], 15);
492 +   III(aaa, bbb, ccc, ddd, eee, X[ 1], 13);
493 +   III(eee, aaa, bbb, ccc, ddd, X[ 2], 11);
494 +
495 +   /* parallel round 3 */
496 +   HHH(ddd, eee, aaa, bbb, ccc, X[15],  9);
497 +   HHH(ccc, ddd, eee, aaa, bbb, X[ 5],  7);
498 +   HHH(bbb, ccc, ddd, eee, aaa, X[ 1], 15);
499 +   HHH(aaa, bbb, ccc, ddd, eee, X[ 3], 11);
500 +   HHH(eee, aaa, bbb, ccc, ddd, X[ 7],  8);
501 +   HHH(ddd, eee, aaa, bbb, ccc, X[14],  6);
502 +   HHH(ccc, ddd, eee, aaa, bbb, X[ 6],  6);
503 +   HHH(bbb, ccc, ddd, eee, aaa, X[ 9], 14);
504 +   HHH(aaa, bbb, ccc, ddd, eee, X[11], 12);
505 +   HHH(eee, aaa, bbb, ccc, ddd, X[ 8], 13);
506 +   HHH(ddd, eee, aaa, bbb, ccc, X[12],  5);
507 +   HHH(ccc, ddd, eee, aaa, bbb, X[ 2], 14);
508 +   HHH(bbb, ccc, ddd, eee, aaa, X[10], 13);
509 +   HHH(aaa, bbb, ccc, ddd, eee, X[ 0], 13);
510 +   HHH(eee, aaa, bbb, ccc, ddd, X[ 4],  7);
511 +   HHH(ddd, eee, aaa, bbb, ccc, X[13],  5);
512 +
513 +   /* parallel round 4 */   
514 +   GGG(ccc, ddd, eee, aaa, bbb, X[ 8], 15);
515 +   GGG(bbb, ccc, ddd, eee, aaa, X[ 6],  5);
516 +   GGG(aaa, bbb, ccc, ddd, eee, X[ 4],  8);
517 +   GGG(eee, aaa, bbb, ccc, ddd, X[ 1], 11);
518 +   GGG(ddd, eee, aaa, bbb, ccc, X[ 3], 14);
519 +   GGG(ccc, ddd, eee, aaa, bbb, X[11], 14);
520 +   GGG(bbb, ccc, ddd, eee, aaa, X[15],  6);
521 +   GGG(aaa, bbb, ccc, ddd, eee, X[ 0], 14);
522 +   GGG(eee, aaa, bbb, ccc, ddd, X[ 5],  6);
523 +   GGG(ddd, eee, aaa, bbb, ccc, X[12],  9);
524 +   GGG(ccc, ddd, eee, aaa, bbb, X[ 2], 12);
525 +   GGG(bbb, ccc, ddd, eee, aaa, X[13],  9);
526 +   GGG(aaa, bbb, ccc, ddd, eee, X[ 9], 12);
527 +   GGG(eee, aaa, bbb, ccc, ddd, X[ 7],  5);
528 +   GGG(ddd, eee, aaa, bbb, ccc, X[10], 15);
529 +   GGG(ccc, ddd, eee, aaa, bbb, X[14],  8);
530 +
531 +   /* parallel round 5 */
532 +   FFF(bbb, ccc, ddd, eee, aaa, X[12] ,  8);
533 +   FFF(aaa, bbb, ccc, ddd, eee, X[15] ,  5);
534 +   FFF(eee, aaa, bbb, ccc, ddd, X[10] , 12);
535 +   FFF(ddd, eee, aaa, bbb, ccc, X[ 4] ,  9);
536 +   FFF(ccc, ddd, eee, aaa, bbb, X[ 1] , 12);
537 +   FFF(bbb, ccc, ddd, eee, aaa, X[ 5] ,  5);
538 +   FFF(aaa, bbb, ccc, ddd, eee, X[ 8] , 14);
539 +   FFF(eee, aaa, bbb, ccc, ddd, X[ 7] ,  6);
540 +   FFF(ddd, eee, aaa, bbb, ccc, X[ 6] ,  8);
541 +   FFF(ccc, ddd, eee, aaa, bbb, X[ 2] , 13);
542 +   FFF(bbb, ccc, ddd, eee, aaa, X[13] ,  6);
543 +   FFF(aaa, bbb, ccc, ddd, eee, X[14] ,  5);
544 +   FFF(eee, aaa, bbb, ccc, ddd, X[ 0] , 15);
545 +   FFF(ddd, eee, aaa, bbb, ccc, X[ 3] , 13);
546 +   FFF(ccc, ddd, eee, aaa, bbb, X[ 9] , 11);
547 +   FFF(bbb, ccc, ddd, eee, aaa, X[11] , 11);
548 +
549 +   /* combine results */
550 +   ddd += cc + MDbuf[1];               /* final result for MDbuf[0] */
551 +   MDbuf[1] = MDbuf[2] + dd + eee;
552 +   MDbuf[2] = MDbuf[3] + ee + aaa;
553 +   MDbuf[3] = MDbuf[4] + aa + bbb;
554 +   MDbuf[4] = MDbuf[0] + bb + ccc;
555 +   MDbuf[0] = ddd;
556 +
557 +   return;
558 +}
559 +
560 +/********************************************************************/
561 +
562 +void MDfinish(dword *MDbuf, byte *strptr, dword lswlen, dword mswlen)
563 +{
564 +   unsigned int i;                                 /* counter       */
565 +   dword        X[16];                             /* message words */
566 +
567 +   memset(X, 0, 16*sizeof(dword));
568 +
569 +   /* put bytes from strptr into X */
570 +   for (i=0; i<(lswlen&63); i++) {
571 +      /* byte i goes into word X[i div 4] at pos.  8*(i mod 4)  */
572 +      X[i>>2] ^= (dword) *strptr++ << (8 * (i&3));
573 +   }
574 +
575 +   /* append "1" bit to the message. Be careful :
576 +      message = "" -> "10000000" = 128 */
577 +   X[(lswlen>>2)&15] ^= (dword)1 << (8*(lswlen&3)+7);
578 +
579 +   if ((lswlen & 63) > 55) {
580 +      /* length goes to next block */
581 +      compress(MDbuf, X);
582 +      memset(X, 0, 16*sizeof(dword));
583 +   }
584 +
585 +   /* append length in bits*/
586 +   X[14] = lswlen << 3;
587 +   X[15] = (lswlen >> 29) | (mswlen << 3);
588 +   compress(MDbuf, X);
589 +
590 +   return;
591 +}
592 +
593 +void MDcalc(byte *MD,byte *sp,dword sl)
594 +{ dword X[16];
595 +  dword MDbuf[5];
596 +  int i,j;
597 +   
598 +  MDinit(MDbuf);
599 +  
600 +  while (sl >= 64)
601 +  {
602 +    memset(X,0,16*sizeof(dword));
603 +    
604 +    for (i=0; i<64; i++)
605 +        X[i>>2] |= ((dword)(*sp++)) << (8 * (i&3));
606 +  
607 +    sl-=64;
608 +    compress(MDbuf,X);
609 +    
610 +  };
611 +  MDfinish(MDbuf,sp,sl,0);
612 +  
613 +  for (i=0;i<5;i++)
614 +    for (j=0;j<4;j++)
615 +      *MD++=(byte)((MDbuf[i]>>(j*8))&0xFF);
616 +}
617 +    
618 +/************************ end of file rmd160.c **********************/
619 +
620 diff -urN util-linux-2.9w/mount/rmd160.h util-linux-2.9w.int/mount/rmd160.h
621 --- util-linux-2.9w/mount/rmd160.h      Thu Jan  1 01:00:00 1970
622 +++ util-linux-2.9w.int/mount/rmd160.h  Mon Sep  6 14:05:07 1999
623 @@ -0,0 +1,58 @@
624 +/********************************************************************\
625 + *
626 + *      FILE:     rmd160.h
627 + *
628 + *      CONTENTS: Header file for a sample C-implementation of the
629 + *                RIPEMD-160 hash-function. 
630 + *      TARGET:   any computer with an ANSI C compiler
631 + *
632 + *      AUTHOR:   Antoon Bosselaers, ESAT-COSIC
633 + *      DATE:     1 March 1996
634 + *      VERSION:  1.0
635 + *
636 + *      Copyright (c) Katholieke Universiteit Leuven
637 + *      1996, All Rights Reserved
638 + *
639 +\********************************************************************/
640 +
641 +#ifndef  RMD160H           /* make sure this file is read only once */
642 +#define  RMD160H
643 +
644 +/********************************************************************/
645 +
646 +/* typedef 8 and 32 bit types, resp.  */
647 +/* adapt these, if necessary, 
648 +   for your operating system and compiler */
649 +
650 +typedef    unsigned char        byte;
651 +typedef    unsigned long        dword;
652 +
653 +/********************************************************************/
654 +
655 +/* function prototypes */
656 +
657 +void MDinit(dword *MDbuf);
658 +/*
659 + *  initializes MDbuffer to "magic constants"
660 + */
661 +
662 +void compress(dword *MDbuf, dword *X);
663 +/*
664 + *  the compression function.
665 + *  transforms MDbuf using message bytes X[0] through X[15]
666 + */
667 +
668 +void MDfinish(dword *MDbuf, byte *strptr, dword lswlen, dword mswlen);
669 +/*
670 + *  puts bytes from strptr into X and pad out; appends length 
671 + *  and finally, compresses the last block(s)
672 + *  note: length in bits == 8 * (lswlen + 2^32 mswlen).
673 + *  note: there are (lswlen mod 64) bytes left in strptr.
674 + */
675 +
676 +void MDcalc(byte *MDbuf,byte *sp,dword sl);
677 +
678 +#endif  /* RMD160H */
679 +
680 +/*********************** end of file rmd160.h ***********************/
681 +
This page took 0.129553 seconds and 3 git commands to generate.