1 diff -ruN john-1.6/doc/CHANGES john-1.6.34/doc/CHANGES
2 --- john-1.6/doc/CHANGES 1970-01-01 01:00:00.000000000 +0100
3 +++ john-1.6.34/doc/CHANGES 2003-01-24 04:55:37.000000000 +0100
5 +The following major changes have been done since John 1.6:
7 +* Two MD5 hashes at a time for extra ILP on RISC: up to +80% on Alpha EV5.
8 +* Significant improvements to the generic bitslice DES code: +20% on RISC.
9 +* Bitslice DES code for x86 with MMX: more than twice faster on Intel MMX.
10 +* Bitsliced the LM hash code as well: now several times faster.
11 +* Generic Blowfish x86 assembly code in addition to the original Pentium
12 +version: +15% on the Pentium Pro family (up to Pentium III), +20% on AMD.
13 +* First attempt at vectorization support for bitslice DES.
14 +* Better idle priority emulation with POSIX.1b (POSIX.4) scheduling calls.
15 +* System-wide installation support for *BSD ports and Linux distributions.
16 +* AIX, DU / Tru64 C2, HP-UX tcb files support in 'unshadow'.
17 +* New make targets for Linux/PowerPC, FreeBSD/Alpha, SCO, OpenBSD/SPARC,
18 +OpenBSD/VAX, NetBSD/VAX, Solaris/SPARC64, MacOS X, BeOS.
19 +* Bug and portability fixes, and new bugs.
20 +* Bonus: "Strip" cracker included in the default john.conf (john.ini).
21 diff -ruN john-1.6/doc/LICENSING john-1.6.34/doc/LICENSING
22 --- john-1.6/doc/LICENSING 1970-01-01 01:00:00.000000000 +0100
23 +++ john-1.6.34/doc/LICENSING 2002-05-08 20:05:53.000000000 +0200
25 +John the Ripper 1.7, when released, is going to be GPL'ed. However,
26 +the licensing status of one source file -- x86-mmx.S -- is non-obvious
27 +to me. I have explicit permission to use the S-box code found in this
28 +file in John, but I'm not sure whether this was meant to imply that I
29 +am free to put this code under a license of my choice. I haven't got
30 +a reply regarding this so far.
32 +Portions of this code I've placed into the public domain as a separate
33 +package designed to provide modern password hashing for your software
34 +and your servers (where the GPL restrictions could be a problem). The
35 +package can be found at:
37 + http://www.openwall.com/crypt/
38 diff -ruN john-1.6/run/john.conf john-1.6.34/run/john.conf
39 --- john-1.6/run/john.conf 1970-01-01 01:00:00.000000000 +0100
40 +++ john-1.6.34/run/john.conf 2002-05-10 20:16:35.000000000 +0200
43 +# This file is part of John the Ripper password cracker,
44 +# Copyright (c) 1996-2002 by Solar Designer
48 +# Wordlist file name, to be used in batch mode
49 +Wordfile = $JOHN/password.lst
50 +# Use idle cycles only
52 +# Crash recovery file saving delay in seconds
54 +# Beep when a password is found (who needs this anyway?)
57 +# "Single crack" mode rules
59 +# Simple rules come first...
65 +# These were not included in crackers I've seen, but are pretty efficient,
66 +# so I include them near the beginning
71 +# Weird order, eh? Can't do anything about it, the order is based on the
72 +# number of successful cracks...
90 +# About 50% of single-mode-crackable passwords get cracked by now...
131 +# Now to the suffix stuff...
132 +<*l$[1-9!0a-z"-/:-@\[-`{-~]
133 +<*(?ac$[1-9!0a-z"-/:-@\[-`{-~]
140 +# Removing vowels...
144 +# crack -> cracked, crack -> cracking
150 +<*(?a[lc])er=1iD0o0yr
151 +# The following 3l33t rules are based on original Crack's dicts.rules
167 +l/asa4/ese3/lsl1[:c]
168 +l/asa4/ese3/oso0[:c]
169 +l/asa4/ese3/sss$[:c]
170 +l/asa4/lsl1/oso0[:c]
171 +l/asa4/lsl1/sss$[:c]
172 +l/asa4/oso0/sss$[:c]
173 +l/ese3/lsl1/oso0[:c]
174 +l/ese3/lsl1/sss$[:c]
175 +l/ese3/oso0/sss$[:c]
176 +l/lsl1/oso0/sss$[:c]
177 +l/asa4/ese3/lsl1/oso0[:c]
178 +l/asa4/ese3/lsl1/sss$[:c]
179 +l/asa4/ese3/oso0/sss$[:c]
180 +l/asa4/lsl1/oso0/sss$[:c]
181 +l/ese3/lsl1/oso0/sss$[:c]
182 +l/asa4/ese3/lsl1/oso0/sss$[:c]
183 +# Now to the prefix stuff...
191 +<9(?a[lc]^.^r^[mdMD]
194 +# Some word pair rules...
195 +# johnsmith -> JohnSmith, johnSmith
197 +# JohnSmith -> john smith, john_smith, john-smith
199 +# JohnSmith -> John smith, John_smith, John-smith
201 +# JohnSmith -> john Smith, john_Smith, john-Smith
203 +# johnsmith -> John Smith, John_Smith, John-Smith
205 +# Applying different simple rules to each of the two words
210 +# jsmith -> smithj, etc...
222 +# Inserting a dot...
224 +# More suffix stuff...
230 +# cracking -> CRACKiNG
232 +# Crack96 -> cRACK96
234 +# Crack96 -> cRACK(^
236 +# Crack96 -> CRaCK96
238 +# Really weird charset conversions, like "england" -> "rmh;smf"
244 +# Both prefixing and suffixing...
268 +# The rest of two-digit suffix stuff, less common numbers...
271 +# Some three-digit numbers...
283 +# Some [birth] years...
289 +# Uncomment the following lines if you're really crazy
290 +;# Insert/overstrike some characters...
293 +;# Toggle case everywhere...
294 +;lMT[*7]T[*6]T[*5]T[*4]T[*3]T[*2]T[*1]T[*0]Q
295 +;# Very slow stuff...
296 +;l$[1-90]<-$[0-9]$[0-9]
297 +;(?ac$[1-90]<-$[0-9]$[0-9]
302 +# Wordlist mode rules
303 +[List.Rules:Wordlist]
304 +# Try words as they are
306 +# Lowercase every pure alphanumeric word
308 +# Capitalize every pure alphanumeric word
310 +# Lowercase and pluralize pure alphabetic words
312 +# Lowercase pure alphabetic words and append '1'
314 +# Capitalize pure alphabetic words and append '1'
316 +# Duplicate reasonably short pure alphabetic words (fred -> fredfred)
318 +# Lowercase and reverse pure alphabetic words
320 +# Prefix pure alphabetic words with '1'
322 +# Uppercase pure alphanumeric words
324 +# Lowercase pure alphabetic words and append a digit or simple punctuation
325 +<*>2!?Al$[2!37954860.?]
326 +# Words containing punctuation, which is then squeezed out, lowercase
328 +# Words with vowels removed, lowercase
330 +# Words containing whitespace, which is then squeezed out, lowercase
332 +# Capitalize and duplicate short pure alphabetic words (fred -> FredFred)
334 +# Capitalize and reverse pure alphabetic words (fred -> derF)
336 +# Reverse and capitalize pure alphabetic words (fred -> Derf)
338 +# Lowercase and reflect pure alphabetic words (fred -> fredderf)
340 +# Uppercase the last letter of pure alphabetic words (fred -> freD)
342 +# Prefix pure alphabetic words with '2' or '4'
344 +# Capitalize pure alphabetic words and append a digit or simple punctuation
345 +-c <*>2!?Ac$[2!3957468.?0]
346 +# Prefix pure alphabetic words with digits
348 +# Capitalize and pluralize pure alphabetic words of reasonable length
350 +# Lowercase/capitalize pure alphabetic words of reasonable length and convert:
351 +# crack -> cracked, crack -> cracking
354 +# Try the second half of split passwords
360 +File = $JOHN/all.chr
366 +File = $JOHN/alpha.chr
371 +[Incremental:Digits]
372 +File = $JOHN/digits.chr
377 +[Incremental:LanMan]
378 +File = $JOHN/lanman.chr
383 +# Some pre-defined word filters
384 +[List.External:Filter_Alpha]
390 + while (c = word[i++])
391 + if (c < 'a' || c > 'z') {
396 +[List.External:Filter_Digits]
402 + while (c = word[i++])
403 + if (c < '0' || c > '9') {
408 +[List.External:Filter_LanMan]
413 + word[7] = 0; // Truncate at 7 characters
415 + i = 0; // Convert to uppercase
416 + while (c = word[i]) {
417 + if (c >= 'a' && c <= 'z') word[i] &= 0xDF;
422 +# A simple cracker for LM hashes
423 +[List.External:LanMan]
424 +int length; // Current length
428 + word[0] = 'A' - 1; // Start with "A"
429 + word[length = 1] = 0;
436 + i = length - 1; // Start from the last character
437 + while (++word[i] > 'Z') // Try to increase it
438 + if (i) // Overflow here, any more positions?
439 + word[i--] = 'A'; // Yes, move to the left, and repeat
442 + word[i = ++length] = 0; // Switch to the next length
447 + word = 0; return; // We're done
453 + length = 0; // Calculate the length
454 + while (word[length]) length++;
457 +# Strip 0.5 ("Secure Tool for Recalling Important Passwords") cracker,
458 +# based on analysis done by Thomas Roessler and Ian Goldberg. This will
459 +# crack passwords you may have generated with Strip, other uses of Strip
461 +# See http://www.zetetic.net/products.html for information on Strip.
462 +[List.External:Strip]
463 +int minlength, maxlength, mintype, maxtype;
464 +int crack_seed, length, type;
465 +int count, charset[128];
471 +/* Password lengths to try; Strip can generate passwords of 4 to 16
472 + * characters, but traditional crypt(3) hashes are limited to 8. */
473 + minlength = 8; // 4
474 + maxlength = 8; // 16
476 +/* Password types to try (Numeric, Alpha-Num, Alpha-Num w/ Meta). */
480 + crack_seed = 0x10000;
481 + length = minlength - 1;
485 + c = '0'; while (c <= '9') charset[count++] = c++;
493 + if (crack_seed > 0xffff) {
496 + if (++length > maxlength) {
497 + length = minlength;
499 + if (++type > maxtype) {
507 + c = 'a'; while (c <= 'f') charset[count++] = c++;
508 + c = 'h'; while (c <= 'z') charset[count++] = c++;
509 + c = 'A'; while (c <= 'Z') charset[count++] = c++;
512 + charset[count++] = '!';
513 + c = '#'; while (c <= '&') charset[count++] = c++;
514 + c = '('; while (c <= '/') charset[count++] = c++;
515 + c = '<'; while (c <= '>') charset[count++] = c++;
516 + charset[count++] = '?'; charset[count++] = '@';
517 + charset[count++] = '['; charset[count++] = ']';
518 + charset[count++] = '^'; charset[count++] = '_';
519 + c = '{'; while (c <= '~') charset[count++] = c++;
523 + seed = (crack_seed++ << 16 >> 16) * 22695477 + 1;
526 + while (i < length) {
527 + random = ((seed = seed * 22695477 + 1) >> 16) & 0x7fff;
528 + word[i++] = charset[random % count];
534 +# Useful external mode example
535 +[List.External:Double]
537 + * This cracking mode tries all the possible duplicated lowercase alphabetic
538 + * "words" of up to 8 characters long. Since word halves are the same, it
539 + * only has to try about 500,000 words.
542 +/* Global variables: current length and word */
543 +int length, current[9];
545 +/* Called at startup to initialize the global variables */
550 + i = length = 2; // Start with 4 character long words
551 + while (i--) current[i] = 'a'; // Set our half-word to "aa"
554 +/* Generates a new word */
559 +/* Export last generated word, duplicating it at the same time; here "word"
560 + * is a pre-defined external variable. */
561 + word[(i = length) << 1] = 0;
562 + while (i--) word[length + i] = word[i] = current[i];
564 +/* Generate a new word */
565 + i = length - 1; // Start from the last character
566 + while (++current[i] > 'z') // Try to increase it
567 + if (i) // Overflow here, any more positions?
568 + current[i--] = 'a'; // Yes, move to the left, and repeat
570 + current = 0; // Request a length switch
571 + break; // Break out of the loop
574 +/* Switch to the next length, unless we were generating 8 character long
575 + * words already. */
576 + if (!current && length < 4) {
578 + while (i--) current[i] = 'a';
582 +/* Called when restoring an interrupted session */
587 +/* Import the word back */
589 + while (current[i] = word[i]) i++;
591 +/* ...and calculate the half-word length */
595 +# Simple parallel processing example
596 +[List.External:Parallel]
598 + * This word filter makes John process some of the words only, for running
599 + * multiple instances on different CPUs. It can be used with any cracking
600 + * mode except for "single crack". Note: this is not a good solution, but
601 + * is just an example of what can be done with word filters.
604 +int node, total; // This node's number, and node count
605 +int number; // Current word number
609 + node = 1; total = 2; // Node 1 of 2, change as appropriate
610 + number = node - 1; // Speedup the filter a bit
615 + if (number++ % total) // Word for a different node?
616 + word = 0; // Yes, skip it
618 diff -ruN john-1.6/src/AFS_fmt.c john-1.6.34/src/AFS_fmt.c
619 --- john-1.6/src/AFS_fmt.c 1998-12-03 01:29:50.000000000 +0100
620 +++ john-1.6.34/src/AFS_fmt.c 2001-06-16 08:08:33.000000000 +0200
623 * This file is part of John the Ripper password cracker,
624 - * Copyright (c) 1996-98 by Solar Designer
625 + * Copyright (c) 1996-2001 by Solar Designer
631 static DES_binary AFS_long_IV_binary;
634 +static void init(void)
636 ARCH_WORD_32 block[2];
637 #if !ARCH_LITTLE_ENDIAN
638 @@ -121,12 +121,12 @@
640 if (strncmp(ciphertext, "$K4$", 4)) return 0;
642 - for (pos = &ciphertext[4]; atoi16[(ARCH_INDEX)*pos] != 0x7F; pos++);
643 + for (pos = &ciphertext[4]; atoi16[ARCH_INDEX(*pos)] != 0x7F; pos++);
644 if (*pos != ',' || pos - ciphertext != CIPHERTEXT_LENGTH) return 0;
646 for (index = 0; index < 16; index += 2) {
647 - value = (int)atoi16[(ARCH_INDEX)ciphertext[index + 4]] << 4;
648 - value |= atoi16[(ARCH_INDEX)ciphertext[index + 5]];
649 + value = (int)atoi16[ARCH_INDEX(ciphertext[index + 4])] << 4;
650 + value |= atoi16[ARCH_INDEX(ciphertext[index + 5])];
657 for (index = 0; index < 16; index += 2) {
658 - value = (int)atoi16[(ARCH_INDEX)ciphertext[index + 4]] << 4;
659 - value |= atoi16[(ARCH_INDEX)ciphertext[index + 5]];
660 + value = (int)atoi16[ARCH_INDEX(ciphertext[index + 4])] << 4;
661 + value |= atoi16[ARCH_INDEX(ciphertext[index + 5])];
663 out[index >> 3] |= (value | 1) << ((index << 2) & 0x18);
669 + fmt_default_clear_keys,
673 diff -ruN john-1.6/src/alpha.h john-1.6.34/src/alpha.h
674 --- john-1.6/src/alpha.h 1998-12-03 01:29:50.000000000 +0100
675 +++ john-1.6.34/src/alpha.h 2000-05-08 09:05:05.000000000 +0200
678 * This file is part of John the Ripper password cracker,
679 - * Copyright (c) 1996-98 by Solar Designer
680 + * Copyright (c) 1996-2000 by Solar Designer
688 -#define ARCH_GENERIC 0
689 #define ARCH_WORD long
692 +#define ARCH_BITS_LOG 6
693 #define ARCH_BITS_STR "64"
694 #define ARCH_LITTLE_ENDIAN 1
695 #define ARCH_INT_GT_32 0
696 #define ARCH_ALLOWS_UNALIGNED 0
697 -#define ARCH_INDEX unsigned long
698 +#define ARCH_INDEX(x) ((unsigned long)(unsigned char)(x))
706 +#define DES_BS_ASM 0
708 +#define DES_BS_VECTOR 0
709 +#define DES_BS_EXPAND 1
716 diff -ruN john-1.6/src/alpha.S john-1.6.34/src/alpha.S
717 --- john-1.6/src/alpha.S 1998-12-03 01:29:50.000000000 +0100
718 +++ john-1.6.34/src/alpha.S 1999-09-22 05:25:30.000000000 +0200
721 * This file is part of John the Ripper password cracker,
722 - * Copyright (c) 1996-98 by Solar Designer
723 + * Copyright (c) 1996-99 by Solar Designer
730 * In reality, bitslice DES turned out to be faster almost everywhere, so
731 - * these routines are now only used for BSDI setkey(), AFS and NT LM hash
733 + * these routines are now only used for BSDI setkey() and AFS by default.
735 * The following things were kept in mind while coding:
737 diff -ruN john-1.6/src/bench.c john-1.6.34/src/bench.c
738 --- john-1.6/src/bench.c 1998-12-03 01:29:50.000000000 +0100
739 +++ john-1.6.34/src/bench.c 2001-07-26 16:55:13.000000000 +0200
742 * This file is part of John the Ripper password cracker,
743 - * Copyright (c) 1996-98 by Solar Designer
744 + * Copyright (c) 1996-2001 by Solar Designer
749 +#define _POSIX_SOURCE
752 +#ifdef _SCO_C_DIALECT
762 -static int bench_running;
763 +static volatile int bench_running;
765 static void bench_handle_timer(int signum)
770 static void bench_set_keys(struct fmt_main *format,
771 - struct fmt_tests **current, int cond)
772 + struct fmt_tests *current, int cond)
777 + format->methods.clear_keys();
779 length = format->params.benchmark_length;
780 for (index = 0; index < format->params.max_keys_per_crypt; index++) {
782 - if (!(*current)->ciphertext)
783 - *current = format->params.tests;
784 - plaintext = (*current)->plaintext;
786 + if (!current->ciphertext)
787 + current = format->params.tests;
788 + plaintext = current->plaintext;
792 if ((int)strlen(plaintext) > length) break;
797 -int benchmark_format(struct fmt_main *format, int salts,
798 +char *benchmark_format(struct fmt_main *format, int salts,
799 struct bench_results *results)
801 + static void *binary = NULL;
802 + static int binary_size = 0;
803 + static char s_error[64];
805 struct fmt_tests *current;
809 unsigned ARCH_WORD count;
811 void *salt, *two_salts[2];
815 - if (!(current = format->params.tests)) return 1;
816 - if (fmt_self_test(format)) return 1;
817 + if (!(current = format->params.tests)) return "FAILED (no data)";
818 + if ((where = fmt_self_test(format))) {
819 + sprintf(s_error, "FAILED (%s)", where);
823 + if (format->params.binary_size > binary_size) {
824 + binary_size = format->params.binary_size;
825 + binary = mem_alloc_tiny(binary_size, MEM_ALIGN_WORD);
826 + memset(binary, 0x55, binary_size);
829 for (index = 0; index < 2; index++) {
830 two_salts[index] = mem_alloc(format->params.salt_size);
835 - bench_set_keys(format, ¤t, cond);
836 + bench_set_keys(format, current, cond);
839 memset(&it, 0, sizeof(it));
840 @@ -111,14 +134,18 @@
844 + max = format->params.max_keys_per_crypt;
848 - bench_set_keys(format, ¤t, cond);
849 + if (!(++current)->ciphertext)
850 + current = format->params.tests;
851 + bench_set_keys(format, current, cond);
854 if (salts > 1) format->methods.set_salt(two_salts[index & 1]);
855 - format->methods.crypt_all(format->params.max_keys_per_crypt);
856 + format->methods.crypt_all(max);
857 + format->methods.cmp_all(binary, max);
862 for (index = 0; index < 2; index++)
863 mem_free(&two_salts[index]);
865 - return event_abort ? -1 : 0;
866 + return event_abort ? "" : NULL;
869 void benchmark_cps(unsigned ARCH_WORD count, clock_t time, char *buffer)
870 @@ -150,13 +177,12 @@
871 sprintf(buffer, cps_hi < 100 ? "%lu.%lu" : "%lu", cps_hi, cps_lo);
874 -void benchmark_all()
875 +void benchmark_all(void)
877 struct fmt_main *format;
878 - char *msg_1, *msg_m;
879 + char *result, *msg_1, *msg_m;
880 struct bench_results results_1, results_m;
881 char s_real[64], s_virtual[64];
884 if ((format = fmt_list))
886 @@ -182,15 +208,16 @@
890 - if ((result = benchmark_format(format, BENCHMARK_MANY,
891 + if ((result = benchmark_format(format,
892 + format->params.salt_size ? BENCHMARK_MANY : 1,
894 - if (result > 0) puts("FAILED"); else putchar('\n');
900 if ((result = benchmark_format(format, 1, &results_1))) {
901 - if (result > 0) puts("FAILED"); else putchar('\n');
906 @@ -198,12 +225,11 @@
908 benchmark_cps(results_m.count, results_m.real, s_real);
909 benchmark_cps(results_m.count, results_m.virtual, s_virtual);
910 - printf("%s:\t%s c/s"
911 -#if !defined(__DJGPP__) && !defined(__CYGWIN32__)
912 - " real, %s c/s virtual\n",
913 +#if !defined(__DJGPP__) && !defined(__CYGWIN32__) && !defined(__BEOS__)
914 + printf("%s:\t%s c/s real, %s c/s virtual\n",
915 msg_m, s_real, s_virtual);
918 + printf("%s:\t%s c/s\n",
922 @@ -214,12 +240,11 @@
924 benchmark_cps(results_1.count, results_1.real, s_real);
925 benchmark_cps(results_1.count, results_1.virtual, s_virtual);
926 - printf("%s:\t%s c/s"
927 -#if !defined(__DJGPP__) && !defined(__CYGWIN32__)
928 - " real, %s c/s virtual\n\n",
929 +#if !defined(__DJGPP__) && !defined(__CYGWIN32__) && !defined(__BEOS__)
930 + printf("%s:\t%s c/s real, %s c/s virtual\n\n",
931 msg_1, s_real, s_virtual);
934 + printf("%s:\t%s c/s\n\n",
937 } while ((format = format->next) && !event_abort);
938 diff -ruN john-1.6/src/bench.h john-1.6.34/src/bench.h
939 --- john-1.6/src/bench.h 1998-12-03 01:29:50.000000000 +0100
940 +++ john-1.6.34/src/bench.h 1999-10-16 15:52:31.000000000 +0200
943 * This file is part of John the Ripper password cracker,
944 - * Copyright (c) 1996-98 by Solar Designer
945 + * Copyright (c) 1996-99 by Solar Designer
953 - * Benchmarks the supplied cracking algorithm. Returns zero on success, a
954 - * positive value if the self test fails or there's no self test for this
955 - * algorithm, or a negative value if aborted.
956 + * Benchmarks the supplied cracking algorithm. Returns NULL on success,
957 + * an error message if the self test fails or there're no test vectors
958 + * for this algorithm, or an empty string if aborted.
960 -extern int benchmark_format(struct fmt_main *format, int salts,
961 +extern char *benchmark_format(struct fmt_main *format, int salts,
962 struct bench_results *results);
966 * Benchmarks all the registered cracking algorithms and prints the results
969 -extern void benchmark_all();
970 +extern void benchmark_all(void);
973 diff -ruN john-1.6/src/best.c john-1.6.34/src/best.c
974 --- john-1.6/src/best.c 1998-12-03 01:29:50.000000000 +0100
975 +++ john-1.6.34/src/best.c 1999-06-08 05:33:20.000000000 +0200
978 * This file is part of John the Ripper password cracker,
979 - * Copyright (c) 1996-98 by Solar Designer
980 + * Copyright (c) 1996-99 by Solar Designer
984 * Benchmark to detect the best algorithm for a particular architecture.
989 +#define _POSIX_SOURCE
992 +#ifdef _SCO_C_DIALECT
998 diff -ruN john-1.6/src/best.sh john-1.6.34/src/best.sh
999 --- john-1.6/src/best.sh 1998-12-03 01:29:50.000000000 +0100
1000 +++ john-1.6.34/src/best.sh 2000-06-25 07:07:28.000000000 +0200
1004 # This file is part of John the Ripper password cracker,
1005 -# Copyright (c) 1996-98 by Solar Designer
1006 +# Copyright (c) 1996-2000 by Solar Designer
1009 [ $# -eq 4 ] || exit 1
1014 -# Detect the best standard DES algorithm
1015 +# Detect the best non-bitslice DES algorithm
1020 for MODE in 1 2 3 4 5; do
1021 - if ./detect $MODE 1 0 0 0 > arch.h; then
1022 + if ./detect $MODE 1 0 0 0 0 > arch.h; then
1023 rm -f $DES_DEPEND bench
1024 echo "Compiling: DES benchmark (code version #$MODE)"
1025 $MAKE bench || exit 1
1030 -./detect $DES_BEST 0 0 0 0 > arch.h
1031 +./detect $DES_BEST 0 0 0 0 0 > arch.h
1032 rm -f $DES_DEPEND bench
1034 echo "Compiling: DES benchmark (code version #$DES_BEST, no key copying)"
1037 # Check if bitslice DES is faster
1039 -./detect $DES_BEST $DES_COPY 1 0 0 > arch.h
1040 +./detect $DES_BEST $DES_COPY 1 0 0 0 > arch.h
1041 rm -f $DES_DEPEND bench
1043 echo "Compiling: DES benchmark (bitslice)"
1046 MAX=`./bench 2` || exit 1
1048 -./detect $DES_BEST $DES_COPY $DES_BS 1 0 > arch.h
1049 +./detect $DES_BEST $DES_COPY $DES_BS 1 0 0 > arch.h
1050 +rm -f $MD5_DEPEND bench
1052 +echo "Compiling: MD5 benchmark (two hashes at a time)"
1053 +$MAKE bench || exit 1
1054 +RES=`./bench 2` || exit 1
1055 +if [ $RES -gt $MAX ]; then
1061 +./detect $DES_BEST $DES_COPY $DES_BS $MD5_X2 1 0 > arch.h
1062 rm -f $MD5_DEPEND bench
1064 echo "Compiling: MD5 benchmark (immediate values)"
1067 MAX=`./bench 3` || exit 1
1069 -./detect $DES_BEST $DES_COPY $DES_BS $MD5_IMM 1 > arch.h
1070 +./detect $DES_BEST $DES_COPY $DES_BS $MD5_X2 $MD5_IMM 1 > arch.h
1071 rm -f $BF_DEPEND bench
1073 echo "Compiling: Blowfish benchmark (scale)"
1075 # Produce generic.h, make sure everything is rebuilt with detected options,
1076 # and do some cleanup
1078 -./detect $DES_BEST $DES_COPY $DES_BS $MD5_IMM $BF_SCALE > generic.h
1079 +./detect $DES_BEST $DES_COPY $DES_BS $MD5_X2 $MD5_IMM $BF_SCALE > generic.h
1080 rm -f $DES_DEPEND $MD5_DEPEND $BF_DEPEND bench detect best.o detect.o arch.h
1081 diff -ruN john-1.6/src/BF_fmt.c john-1.6.34/src/BF_fmt.c
1082 --- john-1.6/src/BF_fmt.c 1998-12-03 01:29:50.000000000 +0100
1083 +++ john-1.6.34/src/BF_fmt.c 2001-06-16 08:08:58.000000000 +0200
1086 * This file is part of John the Ripper password cracker,
1087 - * Copyright (c) 1996-98 by Solar Designer
1088 + * Copyright (c) 1996-2001 by Solar Designer
1094 if (ciphertext[6] != '$') return 0;
1096 - for (pos = &ciphertext[7]; atoi64[(ARCH_INDEX)*pos] != 0x7F; pos++);
1097 + for (pos = &ciphertext[7]; atoi64[ARCH_INDEX(*pos)] != 0x7F; pos++);
1098 if (*pos || pos - ciphertext != CIPHERTEXT_LENGTH) return 0;
1100 + if (BF_atoi64[ARCH_INDEX(*(pos - 1))] & 3) return 0;
1101 + if (BF_atoi64[ARCH_INDEX(ciphertext[28])] & 0xF) return 0;
1107 FMT_CASE | FMT_8_BIT,
1114 (void *(*)(char *))BF_std_get_binary,
1119 + fmt_default_clear_keys,
1123 diff -ruN john-1.6/src/BF_std.c john-1.6.34/src/BF_std.c
1124 --- john-1.6/src/BF_std.c 1998-12-03 01:29:50.000000000 +0100
1125 +++ john-1.6.34/src/BF_std.c 2001-04-29 07:06:12.000000000 +0200
1128 * This file is part of John the Ripper password cracker,
1129 - * Copyright (c) 1996-98 by Solar Designer
1130 + * Copyright (c) 1996-2001 by Solar Designer
1132 + * A public domain version of this code, with reentrant and crypt(3)
1133 + * interfaces added, but optimizations specific to password cracking
1134 + * removed, is available at:
1136 + * http://www.openwall.com/crypt/
1138 * This implementation is compatible with OpenBSD bcrypt.c (version 2a)
1139 * by Niels Provos <provos@physnet.uni-hamburg.de>, and uses some of his
1140 * ideas. The password hashing algorithm was designed by David Mazieres
1141 - * <dm@lcs.mit.edu>. Some of the tricks in BF_ROUND might be inspired by
1142 - * Eric Young's Blowfish library (I can't be sure if I would think of
1143 - * something if I hadn't seen his code) -- SD.
1144 + * <dm@lcs.mit.edu>.
1146 + * There's a paper on the algorithm that explains its design decisions:
1148 + * http://www.usenix.org/events/usenix99/provos.html
1150 + * Some of the tricks in BF_ROUND might be inspired by Eric Young's
1151 + * Blowfish library (I can't be sure if I would think of something if I
1152 + * hadn't seen his code).
1159 +#include "common.h"
1165 - * Magic IV for 64 Blowfish encryptions that we do at the end.
1167 -static char BF_magic_b[24] = "OrpheanBeholderScryDoubt";
1168 -static BF_binary BF_magic_w;
1170 /* Number of Blowfish rounds, this is also hardcoded into a few places */
1178 -#define BF_INDEX(S, i) \
1179 - (*((BF_word *)(((unsigned char *)S) + (i))))
1182 /* Current Blowfish context */
1188 -struct BF_ctx BF_current;
1189 +struct BF_ctx CC_CACHE_ALIGN BF_current;
1191 /* Current Blowfish key */
1192 -static BF_key BF_exp_key, BF_init_key;
1193 +static BF_key CC_CACHE_ALIGN BF_exp_key;
1194 +#if defined(__linux__) && defined(__sparc__)
1195 +static BF_key BF_init_key;
1197 +static BF_key CC_CACHE_ALIGN BF_init_key;
1201 + * Magic IV for 64 Blowfish encryptions that we do at the end.
1202 + * The string is "OrpheanBeholderScryDoubt" on big-endian.
1204 +static BF_word BF_magic_w[6] = {
1205 + 0x4F727068, 0x65616E42, 0x65686F6C,
1206 + 0x64657253, 0x63727944, 0x6F756274
1210 * P-box and S-box tables initialized with digits of Pi.
1211 @@ -325,6 +341,20 @@
1216 + * Same charset, different order -- can't use the common.c table here.
1218 +unsigned char BF_atoi64[0x80] = {
1219 + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
1220 + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
1221 + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 0, 1,
1222 + 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 64, 64, 64, 64, 64,
1223 + 64, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1224 + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 64, 64, 64, 64, 64,
1225 + 64, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
1226 + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 64, 64, 64, 64, 64
1229 #if ARCH_LITTLE_ENDIAN
1231 static void BF_swap(BF_word *x, int count)
1232 @@ -344,12 +374,6 @@
1238 - memcpy(BF_magic_w, BF_magic_b, sizeof(BF_magic_w));
1239 - BF_swap(BF_magic_w, 6);
1243 /* Architectures which can shift addresses left by 2 bits with no extra cost */
1244 #define BF_ROUND(L, R, N) \
1248 /* Architectures with no complicated addressing modes supported */
1249 +#define BF_INDEX(S, i) \
1250 + (*((BF_word *)(((unsigned char *)S) + (i))))
1251 #define BF_ROUND(L, R, N) \
1258 -extern void BF_body();
1259 +extern void (*BF_body)(void);
1267 -void BF_std_crypt_exact()
1268 +void BF_std_crypt_exact(void)
1271 BF_word tmp1, tmp2, tmp3, tmp4;
1272 @@ -580,60 +606,37 @@
1276 - * Standard charset, but non-standard order, so we can't use the table
1277 - * generated in common.c here.
1279 -static unsigned char BF_atoi64[0x80] =
1281 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1282 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1283 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1284 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1285 - 0, 0, 0, 0, 0, 0, 0, 1, 54, 55,
1286 - 56, 57, 58, 59, 60, 61, 62, 63, 0, 0,
1287 - 0, 0, 0, 0, 0, 2, 3, 4, 5, 6,
1288 - 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1289 - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
1290 - 0, 0, 0, 0, 0, 0, 28, 29, 30,
1291 - 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
1292 - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
1293 - 51, 52, 53, 0, 0, 0, 0, 0
1297 * I'm not doing any error checking in the routines below since the
1298 * ciphertext should have already been checked to be fmt_BF.valid().
1301 -static void BF_decode(void *buffer, int length, char *data)
1302 +static void BF_decode(BF_word *dst, char *src, int size)
1304 - unsigned char *dptr = (unsigned char *)buffer;
1305 - unsigned char *end = (unsigned char *)buffer + length;
1306 - char *sptr = data;
1307 - unsigned char c1, c2, c3, c4;
1309 - while (dptr < end) {
1310 - c1 = BF_atoi64[(ARCH_INDEX)*sptr++];
1311 - c2 = BF_atoi64[(ARCH_INDEX)*sptr++];
1312 + unsigned char *dptr = (unsigned char *)dst;
1313 + unsigned char *end = dptr + size;
1314 + unsigned char *sptr = (unsigned char *)src;
1315 + unsigned int c1, c2, c3, c4;
1318 + c1 = BF_atoi64[ARCH_INDEX(*sptr++)];
1319 + c2 = BF_atoi64[ARCH_INDEX(*sptr++)];
1320 *dptr++ = (c1 << 2) | ((c2 & 0x30) >> 4);
1321 if (dptr >= end) break;
1323 - c3 = BF_atoi64[(ARCH_INDEX)*sptr++];
1325 + c3 = BF_atoi64[ARCH_INDEX(*sptr++)];
1326 *dptr++ = ((c2 & 0x0F) << 4) | ((c3 & 0x3C) >> 2);
1327 if (dptr >= end) break;
1329 - c4 = BF_atoi64[(ARCH_INDEX)*sptr++];
1330 + c4 = BF_atoi64[ARCH_INDEX(*sptr++)];
1331 *dptr++ = ((c3 & 0x03) << 6) | c4;
1333 + } while (dptr < end);
1336 BF_word *BF_std_get_salt(char *ciphertext)
1338 static BF_salt salt;
1340 - BF_decode(salt, 16, &ciphertext[7]);
1341 + BF_decode(salt, &ciphertext[7], 16);
1344 salt[4] = (BF_word)1 << atoi(&ciphertext[4]);
1347 static BF_binary binary;
1349 - BF_decode(binary, 23, &ciphertext[29]);
1351 + BF_decode(binary, &ciphertext[29], 23);
1354 binary[5] &= ~(BF_word)0xFF;
1357 diff -ruN john-1.6/src/BF_std.h john-1.6.34/src/BF_std.h
1358 --- john-1.6/src/BF_std.h 1998-12-03 01:29:50.000000000 +0100
1359 +++ john-1.6.34/src/BF_std.h 2001-04-29 06:29:40.000000000 +0200
1362 * This file is part of John the Ripper password cracker,
1363 - * Copyright (c) 1996-98 by Solar Designer
1364 + * Copyright (c) 1996-2001 by Solar Designer
1368 - * Standard OpenBSD Blowfish implementation.
1369 + * OpenBSD-style Blowfish-based password hash implementation.
1372 #ifndef _JOHN_BF_STD_H
1375 extern BF_binary BF_out;
1377 -#define BF_ALGORITHM_NAME "32/" ARCH_BITS_STR
1380 - * Initializes the internal structures.
1381 + * ASCII to binary conversion table, for use in BF_fmt.valid().
1383 -extern void BF_std_init();
1384 +extern unsigned char BF_atoi64[0x80];
1386 +#define BF_ALGORITHM_NAME "32/" ARCH_BITS_STR
1389 * Sets a key for BF_std_crypt().
1392 * Calculates the rest of BF_out, for exact comparison.
1394 -extern void BF_std_crypt_exact();
1395 +extern void BF_std_crypt_exact(void);
1398 * Returns the salt for BF_std_crypt().
1399 diff -ruN john-1.6/src/BSDI_fmt.c john-1.6.34/src/BSDI_fmt.c
1400 --- john-1.6/src/BSDI_fmt.c 1998-12-03 01:29:50.000000000 +0100
1401 +++ john-1.6.34/src/BSDI_fmt.c 2001-06-16 09:32:21.000000000 +0200
1404 * This file is part of John the Ripper password cracker,
1405 - * Copyright (c) 1996-98 by Solar Designer
1406 + * Copyright (c) 1996-2001 by Solar Designer
1411 {"_J9..SDizh.vll5VED9g", "ab1234567"},
1412 {"_J9..SDizRjWQ/zePPHc", "cr1234567"},
1413 {"_J9..SDizxmRI1GjnQuE", "zxyDPWgydbQjgq"},
1414 + {"_K9..SaltNrQgIYUAeoY", "726 even"},
1415 {"_J9..SDSD5YGyRCr4W4c", ""},
1421 -#include "memory.h"
1424 #define ALGORITHM_NAME DES_BS_ALGORITHM_NAME
1426 -#define BINARY_BITS 16
1428 -#define BINARY_SIZE (BINARY_BITS * ARCH_SIZE)
1429 +#define BINARY_SIZE ARCH_SIZE
1430 #define SALT_SIZE (ARCH_SIZE * 2)
1432 -#define MIN_KEYS_PER_CRYPT ARCH_BITS
1433 -#define MAX_KEYS_PER_CRYPT ARCH_BITS
1434 +#define MIN_KEYS_PER_CRYPT DES_BS_DEPTH
1435 +#define MAX_KEYS_PER_CRYPT DES_BS_DEPTH
1444 +static int saved_count;
1455 char key[PLAINTEXT_LENGTH];
1456 } buffer[MAX_KEYS_PER_CRYPT];
1460 -struct fmt_main fmt_BSDI;
1461 -static int binary_bits = BINARY_BITS;
1462 -static int keys_changed;
1467 +static void init(void)
1472 - if (mem_saving_level > 1) {
1473 - DES_bs_mem_saving = 1;
1475 - fmt_BSDI.params.binary_size = ARCH_SIZE;
1481 DES_std_set_salt(0);
1483 @@ -118,9 +100,11 @@
1484 for (pos = &ciphertext[1]; pos < &ciphertext[9]; pos++)
1485 if (!*pos) return 0;
1487 - for (pos = &ciphertext[9]; atoi64[(ARCH_INDEX)*pos] != 0x7F; pos++);
1488 + for (pos = &ciphertext[9]; atoi64[ARCH_INDEX(*pos)] != 0x7F; pos++);
1489 if (*pos || pos - ciphertext != CIPHERTEXT_LENGTH) return 0;
1491 + if (atoi64[ARCH_INDEX(*(pos - 1))] & 3) return 0;
1496 @@ -142,17 +126,17 @@
1498 static int binary_hash_0(void *binary)
1500 - return DES_bs_binary_hash((ARCH_WORD *)binary, 4);
1501 + return *(ARCH_WORD *)binary & 0xF;
1504 static int binary_hash_1(void *binary)
1506 - return DES_bs_binary_hash((ARCH_WORD *)binary, 8);
1507 + return *(ARCH_WORD *)binary & 0xFF;
1510 static int binary_hash_2(void *binary)
1512 - return DES_bs_binary_hash((ARCH_WORD *)binary, 12);
1513 + return *(ARCH_WORD *)binary & 0xFFF;
1516 static int get_hash_0(int index)
1521 - strnfcpy(buffer[index].final, final, 8);
1523 + DES_bs_set_key(final, index);
1525 memcpy(buffer[index].aligned.data.KS, DES_KS_current, sizeof(DES_KS));
1527 @@ -302,26 +285,18 @@
1529 static void crypt_all(int count)
1533 - if (keys_changed) {
1534 - DES_bs_clear_keys();
1535 - for (index = 0; index < count; index++)
1536 - DES_bs_set_key(buffer[index].final, index);
1540 + DES_bs_expand_keys();
1541 DES_bs_crypt(saved_count);
1544 static int cmp_all(void *binary, int count)
1546 - return DES_bs_cmp_all((ARCH_WORD *)binary, binary_bits);
1547 + return DES_bs_cmp_all((ARCH_WORD *)binary);
1550 static int cmp_one(void *binary, int index)
1552 - return DES_bs_cmp_one((ARCH_WORD *)binary, binary_bits, index);
1553 + return DES_bs_cmp_one((ARCH_WORD *)binary, 32, index);
1556 static int cmp_exact(char *source, int index)
1557 @@ -393,7 +368,11 @@
1562 + FMT_CASE | FMT_BS,
1569 @@ -415,6 +394,11 @@
1574 + DES_bs_clear_keys,
1576 + fmt_default_clear_keys,
1581 diff -ruN john-1.6/src/charset.c john-1.6.34/src/charset.c
1582 --- john-1.6/src/charset.c 1998-12-03 01:29:50.000000000 +0100
1583 +++ john-1.6.34/src/charset.c 1999-04-14 12:50:36.000000000 +0200
1586 * This file is part of John the Ripper password cracker,
1587 - * Copyright (c) 1996-98 by Solar Designer
1588 + * Copyright (c) 1996-99 by Solar Designer
1593 current = plaintexts;
1595 for (ptr = (unsigned char *)current->data; *ptr; ptr++)
1596 - (*chars)[0][0][(ARCH_INDEX)(*ptr - CHARSET_MIN)]++;
1597 + (*chars)[0][0][ARCH_INDEX(*ptr - CHARSET_MIN)]++;
1598 } while ((current = current->next));
1601 @@ -159,15 +159,15 @@
1605 - [(ARCH_INDEX)(ptr[pos] - CHARSET_MIN)]++;
1606 + [ARCH_INDEX(ptr[pos] - CHARSET_MIN)]++;
1609 - [(ARCH_INDEX)(ptr[pos - 1] - CHARSET_MIN)]
1610 - [(ARCH_INDEX)(ptr[pos] - CHARSET_MIN)]++;
1611 + [ARCH_INDEX(ptr[pos - 1] - CHARSET_MIN)]
1612 + [ARCH_INDEX(ptr[pos] - CHARSET_MIN)]++;
1613 if (pos > 1) (*chars)
1614 - [(ARCH_INDEX)(ptr[pos - 2] - CHARSET_MIN)]
1615 - [(ARCH_INDEX)(ptr[pos - 1] - CHARSET_MIN)]
1616 - [(ARCH_INDEX)(ptr[pos] - CHARSET_MIN)]++;
1617 + [ARCH_INDEX(ptr[pos - 2] - CHARSET_MIN)]
1618 + [ARCH_INDEX(ptr[pos - 1] - CHARSET_MIN)]
1619 + [ARCH_INDEX(ptr[pos] - CHARSET_MIN)]++;
1620 } while ((current = current->next));
1622 for (i = (pos > 1 ? 0 : CHARSET_SIZE); i <= CHARSET_SIZE; i++)
1623 diff -ruN john-1.6/src/charset.h john-1.6.34/src/charset.h
1624 --- john-1.6/src/charset.h 1998-12-03 01:29:50.000000000 +0100
1625 +++ john-1.6.34/src/charset.h 2001-02-16 06:52:01.000000000 +0100
1628 * This file is part of John the Ripper password cracker,
1629 - * Copyright (c) 1996-98 by Solar Designer
1630 + * Copyright (c) 1996-2001 by Solar Designer
1635 #define _JOHN_CHARSET_H
1638 +#include "common.h"
1644 struct charset_header {
1645 /* CHARSET_VERSION */
1647 + char version[4] CC_PACKED;
1649 /* CHARSET_MIN, CHARSET_MAX */
1650 - unsigned char min, max;
1651 + unsigned char min, max CC_PACKED;
1653 /* CHARSET_LENGTH */
1654 - unsigned char length;
1655 + unsigned char length CC_PACKED;
1657 /* Number of different characters, up to (max - min + 1) */
1658 - unsigned char count;
1659 + unsigned char count CC_PACKED;
1661 -/* File offsets for each length, 32 bit little endian */
1662 - unsigned char offsets[CHARSET_LENGTH][4];
1663 +/* File offsets for each length, 32-bit little endian */
1664 + unsigned char offsets[CHARSET_LENGTH][4] CC_PACKED;
1669 * up to CHARSET_SIZE characters large.
1672 - [CHARSET_LENGTH * (CHARSET_LENGTH + 1) / 2 * CHARSET_SIZE * 3];
1674 -#if ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)) || (__GNUC__ > 2)
1675 - __attribute__ ((packed));
1679 + [CHARSET_LENGTH * (CHARSET_LENGTH + 1) / 2 * CHARSET_SIZE * 3]
1684 * Reads a charset file header.
1685 diff -ruN john-1.6/src/common.c john-1.6.34/src/common.c
1686 --- john-1.6/src/common.c 1998-12-03 01:29:50.000000000 +0100
1687 +++ john-1.6.34/src/common.c 1999-09-22 05:48:17.000000000 +0200
1690 * This file is part of John the Ripper password cracker,
1691 - * Copyright (c) 1996-98 by Solar Designer
1692 + * Copyright (c) 1996-99 by Solar Designer
1698 static int initialized = 0;
1701 +void common_init(void)
1707 memset(atoi64, 0x7F, sizeof(atoi64));
1708 for (pos = itoa64; pos <= &itoa64[63]; pos++)
1709 - atoi64[(ARCH_INDEX)*pos] = pos - itoa64;
1710 + atoi64[ARCH_INDEX(*pos)] = pos - itoa64;
1712 memset(atoi16, 0x7F, sizeof(atoi16));
1713 for (pos = itoa16; pos <= &itoa16[15]; pos++)
1714 - atoi16[(ARCH_INDEX)*pos] = pos - itoa16;
1715 + atoi16[ARCH_INDEX(*pos)] = pos - itoa16;
1717 atoi16['A'] = atoi16['a'];
1718 atoi16['B'] = atoi16['b'];
1719 diff -ruN john-1.6/src/common.h john-1.6.34/src/common.h
1720 --- john-1.6/src/common.h 1998-12-03 01:29:50.000000000 +0100
1721 +++ john-1.6.34/src/common.h 1999-09-22 05:39:10.000000000 +0200
1724 * This file is part of John the Ripper password cracker,
1725 - * Copyright (c) 1996-98 by Solar Designer
1726 + * Copyright (c) 1996-99 by Solar Designer
1731 #define _JOHN_COMMON_H
1734 +#include "memory.h"
1737 typedef unsigned short ARCH_WORD_32;
1739 typedef unsigned int ARCH_WORD_32;
1742 +#if ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)) || (__GNUC__ > 2)
1743 +#define CC_CACHE_ALIGN \
1744 + __attribute__ ((aligned (MEM_ALIGN_CACHE)))
1746 +#define CC_CACHE_ALIGN /* nothing */
1749 +#if ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)) || (__GNUC__ > 2)
1750 +#define CC_PACKED __attribute__ ((packed))
1752 +#define CC_PACKED /* nothing */
1756 * ASCII <-> binary conversion tables.
1760 * Initializes the tables.
1762 -extern void common_init();
1763 +extern void common_init(void);
1766 diff -ruN john-1.6/src/compiler.c john-1.6.34/src/compiler.c
1767 --- john-1.6/src/compiler.c 1998-12-03 01:29:50.000000000 +0100
1768 +++ john-1.6.34/src/compiler.c 2000-08-26 05:50:54.000000000 +0200
1771 * This file is part of John the Ripper password cracker,
1772 - * Copyright (c) 1996-98 by Solar Designer
1773 + * Copyright (c) 1996-2000 by Solar Designer
1777 +#include <stdlib.h>
1785 "Expression is too complex",
1786 "Invalid array size",
1787 "Data section is too large",
1788 + "Integer constant out of range",
1789 "Duplicate identifier",
1790 "Keyword is used as an identifier",
1791 "Not in a function",
1803 static char c_isident[0x100];
1804 #define c_isstart(c) \
1805 - (c_isident[(ARCH_INDEX)(c)] && ((c) < '0' || (c) > '9'))
1806 + (c_isident[ARCH_INDEX(c)] && ((c) < '0' || (c) > '9'))
1810 -static int (*c_ext_getchar)();
1811 -static void (*c_ext_rewind)();
1812 +static int (*c_ext_getchar)(void);
1813 +static void (*c_ext_rewind)(void);
1815 static char *c_reserved[] = {
1827 static struct c_op c_ops[38];
1830 -static void c_init()
1831 +static void c_init(void)
1836 c_unget_buffer[c_unget_count++] = c;
1839 -static char c_buffer_getchar()
1840 +static char c_buffer_getchar(void)
1844 @@ -195,12 +198,12 @@
1848 -static char *c_gettoken()
1849 +static char *c_gettoken(void)
1851 static char token[C_TOKEN_SIZE];
1854 - while (c_isident[(ARCH_INDEX)(token[pos++] = c_getchar(0))])
1855 + while (c_isident[ARCH_INDEX(token[pos++] = c_getchar(0))])
1856 if (pos >= C_TOKEN_SIZE) {
1857 c_errno = C_ERROR_TOOLONG;
1860 static int c_getint(char *token)
1867 if (token[0] == '\'') {
1868 if ((value = c_getchar(1)) == '\'')
1869 @@ -224,20 +228,20 @@
1870 if (value == '\\') value = c_getchar(1);
1871 if (c_getchar(1) != '\'') c_errno = C_ERROR_UNEXPECTED;
1873 - if (token[0] != '0') format = "%d"; else
1874 - if (token[1] != 'x') format = "%o"; else {
1879 - if (sscanf((char *)token, format, &value) != 1)
1881 + l_value = strtol(token, &error, 0);
1882 + value = (int)l_value;
1883 + if (errno == ERANGE || (long)value != l_value)
1884 + c_errno = C_ERROR_RANGE;
1886 + if (!*token || *error || errno)
1887 c_errno = C_ERROR_UNEXPECTED;
1893 -static char c_skip_space()
1894 +static char c_skip_space(void)
1898 @@ -337,19 +341,20 @@
1902 -static void (*c_op_return)();
1903 -static void (*c_op_bz)();
1904 -static void (*c_op_ba)();
1905 -static void (*c_op_push_imm)();
1906 -static void (*c_op_push_mem)();
1907 -static void (*c_op_pop)();
1909 -static void (*c_op_push_imm_imm)();
1910 -static void (*c_op_push_imm_mem)();
1911 -static void (*c_op_push_mem_imm)();
1912 -static void (*c_op_push_mem_mem)();
1913 +static void (*c_op_return)(void);
1914 +static void (*c_op_bz)(void);
1915 +static void (*c_op_ba)(void);
1916 +static void (*c_op_push_imm)(void);
1917 +static void (*c_op_push_mem)(void);
1918 +static void (*c_op_pop)(void);
1920 +static void (*c_op_push_imm_imm)(void);
1921 +static void (*c_op_push_imm_mem)(void);
1922 +static void (*c_op_push_mem_imm)(void);
1923 +static void (*c_op_push_mem_mem)(void);
1925 -static void (*c_push(void (*last)(), void (*op)(), union c_insn *value))()
1926 +static void (*c_push
1927 + (void (*last)(void), void (*op)(void), union c_insn *value))(void)
1929 if (last == c_op_push_imm || last == c_op_push_mem) {
1930 if (last == c_op_push_imm) {
1935 - void (*last)() = (void (*)())0;
1936 + void (*last)(void) = (void (*)(void))0;
1938 if (term == ')') stack[sp++] = -1;
1944 - if (c_isident[(ARCH_INDEX)c])
1945 + if (c_isident[ARCH_INDEX(c)])
1946 var = c_find_ident(vars, NULL, token);
1952 if ((op = c_find_op(token, left)) < 0) {
1953 - if (c_isident[(ARCH_INDEX)c])
1954 + if (c_isident[ARCH_INDEX(c)])
1955 c_errno = C_ERROR_UNKNOWN;
1957 c_errno = C_ERROR_UNEXPECTED;
1962 -static int c_continue()
1963 +static int c_continue(void)
1965 if (!c_loop_start) return c_errno = C_ERROR_NOTINLOOP;
1971 -static int c_break(char term, struct c_ident *vars)
1972 +static int c_break(void)
1974 struct c_fixup *fixup;
1979 if (!strcmp(token, "break")) {
1980 - if (c_break(term, locals)) break;
1981 + if (c_break()) break;
1984 if (!strcmp(token, "return")) {
1986 static void c_direct(union c_insn *addr);
1989 -int c_compile(int (*ext_getchar)(), void (*ext_rewind)(),
1990 +int c_compile(int (*ext_getchar)(void), void (*ext_rewind)(void),
1991 struct c_ident *externs)
1995 void c_execute(struct c_ident *fn)
1998 - register void (*op)();
1999 + register void (*op)(void);
2003 @@ -1127,12 +1132,12 @@
2007 -static void c_f_op_return()
2008 +static void c_f_op_return(void)
2010 c_pc = (c_sp -= 2)->pc;
2013 -static void c_f_op_bz()
2014 +static void c_f_op_bz(void)
2016 if ((c_sp -= 2)->imm)
2018 @@ -1140,36 +1145,36 @@
2022 -static void c_f_op_ba()
2023 +static void c_f_op_ba(void)
2028 -static void c_f_op_push_imm()
2029 +static void c_f_op_push_imm(void)
2031 c_sp->imm = (c_pc++)->imm;
2035 -static void c_f_op_push_mem()
2036 +static void c_f_op_push_mem(void)
2038 (c_sp++)->imm = *c_pc->mem;
2039 (c_sp++)->mem = (c_pc++)->mem;
2042 -static void c_f_op_pop()
2043 +static void c_f_op_pop(void)
2048 -static void c_f_op_push_imm_imm()
2049 +static void c_f_op_push_imm_imm(void)
2051 c_sp->imm = (c_pc++)->imm;
2052 (c_sp + 2)->imm = (c_pc++)->imm;
2056 -static void c_f_op_push_imm_mem()
2057 +static void c_f_op_push_imm_mem(void)
2059 c_sp->imm = (c_pc++)->imm;
2060 (c_sp + 2)->imm = *c_pc->mem;
2061 @@ -1177,7 +1182,7 @@
2065 -static void c_f_op_push_mem_imm()
2066 +static void c_f_op_push_mem_imm(void)
2068 c_sp->imm = *c_pc->mem;
2069 (c_sp + 1)->mem = (c_pc++)->mem;
2070 @@ -1185,7 +1190,7 @@
2074 -static void c_f_op_push_mem_mem()
2075 +static void c_f_op_push_mem_mem(void)
2077 c_sp->imm = *c_pc->mem;
2078 (c_sp + 1)->mem = (c_pc++)->mem;
2079 @@ -1194,220 +1199,220 @@
2083 -static void c_op_index()
2084 +static void c_op_index(void)
2087 (c_sp - 2)->imm = *((c_sp - 1)->mem += c_sp->imm);
2090 -static void c_op_assign()
2091 +static void c_op_assign(void)
2094 (c_sp - 2)->imm = *(c_sp - 1)->mem = c_sp->imm;
2097 -static void c_op_add_a()
2098 +static void c_op_add_a(void)
2101 (c_sp - 2)->imm = *(c_sp - 1)->mem += c_sp->imm;
2104 -static void c_op_sub_a()
2105 +static void c_op_sub_a(void)
2108 (c_sp - 2)->imm = *(c_sp - 1)->mem -= c_sp->imm;
2111 -static void c_op_mul_a()
2112 +static void c_op_mul_a(void)
2115 (c_sp - 2)->imm = *(c_sp - 1)->mem *= c_sp->imm;
2118 -static void c_op_div_a()
2119 +static void c_op_div_a(void)
2122 (c_sp - 2)->imm = *(c_sp - 1)->mem /= c_sp->imm;
2125 -static void c_op_mod_a()
2126 +static void c_op_mod_a(void)
2129 (c_sp - 2)->imm = *(c_sp - 1)->mem %= c_sp->imm;
2132 -static void c_op_or_a()
2133 +static void c_op_or_a(void)
2136 (c_sp - 2)->imm = *(c_sp - 1)->mem |= c_sp->imm;
2139 -static void c_op_xor_a()
2140 +static void c_op_xor_a(void)
2143 (c_sp - 2)->imm = *(c_sp - 1)->mem ^= c_sp->imm;
2146 -static void c_op_and_a()
2147 +static void c_op_and_a(void)
2150 (c_sp - 2)->imm = *(c_sp - 1)->mem &= c_sp->imm;
2153 -static void c_op_shl_a()
2154 +static void c_op_shl_a(void)
2157 (c_sp - 2)->imm = *(c_sp - 1)->mem <<= c_sp->imm;
2160 -static void c_op_shr_a()
2161 +static void c_op_shr_a(void)
2164 (c_sp - 2)->imm = *(c_sp - 1)->mem >>= c_sp->imm;
2167 -static void c_op_or_i()
2168 +static void c_op_or_i(void)
2171 (c_sp - 2)->imm |= c_sp->imm;
2174 -static void c_op_and_b()
2175 +static void c_op_and_b(void)
2178 (c_sp - 2)->imm = (c_sp - 2)->imm && c_sp->imm;
2181 -static void c_op_not_b()
2182 +static void c_op_not_b(void)
2184 (c_sp - 2)->imm = !(c_sp - 2)->imm;
2187 -static void c_op_eq()
2188 +static void c_op_eq(void)
2191 (c_sp - 2)->imm = (c_sp - 2)->imm == c_sp->imm;
2194 -static void c_op_gt()
2195 +static void c_op_gt(void)
2198 (c_sp - 2)->imm = (c_sp - 2)->imm > c_sp->imm;
2201 -static void c_op_lt()
2202 +static void c_op_lt(void)
2205 (c_sp - 2)->imm = (c_sp - 2)->imm < c_sp->imm;
2208 -static void c_op_ge()
2209 +static void c_op_ge(void)
2212 (c_sp - 2)->imm = (c_sp - 2)->imm >= c_sp->imm;
2215 -static void c_op_le()
2216 +static void c_op_le(void)
2219 (c_sp - 2)->imm = (c_sp - 2)->imm <= c_sp->imm;
2222 -static void c_op_xor_i()
2223 +static void c_op_xor_i(void)
2226 (c_sp - 2)->imm ^= c_sp->imm;
2229 -static void c_op_and_i()
2230 +static void c_op_and_i(void)
2233 (c_sp - 2)->imm &= c_sp->imm;
2236 -static void c_op_shl()
2237 +static void c_op_shl(void)
2240 (c_sp - 2)->imm <<= c_sp->imm;
2243 -static void c_op_shr()
2244 +static void c_op_shr(void)
2247 (c_sp - 2)->imm >>= c_sp->imm;
2250 -static void c_op_add()
2251 +static void c_op_add(void)
2254 (c_sp - 2)->imm += c_sp->imm;
2257 -static void c_op_sub()
2258 +static void c_op_sub(void)
2261 (c_sp - 2)->imm -= c_sp->imm;
2264 -static void c_op_mul()
2265 +static void c_op_mul(void)
2268 (c_sp - 2)->imm *= c_sp->imm;
2271 -static void c_op_div()
2272 +static void c_op_div(void)
2275 (c_sp - 2)->imm /= c_sp->imm;
2278 -static void c_op_mod()
2279 +static void c_op_mod(void)
2282 (c_sp - 2)->imm %= c_sp->imm;
2285 -static void c_op_not_i()
2286 +static void c_op_not_i(void)
2288 (c_sp - 2)->imm = ~(c_sp - 2)->imm;
2291 -static void c_op_neg()
2292 +static void c_op_neg(void)
2294 (c_sp - 2)->imm = -(c_sp - 2)->imm;
2297 -static void c_op_inc_l()
2298 +static void c_op_inc_l(void)
2300 *(c_sp - 1)->mem = ++(c_sp - 2)->imm;
2303 -static void c_op_dec_l()
2304 +static void c_op_dec_l(void)
2306 *(c_sp - 1)->mem = --(c_sp - 2)->imm;
2309 -static void c_op_inc_r()
2310 +static void c_op_inc_r(void)
2312 *(c_sp - 1)->mem = (c_sp - 2)->imm + 1;
2315 -static void c_op_dec_r()
2316 +static void c_op_dec_r(void)
2318 *(c_sp - 1)->mem = (c_sp - 2)->imm - 1;
2321 -static void (*c_op_return)() = c_f_op_return;
2322 -static void (*c_op_bz)() = c_f_op_bz;
2323 -static void (*c_op_ba)() = c_f_op_ba;
2324 -static void (*c_op_push_imm)() = c_f_op_push_imm;
2325 -static void (*c_op_push_mem)() = c_f_op_push_mem;
2326 -static void (*c_op_pop)() = c_f_op_pop;
2328 -static void (*c_op_push_imm_imm)() = c_f_op_push_imm_imm;
2329 -static void (*c_op_push_imm_mem)() = c_f_op_push_imm_mem;
2330 -static void (*c_op_push_mem_imm)() = c_f_op_push_mem_imm;
2331 -static void (*c_op_push_mem_mem)() = c_f_op_push_mem_mem;
2332 +static void (*c_op_return)(void) = c_f_op_return;
2333 +static void (*c_op_bz)(void) = c_f_op_bz;
2334 +static void (*c_op_ba)(void) = c_f_op_ba;
2335 +static void (*c_op_push_imm)(void) = c_f_op_push_imm;
2336 +static void (*c_op_push_mem)(void) = c_f_op_push_mem;
2337 +static void (*c_op_pop)(void) = c_f_op_pop;
2339 +static void (*c_op_push_imm_imm)(void) = c_f_op_push_imm_imm;
2340 +static void (*c_op_push_imm_mem)(void) = c_f_op_push_imm_mem;
2341 +static void (*c_op_push_mem_imm)(void) = c_f_op_push_mem_imm;
2342 +static void (*c_op_push_mem_mem)(void) = c_f_op_push_mem_mem;
2344 static struct c_op c_ops[] = {
2345 {1, C_LEFT_TO_RIGHT, C_CLASS_BINARY, "[", c_op_index},
2346 diff -ruN john-1.6/src/compiler.h john-1.6.34/src/compiler.h
2347 --- john-1.6/src/compiler.h 1998-12-03 01:29:50.000000000 +0100
2348 +++ john-1.6.34/src/compiler.h 2000-08-26 05:25:23.000000000 +0200
2351 * This file is part of John the Ripper password cracker,
2352 - * Copyright (c) 1996-98 by Solar Designer
2353 + * Copyright (c) 1996-2000 by Solar Designer
2358 #define C_ERROR_TOOCOMPLEX 5
2359 #define C_ERROR_ARRAYSIZE 6
2360 #define C_ERROR_DATASIZE 7
2361 -#define C_ERROR_DUPE 8
2362 -#define C_ERROR_RESERVED 9
2363 -#define C_ERROR_NOTINFUNC 10
2364 -#define C_ERROR_NESTEDFUNC 11
2365 -#define C_ERROR_NOTINIF 12
2366 -#define C_ERROR_NOTINLOOP 13
2367 -#define C_ERROR_EOF 14
2368 -#define C_ERROR_INTERNAL 15
2369 +#define C_ERROR_RANGE 8
2370 +#define C_ERROR_DUPE 9
2371 +#define C_ERROR_RESERVED 10
2372 +#define C_ERROR_NOTINFUNC 11
2373 +#define C_ERROR_NESTEDFUNC 12
2374 +#define C_ERROR_NOTINIF 13
2375 +#define C_ERROR_NOTINLOOP 14
2376 +#define C_ERROR_EOF 15
2377 +#define C_ERROR_INTERNAL 16
2382 * Runs the compiler, and allocates some memory for its output and the
2383 * program's data. Returns one of the error codes.
2385 -extern int c_compile(int (*ext_getchar)(), void (*ext_rewind)(),
2386 +extern int c_compile(int (*ext_getchar)(void), void (*ext_rewind)(void),
2387 struct c_ident *externs);
2390 diff -ruN john-1.6/src/config.c john-1.6.34/src/config.c
2391 --- john-1.6/src/config.c 1998-12-03 01:29:50.000000000 +0100
2392 +++ john-1.6.34/src/config.c 2002-10-03 06:15:39.000000000 +0200
2395 * This file is part of John the Ripper password cracker,
2396 - * Copyright (c) 1996-98 by Solar Designer
2397 + * Copyright (c) 1996-2002 by Solar Designer
2412 +char *cfg_name = NULL;
2413 static struct cfg_section *cfg_database = NULL;
2415 static char *trim(char *s)
2420 -void cfg_init(char *name)
2421 +void cfg_init(char *name, int allow_missing)
2424 char line[LINE_BUFFER_SIZE];
2425 @@ -120,8 +122,10 @@
2427 if (cfg_database) return;
2429 - if (!(file = fopen(path_expand(name), "r")))
2430 + if (!(file = fopen(path_expand(name), "r"))) {
2431 + if (allow_missing && errno == ENOENT) return;
2432 pexit("fopen: %s", path_expand(name));
2436 while (fgetl(line, sizeof(line), file))
2438 if (ferror(file)) pexit("fgets");
2440 if (fclose(file)) pexit("fclose");
2442 + cfg_name = str_alloc_copy(path_expand(name));
2445 static struct cfg_section *cfg_get_section(char *section, char *subsection)
2446 @@ -191,10 +197,15 @@
2448 int cfg_get_int(char *section, char *subsection, char *param)
2451 + char *s_value, *error;
2454 - if ((value = cfg_get_param(section, subsection, param)))
2455 - return atoi(value);
2456 + if ((s_value = cfg_get_param(section, subsection, param))) {
2457 + l_value = strtol(s_value, &error, 10);
2458 + if (!*s_value || *error || (l_value & ~0x3FFFFFFFL))
2460 + return (int)l_value;
2465 @@ -209,10 +220,8 @@
2473 - return atoi(value);
2477 diff -ruN john-1.6/src/config.h john-1.6.34/src/config.h
2478 --- john-1.6/src/config.h 1998-12-03 01:29:50.000000000 +0100
2479 +++ john-1.6.34/src/config.h 2000-03-15 00:23:25.000000000 +0100
2482 * This file is part of John the Ripper password cracker,
2483 - * Copyright (c) 1996-98 by Solar Designer
2484 + * Copyright (c) 1996-2000 by Solar Designer
2492 - * Loads a configuration file.
2493 + * Name of the currently loaded configuration file, or NULL for none.
2495 -extern void cfg_init(char *name);
2496 +extern char *cfg_name;
2499 + * Loads a configuration file, or does nothing if one is already loaded.
2501 +extern void cfg_init(char *name, int allow_missing);
2504 * Searches for a section with the supplied name, and returns its line list
2505 diff -ruN john-1.6/src/cracker.c john-1.6.34/src/cracker.c
2506 --- john-1.6/src/cracker.c 1998-12-03 01:29:50.000000000 +0100
2507 +++ john-1.6.34/src/cracker.c 2002-09-05 07:56:20.000000000 +0200
2510 * This file is part of John the Ripper password cracker,
2511 - * Copyright (c) 1996-98 by Solar Designer
2512 + * Copyright (c) 1996-2002 by Solar Designer
2517 static struct fmt_methods crk_methods;
2518 static int crk_key_index, crk_last_key;
2519 static void *crk_last_salt;
2520 -static void (*crk_fix_state)();
2521 +static void (*crk_fix_state)(void);
2522 static struct db_keys *crk_guesses;
2523 static int64 *crk_timestamps;
2524 static char crk_stdout_key[PLAINTEXT_BUFFER_SIZE];
2529 -static void crk_dummy_fix_state()
2530 +static void crk_dummy_fix_state(void)
2534 -static void crk_init_salt()
2535 +static void crk_init_salt(void)
2537 if (!crk_db->salts->next) {
2538 crk_methods.set_salt(crk_db->salts->salt);
2543 -void crk_init(struct db_main *db, void (*fix_state)(),
2544 +void crk_init(struct db_main *db, void (*fix_state)(void),
2545 struct db_keys *guesses)
2551 - if (fmt_self_test(db->format)) {
2552 - fprintf(stderr, "Self test failed\n");
2553 + if ((where = fmt_self_test(db->format))) {
2554 + fprintf(stderr, "Self test failed (%s)\n", where);
2559 crk_db->guess_count++;
2560 status.guess_count++;
2562 - if (crk_guesses) {
2563 + if (crk_guesses && !dupe) {
2564 strnfcpy(crk_guesses->ptr, key, crk_params.plaintext_length);
2565 crk_guesses->ptr += crk_params.plaintext_length;
2566 crk_guesses->count++;
2571 -static int crk_process_event()
2572 +static int crk_process_event(void)
2576 @@ -168,11 +169,11 @@
2577 sig_timer_emu_tick();
2583 if (crk_process_event()) return 1;
2587 crk_methods.crypt_all(crk_key_index);
2589 status_update_crypts(salt->count * crk_key_index);
2594 -static int crk_salt_loop()
2595 +static int crk_salt_loop(void)
2597 struct db_salt *salt;
2600 crk_last_salt = NULL;
2603 + crk_methods.clear_keys();
2609 count = salt->keys->count;
2612 + crk_methods.clear_keys();
2615 strnzcpy(key, ptr, crk_params.plaintext_length + 1);
2616 ptr += crk_params.plaintext_length;
2621 -char *crk_get_key1()
2622 +char *crk_get_key1(void)
2625 return crk_methods.get_key(0);
2627 return crk_stdout_key;
2630 -char *crk_get_key2()
2631 +char *crk_get_key2(void)
2633 if (crk_key_index > 1)
2634 return crk_methods.get_key(crk_key_index - 1);
2640 +void crk_done(void)
2642 if (crk_db->loaded) {
2643 if (crk_key_index && crk_db->salts && !event_abort)
2644 diff -ruN john-1.6/src/cracker.h john-1.6.34/src/cracker.h
2645 --- john-1.6/src/cracker.h 1998-12-03 01:29:50.000000000 +0100
2646 +++ john-1.6.34/src/cracker.h 1999-09-22 05:40:07.000000000 +0200
2649 * This file is part of John the Ripper password cracker,
2650 - * Copyright (c) 1996-98 by Solar Designer
2651 + * Copyright (c) 1996-99 by Solar Designer
2656 * the future. If guesses is not NULL, the cracker will save guessed keys
2657 * in there (the caller must make sure there's room).
2659 -extern void crk_init(struct db_main *db, void (*fix_state)(),
2660 +extern void crk_init(struct db_main *db, void (*fix_state)(void),
2661 struct db_keys *guesses);
2665 * Return current keys range, crk_get_key2() may return NULL if there's only
2666 * one key. Note: these functions may share a static result buffer.
2668 -extern char *crk_get_key1();
2669 -extern char *crk_get_key2();
2670 +extern char *crk_get_key1(void);
2671 +extern char *crk_get_key2(void);
2674 * Processes all the buffered keys (unless aborted).
2676 -extern void crk_done();
2677 +extern void crk_done(void);
2680 diff -ruN john-1.6/src/DES_bs_b.c john-1.6.34/src/DES_bs_b.c
2681 --- john-1.6/src/DES_bs_b.c 1998-12-03 01:29:50.000000000 +0100
2682 +++ john-1.6.34/src/DES_bs_b.c 2001-06-16 08:57:44.000000000 +0200
2685 * This file is part of John the Ripper password cracker,
2686 - * Copyright (c) 1996-98 by Solar Designer
2690 - * Bitslice DES encryption.
2691 + * Copyright (c) 1996-2001 by Solar bdesigner
2699 /* Include the S-boxes here, so that the compiler can inline them */
2700 #include "DES_bs_s.c"
2702 #define b DES_bs_all.B
2703 -#define e DES_bs_all.E
2704 +#define e DES_bs_all.E.E
2710 +#define for_each_depth() \
2711 + for (depth = 0; depth < DES_BS_VECTOR; depth++)
2720 +#define for_each_depth()
2724 +#define DES_bs_clear_block_8(i) \
2725 + for_each_depth() { \
2727 + b[i + 1] bd = 0; \
2728 + b[i + 2] bd = 0; \
2729 + b[i + 3] bd = 0; \
2730 + b[i + 4] bd = 0; \
2731 + b[i + 5] bd = 0; \
2732 + b[i + 6] bd = 0; \
2733 + b[i + 7] bd = 0; \
2736 +#define DES_bs_clear_block() \
2737 + DES_bs_clear_block_8(0); \
2738 + DES_bs_clear_block_8(8); \
2739 + DES_bs_clear_block_8(16); \
2740 + DES_bs_clear_block_8(24); \
2741 + DES_bs_clear_block_8(32); \
2742 + DES_bs_clear_block_8(40); \
2743 + DES_bs_clear_block_8(48); \
2744 + DES_bs_clear_block_8(56);
2746 +void DES_bs_crypt(int count)
2748 - ARCH_WORD **k = DES_bs_all.Kp;
2755 + int iterations, rounds_and_swapped;
2760 + DES_bs_clear_block();
2763 + k = DES_bs_all.KS.v;
2765 + k = DES_bs_all.KS.p;
2767 + rounds_and_swapped = 8;
2768 + iterations = count;
2772 + s1(e[0] ed ^ k[0] kd, e[1] ed ^ k[1] kd, e[2] ed ^ k[2] kd,
2773 + e[3] ed ^ k[3] kd, e[4] ed ^ k[4] kd, e[5] ed ^ k[5] kd,
2774 + &b[40] bd, &b[48] bd, &b[54] bd, &b[62] bd);
2776 + s2(e[6] ed ^ k[6] kd, e[7] ed ^ k[7] kd, e[8] ed ^ k[8] kd,
2777 + e[9] ed ^ k[9] kd, e[10] ed ^ k[10] kd, e[11] ed ^ k[11] kd,
2778 + &b[44] bd, &b[59] bd, &b[33] bd, &b[49] bd);
2780 + s3(e[12] ed ^ k[12] kd, e[13] ed ^ k[13] kd, e[14] ed ^ k[14] kd,
2781 + e[15] ed ^ k[15] kd, e[16] ed ^ k[16] kd, e[17] ed ^ k[17] kd,
2782 + &b[55] bd, &b[47] bd, &b[61] bd, &b[37] bd);
2784 + s4(e[18] ed ^ k[18] kd, e[19] ed ^ k[19] kd, e[20] ed ^ k[20] kd,
2785 + e[21] ed ^ k[21] kd, e[22] ed ^ k[22] kd, e[23] ed ^ k[23] kd,
2786 + &b[57] bd, &b[51] bd, &b[41] bd, &b[32] bd);
2788 + s5(e[24] ed ^ k[24] kd, e[25] ed ^ k[25] kd, e[26] ed ^ k[26] kd,
2789 + e[27] ed ^ k[27] kd, e[28] ed ^ k[28] kd, e[29] ed ^ k[29] kd,
2790 + &b[39] bd, &b[45] bd, &b[56] bd, &b[34] bd);
2792 + s6(e[30] ed ^ k[30] kd, e[31] ed ^ k[31] kd, e[32] ed ^ k[32] kd,
2793 + e[33] ed ^ k[33] kd, e[34] ed ^ k[34] kd, e[35] ed ^ k[35] kd,
2794 + &b[35] bd, &b[60] bd, &b[42] bd, &b[50] bd);
2796 + s7(e[36] ed ^ k[36] kd, e[37] ed ^ k[37] kd, e[38] ed ^ k[38] kd,
2797 + e[39] ed ^ k[39] kd, e[40] ed ^ k[40] kd, e[41] ed ^ k[41] kd,
2798 + &b[63] bd, &b[43] bd, &b[53] bd, &b[38] bd);
2800 + s8(e[42] ed ^ k[42] kd, e[43] ed ^ k[43] kd, e[44] ed ^ k[44] kd,
2801 + e[45] ed ^ k[45] kd, e[46] ed ^ k[46] kd, e[47] ed ^ k[47] kd,
2802 + &b[36] bd, &b[58] bd, &b[46] bd, &b[52] bd);
2804 + if (rounds_and_swapped == 0x100) goto next;
2808 + s1(e[48] ed ^ k[48] kd, e[49] ed ^ k[49] kd, e[50] ed ^ k[50] kd,
2809 + e[51] ed ^ k[51] kd, e[52] ed ^ k[52] kd, e[53] ed ^ k[53] kd,
2810 + &b[8] bd, &b[16] bd, &b[22] bd, &b[30] bd);
2812 + s2(e[54] ed ^ k[54] kd, e[55] ed ^ k[55] kd, e[56] ed ^ k[56] kd,
2813 + e[57] ed ^ k[57] kd, e[58] ed ^ k[58] kd, e[59] ed ^ k[59] kd,
2814 + &b[12] bd, &b[27] bd, &b[1] bd, &b[17] bd);
2816 + s3(e[60] ed ^ k[60] kd, e[61] ed ^ k[61] kd, e[62] ed ^ k[62] kd,
2817 + e[63] ed ^ k[63] kd, e[64] ed ^ k[64] kd, e[65] ed ^ k[65] kd,
2818 + &b[23] bd, &b[15] bd, &b[29] bd, &b[5] bd);
2820 + s4(e[66] ed ^ k[66] kd, e[67] ed ^ k[67] kd, e[68] ed ^ k[68] kd,
2821 + e[69] ed ^ k[69] kd, e[70] ed ^ k[70] kd, e[71] ed ^ k[71] kd,
2822 + &b[25] bd, &b[19] bd, &b[9] bd, &b[0] bd);
2824 + s5(e[72] ed ^ k[72] kd, e[73] ed ^ k[73] kd, e[74] ed ^ k[74] kd,
2825 + e[75] ed ^ k[75] kd, e[76] ed ^ k[76] kd, e[77] ed ^ k[77] kd,
2826 + &b[7] bd, &b[13] bd, &b[24] bd, &b[2] bd);
2828 + s6(e[78] ed ^ k[78] kd, e[79] ed ^ k[79] kd, e[80] ed ^ k[80] kd,
2829 + e[81] ed ^ k[81] kd, e[82] ed ^ k[82] kd, e[83] ed ^ k[83] kd,
2830 + &b[3] bd, &b[28] bd, &b[10] bd, &b[18] bd);
2832 + s7(e[84] ed ^ k[84] kd, e[85] ed ^ k[85] kd, e[86] ed ^ k[86] kd,
2833 + e[87] ed ^ k[87] kd, e[88] ed ^ k[88] kd, e[89] ed ^ k[89] kd,
2834 + &b[31] bd, &b[11] bd, &b[21] bd, &b[6] bd);
2836 + s8(e[90] ed ^ k[90] kd, e[91] ed ^ k[91] kd, e[92] ed ^ k[92] kd,
2837 + e[93] ed ^ k[93] kd, e[94] ed ^ k[94] kd, e[95] ed ^ k[95] kd,
2838 + &b[4] bd, &b[26] bd, &b[14] bd, &b[20] bd);
2842 + if (--rounds_and_swapped) goto start;
2843 + k -= (0x300 + 48);
2844 + rounds_and_swapped = 0x108;
2845 + if (--iterations) goto swap;
2849 + k -= (0x300 - 48);
2850 + rounds_and_swapped = 8;
2851 + if (--iterations) goto start;
2854 +void DES_bs_crypt_25(void)
2861 + int iterations, rounds_and_swapped;
2866 + DES_bs_clear_block();
2869 + k = DES_bs_all.KS.v;
2871 + k = DES_bs_all.KS.p;
2873 + rounds_and_swapped = 8;
2878 + s1(e[0] ed ^ k[0] kd, e[1] ed ^ k[1] kd, e[2] ed ^ k[2] kd,
2879 + e[3] ed ^ k[3] kd, e[4] ed ^ k[4] kd, e[5] ed ^ k[5] kd,
2880 + &b[40] bd, &b[48] bd, &b[54] bd, &b[62] bd);
2882 + s2(e[6] ed ^ k[6] kd, e[7] ed ^ k[7] kd, e[8] ed ^ k[8] kd,
2883 + e[9] ed ^ k[9] kd, e[10] ed ^ k[10] kd, e[11] ed ^ k[11] kd,
2884 + &b[44] bd, &b[59] bd, &b[33] bd, &b[49] bd);
2886 + s3(b[7] bd ^ k[12] kd, b[8] bd ^ k[13] kd, b[9] bd ^ k[14] kd,
2887 + b[10] bd ^ k[15] kd, b[11] bd ^ k[16] kd, b[12] bd ^ k[17] kd,
2888 + &b[55] bd, &b[47] bd, &b[61] bd, &b[37] bd);
2890 + s4(b[11] bd ^ k[18] kd, b[12] bd ^ k[19] kd, b[13] bd ^ k[20] kd,
2891 + b[14] bd ^ k[21] kd, b[15] bd ^ k[22] kd, b[16] bd ^ k[23] kd,
2892 + &b[57] bd, &b[51] bd, &b[41] bd, &b[32] bd);
2894 + s5(e[24] ed ^ k[24] kd, e[25] ed ^ k[25] kd, e[26] ed ^ k[26] kd,
2895 + e[27] ed ^ k[27] kd, e[28] ed ^ k[28] kd, e[29] ed ^ k[29] kd,
2896 + &b[39] bd, &b[45] bd, &b[56] bd, &b[34] bd);
2898 + s6(e[30] ed ^ k[30] kd, e[31] ed ^ k[31] kd, e[32] ed ^ k[32] kd,
2899 + e[33] ed ^ k[33] kd, e[34] ed ^ k[34] kd, e[35] ed ^ k[35] kd,
2900 + &b[35] bd, &b[60] bd, &b[42] bd, &b[50] bd);
2902 + s7(b[23] bd ^ k[36] kd, b[24] bd ^ k[37] kd, b[25] bd ^ k[38] kd,
2903 + b[26] bd ^ k[39] kd, b[27] bd ^ k[40] kd, b[28] bd ^ k[41] kd,
2904 + &b[63] bd, &b[43] bd, &b[53] bd, &b[38] bd);
2906 + s8(b[27] bd ^ k[42] kd, b[28] bd ^ k[43] kd, b[29] bd ^ k[44] kd,
2907 + b[30] bd ^ k[45] kd, b[31] bd ^ k[46] kd, b[0] bd ^ k[47] kd,
2908 + &b[36] bd, &b[58] bd, &b[46] bd, &b[52] bd);
2910 + if (rounds_and_swapped == 0x100) goto next;
2914 + s1(e[48] ed ^ k[48] kd, e[49] ed ^ k[49] kd, e[50] ed ^ k[50] kd,
2915 + e[51] ed ^ k[51] kd, e[52] ed ^ k[52] kd, e[53] ed ^ k[53] kd,
2916 + &b[8] bd, &b[16] bd, &b[22] bd, &b[30] bd);
2918 + s2(e[54] ed ^ k[54] kd, e[55] ed ^ k[55] kd, e[56] ed ^ k[56] kd,
2919 + e[57] ed ^ k[57] kd, e[58] ed ^ k[58] kd, e[59] ed ^ k[59] kd,
2920 + &b[12] bd, &b[27] bd, &b[1] bd, &b[17] bd);
2922 + s3(b[39] bd ^ k[60] kd, b[40] bd ^ k[61] kd, b[41] bd ^ k[62] kd,
2923 + b[42] bd ^ k[63] kd, b[43] bd ^ k[64] kd, b[44] bd ^ k[65] kd,
2924 + &b[23] bd, &b[15] bd, &b[29] bd, &b[5] bd);
2926 + s4(b[43] bd ^ k[66] kd, b[44] bd ^ k[67] kd, b[45] bd ^ k[68] kd,
2927 + b[46] bd ^ k[69] kd, b[47] bd ^ k[70] kd, b[48] bd ^ k[71] kd,
2928 + &b[25] bd, &b[19] bd, &b[9] bd, &b[0] bd);
2930 + s5(e[72] ed ^ k[72] kd, e[73] ed ^ k[73] kd, e[74] ed ^ k[74] kd,
2931 + e[75] ed ^ k[75] kd, e[76] ed ^ k[76] kd, e[77] ed ^ k[77] kd,
2932 + &b[7] bd, &b[13] bd, &b[24] bd, &b[2] bd);
2934 + s6(e[78] ed ^ k[78] kd, e[79] ed ^ k[79] kd, e[80] ed ^ k[80] kd,
2935 + e[81] ed ^ k[81] kd, e[82] ed ^ k[82] kd, e[83] ed ^ k[83] kd,
2936 + &b[3] bd, &b[28] bd, &b[10] bd, &b[18] bd);
2938 + s7(b[55] bd ^ k[84] kd, b[56] bd ^ k[85] kd, b[57] bd ^ k[86] kd,
2939 + b[58] bd ^ k[87] kd, b[59] bd ^ k[88] kd, b[60] bd ^ k[89] kd,
2940 + &b[31] bd, &b[11] bd, &b[21] bd, &b[6] bd);
2942 + s8(b[59] bd ^ k[90] kd, b[60] bd ^ k[91] kd, b[61] bd ^ k[92] kd,
2943 + b[62] bd ^ k[93] kd, b[63] bd ^ k[94] kd, b[32] bd ^ k[95] kd,
2944 + &b[4] bd, &b[26] bd, &b[14] bd, &b[20] bd);
2948 + if (--rounds_and_swapped) goto start;
2949 + k -= (0x300 + 48);
2950 + rounds_and_swapped = 0x108;
2951 + if (--iterations) goto swap;
2955 + k -= (0x300 - 48);
2956 + rounds_and_swapped = 8;
2968 +void DES_bs_crypt_LM(void)
2976 + for_each_depth() {
2985 + b[8] bd = ~(ARCH_WORD)0;
2986 + b[9] bd = ~(ARCH_WORD)0;
2987 + b[10] bd = ~(ARCH_WORD)0;
2989 + b[12] bd = ~(ARCH_WORD)0;
3000 + b[23] bd = ~(ARCH_WORD)0;
3003 + b[26] bd = ~(ARCH_WORD)0;
3006 + b[29] bd = ~(ARCH_WORD)0;
3007 + b[30] bd = ~(ARCH_WORD)0;
3008 + b[31] bd = ~(ARCH_WORD)0;
3012 + b[35] bd = ~(ARCH_WORD)0;
3014 + b[37] bd = ~(ARCH_WORD)0;
3015 + b[38] bd = ~(ARCH_WORD)0;
3016 + b[39] bd = ~(ARCH_WORD)0;
3022 + b[45] bd = ~(ARCH_WORD)0;
3025 + b[48] bd = ~(ARCH_WORD)0;
3026 + b[49] bd = ~(ARCH_WORD)0;
3031 + b[54] bd = ~(ARCH_WORD)0;
3033 + b[56] bd = ~(ARCH_WORD)0;
3035 + b[58] bd = ~(ARCH_WORD)0;
3037 + b[60] bd = ~(ARCH_WORD)0;
3038 + b[61] bd = ~(ARCH_WORD)0;
3039 + b[62] bd = ~(ARCH_WORD)0;
3040 + b[63] bd = ~(ARCH_WORD)0;
3043 + k = DES_bs_all.KS.p;
3047 - s1(*e[0] ^ *k[0], *e[1] ^ *k[1], *e[2] ^ *k[2],
3048 - *e[3] ^ *k[3], *e[4] ^ *k[4], *e[5] ^ *k[5],
3049 - &b[40], &b[48], &b[54], &b[62]);
3050 - s2(*e[6] ^ *k[6], *e[7] ^ *k[7], *e[8] ^ *k[8],
3051 - *e[9] ^ *k[9], *e[10] ^ *k[10], *e[11] ^ *k[11],
3052 - &b[44], &b[59], &b[33], &b[49]);
3053 - s3(*e[12] ^ *k[12], *e[13] ^ *k[13], *e[14] ^ *k[14],
3054 - *e[15] ^ *k[15], *e[16] ^ *k[16], *e[17] ^ *k[17],
3055 - &b[55], &b[47], &b[61], &b[37]);
3056 - s4(*e[18] ^ *k[18], *e[19] ^ *k[19], *e[20] ^ *k[20],
3057 - *e[21] ^ *k[21], *e[22] ^ *k[22], *e[23] ^ *k[23],
3058 - &b[57], &b[51], &b[41], &b[32]);
3059 - s5(*e[24] ^ *k[24], *e[25] ^ *k[25], *e[26] ^ *k[26],
3060 - *e[27] ^ *k[27], *e[28] ^ *k[28], *e[29] ^ *k[29],
3061 - &b[39], &b[45], &b[56], &b[34]);
3062 - s6(*e[30] ^ *k[30], *e[31] ^ *k[31], *e[32] ^ *k[32],
3063 - *e[33] ^ *k[33], *e[34] ^ *k[34], *e[35] ^ *k[35],
3064 - &b[35], &b[60], &b[42], &b[50]);
3065 - s7(*e[36] ^ *k[36], *e[37] ^ *k[37], *e[38] ^ *k[38],
3066 - *e[39] ^ *k[39], *e[40] ^ *k[40], *e[41] ^ *k[41],
3067 - &b[63], &b[43], &b[53], &b[38]);
3068 - s8(*e[42] ^ *k[42], *e[43] ^ *k[43], *e[44] ^ *k[44],
3069 - *e[45] ^ *k[45], *e[46] ^ *k[46], *e[47] ^ *k[47],
3070 - &b[36], &b[58], &b[46], &b[52]);
3072 - s1(*e[48] ^ *k[48], *e[49] ^ *k[49], *e[50] ^ *k[50],
3073 - *e[51] ^ *k[51], *e[52] ^ *k[52], *e[53] ^ *k[53],
3074 - &b[8], &b[16], &b[22], &b[30]);
3075 - s2(*e[54] ^ *k[54], *e[55] ^ *k[55], *e[56] ^ *k[56],
3076 - *e[57] ^ *k[57], *e[58] ^ *k[58], *e[59] ^ *k[59],
3077 - &b[12], &b[27], &b[1], &b[17]);
3078 - s3(*e[60] ^ *k[60], *e[61] ^ *k[61], *e[62] ^ *k[62],
3079 - *e[63] ^ *k[63], *e[64] ^ *k[64], *e[65] ^ *k[65],
3080 - &b[23], &b[15], &b[29], &b[5]);
3081 - s4(*e[66] ^ *k[66], *e[67] ^ *k[67], *e[68] ^ *k[68],
3082 - *e[69] ^ *k[69], *e[70] ^ *k[70], *e[71] ^ *k[71],
3083 - &b[25], &b[19], &b[9], &b[0]);
3084 - s5(*e[72] ^ *k[72], *e[73] ^ *k[73], *e[74] ^ *k[74],
3085 - *e[75] ^ *k[75], *e[76] ^ *k[76], *e[77] ^ *k[77],
3086 - &b[7], &b[13], &b[24], &b[2]);
3087 - s6(*e[78] ^ *k[78], *e[79] ^ *k[79], *e[80] ^ *k[80],
3088 - *e[81] ^ *k[81], *e[82] ^ *k[82], *e[83] ^ *k[83],
3089 - &b[3], &b[28], &b[10], &b[18]);
3090 - s7(*e[84] ^ *k[84], *e[85] ^ *k[85], *e[86] ^ *k[86],
3091 - *e[87] ^ *k[87], *e[88] ^ *k[88], *e[89] ^ *k[89],
3092 - &b[31], &b[11], &b[21], &b[6]);
3093 - s8(*e[90] ^ *k[90], *e[91] ^ *k[91], *e[92] ^ *k[92],
3094 - *e[93] ^ *k[93], *e[94] ^ *k[94], *e[95] ^ *k[95],
3095 - &b[4], &b[26], &b[14], &b[20]);
3097 + s1(b[31] bd ^ k[0] kd, b[0] bd ^ k[1] kd,
3098 + b[1] bd ^ k[2] kd, b[2] bd ^ k[3] kd,
3099 + b[3] bd ^ k[4] kd, b[4] bd ^ k[5] kd,
3100 + &b[40] bd, &b[48] bd, &b[54] bd, &b[62] bd);
3102 + s2(b[3] bd ^ k[6] kd, b[4] bd ^ k[7] kd,
3103 + b[5] bd ^ k[8] kd, b[6] bd ^ k[9] kd,
3104 + b[7] bd ^ k[10] kd, b[8] bd ^ k[11] kd,
3105 + &b[44] bd, &b[59] bd, &b[33] bd, &b[49] bd);
3107 + s3(b[7] bd ^ k[12] kd, b[8] bd ^ k[13] kd,
3108 + b[9] bd ^ k[14] kd, b[10] bd ^ k[15] kd,
3109 + b[11] bd ^ k[16] kd, b[12] bd ^ k[17] kd,
3110 + &b[55] bd, &b[47] bd, &b[61] bd, &b[37] bd);
3112 + s4(b[11] bd ^ k[18] kd, b[12] bd ^ k[19] kd,
3113 + b[13] bd ^ k[20] kd, b[14] bd ^ k[21] kd,
3114 + b[15] bd ^ k[22] kd, b[16] bd ^ k[23] kd,
3115 + &b[57] bd, &b[51] bd, &b[41] bd, &b[32] bd);
3117 + s5(b[15] bd ^ k[24] kd, b[16] bd ^ k[25] kd,
3118 + b[17] bd ^ k[26] kd, b[18] bd ^ k[27] kd,
3119 + b[19] bd ^ k[28] kd, b[20] bd ^ k[29] kd,
3120 + &b[39] bd, &b[45] bd, &b[56] bd, &b[34] bd);
3122 + s6(b[19] bd ^ k[30] kd, b[20] bd ^ k[31] kd,
3123 + b[21] bd ^ k[32] kd, b[22] bd ^ k[33] kd,
3124 + b[23] bd ^ k[34] kd, b[24] bd ^ k[35] kd,
3125 + &b[35] bd, &b[60] bd, &b[42] bd, &b[50] bd);
3127 + s7(b[23] bd ^ k[36] kd, b[24] bd ^ k[37] kd,
3128 + b[25] bd ^ k[38] kd, b[26] bd ^ k[39] kd,
3129 + b[27] bd ^ k[40] kd, b[28] bd ^ k[41] kd,
3130 + &b[63] bd, &b[43] bd, &b[53] bd, &b[38] bd);
3132 + s8(b[27] bd ^ k[42] kd, b[28] bd ^ k[43] kd,
3133 + b[29] bd ^ k[44] kd, b[30] bd ^ k[45] kd,
3134 + b[31] bd ^ k[46] kd, b[0] bd ^ k[47] kd,
3135 + &b[36] bd, &b[58] bd, &b[46] bd, &b[52] bd);
3138 + s1(b[63] bd ^ k[48] kd, b[32] bd ^ k[49] kd,
3139 + b[33] bd ^ k[50] kd, b[34] bd ^ k[51] kd,
3140 + b[35] bd ^ k[52] kd, b[36] bd ^ k[53] kd,
3141 + &b[8] bd, &b[16] bd, &b[22] bd, &b[30] bd);
3143 + s2(b[35] bd ^ k[54] kd, b[36] bd ^ k[55] kd,
3144 + b[37] bd ^ k[56] kd, b[38] bd ^ k[57] kd,
3145 + b[39] bd ^ k[58] kd, b[40] bd ^ k[59] kd,
3146 + &b[12] bd, &b[27] bd, &b[1] bd, &b[17] bd);
3148 + s3(b[39] bd ^ k[60] kd, b[40] bd ^ k[61] kd,
3149 + b[41] bd ^ k[62] kd, b[42] bd ^ k[63] kd,
3150 + b[43] bd ^ k[64] kd, b[44] bd ^ k[65] kd,
3151 + &b[23] bd, &b[15] bd, &b[29] bd, &b[5] bd);
3153 + s4(b[43] bd ^ k[66] kd, b[44] bd ^ k[67] kd,
3154 + b[45] bd ^ k[68] kd, b[46] bd ^ k[69] kd,
3155 + b[47] bd ^ k[70] kd, b[48] bd ^ k[71] kd,
3156 + &b[25] bd, &b[19] bd, &b[9] bd, &b[0] bd);
3158 + s5(b[47] bd ^ k[72] kd, b[48] bd ^ k[73] kd,
3159 + b[49] bd ^ k[74] kd, b[50] bd ^ k[75] kd,
3160 + b[51] bd ^ k[76] kd, b[52] bd ^ k[77] kd,
3161 + &b[7] bd, &b[13] bd, &b[24] bd, &b[2] bd);
3163 + s6(b[51] bd ^ k[78] kd, b[52] bd ^ k[79] kd,
3164 + b[53] bd ^ k[80] kd, b[54] bd ^ k[81] kd,
3165 + b[55] bd ^ k[82] kd, b[56] bd ^ k[83] kd,
3166 + &b[3] bd, &b[28] bd, &b[10] bd, &b[18] bd);
3168 + s7(b[55] bd ^ k[84] kd, b[56] bd ^ k[85] kd,
3169 + b[57] bd ^ k[86] kd, b[58] bd ^ k[87] kd,
3170 + b[59] bd ^ k[88] kd, b[60] bd ^ k[89] kd,
3171 + &b[31] bd, &b[11] bd, &b[21] bd, &b[6] bd);
3173 + s8(b[59] bd ^ k[90] kd, b[60] bd ^ k[91] kd,
3174 + b[61] bd ^ k[92] kd, b[62] bd ^ k[93] kd,
3175 + b[63] bd ^ k[94] kd, b[32] bd ^ k[95] kd,
3176 + &b[4] bd, &b[26] bd, &b[14] bd, &b[20] bd);
3179 - } while (--count);
3180 + } while (--rounds);
3183 diff -ruN john-1.6/src/DES_bs.c john-1.6.34/src/DES_bs.c
3184 --- john-1.6/src/DES_bs.c 1998-12-03 01:29:50.000000000 +0100
3185 +++ john-1.6.34/src/DES_bs.c 2002-10-19 16:05:46.000000000 +0200
3188 * This file is part of John the Ripper password cracker,
3189 - * Copyright (c) 1996-98 by Solar Designer
3190 + * Copyright (c) 1996-2002 by Solar Designer
3196 +#include "common.h"
3197 #include "DES_std.h"
3200 -DES_bs_combined DES_bs_all;
3201 -int DES_bs_mem_saving = 0;
3203 +#define DEPTH [depth]
3205 +#define init_depth() \
3206 + register int depth; \
3207 + depth = index >> ARCH_BITS_LOG; \
3208 + index &= (ARCH_BITS - 1);
3209 +#define for_each_depth() \
3210 + for (depth = 0; depth < DES_BS_VECTOR; depth++)
3214 +#define init_depth()
3215 +#define for_each_depth()
3219 +DES_bs_combined CC_CACHE_ALIGN DES_bs_all;
3222 +static unsigned char DES_LM_KP[56] = {
3223 + 1, 2, 3, 4, 5, 6, 7,
3224 + 10, 11, 12, 13, 14, 15, 0,
3225 + 19, 20, 21, 22, 23, 8, 9,
3226 + 28, 29, 30, 31, 16, 17, 18,
3227 + 37, 38, 39, 24, 25, 26, 27,
3228 + 46, 47, 32, 33, 34, 35, 36,
3229 + 55, 40, 41, 42, 43, 44, 45,
3230 + 48, 49, 50, 51, 52, 53, 54
3233 +static unsigned char DES_LM_reverse[16] = {
3234 + 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15
3238 +extern void DES_bs_init_asm(void);
3241 -extern void DES_bs_body();
3244 +void DES_bs_init(int LM)
3248 + int round, index, bit;
3252 + DES_bs_all.KS_updates = 0;
3254 + DES_bs_clear_keys_LM();
3256 + DES_bs_clear_keys();
3258 - for (index = 0; index < 0x300; index++) {
3259 - bit = DES_K_bits[index];
3261 - DES_bs_all.Kp[index] = &DES_bs_all.K[55 - bit];
3264 + k = DES_bs_all.KS.p;
3266 + k = DES_bs_all.KSp;
3268 + k = DES_bs_all.KS.p;
3272 + for (round = 0; round < 16; round++) {
3273 + s += DES_ROT[round];
3274 + for (index = 0; index < 48; index++) {
3275 + p = DES_PC2[index];
3276 + q = p < 28 ? 0 : 28;
3278 + while (p >= 28) p -= 28;
3279 + bit = DES_PC1[p + q];
3283 + if (LM) bit = DES_LM_KP[bit];
3284 + *k++ = &DES_bs_all.K[bit] START;
3288 +/* Initialize the array with right shifts needed to get past the first
3289 + * non-zero bit in the index. */
3290 + for (bit = 0; bit <= 7; bit++)
3291 + for (index = 1 << bit; index < 0x100; index += 2 << bit)
3292 + DES_bs_all.s[index] = bit + 1;
3294 +/* Special case: instead of doing an extra check in the loop below, we
3295 + * might instead overrun into DES_bs_all.B, which is harmless, as long
3296 + * as the order of fields is unchanged. */
3297 + DES_bs_all.s[0] = 57;
3300 + for (c = 0; c < 0x100; c++)
3301 + if (c >= 'a' && c <= 'z')
3302 + DES_bs_all.E.extras.u[c] = c & ~0x20;
3304 + DES_bs_all.E.extras.u[c] = c;
3308 + DES_bs_init_asm();
3312 void DES_bs_set_salt(ARCH_WORD salt)
3314 - register int src, dst;
3315 register ARCH_WORD mask;
3316 + register int src, dst;
3319 for (dst = 0; dst < 48; dst++) {
3320 @@ -38,158 +125,232 @@
3321 if (dst < 24) src = dst + 24; else src = dst - 24;
3324 - DES_bs_all.E[dst] = &DES_bs_all.B[DES_E[src]];
3325 - DES_bs_all.E[dst + 48] = &DES_bs_all.B[DES_E[src] + 32];
3326 + DES_bs_all.E.E[dst] = &DES_bs_all.B[DES_E[src]] START;
3327 + DES_bs_all.E.E[dst + 48] = &DES_bs_all.B[DES_E[src] + 32] START;
3333 -void DES_bs_clear_keys()
3334 +void DES_bs_clear_keys(void)
3336 + if (DES_bs_all.KS_updates++ & 0xFFF) return;
3337 + DES_bs_all.KS_updates = 1;
3338 + memset(DES_bs_all.K, 0, sizeof(DES_bs_all.K));
3339 + memset(DES_bs_all.keys, 0, sizeof(DES_bs_all.keys));
3340 + DES_bs_all.keys_changed = 1;
3343 +void DES_bs_clear_keys_LM(void)
3345 + if (DES_bs_all.KS_updates++ & 0xFFF) return;
3346 + DES_bs_all.KS_updates = 1;
3347 memset(DES_bs_all.K, 0, sizeof(DES_bs_all.K));
3348 +#if !DES_BS_VECTOR && ARCH_BITS >= 64
3349 + memset(DES_bs_all.E.extras.keys, 0, sizeof(DES_bs_all.E.extras.keys));
3351 + memset(DES_bs_all.keys, 0, sizeof(DES_bs_all.keys));
3355 void DES_bs_set_key(char *key, int index)
3357 - register char *ptr;
3358 - register int ofs, bit;
3359 - register ARCH_WORD value;
3360 + register unsigned char *new = (unsigned char *)key;
3361 + register unsigned char *old = DES_bs_all.keys[index];
3362 + register ARCH_WORD xor, mask;
3363 + register int ofs, bit, shift;
3368 - for (ptr = key; *ptr && ofs; ptr++) {
3370 - value = *ptr & 0x7F;
3371 + mask = (ARCH_WORD)1 << index;
3373 + while ((*new || *old) && ofs < 55) {
3374 + if ((xor = *new ^ *old)) {
3379 + shift = DES_bs_all.s[xor];
3380 + DES_bs_all.K[bit += shift] DEPTH ^= mask;
3381 + } while (xor >>= shift);
3385 - DES_bs_all.K[bit++] |= (value & 1) << index;
3386 - } while (value >>= 1);
3392 + DES_bs_all.keys_changed = 1;
3395 -void DES_bs_crypt(int count)
3396 +void DES_bs_set_key_LM(char *key, int index)
3399 - register ARCH_WORD R, L;
3400 + register unsigned char *new = (unsigned char *)key;
3401 +#if !DES_BS_VECTOR && ARCH_BITS >= 64
3402 + register unsigned char *old = DES_bs_all.E.extras.keys[index];
3404 + register unsigned char *old = DES_bs_all.keys[index];
3406 + register unsigned char plain;
3407 + register ARCH_WORD xor, mask;
3408 + register int ofs, bit, shift;
3410 - memset(DES_bs_all.B, 0, sizeof(DES_bs_all.B));
3415 + mask = (ARCH_WORD)1 << index;
3417 + while ((*new || *old) && ofs < 55) {
3418 + plain = DES_bs_all.E.extras.u[ARCH_INDEX(*new)];
3419 + if ((xor = plain ^ *old)) {
3423 + shift = DES_bs_all.s[xor];
3424 + DES_bs_all.K[bit += shift] DEPTH ^= mask;
3425 + } while (xor >>= shift);
3434 - if (!--count) break;
3436 +void DES_bs_expand_keys(void)
3438 + register int index;
3440 + register int depth;
3443 + if (!DES_bs_all.keys_changed) return;
3445 + for (index = 0; index < 0x300; index++)
3448 + DES_bs_all.KS.v[index] DEPTH = DES_bs_all.KSp[index] DEPTH;
3450 + DES_bs_all.KS.v[index] = *DES_bs_all.KSp[index];
3453 - for (bit = 0; bit < 32; bit++) {
3454 - R = DES_bs_all.B[bit];
3455 - L = DES_bs_all.B[bit + 32];
3456 - DES_bs_all.B[bit + 32] = R;
3457 - DES_bs_all.B[bit] = L;
3460 + DES_bs_all.keys_changed = 0;
3464 -ARCH_WORD *DES_bs_get_binary(char *ciphertext)
3465 +static ARCH_WORD *DES_bs_get_binary_raw(ARCH_WORD *raw, int count)
3467 - static ARCH_WORD out[64];
3473 - raw = DES_raw_get_binary(ciphertext);
3475 - out[1] = out[0] = 0;
3476 - for (bit = 0; bit < 64; bit++) {
3479 -/* Swap L and R here instead of doing it one more time in DES_bs_crypt() */
3482 -/* Calculate the number of one of the 16 data bits in raw[index] */
3483 - shift = ((bit & 0xC) << 1) + (bit & 3) + 1;
3486 - value = (raw[index] >> shift) & 1;
3488 - if (DES_bs_mem_saving)
3489 -/* Memory saving: pack the bits into two words */
3490 - out[bit >> 5] |= value << (bit & 0x1F);
3492 -/* We either set or clear all the bits in every word */
3493 - out[bit] = value ? ~(ARCH_WORD)0 : 0;
3495 + static ARCH_WORD out[2];
3497 +/* For odd iteration counts, swap L and R here instead of doing it one
3498 + * more time in DES_bs_crypt(). */
3500 + out[count] = raw[0];
3501 + out[count ^ 1] = raw[1];
3506 -int DES_bs_binary_hash(ARCH_WORD *binary, int count)
3507 +ARCH_WORD *DES_bs_get_binary(char *ciphertext)
3511 - if (DES_bs_mem_saving)
3512 - return (int)*binary & ((1 << count) - 1);
3513 + return DES_bs_get_binary_raw(
3514 + DES_raw_get_binary(ciphertext),
3515 + DES_raw_get_count(ciphertext));
3519 - for (bit = 0; bit < count; bit++)
3520 - if (binary[bit]) result |= 1 << bit;
3521 +ARCH_WORD *DES_bs_get_binary_LM(char *ciphertext)
3523 + ARCH_WORD block[2], value;
3527 + block[0] = block[1] = 0;
3528 + for (index = 0; index < 16; index += 2) {
3529 + l = atoi16[ARCH_INDEX(ciphertext[index])];
3530 + h = atoi16[ARCH_INDEX(ciphertext[index + 1])];
3531 + value = DES_LM_reverse[l] | (DES_LM_reverse[h] << 4);
3532 + block[index >> 3] |= value << ((index << 2) & 0x18);
3536 + return DES_bs_get_binary_raw(DES_do_IP(block), 1);
3539 int DES_bs_get_hash(int index, int count)
3541 - register int bit, result;
3542 - register ARCH_WORD mask;
3543 + register int result;
3545 - mask = (ARCH_WORD)1 << index;
3547 - for (bit = 0; bit < count; bit++)
3548 - if (DES_bs_all.B[bit] & mask) result |= 1 << bit;
3551 + result = (DES_bs_all.B[0] DEPTH >> index) & 1;
3552 + result |= ((DES_bs_all.B[1] DEPTH >> index) & 1) << 1;
3553 + result |= ((DES_bs_all.B[2] DEPTH >> index) & 1) << 2;
3554 + result |= ((DES_bs_all.B[3] DEPTH >> index) & 1) << 3;
3555 + if (count == 4) return result;
3557 + result |= ((DES_bs_all.B[4] DEPTH >> index) & 1) << 4;
3558 + result |= ((DES_bs_all.B[5] DEPTH >> index) & 1) << 5;
3559 + result |= ((DES_bs_all.B[6] DEPTH >> index) & 1) << 6;
3560 + result |= ((DES_bs_all.B[7] DEPTH >> index) & 1) << 7;
3561 + if (count == 8) return result;
3563 + result |= ((DES_bs_all.B[8] DEPTH >> index) & 1) << 8;
3564 + result |= ((DES_bs_all.B[9] DEPTH >> index) & 1) << 9;
3565 + result |= ((DES_bs_all.B[10] DEPTH >> index) & 1) << 10;
3566 + result |= ((DES_bs_all.B[11] DEPTH >> index) & 1) << 11;
3572 * The trick I used here allows to compare one ciphertext against all the
3573 - * DES_bs_crypt() outputs in just O(log2(ARCH_BITS)) operations.
3574 + * DES_bs_crypt() outputs in just O(log2(ARCH_BITS)) operations, assuming
3575 + * that DES_BS_VECTOR is 0 or 1. This routine isn't vectorized, yet.
3577 -int DES_bs_cmp_all(ARCH_WORD *binary, int count)
3578 +int DES_bs_cmp_all(ARCH_WORD *binary)
3580 + register ARCH_WORD value, mask;
3582 - register ARCH_WORD mask;
3584 + register int depth;
3587 + for_each_depth() {
3588 + value = binary[0];
3590 + mask = DES_bs_all.B[0] DEPTH ^ -(value & 1);
3591 + mask |= DES_bs_all.B[1] DEPTH ^ -((value >> 1) & 1);
3592 + if (mask == ~(ARCH_WORD)0) goto next_depth;
3593 + mask |= DES_bs_all.B[2] DEPTH ^ -((value >> 2) & 1);
3594 + mask |= DES_bs_all.B[3] DEPTH ^ -((value >> 3) & 1);
3595 + if (mask == ~(ARCH_WORD)0) goto next_depth;
3597 + for (bit = 4; bit < 32; bit += 2) {
3598 + mask |= DES_bs_all.B[bit] DEPTH ^
3600 + if (mask == ~(ARCH_WORD)0) goto next_depth;
3601 + mask |= DES_bs_all.B[bit + 1] DEPTH ^
3602 + -((value >> 1) & 1);
3603 + if (mask == ~(ARCH_WORD)0) goto next_depth;
3608 - if (DES_bs_mem_saving)
3609 - for (bit = 0; bit < ((count < 32) ? count : 32); bit++) {
3610 - mask |= DES_bs_all.B[bit] ^
3611 - ((binary[0] & (1 << bit)) ? ~(ARCH_WORD)0 : 0);
3612 - if (mask == ~(ARCH_WORD)0) return 0;
3615 - for (bit = 0; bit < count; bit++) {
3616 - mask |= DES_bs_all.B[bit] ^ binary[bit];
3617 - if (mask == ~(ARCH_WORD)0) return 0;
3627 int DES_bs_cmp_one(ARCH_WORD *binary, int count, int index)
3630 - register ARCH_WORD mask;
3632 - if (DES_bs_mem_saving) {
3633 - for (bit = 0; bit < count; bit++)
3634 - if (((DES_bs_all.B[bit] >> index) ^
3635 - (binary[bit >> 5] >> (bit & 0x1F))) & 1) return 0;
3641 - mask = (ARCH_WORD)1 << index;
3642 for (bit = 0; bit < count; bit++)
3643 - if ((DES_bs_all.B[bit] ^ binary[bit]) & mask) return 0;
3644 + if (((DES_bs_all.B[bit] DEPTH >> index) ^
3645 + (binary[bit >> 5] >> (bit & 0x1F))) & 1) return 0;
3649 diff -ruN john-1.6/src/DES_bs.h john-1.6.34/src/DES_bs.h
3650 --- john-1.6/src/DES_bs.h 1998-12-03 01:29:50.000000000 +0100
3651 +++ john-1.6.34/src/DES_bs.h 2001-06-28 23:11:25.000000000 +0200
3654 * This file is part of John the Ripper password cracker,
3655 - * Copyright (c) 1996-98 by Solar Designer
3656 + * Copyright (c) 1996-2001 by Solar Designer
3664 +#ifndef DES_BS_ALGORITHM_NAME
3665 #define DES_BS_ALGORITHM_NAME ARCH_BITS_STR "/" ARCH_BITS_STR " BS"
3669 - * Non-zero when memory saving is enabled, with a performance impact. This
3670 - * should be either set at the very beginning, or never set at all.
3672 -extern int DES_bs_mem_saving;
3674 +#define DES_BS_DEPTH (ARCH_BITS * DES_BS_VECTOR)
3676 +#define DES_BS_DEPTH ARCH_BITS
3680 +typedef ARCH_WORD DES_bs_vector[DES_BS_VECTOR];
3682 +#define DES_bs_vector ARCH_WORD
3686 * All bitslice DES parameters combined into one struct for more efficient
3688 + * cache usage. Don't re-order unless you know what you're doing, as there
3689 + * is an optimization that would produce undefined results if you did.
3691 + * This must match the definition in x86-mmx.S.
3694 - ARCH_WORD *Kp[0x300]; /* Key schedule (key bit pointers) */
3695 - ARCH_WORD *E[96]; /* Expansion function (data bit pointers) */
3696 - ARCH_WORD K[56]; /* Keys */
3697 - ARCH_WORD B[64]; /* Data blocks */
3699 + ARCH_WORD *KSp[0x300]; /* Initial key schedule (key bit pointers) */
3702 + ARCH_WORD *p[0x300]; /* Key bit pointers */
3704 + DES_bs_vector v[0x300]; /* Key bit values */
3706 + } KS; /* Current key schedule */
3708 + ARCH_WORD *E[96]; /* Expansion function (data bit ptrs) */
3710 +#if !DES_BS_VECTOR && ARCH_BITS >= 64
3711 + unsigned char keys[DES_BS_DEPTH][8]; /* Current keys */
3713 + unsigned char u[0x100]; /* Uppercase */
3714 + } extras; /* Re-use the cache space for LM */
3716 + DES_bs_vector K[56]; /* Keys */
3717 + DES_bs_vector B[64]; /* Data blocks */
3719 + DES_bs_vector tmp[16]; /* Miscellaneous temporary storage */
3721 + unsigned char s[0x100]; /* Shift counts, used internally */
3722 + int KS_updates; /* Key schedule updates counter */
3723 + int keys_changed; /* If keys have changed since last expand */
3724 + unsigned char keys[DES_BS_DEPTH][8]; /* Current keys */
3727 extern DES_bs_combined DES_bs_all;
3730 * Initializes the internal structures.
3732 -extern void DES_bs_init();
3733 +extern void DES_bs_init(int LM);
3736 * Sets a salt for DES_bs_crypt().
3738 extern void DES_bs_set_salt(ARCH_WORD salt);
3741 - * Clears the bitslice keys, should be done before DES_bs_set_key() calls.
3742 + * Clears the bitslice keys if the key schedule has been updated too
3743 + * many times without being fully regenerated. This should be called
3744 + * whenever possible to reduce the impact of hardware faults.
3746 -extern void DES_bs_clear_keys();
3747 +extern void DES_bs_clear_keys(void);
3748 +extern void DES_bs_clear_keys_LM(void);
3751 * Sets a key for DES_bs_crypt().
3753 extern void DES_bs_set_key(char *key, int index);
3756 - * Main encryption routine, accepts the iteration count.
3757 + * Initializes the key schedule with actual key bits. Not for LM.
3760 +extern void DES_bs_expand_keys(void);
3762 +#define DES_bs_expand_keys()
3766 + * Sets a key for DES_bs_crypt_LM().
3768 +extern void DES_bs_set_key_LM(char *key, int index);
3771 + * Generic bitslice routine: 24 bit salts, variable iteration count.
3773 extern void DES_bs_crypt(int count);
3776 + * A simplified special-case version: 12 bit salts, 25 iterations.
3778 +extern void DES_bs_crypt_25(void);
3781 + * Another special-case version: a non-zero IV, no salts, no iterations.
3783 +extern void DES_bs_crypt_LM(void);
3786 * Converts an ASCII ciphertext to binary to be used with one of the
3787 * comparison functions.
3789 extern ARCH_WORD *DES_bs_get_binary(char *ciphertext);
3792 - * Calculates a hash for a ciphertext, for faster comparison.
3793 + * Similarly, for LM hashes.
3795 -extern int DES_bs_binary_hash(ARCH_WORD *binary, int count);
3796 +extern ARCH_WORD *DES_bs_get_binary_LM(char *ciphertext);
3799 * Calculates a hash for a DES_bs_crypt() output.
3800 @@ -75,14 +136,13 @@
3801 extern int DES_bs_get_hash(int index, int count);
3804 - * Compares count bits of a given ciphertext against all the DES_bs_crypt()
3805 + * Compares 32 bits of a given ciphertext against all the DES_bs_crypt()
3806 * outputs and returns zero if no matches detected.
3808 -extern int DES_bs_cmp_all(ARCH_WORD *binary, int count);
3809 +extern int DES_bs_cmp_all(ARCH_WORD *binary);
3812 - * Same as the above, except the comparison is done against only one of the
3813 - * DES_bs_crypt() outputs.
3814 + * Compares count bits of a given ciphertext against one of the outputs.
3816 extern int DES_bs_cmp_one(ARCH_WORD *binary, int count, int index);
3818 diff -ruN john-1.6/src/DES_fmt.c john-1.6.34/src/DES_fmt.c
3819 --- john-1.6/src/DES_fmt.c 1998-12-03 01:29:50.000000000 +0100
3820 +++ john-1.6.34/src/DES_fmt.c 2001-06-19 10:34:09.000000000 +0200
3823 * This file is part of John the Ripper password cracker,
3824 - * Copyright (c) 1996-98 by Solar Designer
3825 + * Copyright (c) 1996-2001 by Solar Designer
3830 #include "formats.h"
3832 #define FORMAT_LABEL "des"
3833 -#define FORMAT_NAME "Standard DES"
3834 +#define FORMAT_NAME "Traditional DES"
3836 #define BENCHMARK_COMMENT ""
3837 #define BENCHMARK_LENGTH 0
3842 -#include "memory.h"
3845 #define ALGORITHM_NAME DES_BS_ALGORITHM_NAME
3847 -#define BINARY_BITS 16
3849 -#define BINARY_SIZE (BINARY_BITS * ARCH_SIZE)
3850 +#define BINARY_SIZE ARCH_SIZE
3851 #define SALT_SIZE ARCH_SIZE
3853 -#define MIN_KEYS_PER_CRYPT ARCH_BITS
3854 -#define MAX_KEYS_PER_CRYPT ARCH_BITS
3855 +#define MIN_KEYS_PER_CRYPT DES_BS_DEPTH
3856 +#define MAX_KEYS_PER_CRYPT DES_BS_DEPTH
3861 #define MAX_KEYS_PER_CRYPT 0x80
3876 char key[PLAINTEXT_LENGTH];
3877 } buffer[MAX_KEYS_PER_CRYPT];
3882 -struct fmt_main fmt_DES;
3883 -static int binary_bits = BINARY_BITS;
3884 -static int keys_changed;
3888 - if (mem_saving_level > 1) {
3889 - DES_bs_mem_saving = 1;
3891 - fmt_DES.params.binary_size = ARCH_SIZE;
3896 +static void init(void)
3904 if (!ciphertext[0] || !ciphertext[1]) return 0;
3906 - for (pos = &ciphertext[2]; atoi64[(ARCH_INDEX)*pos] != 0x7F; pos++);
3907 + for (pos = &ciphertext[2]; atoi64[ARCH_INDEX(*pos)] != 0x7F; pos++);
3908 if (*pos && *pos != ',') return 0;
3910 + if (atoi64[ARCH_INDEX(*(pos - 1))] & 3) return 0;
3912 switch (pos - ciphertext) {
3913 case CIPHERTEXT_LENGTH_1:
3916 case CIPHERTEXT_LENGTH_2:
3917 + if (atoi64[ARCH_INDEX(ciphertext[12])] & 3) return 0;
3921 @@ -144,17 +132,17 @@
3923 static int binary_hash_0(void *binary)
3925 - return DES_bs_binary_hash((ARCH_WORD *)binary, 4);
3926 + return *(ARCH_WORD *)binary & 0xF;
3929 static int binary_hash_1(void *binary)
3931 - return DES_bs_binary_hash((ARCH_WORD *)binary, 8);
3932 + return *(ARCH_WORD *)binary & 0xFF;
3935 static int binary_hash_2(void *binary)
3937 - return DES_bs_binary_hash((ARCH_WORD *)binary, 12);
3938 + return *(ARCH_WORD *)binary & 0xFFF;
3941 static int get_hash_0(int index)
3942 @@ -184,26 +172,18 @@
3944 static void crypt_all(int count)
3948 - if (keys_changed) {
3949 - DES_bs_clear_keys();
3950 - for (index = 0; index < count; index++)
3951 - DES_bs_set_key(buffer[index].key, index);
3956 + DES_bs_expand_keys();
3957 + DES_bs_crypt_25();
3960 static int cmp_all(void *binary, int count)
3962 - return DES_bs_cmp_all((ARCH_WORD *)binary, binary_bits);
3963 + return DES_bs_cmp_all((ARCH_WORD *)binary);
3966 static int cmp_one(void *binary, int index)
3968 - return DES_bs_cmp_one((ARCH_WORD *)binary, binary_bits, index);
3969 + return DES_bs_cmp_one((ARCH_WORD *)binary, 32, index);
3972 static int cmp_exact(char *source, int index)
3973 @@ -303,23 +283,24 @@
3978 static void set_key(char *key, int index)
3983 DES_std_set_key(key);
3984 memcpy(buffer[index].aligned.data.KS, DES_KS_current, sizeof(DES_KS));
3987 memcpy(buffer[index].key, key, PLAINTEXT_LENGTH);
3991 static char *get_key(int index)
3993 static char out[PLAINTEXT_LENGTH + 1];
3996 + memcpy(out, DES_bs_all.keys[index], PLAINTEXT_LENGTH);
3998 memcpy(out, buffer[index].key, PLAINTEXT_LENGTH);
4000 out[PLAINTEXT_LENGTH] = 0;
4003 @@ -337,7 +318,11 @@
4008 + FMT_CASE | FMT_BS,
4015 @@ -361,8 +346,17 @@
4026 + DES_bs_clear_keys,
4028 + fmt_default_clear_keys,
4033 diff -ruN john-1.6/src/DES_std.c john-1.6.34/src/DES_std.c
4034 --- john-1.6/src/DES_std.c 1998-12-03 01:29:50.000000000 +0100
4035 +++ john-1.6.34/src/DES_std.c 2001-02-16 06:50:21.000000000 +0100
4038 * This file is part of John the Ripper password cracker,
4039 - * Copyright (c) 1996-98 by Solar Designer
4040 + * Copyright (c) 1996-2001 by Solar Designer
4046 +#include "common.h"
4047 #include "DES_std.h"
4051 -#if ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)) || (__GNUC__ > 2)
4052 -#define DES_ALIGN __attribute__ ((aligned (128)))
4054 -#define DES_ALIGN /* nothing */
4067 ARCH_WORD SPE_W[4][64 * 64];
4070 -} DES_ALIGN DES_all;
4071 +} CC_CACHE_ALIGN DES_all;
4085 ARCH_WORD SPE_W[4][64 * 64][2];
4088 -} DES_ALIGN DES_all;
4089 +} CC_CACHE_ALIGN DES_all;
4100 #define DES_KS_copy DES_all.data.KS
4101 #define DES_SPE_F DES_all.data.SPE_F
4104 ARCH_WORD DES_count;
4106 -DES_KS DES_ALIGN DES_KS_current;
4107 -DES_KS DES_ALIGN DES_KS_table[8][128];
4108 +DES_KS CC_CACHE_ALIGN DES_KS_current;
4109 +DES_KS CC_CACHE_ALIGN DES_KS_table[8][128];
4114 static char DES_key[16];
4119 extern DES_KS DES_KS_copy;
4121 unsigned ARCH_WORD *DES_out;
4123 #if (ARCH_BITS >= 64 && (DES_SCALE || !DES_MASK) || DES_128K) && \
4126 - * 64 bit architectures which can shift addresses left by 1 bit with no extra
4127 + * 64-bit architectures which can shift addresses left by 1 bit with no extra
4128 * time required (for example by adding a register to itself).
4130 #define DES_INDEX(SPE, i) \
4133 #if DES_SIZE_FIX == 0
4135 - * 64 bit architectures which can shift addresses left by 3 bits (but maybe
4136 + * 64-bit architectures which can shift addresses left by 3 bits (but maybe
4137 * not by 1) with no extra time required (for example by using the S8ADDQ
4138 * instruction on DEC Alphas; we would need an ADDQ anyway).
4142 #if ARCH_BITS >= 64 && !DES_SCALE && DES_SIZE_FIX == 2
4144 - * This method might be good for some 64 bit architectures with no complicated
4145 + * This method might be good for some 64-bit architectures with no complicated
4146 * addressing modes supported. It would be the best one for DEC Alphas if they
4147 * didn't have the S8ADDQ instruction.
4149 @@ -192,12 +183,18 @@
4151 #define DES_KS_INDEX(i) (DES_KS_copy + (i * (16 / DES_SIZE)))
4153 -#define DES_TO_6_BIT(x) \
4154 +#define DES_24_TO_32(x) \
4156 (((x) & 07700) << 2) | \
4157 (((x) & 0770000) << 4) | \
4158 (((x) & 077000000) << 6))
4160 +#define DES_16_TO_32(x) \
4161 + ((((x) & 0xF) << 1) | \
4162 + (((x) & 0xF0) << 5) | \
4163 + (((x) & 0xF00) << 9) | \
4164 + (((x) & 0xF000) << 13))
4167 #define DES_UNDO_SIZE_FIX(x) \
4168 ((((x) >> 1) & 0xFF00FF00) | (((x) & 0x00FF00FF) >> 3))
4169 @@ -294,58 +291,33 @@
4170 44, 45, 46, 47, 60, 61, 62, 63
4173 -unsigned char DES_K_bits[0x300] = {
4174 - 9, 50, 33, 59, 48, 16, 32, 56, 1, 8, 18, 41, 2, 34, 25, 24,
4175 - 43, 57, 58, 0, 35, 26, 17, 40, 21, 27, 38, 53, 36, 3, 46, 29,
4176 - 4, 52, 22, 28, 60, 20, 37, 62, 14, 19, 44, 13, 12, 61, 54, 30,
4177 - 1, 42, 25, 51, 40, 8, 24, 48, 58, 0, 10, 33, 59, 26, 17, 16,
4178 - 35, 49, 50, 57, 56, 18, 9, 32, 13, 19, 30, 45, 28, 62, 38, 21,
4179 - 27, 44, 14, 20, 52, 12, 29, 54, 6, 11, 36, 5, 4, 53, 46, 22,
4180 - 50, 26, 9, 35, 24, 57, 8, 32, 42, 49, 59, 17, 43, 10, 1, 0,
4181 - 48, 33, 34, 41, 40, 2, 58, 16, 60, 3, 14, 29, 12, 46, 22, 5,
4182 - 11, 28, 61, 4, 36, 27, 13, 38, 53, 62, 20, 52, 19, 37, 30, 6,
4183 - 34, 10, 58, 48, 8, 41, 57, 16, 26, 33, 43, 1, 56, 59, 50, 49,
4184 - 32, 17, 18, 25, 24, 51, 42, 0, 44, 54, 61, 13, 27, 30, 6, 52,
4185 - 62, 12, 45, 19, 20, 11, 60, 22, 37, 46, 4, 36, 3, 21, 14, 53,
4186 - 18, 59, 42, 32, 57, 25, 41, 0, 10, 17, 56, 50, 40, 43, 34, 33,
4187 - 16, 1, 2, 9, 8, 35, 26, 49, 28, 38, 45, 60, 11, 14, 53, 36,
4188 - 46, 27, 29, 3, 4, 62, 44, 6, 21, 30, 19, 20, 54, 5, 61, 37,
4189 - 2, 43, 26, 16, 41, 9, 25, 49, 59, 1, 40, 34, 24, 56, 18, 17,
4190 - 0, 50, 51, 58, 57, 48, 10, 33, 12, 22, 29, 44, 62, 61, 37, 20,
4191 - 30, 11, 13, 54, 19, 46, 28, 53, 5, 14, 3, 4, 38, 52, 45, 21,
4192 - 51, 56, 10, 0, 25, 58, 9, 33, 43, 50, 24, 18, 8, 40, 2, 1,
4193 - 49, 34, 35, 42, 41, 32, 59, 17, 27, 6, 13, 28, 46, 45, 21, 4,
4194 - 14, 62, 60, 38, 3, 30, 12, 37, 52, 61, 54, 19, 22, 36, 29, 5,
4195 - 35, 40, 59, 49, 9, 42, 58, 17, 56, 34, 8, 2, 57, 24, 51, 50,
4196 - 33, 18, 48, 26, 25, 16, 43, 1, 11, 53, 60, 12, 30, 29, 5, 19,
4197 - 61, 46, 44, 22, 54, 14, 27, 21, 36, 45, 38, 3, 6, 20, 13, 52,
4198 - 56, 32, 51, 41, 1, 34, 50, 9, 48, 26, 0, 59, 49, 16, 43, 42,
4199 - 25, 10, 40, 18, 17, 8, 35, 58, 3, 45, 52, 4, 22, 21, 60, 11,
4200 - 53, 38, 36, 14, 46, 6, 19, 13, 28, 37, 30, 62, 61, 12, 5, 44,
4201 - 40, 16, 35, 25, 50, 18, 34, 58, 32, 10, 49, 43, 33, 0, 56, 26,
4202 - 9, 59, 24, 2, 1, 57, 48, 42, 54, 29, 36, 19, 6, 5, 44, 62,
4203 - 37, 22, 20, 61, 30, 53, 3, 60, 12, 21, 14, 46, 45, 27, 52, 28,
4204 - 24, 0, 48, 9, 34, 2, 18, 42, 16, 59, 33, 56, 17, 49, 40, 10,
4205 - 58, 43, 8, 51, 50, 41, 32, 26, 38, 13, 20, 3, 53, 52, 28, 46,
4206 - 21, 6, 4, 45, 14, 37, 54, 44, 27, 5, 61, 30, 29, 11, 36, 12,
4207 - 8, 49, 32, 58, 18, 51, 2, 26, 0, 43, 17, 40, 1, 33, 24, 59,
4208 - 42, 56, 57, 35, 34, 25, 16, 10, 22, 60, 4, 54, 37, 36, 12, 30,
4209 - 5, 53, 19, 29, 61, 21, 38, 28, 11, 52, 45, 14, 13, 62, 20, 27,
4210 - 57, 33, 16, 42, 2, 35, 51, 10, 49, 56, 1, 24, 50, 17, 8, 43,
4211 - 26, 40, 41, 48, 18, 9, 0, 59, 6, 44, 19, 38, 21, 20, 27, 14,
4212 - 52, 37, 3, 13, 45, 5, 22, 12, 62, 36, 29, 61, 60, 46, 4, 11,
4213 - 41, 17, 0, 26, 51, 48, 35, 59, 33, 40, 50, 8, 34, 1, 57, 56,
4214 - 10, 24, 25, 32, 2, 58, 49, 43, 53, 28, 3, 22, 5, 4, 11, 61,
4215 - 36, 21, 54, 60, 29, 52, 6, 27, 46, 20, 13, 45, 44, 30, 19, 62,
4216 - 25, 1, 49, 10, 35, 32, 48, 43, 17, 24, 34, 57, 18, 50, 41, 40,
4217 - 59, 8, 9, 16, 51, 42, 33, 56, 37, 12, 54, 6, 52, 19, 62, 45,
4218 - 20, 5, 38, 44, 13, 36, 53, 11, 30, 4, 60, 29, 28, 14, 3, 46,
4219 - 17, 58, 41, 2, 56, 24, 40, 35, 9, 16, 26, 49, 10, 42, 33, 32,
4220 - 51, 0, 1, 8, 43, 34, 25, 48, 29, 4, 46, 61, 44, 11, 54, 37,
4221 - 12, 60, 30, 36, 5, 28, 45, 3, 22, 27, 52, 21, 20, 6, 62, 38
4222 +unsigned char DES_PC1[56] = {
4223 + 56, 48, 40, 32, 24, 16, 8,
4224 + 0, 57, 49, 41, 33, 25, 17,
4225 + 9, 1, 58, 50, 42, 34, 26,
4226 + 18, 10, 2, 59, 51, 43, 35,
4227 + 62, 54, 46, 38, 30, 22, 14,
4228 + 6, 61, 53, 45, 37, 29, 21,
4229 + 13, 5, 60, 52, 44, 36, 28,
4230 + 20, 12, 4, 27, 19, 11, 3
4233 +unsigned char DES_ROT[16] = {
4234 + 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1
4237 +unsigned char DES_PC2[48] = {
4238 + 13, 16, 10, 23, 0, 4,
4239 + 2, 27, 14, 5, 20, 9,
4240 + 22, 18, 11, 3, 25, 7,
4241 + 15, 6, 26, 19, 12, 1,
4242 + 40, 51, 30, 36, 46, 54,
4243 + 29, 39, 50, 44, 32, 47,
4244 + 43, 48, 38, 55, 33, 52,
4245 + 45, 41, 49, 35, 28, 31
4248 -static void init_SPE()
4249 +static void init_SPE(void)
4251 int box, index, row, column, bit;
4252 ARCH_WORD mask, l, h;
4253 @@ -366,14 +338,14 @@
4255 for (bit = 0; bit < 24; bit++) {
4256 if (((unsigned ARCH_WORD)0x80000000 >>
4257 - DES_P[DES_E[bit]]) & mask)
4258 + DES_P[ARCH_INDEX(DES_E[bit])]) & mask)
4260 if (((unsigned ARCH_WORD)0x80000000 >>
4261 - DES_P[DES_E[bit + 24]]) & mask)
4262 + DES_P[ARCH_INDEX(DES_E[bit + 24])]) & mask)
4266 - l = DES_TO_6_BIT(l); h = DES_TO_6_BIT(h);
4267 + l = DES_24_TO_32(l); h = DES_24_TO_32(h);
4270 DES_SPE[box][index] =
4275 -static void init_IP_E()
4276 +static void init_IP_E(void)
4278 int src, dst, dst1, dst2;
4279 int chunk, mask, value;
4281 for (dst1 = 0; dst1 < 8; dst1++)
4282 for (dst2 = 0; dst2 < 6; dst2++) {
4283 dst = (dst1 << 3) + dst2;
4284 - src = DES_IP[DES_E[dst1 * 6 + dst2]];
4285 + src = DES_IP[ARCH_INDEX(DES_E[dst1 * 6 + dst2])];
4286 if (src >= 32) src -= 32; else src--;
4293 -static void init_C_FP()
4294 +static void init_C_FP(void)
4297 int chunk, mask, value;
4299 memset(DES_C_FP, 0, sizeof(DES_C_FP));
4301 for (src = 0; src < 64; src++) {
4302 - dst = DES_IP[DES_C[src]] ^ 7;
4303 + dst = DES_IP[ARCH_INDEX(DES_C[src])] ^ 7;
4306 mask = 1 << (src & 3);
4307 @@ -440,12 +412,12 @@
4311 -static void init_KS()
4312 +static void init_KS(void)
4314 - int pos, chr, bit, ofs, index;
4315 + int pos, chr, round, bit, ofs;
4316 unsigned char block[64];
4319 + ARCH_WORD value[2];
4320 + int k, p, q, r, s;
4322 memset(block, 0, sizeof(block));
4324 @@ -454,22 +426,31 @@
4325 for (bit = 0; bit < 7; bit++)
4326 block[(pos << 3) + bit] = (chr >> (6 - bit)) & 1;
4329 - for (index = 0; index < 32; index++) {
4331 - for (ofs = 0; ofs < 32; ofs += 8)
4332 - for (bit = 0; bit < 6; bit++) value |=
4333 - (ARCH_WORD)block[*k++] << (ofs + bit);
4335 -#if ARCH_BITS >= 64
4337 - DES_KS_table[pos][chr][index >> 1] |=
4338 - DES_DO_SIZE_FIX(value) << 32;
4340 - DES_KS_table[pos][chr][index >> 1] =
4341 - DES_DO_SIZE_FIX(value);
4343 - DES_KS_table[pos][chr][index] = DES_DO_SIZE_FIX(value);
4345 + for (round = 0; round < 16; round++) {
4346 + s += DES_ROT[round];
4347 + value[0] = value[1] = 0;
4349 + for (ofs = 0; ofs < 64; ofs += 8)
4350 + for (bit = 0; bit < 6; bit++) {
4352 + q = p < 28 ? 0 : 28;
4354 + while (p >= 28) p -= 28;
4355 + r = DES_PC1[p + q];
4356 + value[ofs >> 5] |= (ARCH_WORD)block[r] <<
4357 + ((ofs & 31) + bit);
4360 +#if ARCH_BITS >= 64
4361 + DES_KS_table[pos][chr][round] =
4362 + DES_DO_SIZE_FIX(value[0]) |
4363 + (DES_DO_SIZE_FIX(value[1]) << 32);
4365 + DES_KS_table[pos][chr][round << 1] =
4366 + DES_DO_SIZE_FIX(value[0]);
4367 + DES_KS_table[pos][chr][(round << 1) + 1] =
4368 + DES_DO_SIZE_FIX(value[1]);
4373 memcpy(DES_KS_current, DES_KS_table, sizeof(DES_KS));
4376 -void DES_std_init()
4377 +void DES_std_init(void)
4381 @@ -618,12 +599,12 @@
4384 memcpy(DES_KS_current,
4385 - DES_KS_table[0][(ARCH_INDEX)(DES_key[0] = key[0] & 0x7F)],
4386 + DES_KS_table[0][ARCH_INDEX(DES_key[0] = key[0] & 0x7F)],
4389 pos = (DES_KS *)DES_KS_table[1][0];
4390 for (i = 1; i < 8; i++) {
4391 - DES_xor_key1(pos[(ARCH_INDEX)(DES_key[i] = key[i] & 0x7F)]);
4392 + DES_xor_key1(pos[ARCH_INDEX(DES_key[i] = key[i] & 0x7F)]);
4397 register ARCH_WORD *value1, *value2;
4400 - for (k = i = 0; (j = key[i]) && (l = DES_key[i]); i++)
4402 + for (k = i = 0; (l = DES_key[i]) && (j = key[i]); i++)
4408 if ((k < (j << 1)) && (++DES_KS_updates & 0xFFF)) {
4410 - for (i = 0; (k = key[i]) && i < 8; i++) {
4411 + for (i = 0; i < 8 && (k = key[i]); i++) {
4413 if (k == (l = DES_key[j++])) continue;
4419 - for (i = 1; (k = key[i]) && i < 8; i++)
4420 + for (i = 1; i < 8 && (k = key[i]); i++)
4421 DES_xor_key1(DES_KS_table[i][k & 0x7F]);
4428 -/* 64 bit, 4K, mask, scale */
4429 +/* 64-bit, 4K, mask, scale */
4430 #define DES_ROUND(L, H, B) \
4431 T = DES_INDEX(DES_SPE_F[0], DES_D & DES_MASK_6); \
4432 B ^= DES_INDEX(DES_SPE_F[1], (DES_D >> 8) & DES_MASK_6); \
4434 * (which is done at compile time), I moved the extra shift out of the mask,
4435 * which allows doing this with special addressing modes, where possible.
4437 -/* 64 bit, 4K, mask, no scale */
4438 +/* 64-bit, 4K, mask, no scale */
4439 #define DES_ROUND(L, H, B) \
4440 T = DES_INDEX(DES_SPE_F[0], (DES_D & (DES_MASK_6 >> 1)) << 1); \
4441 B ^= DES_INDEX(DES_SPE_F[1], (DES_D >> 7) & DES_MASK_6); \
4443 B ^= T ^ DES_INDEX(DES_SPE_F[7], (DES_D >> 55) & DES_MASK_6);
4446 -/* 64 bit, 4K, store/load, scale */
4447 +/* 64-bit, 4K, store/load, scale */
4448 #define DES_ROUND(L, H, B) \
4449 T = DES_INDEX(DES_SPE_F[0], DES_B0); \
4450 B ^= DES_INDEX(DES_SPE_F[1], DES_B1); \
4452 B ^= T ^ DES_INDEX(DES_SPE_F[7], DES_B7);
4455 -/* 64 bit, 128K, mask, no scale */
4456 +/* 64-bit, 128K, mask, no scale */
4457 #define DES_ROUND(L, H, B) \
4458 B ^= DES_INDEX(DES_SPE_W[0], DES_D & 0xFFFF); \
4459 B ^= DES_INDEX(DES_SPE_W[1], (DES_D >>= 16) & 0xFFFF); \
4464 -/* 32 bit, 4K, mask */
4465 +/* 32-bit, 4K, mask */
4466 #define DES_ROUND(L, H, B) \
4467 L ^= DES_INDEX(DES_SPE_L[0], DES_Dl & DES_MASK_6); \
4468 H ^= DES_INDEX(DES_SPE_H[0], DES_Dl & DES_MASK_6); \
4470 L ^= DES_INDEX(DES_SPE_L[7], (DES_Dh >>= 8) & DES_MASK_6); \
4471 H ^= DES_INDEX(DES_SPE_H[7], DES_Dh & DES_MASK_6);
4473 -/* 32 bit, 4K, store/load */
4474 +/* 32-bit, 4K, store/load */
4475 #define DES_ROUND(L, H, B) \
4476 L ^= DES_INDEX(DES_SPE_L[0], DES_B0); \
4477 H ^= DES_INDEX(DES_SPE_H[0], DES_B0); \
4479 H ^= DES_INDEX(DES_SPE_H[7], DES_B7);
4482 -/* 32 bit, 128K, mask */
4483 +/* 32-bit, 128K, mask */
4484 #define DES_ROUND(L, H, B) \
4485 L ^= DES_INDEX_L(DES_SPE_W[0], DES_Dl & 0xFFFF); \
4486 H ^= DES_INDEX_H(DES_SPE_W[0], DES_Dl & 0xFFFF); \
4491 -static void crypt_body()
4492 +static void crypt_body(void)
4494 void DES_std_crypt(DES_KS KS, DES_binary DES_out)
4496 @@ -1064,12 +1046,12 @@
4498 ARCH_WORD DES_raw_get_salt(char *ciphertext)
4500 - if (ciphertext[13]) return DES_atoi64[(ARCH_INDEX)ciphertext[5]] |
4501 - ((ARCH_WORD)DES_atoi64[(ARCH_INDEX)ciphertext[6]] << 6) |
4502 - ((ARCH_WORD)DES_atoi64[(ARCH_INDEX)ciphertext[7]] << 12) |
4503 - ((ARCH_WORD)DES_atoi64[(ARCH_INDEX)ciphertext[8]] << 18);
4504 - else return DES_atoi64[(ARCH_INDEX)ciphertext[0]] |
4505 - ((ARCH_WORD)DES_atoi64[(ARCH_INDEX)ciphertext[1]] << 6);
4506 + if (ciphertext[13]) return DES_atoi64[ARCH_INDEX(ciphertext[5])] |
4507 + ((ARCH_WORD)DES_atoi64[ARCH_INDEX(ciphertext[6])] << 6) |
4508 + ((ARCH_WORD)DES_atoi64[ARCH_INDEX(ciphertext[7])] << 12) |
4509 + ((ARCH_WORD)DES_atoi64[ARCH_INDEX(ciphertext[8])] << 18);
4510 + else return DES_atoi64[ARCH_INDEX(ciphertext[0])] |
4511 + ((ARCH_WORD)DES_atoi64[ARCH_INDEX(ciphertext[1])] << 6);
4514 ARCH_WORD DES_std_get_salt(char *ciphertext)
4515 @@ -1077,75 +1059,72 @@
4518 salt = DES_raw_get_salt(ciphertext);
4519 - salt = DES_TO_6_BIT(salt);
4520 + salt = DES_24_TO_32(salt);
4521 return DES_DO_SIZE_FIX(salt);
4524 ARCH_WORD DES_raw_get_count(char *ciphertext)
4526 - if (ciphertext[13]) return DES_atoi64[(ARCH_INDEX)ciphertext[1]] |
4527 - ((ARCH_WORD)DES_atoi64[(ARCH_INDEX)ciphertext[2]] << 6) |
4528 - ((ARCH_WORD)DES_atoi64[(ARCH_INDEX)ciphertext[3]] << 12) |
4529 - ((ARCH_WORD)DES_atoi64[(ARCH_INDEX)ciphertext[4]] << 18);
4530 + if (ciphertext[13]) return DES_atoi64[ARCH_INDEX(ciphertext[1])] |
4531 + ((ARCH_WORD)DES_atoi64[ARCH_INDEX(ciphertext[2])] << 6) |
4532 + ((ARCH_WORD)DES_atoi64[ARCH_INDEX(ciphertext[3])] << 12) |
4533 + ((ARCH_WORD)DES_atoi64[ARCH_INDEX(ciphertext[4])] << 18);
4537 -ARCH_WORD *DES_raw_get_binary(char *ciphertext)
4538 +ARCH_WORD *DES_do_IP(ARCH_WORD in[2])
4540 - static ARCH_WORD masks[8] = {
4541 - 0x1000, 0x0800, 0x0400, 0x0200, 0x0010, 0x0008, 0x0004, 0x0002
4543 + static ARCH_WORD out[2];
4546 - static ARCH_WORD out[4];
4547 + out[0] = out[1] = 0;
4548 + for (dst = 0; dst < 64; dst++) {
4549 + src = DES_IP[dst ^ 0x20];
4551 + if (in[src >> 5] & (1 << (src & 0x1F)))
4552 + out[dst >> 5] |= 1 << (dst & 0x1F);
4558 - int ofs, chr, bit, index, value;
4559 - unsigned char block[66], *ptr;
4560 - ARCH_WORD mask1, mask2;
4561 - ARCH_WORD Rl, Rh, Ll, Lh;
4562 +ARCH_WORD *DES_raw_get_binary(char *ciphertext)
4564 + ARCH_WORD block[3];
4566 + int ofs, chr, src, dst, value;
4568 if (ciphertext[13]) ofs = 9; else ofs = 2;
4571 + block[0] = block[1] = 0;
4573 for (chr = 0; chr < 11; chr++) {
4574 - value = DES_atoi64[(ARCH_INDEX)ciphertext[chr + ofs]];
4576 + value = DES_atoi64[ARCH_INDEX(ciphertext[chr + ofs])];
4579 - for (bit = 0; bit < 6; bit++) {
4580 - *ptr++ = value & mask1;
4582 + for (src = 0; src < 6; src++) {
4584 + block[dst >> 5] |= 1 << (dst & 0x1F);
4590 - Lh = Ll = Rh = Rl = 0;
4593 - for (index = 0; index < 8; index++) {
4594 - mask2 = (mask1 = masks[index]) << 16;
4596 - if (*ptr++) Rl |= mask1;
4597 - if (*ptr++) Ll |= mask1;
4598 - if (*ptr++) Rl |= mask2;
4599 - if (*ptr++) Ll |= mask2;
4600 - if (*ptr++) Rh |= mask1;
4601 - if (*ptr++) Lh |= mask1;
4602 - if (*ptr++) Rh |= mask2;
4603 - if (*ptr++) Lh |= mask2;
4612 + return DES_do_IP(block);
4615 ARCH_WORD *DES_std_get_binary(char *ciphertext)
4618 + static ARCH_WORD out[4];
4620 ARCH_WORD salt, mask;
4622 - out = DES_raw_get_binary(ciphertext);
4623 + raw = DES_raw_get_binary(ciphertext);
4625 + out[0] = DES_16_TO_32(raw[0]);
4626 + out[1] = DES_16_TO_32(raw[0] >> 16);
4627 + out[2] = DES_16_TO_32(raw[1]);
4628 + out[3] = DES_16_TO_32(raw[1] >> 16);
4630 out[0] = DES_DO_SIZE_FIX(out[0]);
4631 out[1] = DES_DO_SIZE_FIX(out[1]);
4632 diff -ruN john-1.6/src/DES_std.h john-1.6.34/src/DES_std.h
4633 --- john-1.6/src/DES_std.h 1998-12-03 01:29:50.000000000 +0100
4634 +++ john-1.6.34/src/DES_std.h 2000-03-24 22:22:20.000000000 +0100
4637 * This file is part of John the Ripper password cracker,
4638 - * Copyright (c) 1996-98 by Solar Designer
4639 + * Copyright (c) 1996-2000 by Solar Designer
4643 - * Standard DES implementation.
4644 + * "Standard" (non-bitslice) DES implementation.
4647 #ifndef _JOHN_DES_STD_H
4652 - * Expansion table.
4653 + * Various DES tables exported for use by other implementations.
4655 extern unsigned char DES_E[48];
4658 - * Key bits schedule.
4660 -extern unsigned char DES_K_bits[0x300];
4661 +extern unsigned char DES_PC1[56];
4662 +extern unsigned char DES_ROT[16];
4663 +extern unsigned char DES_PC2[48];
4666 * Current key schedule.
4667 @@ -108,10 +106,9 @@
4668 (DES_STD_HASH_1(x) | \
4669 (((x) >> (DES_SIZE_FIX + 9)) & 0xF00))
4671 +#ifndef DES_STD_ALGORITHM_NAME
4673 #define DES_STD_ALGORITHM_BITS "48/" ARCH_BITS_STR
4675 -#define DES_STD_ALGORITHM_BITS "48/64"
4677 #define DES_STD_ALGORITHM_BITS "24/32"
4679 @@ -122,11 +119,12 @@
4681 #define DES_STD_ALGORITHM_NAME \
4682 DES_STD_ALGORITHM_BITS " " DES_STD_ALGORITHM_SIZE
4686 * Initializes the internal structures.
4688 -extern void DES_std_init();
4689 +extern void DES_std_init(void);
4692 * Sets a salt for DES_std_crypt().
4693 @@ -178,6 +176,13 @@
4694 extern ARCH_WORD DES_raw_get_count(char *ciphertext);
4697 + * Does the Initial Permutation; to be used at startup only (doesn't
4698 + * require that DES_std_init() has been called, is not as fast as it
4701 +extern ARCH_WORD *DES_do_IP(ARCH_WORD in[2]);
4704 * Converts an ASCII ciphertext to binary.
4706 extern ARCH_WORD *DES_raw_get_binary(char *ciphertext);
4707 diff -ruN john-1.6/src/detect.c john-1.6.34/src/detect.c
4708 --- john-1.6/src/detect.c 1998-12-03 01:29:50.000000000 +0100
4709 +++ john-1.6.34/src/detect.c 2000-05-08 09:04:46.000000000 +0200
4712 * This file is part of John the Ripper password cracker,
4713 - * Copyright (c) 1996-98 by Solar Designer
4714 + * Copyright (c) 1996-2000 by Solar Designer
4719 int main(int argc, char **argv)
4724 - if (argc != 6) return 1;
4725 + if (argc != 7) return 1;
4728 + while (sizeof(long) * 8 != 1 << size_log) size_log++;
4733 "#define _JOHN_ARCH_H\n");
4736 -"#define ARCH_GENERIC\t\t\t%d\n"
4737 "#define ARCH_WORD\t\t\tlong\n"
4738 "#define ARCH_SIZE\t\t\t%d\n"
4739 "#define ARCH_BITS\t\t\t%d\n"
4740 +"#define ARCH_BITS_LOG\t\t\t%d\n"
4741 "#define ARCH_BITS_STR\t\t\t\"%d\"\n"
4742 "#define ARCH_LITTLE_ENDIAN\t\t%d\n"
4743 "#define ARCH_INT_GT_32\t\t\t%d\n"
4744 "#define ARCH_ALLOWS_UNALIGNED\t\t0\n"
4746 -"#define ARCH_INDEX\t\t\tunsigned long\n"
4747 +"#define ARCH_INDEX(x)\t\t\t((unsigned long)(unsigned char)(x))\n"
4749 -"#define ARCH_INDEX\t\t\tunsigned int\n"
4750 +"#define ARCH_INDEX(x)\t\t\t((unsigned int)(unsigned char)(x))\n"
4755 "#define OS_FLOCK\t\t\t0\n"
4764 (int)(sizeof(long) * 8),
4766 (int)(sizeof(long) * 8),
4767 (int)(*(char *)&value),
4768 (sizeof(int) > 4) ? 1 : 0);
4769 @@ -125,9 +125,13 @@
4772 "#define DES_COPY\t\t\t%c\n"
4773 +"#define DES_BS_ASM\t\t\t0\n"
4774 "#define DES_BS\t\t\t\t%c\n"
4775 +"#define DES_BS_VECTOR\t\t\t0\n"
4776 +"#define DES_BS_EXPAND\t\t\t1\n"
4778 "#define MD5_ASM\t\t\t\t0\n"
4779 +"#define MD5_X2\t\t\t\t%c\n"
4780 "#define MD5_IMM\t\t\t\t%c\n"
4782 "#define BF_ASM\t\t\t\t0\n"
4793 diff -ruN john-1.6/src/external.c john-1.6.34/src/external.c
4794 --- john-1.6/src/external.c 1998-12-03 01:29:50.000000000 +0100
4795 +++ john-1.6.34/src/external.c 2001-06-16 09:46:21.000000000 +0200
4798 * This file is part of John the Ripper password cracker,
4799 - * Copyright (c) 1996-98 by Solar Designer
4800 + * Copyright (c) 1996-2001 by Solar Designer
4809 #include "signals.h"
4810 #include "compiler.h"
4813 static char int_word[PLAINTEXT_BUFFER_SIZE];
4814 static char rec_word[PLAINTEXT_BUFFER_SIZE];
4816 -static char *ext_mode = NULL;
4817 +char *ext_mode = NULL;
4819 static c_int ext_word[PLAINTEXT_BUFFER_SIZE];
4825 -static struct c_ident *f_generate, *f_filter;
4826 +static struct c_ident *f_generate;
4827 +struct c_ident *f_filter;
4829 static struct cfg_list *ext_source;
4830 static struct cfg_line *ext_line;
4833 -static int ext_getchar()
4834 +static int ext_getchar(void)
4842 -static void ext_rewind()
4843 +static void ext_rewind(void)
4845 ext_line = ext_source->head;
4848 if (!ext_line) ext_line = ext_source->tail;
4850 fprintf(stderr, "Compiler error in %s at line %d: %s\n",
4851 - path_expand(CFG_NAME), ext_line->number,
4852 + cfg_name, ext_line->number,
4860 -int ext_filter(char *word)
4861 +int ext_filter_body(char *in, char *out)
4863 unsigned char *internal;
4866 - if (!ext_mode || !f_filter) return 1;
4868 - internal = (unsigned char *)word;
4869 + internal = (unsigned char *)in;
4870 external = ext_word;
4872 *external++ = *internal++;
4875 c_execute(f_filter);
4877 - if (word[0] && !ext_word[0]) return 0;
4878 + if (in[0] && !ext_word[0]) return 0;
4880 - internal = (unsigned char *)word;
4881 + internal = (unsigned char *)out;
4882 external = ext_word;
4884 *internal++ = *external++;
4889 -static void fix_state()
4890 +static void fix_state(void)
4892 strcpy(rec_word, int_word);
4894 diff -ruN john-1.6/src/external.h john-1.6.34/src/external.h
4895 --- john-1.6/src/external.h 1998-12-03 01:29:50.000000000 +0100
4896 +++ john-1.6.34/src/external.h 2001-06-16 09:47:26.000000000 +0200
4899 * This file is part of John the Ripper password cracker,
4900 - * Copyright (c) 1996-98 by Solar Designer
4901 + * Copyright (c) 1996-2001 by Solar Designer
4909 + * Defined for use in the ext_filter() macro, below.
4911 +extern char *ext_mode;
4912 +extern struct c_ident *f_filter;
4915 * Initializes an external mode.
4917 extern void ext_init(char *mode);
4920 * Calls an external word filter. Returns 0 if the word is rejected.
4922 -extern int ext_filter(char *word);
4923 +#define ext_filter(word) \
4924 + (!ext_mode || !f_filter || ext_filter_body(word, word))
4927 + * The actual implementation of ext_filter(); use the macro instead.
4929 +extern int ext_filter_body(char *in, char *out);
4932 * Runs the external mode cracker.
4933 diff -ruN john-1.6/src/formats.c john-1.6.34/src/formats.c
4934 --- john-1.6/src/formats.c 1998-12-03 01:29:50.000000000 +0100
4935 +++ john-1.6.34/src/formats.c 2001-06-16 08:07:01.000000000 +0200
4938 * This file is part of John the Ripper password cracker,
4939 - * Copyright (c) 1996-98 by Solar Designer
4940 + * Copyright (c) 1996-2001 by Solar Designer
4948 -int fmt_self_test(struct fmt_main *format)
4949 +char *fmt_self_test(struct fmt_main *format)
4951 + static char s_size[32];
4952 struct fmt_tests *current;
4953 char *ciphertext, *plaintext;
4955 + int index, max, size;
4956 void *binary, *salt;
4958 if (format->params.plaintext_length > PLAINTEXT_BUFFER_SIZE - 3)
4962 - if (format->methods.valid("*")) return 1;
4963 + if (format->methods.valid("*")) return "valid";
4967 - if (!(current = format->params.tests)) return 0;
4968 + if (!(current = format->params.tests)) return NULL;
4970 + index = 0; max = format->params.max_keys_per_crypt;
4971 + if (max > 2 && !(format->params.flags & FMT_BS)) max = 2;
4973 - if (format->methods.valid(current->ciphertext) != 1) break;
4974 + if (format->methods.valid(current->ciphertext) != 1)
4976 ciphertext = format->methods.split(current->ciphertext, 0);
4977 plaintext = current->plaintext;
4980 salt = format->methods.salt(ciphertext);
4982 if ((unsigned int)format->methods.salt_hash(salt) >=
4983 - SALT_HASH_SIZE) break;
4985 + return "salt_hash";
4987 format->methods.set_salt(salt);
4988 - format->methods.set_key(current->plaintext, 0);
4989 + format->methods.set_key(current->plaintext, index);
4991 - format->methods.crypt_all(1);
4992 + format->methods.crypt_all(index + 1);
4994 for (size = 0; size < 3; size++)
4995 - if (format->methods.get_hash[size](0) !=
4996 - format->methods.binary_hash[size](binary)) break;
4997 - if (size < 3) break;
4999 - if (!format->methods.cmp_all(binary, 1)) break;
5000 - if (!format->methods.cmp_one(binary, 0)) break;
5001 - if (!format->methods.cmp_exact(ciphertext, 0)) break;
5002 + if (format->methods.get_hash[size](index) !=
5003 + format->methods.binary_hash[size](binary)) {
5004 + sprintf(s_size, "get_hash[%d]", size);
5008 + if (!format->methods.cmp_all(binary, index + 1))
5010 + if (!format->methods.cmp_one(binary, index))
5012 + if (!format->methods.cmp_exact(ciphertext, index))
5013 + return "cmp_exact";
5015 + if (strncmp(format->methods.get_key(index), plaintext,
5016 + format->params.plaintext_length))
5019 - if (strncmp(format->methods.get_key(0), plaintext,
5020 - format->params.plaintext_length)) break;
5021 + index = (index << 1) + 1; /* 0, 1, 3, 7, 15, 31, 63, ... */
5022 + if (index >= max) index = 0;
5023 } while ((++current)->ciphertext);
5025 - return current->ciphertext != NULL;
5029 -void fmt_default_init()
5030 +void fmt_default_init(void)
5034 @@ -110,6 +124,10 @@
5038 +void fmt_default_clear_keys(void)
5042 int fmt_default_get_hash(int index)
5045 diff -ruN john-1.6/src/formats.h john-1.6.34/src/formats.h
5046 --- john-1.6/src/formats.h 1998-12-03 01:29:50.000000000 +0100
5047 +++ john-1.6.34/src/formats.h 2001-06-16 09:45:42.000000000 +0200
5050 * This file is part of John the Ripper password cracker,
5051 - * Copyright (c) 1996-98 by Solar Designer
5052 + * Copyright (c) 1996-2001 by Solar Designer
5058 #define FMT_CASE 0x00000001
5059 #define FMT_8_BIT 0x00000002
5060 +#define FMT_BS 0x00010000
5063 * A password to test the methods for correct operation.
5065 struct fmt_methods {
5066 /* Initializes the algorithm's internal structures, valid() is the only
5067 * method that is allowed to be called before a call to init(). */
5069 + void (*init)(void);
5071 /* Checks if an ASCII ciphertext is valid for this format. Returns zero for
5072 * invalid ciphertexts, or a number of parts the ciphertext should be split
5073 @@ -107,6 +108,11 @@
5074 /* Returns a plaintext previously set with set_key() */
5075 char *(*get_key)(int index);
5077 +/* Allow the previously set keys to be dropped if that would help improve
5078 + * performance and/or reduce the impact of certain hardware faults. After
5079 + * a call to clear_keys() the keys are undefined. */
5080 + void (*clear_keys)(void);
5082 /* Calculates the ciphertexts for given salt and plaintexts. This may
5083 * always calculate at least min_keys_per_crypt ciphertexts regardless of
5084 * the requested count, for some formats. */
5085 @@ -162,21 +168,22 @@
5086 extern void fmt_init(struct fmt_main *format);
5089 - * Tests the format's methods for correct operation. Returns a non-zero value
5091 + * Tests the format's methods for correct operation. Returns NULL on
5092 + * success, method name on error.
5094 -extern int fmt_self_test(struct fmt_main *format);
5095 +extern char *fmt_self_test(struct fmt_main *format);
5100 -extern void fmt_default_init();
5101 +extern void fmt_default_init(void);
5102 extern int fmt_default_valid(char *ciphertext);
5103 extern char *fmt_default_split(char *ciphertext, int index);
5104 extern void *fmt_default_binary(char *ciphertext);
5105 extern void *fmt_default_salt(char *ciphertext);
5106 extern int fmt_default_binary_hash(void *binary);
5107 extern int fmt_default_salt_hash(void *salt);
5108 +extern void fmt_default_clear_keys(void);
5109 extern int fmt_default_get_hash(int index);
5112 diff -ruN john-1.6/src/getopt.c john-1.6.34/src/getopt.c
5113 --- john-1.6/src/getopt.c 1998-12-03 01:29:50.000000000 +0100
5114 +++ john-1.6.34/src/getopt.c 2000-08-26 05:52:13.000000000 +0200
5117 * This file is part of John the Ripper password cracker,
5118 - * Copyright (c) 1996-98 by Solar Designer
5119 + * Copyright (c) 1996-2000 by Solar Designer
5123 @@ -105,10 +105,9 @@
5125 static int opt_check_one(struct opt_entry *list, opt_flags flg, char *opt)
5128 struct opt_entry *entry;
5130 - param = opt_find(list, opt, &entry);
5131 + opt_find(list, opt, &entry);
5132 if (!entry) return OPT_ERROR_UNKNOWN;
5134 if ((flg & entry->req_set) != entry->req_set || (flg & entry->req_clr))
5135 diff -ruN john-1.6/src/idle.c john-1.6.34/src/idle.c
5136 --- john-1.6/src/idle.c 1998-12-03 01:29:50.000000000 +0100
5137 +++ john-1.6.34/src/idle.c 2001-07-26 16:56:25.000000000 +0200
5140 * This file is part of John the Ripper password cracker,
5141 - * Copyright (c) 1996-98 by Solar Designer
5142 + * Copyright (c) 1996-2001 by Solar Designer
5148 +#ifdef _POSIX_PRIORITY_SCHEDULING
5151 -#define SCHED_IDLE 3
5154 +#include <sys/times.h>
5156 static int use_yield = 0;
5160 extern int nice(int);
5169 #include "options.h"
5170 +#include "signals.h"
5173 +void idle_init(void)
5176 +#if defined(_POSIX_PRIORITY_SCHEDULING) && defined(SCHED_IDLE)
5177 struct sched_param param = {0};
5180 if (!cfg_get_bool(SECTION_OPTIONS, NULL, "Idle")) return;
5181 if (options.flags & FLG_STDOUT) return;
5186 + set_thread_priority(getpid(), 1);
5190 - use_yield = sched_setscheduler(getpid(), SCHED_IDLE, ¶m) ? 1 : 2;
5191 +#if defined(_POSIX_PRIORITY_SCHEDULING) && defined(SCHED_IDLE)
5192 + use_yield = sched_setscheduler(getpid(), SCHED_IDLE, ¶m) != 0;
5193 +#elif defined(_POSIX_PRIORITY_SCHEDULING)
5198 -void idle_yield(int always)
5199 +void idle_yield(void)
5203 - if (use_yield == 1 || always) sched_yield();
5204 +#ifdef _POSIX_PRIORITY_SCHEDULING
5205 + static int calls_per_tick = 0;
5206 + static int calls_since_tick = 0;
5207 + static int calls_since_adj = 0;
5208 + static clock_t last_adj = 0;
5209 + clock_t last_check;
5213 + if (!use_yield) return;
5215 + if (++calls_since_tick < calls_per_tick) return;
5216 + calls_since_adj += calls_since_tick;
5217 + calls_since_tick = 0;
5219 + current = times(&buf);
5220 + if (!last_adj) last_adj = current;
5222 + if (current - last_adj >= CLK_TCK) {
5223 + calls_per_tick = calls_since_adj / (current - last_adj);
5224 + calls_since_adj = 0;
5225 + last_adj = current;
5229 + if (event_pending) break;
5230 + last_check = current;
5232 + current = times(&buf);
5233 + } while (current - last_check > 1 && current - last_adj < CLK_TCK);
5236 diff -ruN john-1.6/src/idle.h john-1.6.34/src/idle.h
5237 --- john-1.6/src/idle.h 1998-12-03 01:29:50.000000000 +0100
5238 +++ john-1.6.34/src/idle.h 2001-05-08 22:37:37.000000000 +0200
5241 * This file is part of John the Ripper password cracker,
5242 - * Copyright (c) 1996-98 by Solar Designer
5243 + * Copyright (c) 1996-2001 by Solar Designer
5248 * Sets this process to idle priority, if supported and enabled in the
5249 * configuration file.
5251 -extern void idle_init();
5252 +extern void idle_init(void);
5255 * If the idle_init() call was unable to set the idle priority, this can
5256 * still be used to yield a timeslice if there's something else to do.
5258 -extern void idle_yield(int always);
5259 +extern void idle_yield(void);
5262 diff -ruN john-1.6/src/inc.c john-1.6.34/src/inc.c
5263 --- john-1.6/src/inc.c 1998-12-03 01:29:50.000000000 +0100
5264 +++ john-1.6.34/src/inc.c 2003-06-29 15:18:57.000000000 +0200
5267 * This file is part of John the Ripper password cracker,
5268 - * Copyright (c) 1996-98 by Solar Designer
5269 + * Copyright (c) 1996-2003 by Solar Designer
5274 typedef char (*chars_table)
5275 [CHARSET_SIZE + 1][CHARSET_SIZE + 1][CHARSET_SIZE + 1];
5277 +static int rec_compat;
5278 static int rec_entry;
5279 static int rec_numbers[CHARSET_LENGTH];
5285 - fprintf(file, "%d\n", rec_entry);
5286 + fprintf(file, "%d\n%d\n%d\n", rec_entry, rec_compat, CHARSET_LENGTH);
5287 for (pos = 0; pos < CHARSET_LENGTH; pos++)
5288 fprintf(file, "%d\n", rec_numbers[pos]);
5291 static int restore_state(FILE *file)
5296 if (fscanf(file, "%d\n", &rec_entry) != 1) return 1;
5297 - for (pos = 0; pos < CHARSET_LENGTH; pos++) {
5299 + length = CHARSET_LENGTH;
5300 + if (rec_version >= 2) {
5301 + if (fscanf(file, "%d\n%d\n", &rec_compat, &length) != 2)
5303 + if ((unsigned int)rec_compat > 1) return 1;
5304 + if ((unsigned int)length > CHARSET_LENGTH) return 1;
5306 + for (pos = 0; pos < length; pos++) {
5307 if (fscanf(file, "%d\n", &rec_numbers[pos]) != 1) return 1;
5308 if ((unsigned int)rec_numbers[pos] >= CHARSET_SIZE) return 1;
5314 -static void fix_state()
5315 +static void fix_state(void)
5318 memcpy(rec_numbers, numbers, sizeof(rec_numbers));
5319 @@ -164,11 +174,11 @@
5320 memset(present, 0, sizeof(present));
5322 if (--count <= 1) return;
5323 - present[((ARCH_INDEX)*dptr++) - CHARSET_MIN] = 1;
5324 + present[ARCH_INDEX(*dptr++) - CHARSET_MIN] = 1;
5328 - if (!present[(ARCH_INDEX)*sptr - CHARSET_MIN]) {
5329 + if (!present[ARCH_INDEX(*sptr) - CHARSET_MIN]) {
5331 if (--count <= 1) break;
5333 @@ -208,36 +218,86 @@
5334 static int inc_key_loop(int length, int fixed, int count,
5335 char *char1, char2_table char2, chars_table *chars)
5337 - char key[PLAINTEXT_BUFFER_SIZE];
5338 + char key_i[PLAINTEXT_BUFFER_SIZE];
5339 + char key_e[PLAINTEXT_BUFFER_SIZE];
5341 + char *chars_cache;
5342 + int numbers_cache;
5345 - key[length + 1] = 0;
5346 + key_i[length + 1] = 0;
5347 numbers[fixed] = count;
5350 - key[0] = char1[numbers[0]];
5351 + chars_cache = NULL;
5358 + key_i[0] = char1[numbers[0]];
5360 - key[1] = (*char2)[key[0] - CHARSET_MIN][numbers[1]];
5361 - for (pos = 2; pos <= length; pos++)
5362 - key[pos] = (*chars[pos - 2])
5363 - [(ARCH_INDEX)key[pos - 2] - CHARSET_MIN]
5364 - [(ARCH_INDEX)key[pos - 1] - CHARSET_MIN]
5367 - if (ext_filter(key))
5368 - if (crk_process_key(key)) return 1;
5373 - if (pos == fixed) continue;
5374 - if (++numbers[pos] <= count -
5375 - ((pos < fixed) ? 1 : 0)) break;
5377 - } while (++pos <= length);
5379 - if (++numbers[0] <= count) pos = 0; else break;
5380 - } while (pos <= length);
5381 + key_i[1] = (*char2)[key_i[0] - CHARSET_MIN][numbers[1]];
5384 + while (pos < length) {
5385 + key_i[pos] = (*chars[pos - 2])
5386 + [ARCH_INDEX(key_i[pos - 2]) - CHARSET_MIN]
5387 + [ARCH_INDEX(key_i[pos - 1]) - CHARSET_MIN]
5391 + numbers_cache = numbers[length];
5392 + if (pos == length) {
5393 + chars_cache = (*chars[pos - 2])
5394 + [ARCH_INDEX(key_i[pos - 2]) - CHARSET_MIN]
5395 + [ARCH_INDEX(key_i[pos - 1]) - CHARSET_MIN];
5397 + key_i[length] = chars_cache[numbers_cache];
5401 + if (!ext_mode || !f_filter || ext_filter_body(key_i, key = key_e))
5402 + if (crk_process_key(key)) return 1;
5404 + if (rec_compat) goto compat;
5407 + if (fixed < length) {
5408 + if (++numbers_cache <= count) {
5409 + if (length >= 2) goto update_last;
5410 + numbers[length] = numbers_cache;
5411 + goto update_ending;
5413 + numbers[pos--] = 0;
5414 + while (pos > fixed) {
5415 + if (++numbers[pos] <= count) goto update_ending;
5416 + numbers[pos--] = 0;
5419 + while (pos-- > 0) {
5420 + if (++numbers[pos] < count) goto update_ending;
5429 + if (++numbers[0] < count) goto update_all;
5430 + if (!length && numbers[0] <= count) goto update_all;
5433 + while (pos < fixed) {
5434 + if (++numbers[pos] < count) goto update_all;
5435 + numbers[pos++] = 0;
5438 + while (++pos <= length) {
5439 + if (++numbers[pos] <= count) goto update_all;
5445 @@ -279,6 +339,29 @@
5446 max_length = CHARSET_LENGTH;
5447 max_count = cfg_get_int(SECTION_INC, mode, "CharCount");
5449 + if (min_length > max_length) {
5450 + fprintf(stderr, "MinLen = %d exceeds MaxLen = %d\n",
5451 + min_length, max_length);
5455 + if (max_length > CHARSET_LENGTH) {
5458 + "MaxLen = %d exceeds the compile-time limit of %d\n\n"
5459 + "There're several good reasons why you probably don't "
5460 + "need to raise it:\n"
5461 + "- many hash types don't support passwords "
5462 + "(or password halves) longer than\n"
5463 + "7 or 8 characters;\n"
5464 + "- you probably don't have sufficient statistical "
5465 + "information to generate a\n"
5466 + "charset file for lengths beyond 8;\n"
5467 + "- the limitation applies to incremental mode only.\n",
5468 + max_length, CHARSET_LENGTH);
5472 if (!(file = fopen(path_expand(charset), "rb")))
5473 pexit("fopen: %s", path_expand(charset));
5477 if (max_count < 0) max_count = CHARSET_SIZE; else
5478 if ((unsigned int)max_count > real_count)
5479 - fprintf(stderr,"Warning: only %d characters available\n",
5480 + fprintf(stderr, "Warning: only %d characters available\n",
5483 if (header->length >= 2)
5485 for (pos = 0; pos < (int)header->length - 2; pos++)
5486 chars[pos] = (chars_table)mem_alloc(sizeof(*chars[0]));
5490 memset(rec_numbers, 0, sizeof(rec_numbers));
5492 diff -ruN john-1.6/src/john.c john-1.6.34/src/john.c
5493 --- john-1.6/src/john.c 1998-12-03 01:29:50.000000000 +0100
5494 +++ john-1.6.34/src/john.c 2002-04-11 19:58:45.000000000 +0200
5497 * This file is part of John the Ripper password cracker,
5498 - * Copyright (c) 1996-98 by Solar Designer
5499 + * Copyright (c) 1996-2002 by Solar Designer
5503 +#include <unistd.h>
5506 #include <sys/stat.h>
5510 #include "signals.h"
5513 #include "formats.h"
5519 -extern int CPU_detect();
5520 +extern int CPU_detect(void);
5523 extern struct fmt_main fmt_DES, fmt_BSDI, fmt_MD5, fmt_BF;
5525 fmt_register(format);
5528 -static void john_register_all()
5529 +static void john_register_all(void)
5531 if (options.format) strlwr(options.format);
5537 -static void john_load()
5538 +static void john_load(void)
5540 struct list_entry *current;
5542 @@ -172,6 +172,13 @@
5544 if (!CPU_detect()) {
5547 +#if defined(__DJGPP__) || defined(__CYGWIN32__)
5548 +#error CPU_FALLBACK is incompatible with the current DOS and Win32 code
5550 + execv(JOHN_SYSTEMWIDE_EXEC "/" CPU_FALLBACK_BINARY, argv);
5553 fprintf(stderr, "Sorry, %s is required\n", CPU_NAME);
5556 @@ -179,19 +186,26 @@
5560 - cfg_init(CFG_NAME);
5562 +#if JOHN_SYSTEMWIDE
5563 + cfg_init(CFG_PRIVATE_FULL_NAME, 1);
5564 + cfg_init(CFG_PRIVATE_ALT_NAME, 1);
5566 + cfg_init(CFG_FULL_NAME, 1);
5567 + cfg_init(CFG_ALT_NAME, 0);
5569 status_init(NULL, 1);
5570 opt_init(argc, argv);
5572 john_register_all();
5575 - sig_init(idle_yield);
5581 -static void john_run()
5582 +static void john_run(void)
5584 if (options.flags & FLG_TEST_CHK)
5590 -static void john_done()
5591 +static void john_done(void)
5595 @@ -259,14 +273,6 @@
5596 name[strlen(name) - 4] = 0;
5599 - if (!strcmp(name, "john")) {
5600 - john_init(argc, argv);
5607 if (!strcmp(name, "unshadow"))
5608 return unshadow(argc, argv);
5611 if (!strcmp(name, "unique"))
5612 return unique(argc, argv);
5614 - fprintf(stderr, "Sorry, I can't find myself\n");
5616 + john_init(argc, argv);
5622 diff -ruN john-1.6/src/LM_fmt.c john-1.6.34/src/LM_fmt.c
5623 --- john-1.6/src/LM_fmt.c 1998-12-03 01:29:50.000000000 +0100
5624 +++ john-1.6.34/src/LM_fmt.c 2001-08-19 05:06:18.000000000 +0200
5627 * This file is part of John the Ripper password cracker,
5628 - * Copyright (c) 1996-98 by Solar Designer
5629 + * Copyright (c) 1996-2001 by Solar Designer
5635 -#include "DES_std.h"
5637 +#include "memory.h"
5638 +#include "DES_bs.h"
5640 #include "formats.h"
5643 #define CIPHERTEXT_LENGTH 32
5645 #define LM_EMPTY "AAD3B435B51404EE"
5646 +#define LM_EMPTY_LOWER "aad3b435b51404ee"
5648 static struct fmt_tests tests[] = {
5649 - {"$LM$1C3A2B6D939A1021", "AAA"},
5650 + {"$LM$A9C604D244C4E99D", "AAAAAA"},
5651 {"$LM$CBC501A4D2227783", "AAAAAAA"},
5652 - {"$LM$CE045FF77F9D89E2", "ZZZZ"},
5653 + {"$LM$3466C2B0487FE39A", "CRACKPO"},
5654 + {"$LM$DBC5E5CBA8028091", "IMPUNIT"},
5655 {LM_EMPTY LM_EMPTY, ""},
5656 - {"$LM$7584248B8D2C9F9E", "A"},
5657 + {"$LM$73CC402BD3E79175", "SCLEROS"},
5658 + {"$LM$5ECD9236D21095CE", "YOKOHAM"},
5659 + {"$LM$A5E6066DE61C3E35", "ZZZZZZZ"},
5660 + {"$LM$1FB363FEB834C12D", "ZZZZZZ"},
5664 -#define ALGORITHM_NAME DES_STD_ALGORITHM_NAME
5665 +#define ALGORITHM_NAME DES_BS_ALGORITHM_NAME
5667 #define BINARY_SIZE ARCH_SIZE
5670 -#define MIN_KEYS_PER_CRYPT 0x40
5671 -#define MAX_KEYS_PER_CRYPT 0x40
5672 +#define MIN_KEYS_PER_CRYPT DES_BS_DEPTH
5673 +#define MAX_KEYS_PER_CRYPT DES_BS_DEPTH
5675 -#define LM_IV_0 0x2153474B
5676 -#define LM_IV_1 0x25242340
5681 - DES_binary binary;
5683 - char key[PLAINTEXT_LENGTH + 1];
5684 -} buffer[MAX_KEYS_PER_CRYPT];
5686 -static DES_binary LM_IV;
5691 - DES_std_set_salt(0);
5694 - DES_std_set_block(LM_IV_0, LM_IV_1);
5695 - memcpy(LM_IV, DES_IV, sizeof(DES_binary));
5696 +static void init(void)
5701 static int valid(char *ciphertext)
5704 + char lower[CIPHERTEXT_LENGTH - 16 + 1];
5706 - for (pos = ciphertext; atoi16[(ARCH_INDEX)*pos] != 0x7F; pos++);
5707 + for (pos = ciphertext; atoi16[ARCH_INDEX(*pos)] != 0x7F; pos++);
5708 if (!*pos && pos - ciphertext == CIPHERTEXT_LENGTH) {
5709 - if (strcmp(&ciphertext[16], LM_EMPTY))
5710 + strcpy(lower, &ciphertext[16]);
5712 + if (strcmp(lower, LM_EMPTY_LOWER))
5718 if (strncmp(ciphertext, "$LM$", 4)) return 0;
5720 - for (pos = &ciphertext[4]; atoi16[(ARCH_INDEX)*pos] != 0x7F; pos++);
5721 + for (pos = &ciphertext[4]; atoi16[ARCH_INDEX(*pos)] != 0x7F; pos++);
5722 if (*pos || pos - ciphertext != 20) return 0;
5725 @@ -103,149 +95,65 @@
5727 static void *get_binary(char *ciphertext)
5729 - static DES_binary out;
5730 - ARCH_WORD_32 block[2];
5733 - block[0] = block[1] = 0;
5734 - for (index = 0; index < 16; index += 2) {
5735 - value = (int)atoi16[(ARCH_INDEX)ciphertext[index + 4]] << 4;
5736 - value |= atoi16[(ARCH_INDEX)ciphertext[index + 5]];
5738 - block[index >> 3] |= value << ((index << 2) & 0x18);
5741 - DES_std_set_block(block[0], block[1]);
5742 - memcpy(out, DES_IV, sizeof(DES_binary));
5745 + return DES_bs_get_binary_LM(ciphertext + 4);
5748 static int binary_hash_0(void *binary)
5750 - return DES_STD_HASH_0(*(ARCH_WORD *)binary);
5751 + return *(ARCH_WORD *)binary & 0xF;
5754 static int binary_hash_1(void *binary)
5756 - return DES_STD_HASH_1(*(ARCH_WORD *)binary);
5757 + return *(ARCH_WORD *)binary & 0xFF;
5760 static int binary_hash_2(void *binary)
5762 - return DES_STD_HASH_2(*(ARCH_WORD *)binary);
5763 + return *(ARCH_WORD *)binary & 0xFFF;
5766 static int get_hash_0(int index)
5768 - return DES_STD_HASH_0(buffer[index].aligned.binary[0]);
5769 + return DES_bs_get_hash(index, 4);
5772 static int get_hash_1(int index)
5776 - binary = buffer[index].aligned.binary[0];
5777 - return DES_STD_HASH_1(binary);
5778 + return DES_bs_get_hash(index, 8);
5781 static int get_hash_2(int index)
5785 - binary = buffer[index].aligned.binary[0];
5786 - return DES_STD_HASH_2(binary);
5787 + return DES_bs_get_hash(index, 12);
5790 static void set_salt(void *salt)
5794 -static void crypt_all(int count)
5797 - unsigned char *key7;
5800 - ARCH_WORD_32 w[2];
5803 - for (index = 0; index < count; index++) {
5804 - key7 = (unsigned char *)buffer[index].key;
5805 - key8.b[0] = key7[0] >> 1;
5806 - key8.b[1] = ((key7[0] & 0x01) << 6) | (key7[1] >> 2);
5807 - key8.b[2] = ((key7[1] & 0x03) << 5) | (key7[2] >> 3);
5808 - key8.b[3] = ((key7[2] & 0x07) << 4) | (key7[3] >> 4);
5809 - key8.b[4] = ((key7[3] & 0x0F) << 3) | (key7[4] >> 5);
5810 - key8.b[5] = ((key7[4] & 0x1F) << 2) | (key7[5] >> 6);
5811 - key8.b[6] = ((key7[5] & 0x3F) << 1) | (key7[6] >> 7);
5812 - key8.b[7] = key7[6];
5813 - key8.w[0] |= 0x80808080;
5814 - key8.w[1] |= 0x80808080;
5816 - DES_std_set_key(key8.b);
5818 - DES_IV[0] = LM_IV[0];
5819 - DES_IV[1] = LM_IV[1];
5821 - DES_IV[2] = LM_IV[2];
5822 - DES_IV[3] = LM_IV[3];
5825 - DES_std_crypt(DES_KS_current, buffer[index].aligned.binary);
5829 static int cmp_all(void *binary, int count)
5833 - for (index = 0; index < count; index++)
5834 - if (*(unsigned ARCH_WORD *)binary == buffer[index].aligned.binary[0])
5838 + return DES_bs_cmp_all((ARCH_WORD *)binary);
5841 static int cmp_one(void *binary, int index)
5843 - return *(unsigned ARCH_WORD *)binary ==
5844 - buffer[index].aligned.binary[0];
5845 + return DES_bs_cmp_one((ARCH_WORD *)binary, 32, index);
5848 static int cmp_exact(char *source, int index)
5850 - ARCH_WORD *binary;
5853 - binary = (ARCH_WORD *)get_binary(source);
5855 - for (word = 0; word < 16 / DES_SIZE; word++)
5856 - if ((unsigned ARCH_WORD)binary[word] !=
5857 - buffer[index].aligned.binary[word])
5863 -static void set_key(char *key, int index)
5865 - char *dst = buffer[index].key;
5867 - int count = PLAINTEXT_LENGTH;
5870 - if (*src >= 'a' && *src <= 'z')
5871 - *dst++ = *src++ & ~0x20;
5873 - if ((*dst++ = *src)) src++;
5874 - } while (--count);
5876 + return DES_bs_cmp_one(get_binary(source), 64, index);
5879 static char *get_key(int index)
5881 - return buffer[index].key;
5882 +#if !DES_BS_VECTOR && ARCH_BITS >= 64
5883 + return (char *)DES_bs_all.E.extras.keys[index];
5885 + return (char *)DES_bs_all.keys[index];
5889 struct fmt_main fmt_LM = {
5895 + FMT_8_BIT | FMT_BS,
5899 @@ -275,9 +183,10 @@
5901 fmt_default_salt_hash,
5904 + DES_bs_set_key_LM,
5907 + DES_bs_clear_keys_LM,
5908 + (void (*)(int))DES_bs_crypt_LM,
5912 diff -ruN john-1.6/src/loader.c john-1.6.34/src/loader.c
5913 --- john-1.6/src/loader.c 1998-12-03 01:29:50.000000000 +0100
5914 +++ john-1.6.34/src/loader.c 2000-08-26 05:59:56.000000000 +0200
5917 * This file is part of John the Ripper password cracker,
5918 - * Copyright (c) 1996-98 by Solar Designer
5919 + * Copyright (c) 1996-2000 by Solar Designer
5924 * Word separator characters for ldr_split_words(), used on GECOS fields.
5927 - "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~\177\377"
5928 + "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~\177"
5930 static char issep_map[0x100];
5931 static int issep_initialized = 0;
5933 if (fclose(file)) pexit("fclose");
5936 -static void ldr_init_issep()
5937 +static void ldr_init_issep(void)
5943 memset(issep_map, 1, 33);
5944 for (pos = issep; *pos; pos++)
5945 - issep_map[(ARCH_INDEX)*pos] = 1;
5946 + issep_map[ARCH_INDEX(*pos)] = 1;
5948 issep_initialized = 1;
5950 @@ -246,11 +246,11 @@
5954 - while (*word && issep_map[(ARCH_INDEX)*word]) word++;
5955 + while (*word && issep_map[ARCH_INDEX(*word)]) word++;
5959 - while (!issep_map[(ARCH_INDEX)*pos]) pos++;
5960 + while (!issep_map[ARCH_INDEX(*pos)]) pos++;
5961 if (*pos) *pos++ = 0;
5963 list_add_unique(dst, word);
5965 if (!current_salt) {
5966 last_salt = db->salt_hash[salt_hash];
5967 current_salt = db->salt_hash[salt_hash] =
5968 - mem_alloc_tiny(sizeof(struct db_salt),
5970 + mem_alloc_tiny(salt_size, MEM_ALIGN_WORD);
5971 current_salt->next = last_salt;
5973 current_salt->salt = mem_alloc_copy(
5975 for (size = 2; size >= 0; size--)
5976 if (current->count >= password_hash_thresholds[size]) break;
5978 + if ((db->format->params.flags & FMT_BS) && !size) size = -1;
5980 if (size >= 0 && mem_saving_level < 2) {
5981 current->hash = mem_alloc_tiny(
5982 password_hash_sizes[size] *
5983 diff -ruN john-1.6/src/logger.c john-1.6.34/src/logger.c
5984 --- john-1.6/src/logger.c 1998-12-03 01:29:50.000000000 +0100
5985 +++ john-1.6.34/src/logger.c 1999-09-22 05:57:17.000000000 +0200
5988 * This file is part of John the Ripper password cracker,
5989 - * Copyright (c) 1996-98 by Solar Designer
5990 + * Copyright (c) 1996-99 by Solar Designer
5995 cfg_beep = cfg_get_bool(SECTION_OPTIONS, NULL, "Beep");
5998 -static void log_write()
5999 +static void log_write(void)
6004 write_loop(fileno(stderr), "\007", 1);
6008 +void log_flush(void)
6011 if (log_bufptr != log_buffer) log_write();
6017 +void log_done(void)
6021 diff -ruN john-1.6/src/logger.h john-1.6.34/src/logger.h
6022 --- john-1.6/src/logger.h 1998-12-03 01:29:50.000000000 +0100
6023 +++ john-1.6.34/src/logger.h 1999-09-22 05:41:22.000000000 +0200
6026 * This file is part of John the Ripper password cracker,
6027 - * Copyright (c) 1996-98 by Solar Designer
6028 + * Copyright (c) 1996-99 by Solar Designer
6034 * Writes the log file buffer to disk.
6036 -extern void log_flush();
6037 +extern void log_flush(void);
6040 * Closes the log file.
6042 -extern void log_done();
6043 +extern void log_done(void);
6046 diff -ruN john-1.6/src/Makefile john-1.6.34/src/Makefile
6047 --- john-1.6/src/Makefile 1998-12-03 01:29:50.000000000 +0100
6048 +++ john-1.6.34/src/Makefile 2003-06-29 15:16:53.000000000 +0200
6051 # This file is part of John the Ripper password cracker,
6052 -# Copyright (c) 1996-98 by Solar Designer
6053 +# Copyright (c) 1996-2003 by Solar Designer
6066 OPT_NORMAL = -funroll-loops
6067 OPT_INLINE = -finline-functions
6070 +JOHN_VERSION = 1.6.34
6071 JOHN_ARCHIVE = john-$(JOHN_VERSION)
6074 $(JOHN_ARCHIVE)/src/*.{c,h,S,sh,asm,com,diff} \
6075 $(JOHN_ARCHIVE)/src/Makefile{,.dep} \
6076 - $(JOHN_ARCHIVE)/run/{mailer,john.ini,*.chr,password.lst} \
6077 + $(JOHN_ARCHIVE)/run/{mailer,john.conf,*.chr,password.lst} \
6078 $(JOHN_ARCHIVE)/doc/* \
6079 $(JOHN_ARCHIVE)/README
6082 - DES_fmt.o DES_std.o \
6083 +JOHN_OBJS_MINIMAL = \
6084 + DES_fmt.o DES_std.o DES_bs.o \
6086 MD5_fmt.o MD5_std.o \
6093 + $(JOHN_OBJS_MINIMAL) \
6100 - DES_bs.o DES_bs_b.o
6102 BENCH_DES_OBJS_ORIG = \
6106 $(BENCH_DES_OBJS_ORIG)
6108 BENCH_MD5_OBJS_DEPEND = \
6110 + MD5_fmt.o MD5_std.o
6112 BENCH_BF_OBJS_DEPEND = \
6116 - $(BITSLICE_OBJS) \
6117 $(BENCH_DES_OBJS_DEPEND) \
6118 - MD5_fmt.o $(BENCH_MD5_OBJS_DEPEND) \
6119 + DES_bs.o DES_bs_b.o \
6120 + $(BENCH_MD5_OBJS_DEPEND) \
6121 BF_fmt.o $(BENCH_BF_OBJS_DEPEND) \
6122 bench.o best.o common.o config.o formats.o memory.o misc.o params.o \
6123 path.o signals.o tty.o
6124 @@ -82,125 +84,135 @@
6125 @echo "where SYSTEM can be one of the following:"
6126 @echo "linux-x86-any-elf Linux, x86, ELF binaries"
6127 @echo "linux-x86-mmx-elf Linux, x86 with MMX, ELF binaries"
6128 - @echo "linux-x86-k6-elf Linux, AMD K6, ELF binaries"
6129 @echo "linux-x86-any-a.out Linux, x86, a.out binaries"
6130 @echo "linux-alpha Linux, Alpha"
6131 - @echo "linux-sparc Linux, SPARC"
6132 - @echo "freebsd-x86-any-a.out FreeBSD, x86, a.out binaries"
6133 - @echo "freebsd-x86-k6-a.out FreeBSD, AMD K6, a.out binaries"
6134 + @echo "linux-sparc Linux, SPARC 32-bit"
6135 + @echo "linux-ppc Linux, PowerPC"
6136 @echo "freebsd-x86-any-elf FreeBSD, x86, ELF binaries"
6137 @echo "freebsd-x86-mmx-elf FreeBSD, x86 with MMX, ELF binaries"
6138 - @echo "freebsd-x86-k6-elf FreeBSD, AMD K6, ELF binaries"
6139 + @echo "freebsd-x86-any-a.out FreeBSD, x86, a.out binaries"
6140 + @echo "freebsd-alpha FreeBSD, Alpha"
6141 @echo "openbsd-x86-any OpenBSD, x86"
6142 - @echo "openbsd-x86-k6 OpenBSD, AMD K6"
6143 - @echo "solaris-sparc-gcc Solaris, SPARC, gcc"
6144 - @echo "solaris-sparc-v8-cc Solaris, SPARC V8, cc"
6145 - @echo "solaris-sparc-v9-cc Solaris, SPARC V9, cc"
6146 + @echo "openbsd-sparc OpenBSD, SPARC 32-bit"
6147 + @echo "openbsd-vax OpenBSD, VAX"
6148 + @echo "netbsd-vax NetBSD, VAX"
6149 + @echo "solaris-sparc-gcc Solaris, SPARC 32-bit, gcc"
6150 + @echo "solaris-sparc64-gcc Solaris, SPARC V9 64-bit, gcc"
6151 + @echo "solaris-sparc-v8-cc Solaris, SPARC V8 32-bit, cc"
6152 + @echo "solaris-sparc-v9-cc Solaris, SPARC V9 32-bit, cc"
6153 + @echo "solaris-sparc64-cc Solaris, SPARC V9 64-bit, cc"
6154 @echo "solaris-x86-any Solaris, x86, gcc"
6155 - @echo "solaris-x86-k6 Solaris, AMD K6, gcc"
6156 - @echo "digital-alpha-cc Digital UNIX, Alpha, cc"
6157 + @echo "sco-x86-any-gcc SCO, x86, gcc, ELF binaries"
6158 + @echo "sco-x86-any-cc SCO, x86, cc, ELF binaries"
6159 + @echo "tru64-alpha-cc Tru64 (Digital UNIX, OSF/1), Alpha, cc"
6160 @echo "aix-ppc-cc AIX, PowerPC, cc"
6161 + @echo "macosx-ppc-cc MacOS X, PowerPC, cc"
6162 @echo "hpux-pa-risc-gcc HP-UX, PA-RISC, gcc"
6163 - @echo "hpux-pa-risc-cc HP-UX, PA-RISC, cc"
6164 + @echo "hpux-pa-risc-cc HP-UX, PA-RISC, ANSI cc"
6165 @echo "irix-mips32-cc IRIX, MIPS 32-bit, cc"
6166 @echo "irix-mips64-cc IRIX, MIPS 64-bit, cc"
6167 + @echo "irix-mips64-r10k-cc IRIX, MIPS 64-bit (R10K), cc"
6168 @echo "dos-djgpp-x86-any DOS, DJGPP 2.x, x86"
6169 @echo "dos-djgpp-x86-mmx DOS, DJGPP 2.x, x86 with MMX"
6170 - @echo "dos-djgpp-x86-k6 DOS, DJGPP 2.x, AMD K6"
6171 @echo "win32-cygwin-x86-any Win32, Cygwin, x86"
6172 @echo "win32-cygwin-x86-mmx Win32, Cygwin, x86 with MMX"
6173 - @echo "win32-cygwin-x86-k6 Win32, Cygwin, AMD K6"
6174 - @echo "generic Any other UNIX system with gcc"
6175 + @echo "beos-x86-any BeOS, x86"
6176 + @echo "beos-x86-mmx BeOS, x86 with MMX"
6177 + @echo "generic Any other Unix system with gcc"
6180 $(LN) x86-any.h arch.h
6182 - JOHN_OBJS="$(JOHN_OBJS) x86.o" \
6183 - CFLAGS="$(CFLAGS) -m486"
6184 + JOHN_OBJS="$(JOHN_OBJS) x86.o"
6187 $(LN) x86-mmx.h arch.h
6189 - JOHN_OBJS="$(JOHN_OBJS) x86.o" \
6190 - CFLAGS="$(CFLAGS) -m486"
6193 - $(LN) x86-k6.h arch.h
6195 - JOHN_OBJS="$(BITSLICE_OBJS) $(JOHN_OBJS) x86.o"
6196 + JOHN_OBJS="$(JOHN_OBJS_MINIMAL) x86.o x86-mmx.o"
6198 linux-x86-any-a.out:
6199 $(LN) x86-any.h arch.h
6201 JOHN_OBJS="$(JOHN_OBJS) x86.o" \
6202 - CFLAGS="$(CFLAGS) -m486" \
6203 ASFLAGS="$(ASFLAGS) -DUNDERSCORES -DALIGN_LOG"
6206 $(LN) alpha.h arch.h
6208 - JOHN_OBJS="$(BITSLICE_OBJS) $(JOHN_OBJS) alpha.o"
6209 + JOHN_OBJS="$(JOHN_OBJS) alpha.o"
6211 -linux-alpha-very-slow-cache:
6212 - $(LN) alpha-4k.h arch.h
6213 +# This target is currently "undocumented" as ccc generates much slower
6214 +# code for the large unrolled loops in John; let's hope it gets fixed.
6216 + $(LN) alpha.h arch.h
6218 + CPP=ccc CC=ccc AS=ccc LD=ccc \
6219 + CFLAGS="-c -Wf,-switch,noil_schedule" \
6220 + OPT_NORMAL="-fast" \
6221 + OPT_INLINE="-O2 -arch host" \
6222 JOHN_OBJS="$(JOHN_OBJS) alpha.o"
6225 - $(MAKE) HAMMER=use-linux-sparc sparc.h
6226 - ln -s sparc.h arch.h
6227 + $(MAKE) use-linux-sparc HAMMER=use-linux-sparc NAIL=sparc.h
6228 + $(LN) sparc.h arch.h
6229 $(MAKE) use-linux-sparc NAIL="$(PROJ)"
6233 BENCH_DES_OBJS_DEPEND="$(BENCH_DES_OBJS_ORIG) sparc.o" \
6234 - JOHN_OBJS="$(BITSLICE_OBJS) $(JOHN_OBJS_ORIG) sparc.o"
6236 -freebsd-x86-any-a.out:
6237 - $(LN) x86-any.h arch.h
6239 - JOHN_OBJS="$(JOHN_OBJS) x86.o" \
6240 - CFLAGS="$(CFLAGS) -m486" \
6241 - ASFLAGS="$(ASFLAGS) -DUNDERSCORES -DALIGN_LOG -DBSD"
6242 + JOHN_OBJS="$(JOHN_OBJS_ORIG) sparc.o"
6244 -freebsd-x86-k6-a.out:
6245 - $(LN) x86-k6.h arch.h
6247 - JOHN_OBJS="$(BITSLICE_OBJS) $(JOHN_OBJS) x86.o" \
6248 - ASFLAGS="$(ASFLAGS) -DUNDERSCORES -DALIGN_LOG -DBSD"
6250 + $(LN) ppc.h arch.h
6253 freebsd-x86-any-elf:
6254 $(LN) x86-any.h arch.h
6256 JOHN_OBJS="$(JOHN_OBJS) x86.o" \
6257 - CFLAGS="$(CFLAGS) -m486" \
6258 ASFLAGS="$(ASFLAGS) -DBSD"
6260 freebsd-x86-mmx-elf:
6261 $(LN) x86-mmx.h arch.h
6263 - JOHN_OBJS="$(JOHN_OBJS) x86.o" \
6264 - CFLAGS="$(CFLAGS) -m486" \
6265 + JOHN_OBJS="$(JOHN_OBJS_MINIMAL) x86.o x86-mmx.o" \
6266 ASFLAGS="$(ASFLAGS) -DBSD"
6268 -freebsd-x86-k6-elf:
6269 - $(LN) x86-k6.h arch.h
6270 +freebsd-x86-any-a.out:
6271 + $(LN) x86-any.h arch.h
6273 - JOHN_OBJS="$(BITSLICE_OBJS) $(JOHN_OBJS) x86.o" \
6274 - ASFLAGS="$(ASFLAGS) -DBSD"
6275 + JOHN_OBJS="$(JOHN_OBJS) x86.o" \
6276 + ASFLAGS="$(ASFLAGS) -DUNDERSCORES -DALIGN_LOG -DBSD"
6279 + $(LN) alpha.h arch.h
6281 + JOHN_OBJS="$(JOHN_OBJS) alpha.o"
6284 $(LN) x86-any.h arch.h
6286 JOHN_OBJS="$(JOHN_OBJS) x86.o" \
6287 - CFLAGS="$(CFLAGS) -m486" \
6288 ASFLAGS="$(ASFLAGS) -DUNDERSCORES -DALIGN_LOG -DBSD"
6291 - $(LN) x86-k6.h arch.h
6293 - JOHN_OBJS="$(BITSLICE_OBJS) $(JOHN_OBJS) x86.o" \
6294 - ASFLAGS="$(ASFLAGS) -DUNDERSCORES -DALIGN_LOG -DBSD"
6296 + $(MAKE) use-openbsd-sparc HAMMER=use-openbsd-sparc NAIL=sparc.h
6297 + $(LN) sparc.h arch.h
6298 + $(MAKE) use-openbsd-sparc NAIL="$(PROJ)"
6302 + BENCH_DES_OBJS_DEPEND="$(BENCH_DES_OBJS_ORIG) sparc.o" \
6303 + JOHN_OBJS="$(JOHN_OBJS_ORIG) sparc.o" \
6304 + ASFLAGS="-c -DUNDERSCORES -DBSD"
6307 + $(LN) vax.h arch.h
6311 + $(LN) vax.h arch.h
6315 $(MAKE) $(HAMMER) NAIL=sparc.h
6316 @@ -220,27 +232,28 @@
6317 use-solaris-sparc-gcc:
6319 BENCH_DES_OBJS_DEPEND="$(BENCH_DES_OBJS_ORIG) sparc.o" \
6320 - JOHN_OBJS="$(BITSLICE_OBJS) $(JOHN_OBJS_ORIG) sparc.o"
6321 + JOHN_OBJS="$(JOHN_OBJS_ORIG) sparc.o" \
6324 use-solaris-sparc-v8-cc:
6326 BENCH_DES_OBJS_DEPEND="$(BENCH_DES_OBJS_ORIG) spro-sparc.o" \
6327 - JOHN_OBJS="$(BITSLICE_OBJS) $(JOHN_OBJS_ORIG) spro-sparc.o" \
6328 + JOHN_OBJS="$(JOHN_OBJS_ORIG) spro-sparc.o" \
6329 CPP=cc CC=cc AS=cc LD=cc \
6330 CFLAGS="-c -xO4 -xarch=v8" \
6331 - LDFLAGS="-s -lc" \
6332 + LDFLAGS="-s -lc -lrt" \
6334 - OPT_INLINE="-xinline=S1,S2,S3,S4,S5,S6,S7,S8"
6335 + OPT_INLINE="-xinline=s1,s2,s3,s4,s5,s6,s7,s8"
6337 use-solaris-sparc-v9-cc:
6339 BENCH_DES_OBJS_DEPEND="$(BENCH_DES_OBJS_ORIG) spro-sparc.o" \
6340 - JOHN_OBJS="$(BITSLICE_OBJS) $(JOHN_OBJS_ORIG) spro-sparc.o" \
6341 + JOHN_OBJS="$(JOHN_OBJS_ORIG) spro-sparc.o" \
6342 CPP=cc CC=cc AS=cc LD=cc \
6343 CFLAGS="-c -xO4 -xarch=v8plusa -xchip=ultra" \
6344 - LDFLAGS="-s -lc" \
6345 + LDFLAGS="-s -lc -lrt" \
6347 - OPT_INLINE="-xinline=S1,S2,S3,S4,S5,S6,S7,S8"
6348 + OPT_INLINE="-xinline=s1,s2,s3,s4,s5,s6,s7,s8"
6352 @@ -250,66 +263,107 @@
6354 # Older versions of spro cc didn't support .S files directly
6355 spro-sparc.o: sparc.S
6356 - $(CPP) $(CPPFLAGS) sparc.S > tmp.s
6357 + $(CPP) $(CPPFLAGS) sparc.S | $(SED) 's/% /%/g' > tmp.s
6358 $(AS) $(ASFLAGS) tmp.s -o spro-sparc.o
6361 +solaris-sparc64-cc:
6362 + $(LN) sparc64.h arch.h
6364 + CPP=cc CC=cc AS=cc LD=cc \
6365 + CFLAGS="-c -fast -xarch=native64" \
6366 + LDFLAGS="-xarch=native64 -s -lc -lrt" \
6368 + OPT_INLINE="-xinline=s1,s2,s3,s4,s5,s6,s7,s8"
6370 +solaris-sparc64-gcc:
6371 + $(LN) sparc64.h arch.h
6373 + CFLAGS="$(CFLAGS) -m64 -mcpu=ultrasparc" \
6374 + LDFLAGS="-m64 -s -lrt"
6378 ln -s x86-any.h arch.h
6381 JOHN_OBJS="$(JOHN_OBJS) solaris-x86.o" \
6382 - CFLAGS="$(CFLAGS) -m486"
6386 - ln -s x86-k6.h arch.h
6389 - JOHN_OBJS="$(BITSLICE_OBJS) $(JOHN_OBJS) solaris-x86.o"
6390 + LDFLAGS="-s -lc -lrt"
6392 # Solaris x86 got a broken assembler, with line length restriction (and some
6393 # other problems, that are worked around in x86.S)
6394 solaris-x86.o: x86.S
6395 - $(CPP) $(CPPFLAGS) -P -DSOLARIS x86.S | tr \; \\n > tmp.s
6396 + $(CPP) $(CPPFLAGS) -P -DDUMBAS x86.S | $(TR) \; \\n > tmp.s
6397 $(AS) $(ASFLAGS) tmp.s -o solaris-x86.o
6403 + ln -s x86-any.h arch.h
6406 + JOHN_OBJS="$(JOHN_OBJS) sco-x86.o"
6410 + ln -s x86-any.h arch.h
6413 + JOHN_OBJS="$(JOHN_OBJS) sco-x86.o" \
6414 + CPP=cc CC=cc AS=cc LD=cc \
6415 + CFLAGS="-c -b elf -O3" \
6416 + ASFLAGS="-c -b elf" \
6417 + OPT_NORMAL="-K loop_unroll,no_inline" \
6418 + OPT_INLINE="-K inline"
6420 +# SCO is even worse than Solaris x86
6422 + $(CPP) $(CPPFLAGS) -DDUMBAS x86.S | \
6423 + $(TR) \; \\n | $(SED) 's/\([%.]\) /\1/g' > tmp.s
6424 + $(AS) $(ASFLAGS) tmp.s -o sco-x86.o
6428 $(LN) alpha.h arch.h
6430 - JOHN_OBJS="$(BITSLICE_OBJS) $(JOHN_OBJS) digital-alpha.o" \
6431 + JOHN_OBJS="$(JOHN_OBJS) digipaq-alpha.o" \
6432 CPP=cc CC=cc AS=cc LD=cc \
6433 - CFLAGS="-c -O5 -tune host" \
6434 + CFLAGS="-c -O4 -arch host" \
6436 OPT_INLINE="-inline all"
6438 -# DEC's cc and make use the .S suffix for a different purpose...
6439 -digital-alpha.o: alpha.S
6440 +# Digital/Compaq's cc and make use the .S suffix for a different purpose...
6441 +digipaq-alpha.o: alpha.S
6442 $(CPP) $(CPPFLAGS) alpha.S > tmp.s
6443 - $(AS) $(ASFLAGS) tmp.s -o digital-alpha.o
6444 + $(AS) $(ASFLAGS) tmp.s -o digipaq-alpha.o
6450 - JOHN_OBJS="$(BITSLICE_OBJS) $(JOHN_OBJS)" \
6451 CPP=cc CC=cc AS=cc LD=cc \
6452 - CFLAGS="-c -qunroll -qarch=ppc -qtune=601 -qchars=signed" \
6453 + CFLAGS="-c -qunroll -qarch=ppc -qchars=signed" \
6454 LDFLAGS="-s -lbsd" \
6456 OPT_INLINE="-O3 -Q=99 -w"
6459 + $(LN) ppc.h arch.h
6461 + CPP=cc CC=cc AS=cc LD=cc \
6462 + CFLAGS="-c -traditional-cpp" \
6464 + OPT_NORMAL="-O2" \
6468 $(LN) pa-risc.h arch.h
6470 - JOHN_OBJS="$(BITSLICE_OBJS) $(JOHN_OBJS)"
6471 + CFLAGS="-c -Wall -O3 -fomit-frame-pointer"
6474 $(LN) pa-risc.h arch.h
6476 - JOHN_OBJS="$(BITSLICE_OBJS) $(JOHN_OBJS)" \
6477 CPP=cc CC=cc AS=cc LD=cc \
6478 CFLAGS="-c -Aa -D_HPUX_SOURCE -DANSI_CPP" \
6482 $(LN) mips32.h arch.h
6484 - JOHN_OBJS="$(BITSLICE_OBJS) $(JOHN_OBJS)" \
6485 CPP=cc CC=cc AS=cc LD=cc \
6486 CFLAGS="-c -O2 -32 -signed" \
6488 @@ -329,7 +382,15 @@
6490 $(LN) mips64.h arch.h
6492 - JOHN_OBJS="$(BITSLICE_OBJS) $(JOHN_OBJS)" \
6493 + CPP=cc CC=cc AS=cc LD=cc \
6494 + CFLAGS="-c -O2 -64 -mips3 -signed" \
6495 + LDFLAGS="-s -64 -mips3" \
6496 + OPT_NORMAL="-LNO:opt=1 -OPT:Olimit=2194" \
6497 + OPT_INLINE="-INLINE:all"
6499 +irix-mips64-r10k-cc:
6500 + $(LN) mips64.h arch.h
6502 CPP=cc CC=cc AS=cc LD=cc \
6503 CFLAGS="-c -O2 -64 -mips4 -r10000 -signed" \
6504 LDFLAGS="-s -64 -mips4 -r10000" \
6505 @@ -340,50 +401,40 @@
6506 copy x86-any.h arch.h
6507 $(MAKE) $(PROJ_DOS) \
6508 JOHN_OBJS="$(JOHN_OBJS) x86.o" \
6509 - CFLAGS="$(CFLAGS) -m486" \
6510 ASFLAGS="$(ASFLAGS) -DUNDERSCORES -DALIGN_LOG"
6513 copy x86-mmx.h arch.h
6514 $(MAKE) $(PROJ_DOS) \
6515 - JOHN_OBJS="$(JOHN_OBJS) x86.o" \
6516 - CFLAGS="$(CFLAGS) -m486" \
6517 - ASFLAGS="$(ASFLAGS) -DUNDERSCORES -DALIGN_LOG"
6520 - copy x86-k6.h arch.h
6521 - copy nonstd.c DES_bs_s.c
6522 - $(MAKE) $(PROJ_DOS) \
6523 - JOHN_OBJS="$(BITSLICE_OBJS) $(JOHN_OBJS) x86.o" \
6524 + JOHN_OBJS="$(JOHN_OBJS_MINIMAL) x86.o x86-mmx.o" \
6525 ASFLAGS="$(ASFLAGS) -DUNDERSCORES -DALIGN_LOG"
6527 win32-cygwin-x86-any:
6528 $(CP) x86-any.h arch.h
6529 $(MAKE) $(PROJ_WIN32) \
6530 JOHN_OBJS="$(JOHN_OBJS) x86.o" \
6531 - CFLAGS="$(CFLAGS) -mpentium" \
6532 ASFLAGS="$(ASFLAGS) -DUNDERSCORES"
6534 win32-cygwin-x86-mmx:
6535 $(CP) x86-mmx.h arch.h
6536 $(MAKE) $(PROJ_WIN32) \
6537 - JOHN_OBJS="$(JOHN_OBJS) x86.o" \
6538 - CFLAGS="$(CFLAGS) -mpentium" \
6539 + JOHN_OBJS="$(JOHN_OBJS_MINIMAL) x86.o x86-mmx.o" \
6540 ASFLAGS="$(ASFLAGS) -DUNDERSCORES"
6542 -win32-cygwin-x86-k6:
6543 - $(CP) x86-k6.h arch.h
6544 - $(CP) nonstd.c DES_bs_s.c
6545 - $(MAKE) $(PROJ_WIN32) \
6546 - JOHN_OBJS="$(BITSLICE_OBJS) $(JOHN_OBJS) x86.o" \
6547 - CFLAGS="-c -Wall -O -fomit-frame-pointer" \
6548 - ASFLAGS="$(ASFLAGS) -DUNDERSCORES"
6550 + $(LN) x86-any.h arch.h
6552 + JOHN_OBJS="$(JOHN_OBJS) x86.o"
6555 + $(LN) x86-mmx.h arch.h
6557 + JOHN_OBJS="$(JOHN_OBJS_MINIMAL) x86.o x86-mmx.o"
6561 ln -s generic.h arch.h
6563 - JOHN_OBJS="$(BITSLICE_OBJS) $(JOHN_OBJS)"
6568 @@ -401,12 +452,15 @@
6569 $(LD) $(LDFLAGS) $(JOHN_OBJS) -o ../run/john
6571 ../run/unshadow: ../run/john
6572 + $(RM) ../run/unshadow
6573 ln -s john ../run/unshadow
6575 ../run/unafs: ../run/john
6576 + $(RM) ../run/unafs
6577 ln -s john ../run/unafs
6579 ../run/unique: ../run/john
6580 + $(RM) ../run/unique
6581 ln -s john ../run/unique
6583 ../run/john.bin: $(JOHN_OBJS)
6585 strip ../run/unique.exe
6587 # Inlining the S-boxes produces faster code, as long as they fit in the cache
6588 -# (that is, on RISC with at least 8 Kb of L1 code cache).
6589 +# (that is, on RISC with at least 8 KB of L1 code cache).
6590 DES_bs_b.o: DES_bs_b.c DES_bs_s.c
6591 $(CC) $(CFLAGS) $(OPT_INLINE) DES_bs_b.c
6593 diff -ruN john-1.6/src/math.h john-1.6.34/src/math.h
6594 --- john-1.6/src/math.h 1998-12-03 01:29:50.000000000 +0100
6595 +++ john-1.6.34/src/math.h 2001-02-16 06:48:37.000000000 +0100
6598 * This file is part of John the Ripper password cracker,
6599 - * Copyright (c) 1996-98 by Solar Designer
6600 + * Copyright (c) 1996-2001 by Solar Designer
6604 - * 64 bit integer math functions.
6605 + * 64-bit integer math functions.
6608 #ifndef _JOHN_MATH_H
6609 #define _JOHN_MATH_H
6612 +#define int64 _john_int64_t
6615 unsigned int lo, hi;
6617 diff -ruN john-1.6/src/MD5_fmt.c john-1.6.34/src/MD5_fmt.c
6618 --- john-1.6/src/MD5_fmt.c 1998-12-03 01:29:50.000000000 +0100
6619 +++ john-1.6.34/src/MD5_fmt.c 2001-11-13 12:34:32.000000000 +0100
6622 * This file is part of John the Ripper password cracker,
6623 - * Copyright (c) 1996-98 by Solar Designer
6624 + * Copyright (c) 1996-2001 by Solar Designer
6629 #define BINARY_SIZE 4
6632 -#define MIN_KEYS_PER_CRYPT 1
6633 -#define MAX_KEYS_PER_CRYPT 1
6634 +#define MIN_KEYS_PER_CRYPT MD5_N
6635 +#define MAX_KEYS_PER_CRYPT MD5_N
6637 static struct fmt_tests tests[] = {
6638 {"$1$12345678$aIccj83HRDBo6ux1bVx7D1", "0123456789ABCDE"},
6643 -static char saved_key[PLAINTEXT_LENGTH + 1];
6644 +static char saved_key[MD5_N][PLAINTEXT_LENGTH + 1];
6646 static int valid(char *ciphertext)
6649 if (strncmp(ciphertext, "$1$", 3)) return 0;
6651 for (pos = &ciphertext[3]; *pos && *pos != '$'; pos++);
6652 - if (!*pos || pos < &ciphertext[4] || pos > &ciphertext[11]) return 0;
6653 + if (!*pos || pos < &ciphertext[3] || pos > &ciphertext[11]) return 0;
6656 - while (atoi64[(ARCH_INDEX)*pos] != 0x7F) pos++;
6657 + while (atoi64[ARCH_INDEX(*pos)] != 0x7F) pos++;
6658 if (*pos || pos - start != CIPHERTEXT_LENGTH) return 0;
6660 + if (atoi64[ARCH_INDEX(*(pos - 1))] & 0x3C) return 0;
6667 static int get_hash_0(int index)
6669 - return MD5_out[0] & 0xF;
6670 + return MD5_out[index][0] & 0xF;
6673 static int get_hash_1(int index)
6675 - return MD5_out[0] & 0xFF;
6676 + return MD5_out[index][0] & 0xFF;
6679 static int get_hash_2(int index)
6681 - return MD5_out[0] & 0xFFF;
6682 + return MD5_out[index][0] & 0xFFF;
6685 static int salt_hash(void *salt)
6688 - ((int)atoi64[(ARCH_INDEX)((char *)salt)[0]] |
6689 - ((int)atoi64[(ARCH_INDEX)((char *)salt)[1]] << 6)) & 0x3FF;
6690 + ((int)atoi64[ARCH_INDEX(((char *)salt)[0])] |
6691 + ((int)atoi64[ARCH_INDEX(((char *)salt)[1])] << 6)) & 0x3FF;
6694 static void set_key(char *key, int index)
6696 - MD5_std_set_key(key);
6697 + MD5_std_set_key(key, index);
6699 - strnfcpy(saved_key, key, PLAINTEXT_LENGTH);
6700 + strnfcpy(saved_key[index], key, PLAINTEXT_LENGTH);
6703 static char *get_key(int index)
6705 - saved_key[PLAINTEXT_LENGTH] = 0;
6706 + saved_key[index][PLAINTEXT_LENGTH] = 0;
6709 + return saved_key[index];
6712 static int cmp_all(void *binary, int index)
6714 - return *(MD5_word *)binary == MD5_out[0];
6716 + return *(MD5_word *)binary == MD5_out[0][0] ||
6717 + *(MD5_word *)binary == MD5_out[1][0];
6719 + return *(MD5_word *)binary == MD5_out[0][0];
6723 static int cmp_exact(char *source, int index)
6725 - return !memcmp(MD5_std_get_binary(source), MD5_out,
6726 + return !memcmp(MD5_std_get_binary(source), MD5_out[index],
6727 sizeof(MD5_binary));
6731 FMT_CASE | FMT_8_BIT,
6738 (void *(*)(char *))MD5_std_get_binary,
6740 (void (*)(void *))MD5_std_set_salt,
6743 + fmt_default_clear_keys,
6744 (void (*)(int))MD5_std_crypt,
6747 diff -ruN john-1.6/src/MD5_std.c john-1.6.34/src/MD5_std.c
6748 --- john-1.6/src/MD5_std.c 1998-12-03 01:29:50.000000000 +0100
6749 +++ john-1.6.34/src/MD5_std.c 2001-06-17 08:52:32.000000000 +0200
6752 * This file is part of John the Ripper password cracker,
6753 - * Copyright (c) 1996-98 by Solar Designer
6754 + * Copyright (c) 1996-2001 by Solar Designer
6756 * Based on the RSA Data Security, Inc. MD5 Message-Digest Algorithm and
6757 * FreeBSD MD5-based crypt(3) by Poul-Henning Kamp <phk@login.dknet.dk>.
6760 #include "MD5_std.h"
6762 -MD5_binary MD5_out;
6763 +MD5_std_combined CC_CACHE_ALIGN MD5_std_all;
6770 +static MD5_data MD5_data_init = {
6772 + 0xd76aa477, 0xf8fa0bcc, 0xbcdb4dd9, 0xb18b7a77,
6773 + 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
6774 + 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
6775 + 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
6776 + 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa,
6777 + 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,
6778 + 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,
6779 + 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
6780 + 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c,
6781 + 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
6782 + 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05,
6783 + 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
6784 + 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039,
6785 + 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
6786 + 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
6787 + 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391
6789 + 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476
6791 + 0x77777777, 0x00ff00ff
6802 -#define Ca 0x67452301
6803 -#define Cb 0xefcdab89
6804 -#define Cc 0x98badcfe
6805 -#define Cd 0x10325476
6813 #define AC1 0xd76aa477
6814 -#define AC2 0xe8c7b756
6815 -#define AC3 0x242070db
6816 -#define AC4 0xc1bdceee
6817 +#define AC2pCd 0xf8fa0bcc
6818 +#define AC3pCc 0xbcdb4dd9
6819 +#define AC4pCb 0xb18b7a77
6820 #define AC5 0xf57c0faf
6821 #define AC6 0x4787c62a
6822 #define AC7 0xa8304613
6823 @@ -115,40 +132,28 @@
6824 #define AC62 0xbd3af235
6825 #define AC63 0x2ad7d2bb
6826 #define AC64 0xeb86d391
6828 +#define Ca 0x67452301
6829 +#define Cb 0xefcdab89
6830 +#define Cc 0x98badcfe
6831 +#define Cd 0x10325476
6833 #define MASK1 0x77777777
6835 +#define OOFFOOFF 0x00ff00ff
6840 - * If we used immediate values on RISC with 32 bit instruction size, it would
6841 - * take 130 instructions to load all the 65 values. Keeping the values in an
6842 - * array instead reduces the instruction count to 67.
6843 + * If we used immediate values on RISC with 32-bit instruction size, it would
6844 + * take about twice more instructions to load all the values.
6847 -static MD5_word MD5_AC[65] = {
6848 - 0xd76aa477, 0xe8c7b756, 0x242070db, 0xc1bdceee,
6849 - 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
6850 - 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
6851 - 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
6852 - 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa,
6853 - 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,
6854 - 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,
6855 - 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
6856 - 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c,
6857 - 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
6858 - 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05,
6859 - 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
6860 - 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039,
6861 - 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
6862 - 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
6863 - 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391,
6867 +#define MD5_AC MD5_std_all.data.AC
6868 #define AC1 MD5_AC[0]
6869 -#define AC2 MD5_AC[1]
6870 -#define AC3 MD5_AC[2]
6871 -#define AC4 MD5_AC[3]
6872 +#define AC2pCd MD5_AC[1]
6873 +#define AC3pCc MD5_AC[2]
6874 +#define AC4pCb MD5_AC[3]
6875 #define AC5 MD5_AC[4]
6876 #define AC6 MD5_AC[5]
6877 #define AC7 MD5_AC[6]
6878 @@ -209,7 +214,16 @@
6879 #define AC62 MD5_AC[61]
6880 #define AC63 MD5_AC[62]
6881 #define AC64 MD5_AC[63]
6882 -#define MASK1 MD5_AC[64]
6884 +#define MD5_IV MD5_std_all.data.IV
6885 +#define Ca MD5_IV[0]
6886 +#define Cb MD5_IV[1]
6887 +#define Cc MD5_IV[2]
6888 +#define Cd MD5_IV[3]
6890 +#define MASK1 MD5_std_all.data.masks[0]
6892 +#define OOFFOOFF MD5_std_all.data.masks[1]
6897 * ROTATE_LEFT rotates x left n bits.
6899 #define ROTATE_LEFT(x, n) \
6900 - (x) = (((x) << (n)) | ((x) >> (32 - (n))))
6901 + (x) = (((x) << (n)) | ((MD5_word)(x) >> (32 - (n))))
6904 * FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
6905 @@ -252,16 +266,339 @@
6906 ROTATE_LEFT ((a), (s)); \
6910 +static void MD5_body(MD5_word x0[15], MD5_word x1[15],
6911 + MD5_word out0[4], MD5_word out1[4]);
6913 +static void MD5_body(MD5_word x[15], MD5_word out[4]);
6918 +extern void MD5_body(MD5_word x[15], MD5_word out[4]);
6922 +static unsigned char PADDING[56] = {
6923 + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
6924 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
6925 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
6928 +#if ARCH_LITTLE_ENDIAN
6930 +#define MD5_swap(x, y, count)
6934 +static void MD5_swap(MD5_word *x, MD5_word *y, int count)
6936 + register MD5_word tmp, mask;
6941 + ROTATE_LEFT(tmp, 16);
6942 + *y++ = ((tmp & mask) << 8) | ((tmp >> 8) & mask);
6943 + } while (--count);
6948 +#define order MD5_std_all.order
6949 +#define pool MD5_std_all.pool
6950 +#define block MD5_std_all.block
6952 +static void init_line(int line, int index, MD5_block *even, MD5_block *odd)
6954 + order[line][index].even = even;
6955 + order[line][index].odd = odd;
6958 +void MD5_std_init(void)
6961 + MD5_pool *current;
6964 + MD5_std_all.data = MD5_data_init;
6967 + for (index = 0, current = pool; index < MD5_N; index++, current++) {
6968 + init_line(0, index, ¤t->e.p, ¤t->o.psp);
6969 + init_line(1, index, ¤t->e.spp, ¤t->o.pp);
6970 + init_line(2, index, ¤t->e.spp, ¤t->o.psp);
6971 + init_line(3, index, ¤t->e.pp, ¤t->o.ps);
6972 + init_line(4, index, ¤t->e.spp, ¤t->o.pp);
6973 + init_line(5, index, ¤t->e.spp, ¤t->o.psp);
6974 + init_line(6, index, ¤t->e.pp, ¤t->o.psp);
6975 + init_line(7, index, ¤t->e.sp, ¤t->o.pp);
6976 + init_line(8, index, ¤t->e.spp, ¤t->o.psp);
6977 + init_line(9, index, ¤t->e.pp, ¤t->o.psp);
6978 + init_line(10, index, ¤t->e.spp, ¤t->o.p);
6979 + init_line(11, index, ¤t->e.spp, ¤t->o.psp);
6980 + init_line(12, index, ¤t->e.pp, ¤t->o.psp);
6981 + init_line(13, index, ¤t->e.spp, ¤t->o.pp);
6982 + init_line(14, index, ¤t->e.sp, ¤t->o.psp);
6983 + init_line(15, index, ¤t->e.pp, ¤t->o.psp);
6984 + init_line(16, index, ¤t->e.spp, ¤t->o.pp);
6985 + init_line(17, index, ¤t->e.spp, ¤t->o.ps);
6986 + init_line(18, index, ¤t->e.pp, ¤t->o.psp);
6987 + init_line(19, index, ¤t->e.spp, ¤t->o.pp);
6988 + init_line(20, index, ¤t->e.spp, ¤t->o.psp);
6992 +void MD5_std_set_salt(char *salt)
6996 + for (length = 0; length < 8 && salt[length]; length++);
6998 + memcpy(pool[0].s, salt, pool[0].l.s = length);
7000 + memcpy(pool[1].s, salt, pool[1].l.s = length);
7004 +void MD5_std_set_key(char *key, int index)
7007 + MD5_pool *current;
7009 + for (length = 0; key[length] && length < 15; length++);
7010 + current = &pool[index];
7012 + memcpy(current->o.p.b, key, current->l.p = length);
7013 + memcpy(¤t->o.p.b[length + 16], PADDING, 40 - length);
7014 + current->o.p.w[14] = (length + 16) << 3;
7016 + memcpy(current->o.pp.b, key, length);
7017 + memcpy(¤t->o.pp.b[length], key, length);
7018 + current->l.pp = length << 1;
7019 + memcpy(¤t->o.pp.b[current->l.pp + 16], PADDING,
7020 + 40 - current->l.pp);
7021 + current->o.pp.w[14] = (current->l.pp + 16) << 3;
7023 + memcpy(¤t->e.p.b[16], key, length);
7024 + memcpy(¤t->e.p.b[16 + length], PADDING, 40 - length);
7025 + current->e.p.w[14] = (length + 16) << 3;
7026 + MD5_swap(current->e.p.w, current->e.p.w, 14);
7028 + memcpy(¤t->e.pp.b[16], current->o.pp.b, current->l.pp);
7029 + memcpy(¤t->e.pp.b[16 + current->l.pp], PADDING,
7030 + 40 - current->l.pp);
7031 + current->e.pp.w[14] = (current->l.pp + 16) << 3;
7032 + MD5_swap(current->e.pp.w, current->e.pp.w, 14);
7034 + order[1][index].length = current->l.pp;
7035 + order[4][index].length = current->l.pp;
7036 + order[7][index].length = current->l.pp;
7037 + order[10][index].length = length;
7038 + order[13][index].length = current->l.pp;
7039 + order[16][index].length = current->l.pp;
7040 + order[19][index].length = current->l.pp;
7043 +void MD5_std_crypt(void)
7045 + int length, index, mask;
7046 + MD5_pattern *line;
7047 +#if ARCH_LITTLE_ENDIAN
7052 +#if ARCH_LITTLE_ENDIAN
7058 + for (index = 0, key = pool; index < MD5_N; index++, key++) {
7063 + memcpy(key->o.ps.b, key->o.p.b, key->l.p);
7064 + memcpy(&key->o.ps.b[key->l.p], key->s, key->l.s);
7065 + key->l.ps = key->l.p + key->l.s;
7066 + memcpy(&key->o.ps.b[key->l.ps + 16], PADDING,
7068 + key->o.ps.w[14] = (key->l.ps + 16) << 3;
7070 + memcpy(key->o.psp.b, key->o.ps.b, key->l.ps);
7071 + memcpy(&key->o.psp.b[key->l.ps], key->o.p.b, key->l.p);
7072 + key->l.psp = key->l.ps + key->l.p;
7073 + memcpy(&key->o.psp.b[key->l.psp + 16], PADDING,
7075 + key->o.psp.w[14] = (key->l.psp + 16) << 3;
7077 + memcpy(&key->e.sp.b[16], key->s, key->l.s);
7078 + memcpy(&key->e.sp.b[16 + key->l.s], key->o.p.b,
7080 + memcpy(&key->e.sp.b[16 + key->l.ps], PADDING,
7082 + key->e.sp.w[14] = (key->l.ps + 16) << 3;
7083 + MD5_swap(key->e.sp.w, key->e.sp.w, 14);
7085 + memcpy(&key->e.spp.b[16], key->s, key->l.s);
7086 + memcpy(&key->e.spp.b[16 + key->l.s], key->o.pp.b,
7088 + memcpy(&key->e.spp.b[16 + key->l.psp], PADDING,
7090 + key->e.spp.w[14] = (key->l.psp + 16) << 3;
7091 + MD5_swap(key->e.spp.w, key->e.spp.w, 14);
7093 + order[0][index].length = key->l.psp;
7094 + order[2][index].length = key->l.psp;
7095 + order[3][index].length = key->l.ps;
7096 + order[5][index].length = key->l.psp;
7097 + order[6][index].length = key->l.psp;
7098 + order[8][index].length = key->l.psp;
7099 + order[9][index].length = key->l.psp;
7100 + order[11][index].length = key->l.psp;
7101 + order[12][index].length = key->l.psp;
7102 + order[14][index].length = key->l.psp;
7103 + order[15][index].length = key->l.psp;
7104 + order[17][index].length = key->l.ps;
7105 + order[18][index].length = key->l.psp;
7106 + order[20][index].length = key->l.psp;
7108 + memcpy(&block[index], key->o.psp.b, key->l.psp);
7109 + memcpy(&block[index].b[key->l.psp], PADDING, 56 - key->l.psp);
7110 + block[index].w[14] = key->l.psp << 3;
7111 + MD5_swap(block[index].w, block[index].w, 14);
7115 + MD5_body(block[0].w, block[1].w, MD5_out[0], MD5_out[1]);
7116 + MD5_swap(MD5_out[0], MD5_out[0], 8);
7118 + MD5_body(block[0].w, MD5_out[0]);
7119 + MD5_swap(MD5_out[0], MD5_out[0], 4);
7123 + for (index = 0, key = pool; index < MD5_N; index++, key++) {
7125 + memcpy(&block[index], key->o.p.b, key->l.p);
7126 + memcpy(&block[index].b[key->l.p], "$1$", 3);
7127 + memcpy(&block[index].b[key->l.p + 3], key->s, key->l.s);
7128 + memcpy(&block[index].b[key->l.ps + 3],
7129 + MD5_out[index], key->l.p);
7130 + length = key->l.psp + 3;
7131 + if ((mask = key->l.p))
7133 + block[index].b[length++] =
7134 + (mask & 1) ? 0 : key->o.p.b[0];
7135 + } while (mask >>= 1);
7136 + memcpy(&block[index].b[length], PADDING, 56 - length);
7137 + block[index].w[14] = length << 3;
7138 + MD5_swap(block[index].w, block[index].w, 14);
7147 + MD5_body(block[0].w, block[1].w,
7148 + order[0][0].even->w, order[0][1].even->w);
7150 + MD5_body(block[0].w, order[0][0].even->w);
7153 + index = 500; line = order[0];
7155 +#if ARCH_LITTLE_ENDIAN
7156 +#if ARCH_ALLOWS_UNALIGNED
7158 + MD5_body(line[0].even->w, line[1].even->w,
7159 + (MD5_word *)&line[0].odd->b[line[0].length],
7160 + (MD5_word *)&line[1].odd->b[line[1].length]);
7162 + MD5_body(line[0].even->w,
7163 + (MD5_word *)&line[0].odd->b[line[0].length]);
7167 + MD5_body(line[0].even->w, line[1].even->w,
7168 + MD5_out[0], MD5_out[1]);
7169 + memcpy(&line[0].odd->b[line[0].length], MD5_out[0], 16);
7170 + memcpy(&line[1].odd->b[line[1].length], MD5_out[1], 16);
7172 + if (((ARCH_WORD)&line[0].odd->b[line[0].length]) & 3) {
7173 + MD5_body(line[0].even->w, MD5_out[0]);
7174 + memcpy(&line[0].odd->b[line[0].length],
7177 + MD5_body(line[0].even->w,
7178 + (MD5_word *)&line[0].odd->b[line[0].length]);
7182 + last0 = line[0].odd->w;
7184 + last1 = line[1].odd->w;
7185 + if ((line += 2) > &order[20][MD5_N - 1]) line = order[0];
7186 + MD5_body(last0, last1, line[0].even->w, line[1].even->w);
7188 + if (++line > &order[20][0]) line = order[0];
7189 + MD5_body(last0, line[0].even->w);
7193 + MD5_body(line[0].even->w, line[1].even->w,
7194 + MD5_out[0], MD5_out[1]);
7195 + MD5_swap(MD5_out[0], MD5_out[0], 8);
7197 + MD5_body(line[0].even->w, MD5_out[0]);
7198 + MD5_swap(MD5_out[0], MD5_out[0], 4);
7200 + memcpy(&line[0].odd->b[line[0].length], MD5_out[0], 16);
7202 + memcpy(&line[1].odd->b[line[1].length], MD5_out[1], 16);
7204 + MD5_swap(line[0].odd->w, block[0].w, 14);
7205 + block[0].w[14] = line[0].odd->w[14];
7207 + MD5_swap(line[1].odd->w, block[1].w, 14);
7208 + block[1].w[14] = line[1].odd->w[14];
7209 + if ((line += 2) > &order[20][MD5_N - 1]) line = order[0];
7210 + MD5_body(block[0].w, block[1].w,
7211 + line[0].even->w, line[1].even->w);
7213 + if (++line > &order[20][0]) line = order[0];
7214 + MD5_body(block[0].w, line[0].even->w);
7217 + } while (--index);
7219 + memcpy(MD5_out[0], line[0].even, 16);
7221 + memcpy(MD5_out[1], line[1].even, 16);
7229 static void MD5_body(MD5_word x[15], MD5_word out[4])
7231 - register MD5_word a, b = Cb, c = Cc, d = Cd;
7232 + register unsigned ARCH_WORD a, b = Cb, c = Cc, d;
7235 - a = AC1 + x[0]; ROTATE_LEFT (a, S11); a += b; /* 1 */
7236 - d += (c ^ (a & MASK1)) + x[1] + AC2;
7238 + ROTATE_LEFT (a, S11); a += b; /* 1 */
7239 + d = (c ^ (a & MASK1)) + x[1] + AC2pCd;
7240 ROTATE_LEFT (d, S12); d += a; /* 2 */
7241 - FF (c, d, a, b, x[ 2], S13, AC3); /* 3 */
7242 - FF (b, c, d, a, x[ 3], S14, AC4); /* 4 */
7243 + c = F(d, a, b) + x[2] + AC3pCc;
7244 + ROTATE_LEFT(c, S13); c += d; /* 3 */
7245 + b = F(c, d, a) + x[3] + AC4pCb;
7246 + ROTATE_LEFT(b, S14); b += c; /* 4 */
7247 FF (a, b, c, d, x[ 4], S11, AC5); /* 5 */
7248 FF (d, a, b, c, x[ 5], S12, AC6); /* 6 */
7249 FF (c, d, a, b, x[ 6], S13, AC7); /* 7 */
7250 @@ -341,224 +678,180 @@
7254 -extern void MD5_body(MD5_word x[15], MD5_word out[4]);
7258 -#if ARCH_LITTLE_ENDIAN
7260 -#define MD5_swap(x, y, count)
7264 -static void MD5_swap(MD5_word *x, MD5_word *y, int count)
7265 +static void MD5_body(MD5_word x0[15], MD5_word x1[15],
7266 + MD5_word out0[4], MD5_word out1[4])
7269 + register unsigned ARCH_WORD a0, b0 = Cb, c0 = Cc, d0;
7270 + register unsigned ARCH_WORD a1, b1, c1, d1;
7271 + register unsigned ARCH_WORD u, v;
7275 - ROTATE_LEFT(tmp, 16);
7276 - *y++ = ((tmp & 0x00FF00FF) << 8) | ((tmp >> 8) & 0x00FF00FF);
7277 - } while (--count);
7282 -static unsigned char PADDING[56] = {
7283 - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7284 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7285 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
7291 - int p, s, ps, pp, psp;
7294 - MD5_block p, sp, pp, spp;
7297 - MD5_block p, ps, pp, psp;
7303 - MD5_block *even, *odd;
7306 -static struct pattern order[21] = {
7307 - {0, &patterns.e.p, &patterns.o.psp},
7308 - {0, &patterns.e.spp, &patterns.o.pp},
7309 - {0, &patterns.e.spp, &patterns.o.psp},
7310 - {0, &patterns.e.pp, &patterns.o.ps},
7311 - {0, &patterns.e.spp, &patterns.o.pp},
7312 - {0, &patterns.e.spp, &patterns.o.psp},
7313 - {0, &patterns.e.pp, &patterns.o.psp},
7314 - {0, &patterns.e.sp, &patterns.o.pp},
7315 - {0, &patterns.e.spp, &patterns.o.psp},
7316 - {0, &patterns.e.pp, &patterns.o.psp},
7317 - {0, &patterns.e.spp, &patterns.o.p},
7318 - {0, &patterns.e.spp, &patterns.o.psp},
7319 - {0, &patterns.e.pp, &patterns.o.psp},
7320 - {0, &patterns.e.spp, &patterns.o.pp},
7321 - {0, &patterns.e.sp, &patterns.o.psp},
7322 - {0, &patterns.e.pp, &patterns.o.psp},
7323 - {0, &patterns.e.spp, &patterns.o.pp},
7324 - {0, &patterns.e.spp, &patterns.o.ps},
7325 - {0, &patterns.e.pp, &patterns.o.psp},
7326 - {0, &patterns.e.spp, &patterns.o.pp},
7327 - {0, &patterns.e.spp, &patterns.o.psp},
7330 -void MD5_std_set_salt(char *salt)
7334 - for (length = 0; salt[length] && length < 8; length++);
7336 - memcpy(patterns.s, salt, patterns.l.s = length);
7339 + a0 = (u = AC1) + x0[0];
7340 + ROTATE_LEFT (a0, S11); a0 += b0; /* 1 */
7342 + ROTATE_LEFT (a1, S11); a1 += b0; /* 1 */
7343 + d0 = (c0 ^ (a0 & (u = MASK1))) + x0[1] + (v = AC2pCd);
7344 + ROTATE_LEFT (d0, S12); d0 += a0; /* 2 */
7345 + d1 = (c0 ^ (a1 & u)) + x1[1] + v;
7346 + ROTATE_LEFT (d1, S12); d1 += a1; /* 2 */
7347 + c0 = F(d0, a0, b0) + x0[2] + (u = AC3pCc);
7348 + ROTATE_LEFT(c0, S13); c0 += d0; /* 3 */
7349 + c1 = F(d1, a1, b0) + x1[2] + u;
7350 + ROTATE_LEFT(c1, S13); c1 += d1; /* 3 */
7351 + b0 = F(c0, d0, a0) + x0[3] + (u = AC4pCb);
7352 + ROTATE_LEFT(b0, S14); b0 += c0; /* 4 */
7353 + b1 = F(c1, d1, a1) + x1[3] + u;
7354 + ROTATE_LEFT(b1, S14); b1 += c1; /* 4 */
7355 + FF (a0, b0, c0, d0, x0[ 4], S11, (u = AC5)); /* 5 */
7356 + FF (a1, b1, c1, d1, x1[ 4], S11, u); /* 5 */
7357 + FF (d0, a0, b0, c0, x0[ 5], S12, (u = AC6)); /* 6 */
7358 + FF (d1, a1, b1, c1, x1[ 5], S12, u); /* 6 */
7359 + FF (c0, d0, a0, b0, x0[ 6], S13, (u = AC7)); /* 7 */
7360 + FF (c1, d1, a1, b1, x1[ 6], S13, u); /* 7 */
7361 + FF (b0, c0, d0, a0, x0[ 7], S14, (u = AC8)); /* 8 */
7362 + FF (b1, c1, d1, a1, x1[ 7], S14, u); /* 8 */
7363 + FF (a0, b0, c0, d0, x0[ 8], S11, (u = AC9)); /* 9 */
7364 + FF (a1, b1, c1, d1, x1[ 8], S11, u); /* 9 */
7365 + FF (d0, a0, b0, c0, x0[ 9], S12, (u = AC10)); /* 10 */
7366 + FF (d1, a1, b1, c1, x1[ 9], S12, u); /* 10 */
7367 + FF (c0, d0, a0, b0, x0[10], S13, (u = AC11)); /* 11 */
7368 + FF (c1, d1, a1, b1, x1[10], S13, u); /* 11 */
7369 + FF (b0, c0, d0, a0, x0[11], S14, (u = AC12)); /* 12 */
7370 + FF (b1, c1, d1, a1, x1[11], S14, u); /* 12 */
7371 + FF (a0, b0, c0, d0, x0[12], S11, (u = AC13)); /* 13 */
7372 + FF (a1, b1, c1, d1, x1[12], S11, u); /* 13 */
7373 + FF (d0, a0, b0, c0, x0[13], S12, (u = AC14)); /* 14 */
7374 + FF (d1, a1, b1, c1, x1[13], S12, u); /* 14 */
7375 + FF (c0, d0, a0, b0, x0[14], S13, (u = AC15)); /* 15 */
7376 + FF (c1, d1, a1, b1, x1[14], S13, u); /* 15 */
7377 + b0 += F (c0, d0, a0) + (u = AC16);
7378 + ROTATE_LEFT (b0, S14); b0 += c0; /* 16 */
7379 + b1 += F (c1, d1, a1) + u;
7380 + ROTATE_LEFT (b1, S14); b1 += c1; /* 16 */
7382 -void MD5_std_set_key(char *key)
7386 + GG (a0, b0, c0, d0, x0[ 1], S21, (u = AC17)); /* 17 */
7387 + GG (a1, b1, c1, d1, x1[ 1], S21, u); /* 17 */
7388 + GG (d0, a0, b0, c0, x0[ 6], S22, (u = AC18)); /* 18 */
7389 + GG (d1, a1, b1, c1, x1[ 6], S22, u); /* 18 */
7390 + GG (c0, d0, a0, b0, x0[11], S23, (u = AC19)); /* 19 */
7391 + GG (c1, d1, a1, b1, x1[11], S23, u); /* 19 */
7392 + GG (b0, c0, d0, a0, x0[ 0], S24, (u = AC20)); /* 20 */
7393 + GG (b1, c1, d1, a1, x1[ 0], S24, u); /* 20 */
7394 + GG (a0, b0, c0, d0, x0[ 5], S21, (u = AC21)); /* 21 */
7395 + GG (a1, b1, c1, d1, x1[ 5], S21, u); /* 21 */
7396 + GG (d0, a0, b0, c0, x0[10], S22, (u = AC22)); /* 22 */
7397 + GG (d1, a1, b1, c1, x1[10], S22, u); /* 22 */
7398 + c0 += G (d0, a0, b0) + (u = AC23);
7399 + ROTATE_LEFT (c0, S23); c0 += d0; /* 23 */
7400 + c1 += G (d1, a1, b1) + u;
7401 + ROTATE_LEFT (c1, S23); c1 += d1; /* 23 */
7402 + GG (b0, c0, d0, a0, x0[ 4], S24, (u = AC24)); /* 24 */
7403 + GG (b1, c1, d1, a1, x1[ 4], S24, u); /* 24 */
7404 + GG (a0, b0, c0, d0, x0[ 9], S21, (u = AC25)); /* 25 */
7405 + GG (a1, b1, c1, d1, x1[ 9], S21, u); /* 25 */
7406 + GG (d0, a0, b0, c0, x0[14], S22, (u = AC26)); /* 26 */
7407 + GG (d1, a1, b1, c1, x1[14], S22, u); /* 26 */
7408 + GG (c0, d0, a0, b0, x0[ 3], S23, (u = AC27)); /* 27 */
7409 + GG (c1, d1, a1, b1, x1[ 3], S23, u); /* 27 */
7410 + GG (b0, c0, d0, a0, x0[ 8], S24, (u = AC28)); /* 28 */
7411 + GG (b1, c1, d1, a1, x1[ 8], S24, u); /* 28 */
7412 + GG (a0, b0, c0, d0, x0[13], S21, (u = AC29)); /* 29 */
7413 + GG (a1, b1, c1, d1, x1[13], S21, u); /* 29 */
7414 + GG (d0, a0, b0, c0, x0[ 2], S22, (u = AC30)); /* 30 */
7415 + GG (d1, a1, b1, c1, x1[ 2], S22, u); /* 30 */
7416 + GG (c0, d0, a0, b0, x0[ 7], S23, (u = AC31)); /* 31 */
7417 + GG (c1, d1, a1, b1, x1[ 7], S23, u); /* 31 */
7418 + GG (b0, c0, d0, a0, x0[12], S24, (u = AC32)); /* 32 */
7419 + GG (b1, c1, d1, a1, x1[12], S24, u); /* 32 */
7421 - for (length = 0; key[length] && length < 15; length++);
7423 + HH (a0, b0, c0, d0, x0[ 5], S31, (u = AC33)); /* 33 */
7424 + HH (a1, b1, c1, d1, x1[ 5], S31, u); /* 33 */
7425 + HH (d0, a0, b0, c0, x0[ 8], S32, (u = AC34)); /* 34 */
7426 + HH (d1, a1, b1, c1, x1[ 8], S32, u); /* 34 */
7427 + HH (c0, d0, a0, b0, x0[11], S33, (u = AC35)); /* 35 */
7428 + HH (c1, d1, a1, b1, x1[11], S33, u); /* 35 */
7429 + HH (b0, c0, d0, a0, x0[14], S34, (u = AC36)); /* 36 */
7430 + HH (b1, c1, d1, a1, x1[14], S34, u); /* 36 */
7431 + HH (a0, b0, c0, d0, x0[ 1], S31, (u = AC37)); /* 37 */
7432 + HH (a1, b1, c1, d1, x1[ 1], S31, u); /* 37 */
7433 + HH (d0, a0, b0, c0, x0[ 4], S32, (u = AC38)); /* 38 */
7434 + HH (d1, a1, b1, c1, x1[ 4], S32, u); /* 38 */
7435 + HH (c0, d0, a0, b0, x0[ 7], S33, (u = AC39)); /* 39 */
7436 + HH (c1, d1, a1, b1, x1[ 7], S33, u); /* 39 */
7437 + HH (b0, c0, d0, a0, x0[10], S34, (u = AC40)); /* 40 */
7438 + HH (b1, c1, d1, a1, x1[10], S34, u); /* 40 */
7439 + HH (a0, b0, c0, d0, x0[13], S31, (u = AC41)); /* 41 */
7440 + HH (a1, b1, c1, d1, x1[13], S31, u); /* 41 */
7441 + HH (d0, a0, b0, c0, x0[ 0], S32, (u = AC42)); /* 42 */
7442 + HH (d1, a1, b1, c1, x1[ 0], S32, u); /* 42 */
7443 + HH (c0, d0, a0, b0, x0[ 3], S33, (u = AC43)); /* 43 */
7444 + HH (c1, d1, a1, b1, x1[ 3], S33, u); /* 43 */
7445 + HH (b0, c0, d0, a0, x0[ 6], S34, (u = AC44)); /* 44 */
7446 + HH (b1, c1, d1, a1, x1[ 6], S34, u); /* 44 */
7447 + HH (a0, b0, c0, d0, x0[ 9], S31, (u = AC45)); /* 45 */
7448 + HH (a1, b1, c1, d1, x1[ 9], S31, u); /* 45 */
7449 + HH (d0, a0, b0, c0, x0[12], S32, (u = AC46)); /* 46 */
7450 + HH (d1, a1, b1, c1, x1[12], S32, u); /* 46 */
7451 + c0 += H (d0, a0, b0) + (u = AC47);
7452 + ROTATE_LEFT (c0, S33); c0 += d0; /* 47 */
7453 + c1 += H (d1, a1, b1) + u;
7454 + ROTATE_LEFT (c1, S33); c1 += d1; /* 47 */
7455 + HH (b0, c0, d0, a0, x0[ 2], S34, (u = AC48)); /* 48 */
7456 + HH (b1, c1, d1, a1, x1[ 2], S34, u); /* 48 */
7458 - memcpy(patterns.o.p.b, key, patterns.l.p = length);
7459 - memcpy(&patterns.o.p.b[length + 16], PADDING, 40 - length);
7460 - patterns.o.p.w[14] = (length + 16) << 3;
7462 - memcpy(patterns.o.pp.b, key, length);
7463 - memcpy(&patterns.o.pp.b[length], key, length);
7464 - patterns.l.pp = length << 1;
7465 - memcpy(&patterns.o.pp.b[patterns.l.pp + 16], PADDING,
7466 - 40 - patterns.l.pp);
7467 - patterns.o.pp.w[14] = (patterns.l.pp + 16) << 3;
7469 - memcpy(&patterns.e.p.b[16], key, length);
7470 - memcpy(&patterns.e.p.b[16 + length], PADDING, 40 - length);
7471 - patterns.e.p.w[14] = (length + 16) << 3;
7472 - MD5_swap(patterns.e.p.w, patterns.e.p.w, 14);
7474 - memcpy(&patterns.e.pp.b[16], patterns.o.pp.b, patterns.l.pp);
7475 - memcpy(&patterns.e.pp.b[16 + patterns.l.pp], PADDING,
7476 - 40 - patterns.l.pp);
7477 - patterns.e.pp.w[14] = (patterns.l.pp + 16) << 3;
7478 - MD5_swap(patterns.e.pp.w, patterns.e.pp.w, 14);
7480 - order[1].length = patterns.l.pp;
7481 - order[4].length = patterns.l.pp;
7482 - order[7].length = patterns.l.pp;
7483 - order[10].length = length;
7484 - order[13].length = patterns.l.pp;
7485 - order[16].length = patterns.l.pp;
7486 - order[19].length = patterns.l.pp;
7488 + II (a0, b0, c0, d0, x0[ 0], S41, (u = AC49)); /* 49 */
7489 + II (a1, b1, c1, d1, x1[ 0], S41, u); /* 49 */
7490 + II (d0, a0, b0, c0, x0[ 7], S42, (u = AC50)); /* 50 */
7491 + II (d1, a1, b1, c1, x1[ 7], S42, u); /* 50 */
7492 + II (c0, d0, a0, b0, x0[14], S43, (u = AC51)); /* 51 */
7493 + II (c1, d1, a1, b1, x1[14], S43, u); /* 51 */
7494 + II (b0, c0, d0, a0, x0[ 5], S44, (u = AC52)); /* 52 */
7495 + II (b1, c1, d1, a1, x1[ 5], S44, u); /* 52 */
7496 + II (a0, b0, c0, d0, x0[12], S41, (u = AC53)); /* 53 */
7497 + II (a1, b1, c1, d1, x1[12], S41, u); /* 53 */
7498 + II (d0, a0, b0, c0, x0[ 3], S42, (u = AC54)); /* 54 */
7499 + II (d1, a1, b1, c1, x1[ 3], S42, u); /* 54 */
7500 + II (c0, d0, a0, b0, x0[10], S43, (u = AC55)); /* 55 */
7501 + II (c1, d1, a1, b1, x1[10], S43, u); /* 55 */
7502 + II (b0, c0, d0, a0, x0[ 1], S44, (u = AC56)); /* 56 */
7503 + II (b1, c1, d1, a1, x1[ 1], S44, u); /* 56 */
7504 + II (a0, b0, c0, d0, x0[ 8], S41, (u = AC57)); /* 57 */
7505 + II (a1, b1, c1, d1, x1[ 8], S41, u); /* 57 */
7506 + d0 += I (a0, b0, c0) + (u = AC58);
7507 + ROTATE_LEFT (d0, S42); d0 += a0; /* 58 */
7508 + d1 += I (a1, b1, c1) + u;
7509 + ROTATE_LEFT (d1, S42); d1 += a1; /* 58 */
7510 + II (c0, d0, a0, b0, x0[ 6], S43, (u = AC59)); /* 59 */
7511 + II (c1, d1, a1, b1, x1[ 6], S43, u); /* 59 */
7512 + II (b0, c0, d0, a0, x0[13], S44, (u = AC60)); /* 60 */
7513 + II (b1, c1, d1, a1, x1[13], S44, u); /* 60 */
7514 + II (a0, b0, c0, d0, x0[ 4], S41, (u = AC61)); /* 61 */
7515 + II (a1, b1, c1, d1, x1[ 4], S41, u); /* 61 */
7516 + II (d0, a0, b0, c0, x0[11], S42, (u = AC62)); /* 62 */
7517 + II (d1, a1, b1, c1, x1[11], S42, u); /* 62 */
7518 + II (c0, d0, a0, b0, x0[ 2], S43, (u = AC63)); /* 63 */
7519 + II (c1, d1, a1, b1, x1[ 2], S43, u); /* 63 */
7520 + II (b0, c0, d0, a0, x0[ 9], S44, (u = AC64)); /* 64 */
7521 + II (b1, c1, d1, a1, x1[ 9], S44, u); /* 64 */
7523 + out1[3] = Cd + d1;
7525 + out0[0] = Ca + a0;
7526 + out0[1] = Cb + b0;
7527 + out0[2] = Cc + c0;
7528 + out0[3] = Cd + d0;
7530 + out1[0] = Ca + a1;
7531 + out1[1] = Cb + b1;
7532 + out1[2] = Cc + c1;
7535 -void MD5_std_crypt()
7538 - int length, index;
7539 - struct pattern *line;
7540 -#if ARCH_LITTLE_ENDIAN
7544 - memcpy(patterns.o.ps.b, patterns.o.p.b, patterns.l.p);
7545 - memcpy(&patterns.o.ps.b[patterns.l.p], patterns.s, patterns.l.s);
7546 - patterns.l.ps = patterns.l.p + patterns.l.s;
7547 - memcpy(&patterns.o.ps.b[patterns.l.ps + 16], PADDING,
7548 - 40 - patterns.l.ps);
7549 - patterns.o.ps.w[14] = (patterns.l.ps + 16) << 3;
7551 - memcpy(patterns.o.psp.b, patterns.o.ps.b, patterns.l.ps);
7552 - memcpy(&patterns.o.psp.b[patterns.l.ps], patterns.o.p.b, patterns.l.p);
7553 - patterns.l.psp = patterns.l.ps + patterns.l.p;
7554 - memcpy(&patterns.o.psp.b[patterns.l.psp + 16], PADDING,
7555 - 40 - patterns.l.psp);
7556 - patterns.o.psp.w[14] = (patterns.l.psp + 16) << 3;
7558 - memcpy(&patterns.e.sp.b[16], patterns.s, patterns.l.s);
7559 - memcpy(&patterns.e.sp.b[16 + patterns.l.s], patterns.o.p.b,
7561 - memcpy(&patterns.e.sp.b[16 + patterns.l.ps], PADDING,
7562 - 40 - patterns.l.ps);
7563 - patterns.e.sp.w[14] = (patterns.l.ps + 16) << 3;
7564 - MD5_swap(patterns.e.sp.w, patterns.e.sp.w, 14);
7566 - memcpy(&patterns.e.spp.b[16], patterns.s, patterns.l.s);
7567 - memcpy(&patterns.e.spp.b[16 + patterns.l.s], patterns.o.pp.b,
7569 - memcpy(&patterns.e.spp.b[16 + patterns.l.psp], PADDING,
7570 - 40 - patterns.l.psp);
7571 - patterns.e.spp.w[14] = (patterns.l.psp + 16) << 3;
7572 - MD5_swap(patterns.e.spp.w, patterns.e.spp.w, 14);
7574 - order[0].length = patterns.l.psp;
7575 - order[2].length = patterns.l.psp;
7576 - order[3].length = patterns.l.ps;
7577 - order[5].length = patterns.l.psp;
7578 - order[6].length = patterns.l.psp;
7579 - order[8].length = patterns.l.psp;
7580 - order[9].length = patterns.l.psp;
7581 - order[11].length = patterns.l.psp;
7582 - order[12].length = patterns.l.psp;
7583 - order[14].length = patterns.l.psp;
7584 - order[15].length = patterns.l.psp;
7585 - order[17].length = patterns.l.ps;
7586 - order[18].length = patterns.l.psp;
7587 - order[20].length = patterns.l.psp;
7589 - memcpy(&block, patterns.o.psp.b, patterns.l.psp);
7590 - memcpy(&block.b[patterns.l.psp], PADDING, 56 - patterns.l.psp);
7591 - block.w[14] = patterns.l.psp << 3;
7592 - MD5_swap(block.w, block.w, 14);
7593 - MD5_body(block.w, MD5_out);
7594 - MD5_swap(MD5_out, MD5_out, 4);
7596 - memcpy(&block, patterns.o.p.b, patterns.l.p);
7597 - memcpy(&block.b[patterns.l.p], "$1$", 3);
7598 - memcpy(&block.b[patterns.l.p + 3], patterns.s, patterns.l.s);
7599 - memcpy(&block.b[patterns.l.ps + 3], MD5_out, patterns.l.p);
7600 - length = patterns.l.psp + 3;
7601 - if ((index = patterns.l.p))
7603 - block.b[length++] = (index & 1) ? 0 : patterns.o.p.b[0];
7604 - } while (index >>= 1);
7605 - memcpy(&block.b[length], PADDING, 56 - length);
7606 - block.w[14] = length << 3;
7607 - MD5_swap(block.w, block.w, 14);
7608 - MD5_body(block.w, order[0].even->w);
7610 - index = 500; line = order;
7612 -#if ARCH_LITTLE_ENDIAN
7613 -#if ARCH_ALLOWS_UNALIGNED
7614 - MD5_body(line->even->w,
7615 - (MD5_word *)&line->odd->b[line->length]);
7617 - MD5_body(line->even->w, MD5_out);
7618 - memcpy(&line->odd->b[line->length], MD5_out, 16);
7620 - last = line->odd->w;
7621 - if (++line >= order + 21) line = order;
7622 - MD5_body(last, line->even->w);
7624 - MD5_body(line->even->w, MD5_out);
7625 - MD5_swap(MD5_out, MD5_out, 4);
7626 - memcpy(&line->odd->b[line->length], MD5_out, 16);
7627 - MD5_swap(line->odd->w, block.w, 14);
7628 - block.w[14] = line->odd->w[14];
7629 - if (++line >= order + 21) line = order;
7630 - MD5_body(block.w, line->even->w);
7632 - } while (--index);
7634 - memcpy(MD5_out, line->even, 16);
7637 char *MD5_std_get_salt(char *ciphertext)
7639 @@ -574,10 +867,10 @@
7641 #define TO_BINARY(b1, b2, b3) \
7643 - (MD5_word)atoi64[(ARCH_INDEX)pos[0]] | \
7644 - ((MD5_word)atoi64[(ARCH_INDEX)pos[1]] << 6) | \
7645 - ((MD5_word)atoi64[(ARCH_INDEX)pos[2]] << 12) | \
7646 - ((MD5_word)atoi64[(ARCH_INDEX)pos[3]] << 18); \
7647 + (MD5_word)atoi64[ARCH_INDEX(pos[0])] | \
7648 + ((MD5_word)atoi64[ARCH_INDEX(pos[1])] << 6) | \
7649 + ((MD5_word)atoi64[ARCH_INDEX(pos[2])] << 12) | \
7650 + ((MD5_word)atoi64[ARCH_INDEX(pos[3])] << 18); \
7652 out.b[b1] = value >> 16; \
7653 out.b[b2] = value >> 8; \
7655 TO_BINARY(3, 9, 15);
7656 TO_BINARY(4, 10, 5);
7658 - (MD5_word)atoi64[(ARCH_INDEX)pos[0]] |
7659 - ((MD5_word)atoi64[(ARCH_INDEX)pos[1]] << 6);
7660 + (MD5_word)atoi64[ARCH_INDEX(pos[0])] |
7661 + ((MD5_word)atoi64[ARCH_INDEX(pos[1])] << 6);
7663 MD5_swap(out.w, out.w, 4);
7665 diff -ruN john-1.6/src/MD5_std.h john-1.6.34/src/MD5_std.h
7666 --- john-1.6/src/MD5_std.h 1998-12-03 01:29:50.000000000 +0100
7667 +++ john-1.6.34/src/MD5_std.h 2000-06-25 07:06:03.000000000 +0200
7670 * This file is part of John the Ripper password cracker,
7671 - * Copyright (c) 1996-98 by Solar Designer
7672 + * Copyright (c) 1996-2000 by Solar Designer
7676 - * Standard FreeBSD MD5 implementation.
7677 + * FreeBSD-style MD5-based password hash implementation.
7680 #ifndef _JOHN_MD5_STD_H
7682 typedef MD5_word MD5_binary[4];
7685 + * Various structures for internal use.
7696 + MD5_block *even, *odd;
7702 + int p, s, ps, pp, psp;
7705 + MD5_block p, sp, pp, spp;
7708 + MD5_block p, ps, pp, psp;
7716 + MD5_word masks[2];
7732 + MD5_binary out[MD5_N];
7734 + MD5_block block[MD5_N];
7735 + MD5_pattern order[21][MD5_N];
7736 + MD5_pool pool[MD5_N];
7737 +} MD5_std_combined;
7739 +extern MD5_std_combined MD5_std_all;
7742 * MD5_std_crypt() output buffer.
7744 -extern MD5_binary MD5_out;
7745 +#define MD5_out MD5_std_all.out
7748 +#define MD5_ALGORITHM_NAME "32/" ARCH_BITS_STR " X2"
7750 #define MD5_ALGORITHM_NAME "32/" ARCH_BITS_STR
7754 + * Initializes the internal structures.
7756 +extern void MD5_std_init(void);
7759 * Sets a salt for MD5_std_crypt().
7760 @@ -36,12 +102,12 @@
7761 * Sets a key for MD5_std_crypt().
7762 * Currently only supports keys up to 15 characters long.
7764 -extern void MD5_std_set_key(char *key);
7765 +extern void MD5_std_set_key(char *key, int index);
7768 * Main encryption routine, sets MD5_out.
7770 -extern void MD5_std_crypt();
7771 +extern void MD5_std_crypt(void);
7774 * Returns the salt for MD5_std_set_salt().
7775 diff -ruN john-1.6/src/memory.h john-1.6.34/src/memory.h
7776 --- john-1.6/src/memory.h 1998-12-03 01:29:50.000000000 +0100
7777 +++ john-1.6.34/src/memory.h 1999-06-19 05:34:13.000000000 +0200
7780 #define MEM_ALIGN_NONE 1
7781 #define MEM_ALIGN_WORD ARCH_SIZE
7782 +#define MEM_ALIGN_CACHE (ARCH_SIZE * 8)
7785 * Block size used by mem_alloc_tiny().
7786 diff -ruN john-1.6/src/mips32.h john-1.6.34/src/mips32.h
7787 --- john-1.6/src/mips32.h 1998-12-03 01:29:50.000000000 +0100
7788 +++ john-1.6.34/src/mips32.h 2000-05-08 09:05:13.000000000 +0200
7791 * This file is part of John the Ripper password cracker,
7792 - * Copyright (c) 1996-98 by Solar Designer
7793 + * Copyright (c) 1996-2000 by Solar Designer
7798 #ifndef _JOHN_ARCH_H
7799 #define _JOHN_ARCH_H
7801 -#define ARCH_GENERIC 1
7802 #define ARCH_WORD long
7804 #define ARCH_BITS 32
7805 +#define ARCH_BITS_LOG 5
7806 #define ARCH_BITS_STR "32"
7807 #define ARCH_LITTLE_ENDIAN 0
7808 #define ARCH_INT_GT_32 0
7809 #define ARCH_ALLOWS_UNALIGNED 0
7810 -#define ARCH_INDEX unsigned int
7811 +#define ARCH_INDEX(x) ((unsigned int)(unsigned char)(x))
7819 +#define DES_BS_ASM 0
7821 +#define DES_BS_VECTOR 0
7822 +#define DES_BS_EXPAND 1
7831 diff -ruN john-1.6/src/mips64.h john-1.6.34/src/mips64.h
7832 --- john-1.6/src/mips64.h 1998-12-03 01:29:50.000000000 +0100
7833 +++ john-1.6.34/src/mips64.h 2000-05-08 09:05:18.000000000 +0200
7836 * This file is part of John the Ripper password cracker,
7837 - * Copyright (c) 1996-98 by Solar Designer
7838 + * Copyright (c) 1996-2000 by Solar Designer
7843 #ifndef _JOHN_ARCH_H
7844 #define _JOHN_ARCH_H
7846 -#define ARCH_GENERIC 1
7847 #define ARCH_WORD long
7849 #define ARCH_BITS 64
7850 +#define ARCH_BITS_LOG 6
7851 #define ARCH_BITS_STR "64"
7852 #define ARCH_LITTLE_ENDIAN 0
7853 #define ARCH_INT_GT_32 0
7854 #define ARCH_ALLOWS_UNALIGNED 0
7855 -#define ARCH_INDEX unsigned int
7856 +#define ARCH_INDEX(x) ((unsigned int)(unsigned char)(x))
7864 +#define DES_BS_ASM 0
7866 +#define DES_BS_VECTOR 0
7867 +#define DES_BS_EXPAND 1
7876 diff -ruN john-1.6/src/misc.c john-1.6.34/src/misc.c
7877 --- john-1.6/src/misc.c 1998-12-03 01:29:50.000000000 +0100
7878 +++ john-1.6.34/src/misc.c 1999-09-22 05:57:40.000000000 +0200
7881 * This file is part of John the Ripper password cracker,
7882 - * Copyright (c) 1996-98 by Solar Designer
7883 + * Copyright (c) 1996-99 by Solar Designer
7896 diff -ruN john-1.6/src/misc.h john-1.6.34/src/misc.h
7897 --- john-1.6/src/misc.h 1998-12-03 01:29:50.000000000 +0100
7898 +++ john-1.6.34/src/misc.h 2001-10-22 06:46:52.000000000 +0200
7901 * This file is part of John the Ripper password cracker,
7902 - * Copyright (c) 1996-98 by Solar Designer
7903 + * Copyright (c) 1996-99 by Solar Designer
7909 * Exit on error. Terminates the process with non-zero exit status.
7911 -extern void error();
7912 +extern void error(void);
7915 * Similar to perror(), but supports formatted output, and calls error().
7919 * Similar to fgets(), but doesn't leave the newline character in the buffer,
7920 - * and skips to the end of long lines. Handles both UNIX and DOS style text
7921 + * and skips to the end of long lines. Handles both Unix and DOS style text
7924 extern char *fgetl(char *s, int size, FILE *stream);
7927 - * Similar to strncpy(), but terminates with only one null if there's room
7928 - * instead of null padding to the supplied size like strncpy() does.
7929 + * Similar to strncpy(), but terminates with only one NUL if there's room
7930 + * instead of padding to the supplied size like strncpy() does.
7932 extern char *strnfcpy(char *dst, char *src, int size);
7935 - * Similar to the above, but always null terminates the string.
7936 + * Similar to the above, but always NUL terminates the string.
7938 extern char *strnzcpy(char *dst, char *src, int size);
7941 - * Similar to strncat(), but total buffer size is supplied, and always null
7942 + * Similar to strncat(), but total buffer size is supplied, and always NUL
7943 * terminates the string.
7945 extern char *strnzcat(char *dst, char *src, int size);
7946 diff -ruN john-1.6/src/options.c john-1.6.34/src/options.c
7947 --- john-1.6/src/options.c 1998-12-03 01:29:50.000000000 +0100
7948 +++ john-1.6.34/src/options.c 2003-01-15 03:59:01.000000000 +0100
7951 * This file is part of John the Ripper password cracker,
7952 - * Copyright (c) 1996-98 by Solar Designer
7953 + * Copyright (c) 1996-2002 by Solar Designer
7969 +/* nonstd.c and parts of x86-mmx.S aren't mine */
7970 +#define JOHN_COPYRIGHT \
7971 + "Solar Designer and others"
7973 +#define JOHN_COPYRIGHT \
7977 #define JOHN_USAGE \
7978 -"\nJohn the Ripper Version " JOHN_VERSION \
7979 -" Copyright (c) 1996-98 by Solar Designer\n" \
7980 +"John the Ripper password cracker, version " JOHN_VERSION "\n" \
7981 +"Copyright (c) 1996-2003 by " JOHN_COPYRIGHT "\n" \
7983 "Usage: %s [OPTIONS] [PASSWORD-FILES]\n" \
7984 "-single \"single crack\" mode\n" \
7985 diff -ruN john-1.6/src/params.h john-1.6.34/src/params.h
7986 --- john-1.6/src/params.h 1998-12-03 01:29:50.000000000 +0100
7987 +++ john-1.6.34/src/params.h 2003-06-29 15:05:05.000000000 +0200
7990 * This file is part of John the Ripper password cracker,
7991 - * Copyright (c) 1996-98 by Solar Designer
7992 + * Copyright (c) 1996-2003 by Solar Designer
7998 * John's version number.
8000 -#define JOHN_VERSION "1.6"
8001 +#define JOHN_VERSION "1.6.34"
8004 - * Crash recovery file format version number.
8005 + * Is this a system-wide installation? *BSD ports and Linux distributions
8006 + * will probably want to set this to 1 for their builds of John.
8008 +#ifndef JOHN_SYSTEMWIDE
8009 +#define JOHN_SYSTEMWIDE 0
8012 +#if JOHN_SYSTEMWIDE
8013 +#define JOHN_SYSTEMWIDE_EXEC "/usr/libexec/john"
8014 +#define JOHN_SYSTEMWIDE_HOME "/usr/share/john"
8015 +#define JOHN_PRIVATE_HOME "~/.john"
8019 + * Crash recovery file format version strings.
8021 #define RECOVERY_VERSION_0 "REC0"
8022 #define RECOVERY_VERSION_1 "REC1"
8023 -#define RECOVERY_VERSION_CURRENT RECOVERY_VERSION_1
8024 +#define RECOVERY_VERSION_2 "REC2"
8025 +#define RECOVERY_VERSION_CURRENT RECOVERY_VERSION_2
8028 - * Charset file format version number.
8029 + * Charset file format version string.
8031 #define CHARSET_VERSION "CHR1"
8037 -#define LOG_NAME "~/john.pot"
8038 -#define CFG_NAME "~/john.ini"
8039 -#define RECOVERY_NAME "~/restore"
8040 -#define WORDLIST_NAME "~/password.lst"
8041 +#define CFG_FULL_NAME "$JOHN/john.conf"
8042 +#define CFG_ALT_NAME "$JOHN/john.ini"
8043 +#if JOHN_SYSTEMWIDE
8044 +#define CFG_PRIVATE_FULL_NAME JOHN_PRIVATE_HOME "/john.conf"
8045 +#define CFG_PRIVATE_ALT_NAME JOHN_PRIVATE_HOME "/john.ini"
8046 +#define LOG_NAME JOHN_PRIVATE_HOME "/john.pot"
8047 +#define RECOVERY_NAME JOHN_PRIVATE_HOME "/restore"
8049 +#define LOG_NAME "$JOHN/john.pot"
8050 +#define RECOVERY_NAME "$JOHN/restore"
8052 +#define WORDLIST_NAME "$JOHN/password.lst"
8055 * Configuration file section names.
8056 diff -ruN john-1.6/src/pa-risc.h john-1.6.34/src/pa-risc.h
8057 --- john-1.6/src/pa-risc.h 1998-12-03 01:29:50.000000000 +0100
8058 +++ john-1.6.34/src/pa-risc.h 2000-05-08 09:05:36.000000000 +0200
8061 * This file is part of John the Ripper password cracker,
8062 - * Copyright (c) 1996-98 by Solar Designer
8063 + * Copyright (c) 1996-2000 by Solar Designer
8068 #ifndef _JOHN_ARCH_H
8069 #define _JOHN_ARCH_H
8071 -#define ARCH_GENERIC 1
8072 #define ARCH_WORD long
8074 #define ARCH_BITS 32
8075 +#define ARCH_BITS_LOG 5
8076 #define ARCH_BITS_STR "32"
8077 #define ARCH_LITTLE_ENDIAN 0
8078 #define ARCH_INT_GT_32 0
8079 #define ARCH_ALLOWS_UNALIGNED 0
8080 -#define ARCH_INDEX unsigned int
8081 +#define ARCH_INDEX(x) ((unsigned int)(unsigned char)(x))
8089 +#define DES_BS_ASM 0
8091 +#define DES_BS_VECTOR 8
8092 +#define DES_BS_EXPAND 0
8093 +#define DES_BS_ALGORITHM_NAME "32/32x8V BS"
8100 diff -ruN john-1.6/src/path.c john-1.6.34/src/path.c
8101 --- john-1.6/src/path.c 1998-12-03 01:29:50.000000000 +0100
8102 +++ john-1.6.34/src/path.c 2000-03-15 00:42:04.000000000 +0100
8105 * This file is part of John the Ripper password cracker,
8106 - * Copyright (c) 1996-98 by Solar Designer
8107 + * Copyright (c) 1996-2000 by Solar Designer
8118 -static char *home_path = NULL;
8119 -static size_t home_path_length;
8120 +static char *john_home_path = NULL;
8121 +static int john_home_length;
8123 +#if JOHN_SYSTEMWIDE
8124 +#include <unistd.h>
8127 +#include <sys/types.h>
8128 +#include <sys/stat.h>
8130 +static char *user_home_path = NULL;
8131 +static int user_home_length;
8134 void path_init(char **argv)
8136 +#if JOHN_SYSTEMWIDE
8137 + struct passwd *pw;
8138 +#ifdef JOHN_PRIVATE_HOME
8145 - if (!argv[0]) error();
8147 - if (!home_path && (pos = strrchr(argv[0], '/'))) {
8148 - home_path_length = pos - argv[0] + 1;
8149 - if (home_path_length >= PATH_BUFFER_SIZE)
8150 - home_path_length = PATH_BUFFER_SIZE - 1;
8152 - home_path = mem_alloc(PATH_BUFFER_SIZE);
8153 +#if JOHN_SYSTEMWIDE
8154 + john_home_path = mem_alloc(PATH_BUFFER_SIZE);
8155 + strnzcpy(john_home_path, JOHN_SYSTEMWIDE_HOME "/", PATH_BUFFER_SIZE);
8156 + john_home_length = strlen(john_home_path);
8158 + if (user_home_path) return;
8159 + pw = getpwuid(getuid());
8163 + user_home_length = strlen(pw->pw_dir) + 1;
8164 + if (user_home_length >= PATH_BUFFER_SIZE) return;
8166 + user_home_path = mem_alloc(PATH_BUFFER_SIZE);
8167 + memcpy(user_home_path, pw->pw_dir, user_home_length - 1);
8168 + user_home_path[user_home_length - 1] = '/';
8170 +#ifdef JOHN_PRIVATE_HOME
8171 + private = path_expand(JOHN_PRIVATE_HOME);
8172 + if (mkdir(private, S_IRUSR | S_IWUSR | S_IXUSR)) {
8173 + if (errno != EEXIST) pexit("mkdir: %s", private);
8175 + fprintf(stderr, "Created directory: %s\n", private);
8179 + if (!john_home_path && (pos = strrchr(argv[0], '/'))) {
8180 + john_home_length = pos - argv[0] + 1;
8181 + if (john_home_length >= PATH_BUFFER_SIZE) return;
8183 - memcpy(home_path, argv[0], home_path_length);
8184 + john_home_path = mem_alloc(PATH_BUFFER_SIZE);
8185 + memcpy(john_home_path, argv[0], john_home_length);
8190 char *path_expand(char *name)
8192 + if (!strncmp(name, "$JOHN/", 6)) {
8193 + if (john_home_path &&
8194 + john_home_length + strlen(name) - 6 < PATH_BUFFER_SIZE) {
8195 + strnzcpy(&john_home_path[john_home_length], &name[6],
8196 + PATH_BUFFER_SIZE - john_home_length);
8197 + return john_home_path;
8202 +#if JOHN_SYSTEMWIDE
8203 if (!strncmp(name, "~/", 2)) {
8205 - strnzcpy(&home_path[home_path_length], &name[2],
8206 - PATH_BUFFER_SIZE - home_path_length);
8213 + if (user_home_path &&
8214 + user_home_length + strlen(name) - 2 < PATH_BUFFER_SIZE) {
8215 + strnzcpy(&user_home_path[user_home_length], &name[2],
8216 + PATH_BUFFER_SIZE - user_home_length);
8217 + return user_home_path;
8227 +void path_done(void)
8229 - mem_free((void **)&home_path);
8230 + mem_free((void **)&john_home_path);
8231 +#if JOHN_SYSTEMWIDE
8232 + mem_free((void **)&user_home_path);
8235 diff -ruN john-1.6/src/path.h john-1.6.34/src/path.h
8236 --- john-1.6/src/path.h 1998-12-03 01:29:50.000000000 +0100
8237 +++ john-1.6.34/src/path.h 2000-03-14 23:12:53.000000000 +0100
8240 * This file is part of John the Ripper password cracker,
8241 - * Copyright (c) 1996-98 by Solar Designer
8242 + * Copyright (c) 1996-2000 by Solar Designer
8247 extern void path_init(char **argv);
8250 - * Expands "~/" in a path name.
8251 + * Expands "$JOHN/" and "~/" in a path name.
8253 extern char *path_expand(char *name);
8256 * Frees the memory allocated in path_init().
8258 -extern void path_done();
8259 +extern void path_done(void);
8262 diff -ruN john-1.6/src/ppc.h john-1.6.34/src/ppc.h
8263 --- john-1.6/src/ppc.h 1998-12-03 01:29:50.000000000 +0100
8264 +++ john-1.6.34/src/ppc.h 2000-05-08 09:05:39.000000000 +0200
8267 * This file is part of John the Ripper password cracker,
8268 - * Copyright (c) 1996-98 by Solar Designer
8269 + * Copyright (c) 1996-2000 by Solar Designer
8274 #ifndef _JOHN_ARCH_H
8275 #define _JOHN_ARCH_H
8277 -#define ARCH_GENERIC 1
8278 #define ARCH_WORD long
8280 #define ARCH_BITS 32
8281 +#define ARCH_BITS_LOG 5
8282 #define ARCH_BITS_STR "32"
8283 #define ARCH_LITTLE_ENDIAN 0
8284 #define ARCH_INT_GT_32 0
8285 #define ARCH_ALLOWS_UNALIGNED 0
8286 -#define ARCH_INDEX unsigned int
8287 +#define ARCH_INDEX(x) ((unsigned int)(unsigned char)(x))
8295 +#define DES_BS_ASM 0
8297 +#define DES_BS_VECTOR 0
8298 +#define DES_BS_EXPAND 1
8307 diff -ruN john-1.6/src/recovery.c john-1.6.34/src/recovery.c
8308 --- john-1.6/src/recovery.c 1998-12-03 01:29:50.000000000 +0100
8309 +++ john-1.6.34/src/recovery.c 2001-05-11 15:50:17.000000000 +0200
8312 * This file is part of John the Ripper password cracker,
8313 - * Copyright (c) 1996-98 by Solar Designer
8314 + * Copyright (c) 1996-2001 by Solar Designer
8319 #include "recovery.h"
8321 char *rec_name = RECOVERY_NAME;
8322 +int rec_version = 0;
8327 static void (*rec_save_mode)(FILE *file);
8329 #if defined(LOCK_EX) && OS_FLOCK
8330 -static void rec_lock()
8331 +static void rec_lock(void)
8333 if (flock(rec_fd, LOCK_EX | LOCK_NB)) {
8334 if (errno == EWOULDBLOCK) {
8336 rec_save_mode = save_mode;
8340 +void rec_save(void)
8345 void rec_restore_args(int lock)
8347 char line[LINE_BUFFER_SIZE];
8351 char *save_rec_name;
8354 if (!fgetl(line, sizeof(line), rec_file)) rec_format_error("fgets");
8357 - if (!strcmp(line, RECOVERY_VERSION_1)) version = 1; else
8359 + if (!strcmp(line, RECOVERY_VERSION_2)) rec_version = 2; else
8360 + if (!strcmp(line, RECOVERY_VERSION_1)) rec_version = 1; else
8361 if (strcmp(line, RECOVERY_VERSION_0)) rec_format_error("fgets");
8363 if (fscanf(rec_file, "%d\n", &argc) != 1) rec_format_error("fscanf");
8365 &status.crypts.hi) != 4) rec_format_error("fscanf");
8366 if (!status_restored_time) status_restored_time = 1;
8368 - if (version == 0) {
8369 + if (rec_version == 0) {
8371 status.progress = -1;
8373 diff -ruN john-1.6/src/recovery.h john-1.6.34/src/recovery.h
8374 --- john-1.6/src/recovery.h 1998-12-03 01:29:50.000000000 +0100
8375 +++ john-1.6.34/src/recovery.h 2001-05-11 15:51:13.000000000 +0200
8378 * This file is part of John the Ripper password cracker,
8379 - * Copyright (c) 1996-98 by Solar Designer
8380 + * Copyright (c) 1996-2001 by Solar Designer
8385 extern char *rec_name;
8388 + * Crash recovery file format version number.
8390 +extern int rec_version;
8393 * Original command line arguments.
8395 extern int rec_argc;
8398 * Saves the command line arguments and cracking mode specific information.
8400 -extern void rec_save();
8401 +extern void rec_save(void);
8404 * Closes the crash recovery file.
8405 diff -ruN john-1.6/src/rules.c john-1.6.34/src/rules.c
8406 --- john-1.6/src/rules.c 1998-12-03 01:29:50.000000000 +0100
8407 +++ john-1.6.34/src/rules.c 2002-05-08 20:07:17.000000000 +0200
8410 * This file is part of John the Ripper password cracker,
8411 - * Copyright (c) 1996-98 by Solar Designer
8412 + * Copyright (c) 1996-99 by Solar Designer
8422 #include "formats.h"
8427 #define POSITION { \
8428 - if ((pos = rules_length[(ARCH_INDEX)RULE]) == INVALID_LENGTH) { \
8429 + if ((pos = rules_length[ARCH_INDEX(RULE)]) == INVALID_LENGTH) { \
8431 rules_errno = RULES_ERROR_POSITION; \
8435 #define CLASS(start, true, false) { \
8436 if ((value = RULE) == '?') { \
8437 - if (!(class = rules_classes[(ARCH_INDEX)RULE])) { \
8438 + if (!(class = rules_classes[ARCH_INDEX(RULE)])) { \
8440 rules_errno = RULES_ERROR_CLASS; \
8442 rules_errno = RULES_ERROR_END; \
8445 - for (pos = (start); (ARCH_INDEX)in[pos]; pos++) \
8446 - if (class[(ARCH_INDEX)in[pos]]) { \
8447 + for (pos = (start); ARCH_INDEX(in[pos]); pos++) \
8448 + if (class[ARCH_INDEX(in[pos])]) { \
8453 rules_errno = RULES_ERROR_END; \
8456 - for (pos = (start); (ARCH_INDEX)in[pos]; pos++) \
8457 + for (pos = (start); ARCH_INDEX(in[pos]); pos++) \
8458 if (in[pos] == value) { \
8461 @@ -123,30 +122,30 @@
8464 #define CONV(conv) { \
8465 - for (pos = 0; (out[pos] = (conv)[(ARCH_INDEX)in[pos]]); pos++); \
8466 + for (pos = 0; (out[pos] = (conv)[ARCH_INDEX(in[pos])]); pos++); \
8469 static void rules_init_class(char name, char *valid)
8473 - rules_classes[(ARCH_INDEX)name] =
8474 + rules_classes[ARCH_INDEX(name)] =
8475 mem_alloc_tiny(0x100, MEM_ALIGN_NONE);
8476 - memset(rules_classes[(ARCH_INDEX)name], 0, 0x100);
8477 - for (pos = valid; (ARCH_INDEX)*pos; pos++)
8478 - rules_classes[(ARCH_INDEX)name][(ARCH_INDEX)*pos] = 1;
8479 + memset(rules_classes[ARCH_INDEX(name)], 0, 0x100);
8480 + for (pos = valid; ARCH_INDEX(*pos); pos++)
8481 + rules_classes[ARCH_INDEX(name)][ARCH_INDEX(*pos)] = 1;
8483 if (name >= 'a' && name <= 'z') {
8485 - rules_classes[(ARCH_INDEX)inv] =
8486 + rules_classes[ARCH_INDEX(inv)] =
8487 mem_alloc_tiny(0x100, MEM_ALIGN_NONE);
8488 - memset(rules_classes[(ARCH_INDEX)inv], 1, 0x100);
8489 - for (pos = valid; (ARCH_INDEX)*pos; pos++)
8490 - rules_classes[(ARCH_INDEX)inv][(ARCH_INDEX)*pos] = 0;
8491 + memset(rules_classes[ARCH_INDEX(inv)], 1, 0x100);
8492 + for (pos = valid; ARCH_INDEX(*pos); pos++)
8493 + rules_classes[ARCH_INDEX(inv)][ARCH_INDEX(*pos)] = 0;
8497 -static void rules_init_classes()
8498 +static void rules_init_classes(void)
8500 memset(rules_classes, 0, sizeof(rules_classes));
8502 @@ -172,12 +171,12 @@
8503 for (pos = 0; pos < 0x100; pos++) conv[pos] = pos;
8506 - conv[(ARCH_INDEX)*src++] = *dst++;
8507 + conv[ARCH_INDEX(*src++)] = *dst++;
8512 -static void rules_init_convs()
8513 +static void rules_init_convs(void)
8515 conv_shift = rules_init_conv(conv_source, CONV_SHIFT);
8516 conv_invert = rules_init_conv(conv_source, CONV_INVERT);
8518 in[RULE_WORD_SIZE - 1] = 0;
8521 -/* Crack v4.1 rules */
8522 +/* Crack 4.1 rules */
8526 @@ -303,12 +302,12 @@
8530 - if ((out[0] = conv_toupper[(ARCH_INDEX)in[0]]))
8531 + if ((out[0] = conv_toupper[ARCH_INDEX(in[0])]))
8533 - out[pos] = conv_tolower[(ARCH_INDEX)in[pos]];
8534 + out[pos] = conv_tolower[ARCH_INDEX(in[pos])];
8536 if (out[0] == 'M' && out[1] == 'c')
8537 - out[2] = conv_toupper[(ARCH_INDEX)out[2]];
8538 + out[2] = conv_toupper[ARCH_INDEX(out[2])];
8546 -/* Crack v5.0 rules */
8547 +/* Crack 5.0 rules */
8549 if (in[0]) strcpy(out, &in[1]); else out[0] = 0;
8551 @@ -438,12 +437,12 @@
8555 - if ((out[0] = conv_tolower[(ARCH_INDEX)in[0]]))
8556 + if ((out[0] = conv_tolower[ARCH_INDEX(in[0])]))
8558 - out[pos] = conv_toupper[(ARCH_INDEX)in[pos]];
8559 + out[pos] = conv_toupper[ARCH_INDEX(in[pos])];
8561 if (out[0] == 'm' && out[1] == 'C')
8562 - out[2] = conv_tolower[(ARCH_INDEX)out[2]];
8563 + out[2] = conv_tolower[ARCH_INDEX(out[2])];
8571 - out[pos] = conv_invert[(ARCH_INDEX)out[pos]];
8572 + out[pos] = conv_invert[ARCH_INDEX(out[pos])];
8578 if (!(count = rules_check(start, split))) {
8579 fprintf(stderr, "Invalid rule in %s at line %d: %s\n",
8580 - path_expand(CFG_NAME), rules_line,
8581 + cfg_name, rules_line,
8582 rules_errors[rules_errno]);
8585 diff -ruN john-1.6/src/signals.c john-1.6.34/src/signals.c
8586 --- john-1.6/src/signals.c 1998-12-03 01:29:50.000000000 +0100
8587 +++ john-1.6.34/src/signals.c 2001-05-08 02:59:05.000000000 +0200
8590 * This file is part of John the Ripper password cracker,
8591 - * Copyright (c) 1996-98 by Solar Designer
8592 + * Copyright (c) 1996-2001 by Solar Designer
8597 +#define _POSIX_SOURCE
8600 +#ifdef _SCO_C_DIALECT
8601 +#include <limits.h>
8610 -int event_pending = 0, event_abort = 0, event_save = 0, event_status = 0;
8611 +volatile int event_pending = 0;
8612 +volatile int event_abort = 0, event_save = 0, event_status = 0;
8614 static int timer_save_interval, timer_save_value;
8616 -static void (*sig_yield)(int always);
8622 timer_emu_count = 0; timer_emu_max = 0;
8625 -void sig_timer_emu_tick()
8626 +void sig_timer_emu_tick(void)
8628 static clock_t last = 0;
8634 -static void sig_install_update();
8635 +static void sig_install_update(void);
8637 -static void sig_handle_update()
8638 +static void sig_handle_update(int signum)
8640 event_save = event_pending = 1;
8646 -static void sig_install_update()
8647 +static void sig_install_update(void)
8650 struct sigaction sa;
8651 @@ -98,12 +105,12 @@
8655 -static void sig_remove_update()
8656 +static void sig_remove_update(void)
8658 signal(SIGHUP, SIG_IGN);
8662 +void check_abort(void)
8665 fprintf(stderr, "Session aborted\n");
8670 -static void sig_install_abort();
8671 +static void sig_install_abort(void);
8674 static BOOL sig_handle_abort(DWORD ctrltype)
8679 -static void sig_install_abort()
8680 +static void sig_install_abort(void)
8688 -static void sig_remove_abort()
8689 +static void sig_remove_abort(void)
8691 signal(SIGINT, SIG_DFL);
8692 signal(SIGTERM, SIG_DFL);
8697 -static int sig_getchar()
8698 +static int sig_getchar(void)
8706 -static void sig_install_timer();
8707 +static void sig_install_timer(void);
8709 static void sig_handle_timer(int signum)
8711 @@ -207,13 +214,10 @@
8712 sig_install_timer();
8715 - if (!event_pending && sig_yield)
8718 errno = saved_errno;
8721 -static void sig_install_timer()
8722 +static void sig_install_timer(void)
8725 signal(SIGALRM, sig_handle_timer);
8730 -static void sig_remove_timer()
8731 +static void sig_remove_timer(void)
8734 struct itimerval it;
8736 signal(SIGALRM, SIG_DFL);
8739 -static void sig_done();
8740 +static void sig_done(void);
8743 +void sig_init(void)
8745 timer_save_interval = cfg_get_int(SECTION_OPTIONS, NULL, "Save");
8746 if (timer_save_interval < 0)
8748 sig_install_timer();
8751 -static void sig_done()
8752 +static void sig_done(void)
8754 sig_remove_update();
8756 diff -ruN john-1.6/src/signals.h john-1.6.34/src/signals.h
8757 --- john-1.6/src/signals.h 1998-12-03 01:29:50.000000000 +0100
8758 +++ john-1.6.34/src/signals.h 2001-05-08 21:21:41.000000000 +0200
8761 * This file is part of John the Ripper password cracker,
8762 - * Copyright (c) 1996-98 by Solar Designer
8763 + * Copyright (c) 1996-2001 by Solar Designer
8768 * to clear individual flags in a bitmask without a race condition on RISC,
8769 * or having to block the signals.
8771 -extern int event_pending; /* An event is pending */
8772 -extern int event_abort; /* Abort requested */
8773 -extern int event_save; /* Time to save the crash recovery file */
8774 -extern int event_status; /* Status display requested */
8775 +extern volatile int event_pending; /* An event is pending */
8776 +extern volatile int event_abort; /* Abort requested */
8777 +extern volatile int event_save; /* Save the crash recovery file */
8778 +extern volatile int event_status; /* Status display requested */
8782 * Timer emulation for systems with no setitimer(2).
8784 #include <sys/times.h>
8786 extern void sig_timer_emu_init(clock_t interval);
8787 -extern void sig_timer_emu_tick();
8788 +extern void sig_timer_emu_tick(void);
8792 * Installs the signal handlers.
8794 -extern void sig_init(void (*yield)(int always));
8795 +extern void sig_init(void);
8798 * Terminates the process if event_abort is set.
8800 -extern void check_abort();
8801 +extern void check_abort(void);
8804 diff -ruN john-1.6/src/single.c john-1.6.34/src/single.c
8805 --- john-1.6/src/single.c 1998-12-03 01:29:50.000000000 +0100
8806 +++ john-1.6.34/src/single.c 2000-03-15 00:27:42.000000000 +0100
8809 * This file is part of John the Ripper password cracker,
8810 - * Copyright (c) 1996-98 by Solar Designer
8811 + * Copyright (c) 1996-99 by Solar Designer
8821 #include "signals.h"
8824 fprintf(file, "%d\n", rec_rule);
8827 -static int restore_rule_number()
8828 +static int restore_rule_number(void)
8831 for (rule_number = 0; rule_number < rec_rule; rule_number++)
8833 return restore_rule_number();
8836 -static int get_progress()
8837 +static int get_progress(void)
8839 if (progress) return progress;
8842 memset((*keys)->hash, -1, hash_size);
8845 -static void single_init()
8846 +static void single_init(void)
8848 struct db_salt *salt;
8852 if (rpp_init(rule_ctx, SUBSECTION_SINGLE)) {
8853 fprintf(stderr, "No \"single crack\" mode rules found in %s\n",
8854 - path_expand(CFG_NAME));
8863 -static void single_run()
8864 +static void single_run(void)
8867 struct db_salt *salt;
8872 -static void single_done()
8873 +static void single_done(void)
8875 struct db_salt *salt;
8877 diff -ruN john-1.6/src/sparc64.h john-1.6.34/src/sparc64.h
8878 --- john-1.6/src/sparc64.h 1970-01-01 01:00:00.000000000 +0100
8879 +++ john-1.6.34/src/sparc64.h 2003-01-24 04:41:40.000000000 +0100
8882 + * This file is part of John the Ripper password cracker,
8883 + * Copyright (c) 2003 by Solar Designer
8887 + * Architecture specific parameters for SPARC V9, 64-bit.
8890 +#ifndef _JOHN_ARCH_H
8891 +#define _JOHN_ARCH_H
8893 +#define ARCH_WORD long
8894 +#define ARCH_SIZE 8
8895 +#define ARCH_BITS 64
8896 +#define ARCH_BITS_LOG 6
8897 +#define ARCH_BITS_STR "64"
8898 +#define ARCH_LITTLE_ENDIAN 0
8899 +#define ARCH_INT_GT_32 0
8900 +#define ARCH_ALLOWS_UNALIGNED 0
8901 +#define ARCH_INDEX(x) ((unsigned int)(unsigned char)(x))
8906 +#define CPU_DETECT 0
8912 +#define DES_SCALE 0
8915 +#define DES_BS_ASM 0
8917 +#define DES_BS_VECTOR 0
8918 +#define DES_BS_EXPAND 1
8928 diff -ruN john-1.6/src/sparc.S john-1.6.34/src/sparc.S
8929 --- john-1.6/src/sparc.S 1998-12-03 01:29:50.000000000 +0100
8930 +++ john-1.6.34/src/sparc.S 2001-01-24 20:24:09.000000000 +0100
8933 * This file is part of John the Ripper password cracker,
8934 - * Copyright (c) 1996-98 by Solar Designer
8935 + * Copyright (c) 1996-2001 by Solar Designer
8944 +#define DES_IV _DES_IV
8945 +#define DES_count _DES_count
8946 +#define DES_KS_current _DES_KS_current
8947 +#define DES_KS_table _DES_KS_table
8948 +#define DES_SPE_L _DES_SPE_L
8949 +#define DES_SPE_H _DES_SPE_H
8950 +#define DES_SPE_W _DES_SPE_W
8951 +#define DES_std_crypt _DES_std_crypt
8952 +#define DES_xor_key1 _DES_xor_key1
8953 +#define DES_xor_key2 _DES_xor_key2
8957 + * Load an address assuming that it is 1024-byte aligned if the section
8958 + * alignment for this platform is large enough.
8961 +#define LDAA(addr, reg) set (addr),reg
8963 +#define LDAA(addr, reg) sethi %hi(addr),reg
8969 @@ -202,17 +225,17 @@
8973 - sethi %hi(DES_SPE_L+0x400),SPE_L_4
8974 - sethi %hi(DES_SPE_W),SPE_0
8975 - sethi %hi(DES_SPE_W+0x8000),SPE_1
8976 - sethi %hi(DES_SPE_W+0x10000),SPE_2
8977 - sethi %hi(DES_SPE_W+0x18000),SPE_3
8978 + LDAA (DES_SPE_L+0x400,SPE_L_4)
8979 + LDAA (DES_SPE_W,SPE_0)
8980 + LDAA (DES_SPE_W+0x8000,SPE_1)
8981 + LDAA (DES_SPE_W+0x10000,SPE_2)
8982 + LDAA (DES_SPE_W+0x18000,SPE_3)
8987 - sethi %hi(DES_SPE_L),SPE_L_0
8988 - sethi %hi(DES_SPE_L+0x400),SPE_L_4
8989 + LDAA (DES_SPE_L,SPE_L_0)
8990 + LDAA (DES_SPE_L+0x400,SPE_L_4)
8991 add SPE_L_0,0x808,SPE_H_0
8992 add SPE_L_0,0x100,SPE_L_1
8993 add SPE_L_0,0x200,SPE_L_2
8998 - sethi %hi(DES_KS_current),kp
8999 + LDAA (DES_KS_current,kp)
9007 - sethi %hi(DES_KS_current),kp
9008 + LDAA (DES_KS_current,kp)
9012 @@ -340,7 +363,12 @@
9025 @@ -363,9 +391,22 @@
9032 +.common DES_SPE_W, 0x20000, "bss"
9035 +.common DES_KS_current, 128, "bss"
9036 +.common DES_KS_table, (8 * 128 * 16 * 8), "bss"
9041 .common DES_SPE_W, 0x20000, 1024
9044 .common DES_KS_current, 128, 1024
9045 .common DES_KS_table, (8 * 128 * 16 * 8), 32
9048 diff -ruN john-1.6/src/sparc.sh john-1.6.34/src/sparc.sh
9049 --- john-1.6/src/sparc.sh 1998-12-03 01:29:50.000000000 +0100
9050 +++ john-1.6.34/src/sparc.sh 2000-06-25 07:08:21.000000000 +0200
9054 # This file is part of John the Ripper password cracker,
9055 -# Copyright (c) 1996-98 by Solar Designer
9056 +# Copyright (c) 1996-2000 by Solar Designer
9059 [ $# -eq 3 ] || exit 1
9064 -# Detect the best standard DES algorithm
9065 +# Detect the best non-bitslice DES algorithm
9071 - if ./detect $MODE 0 0 0 0 > arch.h; then
9072 + if ./detect $MODE 0 0 1 0 0 > arch.h; then
9073 rm -f $DES_DEPEND bench
9074 $MAKE $HAMMER NAIL=bench \
9075 BENCH_DES_OBJS_DEPEND="$DES_DEPEND" || exit 1
9078 # Check if bitslice DES is faster
9080 -./detect $DES_BEST 0 1 0 0 > arch.h
9081 +./detect $DES_BEST 0 1 1 0 0 > arch.h
9082 rm -f $DES_DEPEND bench
9084 $MAKE $HAMMER NAIL=bench BENCH_DES_OBJS_DEPEND="$DES_DEPEND" || exit 1
9086 # Produce sparc.h, make sure everything is rebuilt with detected options,
9087 # and do some cleanup
9089 -./detect $DES_BEST 0 $DES_BS 0 0 > sparc.h
9090 +./detect $DES_BEST 0 $DES_BS 1 0 0 > sparc.h
9091 rm -f $DES_DEPEND bench detect best.o detect.o arch.h
9092 diff -ruN john-1.6/src/status.c john-1.6.34/src/status.c
9093 --- john-1.6/src/status.c 1998-12-03 01:29:50.000000000 +0100
9094 +++ john-1.6.34/src/status.c 2001-06-08 23:11:07.000000000 +0200
9097 * This file is part of John the Ripper password cracker,
9098 - * Copyright (c) 1996-98 by Solar Designer
9099 + * Copyright (c) 1996-2001 by Solar Designer
9104 +#define _POSIX_SOURCE
9107 +#ifdef _SCO_C_DIALECT
9108 +#include <limits.h>
9123 struct status_main status;
9124 unsigned int status_restored_time = 0;
9125 -int (*status_get_progress)() = NULL;
9126 +int (*status_get_progress)(void) = NULL;
9128 -static clock_t get_time()
9129 +static clock_t get_time(void)
9136 -void status_init(int (*get_progress)(), int start)
9137 +void status_init(int (*get_progress)(void), int start)
9140 if (!status_restored_time)
9141 memset(&status, 0, sizeof(status));
9142 - status.start_time =
9143 - get_time() - status_restored_time * CLK_TCK;
9144 + status.start_time = get_time();
9147 status_get_progress = get_progress;
9150 void status_update_crypts(unsigned int count)
9152 + unsigned int saved_hi, time;
9155 + saved_hi = status.crypts.hi;
9156 add32to64(&status.crypts, count);
9158 + if (status.crypts.hi != saved_hi) {
9159 + ticks = get_time() - status.start_time;
9160 + if (ticks > ((clock_t)1 << (sizeof(clock_t) * 8 - 2))) {
9161 + time = ticks / CLK_TCK;
9162 + status_restored_time += time;
9163 + status.start_time += (clock_t)time * CLK_TCK;
9168 -unsigned int status_get_time()
9169 +unsigned int status_get_time(void)
9171 - return (get_time() - status.start_time) / CLK_TCK;
9172 + return status_restored_time +
9173 + (get_time() - status.start_time) / CLK_TCK;
9176 static char *status_get_cps(char *buffer)
9178 - unsigned int time, cps_hi, cps_lo;
9181 + unsigned long time;
9182 + unsigned int cps_hi, cps_lo;
9185 - if (!(time = status_get_time())) time = 1;
9186 + use_ticks = !status.crypts.hi && !status_restored_time;
9188 - cps_hi = div64by32lo(&status.crypts, time);
9189 + ticks = get_time() - status.start_time;
9193 + time = status_restored_time + ticks / CLK_TCK;
9194 + if (!time) time = 1;
9196 + tmp = status.crypts;
9197 + if (use_ticks) mul64by32(&tmp, CLK_TCK);
9198 + cps_hi = div64by32lo(&tmp, time);
9200 tmp = status.crypts;
9201 + if (use_ticks) mul64by32(&tmp, CLK_TCK);
9202 mul64by32(&tmp, 100);
9203 cps_lo = div64by32lo(&tmp, time) % 100;
9206 int64 current, next, rem;
9209 - s_words_ptr = &s_words[sizeof(s_words)];
9210 - *--s_words_ptr = 0;
9211 + s_words_ptr = &s_words[sizeof(s_words) - 1];
9214 current = status.crypts;
9217 saved_key ? saved_key : "");
9220 -void status_print()
9221 +void status_print(void)
9225 diff -ruN john-1.6/src/status.h john-1.6.34/src/status.h
9226 --- john-1.6/src/status.h 1998-12-03 01:29:50.000000000 +0100
9227 +++ john-1.6.34/src/status.h 2001-06-02 20:09:05.000000000 +0200
9230 * This file is part of John the Ripper password cracker,
9231 - * Copyright (c) 1996-98 by Solar Designer
9232 + * Copyright (c) 1996-2001 by Solar Designer
9238 extern struct status_main status;
9240 -extern int (*status_get_progress)();
9241 +extern int (*status_get_progress)(void);
9244 * Elapsed time of previous sessions, in seconds.
9246 extern unsigned int status_restored_time;
9249 - * If start is non-zero, sets start_time to current time minus
9250 - * status_restored_time, and the rest of fields to zero. Always
9251 - * initializes the get_progress() handler (can be NULL).
9252 + * If start is non-zero, sets start_time to current time and the rest of
9253 + * fields to zero. Always initializes the get_progress() handler (can be
9256 -extern void status_init(int (*get_progress)(), int start);
9257 +extern void status_init(int (*get_progress)(void), int start);
9260 * Updates the crypts count.
9264 * Returns the elapsed time in seconds.
9266 - * Currently this does not support running for more than 248 days total
9267 - * (assuming CLK_TCK is 100). However, this should survive uptimes of the
9268 - * box we are running on of more than 248 days.
9270 -extern unsigned int status_get_time();
9271 +extern unsigned int status_get_time(void);
9274 * Prints current status to stdout.
9276 -extern void status_print();
9277 +extern void status_print(void);
9280 diff -ruN john-1.6/src/tty.c john-1.6.34/src/tty.c
9281 --- john-1.6/src/tty.c 1998-12-03 01:29:50.000000000 +0100
9282 +++ john-1.6.34/src/tty.c 1999-09-22 06:01:15.000000000 +0200
9285 * This file is part of John the Ripper password cracker,
9286 - * Copyright (c) 1996-98 by Solar Designer
9287 + * Copyright (c) 1996-99 by Solar Designer
9292 static struct termios saved_ti;
9296 +void tty_init(void)
9305 +int tty_getchar(void)
9314 +void tty_done(void)
9318 diff -ruN john-1.6/src/tty.h john-1.6.34/src/tty.h
9319 --- john-1.6/src/tty.h 1998-12-03 01:29:50.000000000 +0100
9320 +++ john-1.6.34/src/tty.h 1999-09-22 05:44:00.000000000 +0200
9323 * This file is part of John the Ripper password cracker,
9324 - * Copyright (c) 1996-98 by Solar Designer
9325 + * Copyright (c) 1996-99 by Solar Designer
9330 * Initializes the terminal for unbuffered non-blocking input. Also registers
9331 * tty_done() via atexit().
9333 -extern void tty_init();
9334 +extern void tty_init(void);
9337 * Reads a character, returns -1 if no data available or on error.
9339 -extern int tty_getchar();
9340 +extern int tty_getchar(void);
9343 * Restores the terminal parameters and closes the file descriptor.
9345 -extern void tty_done();
9346 +extern void tty_done(void);
9349 diff -ruN john-1.6/src/unique.c john-1.6.34/src/unique.c
9350 --- john-1.6/src/unique.c 1998-12-03 01:29:50.000000000 +0100
9351 +++ john-1.6.34/src/unique.c 2002-11-05 21:49:46.000000000 +0100
9354 * This file is part of John the Ripper password cracker,
9355 - * Copyright (c) 1996-98 by Solar Designer
9356 + * Copyright (c) 1996-2002 by Solar Designer
9364 -static void init_hash()
9365 +static void init_hash(void)
9370 buffer.hash[index] = ENTRY_END_HASH;
9373 -static void read_buffer()
9374 +static void read_buffer(void)
9376 char line[LINE_BUFFER_SIZE];
9377 unsigned int ptr, current, *last;
9380 while (fgetl(line, sizeof(line), stdin)) {
9381 last = &buffer.hash[line_hash(line)];
9382 -#if ARCH_LITTLE_ENDIAN
9383 +#if ARCH_LITTLE_ENDIAN && !ARCH_INT_GT_32
9386 current = get_int(last);
9388 put_data(ptr, ENTRY_END_LIST);
9391 -static void write_buffer()
9392 +static void write_buffer(void)
9394 unsigned int ptr, hash;
9400 -static void clean_buffer()
9401 +static void clean_buffer(void)
9403 char line[LINE_BUFFER_SIZE];
9404 unsigned int current, *last;
9405 @@ -149,7 +149,11 @@
9407 while (fgetl(line, sizeof(line), output)) {
9408 last = &buffer.hash[line_hash(line)];
9409 +#if ARCH_LITTLE_ENDIAN && !ARCH_INT_GT_32
9412 + current = get_int(last);
9414 while (current != ENTRY_END_HASH && current != ENTRY_DUPE) {
9415 if (!strcmp(line, &buffer.data[current + 4])) {
9416 put_int(last, get_data(current));
9420 if (ferror(output)) pexit("fgets");
9422 +/* Workaround a Solaris stdio bug. */
9423 + if (fseek(output, 0, SEEK_END) < 0) pexit("fseek");
9426 static void unique_init(char *name)
9428 if (!(output = fdopen(fd, "w+"))) pexit("fdopen");
9431 -static void unique_run()
9432 +static void unique_run(void)
9440 -static void unique_done()
9441 +static void unique_done(void)
9443 if (fclose(output)) pexit("fclose");
9445 diff -ruN john-1.6/src/unshadow.c john-1.6.34/src/unshadow.c
9446 --- john-1.6/src/unshadow.c 1998-12-03 01:29:50.000000000 +0100
9447 +++ john-1.6.34/src/unshadow.c 2001-10-19 14:52:19.000000000 +0200
9450 * This file is part of John the Ripper password cracker,
9451 - * Copyright (c) 1996-98 by Solar Designer
9452 + * Copyright (c) 1996-2001 by Solar Designer
9458 static void process_shadow_line(char *line)
9460 - char *pos1, *pos2;
9461 - struct shadow_entry **entry, *last;
9462 + static struct shadow_entry **entry = NULL;
9463 + struct shadow_entry *last;
9464 + char *login, *passwd, *tail;
9466 + if (!(passwd = strchr(line, ':'))) {
9467 + while (*line == ' ' || *line == '\t') line++;
9469 + if (!strncmp(line, "password = ", 11) && entry)
9470 + (*entry)->passwd = str_alloc_copy(line + 11);
9474 - if (!(pos1 = strchr(line, ':'))) return;
9479 - if (!(pos2 = strchr(pos1, ':')))
9480 - pos2 = pos1 + strlen(pos1);
9481 - if (pos2 - pos1 < 1) return;
9483 + /* DU / Tru64 C2, HP-UX tcb */
9484 + if (!strncmp(passwd, "u_name=", 7)) {
9485 + if ((passwd = strstr(passwd, ":u_pwd=")))
9489 + if (!strncmp(passwd, "u_pwd=", 6) && entry) {
9491 + if ((tail = strchr(passwd, ':')))
9493 + (*entry)->passwd = str_alloc_copy(passwd);
9497 + if (passwd && (tail = strchr(passwd, ':')))
9500 - entry = &shadow_table[login_hash(line)];
9501 + entry = &shadow_table[login_hash(login)];
9503 *entry = mem_alloc_tiny(sizeof(struct shadow_entry), MEM_ALIGN_WORD);
9504 (*entry)->next = last;
9505 - (*entry)->login = str_alloc_copy(line);
9506 - (*entry)->passwd = str_alloc_copy(pos1);
9507 + (*entry)->login = str_alloc_copy(login);
9508 + (*entry)->passwd = passwd ? str_alloc_copy(passwd) : "*";
9511 static void process_passwd_line(char *line)
9513 if (!(pos2 = strchr(pos1, ':')))
9514 pos2 = pos1 + strlen(pos1);
9516 - if ((current = shadow_table[login_hash(line)]))
9517 + if (pos2 > pos1 && (current = shadow_table[login_hash(line)]))
9519 if (!strcmp(current->login, line)) {
9520 printf("%s:%s%s\n", line, current->passwd, pos2);
9521 diff -ruN john-1.6/src/vax.h john-1.6.34/src/vax.h
9522 --- john-1.6/src/vax.h 1970-01-01 01:00:00.000000000 +0100
9523 +++ john-1.6.34/src/vax.h 2000-08-24 00:16:43.000000000 +0200
9526 + * This file is part of John the Ripper password cracker,
9527 + * Copyright (c) 1996-2000 by Solar Designer
9531 + * Architecture specific parameters for VAX.
9534 +#ifndef _JOHN_ARCH_H
9535 +#define _JOHN_ARCH_H
9537 +#define ARCH_WORD long
9538 +#define ARCH_SIZE 4
9539 +#define ARCH_BITS 32
9540 +#define ARCH_BITS_LOG 5
9541 +#define ARCH_BITS_STR "32"
9542 +#define ARCH_LITTLE_ENDIAN 1
9543 +#define ARCH_INT_GT_32 0
9544 +#define ARCH_ALLOWS_UNALIGNED 1
9545 +#define ARCH_INDEX(x) ((unsigned int)(unsigned char)(x))
9550 +#define CPU_DETECT 0
9556 +#define DES_SCALE 1
9559 +#define DES_BS_ASM 0
9561 +#define DES_BS_VECTOR 0
9562 +#define DES_BS_EXPAND 1
9572 diff -ruN john-1.6/src/wordlist.c john-1.6.34/src/wordlist.c
9573 --- john-1.6/src/wordlist.c 1998-12-03 01:29:50.000000000 +0100
9574 +++ john-1.6.34/src/wordlist.c 2000-03-15 00:27:57.000000000 +0100
9577 * This file is part of John the Ripper password cracker,
9578 - * Copyright (c) 1996-98 by Solar Designer
9579 + * Copyright (c) 1996-99 by Solar Designer
9584 fprintf(file, "%d\n%ld\n", rec_rule, rec_pos);
9587 -static int restore_rule_number()
9588 +static int restore_rule_number(void)
9591 for (rule_number = 0; rule_number < rec_rule; rule_number++)
9596 -static void restore_line_number()
9597 +static void restore_line_number(void)
9599 char line[LINE_BUFFER_SIZE];
9605 -static void fix_state()
9606 +static void fix_state(void)
9608 rec_rule = rule_number;
9614 -static int get_progress()
9615 +static int get_progress(void)
9617 struct stat file_stat;
9621 if (rpp_init(rule_ctx = &ctx, SUBSECTION_WORDLIST)) {
9622 fprintf(stderr, "No wordlist mode rules found in %s\n",
9623 - path_expand(CFG_NAME));
9628 diff -ruN john-1.6/src/x86-any.h john-1.6.34/src/x86-any.h
9629 --- john-1.6/src/x86-any.h 1998-12-03 01:29:50.000000000 +0100
9630 +++ john-1.6.34/src/x86-any.h 2001-07-26 17:00:00.000000000 +0200
9633 * This file is part of John the Ripper password cracker,
9634 - * Copyright (c) 1996-98 by Solar Designer
9635 + * Copyright (c) 1996-2001 by Solar Designer
9640 #ifndef _JOHN_ARCH_H
9641 #define _JOHN_ARCH_H
9643 -#define ARCH_GENERIC 0
9644 #define ARCH_WORD long
9646 #define ARCH_BITS 32
9647 +#define ARCH_BITS_LOG 5
9648 #define ARCH_BITS_STR "32"
9649 #define ARCH_LITTLE_ENDIAN 1
9650 #define ARCH_INT_GT_32 0
9651 #define ARCH_ALLOWS_UNALIGNED 1
9652 -#define ARCH_INDEX unsigned int
9653 +#define ARCH_INDEX(x) ((unsigned int)(unsigned char)(x))
9655 -#ifdef __CYGWIN32__
9656 +#if defined(__CYGWIN32__) || defined(__BEOS__)
9664 +#define DES_BS_ASM 0
9666 +#define DES_BS_VECTOR 0
9667 +#define DES_BS_EXPAND 0
9674 diff -ruN john-1.6/src/x86-mmx.h john-1.6.34/src/x86-mmx.h
9675 --- john-1.6/src/x86-mmx.h 1998-12-03 01:29:50.000000000 +0100
9676 +++ john-1.6.34/src/x86-mmx.h 2002-04-11 19:55:55.000000000 +0200
9679 * This file is part of John the Ripper password cracker,
9680 - * Copyright (c) 1996-98 by Solar Designer
9681 + * Copyright (c) 1996-2002 by Solar Designer
9686 #ifndef _JOHN_ARCH_H
9687 #define _JOHN_ARCH_H
9689 -#define ARCH_GENERIC 0
9690 #define ARCH_WORD long
9692 #define ARCH_BITS 32
9693 +#define ARCH_BITS_LOG 5
9694 #define ARCH_BITS_STR "32"
9695 #define ARCH_LITTLE_ENDIAN 1
9696 #define ARCH_INT_GT_32 0
9697 #define ARCH_ALLOWS_UNALIGNED 1
9698 -#define ARCH_INDEX unsigned int
9699 +#define ARCH_INDEX(x) ((unsigned int)(unsigned char)(x))
9701 -#ifdef __CYGWIN32__
9702 +#if defined(__CYGWIN32__) || defined(__BEOS__)
9707 #define CPU_DETECT 1
9709 #define CPU_NAME "MMX"
9710 +#ifndef CPU_FALLBACK
9711 +#define CPU_FALLBACK 0
9714 +#define CPU_FALLBACK_BINARY "john-non-mmx"
9724 +#define DES_STD_ALGORITHM_NAME "48/64 4K MMX"
9725 +#define DES_BS_ASM 1
9727 +#define DES_BS_VECTOR 2
9728 +#define DES_BS_EXPAND 1
9729 +#define DES_BS_ALGORITHM_NAME "64/64 BS MMX"
9736 diff -ruN john-1.6/src/x86-mmx.S john-1.6.34/src/x86-mmx.S
9737 --- john-1.6/src/x86-mmx.S 1970-01-01 01:00:00.000000000 +0100
9738 +++ john-1.6.34/src/x86-mmx.S 2001-06-28 23:15:03.000000000 +0200
9741 + * This file is part of John the Ripper password cracker,
9742 + * Copyright (c) 2000-2001 by Solar Designer and others:
9744 + * The MMX DES S-box code is by Bruce Ford and Rémi Guyomarch, originally
9745 + * for use in the distributed.net clients, included here with permission.
9746 + * Only minor modifications have been made to their S-box code. Optimized
9747 + * S-box expressions are based on work by Matthew Kwan (see nonstd.c).
9749 + * Note: there's some MMX code in x86.S as well.
9753 +#define DES_bs_all _DES_bs_all
9754 +#define DES_bs_init_asm _DES_bs_init_asm
9755 +#define DES_bs_crypt _DES_bs_crypt
9756 +#define DES_bs_crypt_25 _DES_bs_crypt_25
9757 +#define DES_bs_crypt_LM _DES_bs_crypt_LM
9761 + * Some broken systems don't offer section alignments larger than 4 bytes,
9762 + * while for the MMX code we need at least an 8 byte alignment. ALIGN_FIX
9763 + * is here to work around this issue when we happen to get bad addresses.
9767 +#define DO_ALIGN(log) .align (log)
9769 +#define DO_ALIGN(log) .align (1 << (log))
9773 +#define DO_ALIGN(log) .align (log); .space 4
9775 +#define DO_ALIGN(log) .align (1 << (log)); .space 4
9801 +DES_bs_all_fields_not_used_here:
9802 +.space (0x100 + 4 + 4 + 64 * 8)
9803 +DES_bs_all_possible_alignment_gaps:
9806 +#define E(i) DES_bs_all_E+(i)*4
9807 +#define B(i) DES_bs_all_B+(i)*8
9808 +#define tmp_at(i) DES_bs_all_tmp+(i)*8
9810 +#define pnot tmp_at(0)
9819 +#define S1_out1 %mm5
9820 +#define S1_out2 %mm7
9821 +#define S1_out3 %mm2
9822 +#define S1_out4 %mm0
9824 +#define S1_a1 tmp_at(1)
9825 +#define S1_a3 tmp_at(2)
9826 +#define S1_a5 tmp_at(3)
9827 +#define S1_x1 tmp_at(4)
9828 +#define S1_x3 tmp_at(5)
9829 +#define S1_x4 tmp_at(6)
9830 +#define S1_x5 tmp_at(7)
9831 +#define S1_x6 tmp_at(8)
9832 +#define S1_x13 tmp_at(9)
9833 +#define S1_x14 tmp_at(10)
9834 +#define S1_x25 tmp_at(11)
9835 +#define S1_x26 tmp_at(12)
9836 +#define S1_x38 tmp_at(13)
9837 +#define S1_x55 tmp_at(14)
9838 +#define S1_x58 tmp_at(15)
9840 +#define S1(out1, out2, out3, out4, extra) \
9841 + movq %mm0,S1_a1; \
9848 + movq %mm4,S1_a5; \
9850 + movq %mm3,S1_x3; \
9852 + movq %mm6,S1_x1; \
9854 + movq %mm7,S1_x5; \
9856 + movq %mm2,S1_a3; \
9858 + movq %mm3,S1_x4; \
9864 + movq %mm7,S1_x6; \
9868 + movq %mm2,S1_x25; \
9870 + pand S1_a3,%mm4; \
9872 + pxor S1_a3,%mm6; \
9874 + pand S1_x5,%mm6; \
9876 + movq %mm4,S1_x38; \
9878 + movq %mm7,S1_x26; \
9880 + movq %mm2,S1_x13; \
9882 + movq S1_x1,%mm7; \
9884 + movq %mm0,S1_x14; \
9886 + pandn S1_x3,%mm0; \
9890 + pxor S1_x38,%mm5; \
9892 + movq S1_a5,%mm0; \
9894 + movq %mm6,S1_x55; \
9896 + movq S1_x14,%mm6; \
9898 + pand S1_x5,%mm6; \
9900 + movq %mm5,S1_x58; \
9902 + pxor S1_x6,%mm7; \
9904 + pxor S1_x26,%mm2; \
9906 + pand S1_a3,%mm6; \
9909 + movq S1_a1,%mm7; \
9911 + movq S1_x4,%mm2; \
9913 + por S1_x38,%mm2; \
9915 + pxor S1_x25,%mm6; \
9917 + movq S1_a3,%mm4; \
9919 + por S1_x26,%mm4; \
9921 + pxor S1_x14,%mm4; \
9923 + movq S1_x13,%mm2; \
9925 + pxor S1_x55,%mm3; \
9929 + movq S1_a5,%mm4; \
9932 + pxor S1_x58,%mm2; \
9944 +#define S2_out1 %mm1
9946 +#define S2_out3 %mm7
9947 +#define S2_out4 %mm2
9949 +#define S2_a1 tmp_at(1)
9950 +#define S2_a2 tmp_at(2)
9951 +#define S2_a3 tmp_at(3)
9952 +#define S2_a4 tmp_at(4)
9953 +#define S2_x3 tmp_at(5)
9954 +#define S2_x4 tmp_at(6)
9955 +#define S2_x5 tmp_at(7)
9956 +#define S2_x13 tmp_at(8)
9957 +#define S2_x18 tmp_at(9)
9958 +#define S2_x25 tmp_at(10)
9960 +#define S2(out1, out2, out3, out4, extra) \
9961 + movq %mm3,S2_a4; \
9964 + movq %mm0,S2_a1; \
9970 + movq %mm2,S2_a3; \
9972 + movq %mm6,S2_x3; \
9978 + movq %mm1,S2_a2; \
9980 + movq %mm6,S2_x4; \
9982 + movq %mm7,S2_x13; \
9984 + pand S2_a3,%mm3; \
9986 + movq S2_x4,%mm7; \
9988 + pand S2_a4,%mm2; \
9990 + movq %mm6,S2_x5; \
9992 + movq S2_a1,%mm2; \
10000 + pxor S2_x13,%mm1; \
10002 + movq %mm3,out2; \
10003 + pand %mm0,%mm4; \
10004 + movq S2_x13,%mm3; \
10006 + movq %mm2,S2_x18; \
10007 + pxor %mm6,%mm3; \
10008 + movq S2_a2,%mm2; \
10009 + pxor %mm6,%mm0; \
10010 + pxor %mm2,%mm3; \
10011 + pand %mm2,%mm0; \
10012 + pxor %mm3,%mm7; \
10014 + pxor S2_x3,%mm4; \
10015 + pand %mm3,%mm6; \
10016 + pxor %mm0,%mm4; \
10017 + pxor %mm5,%mm6; \
10018 + movq %mm7,S2_x25; \
10019 + pand %mm3,%mm0; \
10020 + movq S2_a3,%mm7; \
10021 + pxor %mm2,%mm5; \
10022 + pxor S2_x5,%mm0; \
10023 + pand %mm4,%mm7; \
10024 + pand S2_a2,%mm4; \
10025 + pxor %mm5,%mm7; \
10026 + por S2_a4,%mm7; \
10027 + movq %mm1,%mm5; \
10028 + por S2_a3,%mm5; \
10030 + pand S2_x18,%mm2; \
10031 + pxor %mm3,%mm4; \
10032 + movq S2_a4,%mm3; \
10033 + pand %mm4,%mm2; \
10034 + pand S2_a3,%mm4; \
10035 + pxor %mm5,%mm0; \
10036 + pxor S2_x25,%mm7; \
10037 + pxor %mm6,%mm4; \
10038 + pxor out3,%mm7; \
10039 + pand %mm3,%mm1; \
10041 + pxor out1,%mm1; \
10042 + pxor %mm4,%mm2; \
10043 + pxor %mm0,%mm1; \
10044 + pxor out4,%mm2; \
10045 + movq %mm1,out1; \
10046 + movq %mm7,out3; \
10049 +#define S3_out1 %mm2
10050 +#define S3_out2 %mm6
10051 +#define S3_out3 %mm3
10052 +#define S3_out4 %mm7
10054 +#define S3_a1 tmp_at(1)
10055 +#define S3_x2 tmp_at(2)
10056 +#define S3_x9 tmp_at(3)
10057 +#define S3_a5 tmp_at(4)
10058 +#define S3_x4 tmp_at(5)
10059 +#define S3_a6 tmp_at(6)
10060 +#define S3_x6 tmp_at(7)
10061 +#define S3_x5 tmp_at(8)
10062 +#define S3_x11 tmp_at(9)
10063 +#define S3_x12 tmp_at(10)
10064 +#define S3_x13 tmp_at(11)
10065 +#define S3_x54 tmp_at(12)
10066 +#define S3_x7 tmp_at(13)
10067 +#define S3_a4 tmp_at(14)
10068 +#define S3_a3 S3_a5
10069 +#define S3_x38 S3_x4
10071 +#define S3(out1, out2, out3, out4, extra) \
10072 + movq %mm0,S3_a1; \
10074 + movq %mm4,%mm0; \
10075 + movq %mm5,%mm6; \
10076 + pxor pnot,%mm6; \
10077 + movq %mm4,%mm7; \
10078 + pxor %mm6,%mm7; \
10079 + movq %mm6,S3_x2; \
10080 + pand %mm2,%mm0; \
10081 + movq %mm7,S3_x9; \
10082 + pxor %mm5,%mm0; \
10083 + movq %mm4,S3_a5; \
10084 + pandn %mm3,%mm4; \
10085 + movq %mm0,S3_x4; \
10087 + movq S3_a5,%mm6; \
10088 + pxor %mm4,%mm0; \
10089 + movq %mm5,S3_a6; \
10090 + pandn %mm2,%mm6; \
10091 + movq %mm0,S3_x6; \
10092 + pxor %mm6,%mm7; \
10093 + movq S3_x2,%mm5; \
10094 + pxor %mm1,%mm0; \
10095 + movq %mm4,S3_x5; \
10096 + movq %mm7,%mm4; \
10097 + por S3_x4,%mm5; \
10098 + pand %mm0,%mm4; \
10099 + movq %mm7,S3_x11; \
10100 + pxor %mm5,%mm6; \
10101 + pxor S3_a5,%mm7; \
10103 + movq %mm4,S3_x12; \
10104 + pand %mm5,%mm4; \
10105 + movq %mm7,S3_x13; \
10107 + movq %mm4,S3_x54; \
10108 + movq %mm2,%mm4; \
10109 + pxor S3_x9,%mm4; \
10110 + pand %mm3,%mm7; \
10111 + movq %mm0,S3_x7; \
10112 + pxor %mm3,%mm4; \
10113 + pxor S3_a6,%mm5; \
10114 + pxor %mm4,%mm6; \
10115 + movq %mm3,S3_a4; \
10117 + movq %mm2,S3_a3; \
10118 + pxor %mm3,%mm5; \
10120 + pxor %mm7,%mm2; \
10121 + pxor S3_x12,%mm7; \
10122 + movq %mm2,%mm4; \
10123 + por S3_x5,%mm2; \
10124 + pand %mm1,%mm7; \
10125 + por S3_x4,%mm4; \
10127 + pxor S3_x11,%mm7; \
10128 + pxor %mm3,%mm2; \
10129 + movq S3_a1,%mm3; \
10130 + pxor S3_a4,%mm4; \
10131 + pand %mm3,%mm7; \
10132 + pxor S3_x7,%mm7; \
10134 + movq %mm4,S3_x38; \
10135 + pxor %mm6,%mm2; \
10136 + pxor out4,%mm7; \
10138 + movq S3_a3,%mm6; \
10139 + movq %mm2,%mm3; \
10140 + pxor S3_x9,%mm6; \
10141 + por S3_x5,%mm6; \
10142 + pxor S3_x38,%mm3; \
10143 + pxor %mm6,%mm4; \
10144 + movq S3_a6,%mm6; \
10145 + pand S3_x11,%mm6; \
10146 + movq %mm7,out4; \
10147 + movq S3_x2,%mm0; \
10148 + pxor %mm6,%mm3; \
10149 + por S3_x6,%mm6; \
10150 + pand %mm1,%mm3; \
10151 + por S3_x38,%mm0; \
10152 + pxor %mm6,%mm3; \
10153 + pxor S3_x13,%mm0; \
10154 + movq %mm5,%mm6; \
10155 + por S3_a1,%mm3; \
10156 + pxor %mm5,%mm0; \
10157 + pand S3_x54,%mm6; \
10158 + pxor %mm4,%mm3; \
10159 + por S3_a1,%mm6; \
10160 + pxor out3,%mm3; \
10161 + pxor %mm0,%mm6; \
10162 + pxor out1,%mm2; \
10163 + movq %mm3,out3; \
10164 + pxor out2,%mm6; \
10165 + movq %mm2,out1; \
10168 +#define S4_out1 %mm1
10169 +#define S4_out2 %mm0
10170 +#define S4_out3 %mm6
10171 +#define S4_out4 %mm5
10173 +#define S4_a2 tmp_at(1)
10174 +#define S4_a3 tmp_at(2)
10175 +#define S4_a4 tmp_at(3)
10176 +#define S4_a6 tmp_at(4)
10178 +#define S4(out1, out2, out3, out4, extra) \
10179 + movq %mm2,%mm6; \
10180 + movq %mm3,S4_a4; \
10181 + movq %mm0,%mm7; \
10182 + movq %mm1,S4_a2; \
10185 + pand %mm4,%mm7; \
10186 + movq %mm1,%mm3; \
10187 + movq %mm5,S4_a6; \
10188 + movq %mm2,S4_a3; \
10189 + movq %mm4,%mm5; \
10190 + pand %mm6,%mm5; \
10192 + pxor pnot,%mm2; \
10193 + pxor %mm5,%mm0; \
10194 + pxor pnot,%mm0; \
10195 + pxor %mm7,%mm6; \
10196 + pxor %mm0,%mm3; \
10197 + movq %mm1,%mm7; \
10198 + pand %mm6,%mm7; \
10199 + pxor %mm2,%mm5; \
10200 + pxor %mm4,%mm2; \
10201 + pand %mm5,%mm0; \
10202 + pxor %mm7,%mm4; \
10203 + pand %mm1,%mm5; \
10205 + pxor %mm6,%mm5; \
10206 + movq S4_a4,%mm1; \
10207 + movq %mm0,%mm6; \
10208 + pand %mm4,%mm1; \
10209 + pxor %mm2,%mm6; \
10210 + por S4_a4,%mm6; \
10211 + pxor %mm3,%mm1; \
10212 + pand S4_a2,%mm4; \
10213 + pxor %mm5,%mm6; \
10214 + movq S4_a6,%mm3; \
10215 + pxor %mm0,%mm4; \
10216 + pxor S4_a3,%mm7; \
10217 + movq %mm3,%mm0; \
10218 + pxor %mm2,%mm7; \
10219 + pand %mm6,%mm0; \
10220 + movq S4_a4,%mm2; \
10222 + pxor %mm1,%mm0; \
10223 + pand %mm2,%mm7; \
10224 + pxor pnot,%mm1; \
10225 + pxor %mm7,%mm4; \
10226 + movq %mm4,%mm5; \
10227 + pxor %mm1,%mm4; \
10228 + pxor out1,%mm1; \
10230 + pand S4_a2,%mm4; \
10231 + pxor %mm6,%mm1; \
10232 + pxor %mm0,%mm4; \
10233 + pxor out3,%mm6; \
10234 + pxor %mm4,%mm2; \
10235 + pxor out2,%mm0; \
10236 + pand %mm2,%mm3; \
10237 + pxor %mm2,%mm6; \
10238 + pxor %mm3,%mm5; \
10239 + movq %mm1,out1; \
10240 + pxor %mm5,%mm6; \
10241 + movq %mm0,out2; \
10242 + pxor out4,%mm5; \
10243 + movq %mm6,out3; \
10246 +#define S5_out1 %mm5
10247 +#define S5_out2 %mm7
10248 +#define S5_out3 %mm6
10249 +#define S5_out4 %mm4
10251 +#define S5_a1 tmp_at(1)
10252 +#define S5_a2 tmp_at(2)
10253 +#define S5_a6 tmp_at(3)
10254 +#define S5_x2 tmp_at(4)
10255 +#define S5_x4 tmp_at(5)
10256 +#define S5_x5 tmp_at(6)
10257 +#define S5_x6 tmp_at(7)
10258 +#define S5_x7 tmp_at(8)
10259 +#define S5_x8 tmp_at(9)
10260 +#define S5_x9 tmp_at(10)
10261 +#define S5_x13 tmp_at(11)
10262 +#define S5_x16 tmp_at(12)
10263 +#define S5_x17 S5_a6
10264 +#define S5_x21 S5_x7
10265 +#define S5_x24 S5_x8
10266 +#define S5_x28 S5_x17
10267 +#define S5_x38 S5_x9
10269 +#define S5(out1, out2, out3, out4, extra) \
10270 + movq %mm1,S5_a2; \
10271 + movq %mm3,%mm6; \
10272 + movq %mm2,%mm7; \
10273 + pandn %mm2,%mm6; \
10274 + pandn %mm0,%mm7; \
10275 + movq %mm6,%mm1; \
10276 + movq %mm0,S5_a1; \
10277 + pxor %mm0,%mm1; \
10279 + pxor %mm3,%mm0; \
10280 + movq %mm1,S5_x2; \
10281 + movq %mm5,S5_a6; \
10284 + movq %mm6,S5_x7; \
10285 + pxor %mm5,%mm1; \
10286 + movq %mm5,S5_x4; \
10287 + pand %mm2,%mm6; \
10288 + movq S5_a6,%mm5; \
10289 + pxor %mm3,%mm6; \
10290 + pandn S5_x7,%mm5; \
10291 + movq %mm0,S5_x6; \
10292 + movq %mm7,%mm0; \
10293 + movq %mm5,S5_x8; \
10294 + pxor %mm2,%mm5; \
10295 + movq %mm1,S5_x5; \
10296 + pxor %mm3,%mm0; \
10297 + movq %mm5,S5_x9; \
10298 + pandn %mm6,%mm7; \
10299 + por S5_a6,%mm0; \
10301 + movq %mm6,S5_x13; \
10302 + pxor %mm1,%mm5; \
10303 + movq %mm0,S5_x16; \
10304 + pxor %mm0,%mm7; \
10305 + movq S5_a2,%mm0; \
10306 + movq %mm4,%mm1; \
10307 + movq %mm7,S5_x17; \
10309 + pand S5_x5,%mm7; \
10310 + pxor %mm6,%mm1; \
10311 + pandn %mm1,%mm0; \
10312 + movq %mm7,%mm6; \
10313 + pandn S5_x7,%mm6; \
10314 + pxor %mm0,%mm5; \
10315 + pxor S5_x9,%mm7; \
10316 + movq %mm3,%mm0; \
10317 + movq %mm5,S5_x21; \
10318 + movq %mm6,%mm5; \
10319 + pandn S5_x8,%mm0; \
10320 + pandn %mm1,%mm5; \
10321 + pxor out3,%mm6; \
10322 + pxor %mm2,%mm0; \
10323 + movq S5_a1,%mm2; \
10324 + movq %mm0,%mm1; \
10325 + pxor S5_x9,%mm2; \
10326 + pand %mm4,%mm1; \
10327 + movq %mm7,S5_x38; \
10328 + pxor %mm1,%mm6; \
10329 + movq S5_x4,%mm1; \
10330 + movq %mm2,%mm7; \
10331 + pand S5_x2,%mm7; \
10332 + pand %mm3,%mm1; \
10333 + pxor S5_x17,%mm1; \
10334 + pandn %mm4,%mm7; \
10335 + movq %mm2,S5_x24; \
10336 + pxor %mm7,%mm1; \
10337 + movq out2,%mm7; \
10339 + movq S5_a2,%mm2; \
10340 + pxor %mm1,%mm7; \
10341 + movq %mm3,S5_x28; \
10342 + pandn %mm3,%mm2; \
10343 + movq S5_x38,%mm3; \
10344 + pxor %mm2,%mm7; \
10345 + movq S5_x16,%mm2; \
10347 + por S5_x13,%mm2; \
10349 + pxor out1,%mm5; \
10350 + pxor %mm3,%mm2; \
10351 + por S5_a2,%mm2; \
10352 + movq %mm7,out2; \
10353 + pxor S5_x6,%mm1; \
10354 + pxor %mm2,%mm6; \
10355 + pandn %mm4,%mm1; \
10356 + movq S5_x38,%mm2; \
10357 + pxor S5_x24,%mm1; \
10358 + movq %mm2,%mm3; \
10359 + pxor S5_x21,%mm2; \
10360 + pxor %mm1,%mm5; \
10361 + pand S5_x6,%mm3; \
10362 + pandn %mm4,%mm2; \
10363 + pand S5_x28,%mm2; \
10364 + pxor %mm0,%mm3; \
10365 + pxor pnot,%mm6; \
10366 + pxor %mm2,%mm3; \
10367 + movq S5_x21,%mm4; \
10368 + por S5_a2,%mm3; \
10369 + movq %mm6,out3; \
10370 + pxor out4,%mm4; \
10371 + pxor %mm3,%mm5; \
10372 + movq %mm4,out4; \
10375 +#define S6_out1 %mm0
10377 +#define S6_out3 %mm2
10378 +#define S6_out4 %mm4
10380 +#define S6_a1 tmp_at(1)
10381 +#define S6_a2 tmp_at(2)
10382 +#define S6_a3 tmp_at(3)
10383 +#define S6_a4 tmp_at(4)
10384 +#define S6_x1 tmp_at(5)
10385 +#define S6_x2 tmp_at(6)
10386 +#define S6_x5 tmp_at(7)
10387 +#define S6_x6 tmp_at(8)
10388 +#define S6_x8 tmp_at(9)
10389 +#define S6_x15 tmp_at(10)
10390 +#define S6_x16 tmp_at(11)
10392 +#define S6(out1, out2, out3, out4, extra) \
10393 + movq %mm2,S6_a3; \
10395 + movq %mm4,%mm6; \
10396 + pxor pnot,%mm6; \
10397 + movq %mm5,%mm7; \
10398 + movq %mm1,S6_a2; \
10399 + movq %mm4,%mm2; \
10400 + movq %mm3,S6_a4; \
10401 + pxor %mm1,%mm7; \
10402 + pxor pnot,%mm1; \
10403 + pxor %mm6,%mm7; \
10404 + movq %mm6,S6_x2; \
10405 + pxor %mm0,%mm7; \
10406 + pand %mm5,%mm2; \
10407 + movq %mm4,%mm6; \
10408 + movq %mm1,S6_x1; \
10409 + movq %mm5,%mm3; \
10410 + pand S6_a2,%mm3; \
10411 + pand %mm7,%mm6; \
10412 + movq %mm0,S6_a1; \
10414 + movq %mm2,S6_x6; \
10415 + pand %mm6,%mm0; \
10416 + movq %mm3,S6_x15; \
10417 + pxor %mm0,%mm1; \
10418 + movq S6_a4,%mm0; \
10419 + movq %mm4,%mm2; \
10420 + movq %mm6,S6_x8; \
10421 + pand %mm1,%mm0; \
10422 + movq %mm7,S6_x5; \
10423 + pxor %mm3,%mm2; \
10424 + movq S6_x2,%mm6; \
10425 + pxor %mm7,%mm0; \
10426 + movq S6_a1,%mm7; \
10427 + pxor %mm5,%mm1; \
10428 + movq %mm2,S6_x16; \
10429 + pand %mm7,%mm2; \
10430 + movq S6_a4,%mm3; \
10431 + pxor %mm2,%mm6; \
10432 + pxor S6_a2,%mm2; \
10433 + pand %mm7,%mm1; \
10435 + pxor %mm5,%mm6; \
10436 + pxor %mm3,%mm1; \
10437 + pand %mm6,%mm7; \
10438 + pand S6_a3,%mm1; \
10439 + pand %mm4,%mm6; \
10440 + movq S6_x6,%mm3; \
10441 + pxor %mm1,%mm0; \
10442 + pxor out2,%mm0; \
10444 + pand S6_a4,%mm3; \
10445 + pxor %mm7,%mm4; \
10446 + movq S6_x5,%mm1; \
10447 + pxor %mm3,%mm4; \
10448 + pxor pnot,%mm2; \
10450 + movq %mm0,out2; \
10451 + movq %mm5,%mm3; \
10452 + pandn S6_a4,%mm3; \
10453 + pxor %mm6,%mm1; \
10454 + movq S6_x6,%mm0; \
10455 + pxor %mm2,%mm3; \
10456 + por S6_a4,%mm1; \
10457 + pxor %mm3,%mm0; \
10458 + pand S6_a3,%mm3; \
10459 + pxor %mm1,%mm0; \
10460 + por S6_x5,%mm6; \
10461 + movq %mm7,%mm1; \
10462 + pxor S6_x15,%mm7; \
10463 + pxor %mm3,%mm4; \
10464 + movq S6_a4,%mm3; \
10465 + pxor %mm5,%mm7; \
10466 + pand S6_x8,%mm5; \
10468 + pxor S6_x6,%mm6; \
10470 + por S6_x16,%mm1; \
10471 + pxor %mm6,%mm5; \
10472 + pxor S6_x1,%mm1; \
10473 + movq S6_a3,%mm3; \
10474 + pxor %mm1,%mm7; \
10475 + pxor out4,%mm4; \
10477 + pand %mm1,%mm2; \
10478 + pxor out1,%mm0; \
10480 + pxor %mm7,%mm0; \
10481 + pxor %mm5,%mm2; \
10482 + movq %mm4,out4; \
10483 + pxor out3,%mm2; \
10484 + movq %mm0,out1; \
10487 +#define S7_out1 %mm7
10488 +#define S7_out2 %mm1
10489 +#define S7_out3 %mm3
10490 +#define S7_out4 %mm0
10492 +#define S7_a1 tmp_at(1)
10493 +#define S7_a2 tmp_at(2)
10494 +#define S7_a4 tmp_at(3)
10495 +#define S7_a6 tmp_at(4)
10496 +#define S7_x6 tmp_at(5)
10497 +#define S7_x7 tmp_at(6)
10498 +#define S7_x8 tmp_at(7)
10499 +#define S7_x11 tmp_at(8)
10500 +#define S7_x13 tmp_at(9)
10501 +#define S7_x15 tmp_at(10)
10502 +#define S7_x25 tmp_at(11)
10503 +#define S7_x26 tmp_at(12)
10505 +#define S7(out1, out2, out3, out4, extra) \
10506 + movq %mm0,S7_a1; \
10507 + movq %mm1,%mm6; \
10509 + movq %mm1,S7_a2; \
10510 + movq %mm3,%mm7; \
10511 + movq %mm5,S7_a6; \
10512 + pand %mm3,%mm6; \
10513 + movq %mm3,S7_a4; \
10514 + pxor %mm4,%mm6; \
10515 + pxor pnot,%mm4; \
10516 + pand %mm6,%mm7; \
10517 + pand %mm4,%mm3; \
10518 + movq %mm1,%mm5; \
10519 + pxor %mm2,%mm6; \
10520 + pxor %mm7,%mm5; \
10521 + movq %mm7,S7_x6; \
10524 + pxor %mm6,%mm7; \
10525 + movq %mm5,S7_x7; \
10526 + pand %mm2,%mm4; \
10527 + pand %mm2,%mm5; \
10529 + movq %mm1,S7_x13; \
10530 + pxor %mm5,%mm0; \
10531 + por S7_a6,%mm0; \
10532 + pxor %mm4,%mm1; \
10533 + movq %mm4,S7_x15; \
10534 + pxor %mm6,%mm0; \
10535 + movq %mm5,S7_x8; \
10536 + movq %mm3,%mm4; \
10537 + movq S7_a6,%mm6; \
10538 + movq %mm0,%mm5; \
10539 + pxor S7_x6,%mm5; \
10541 + movq %mm7,S7_x25; \
10543 + movq S7_a1,%mm7; \
10544 + pxor %mm1,%mm5; \
10545 + movq %mm3,S7_x26; \
10546 + pand %mm5,%mm7; \
10547 + movq %mm0,S7_x11; \
10548 + pxor %mm0,%mm7; \
10549 + movq S7_a4,%mm3; \
10550 + movq %mm7,%mm0; \
10551 + por S7_a2,%mm0; \
10552 + pand %mm3,%mm1; \
10553 + pand S7_x13,%mm3; \
10554 + por S7_x7,%mm2; \
10555 + pxor S7_x6,%mm0; \
10556 + pxor %mm3,%mm2; \
10557 + movq S7_a2,%mm3; \
10558 + movq %mm0,%mm6; \
10559 + pxor pnot,%mm3; \
10560 + pxor S7_x15,%mm6; \
10562 + pand S7_x26,%mm0; \
10563 + pxor %mm6,%mm4; \
10564 + pand S7_a6,%mm0; \
10566 + por S7_a6,%mm6; \
10567 + pand %mm5,%mm3; \
10568 + pand S7_a6,%mm1; \
10569 + pxor %mm3,%mm0; \
10570 + por S7_a1,%mm0; \
10571 + pxor %mm6,%mm2; \
10572 + pxor S7_x11,%mm1; \
10573 + pxor %mm4,%mm0; \
10574 + movq S7_a1,%mm4; \
10575 + pxor %mm2,%mm5; \
10576 + movq S7_a4,%mm6; \
10578 + pxor S7_x25,%mm6; \
10579 + pxor %mm4,%mm1; \
10580 + movq S7_a6,%mm4; \
10581 + pand %mm1,%mm6; \
10582 + movq S7_x6,%mm3; \
10583 + pand %mm4,%mm6; \
10584 + pxor S7_x15,%mm3; \
10585 + pxor %mm5,%mm6; \
10586 + pxor S7_x8,%mm2; \
10588 + por S7_a1,%mm6; \
10589 + pxor %mm2,%mm3; \
10590 + pxor out1,%mm7; \
10591 + pxor %mm6,%mm3; \
10592 + pxor out2,%mm1; \
10593 + movq %mm7,out1; \
10594 + pxor out3,%mm3; \
10595 + movq %mm1,out2; \
10596 + pxor out4,%mm0; \
10597 + movq %mm3,out3; \
10600 +#define S8_out1 %mm6
10601 +#define S8_out2 %mm2
10602 +#define S8_out3 %mm5
10603 +#define S8_out4 %mm1
10605 +#define S8_a1 tmp_at(1)
10606 +#define S8_a2 tmp_at(2)
10607 +#define S8_a4 tmp_at(3)
10608 +#define S8_a5 tmp_at(4)
10609 +#define S8_a6 tmp_at(5)
10610 +#define S8_x14 tmp_at(6)
10611 +#define S8_x22 tmp_at(7)
10612 +#define S8_x33 tmp_at(8)
10614 +#define S8(out1, out2, out3, out4, extra) \
10615 + movq %mm0,S8_a1; \
10617 + movq %mm2,%mm6; \
10618 + pxor pnot,%mm0; \
10619 + movq %mm2,%mm7; \
10620 + movq %mm3,S8_a4; \
10622 + pxor pnot,%mm3; \
10623 + pxor %mm0,%mm6; \
10624 + movq %mm5,S8_a6; \
10625 + movq %mm4,%mm5; \
10626 + movq %mm1,S8_a2; \
10627 + movq %mm7,%mm1; \
10628 + movq %mm4,S8_a5; \
10629 + pxor %mm3,%mm7; \
10632 + pand %mm4,%mm1; \
10633 + pandn %mm0,%mm2; \
10635 + pxor %mm1,%mm2; \
10636 + movq %mm5,S8_x22; \
10637 + pand %mm3,%mm5; \
10638 + por S8_a2,%mm2; \
10639 + pxor %mm4,%mm7; \
10640 + pxor %mm0,%mm3; \
10641 + movq %mm4,%mm1; \
10642 + pxor S8_x22,%mm7; \
10643 + pxor %mm3,%mm1; \
10644 + pxor %mm6,%mm4; \
10645 + pxor %mm5,%mm2; \
10646 + pxor S8_a1,%mm5; \
10647 + pand %mm3,%mm6; \
10648 + movq %mm1,S8_x14; \
10649 + pand %mm4,%mm5; \
10650 + movq %mm7,S8_x33; \
10651 + movq %mm0,%mm1; \
10652 + pand S8_a5,%mm3; \
10653 + movq %mm0,%mm7; \
10654 + pand S8_a5,%mm1; \
10655 + pxor %mm3,%mm7; \
10656 + pand S8_a2,%mm7; \
10657 + pxor %mm1,%mm6; \
10658 + movq S8_a6,%mm1; \
10659 + pxor %mm4,%mm7; \
10660 + por S8_a2,%mm6; \
10661 + pandn %mm0,%mm4; \
10662 + pxor S8_x14,%mm6; \
10663 + pand %mm2,%mm1; \
10664 + pxor S8_a1,%mm3; \
10665 + pxor %mm6,%mm2; \
10666 + por S8_a6,%mm6; \
10667 + pxor %mm7,%mm1; \
10668 + pxor S8_x22,%mm3; \
10669 + pxor %mm7,%mm6; \
10670 + por S8_a2,%mm4; \
10671 + pand S8_a2,%mm5; \
10672 + pxor %mm4,%mm3; \
10673 + movq S8_a1,%mm4; \
10674 + pand S8_x33,%mm4; \
10675 + por S8_a4,%mm7; \
10676 + pxor %mm4,%mm0; \
10677 + pand S8_a2,%mm7; \
10678 + pxor %mm0,%mm5; \
10679 + movq S8_a6,%mm4; \
10681 + pxor S8_x33,%mm7; \
10683 + pxor out1,%mm6; \
10684 + pand %mm4,%mm2; \
10685 + pxor out4,%mm1; \
10686 + pxor %mm7,%mm5; \
10687 + pxor %mm3,%mm2; \
10688 + pxor out3,%mm5; \
10689 + movq %mm6,out1; \
10690 + pxor out2,%mm2; \
10691 + movq %mm1,out4; \
10692 + movq %mm5,out3; \
10697 +#define DES_bs_clear_block_8(i) \
10698 + movq zero,B(i); \
10699 + movq zero,B(i + 1); \
10700 + movq zero,B(i + 2); \
10701 + movq zero,B(i + 3); \
10702 + movq zero,B(i + 4); \
10703 + movq zero,B(i + 5); \
10704 + movq zero,B(i + 6); \
10705 + movq zero,B(i + 7)
10707 +#define DES_bs_clear_block \
10708 + DES_bs_clear_block_8(0); \
10709 + DES_bs_clear_block_8(8); \
10710 + DES_bs_clear_block_8(16); \
10711 + DES_bs_clear_block_8(24); \
10712 + DES_bs_clear_block_8(32); \
10713 + DES_bs_clear_block_8(40); \
10714 + DES_bs_clear_block_8(48); \
10715 + DES_bs_clear_block_8(56)
10717 +#define k_ptr %edx
10718 +#define K(i) (i)*8(k_ptr)
10719 +#define k(i) (i)*4(k_ptr)
10721 +#define a6_xor_ptr %esi
10722 +#define a6_p pxor (a6_xor_ptr),a6
10723 +#define a6_v(i) pxor K(i),a6
10726 +#define tmp2 a6_xor_ptr
10728 +#define xor_E(i) \
10729 + movl E(i),tmp1; \
10731 + movl E(i + 1),tmp2; \
10732 + movq K(i + 1),a2; \
10733 + pxor (tmp1),a1; \
10734 + pxor (tmp2),a2; \
10735 + movl E(i + 2),tmp1; \
10736 + movq K(i + 2),a3; \
10737 + movl E(i + 3),tmp2; \
10738 + movq K(i + 3),a4; \
10739 + pxor (tmp1),a3; \
10740 + pxor (tmp2),a4; \
10741 + movl E(i + 4),tmp1; \
10742 + movq K(i + 4),a5; \
10743 + movl E(i + 5),a6_xor_ptr; \
10744 + movq K(i + 5),a6; \
10747 +#define xor_B(b1, k1, b2, k2, b3, k3, b4, k4, b5, k5, b6) \
10760 +#define xor_B_KS_p(b1, k1, b2, k2, b3, k3, b4, k4, b5, k5, b6, k6) \
10761 + movl k(k1),tmp1; \
10762 + movl k(k2),tmp2; \
10765 + pxor (tmp1),a1; \
10766 + movl k(k3),tmp1; \
10767 + pxor (tmp2),a2; \
10768 + movl k(k4),tmp2; \
10771 + pxor (tmp1),a3; \
10772 + movl k(k5),tmp1; \
10773 + pxor (tmp2),a4; \
10775 + movl k(k6),a6_xor_ptr; \
10788 +.globl DES_bs_init_asm
10790 + movq mm_ones,%mm0
10794 +#define rounds_and_swapped %ebp
10795 +#define iterations %eax
10798 +.globl DES_bs_crypt
10800 + movl 4(%esp),iterations
10804 + movl $DES_bs_all_KS_v,k_ptr
10805 + DES_bs_clear_block
10806 + movl $8,rounds_and_swapped
10807 +DES_bs_crypt_start:
10809 + S1(B(40), B(48), B(54), B(62), a6_p)
10811 + S2(B(44), B(59), B(33), B(49), a6_p)
10813 + S3(B(55), B(47), B(61), B(37), a6_p)
10815 + S4(B(57), B(51), B(41), B(32), a6_p)
10817 + S5(B(39), B(45), B(56), B(34), a6_p)
10819 + S6(B(35), B(60), B(42), B(50), a6_p)
10821 + S7(B(63), B(43), B(53), B(38), a6_p)
10823 + S8(B(36), B(58), B(46), B(52), a6_p)
10824 + cmpl $0x100,rounds_and_swapped
10825 + je DES_bs_crypt_next
10826 +DES_bs_crypt_swap:
10828 + S1(B(8), B(16), B(22), B(30), a6_p)
10830 + S2(B(12), B(27), B(1), B(17), a6_p)
10832 + S3(B(23), B(15), B(29), B(5), a6_p)
10834 + S4(B(25), B(19), B(9), B(0), a6_p)
10836 + S5(B(7), B(13), B(24), B(2), a6_p)
10838 + S6(B(3), B(28), B(10), B(18), a6_p)
10840 + S7(B(31), B(11), B(21), B(6), a6_p)
10843 + S8(B(4), B(26), B(14), B(20), a6_p)
10844 + decl rounds_and_swapped
10845 + jnz DES_bs_crypt_start
10846 + subl $0x300*8+48*8,k_ptr
10847 + movl $0x108,rounds_and_swapped
10849 + jnz DES_bs_crypt_swap
10856 +DES_bs_crypt_next:
10857 + subl $0x300*8-48*8,k_ptr
10858 + movl $8,rounds_and_swapped
10860 + jnz DES_bs_crypt_start
10869 +.globl DES_bs_crypt_25
10874 + movl $DES_bs_all_KS_v,k_ptr
10875 + DES_bs_clear_block
10876 + movl $8,rounds_and_swapped
10877 + movl $25,iterations
10878 +DES_bs_crypt_25_start:
10880 + S1(B(40), B(48), B(54), B(62), a6_p)
10882 + S2(B(44), B(59), B(33), B(49), a6_p)
10883 + xor_B(7, 12, 8, 13, 9, 14, 10, 15, 11, 16, 12)
10884 + S3(B(55), B(47), B(61), B(37), a6_v(17))
10885 + xor_B(11, 18, 12, 19, 13, 20, 14, 21, 15, 22, 16)
10886 + S4(B(57), B(51), B(41), B(32), a6_v(23))
10888 + S5(B(39), B(45), B(56), B(34), a6_p)
10890 + S6(B(35), B(60), B(42), B(50), a6_p)
10891 + xor_B(23, 36, 24, 37, 25, 38, 26, 39, 27, 40, 28)
10892 + S7(B(63), B(43), B(53), B(38), a6_v(41))
10893 + xor_B(27, 42, 28, 43, 29, 44, 30, 45, 31, 46, 0)
10894 + S8(B(36), B(58), B(46), B(52), a6_v(47))
10895 + cmpl $0x100,rounds_and_swapped
10896 + je DES_bs_crypt_25_next
10897 +DES_bs_crypt_25_swap:
10899 + S1(B(8), B(16), B(22), B(30), a6_p)
10901 + S2(B(12), B(27), B(1), B(17), a6_p)
10902 + xor_B(39, 60, 40, 61, 41, 62, 42, 63, 43, 64, 44)
10903 + S3(B(23), B(15), B(29), B(5), a6_v(65))
10904 + xor_B(43, 66, 44, 67, 45, 68, 46, 69, 47, 70, 48)
10905 + S4(B(25), B(19), B(9), B(0), a6_v(71))
10907 + S5(B(7), B(13), B(24), B(2), a6_p)
10909 + S6(B(3), B(28), B(10), B(18), a6_p)
10910 + xor_B(55, 84, 56, 85, 57, 86, 58, 87, 59, 88, 60)
10911 + S7(B(31), B(11), B(21), B(6), a6_v(89))
10912 + xor_B(59, 90, 60, 91, 61, 92, 62, 93, 63, 94, 32)
10913 + S8(B(4), B(26), B(14), B(20), a6_v(95))
10915 + decl rounds_and_swapped
10916 + jnz DES_bs_crypt_25_start
10917 + subl $0x300*8+48*8,k_ptr
10918 + movl $0x108,rounds_and_swapped
10920 + jnz DES_bs_crypt_25_swap
10927 +DES_bs_crypt_25_next:
10928 + subl $0x300*8-48*8,k_ptr
10929 + movl $8,rounds_and_swapped
10931 + jmp DES_bs_crypt_25_start
10935 +#define rounds %eax
10938 +.globl DES_bs_crypt_LM
10943 + movl $DES_bs_all_KS_p,k_ptr
11009 +DES_bs_crypt_LM_loop:
11010 + xor_B_KS_p(31, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5)
11011 + S1(B(40), B(48), B(54), B(62), a6_p)
11012 + xor_B_KS_p(3, 6, 4, 7, 5, 8, 6, 9, 7, 10, 8, 11)
11013 + S2(B(44), B(59), B(33), B(49), a6_p)
11014 + xor_B_KS_p(7, 12, 8, 13, 9, 14, 10, 15, 11, 16, 12, 17)
11015 + S3(B(55), B(47), B(61), B(37), a6_p)
11016 + xor_B_KS_p(11, 18, 12, 19, 13, 20, 14, 21, 15, 22, 16, 23)
11017 + S4(B(57), B(51), B(41), B(32), a6_p)
11018 + xor_B_KS_p(15, 24, 16, 25, 17, 26, 18, 27, 19, 28, 20, 29)
11019 + S5(B(39), B(45), B(56), B(34), a6_p)
11020 + xor_B_KS_p(19, 30, 20, 31, 21, 32, 22, 33, 23, 34, 24, 35)
11021 + S6(B(35), B(60), B(42), B(50), a6_p)
11022 + xor_B_KS_p(23, 36, 24, 37, 25, 38, 26, 39, 27, 40, 28, 41)
11023 + S7(B(63), B(43), B(53), B(38), a6_p)
11024 + xor_B_KS_p(27, 42, 28, 43, 29, 44, 30, 45, 31, 46, 0, 47)
11025 + S8(B(36), B(58), B(46), B(52), a6_p)
11026 + xor_B_KS_p(63, 48, 32, 49, 33, 50, 34, 51, 35, 52, 36, 53)
11027 + S1(B(8), B(16), B(22), B(30), a6_p)
11028 + xor_B_KS_p(35, 54, 36, 55, 37, 56, 38, 57, 39, 58, 40, 59)
11029 + S2(B(12), B(27), B(1), B(17), a6_p)
11030 + xor_B_KS_p(39, 60, 40, 61, 41, 62, 42, 63, 43, 64, 44, 65)
11031 + S3(B(23), B(15), B(29), B(5), a6_p)
11032 + xor_B_KS_p(43, 66, 44, 67, 45, 68, 46, 69, 47, 70, 48, 71)
11033 + S4(B(25), B(19), B(9), B(0), a6_p)
11034 + xor_B_KS_p(47, 72, 48, 73, 49, 74, 50, 75, 51, 76, 52, 77)
11035 + S5(B(7), B(13), B(24), B(2), a6_p)
11036 + xor_B_KS_p(51, 78, 52, 79, 53, 80, 54, 81, 55, 82, 56, 83)
11037 + S6(B(3), B(28), B(10), B(18), a6_p)
11038 + xor_B_KS_p(55, 84, 56, 85, 57, 86, 58, 87, 59, 88, 60, 89)
11039 + S7(B(31), B(11), B(21), B(6), a6_p)
11040 + xor_B_KS_p(59, 90, 60, 91, 61, 92, 62, 93, 63, 94, 32, 95)
11042 + S8(B(4), B(26), B(14), B(20), a6_p)
11044 + jnz DES_bs_crypt_LM_loop
11050 diff -ruN john-1.6/src/x86.S john-1.6.34/src/x86.S
11051 --- john-1.6/src/x86.S 1998-12-03 01:29:50.000000000 +0100
11052 +++ john-1.6.34/src/x86.S 2002-06-22 10:51:30.000000000 +0200
11055 * This file is part of John the Ripper password cracker,
11056 - * Copyright (c) 1996-98 by Solar Designer
11057 + * Copyright (c) 1996-2001 by Solar Designer
11064 #define DO_ALIGN(log) .align (log)
11065 -#elif defined(SOLARIS)
11066 +#elif defined(DUMBAS)
11067 #define DO_ALIGN(log) .align 1 << log
11069 #define DO_ALIGN(log) .align (1 << (log))
11070 @@ -52,12 +52,15 @@
11073 * Included are versions for:
11074 - * 1. MMX (Pentium MMX, Pentium II, some clones);
11075 + * 1. MMX (Pentium MMX and newer Intel x86 CPUs, some clones);
11076 * 2. Intel Pentium without MMX;
11077 * 3. The rest (good for Pentium Pro, 486, clones).
11079 * MMX has to be enabled at compile time (via DES_X2 in arch.h), while #2
11080 * or #3 is chosen based on CPUID info at runtime.
11082 + * Note: MMX code for the bitslice DES implementation is in x86-mmx.S, so
11083 + * you probably want to look in there instead.
11087 @@ -498,9 +501,9 @@
11088 xorl DES_SPE_H+0x700(%edx),Rh
11091 -DES_std_crypt_any:
11092 +DES_std_crypt_generic:
11096 DES_2_ROUNDS_ANY(DES_KS_copy)
11097 DES_2_ROUNDS_ANY(DES_KS_copy+16)
11098 DES_2_ROUNDS_ANY(DES_KS_copy+32)
11099 @@ -521,7 +524,7 @@
11102 movl DES_KS_copy,%eax
11104 + jnz DES_loop_generic
11107 #define DES_xor1(ofs) \
11108 @@ -611,7 +614,7 @@
11109 * Weird alignments to make sure KS address's bits 5-11 never match current
11110 * instruction pointer's bits 5-11.
11115 .zero 0x1000 - 32 - 128
11116 #elif defined(__DJGPP__)
11117 @@ -629,7 +632,7 @@
11119 .globl DES_std_crypt
11121 -.long DES_std_crypt_any
11122 +.long DES_std_crypt_generic
11126 @@ -641,7 +644,7 @@
11135 @@ -657,7 +660,7 @@
11144 @@ -681,7 +684,7 @@
11153 @@ -696,7 +699,7 @@
11162 @@ -708,7 +711,7 @@
11164 .globl DES_KS_current
11171 @@ -716,7 +719,7 @@
11173 .globl DES_KS_table
11179 .space (8 * 128 * 16 * 8)
11180 @@ -756,7 +759,7 @@
11186 #define x(i) i+i+i+i(%ebp)
11188 #define x(i) 4*i(%ebp)
11189 @@ -813,22 +816,43 @@
11193 + movl 8(%esp),%ebp
11197 - movl 20(%esp),%ebp
11199 - movl $0xd76aa477,a
11205 + addl $0xd76aa477,a
11209 - movl $0x77777777,tmp1
11210 - FF (d, a, b, c, x( 1), S12, 0xe8c7b756) /* 2 */
11211 - FF (c, d, a, b, x( 2), S13, 0x242070db) /* 3 */
11212 - FF (b, c, d, a, x( 3), S14, 0xc1bdceee) /* 4 */
11213 + addl $0xf8fa0bcc,d
11218 + andl $0x77777777,tmp1
11221 + addl $0xbcdb4dd9,c
11235 + addl $0xb18b7a77,b
11241 FF (a, b, c, d, x( 4), S11, 0xf57c0faf) /* 5 */
11242 FF (d, a, b, c, x( 5), S12, 0x4787c62a) /* 6 */
11243 FF (c, d, a, b, x( 6), S13, 0xa8304613) /* 7 */
11244 @@ -953,118 +977,252 @@
11249 +#define P(N) BF_current+0x1000+N+N+N+N
11251 +#define P(N) BF_current+0x1000+4*N
11255 + * Intel Pentium optimized version, extra operations are used to avoid
11256 + * imperfect pairing. Also used on the Pentium 4.
11266 -#define tmp1_lo %cl
11270 -#define P(N) BF_current+0x1000+N+N+N+N
11272 -#define P(N) BF_current+0x1000+4*N
11275 +#define tmp1_lo %al
11277 +#define tmp2_hi %ch
11279 +#define tmp3_lo %dl
11281 +#define tmp4_hi %bh
11286 -#define BF_ROUND(L, R, N) \
11288 +#define BF_ROUND_P5(L, R, N) \
11294 - movb %ah,tmp1_lo; \
11295 - andl $0xFF,%eax; \
11297 - andl $0xFF,%edx; \
11301 + movb tmp2_hi,tmp1_lo; \
11302 + andl $0xFF,tmp2; \
11303 + movb tmp4_hi,tmp3_lo; \
11304 + andl $0xFF,tmp4; \
11305 movl BF_current(,tmp1,4),tmp1; \
11306 - movl BF_current+0x400(,%eax,4),tmp2; \
11307 - addl tmp2,tmp1; \
11308 - movl BF_current+0x800(,%ebx,4),tmp2; \
11309 - xorl tmp2,tmp1; \
11310 - movl BF_current+0xC00(,%edx,4),tmp2; \
11311 - addl tmp1,tmp2; \
11312 - movl P(N)+4,%eax; \
11315 -#define BF_ENCRYPT_START \
11316 - BF_ROUND(L, R, 0); \
11317 - BF_ROUND(R, L, 1); \
11318 - BF_ROUND(L, R, 2); \
11319 - BF_ROUND(R, L, 3); \
11320 - BF_ROUND(L, R, 4); \
11321 - BF_ROUND(R, L, 5); \
11322 - BF_ROUND(L, R, 6); \
11323 - BF_ROUND(R, L, 7); \
11324 - BF_ROUND(L, R, 8); \
11325 - BF_ROUND(R, L, 9); \
11326 - BF_ROUND(L, R, 10); \
11327 - BF_ROUND(R, L, 11); \
11328 - BF_ROUND(L, R, 12); \
11329 - BF_ROUND(R, L, 13); \
11330 - BF_ROUND(L, R, 14); \
11331 - BF_ROUND(R, L, 15); \
11332 - movl BF_ptr,tmp2; \
11334 + movl BF_current+0x400(,tmp2,4),tmp5; \
11335 + addl tmp5,tmp1; \
11336 + movl BF_current+0x800(,tmp3,4),tmp5; \
11337 + xorl tmp5,tmp1; \
11338 + movl BF_current+0xC00(,tmp4,4),tmp5; \
11339 + addl tmp1,tmp5; \
11340 + movl P(N)+4,tmp2; \
11343 +#define BF_ENCRYPT_START_P5 \
11344 + BF_ROUND_P5(L, R, 0); \
11345 + BF_ROUND_P5(R, L, 1); \
11346 + BF_ROUND_P5(L, R, 2); \
11347 + BF_ROUND_P5(R, L, 3); \
11348 + BF_ROUND_P5(L, R, 4); \
11349 + BF_ROUND_P5(R, L, 5); \
11350 + BF_ROUND_P5(L, R, 6); \
11351 + BF_ROUND_P5(R, L, 7); \
11352 + BF_ROUND_P5(L, R, 8); \
11353 + BF_ROUND_P5(R, L, 9); \
11354 + BF_ROUND_P5(L, R, 10); \
11355 + BF_ROUND_P5(R, L, 11); \
11356 + BF_ROUND_P5(L, R, 12); \
11357 + BF_ROUND_P5(R, L, 13); \
11358 + BF_ROUND_P5(L, R, 14); \
11359 + BF_ROUND_P5(R, L, 15); \
11360 + movl BF_ptr,tmp5; \
11364 -#define BF_ENCRYPT_END \
11365 +#define BF_ENCRYPT_END_P5 \
11388 + BF_ENCRYPT_START_P5
11390 + BF_ENCRYPT_END_P5
11397 +#ifndef DONT_AVOID_PENTIUMPRO_FAMILY_PARTIAL_REGISTER_STALLS
11400 + movl $BF_current,BF_ptr
11402 + BF_ENCRYPT_START_P5
11403 + BF_ENCRYPT_END_P5
11407 + BF_ENCRYPT_START_P5
11408 + BF_ENCRYPT_END_P5
11412 + BF_ENCRYPT_START_P5
11413 + BF_ENCRYPT_END_P5
11417 + BF_ENCRYPT_START_P5
11419 + BF_ENCRYPT_END_P5
11421 + cmpl $BF_current+0x1000,tmp5
11433 + * Generic x86 version.
11455 +#define tmp2_hi %ch
11460 +#define BF_ROUND_START(L, L_lo, L_hi) \
11461 + shldl $16,L,tmp2; \
11462 + movzbl L_hi,tmp3; \
11463 + movzbl tmp2_hi,tmp1; \
11464 + andl $0xFF,tmp2; \
11465 + movzbl L_lo,tmp4; \
11466 + movl BF_current(,tmp1,4),tmp1; \
11467 + addl BF_current+0x400(,tmp2,4),tmp1
11469 +#define BF_ROUND_END(R, N) \
11470 + xorl BF_current+0x800(,tmp3,4),tmp1; \
11471 + addl BF_current+0xC00(,tmp4,4),tmp1; \
11475 +#define BF_ROUND(L, L_lo, L_hi, R, N) \
11476 + BF_ROUND_START(L, L_lo, L_hi); \
11477 + BF_ROUND_END(R, N)
11479 +#define BF_ENCRYPT_START \
11481 + BF_ROUND(L, L_lo, L_hi, R, 0); \
11482 + BF_ROUND(R, R_lo, R_hi, L, 1); \
11483 + BF_ROUND(L, L_lo, L_hi, R, 2); \
11484 + BF_ROUND(R, R_lo, R_hi, L, 3); \
11485 + BF_ROUND(L, L_lo, L_hi, R, 4); \
11486 + BF_ROUND(R, R_lo, R_hi, L, 5); \
11487 + BF_ROUND(L, L_lo, L_hi, R, 6); \
11488 + BF_ROUND(R, R_lo, R_hi, L, 7); \
11489 + BF_ROUND(L, L_lo, L_hi, R, 8); \
11490 + BF_ROUND(R, R_lo, R_hi, L, 9); \
11491 + BF_ROUND(L, L_lo, L_hi, R, 10); \
11492 + BF_ROUND(R, R_lo, R_hi, L, 11); \
11493 + BF_ROUND(L, L_lo, L_hi, R, 12); \
11494 + BF_ROUND(R, R_lo, R_hi, L, 13); \
11495 + BF_ROUND(L, L_lo, L_hi, R, 14); \
11496 + BF_ROUND_START(R, R_lo, R_hi); \
11499 + xorl BF_current+0x800(,tmp3,4),tmp1; \
11501 + addl BF_current+0xC00(,tmp4,4),tmp1; \
11505 +#define BF_ENCRYPT_END \
11509 +.globl BF_body_generic
11518 +BF_loop_P_generic:
11530 - movl $BF_current,BF_ptr
11535 + jb BF_loop_P_generic
11536 + movl $BF_current,ptr
11537 +BF_loop_S_generic:
11564 - cmpl $BF_current+0x1000,tmp2
11569 + cmpl $BF_current+0x1000,ptr
11572 + jb BF_loop_S_generic
11576 @@ -1077,7 +1235,7 @@
11584 #elif defined(__DJGPP__)
11585 @@ -1091,7 +1249,7 @@
11593 .space (0x1000 + 72)
11594 @@ -1100,6 +1258,13 @@
11599 + * The function pointer, set by CPU_detect().
11608 @@ -1111,11 +1276,20 @@
11609 #define EF_ID $0x00200000
11610 #define CF_MMX $0x00800000
11611 #define CV_INTEL $0x6C65746E
11612 +#define CV_AMD $0x444D4163
11625 + movl $BF_body_generic,BF_body
11629 @@ -1125,30 +1299,51 @@
11633 - jz CPU_detect_ret
11634 + jz CPU_detect_ret /* 386/486 */
11638 + jz CPU_detect_ret /* Newer 486's */
11653 + jz CPU_detect_ret /* No MMX */
11658 - jne CPU_detect_ret
11665 + je CPU_detect_AMD /* Is an AMD processor */
11667 - jne CPU_detect_ret
11668 - movl $DES_std_crypt_P5,%eax
11669 - movl %eax,DES_std_crypt
11670 + jne CPU_detect_yes /* Not an Intel or AMD */
11672 + je CPU_detect_P5 /* Intel Pentium */
11674 + je CPU_detect_P5 /* Intel Pentium 4 */
11675 + jmp CPU_detect_yes /* Not one of the above */
11678 + jne CPU_detect_yes /* Not an AMD Athlon */
11681 + * Enable Intel Pentium optimizations when running on one of:
11684 + * Intel Pentium 4
11689 + movl $DES_std_crypt_P5,DES_std_crypt
11691 + movl $BF_body_P5,BF_body