]> git.pld-linux.org Git - packages/util-linux.git/blob - util-linux-cryptoapi.patch
- added no_multiline patch... needed for gettext in gcc33
[packages/util-linux.git] / util-linux-cryptoapi.patch
1 diff -Nur util-linux-2.11zorg/mount/Makefile util-linux-2.11z/mount/Makefile
2 --- util-linux-2.11zorg/mount/Makefile  Tue Nov 26 09:53:59 2002
3 +++ util-linux-2.11z/mount/Makefile     Fri Mar 28 21:43:00 2003
4 @@ -24,7 +24,7 @@
5  
6  MAYBE = pivot_root swapoff
7  
8 -LO_OBJS = lomount.o $(LIB)/xstrncpy.o
9 +LO_OBJS = lomount.o $(LIB)/xstrncpy.o sha512.o rmd160.o
10  NFS_OBJS = nfsmount.o nfsmount_xdr.o nfsmount_clnt.o
11  GEN_FILES = nfsmount.h nfsmount_xdr.c nfsmount_clnt.c
12  
13 @@ -57,9 +57,13 @@
14  main_losetup.o: lomount.c
15         $(COMPILE) -DMAIN lomount.c -o $@
16  
17 -losetup: main_losetup.o $(LIB)/xstrncpy.o
18 +losetup: main_losetup.o $(LIB)/xstrncpy.o sha512.o rmd160.o
19         $(LINK) $^ -o $@
20  
21 +rmd160.o lomount.o main_losetup.o: rmd160.h
22 +
23 +sha512.o lomount.o main_losetup.o: sha512.h
24 +
25  mount.o umount.o nfsmount.o losetup.o fstab.o realpath.o sundries.o: sundries.h
26  
27  mount.o umount.o fstab.o sundries.o: fstab.h
28 diff -Nur util-linux-2.11zorg/mount/lomount.c util-linux-2.11z/mount/lomount.c
29 --- util-linux-2.11zorg/mount/lomount.c Fri Nov  1 01:58:51 2002
30 +++ util-linux-2.11z/mount/lomount.c    Fri Mar 28 21:43:00 2003
31 @@ -6,6 +6,11 @@
32   * - added Native Language Support
33   * Sun Mar 21 1999 - Arnaldo Carvalho de Melo <acme@conectiva.com.br>
34   * - fixed strerr(errno) in gettext calls
35 + * 2000-09-24 Marc Mutz <Marc@Mutz.com>
36 + * - added long option names and the --pass-fd option to pass
37 + *   passphrases via fd's to losetup/mount. Used for encryption in
38 + *   non-interactive environments. The idea behind xgetpass() is stolen
39 + *   from GnuPG, v.1.0.3 (http://www.gnupg.org/).
40   */
41  
42  #define PROC_DEVICES   "/proc/devices"
43 @@ -21,6 +26,7 @@
44  #include <errno.h>
45  #include <stdlib.h>
46  #include <unistd.h>
47 +#include <limits.h>
48  #include <sys/ioctl.h>
49  #include <sys/stat.h>
50  #include <sys/mman.h>
51 @@ -28,48 +34,102 @@
52  
53  #include "loop.h"
54  #include "lomount.h"
55 +#include "rmd160.h"
56 +#include "sha512.h"
57  #include "xstrncpy.h"
58  #include "nls.h"
59  
60 +#ifndef LO_CRYPT_CRYPTOAPI
61 +#define LO_CRYPT_CRYPTOAPI 18
62 +#endif
63 +#ifndef LO_CRYPT_NONE
64 +#define LO_CRYPT_NONE 0
65 +#endif
66 +#ifndef LO_CRYPT_XOR
67 +#define LO_CRYPT_XOR 1
68 +#endif
69 +#ifndef LO_CRYPT_DES
70 +#define LO_CRYPT_DES 2
71 +#endif
72 +#ifndef LO_CRYPT_FISH2
73 +#define LO_CRYPT_FISH2 3
74 +#endif
75 +#ifndef LO_CRYPT_BLOW
76 +#define LO_CRYPT_BLOW 4
77 +#endif
78 +#ifndef LO_CRYPT_CAST128
79 +#define LO_CRYPT_CAST128 5
80 +#endif
81 +#ifndef LO_CRYPT_IDEA
82 +#define LO_CRYPT_IDEA 6
83 +#endif
84 +#ifndef LO_CRYPT_SERPENT
85 +#define LO_CRYPT_SERPENT 7
86 +#endif
87 +#ifndef LO_CRYPT_MARS
88 +#define LO_CRYPT_MARS 8
89 +#endif
90 +#ifndef LO_CRYPT_RC6
91 +#define LO_CRYPT_RC6 11
92 +#endif
93 +#ifndef LO_CRYPT_3DES
94 +#define LO_CRYPT_3DES 12
95 +#endif
96 +#ifndef LO_CRYPT_DFC
97 +#define LO_CRYPT_DFC 15
98 +#endif
99 +#ifndef LO_CRYPT_RIJNDAEL
100 +#define LO_CRYPT_RIJNDAEL 16
101 +#endif
102 +
103 +
104  extern int verbose;
105  extern char *xstrdup (const char *s);  /* not: #include "sundries.h" */
106  extern void error (const char *fmt, ...);      /* idem */
107  
108 +
109 +struct cipher_info
110 +{
111 +       const char *name;
112 +       int blocksize;
113 +       int keysize_mask;
114 +       int ivsize;
115 +       int key_schedule_size;
116 +};
117 +
118 +static int set_loop_passwd(struct loop_info *_loopinfo, int pfd, int keysz,
119 +                          const char *phash_name, const char *encryption, 
120 +                          int fd, int ffd);
121 +static int get_cipher_info(const char *name, struct cipher_info *res);
122 +static int name_to_id(const char *name);
123 +#ifdef MAIN
124 +static char *id_to_name(int id);
125 +#endif
126
127 +
128  #ifdef LOOP_SET_FD
129  struct crypt_type_struct {
130         int id;
131         char *name;
132 +       int keylength;
133  } crypt_type_tbl[] = {
134 -       { LO_CRYPT_NONE, "no" },
135 -       { LO_CRYPT_NONE, "none" },
136 -       { LO_CRYPT_XOR, "xor" },
137 -       { LO_CRYPT_DES, "DES" },
138 -       { -1, NULL   }
139 +        { LO_CRYPT_NONE, "none", 0 },
140 +        { LO_CRYPT_XOR, "xor", 0 },
141 +        { LO_CRYPT_DES, "des", 8 },
142 +        { LO_CRYPT_FISH2, "twofish", 20 },
143 +        { LO_CRYPT_BLOW, "blowfish", 20 },
144 +        { LO_CRYPT_CAST128, "cast", 16 },
145 +        { LO_CRYPT_SERPENT, "serpent", 16 },
146 +        { LO_CRYPT_MARS, "mars", 16 },
147 +        { LO_CRYPT_RC6, "rc6", 16 },
148 +        { LO_CRYPT_3DES, "des-ede3", 24 },
149 +        { LO_CRYPT_DFC, "dfc", 16 },
150 +        { LO_CRYPT_IDEA, "idea", 16 },
151 +        { LO_CRYPT_RIJNDAEL, "rijndael", 16 },
152 +       { -1, NULL,0   }
153  };
154  
155 -static int 
156 -crypt_type (const char *name) {
157 -       int i;
158 -
159 -       if (name) {
160 -               for (i = 0; crypt_type_tbl[i].id != -1; i++)
161 -                       if (!strcasecmp (name, crypt_type_tbl[i].name))
162 -                               return crypt_type_tbl[i].id;
163 -       }
164 -       return -1;
165 -}
166 -
167  #ifdef MAIN
168 -static char *
169 -crypt_name (int id) {
170 -       int i;
171 -
172 -       for (i = 0; crypt_type_tbl[i].id != -1; i++)
173 -               if (id == crypt_type_tbl[i].id)
174 -                       return crypt_type_tbl[i].name;
175 -       return "undefined";
176 -}
177 -
178  static int
179  show_loop (char *device) {
180         struct loop_info loopinfo;
181 @@ -91,7 +151,7 @@
182         printf (_("%s: [%04x]:%ld (%s) offset %d, %s encryption\n"),
183                 device, loopinfo.lo_device, loopinfo.lo_inode,
184                 loopinfo.lo_name, loopinfo.lo_offset,
185 -               crypt_name (loopinfo.lo_encrypt_type));
186 +               id_to_name(loopinfo.lo_encrypt_type));
187         close (fd);
188  
189         return 0;
190 @@ -184,24 +244,62 @@
191                 error(_(
192                     "mount: Could not find any loop device, and, according to %s,\n"
193                     "       this kernel does not know about the loop device.\n"
194 -                   "       (If so, then recompile or `insmod loop.o'.)"),
195 +                   "       (If so, then recompile or `modprobe loop'.)"),
196                       PROC_DEVICES);
197             else
198                 error(_(
199                     "mount: Could not find any loop device. Maybe this kernel does not know\n"
200 -                   "       about the loop device (then recompile or `insmod loop.o'), or\n"
201 +                   "       about the loop device (then recompile or `modprobe loop'), or\n"
202                     "       maybe /dev/loop# has the wrong major number?"));
203         } else
204                 error(_("mount: could not find any free loop device"));
205         return 0;
206  }
207  
208 +/* A function to read the passphrase either from the terminal or from
209 + * an open file descriptor */
210 +static char *
211 +xgetpass (int pfd, const char *prompt)
212 +{
213 +        if (pfd < 0) /* terminal */
214 +               return (getpass(prompt));
215 +       else {       /* file descriptor */
216 +               char *pass = NULL;
217 +               int buflen, i;
218 +
219 +               buflen=0;
220 +               for (i=0; ; i++) {
221 +                       if (i >= buflen-1) {
222 +                               /* we're running out of space in the buffer. 
223 +                                * Make it bigger: */
224 +                               char *tmppass = pass;
225 +                               buflen += 128;
226 +                               pass = realloc(tmppass,buflen);
227 +                               if (pass == NULL) {
228 +                                       /* realloc failed. Stop reading _now_. */
229 +                                       error("not enough memory while reading passphrase");
230 +                                       pass = tmppass; /* the old buffer hasn't changed */
231 +                                       break;
232 +                               }
233 +                       };
234 +                       if ( read(pfd,pass+i, 1) != 1 || pass[i] == '\n' )
235 +                               break;
236 +               }
237 +               if (pass == NULL)
238 +                       return "";
239 +               else {
240 +                       pass[i] = 0;
241 +                       return pass;
242 +               }
243 +       }
244 +}
245 +
246  int
247  set_loop (const char *device, const char *file, int offset,
248 -         const char *encryption, int *loopro) {
249 +         const char *encryption, int pfd, int keysz, int *loopro, 
250 +         const char *phash_name) {
251         struct loop_info loopinfo;
252 -       int fd, ffd, mode, i;
253 -       char *pass;
254 +       int fd, ffd, mode, tried_old;
255  
256         mode = (*loopro ? O_RDONLY : O_RDWR);
257         if ((ffd = open (file, mode)) < 0) {
258 @@ -219,13 +317,10 @@
259         *loopro = (mode == O_RDONLY);
260  
261         memset (&loopinfo, 0, sizeof (loopinfo));
262 -       xstrncpy (loopinfo.lo_name, file, LO_NAME_SIZE);
263 -       if (encryption && (loopinfo.lo_encrypt_type = crypt_type (encryption))
264 -           < 0) {
265 -               fprintf (stderr, _("Unsupported encryption type %s\n"),
266 -                        encryption);
267 -               return 1;
268 -       }
269 +       snprintf(loopinfo.lo_name, sizeof(loopinfo.lo_name),
270 +                "%s-cbc", encryption);
271 +       loopinfo.lo_name[LO_NAME_SIZE - 1] = 0;
272 +       loopinfo.lo_encrypt_type = LO_CRYPT_CRYPTOAPI;
273         loopinfo.lo_offset = offset;
274  
275  #ifdef MCL_FUTURE  
276 @@ -241,24 +336,148 @@
277         }
278  #endif
279  
280 -       switch (loopinfo.lo_encrypt_type) {
281 +       if (ioctl (fd, LOOP_SET_FD, ffd) < 0) {
282 +               perror ("ioctl: LOOP_SET_FD");
283 +               return 1;
284 +       }
285 +
286 +       tried_old = 0;
287 +again:
288 +       set_loop_passwd(&loopinfo, pfd, keysz, phash_name, encryption, fd, ffd);
289 +
290 +       if (ioctl (fd, LOOP_SET_STATUS, &loopinfo) < 0) {
291 +               /* Try again with old-style LO_CRYPT_XX if
292 +                   new-style LO_CRYPT_CRYPTOAPI ioctl didn't work */
293 +               if (tried_old) {
294 +                       error("The cipher does not exist, or a cipher module "
295 +                             "needs to be loaded into the kernel");
296 +                       perror ("ioctl: LOOP_SET_STATUS");
297 +                       goto out_ioctl;
298 +               }
299 +               strncpy (loopinfo.lo_name, file, LO_NAME_SIZE);
300 +               loopinfo.lo_name[LO_NAME_SIZE - 1] = 0;
301 +               loopinfo.lo_encrypt_type = name_to_id (encryption);
302 +               tried_old = 1;
303 +               goto again;
304 +       }
305 +       close (fd);
306 +       close (ffd);
307 +       if (verbose > 1)
308 +               printf(_("set_loop(%s,%s,%d): success\n"),
309 +                      device, file, offset);
310 +       return 0;
311 +out_ioctl:
312 +       (void) ioctl (fd, LOOP_CLR_FD, 0);
313 +       return 1;
314 +}
315 +
316 +
317 +
318 +typedef int (*phash_func_t)(char dest[LO_KEY_SIZE], const char src[], size_t src_len);
319 +
320 +#define PASSWDBUFFLEN 130
321 +
322 +static int
323 +phash_rmd160old (char dest[LO_KEY_SIZE], const char src[], size_t src_len)
324 +{
325 +  char tmp[PASSWDBUFFLEN] = { 'A', 0, };
326 +  char key[RMD160_HASH_SIZE * 2] = { 0, };
327 +
328 +  strncpy (tmp + 1, src, PASSWDBUFFLEN - 1);
329 +  tmp[PASSWDBUFFLEN - 1] = '\0';
330 +  
331 +  rmd160_hash_buffer(key, src, src_len);
332 +  rmd160_hash_buffer(key + RMD160_HASH_SIZE, tmp, src_len + 1 /* dangerous! */);
333 +
334 +  memcpy (dest, key, LO_KEY_SIZE);
335 +
336 +  return 0;
337 +}
338 +
339 +static int
340 +phash_sha256 (char dest[LO_KEY_SIZE], const char src[], size_t src_len)
341 +{
342 +  memset (dest, 0, LO_KEY_SIZE);
343 +  sha256_hash_buffer ((char *) src, src_len, dest, LO_KEY_SIZE);
344 +  return 0;
345 +}
346 +
347 +static int
348 +phash_sha384 (char dest[LO_KEY_SIZE], const char src[], size_t src_len)
349 +{
350 +  memset (dest, 0, LO_KEY_SIZE);
351 +  sha384_hash_buffer ((char *) src, src_len, dest, LO_KEY_SIZE);
352 +  return 0;
353 +}
354 +
355 +static int
356 +phash_sha512 (char dest[LO_KEY_SIZE], const char src[], size_t src_len)
357 +{
358 +  memset (dest, 0, LO_KEY_SIZE);
359 +  sha512_hash_buffer ((char *) src, src_len, dest, LO_KEY_SIZE);
360 +  return 0;
361 +}
362 +
363 +static int
364 +phash_default (char dest[LO_KEY_SIZE], const char src[], size_t src_len)
365 +{
366 +  fprintf (stderr, "unknown hash type requested\n");
367 +  return 1;
368 +}
369 +
370 +static phash_func_t 
371 +phash_lookup (const char phash_name[])
372 +{
373 +  struct {
374 +    const char *name;
375 +    phash_func_t func;
376 +  } func_table[] = {
377 +    {"rmd160old", phash_rmd160old },
378 +    {"sha256",    phash_sha256 },
379 +    {"sha384",    phash_sha384 },
380 +    {"sha512",    phash_sha512 },
381 +    { 0, phash_default }
382 +  }, *p = func_table;
383 +
384 +  for (; p->name; p++)
385 +    if (!strcmp (phash_name, p->name))
386 +      break;
387 +  
388 +  return p->func;
389 +}
390 +
391 +
392 +int
393 +set_loop_passwd(struct loop_info *loopinfo, int pfd, int keysz, 
394 +               const char *phash_name, const char *encryption,
395 +               int fd, int ffd)
396 +{
397 +       int i;
398 +       int keylength;
399 +       char *pass;
400 +       struct cipher_info info;
401 +
402 +       switch (loopinfo->lo_encrypt_type) {
403         case LO_CRYPT_NONE:
404 -               loopinfo.lo_encrypt_key_size = 0;
405 +               loopinfo->lo_encrypt_key_size = 0;
406                 break;
407         case LO_CRYPT_XOR:
408 -               pass = getpass (_("Password: "));
409 -               xstrncpy (loopinfo.lo_encrypt_key, pass, LO_KEY_SIZE);
410 -               loopinfo.lo_encrypt_key_size = strlen(loopinfo.lo_encrypt_key);
411 +          /* WARNING: xgetpass() can return massive amounts of data,
412 +           * not only 128 bytes like the original getpass(3) */
413 +               pass = xgetpass (pfd,_("Password: "));
414 +               xstrncpy (loopinfo->lo_encrypt_key, pass, LO_KEY_SIZE);
415 +               loopinfo->lo_encrypt_key_size = strlen(loopinfo->lo_encrypt_key);
416                 break;
417         case LO_CRYPT_DES:
418 -               pass = getpass (_("Password: "));
419 -               strncpy (loopinfo.lo_encrypt_key, pass, 8);
420 -               loopinfo.lo_encrypt_key[8] = 0;
421 -               loopinfo.lo_encrypt_key_size = 8;
422 +               printf(_("WARNING: Use of DES is depreciated.\n"));
423 +               pass = xgetpass (pfd,_("Password: "));
424 +               strncpy (loopinfo->lo_encrypt_key, pass, 8);
425 +               loopinfo->lo_encrypt_key[8] = 0;
426 +               loopinfo->lo_encrypt_key_size = 8;
427                 pass = getpass (_("Init (up to 16 hex digits): "));
428                 for (i = 0; i < 16 && pass[i]; i++)
429                         if (isxdigit (pass[i])) {
430 -                               loopinfo.lo_init[i >> 3] |= (pass[i] > '9' ?
431 +                               loopinfo->lo_init[i >> 3] |= (pass[i] > '9' ?
432                                   (islower (pass[i]) ? toupper (pass[i]) :
433                                    pass[i])-'A'+10 : pass[i]-'0') << (i&7) * 4;
434                         } else {
435 @@ -267,29 +486,83 @@
436                                 return 1;
437                         }
438                 break;
439 +       case LO_CRYPT_FISH2:
440 +       case LO_CRYPT_BLOW:
441 +       case LO_CRYPT_IDEA:
442 +       case LO_CRYPT_CAST128:
443 +        case LO_CRYPT_SERPENT:
444 +        case LO_CRYPT_MARS:
445 +        case LO_CRYPT_RC6:
446 +        case LO_CRYPT_3DES:
447 +        case LO_CRYPT_DFC:
448 +        case LO_CRYPT_RIJNDAEL:
449 +               pass = xgetpass(pfd, _("Password: "));
450 +
451 +               if (phash_lookup (phash_name) (loopinfo->lo_encrypt_key, pass, strlen (pass)))
452 +                       return 1;
453 +
454 +               keylength=0;
455 +               for(i=0; crypt_type_tbl[i].id != -1; i++){
456 +                        if(loopinfo->lo_encrypt_type == crypt_type_tbl[i].id){
457 +                                keylength = crypt_type_tbl[i].keylength;
458 +                                break;
459 +                        }
460 +               }
461 +               loopinfo->lo_encrypt_key_size = keylength;
462 +               break;
463 +       case LO_CRYPT_CRYPTOAPI:
464 +               /* Give the kernel an opportunity to load the cipher */
465 +               (void) ioctl (fd, LOOP_SET_STATUS, loopinfo);
466 +               if (get_cipher_info(loopinfo->lo_name, &info) < 0) {
467 +                       return 1;
468 +               }
469 +               if (keysz > 0 &&
470 +                   !((1 << ((keysz / 8) - 1)) & info.keysize_mask)) {
471 +                       error("The specified keysize is not supported by "
472 +                             "the selected cipher");
473 +                       keysz = 0;
474 +               }
475 +
476 +               while (keysz <= 0 ||
477 +                      !((1 << ((keysz / 8) - 1)) & info.keysize_mask)) {
478 +                       int i = 0;
479 +                       int available = 0;
480 +                       char keysize[200];
481 +                       printf("Available keysizes (bits): ");
482 +                       for (; i < 32; i++) {
483 +                               if (info.keysize_mask & (1 << i)) {
484 +                                       printf("%d ", 8*(i+1));
485 +                                       available = 1;
486 +                               }
487 +                       }
488 +                       if (!available) {
489 +                               printf("none");
490 +                       }
491 +                       printf("\nKeysize: ");
492 +                       fgets(keysize, sizeof(keysize), stdin);
493 +                       keysz = atoi(keysize);
494 +               }
495 +
496 +               pass = xgetpass(pfd, _("Password: "));
497 +
498 +               if (phash_lookup (phash_name) (loopinfo->lo_encrypt_key, pass, strlen (pass)))
499 +                       return 1;
500 +
501 +               loopinfo->lo_encrypt_key_size=keysz/8;
502 +
503 +               break;
504         default:
505                 fprintf (stderr,
506                          _("Don't know how to get key for encryption system %d\n"),
507 -                        loopinfo.lo_encrypt_type);
508 +                        loopinfo->lo_encrypt_type);
509                 return 1;
510         }
511 -       if (ioctl (fd, LOOP_SET_FD, ffd) < 0) {
512 -               perror ("ioctl: LOOP_SET_FD");
513 -               return 1;
514 -       }
515 -       if (ioctl (fd, LOOP_SET_STATUS, &loopinfo) < 0) {
516 -               (void) ioctl (fd, LOOP_CLR_FD, 0);
517 -               perror ("ioctl: LOOP_SET_STATUS");
518 -               return 1;
519 -       }
520 -       close (fd);
521 -       close (ffd);
522 -       if (verbose > 1)
523 -               printf(_("set_loop(%s,%s,%d): success\n"),
524 -                      device, file, offset);
525 -       return 0;
526 +        return 0;
527  }
528  
529 +
530 +
531 +
532  int 
533  del_loop (const char *device) {
534         int fd;
535 @@ -320,7 +593,7 @@
536  
537  int
538  set_loop (const char *device, const char *file, int offset,
539 -         const char *encryption, int *loopro) {
540 +         const char *encryption, int pfd, int *loopro) {
541         mutter();
542         return 1;
543  }
544 @@ -349,12 +622,45 @@
545  int verbose = 0;
546  static char *progname;
547  
548 +static struct option longopts[] = {
549 +       { "delete", 0, 0, 'd' },
550 +       { "detach", 0, 0, 'd' },
551 +       { "encryption", 1, 0, 'e' },
552 +       { "help", 0, 0, 'h' },
553 +       { "offset", 1, 0, 'o' },
554 +       { "pass-fd", 1, 0, 'p' },
555 +       { "phash", 1, 0, 'P' },
556 +       { "verbose", 0, 0, 'v' },
557 +       { "keybits", 1, 0, 'k' },
558 +       { NULL, 0, 0, 0 }
559 +};
560 +
561 +
562  static void
563  usage(void) {
564 -       fprintf(stderr, _("usage:\n\
565 +       fprintf(stderr, 
566 +_("usage:\n\
567    %s loop_device                                      # give info\n\
568    %s -d loop_device                                   # delete\n\
569 -  %s [ -e encryption ] [ -o offset ] loop_device file # setup\n"),
570 +  %s [ options ] loop_device file                     # setup\n\
571 +    where options include\n\
572 +    --offset <num>, -o <num>\n\
573 +        start at offset <num> into file.\n\
574 +    --pass-fd <num>, -p <num>\n\
575 +        read passphrase from file descriptor <num>\n\
576 +        instead of the terminal.\n\
577 +    --encryption <cipher>, -e <cipher>\n\
578 +        encrypt with <cipher>.\n\
579 +        Check /proc/crypto/cipher for available ciphers.\n\
580 +    --keybits <num>, -k <num>\n\
581 +        specify number of bits in the hashed key given\n\
582 +        to the cipher.  Some ciphers support several key\n\
583 +        sizes and might be more efficient with a smaller\n\
584 +        key size.  Key sizes < 128 are generally not\n\
585 +        recommended\n\
586 +    --phash <hash>, -P <hash>\n\
587 +        specify <hash> to use for hashing the passphrase\n\
588 +        (supported: rmd160old, sha256, sha384, sha512)\n"),
589                 progname, progname, progname);
590         exit(1);
591  }
592 @@ -388,19 +694,20 @@
593  
594  int
595  main(int argc, char **argv) {
596 -       char *offset, *encryption;
597 -       int delete,off,c;
598 +       char *offset = 0, *encryption = 0, *passfd = 0, *keysize = 0, *phash_name = 0;
599 +       int delete = 0, off = 0, c = 0;
600 +       int pfd = -1;
601         int res = 0;
602         int ro = 0;
603 +       int keysz = 0;
604  
605         setlocale(LC_ALL, "");
606         bindtextdomain(PACKAGE, LOCALEDIR);
607         textdomain(PACKAGE);
608  
609 -       delete = off = 0;
610 -       offset = encryption = NULL;
611         progname = argv[0];
612 -       while ((c = getopt(argc,argv,"de:o:v")) != -1) {
613 +       while ((c = getopt_long(argc,argv,"de:h:k:o:p:P:v",
614 +                               longopts, NULL)) != -1) {
615                 switch (c) {
616                 case 'd':
617                         delete = 1;
618 @@ -408,9 +715,18 @@
619                 case 'e':
620                         encryption = optarg;
621                         break;
622 +               case 'k':
623 +                       keysize = optarg;
624 +                       break;
625                 case 'o':
626                         offset = optarg;
627                         break;
628 +               case 'p':
629 +                       passfd = optarg;
630 +                       break;
631 +               case 'P':
632 +                       phash_name = optarg;
633 +                       break;
634                 case 'v':
635                         verbose = 1;
636                         break;
637 @@ -419,7 +735,7 @@
638                 }
639         }
640         if (argc == 1) usage();
641 -       if ((delete && (argc != optind+1 || encryption || offset)) ||
642 +       if ((delete && (argc != optind+1 || encryption || offset || passfd)) ||
643             (!delete && (argc < optind+1 || argc > optind+2)))
644                 usage();
645         if (argc == optind+1) {
646 @@ -430,7 +746,13 @@
647         } else {
648                 if (offset && sscanf(offset,"%d",&off) != 1)
649                         usage();
650 -               res = set_loop(argv[optind],argv[optind+1],off,encryption,&ro);
651 +               if (passfd && sscanf(passfd,"%d",&pfd) != 1)
652 +                       usage();
653 +               if (keysize && sscanf(keysize,"%d",&keysz) != 1)
654 +                       usage();
655 +               res = set_loop(argv[optind], argv[optind+1], off,
656 +                              encryption, pfd, keysz, &ro,
657 +                              phash_name ? phash_name : "rmd160old");
658         }
659         return res;
660  }
661 @@ -446,3 +768,61 @@
662  }
663  #endif
664  #endif
665 +
666 +static int get_cipher_info(const char *name, struct cipher_info *res)
667 +{
668 +       char path[PATH_MAX];
669 +       char buf[2000];
670 +       FILE *f;
671 +       struct {
672 +               int *out;
673 +               const char *prefix;
674 +       } fields[] = {{&res->blocksize, "blocksize:"},
675 +                     {&res->keysize_mask, "keysize_mask:"},
676 +                     {&res->ivsize, "ivsize:"},
677 +                     {&res->key_schedule_size, "key_schedule_size:"}};
678 +       snprintf(path, sizeof(path), "/proc/crypto/cipher/%s", name);
679 +       f = fopen(path, "r");
680 +       while(f && fgets(buf, sizeof(buf), f)) {
681 +               int i;
682 +               for (i = 0; i < sizeof(fields)/sizeof(fields[0]); i++) {
683 +                       int len = strlen(fields[i].prefix);
684 +                       if (strncmp(buf, fields[i].prefix, len) == 0) {
685 +                               *fields[i].out = strtoul(&buf[len+1], NULL, 0);
686 +                               break;
687 +                       }
688 +               }
689 +               
690 +       }
691 +       if (!f) 
692 +               return -1;
693 +       return 0;
694 +}
695 +
696 +
697 +static int 
698 +name_to_id(const char *name) 
699 +{
700 +       int i;
701 +
702 +       if (name) {
703 +               for (i = 0; crypt_type_tbl[i].id != -1; i++)
704 +                       if (!strcasecmp (name, crypt_type_tbl[i].name))
705 +                               return crypt_type_tbl[i].id;
706 +       } else
707 +               return LO_CRYPT_NONE;
708 +       return LO_CRYPT_CRYPTOAPI;
709 +}
710 +
711 +#ifdef MAIN
712 +static char *
713 +id_to_name(int id) {
714 +       int i;
715 +
716 +       for (i = 0; crypt_type_tbl[i].id != -1; i++)
717 +               if (id == crypt_type_tbl[i].id)
718 +                       return crypt_type_tbl[i].name;
719 +       return "undefined";
720 +}
721 +#endif
722 +
723 diff -Nur util-linux-2.11zorg/mount/lomount.h util-linux-2.11z/mount/lomount.h
724 --- util-linux-2.11zorg/mount/lomount.h Fri Dec  8 18:08:02 2000
725 +++ util-linux-2.11z/mount/lomount.h    Fri Mar 28 21:43:00 2003
726 @@ -1,5 +1,6 @@
727  extern int verbose;
728 -extern int set_loop (const char *, const char *, int, const char *, int *);
729 +extern int set_loop (const char *, const char *, int, const char *, 
730 +                     int, int, int *, const char *);
731  extern int del_loop (const char *);
732  extern int is_loop_device (const char *);
733  extern char * find_unused_loop_device (void);
734 diff -Nur util-linux-2.11zorg/mount/losetup.8 util-linux-2.11z/mount/losetup.8
735 --- util-linux-2.11zorg/mount/losetup.8 Fri Aug 11 11:11:30 2000
736 +++ util-linux-2.11z/mount/losetup.8    Fri Mar 28 21:43:00 2003
737 @@ -10,6 +10,9 @@
738  ] [
739  .B \-o
740  .I offset
741 +] [
742 +.B \-p
743 +.I num
744  ]
745  .I loop_device file
746  .br
747 @@ -26,9 +29,9 @@
748  \fIloop_device\fP argument is given, the status of the corresponding loop
749  device is shown.
750  .SH OPTIONS
751 -.IP \fB\-d\fP
752 +.IP "\fB\-\-delete, \-\-detach, \-d\fP"
753  detach the file or device associated with the specified loop device.
754 -.IP "\fB\-e \fIencryption\fP"
755 +.IP "\fB\-\-encryption, \-e \fIencryption\fP"
756  .RS
757  enable data encryption. The following keywords are recognized:
758  .IP \fBNONE\fP
759 @@ -36,16 +39,62 @@
760  .PD 0
761  .IP \fBXOR\fP
762  use a simple XOR encryption.
763 +.IP \fBAES\fP
764 +use Advanced Encryption Standard encryption. AES encryption is only available 
765 +if you are using the international kernel and AES encryption has been enabled 
766 +in the Crypto API.
767 +enabled in the Crypto API.
768 +.IP \fBBlowfish\fP
769 +use Blowfish encryption. Blowfish encryption is only available if you
770 +are using the international kernel and Blowfish encryption has been
771 +enabled in the Crypto API.
772 +.IP \fBTwofish\fP
773 +use Twofish encryption. Twofish encryption is only available if you
774 +are using the international kernel and Twofish encryption has been
775 +enabled in the Crypto API.
776 +.IP \fBCAST\fP
777 +use CAST encryption. CAST encryption is only available if you
778 +are using the international kernel and CAST encryption has been
779 +enabled in the Crypto API.
780  .IP \fBDES\fP
781  use DES encryption. DES encryption is only available if the optional
782  DES package has been added to the kernel. DES encryption uses an additional
783  start value that is used to protect passwords against dictionary
784 -attacks.
785 +attacks. Use of DES is deprecated.
786 +.IP \fBDFC\fP
787 +use DFC encryption. DFC encryption is only available if you
788 +are using the international kernel and DFC encryption has been
789 +enabled in the Crypto API.
790 +.IP \fBIDEA\fP
791 +use IDEA encryption. IDEA encryption is only available if you
792 +are using the international kernel and IDEA encryption has been
793 +enabled in the Crypto API.
794 +.IP \fBMARS\fP
795 +use MARS encryption. MARS encryption is only available if you
796 +are using the international kernel and MARS encryption has been
797 +enabled in the Crypto API.
798 +.IP \fBRC5\fP
799 +use RC5 encryption. RC5 encryption is only available if you
800 +are using the international kernel and RC5 encryption has been
801 +enabled in the Crypto API.
802 +.IP \fBRC6\fP
803 +use RC6 encryption. RC6 encryption is only available if you
804 +are using the international kernel and RC6 encryption has been
805 +enabled in the Crypto API.
806 +.IP \fBSerpent\fP
807 +use Serpent encryption. Serpent encryption is only available if you
808 +are using the international kernel and Serpent encryption has been
809 +enabled in the Crypto API.
810  .PD
811  .RE
812 -.IP "\fB\-o \fIoffset\fP"
813 +.IP "\fB\-\-offset, \-o \fIoffset\fP"
814  the data start is moved \fIoffset\fP bytes into the specified file or
815  device.
816 +.IP "\fB\-\-pass-fd, \-p \fInum\fP"
817 +read the passphrase from file descriptor \fInum\fP instead of the
818 +terminal.
819 +.IP "\fB\-\-keybits, \-k \fInum\fP"
820 +set the number of bits to use in key to \fInum\fP.
821  .SH RETURN VALUE
822  .B losetup
823  returns 0 on success, nonzero on failure. When
824 @@ -58,6 +107,7 @@
825  .SH FILES
826  .nf
827  /dev/loop0,/dev/loop1,...   loop devices (major=7)
828 +/proc/cipher/*              available ciphers
829  .fi
830  .SH EXAMPLE
831  If you are using the loadable module you must have the module loaded
832 @@ -69,9 +119,8 @@
833  .nf
834  .IP
835  dd if=/dev/zero of=/file bs=1k count=100
836 -losetup -e des /dev/loop0 /file
837 -Password:
838 -Init (up to 16 hex digits):
839 +losetup -e blowfish /dev/loop0 /file
840 +Password :
841  mkfs -t ext2 /dev/loop0 100
842  mount -t ext2 /dev/loop0 /mnt
843   ...
844 @@ -85,8 +134,12 @@
845  # rmmod loop
846  .LP
847  .fi
848 -.SH RESTRICTION
849 -DES encryption is painfully slow. On the other hand, XOR is terribly weak.
850 +.SH RESTRICTIONS
851 +DES encryption is painfully slow. On the other hand, XOR is terribly
852 +weak. Both are insecure nowadays. Some ciphers require a licence for
853 +you to be allowed to use them.
854 +.SH BUGS
855 +CAST, DES, RC5 and Twofish are currently broken and cannot be used.
856  .SH AUTHORS
857  .nf
858  Original version: Theodore Ts'o <tytso@athena.mit.edu>
859 diff -Nur util-linux-2.11zorg/mount/mount.8 util-linux-2.11z/mount/mount.8
860 --- util-linux-2.11zorg/mount/mount.8   Tue Jan 21 13:45:54 2003
861 +++ util-linux-2.11z/mount/mount.8      Fri Mar 28 21:43:00 2003
862 @@ -270,6 +270,12 @@
863  .B \-v
864  Verbose mode.
865  .TP
866 +.B \-p "\fInum\fP"
867 +If the mount requires a passphrase to be entered, read it from file
868 +descriptor
869 +.IR num\fP
870 +instead of from the terminal.
871 +.TP
872  .B \-a
873  Mount all filesystems (of the given types) mentioned in
874  .IR fstab .
875 @@ -627,6 +633,15 @@
876  .BR noexec ", " nosuid ", and " nodev
877  (unless overridden by subsequent options, as in the option line
878  .BR users,exec,dev,suid ).
879 +.TP
880 +.B encryption
881 +Specifies an encryption algorithm to use.  Used in conjunction with the
882 +.BR loop " option."
883 +.TP
884 +.B keybits
885 +Specifies the key size to use for an encryption algorithm. Used in conjunction
886 +with the
887 +.BR loop " and " encryption " options."
888  .RE
889  .TP
890  .B \-\-bind
891 @@ -1688,7 +1703,10 @@
892  .BR loop ", " offset " and " encryption ,
893  that are really options to
894  .BR losetup (8).
895 -If no explicit loop device is mentioned
896 +If the mount requires a passphrase, you will be prompted for one unless
897 +you specify a file descriptor to read from instead with the 
898 +.BR \-\-pass-fd
899 +option. If no explicit loop device is mentioned
900  (but just an option `\fB\-o loop\fP' is given), then
901  .B mount
902  will try to find some unused loop device and use that.
903 diff -Nur util-linux-2.11zorg/mount/mount.c util-linux-2.11z/mount/mount.c
904 --- util-linux-2.11zorg/mount/mount.c   Thu Jan  2 19:38:44 2003
905 +++ util-linux-2.11z/mount/mount.c      Fri Mar 28 21:44:26 2003
906 @@ -113,6 +113,9 @@
907  /* True if ruid != euid.  */
908  static int suid = 0;
909  
910 +/* Contains the fd no. to read the passphrase from, if any */
911 +static int pfd = -1;
912 +
913  /* Map from -o and fstab option strings to the flag argument to mount(2).  */
914  struct opt_map {
915    const char *opt;             /* option name */
916 @@ -192,7 +195,7 @@
917  };
918  
919  static char *opt_loopdev, *opt_vfstype, *opt_offset, *opt_encryption,
920 -  *opt_speed;
921 +  *opt_keybits, *opt_speed, *opt_phash;
922  
923  static struct string_opt_map {
924    char *tag;
925 @@ -203,6 +206,8 @@
926    { "vfs=",    1, &opt_vfstype },
927    { "offset=", 0, &opt_offset },
928    { "encryption=", 0, &opt_encryption },
929 +  { "keybits=", 0, &opt_keybits },
930 +  { "phash=", 0, &opt_phash },
931    { "speed=", 0, &opt_speed },
932    { NULL, 0, NULL }
933  };
934 @@ -553,7 +558,7 @@
935  static int
936  loop_check(char **spec, char **type, int *flags,
937            int *loop, char **loopdev, char **loopfile) {
938 -  int looptype, offset;
939 +  int looptype, offset, keybits;
940  
941    /*
942     * In the case of a loop mount, either type is of the form lo@/dev/loop5
943 @@ -596,7 +601,10 @@
944        if (verbose)
945         printf(_("mount: going to use the loop device %s\n"), *loopdev);
946        offset = opt_offset ? strtoul(opt_offset, NULL, 0) : 0;
947 -      if (set_loop (*loopdev, *loopfile, offset, opt_encryption, &loopro)) {
948 +      keybits = opt_keybits ? strtoul(opt_keybits, NULL, 0) : 0;
949 +      if (set_loop (*loopdev, *loopfile, offset, opt_encryption, pfd, 
950 +                   keybits, &loopro,
951 +                   opt_phash ? opt_phash : "rmd160old")) {
952         if (verbose)
953           printf(_("mount: failed setting up loop device\n"));
954         return EX_FAIL;
955 @@ -1352,6 +1360,7 @@
956         { "rw", 0, 0, 'w' },
957         { "options", 1, 0, 'o' },
958         { "test-opts", 1, 0, 'O' },
959 +       { "pass-fd", 1, 0, 'p' },
960         { "types", 1, 0, 't' },
961         { "bind", 0, 0, 128 },
962         { "replace", 0, 0, 129 },
963 @@ -1389,7 +1398,7 @@
964           "       mount --move olddir newdir\n"
965           "A device can be given by name, say /dev/hda1 or /dev/cdrom,\n"
966           "or by label, using  -L label  or by uuid, using  -U uuid .\n"
967 -         "Other options: [-nfFrsvw] [-o options].\n"
968 +         "Other options: [-nfFrsvw] [-o options] [-p num].\n"
969           "For many more details, say  man 8 mount .\n"
970         ));
971  /*
972 @@ -1405,6 +1414,7 @@
973         int c, result = 0, specseen;
974         char *options = NULL, *test_opts = NULL, *spec, *node;
975         char *volumelabel = NULL;
976 +       char *passfd = NULL;
977         char *uuid = NULL;
978         char *types = NULL;
979         struct mntentchn *mc;
980 @@ -1428,7 +1438,7 @@
981         initproctitle(argc, argv);
982  #endif
983  
984 -       while ((c = getopt_long (argc, argv, "afFhilL:no:O:rsU:vVwt:",
985 +       while ((c = getopt_long (argc, argv, "afFhilL:no:O:p:rsU:vVwt:",
986                                  longopts, NULL)) != -1) {
987                 switch (c) {
988                 case 'a':              /* mount everything in fstab */
989 @@ -1467,6 +1477,9 @@
990                         else
991                                 test_opts = xstrdup(optarg);
992                         break;
993 +               case 'p':               /* read passphrase from given fd */
994 +                       passfd = optarg;
995 +                       break;
996                 case 'r':               /* mount readonly */
997                         readonly = 1;
998                         readwrite = 0;
999 @@ -1576,6 +1589,9 @@
1000         } else
1001                 spec = NULL;            /* just for gcc */
1002  
1003 +       if (passfd && sscanf(passfd,"%d",&pfd) != 1)
1004 +               die (EX_USAGE, _("mount: argument to --pass-fd or -p must be a number"));
1005 +
1006         switch (argc+specseen) {
1007         case 0:
1008                 /* mount -a */
1009 diff -Nur util-linux-2.11zorg/mount/rmd160.c util-linux-2.11z/mount/rmd160.c
1010 --- util-linux-2.11zorg/mount/rmd160.c  Thu Jan  1 00:00:00 1970
1011 +++ util-linux-2.11z/mount/rmd160.c     Fri Mar 28 21:43:00 2003
1012 @@ -0,0 +1,532 @@
1013 +/* rmd160.c  - RIPE-MD160
1014 + *     Copyright (C) 1998 Free Software Foundation, Inc.
1015 + */
1016 +
1017 +/* This file was part of GnuPG. Modified for use within the Linux
1018 + * mount utility by Marc Mutz <Marc@Mutz.com>. None of this code is
1019 + * by myself. I just removed everything that you don't need when all
1020 + * you want to do is to use rmd160_hash_buffer().
1021 + * My comments are marked with (mm).  */
1022 +
1023 +/* GnuPG is free software; you can redistribute it and/or modify
1024 + * it under the terms of the GNU General Public License as published by
1025 + * the Free Software Foundation; either version 2 of the License, or
1026 + * (at your option) any later version.
1027 + *
1028 + * GnuPG is distributed in the hope that it will be useful,
1029 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1030 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1031 + * GNU General Public License for more details.
1032 + *
1033 + * You should have received a copy of the GNU General Public License
1034 + * along with this program; if not, write to the Free Software
1035 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */
1036 +
1037 +#include <string.h> /* (mm) for memcpy */
1038 +#include <endian.h> /* (mm) for BIG_ENDIAN and BYTE_ORDER */
1039 +#include "rmd160.h"
1040 +
1041 +/* (mm) these are used by the original GnuPG file. In order to modify
1042 + * that file not too much, we keep the notations. maybe it would be
1043 + * better to include linux/types.h and typedef __u32 to u32 and __u8
1044 + * to byte?  */
1045 +typedef unsigned int u32; /* taken from e.g. util-linux's minix.h */
1046 +typedef unsigned char byte;
1047 +
1048 +typedef struct {
1049 +    u32  h0,h1,h2,h3,h4;
1050 +    u32  nblocks;
1051 +    byte buf[64];
1052 +    int  count;
1053 +} RMD160_CONTEXT;
1054 +
1055 +/****************
1056 + * Rotate a 32 bit integer by n bytes
1057 + */
1058 +#if defined(__GNUC__) && defined(__i386__)
1059 +static inline u32
1060 +rol( u32 x, int n)
1061 +{
1062 +       __asm__("roll %%cl,%0"
1063 +               :"=r" (x)
1064 +               :"0" (x),"c" (n));
1065 +       return x;
1066 +}
1067 +#else
1068 +  #define rol(x,n) ( ((x) << (n)) | ((x) >> (32-(n))) )
1069 +#endif
1070 +
1071 +/*********************************
1072 + * RIPEMD-160 is not patented, see (as of 25.10.97)
1073 + *   http://www.esat.kuleuven.ac.be/~bosselae/ripemd160.html
1074 + * Note that the code uses Little Endian byteorder, which is good for
1075 + * 386 etc, but we must add some conversion when used on a big endian box.
1076 + *
1077 + *
1078 + * Pseudo-code for RIPEMD-160
1079 + *
1080 + * RIPEMD-160 is an iterative hash function that operates on 32-bit words.
1081 + * The round function takes as input a 5-word chaining variable and a 16-word
1082 + * message block and maps this to a new chaining variable. All operations are
1083 + * defined on 32-bit words. Padding is identical to that of MD4.
1084 + *
1085 + *
1086 + * RIPEMD-160: definitions
1087 + *
1088 + *
1089 + *   nonlinear functions at bit level: exor, mux, -, mux, -
1090 + *
1091 + *   f(j, x, y, z) = x XOR y XOR z               (0 <= j <= 15)
1092 + *   f(j, x, y, z) = (x AND y) OR (NOT(x) AND z)  (16 <= j <= 31)
1093 + *   f(j, x, y, z) = (x OR NOT(y)) XOR z         (32 <= j <= 47)
1094 + *   f(j, x, y, z) = (x AND z) OR (y AND NOT(z))  (48 <= j <= 63)
1095 + *   f(j, x, y, z) = x XOR (y OR NOT(z))         (64 <= j <= 79)
1096 + *
1097 + *
1098 + *   added constants (hexadecimal)
1099 + *
1100 + *   K(j) = 0x00000000     (0 <= j <= 15)
1101 + *   K(j) = 0x5A827999    (16 <= j <= 31)      int(2**30 x sqrt(2))
1102 + *   K(j) = 0x6ED9EBA1    (32 <= j <= 47)      int(2**30 x sqrt(3))
1103 + *   K(j) = 0x8F1BBCDC    (48 <= j <= 63)      int(2**30 x sqrt(5))
1104 + *   K(j) = 0xA953FD4E    (64 <= j <= 79)      int(2**30 x sqrt(7))
1105 + *   K'(j) = 0x50A28BE6     (0 <= j <= 15)      int(2**30 x cbrt(2))
1106 + *   K'(j) = 0x5C4DD124    (16 <= j <= 31)      int(2**30 x cbrt(3))
1107 + *   K'(j) = 0x6D703EF3    (32 <= j <= 47)      int(2**30 x cbrt(5))
1108 + *   K'(j) = 0x7A6D76E9    (48 <= j <= 63)      int(2**30 x cbrt(7))
1109 + *   K'(j) = 0x00000000    (64 <= j <= 79)
1110 + *
1111 + *
1112 + *   selection of message word
1113 + *
1114 + *   r(j)      = j                   (0 <= j <= 15)
1115 + *   r(16..31) = 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8
1116 + *   r(32..47) = 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12
1117 + *   r(48..63) = 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2
1118 + *   r(64..79) = 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
1119 + *   r0(0..15) = 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12
1120 + *   r0(16..31)= 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2
1121 + *   r0(32..47)= 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13
1122 + *   r0(48..63)= 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14
1123 + *   r0(64..79)= 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
1124 + *
1125 + *
1126 + *   amount for rotate left (rol)
1127 + *
1128 + *   s(0..15)  = 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8
1129 + *   s(16..31) = 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12
1130 + *   s(32..47) = 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5
1131 + *   s(48..63) = 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12
1132 + *   s(64..79) = 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
1133 + *   s'(0..15) = 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6
1134 + *   s'(16..31)= 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11
1135 + *   s'(32..47)= 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5
1136 + *   s'(48..63)= 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8
1137 + *   s'(64..79)= 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
1138 + *
1139 + *
1140 + *   initial value (hexadecimal)
1141 + *
1142 + *   h0 = 0x67452301; h1 = 0xEFCDAB89; h2 = 0x98BADCFE; h3 = 0x10325476;
1143 + *                                                     h4 = 0xC3D2E1F0;
1144 + *
1145 + *
1146 + * RIPEMD-160: pseudo-code
1147 + *
1148 + *   It is assumed that the message after padding consists of t 16-word blocks
1149 + *   that will be denoted with X[i][j], with 0 <= i <= t-1 and 0 <= j <= 15.
1150 + *   The symbol [+] denotes addition modulo 2**32 and rol_s denotes cyclic left
1151 + *   shift (rotate) over s positions.
1152 + *
1153 + *
1154 + *   for i := 0 to t-1 {
1155 + *      A := h0; B := h1; C := h2; D = h3; E = h4;
1156 + *      A' := h0; B' := h1; C' := h2; D' = h3; E' = h4;
1157 + *      for j := 0 to 79 {
1158 + *          T := rol_s(j)(A [+] f(j, B, C, D) [+] X[i][r(j)] [+] K(j)) [+] E;
1159 + *          A := E; E := D; D := rol_10(C); C := B; B := T;
1160 + *          T := rol_s'(j)(A' [+] f(79-j, B', C', D') [+] X[i][r'(j)]
1161 +                                                      [+] K'(j)) [+] E';
1162 + *          A' := E'; E' := D'; D' := rol_10(C'); C' := B'; B' := T;
1163 + *      }
1164 + *      T := h1 [+] C [+] D'; h1 := h2 [+] D [+] E'; h2 := h3 [+] E [+] A';
1165 + *      h3 := h4 [+] A [+] B'; h4 := h0 [+] B [+] C'; h0 := T;
1166 + *   }
1167 + */
1168 +
1169 +/* Some examples:
1170 + * ""                    9c1185a5c5e9fc54612808977ee8f548b2258d31
1171 + * "a"                   0bdc9d2d256b3ee9daae347be6f4dc835a467ffe
1172 + * "abc"                 8eb208f7e05d987a9b044a8e98c6b087f15a0bfc
1173 + * "message digest"      5d0689ef49d2fae572b881b123a85ffa21595f36
1174 + * "a...z"               f71c27109c692c1b56bbdceb5b9d2865b3708dbc
1175 + * "abcdbcde...nopq"     12a053384a9c0c88e405a06c27dcf49ada62eb2b
1176 + * "A...Za...z0...9"     b0e20b6e3116640286ed3a87a5713079b21f5189
1177 + * 8 times "1234567890"  9b752e45573d4b39f4dbd3323cab82bf63326bfb
1178 + * 1 million times "a"   52783243c1697bdbe16d37f97f68f08325dc1528
1179 + */
1180 +
1181 +
1182 +static void
1183 +rmd160_init( RMD160_CONTEXT *hd )
1184 +{
1185 +    hd->h0 = 0x67452301;
1186 +    hd->h1 = 0xEFCDAB89;
1187 +    hd->h2 = 0x98BADCFE;
1188 +    hd->h3 = 0x10325476;
1189 +    hd->h4 = 0xC3D2E1F0;
1190 +    hd->nblocks = 0;
1191 +    hd->count = 0;
1192 +}
1193 +
1194 +
1195 +
1196 +/****************
1197 + * Transform the message X which consists of 16 32-bit-words
1198 + */
1199 +static void
1200 +transform( RMD160_CONTEXT *hd, byte *data )
1201 +{
1202 +    u32 a,b,c,d,e,aa,bb,cc,dd,ee,t;
1203 +  #if BYTE_ORDER == BIG_ENDIAN
1204 +    u32 x[16];
1205 +    { int i;
1206 +      byte *p2, *p1;
1207 +      for(i=0, p1=data, p2=(byte*)x; i < 16; i++, p2 += 4 ) {
1208 +       p2[3] = *p1++;
1209 +       p2[2] = *p1++;
1210 +       p2[1] = *p1++;
1211 +       p2[0] = *p1++;
1212 +      }
1213 +    }
1214 +  #else
1215 +   #if 0
1216 +    u32 *x =(u32*)data;
1217 +   #else
1218 +    /* this version is better because it is always aligned;
1219 +     * The performance penalty on a 586-100 is about 6% which
1220 +     * is acceptable - because the data is more local it might
1221 +     * also be possible that this is faster on some machines.
1222 +     * This function (when compiled with -02 on gcc 2.7.2)
1223 +     * executes on a 586-100 (39.73 bogomips) at about 1900kb/sec;
1224 +     * [measured with a 4MB data and "gpgm --print-md rmd160"] */
1225 +    u32 x[16];
1226 +    memcpy( x, data, 64 );
1227 +   #endif
1228 +  #endif
1229 +
1230 +
1231 +#define K0  0x00000000
1232 +#define K1  0x5A827999
1233 +#define K2  0x6ED9EBA1
1234 +#define K3  0x8F1BBCDC
1235 +#define K4  0xA953FD4E
1236 +#define KK0 0x50A28BE6
1237 +#define KK1 0x5C4DD124
1238 +#define KK2 0x6D703EF3
1239 +#define KK3 0x7A6D76E9
1240 +#define KK4 0x00000000
1241 +#define F0(x,y,z)   ( (x) ^ (y) ^ (z) )
1242 +#define F1(x,y,z)   ( ((x) & (y)) | (~(x) & (z)) )
1243 +#define F2(x,y,z)   ( ((x) | ~(y)) ^ (z) )
1244 +#define F3(x,y,z)   ( ((x) & (z)) | ((y) & ~(z)) )
1245 +#define F4(x,y,z)   ( (x) ^ ((y) | ~(z)) )
1246 +#define R(a,b,c,d,e,f,k,r,s) do { t = a + f(b,c,d) + k + x[r]; \
1247 +                                 a = rol(t,s) + e;            \
1248 +                                 c = rol(c,10);               \
1249 +                               } while(0)
1250 +
1251 +    /* left lane */
1252 +    a = hd->h0;
1253 +    b = hd->h1;
1254 +    c = hd->h2;
1255 +    d = hd->h3;
1256 +    e = hd->h4;
1257 +    R( a, b, c, d, e, F0, K0,  0, 11 );
1258 +    R( e, a, b, c, d, F0, K0,  1, 14 );
1259 +    R( d, e, a, b, c, F0, K0,  2, 15 );
1260 +    R( c, d, e, a, b, F0, K0,  3, 12 );
1261 +    R( b, c, d, e, a, F0, K0,  4,  5 );
1262 +    R( a, b, c, d, e, F0, K0,  5,  8 );
1263 +    R( e, a, b, c, d, F0, K0,  6,  7 );
1264 +    R( d, e, a, b, c, F0, K0,  7,  9 );
1265 +    R( c, d, e, a, b, F0, K0,  8, 11 );
1266 +    R( b, c, d, e, a, F0, K0,  9, 13 );
1267 +    R( a, b, c, d, e, F0, K0, 10, 14 );
1268 +    R( e, a, b, c, d, F0, K0, 11, 15 );
1269 +    R( d, e, a, b, c, F0, K0, 12,  6 );
1270 +    R( c, d, e, a, b, F0, K0, 13,  7 );
1271 +    R( b, c, d, e, a, F0, K0, 14,  9 );
1272 +    R( a, b, c, d, e, F0, K0, 15,  8 );
1273 +    R( e, a, b, c, d, F1, K1,  7,  7 );
1274 +    R( d, e, a, b, c, F1, K1,  4,  6 );
1275 +    R( c, d, e, a, b, F1, K1, 13,  8 );
1276 +    R( b, c, d, e, a, F1, K1,  1, 13 );
1277 +    R( a, b, c, d, e, F1, K1, 10, 11 );
1278 +    R( e, a, b, c, d, F1, K1,  6,  9 );
1279 +    R( d, e, a, b, c, F1, K1, 15,  7 );
1280 +    R( c, d, e, a, b, F1, K1,  3, 15 );
1281 +    R( b, c, d, e, a, F1, K1, 12,  7 );
1282 +    R( a, b, c, d, e, F1, K1,  0, 12 );
1283 +    R( e, a, b, c, d, F1, K1,  9, 15 );
1284 +    R( d, e, a, b, c, F1, K1,  5,  9 );
1285 +    R( c, d, e, a, b, F1, K1,  2, 11 );
1286 +    R( b, c, d, e, a, F1, K1, 14,  7 );
1287 +    R( a, b, c, d, e, F1, K1, 11, 13 );
1288 +    R( e, a, b, c, d, F1, K1,  8, 12 );
1289 +    R( d, e, a, b, c, F2, K2,  3, 11 );
1290 +    R( c, d, e, a, b, F2, K2, 10, 13 );
1291 +    R( b, c, d, e, a, F2, K2, 14,  6 );
1292 +    R( a, b, c, d, e, F2, K2,  4,  7 );
1293 +    R( e, a, b, c, d, F2, K2,  9, 14 );
1294 +    R( d, e, a, b, c, F2, K2, 15,  9 );
1295 +    R( c, d, e, a, b, F2, K2,  8, 13 );
1296 +    R( b, c, d, e, a, F2, K2,  1, 15 );
1297 +    R( a, b, c, d, e, F2, K2,  2, 14 );
1298 +    R( e, a, b, c, d, F2, K2,  7,  8 );
1299 +    R( d, e, a, b, c, F2, K2,  0, 13 );
1300 +    R( c, d, e, a, b, F2, K2,  6,  6 );
1301 +    R( b, c, d, e, a, F2, K2, 13,  5 );
1302 +    R( a, b, c, d, e, F2, K2, 11, 12 );
1303 +    R( e, a, b, c, d, F2, K2,  5,  7 );
1304 +    R( d, e, a, b, c, F2, K2, 12,  5 );
1305 +    R( c, d, e, a, b, F3, K3,  1, 11 );
1306 +    R( b, c, d, e, a, F3, K3,  9, 12 );
1307 +    R( a, b, c, d, e, F3, K3, 11, 14 );
1308 +    R( e, a, b, c, d, F3, K3, 10, 15 );
1309 +    R( d, e, a, b, c, F3, K3,  0, 14 );
1310 +    R( c, d, e, a, b, F3, K3,  8, 15 );
1311 +    R( b, c, d, e, a, F3, K3, 12,  9 );
1312 +    R( a, b, c, d, e, F3, K3,  4,  8 );
1313 +    R( e, a, b, c, d, F3, K3, 13,  9 );
1314 +    R( d, e, a, b, c, F3, K3,  3, 14 );
1315 +    R( c, d, e, a, b, F3, K3,  7,  5 );
1316 +    R( b, c, d, e, a, F3, K3, 15,  6 );
1317 +    R( a, b, c, d, e, F3, K3, 14,  8 );
1318 +    R( e, a, b, c, d, F3, K3,  5,  6 );
1319 +    R( d, e, a, b, c, F3, K3,  6,  5 );
1320 +    R( c, d, e, a, b, F3, K3,  2, 12 );
1321 +    R( b, c, d, e, a, F4, K4,  4,  9 );
1322 +    R( a, b, c, d, e, F4, K4,  0, 15 );
1323 +    R( e, a, b, c, d, F4, K4,  5,  5 );
1324 +    R( d, e, a, b, c, F4, K4,  9, 11 );
1325 +    R( c, d, e, a, b, F4, K4,  7,  6 );
1326 +    R( b, c, d, e, a, F4, K4, 12,  8 );
1327 +    R( a, b, c, d, e, F4, K4,  2, 13 );
1328 +    R( e, a, b, c, d, F4, K4, 10, 12 );
1329 +    R( d, e, a, b, c, F4, K4, 14,  5 );
1330 +    R( c, d, e, a, b, F4, K4,  1, 12 );
1331 +    R( b, c, d, e, a, F4, K4,  3, 13 );
1332 +    R( a, b, c, d, e, F4, K4,  8, 14 );
1333 +    R( e, a, b, c, d, F4, K4, 11, 11 );
1334 +    R( d, e, a, b, c, F4, K4,  6,  8 );
1335 +    R( c, d, e, a, b, F4, K4, 15,  5 );
1336 +    R( b, c, d, e, a, F4, K4, 13,  6 );
1337 +
1338 +    aa = a; bb = b; cc = c; dd = d; ee = e;
1339 +
1340 +    /* right lane */
1341 +    a = hd->h0;
1342 +    b = hd->h1;
1343 +    c = hd->h2;
1344 +    d = hd->h3;
1345 +    e = hd->h4;
1346 +    R( a, b, c, d, e, F4, KK0, 5,  8);
1347 +    R( e, a, b, c, d, F4, KK0, 14,  9);
1348 +    R( d, e, a, b, c, F4, KK0, 7,  9);
1349 +    R( c, d, e, a, b, F4, KK0, 0, 11);
1350 +    R( b, c, d, e, a, F4, KK0, 9, 13);
1351 +    R( a, b, c, d, e, F4, KK0, 2, 15);
1352 +    R( e, a, b, c, d, F4, KK0, 11, 15);
1353 +    R( d, e, a, b, c, F4, KK0, 4,  5);
1354 +    R( c, d, e, a, b, F4, KK0, 13,  7);
1355 +    R( b, c, d, e, a, F4, KK0, 6,  7);
1356 +    R( a, b, c, d, e, F4, KK0, 15,  8);
1357 +    R( e, a, b, c, d, F4, KK0, 8, 11);
1358 +    R( d, e, a, b, c, F4, KK0, 1, 14);
1359 +    R( c, d, e, a, b, F4, KK0, 10, 14);
1360 +    R( b, c, d, e, a, F4, KK0, 3, 12);
1361 +    R( a, b, c, d, e, F4, KK0, 12,  6);
1362 +    R( e, a, b, c, d, F3, KK1, 6,  9);
1363 +    R( d, e, a, b, c, F3, KK1, 11, 13);
1364 +    R( c, d, e, a, b, F3, KK1, 3, 15);
1365 +    R( b, c, d, e, a, F3, KK1, 7,  7);
1366 +    R( a, b, c, d, e, F3, KK1, 0, 12);
1367 +    R( e, a, b, c, d, F3, KK1, 13,  8);
1368 +    R( d, e, a, b, c, F3, KK1, 5,  9);
1369 +    R( c, d, e, a, b, F3, KK1, 10, 11);
1370 +    R( b, c, d, e, a, F3, KK1, 14,  7);
1371 +    R( a, b, c, d, e, F3, KK1, 15,  7);
1372 +    R( e, a, b, c, d, F3, KK1, 8, 12);
1373 +    R( d, e, a, b, c, F3, KK1, 12,  7);
1374 +    R( c, d, e, a, b, F3, KK1, 4,  6);
1375 +    R( b, c, d, e, a, F3, KK1, 9, 15);
1376 +    R( a, b, c, d, e, F3, KK1, 1, 13);
1377 +    R( e, a, b, c, d, F3, KK1, 2, 11);
1378 +    R( d, e, a, b, c, F2, KK2, 15,  9);
1379 +    R( c, d, e, a, b, F2, KK2, 5,  7);
1380 +    R( b, c, d, e, a, F2, KK2, 1, 15);
1381 +    R( a, b, c, d, e, F2, KK2, 3, 11);
1382 +    R( e, a, b, c, d, F2, KK2, 7,  8);
1383 +    R( d, e, a, b, c, F2, KK2, 14,  6);
1384 +    R( c, d, e, a, b, F2, KK2, 6,  6);
1385 +    R( b, c, d, e, a, F2, KK2, 9, 14);
1386 +    R( a, b, c, d, e, F2, KK2, 11, 12);
1387 +    R( e, a, b, c, d, F2, KK2, 8, 13);
1388 +    R( d, e, a, b, c, F2, KK2, 12,  5);
1389 +    R( c, d, e, a, b, F2, KK2, 2, 14);
1390 +    R( b, c, d, e, a, F2, KK2, 10, 13);
1391 +    R( a, b, c, d, e, F2, KK2, 0, 13);
1392 +    R( e, a, b, c, d, F2, KK2, 4,  7);
1393 +    R( d, e, a, b, c, F2, KK2, 13,  5);
1394 +    R( c, d, e, a, b, F1, KK3, 8, 15);
1395 +    R( b, c, d, e, a, F1, KK3, 6,  5);
1396 +    R( a, b, c, d, e, F1, KK3, 4,  8);
1397 +    R( e, a, b, c, d, F1, KK3, 1, 11);
1398 +    R( d, e, a, b, c, F1, KK3, 3, 14);
1399 +    R( c, d, e, a, b, F1, KK3, 11, 14);
1400 +    R( b, c, d, e, a, F1, KK3, 15,  6);
1401 +    R( a, b, c, d, e, F1, KK3, 0, 14);
1402 +    R( e, a, b, c, d, F1, KK3, 5,  6);
1403 +    R( d, e, a, b, c, F1, KK3, 12,  9);
1404 +    R( c, d, e, a, b, F1, KK3, 2, 12);
1405 +    R( b, c, d, e, a, F1, KK3, 13,  9);
1406 +    R( a, b, c, d, e, F1, KK3, 9, 12);
1407 +    R( e, a, b, c, d, F1, KK3, 7,  5);
1408 +    R( d, e, a, b, c, F1, KK3, 10, 15);
1409 +    R( c, d, e, a, b, F1, KK3, 14,  8);
1410 +    R( b, c, d, e, a, F0, KK4, 12,  8);
1411 +    R( a, b, c, d, e, F0, KK4, 15,  5);
1412 +    R( e, a, b, c, d, F0, KK4, 10, 12);
1413 +    R( d, e, a, b, c, F0, KK4, 4,  9);
1414 +    R( c, d, e, a, b, F0, KK4, 1, 12);
1415 +    R( b, c, d, e, a, F0, KK4, 5,  5);
1416 +    R( a, b, c, d, e, F0, KK4, 8, 14);
1417 +    R( e, a, b, c, d, F0, KK4, 7,  6);
1418 +    R( d, e, a, b, c, F0, KK4, 6,  8);
1419 +    R( c, d, e, a, b, F0, KK4, 2, 13);
1420 +    R( b, c, d, e, a, F0, KK4, 13,  6);
1421 +    R( a, b, c, d, e, F0, KK4, 14,  5);
1422 +    R( e, a, b, c, d, F0, KK4, 0, 15);
1423 +    R( d, e, a, b, c, F0, KK4, 3, 13);
1424 +    R( c, d, e, a, b, F0, KK4, 9, 11);
1425 +    R( b, c, d, e, a, F0, KK4, 11, 11);
1426 +
1427 +
1428 +    t     = hd->h1 + d + cc;
1429 +    hd->h1 = hd->h2 + e + dd;
1430 +    hd->h2 = hd->h3 + a + ee;
1431 +    hd->h3 = hd->h4 + b + aa;
1432 +    hd->h4 = hd->h0 + c + bb;
1433 +    hd->h0 = t;
1434 +}
1435 +
1436 +
1437 +/* Update the message digest with the contents
1438 + * of INBUF with length INLEN.
1439 + */
1440 +static void
1441 +rmd160_write( RMD160_CONTEXT *hd, byte *inbuf, size_t inlen)
1442 +{
1443 +    if( hd->count == 64 ) { /* flush the buffer */
1444 +       transform( hd, hd->buf );
1445 +       hd->count = 0;
1446 +       hd->nblocks++;
1447 +    }
1448 +    if( !inbuf )
1449 +       return;
1450 +    if( hd->count ) {
1451 +       for( ; inlen && hd->count < 64; inlen-- )
1452 +           hd->buf[hd->count++] = *inbuf++;
1453 +       rmd160_write( hd, NULL, 0 );
1454 +       if( !inlen )
1455 +           return;
1456 +    }
1457 +
1458 +    while( inlen >= 64 ) {
1459 +       transform( hd, inbuf );
1460 +       hd->count = 0;
1461 +       hd->nblocks++;
1462 +       inlen -= 64;
1463 +       inbuf += 64;
1464 +    }
1465 +    for( ; inlen && hd->count < 64; inlen-- )
1466 +       hd->buf[hd->count++] = *inbuf++;
1467 +}
1468 +
1469 +/* The routine terminates the computation
1470 + */
1471 +
1472 +static void
1473 +rmd160_final( RMD160_CONTEXT *hd )
1474 +{
1475 +    u32 t, msb, lsb;
1476 +    byte *p;
1477 +
1478 +    rmd160_write(hd, NULL, 0); /* flush */;
1479 +
1480 +    msb = 0;
1481 +    t = hd->nblocks;
1482 +    if( (lsb = t << 6) < t ) /* multiply by 64 to make a byte count */
1483 +       msb++;
1484 +    msb += t >> 26;
1485 +    t = lsb;
1486 +    if( (lsb = t + hd->count) < t ) /* add the count */
1487 +       msb++;
1488 +    t = lsb;
1489 +    if( (lsb = t << 3) < t ) /* multiply by 8 to make a bit count */
1490 +       msb++;
1491 +    msb += t >> 29;
1492 +
1493 +    if( hd->count < 56 ) { /* enough room */
1494 +       hd->buf[hd->count++] = 0x80; /* pad */
1495 +       while( hd->count < 56 )
1496 +           hd->buf[hd->count++] = 0;  /* pad */
1497 +    }
1498 +    else { /* need one extra block */
1499 +       hd->buf[hd->count++] = 0x80; /* pad character */
1500 +       while( hd->count < 64 )
1501 +           hd->buf[hd->count++] = 0;
1502 +       rmd160_write(hd, NULL, 0);  /* flush */;
1503 +       memset(hd->buf, 0, 56 ); /* fill next block with zeroes */
1504 +    }
1505 +    /* append the 64 bit count */
1506 +    hd->buf[56] = lsb     ;
1507 +    hd->buf[57] = lsb >>  8;
1508 +    hd->buf[58] = lsb >> 16;
1509 +    hd->buf[59] = lsb >> 24;
1510 +    hd->buf[60] = msb     ;
1511 +    hd->buf[61] = msb >>  8;
1512 +    hd->buf[62] = msb >> 16;
1513 +    hd->buf[63] = msb >> 24;
1514 +    transform( hd, hd->buf );
1515 +
1516 +    p = hd->buf;
1517 +  #if BYTE_ORDER == BIG_ENDIAN
1518 +    #define X(a) do { *p++ = hd->h##a     ; *p++ = hd->h##a >> 8;      \
1519 +                     *p++ = hd->h##a >> 16; *p++ = hd->h##a >> 24; } while(0)
1520 +  #else /* little endian */
1521 +    #define X(a) do { *(u32*)p = hd->h##a ; p += 4; } while(0)
1522 +  #endif
1523 +    X(0);
1524 +    X(1);
1525 +    X(2);
1526 +    X(3);
1527 +    X(4);
1528 +  #undef X
1529 +}
1530 +
1531 +/****************
1532 + * Shortcut functions which puts the hash value of the supplied buffer
1533 + * into outbuf which must have a size of 20 bytes.
1534 + */
1535 +void
1536 +rmd160_hash_buffer( char *outbuf, const char *buffer, size_t length )
1537 +{
1538 +    RMD160_CONTEXT hd;
1539 +
1540 +    rmd160_init( &hd );
1541 +    rmd160_write( &hd, (byte*)buffer, length );
1542 +    rmd160_final( &hd );
1543 +    memcpy( outbuf, hd.buf, 20 );
1544 +}
1545 diff -Nur util-linux-2.11zorg/mount/rmd160.h util-linux-2.11z/mount/rmd160.h
1546 --- util-linux-2.11zorg/mount/rmd160.h  Thu Jan  1 00:00:00 1970
1547 +++ util-linux-2.11z/mount/rmd160.h     Fri Mar 28 21:43:00 2003
1548 @@ -0,0 +1,9 @@
1549 +#ifndef RMD160_H
1550 +#define RMD160_H
1551 +
1552 +#define RMD160_HASH_SIZE 20
1553 +
1554 +void
1555 +rmd160_hash_buffer (char *outbuf, const char *buffer, size_t length);
1556 +
1557 +#endif /*RMD160_H*/
1558 diff -Nur util-linux-2.11zorg/mount/sha512.c util-linux-2.11z/mount/sha512.c
1559 --- util-linux-2.11zorg/mount/sha512.c  Thu Jan  1 00:00:00 1970
1560 +++ util-linux-2.11z/mount/sha512.c     Fri Mar 28 21:43:00 2003
1561 @@ -0,0 +1,432 @@
1562 +/*
1563 + *  sha512.c
1564 + *
1565 + *  Written by Jari Ruusu, April 16 2001
1566 + *
1567 + *  Copyright 2001 by Jari Ruusu.
1568 + *  Redistribution of this file is permitted under the GNU Public License.
1569 + */
1570 +
1571 +#include <string.h>
1572 +#include <sys/types.h>
1573 +#include "sha512.h"
1574 +
1575 +/* Define one or more of these. If none is defined, you get all of them */
1576 +#if !defined(SHA256_NEEDED)&&!defined(SHA512_NEEDED)&&!defined(SHA384_NEEDED)
1577 +# define SHA256_NEEDED  1
1578 +# define SHA512_NEEDED  1
1579 +# define SHA384_NEEDED  1
1580 +#endif
1581 +
1582 +#if defined(SHA256_NEEDED)
1583 +static const u_int32_t sha256_hashInit[8] = {
1584 +    0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c,
1585 +    0x1f83d9ab, 0x5be0cd19
1586 +};
1587 +static const u_int32_t sha256_K[64] = {
1588 +    0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1,
1589 +    0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
1590 +    0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786,
1591 +    0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
1592 +    0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147,
1593 +    0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
1594 +    0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b,
1595 +    0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
1596 +    0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a,
1597 +    0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
1598 +    0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
1599 +};
1600 +#endif
1601 +
1602 +#if defined(SHA512_NEEDED)
1603 +static const u_int64_t sha512_hashInit[8] = {
1604 +    0x6a09e667f3bcc908ULL, 0xbb67ae8584caa73bULL, 0x3c6ef372fe94f82bULL,
1605 +    0xa54ff53a5f1d36f1ULL, 0x510e527fade682d1ULL, 0x9b05688c2b3e6c1fULL,
1606 +    0x1f83d9abfb41bd6bULL, 0x5be0cd19137e2179ULL
1607 +};
1608 +#endif
1609 +
1610 +#if defined(SHA384_NEEDED)
1611 +static const u_int64_t sha384_hashInit[8] = {
1612 +    0xcbbb9d5dc1059ed8ULL, 0x629a292a367cd507ULL, 0x9159015a3070dd17ULL,
1613 +    0x152fecd8f70e5939ULL, 0x67332667ffc00b31ULL, 0x8eb44a8768581511ULL,
1614 +    0xdb0c2e0d64f98fa7ULL, 0x47b5481dbefa4fa4ULL
1615 +};
1616 +#endif
1617 +
1618 +#if defined(SHA512_NEEDED) || defined(SHA384_NEEDED)
1619 +static const u_int64_t sha512_K[80] = {
1620 +    0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL, 0xb5c0fbcfec4d3b2fULL,
1621 +    0xe9b5dba58189dbbcULL, 0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL,
1622 +    0x923f82a4af194f9bULL, 0xab1c5ed5da6d8118ULL, 0xd807aa98a3030242ULL,
1623 +    0x12835b0145706fbeULL, 0x243185be4ee4b28cULL, 0x550c7dc3d5ffb4e2ULL,
1624 +    0x72be5d74f27b896fULL, 0x80deb1fe3b1696b1ULL, 0x9bdc06a725c71235ULL,
1625 +    0xc19bf174cf692694ULL, 0xe49b69c19ef14ad2ULL, 0xefbe4786384f25e3ULL,
1626 +    0x0fc19dc68b8cd5b5ULL, 0x240ca1cc77ac9c65ULL, 0x2de92c6f592b0275ULL,
1627 +    0x4a7484aa6ea6e483ULL, 0x5cb0a9dcbd41fbd4ULL, 0x76f988da831153b5ULL,
1628 +    0x983e5152ee66dfabULL, 0xa831c66d2db43210ULL, 0xb00327c898fb213fULL,
1629 +    0xbf597fc7beef0ee4ULL, 0xc6e00bf33da88fc2ULL, 0xd5a79147930aa725ULL,
1630 +    0x06ca6351e003826fULL, 0x142929670a0e6e70ULL, 0x27b70a8546d22ffcULL,
1631 +    0x2e1b21385c26c926ULL, 0x4d2c6dfc5ac42aedULL, 0x53380d139d95b3dfULL,
1632 +    0x650a73548baf63deULL, 0x766a0abb3c77b2a8ULL, 0x81c2c92e47edaee6ULL,
1633 +    0x92722c851482353bULL, 0xa2bfe8a14cf10364ULL, 0xa81a664bbc423001ULL,
1634 +    0xc24b8b70d0f89791ULL, 0xc76c51a30654be30ULL, 0xd192e819d6ef5218ULL,
1635 +    0xd69906245565a910ULL, 0xf40e35855771202aULL, 0x106aa07032bbd1b8ULL,
1636 +    0x19a4c116b8d2d0c8ULL, 0x1e376c085141ab53ULL, 0x2748774cdf8eeb99ULL,
1637 +    0x34b0bcb5e19b48a8ULL, 0x391c0cb3c5c95a63ULL, 0x4ed8aa4ae3418acbULL,
1638 +    0x5b9cca4f7763e373ULL, 0x682e6ff3d6b2b8a3ULL, 0x748f82ee5defb2fcULL,
1639 +    0x78a5636f43172f60ULL, 0x84c87814a1f0ab72ULL, 0x8cc702081a6439ecULL,
1640 +    0x90befffa23631e28ULL, 0xa4506cebde82bde9ULL, 0xbef9a3f7b2c67915ULL,
1641 +    0xc67178f2e372532bULL, 0xca273eceea26619cULL, 0xd186b8c721c0c207ULL,
1642 +    0xeada7dd6cde0eb1eULL, 0xf57d4f7fee6ed178ULL, 0x06f067aa72176fbaULL,
1643 +    0x0a637dc5a2c898a6ULL, 0x113f9804bef90daeULL, 0x1b710b35131c471bULL,
1644 +    0x28db77f523047d84ULL, 0x32caab7b40c72493ULL, 0x3c9ebe0a15c9bebcULL,
1645 +    0x431d67c49c100d4cULL, 0x4cc5d4becb3e42b6ULL, 0x597f299cfc657e2aULL,
1646 +    0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL
1647 +};
1648 +#endif
1649 +
1650 +#define Ch(x,y,z)   (((x) & (y)) ^ ((~(x)) & (z)))
1651 +#define Maj(x,y,z)  (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
1652 +#define R(x,y)      ((y) >> (x))
1653 +
1654 +#if defined(SHA256_NEEDED)
1655 +void sha256_init(sha256_context *ctx)
1656 +{
1657 +    memcpy(&ctx->sha_H[0], &sha256_hashInit[0], sizeof(ctx->sha_H));
1658 +    ctx->sha_blocks = 0;
1659 +    ctx->sha_bufCnt = 0;
1660 +}
1661 +
1662 +#define S(x,y)      (((y) >> (x)) | ((y) << (32 - (x))))
1663 +#define uSig0(x)    ((S(2,(x))) ^ (S(13,(x))) ^ (S(22,(x))))
1664 +#define uSig1(x)    ((S(6,(x))) ^ (S(11,(x))) ^ (S(25,(x))))
1665 +#define lSig0(x)    ((S(7,(x))) ^ (S(18,(x))) ^ (R(3,(x))))
1666 +#define lSig1(x)    ((S(17,(x))) ^ (S(19,(x))) ^ (R(10,(x))))
1667 +
1668 +static void sha256_transform(sha256_context *ctx, unsigned char *datap)
1669 +{
1670 +    register int    j;
1671 +    u_int32_t       a, b, c, d, e, f, g, h;
1672 +    u_int32_t       T1, T2, W[64], Wm2, Wm15;
1673 +
1674 +    /* read the data, big endian byte order */
1675 +    j = 0;
1676 +    do {
1677 +        W[j] = (((u_int32_t)(datap[0]))<<24) | (((u_int32_t)(datap[1]))<<16) |
1678 +               (((u_int32_t)(datap[2]))<<8 ) | ((u_int32_t)(datap[3]));
1679 +        datap += 4;
1680 +    } while(++j < 16);
1681 +    
1682 +    /* initialize variables a...h */
1683 +    a = ctx->sha_H[0];
1684 +    b = ctx->sha_H[1];
1685 +    c = ctx->sha_H[2];
1686 +    d = ctx->sha_H[3];
1687 +    e = ctx->sha_H[4];
1688 +    f = ctx->sha_H[5];
1689 +    g = ctx->sha_H[6];
1690 +    h = ctx->sha_H[7];
1691 +
1692 +    /* apply compression function */
1693 +    j = 0;
1694 +    do {
1695 +        if(j >= 16) {
1696 +            Wm2 = W[j - 2];
1697 +            Wm15 = W[j - 15];
1698 +            W[j] = lSig1(Wm2) + W[j - 7] + lSig0(Wm15) + W[j - 16];
1699 +        }
1700 +        T1 = h + uSig1(e) + Ch(e,f,g) + sha256_K[j] + W[j];
1701 +        T2 = uSig0(a) + Maj(a,b,c);
1702 +        h = g; g = f; f = e;
1703 +        e = d + T1;
1704 +        d = c; c = b; b = a;
1705 +        a = T1 + T2;
1706 +    } while(++j < 64);
1707 +
1708 +    /* compute intermediate hash value */
1709 +    ctx->sha_H[0] += a;
1710 +    ctx->sha_H[1] += b;
1711 +    ctx->sha_H[2] += c;
1712 +    ctx->sha_H[3] += d;
1713 +    ctx->sha_H[4] += e;
1714 +    ctx->sha_H[5] += f;
1715 +    ctx->sha_H[6] += g;
1716 +    ctx->sha_H[7] += h;
1717 +
1718 +    ctx->sha_blocks++;
1719 +}
1720 +
1721 +void sha256_write(sha256_context *ctx, unsigned char *datap, int length)
1722 +{
1723 +    while(length > 0) {
1724 +        if(!ctx->sha_bufCnt) {
1725 +            while(length >= sizeof(ctx->sha_out)) {
1726 +                sha256_transform(ctx, datap);
1727 +                datap += sizeof(ctx->sha_out);
1728 +                length -= sizeof(ctx->sha_out);
1729 +            }
1730 +            if(!length) return;
1731 +        }
1732 +        ctx->sha_out[ctx->sha_bufCnt] = *datap++;
1733 +        length--;
1734 +        if(++ctx->sha_bufCnt == sizeof(ctx->sha_out)) {
1735 +            sha256_transform(ctx, &ctx->sha_out[0]);
1736 +            ctx->sha_bufCnt = 0;
1737 +        }
1738 +    }
1739 +}
1740 +
1741 +void sha256_final(sha256_context *ctx)
1742 +{
1743 +    register int    j;
1744 +    u_int64_t       bitLength;
1745 +    u_int32_t       i;
1746 +    unsigned char   padByte, *datap;
1747 +
1748 +    bitLength = (ctx->sha_blocks << 9) | (ctx->sha_bufCnt << 3);
1749 +    padByte = 0x80;
1750 +    sha256_write(ctx, &padByte, 1);
1751 +
1752 +    /* pad extra space with zeroes */
1753 +    padByte = 0;
1754 +    while(ctx->sha_bufCnt != 56) {
1755 +        sha256_write(ctx, &padByte, 1);
1756 +    }
1757 +
1758 +    /* write bit length, big endian byte order */
1759 +    ctx->sha_out[56] = bitLength >> 56;
1760 +    ctx->sha_out[57] = bitLength >> 48;
1761 +    ctx->sha_out[58] = bitLength >> 40;
1762 +    ctx->sha_out[59] = bitLength >> 32;
1763 +    ctx->sha_out[60] = bitLength >> 24;
1764 +    ctx->sha_out[61] = bitLength >> 16;
1765 +    ctx->sha_out[62] = bitLength >> 8;
1766 +    ctx->sha_out[63] = bitLength;
1767 +    sha256_transform(ctx, &ctx->sha_out[0]);
1768 +    
1769 +    /* return results in ctx->sha_out[0...31] */
1770 +    datap = &ctx->sha_out[0];
1771 +    j = 0;
1772 +    do {
1773 +        i = ctx->sha_H[j];
1774 +        datap[0] = i >> 24;
1775 +        datap[1] = i >> 16;
1776 +        datap[2] = i >> 8;
1777 +        datap[3] = i;
1778 +        datap += 4;
1779 +    } while(++j < 8);
1780 +
1781 +    /* clear sensitive information */
1782 +    memset(&ctx->sha_out[32], 0, sizeof(sha256_context) - 32);
1783 +}
1784 +
1785 +void sha256_hash_buffer(unsigned char *ib, int ile, unsigned char *ob, int ole)
1786 +{
1787 +    sha256_context ctx;
1788 +
1789 +    if(ole < 1) return;
1790 +    memset(ob, 0, ole);
1791 +    if(ole > 32) ole = 32;
1792 +    sha256_init(&ctx);
1793 +    sha256_write(&ctx, ib, ile);
1794 +    sha256_final(&ctx);
1795 +    memcpy(ob, &ctx.sha_out[0], ole);
1796 +    memset(&ctx, 0, sizeof(ctx));
1797 +}
1798 +
1799 +#endif
1800 +
1801 +#if defined(SHA512_NEEDED)
1802 +void sha512_init(sha512_context *ctx)
1803 +{
1804 +    memcpy(&ctx->sha_H[0], &sha512_hashInit[0], sizeof(ctx->sha_H));
1805 +    ctx->sha_blocks = 0;
1806 +    ctx->sha_blocksMSB = 0;
1807 +    ctx->sha_bufCnt = 0;
1808 +}
1809 +#endif
1810 +
1811 +#if defined(SHA512_NEEDED) || defined(SHA384_NEEDED)
1812 +#undef S
1813 +#undef uSig0
1814 +#undef uSig1
1815 +#undef lSig0
1816 +#undef lSig1
1817 +#define S(x,y)      (((y) >> (x)) | ((y) << (64 - (x))))
1818 +#define uSig0(x)    ((S(28,(x))) ^ (S(34,(x))) ^ (S(39,(x))))
1819 +#define uSig1(x)    ((S(14,(x))) ^ (S(18,(x))) ^ (S(41,(x))))
1820 +#define lSig0(x)    ((S(1,(x))) ^ (S(8,(x))) ^ (R(7,(x))))
1821 +#define lSig1(x)    ((S(19,(x))) ^ (S(61,(x))) ^ (R(6,(x))))
1822 +
1823 +static void sha512_transform(sha512_context *ctx, unsigned char *datap)
1824 +{
1825 +    register int    j;
1826 +    u_int64_t       a, b, c, d, e, f, g, h;
1827 +    u_int64_t       T1, T2, W[80], Wm2, Wm15;
1828 +
1829 +    /* read the data, big endian byte order */
1830 +    j = 0;
1831 +    do {
1832 +        W[j] = (((u_int64_t)(datap[0]))<<56) | (((u_int64_t)(datap[1]))<<48) |
1833 +               (((u_int64_t)(datap[2]))<<40) | (((u_int64_t)(datap[3]))<<32) |
1834 +               (((u_int64_t)(datap[4]))<<24) | (((u_int64_t)(datap[5]))<<16) |
1835 +               (((u_int64_t)(datap[6]))<<8 ) | ((u_int64_t)(datap[7]));
1836 +        datap += 8;
1837 +    } while(++j < 16);
1838 +    
1839 +    /* initialize variables a...h */
1840 +    a = ctx->sha_H[0];
1841 +    b = ctx->sha_H[1];
1842 +    c = ctx->sha_H[2];
1843 +    d = ctx->sha_H[3];
1844 +    e = ctx->sha_H[4];
1845 +    f = ctx->sha_H[5];
1846 +    g = ctx->sha_H[6];
1847 +    h = ctx->sha_H[7];
1848 +
1849 +    /* apply compression function */
1850 +    j = 0;
1851 +    do {
1852 +        if(j >= 16) {
1853 +            Wm2 = W[j - 2];
1854 +            Wm15 = W[j - 15];
1855 +            W[j] = lSig1(Wm2) + W[j - 7] + lSig0(Wm15) + W[j - 16];
1856 +        }
1857 +        T1 = h + uSig1(e) + Ch(e,f,g) + sha512_K[j] + W[j];
1858 +        T2 = uSig0(a) + Maj(a,b,c);
1859 +        h = g; g = f; f = e;
1860 +        e = d + T1;
1861 +        d = c; c = b; b = a;
1862 +        a = T1 + T2;
1863 +    } while(++j < 80);
1864 +
1865 +    /* compute intermediate hash value */
1866 +    ctx->sha_H[0] += a;
1867 +    ctx->sha_H[1] += b;
1868 +    ctx->sha_H[2] += c;
1869 +    ctx->sha_H[3] += d;
1870 +    ctx->sha_H[4] += e;
1871 +    ctx->sha_H[5] += f;
1872 +    ctx->sha_H[6] += g;
1873 +    ctx->sha_H[7] += h;
1874 +
1875 +    ctx->sha_blocks++;
1876 +    if(!ctx->sha_blocks) ctx->sha_blocksMSB++;
1877 +}
1878 +
1879 +void sha512_write(sha512_context *ctx, unsigned char *datap, int length)
1880 +{
1881 +    while(length > 0) {
1882 +        if(!ctx->sha_bufCnt) {
1883 +            while(length >= sizeof(ctx->sha_out)) {
1884 +                sha512_transform(ctx, datap);
1885 +                datap += sizeof(ctx->sha_out);
1886 +                length -= sizeof(ctx->sha_out);
1887 +            }
1888 +            if(!length) return;
1889 +        }
1890 +        ctx->sha_out[ctx->sha_bufCnt] = *datap++;
1891 +        length--;
1892 +        if(++ctx->sha_bufCnt == sizeof(ctx->sha_out)) {
1893 +            sha512_transform(ctx, &ctx->sha_out[0]);
1894 +            ctx->sha_bufCnt = 0;
1895 +        }
1896 +    }
1897 +}
1898 +
1899 +void sha512_final(sha512_context *ctx)
1900 +{
1901 +    register int    j;
1902 +    u_int64_t       bitLength, bitLengthMSB;
1903 +    u_int64_t       i;
1904 +    unsigned char   padByte, *datap;
1905 +
1906 +    bitLength = (ctx->sha_blocks << 10) | (ctx->sha_bufCnt << 3);
1907 +    bitLengthMSB = (ctx->sha_blocksMSB << 10) | (ctx->sha_blocks >> 54);
1908 +    padByte = 0x80;
1909 +    sha512_write(ctx, &padByte, 1);
1910 +
1911 +    /* pad extra space with zeroes */
1912 +    padByte = 0;
1913 +    while(ctx->sha_bufCnt != 112) {
1914 +        sha512_write(ctx, &padByte, 1);
1915 +    }
1916 +
1917 +    /* write bit length, big endian byte order */
1918 +    ctx->sha_out[112] = bitLengthMSB >> 56;
1919 +    ctx->sha_out[113] = bitLengthMSB >> 48;
1920 +    ctx->sha_out[114] = bitLengthMSB >> 40;
1921 +    ctx->sha_out[115] = bitLengthMSB >> 32;
1922 +    ctx->sha_out[116] = bitLengthMSB >> 24;
1923 +    ctx->sha_out[117] = bitLengthMSB >> 16;
1924 +    ctx->sha_out[118] = bitLengthMSB >> 8;
1925 +    ctx->sha_out[119] = bitLengthMSB;
1926 +    ctx->sha_out[120] = bitLength >> 56;
1927 +    ctx->sha_out[121] = bitLength >> 48;
1928 +    ctx->sha_out[122] = bitLength >> 40;
1929 +    ctx->sha_out[123] = bitLength >> 32;
1930 +    ctx->sha_out[124] = bitLength >> 24;
1931 +    ctx->sha_out[125] = bitLength >> 16;
1932 +    ctx->sha_out[126] = bitLength >> 8;
1933 +    ctx->sha_out[127] = bitLength;
1934 +    sha512_transform(ctx, &ctx->sha_out[0]);
1935 +    
1936 +    /* return results in ctx->sha_out[0...63] */
1937 +    datap = &ctx->sha_out[0];
1938 +    j = 0;
1939 +    do {
1940 +        i = ctx->sha_H[j];
1941 +        datap[0] = i >> 56;
1942 +        datap[1] = i >> 48;
1943 +        datap[2] = i >> 40;
1944 +        datap[3] = i >> 32;
1945 +        datap[4] = i >> 24;
1946 +        datap[5] = i >> 16;
1947 +        datap[6] = i >> 8;
1948 +        datap[7] = i;
1949 +        datap += 8;
1950 +    } while(++j < 8);
1951 +
1952 +    /* clear sensitive information */
1953 +    memset(&ctx->sha_out[64], 0, sizeof(sha512_context) - 64);
1954 +}
1955 +
1956 +void sha512_hash_buffer(unsigned char *ib, int ile, unsigned char *ob, int ole)
1957 +{
1958 +    sha512_context ctx;
1959 +
1960 +    if(ole < 1) return;
1961 +    memset(ob, 0, ole);
1962 +    if(ole > 64) ole = 64;
1963 +    sha512_init(&ctx);
1964 +    sha512_write(&ctx, ib, ile);
1965 +    sha512_final(&ctx);
1966 +    memcpy(ob, &ctx.sha_out[0], ole);
1967 +    memset(&ctx, 0, sizeof(ctx));
1968 +}
1969 +#endif
1970 +
1971 +#if defined(SHA384_NEEDED)
1972 +void sha384_init(sha512_context *ctx)
1973 +{
1974 +    memcpy(&ctx->sha_H[0], &sha384_hashInit[0], sizeof(ctx->sha_H));
1975 +    ctx->sha_blocks = 0;
1976 +    ctx->sha_blocksMSB = 0;
1977 +    ctx->sha_bufCnt = 0;
1978 +}
1979 +
1980 +void sha384_hash_buffer(unsigned char *ib, int ile, unsigned char *ob, int ole)
1981 +{
1982 +    sha512_context ctx;
1983 +
1984 +    if(ole < 1) return;
1985 +    memset(ob, 0, ole);
1986 +    if(ole > 48) ole = 48;
1987 +    sha384_init(&ctx);
1988 +    sha512_write(&ctx, ib, ile);
1989 +    sha512_final(&ctx);
1990 +    memcpy(ob, &ctx.sha_out[0], ole);
1991 +    memset(&ctx, 0, sizeof(ctx));
1992 +}
1993 +#endif
1994 diff -Nur util-linux-2.11zorg/mount/sha512.h util-linux-2.11z/mount/sha512.h
1995 --- util-linux-2.11zorg/mount/sha512.h  Thu Jan  1 00:00:00 1970
1996 +++ util-linux-2.11z/mount/sha512.h     Fri Mar 28 21:43:00 2003
1997 @@ -0,0 +1,45 @@
1998 +/*
1999 + *  sha512.h
2000 + *
2001 + *  Written by Jari Ruusu, April 16 2001
2002 + *
2003 + *  Copyright 2001 by Jari Ruusu.
2004 + *  Redistribution of this file is permitted under the GNU Public License.
2005 + */
2006 +
2007 +#include <sys/types.h>
2008 +
2009 +typedef struct {
2010 +    unsigned char   sha_out[64];    /* results are here, bytes 0...31 */
2011 +    u_int32_t       sha_H[8];
2012 +    u_int64_t       sha_blocks;
2013 +    int             sha_bufCnt;
2014 +} sha256_context;
2015 +
2016 +typedef struct {
2017 +    unsigned char   sha_out[128];   /* results are here, bytes 0...63 */
2018 +    u_int64_t       sha_H[8];
2019 +    u_int64_t       sha_blocks;
2020 +    u_int64_t       sha_blocksMSB;
2021 +    int             sha_bufCnt;
2022 +} sha512_context;
2023 +
2024 +/* no sha384_context, use sha512_context */
2025 +
2026 +/* 256 bit hash, provides 128 bits of security against collision attacks */
2027 +extern void sha256_init(sha256_context *);
2028 +extern void sha256_write(sha256_context *, unsigned char *, int);
2029 +extern void sha256_final(sha256_context *);
2030 +extern void sha256_hash_buffer(unsigned char *, int, unsigned char *, int);
2031 +
2032 +/* 512 bit hash, provides 256 bits of security against collision attacks */
2033 +extern void sha512_init(sha512_context *);
2034 +extern void sha512_write(sha512_context *, unsigned char *, int);
2035 +extern void sha512_final(sha512_context *);
2036 +extern void sha512_hash_buffer(unsigned char *, int, unsigned char *, int);
2037 +
2038 +/* 384 bit hash, provides 192 bits of security against collision attacks */
2039 +extern void sha384_init(sha512_context *);
2040 +/* no sha384_write(), use sha512_write() */
2041 +/* no sha384_final(), use sha512_final(), result in ctx->sha_out[0...47]  */
2042 +extern void sha384_hash_buffer(unsigned char *, int, unsigned char *, int);
2043 diff -Nur util-linux-2.11zorg/mount/sundries.c util-linux-2.11z/mount/sundries.c
2044 --- util-linux-2.11zorg/mount/sundries.c        Fri Nov  1 01:00:50 2002
2045 +++ util-linux-2.11z/mount/sundries.c   Fri Mar 28 21:43:00 2003
2046 @@ -162,7 +162,7 @@
2047           return 1;
2048  
2049       no = 0;
2050 -     if (!strncmp(types, "no", 2)) {
2051 +     if (types && !strncmp(types, "no", 2)) {
2052           no = 1;
2053           types += 2;
2054       }
This page took 0.206878 seconds and 3 git commands to generate.