diff -Nrup john-1.7.2-a/src/Makefile john-1.7.2-b/src/Makefile --- john-1.7.2-a/src/Makefile 2006-05-15 19:38:00.000000000 +0300 +++ john-1.7.2-b/src/Makefile 2007-10-14 14:18:27.000000000 +0300 @@ -17,7 +17,7 @@ NULL = /dev/null CPPFLAGS = -E CFLAGS = -c -Wall -O2 -fomit-frame-pointer ASFLAGS = -c -LDFLAGS = -s +LDFLAGS = -s `pkg-config --libs libssl` OPT_NORMAL = -funroll-loops OPT_INLINE = -finline-functions @@ -28,6 +28,8 @@ JOHN_OBJS_MINIMAL = \ BF_fmt.o BF_std.o \ AFS_fmt.o \ LM_fmt.o \ + SHA1SUM_fmt.o SHASUM_std.o \ + SHA224SUM_fmt.o SHA256SUM_fmt.o SHA384SUM_fmt.o SHA512SUM_fmt.o \ batch.o bench.o charset.o common.o compiler.o config.o cracker.o \ crc32.o external.o formats.o getopt.o idle.o inc.o john.o list.o \ loader.o logger.o math.o memory.o misc.o options.o params.o path.o \ @@ -58,11 +60,16 @@ BENCH_MD5_OBJS_DEPEND = \ BENCH_BF_OBJS_DEPEND = \ BF_std.o +BENCH_SHASUM_OBJS_DEPEND = \ + SHA1SUM_fmt.o SHASUM_std.o \ + SHA224SUM_fmt.o SHA256SUM_fmt.o SHA384SUM_fmt.o SHA512SUM_fmt.o + BENCH_OBJS = \ $(BENCH_DES_OBJS_DEPEND) \ DES_bs.o $(BENCH_DES_BS_OBJS_DEPEND) \ $(BENCH_MD5_OBJS_DEPEND) \ BF_fmt.o $(BENCH_BF_OBJS_DEPEND) \ + $(BENCH_SHASUM_OBJS_DEPEND) \ bench.o best.o common.o config.o formats.o math.o memory.o miscnl.o \ params.o path.o signals.o tty.o @@ -651,7 +658,8 @@ generic.h: "$(BENCH_DES_OBJS_DEPEND)" \ "$(BENCH_DES_BS_OBJS_DEPEND)" \ "$(BENCH_MD5_OBJS_DEPEND)" \ - "$(BENCH_BF_OBJS_DEPEND)" + "$(BENCH_BF_OBJS_DEPEND)" \ + "$(BENCH_SHASUM_OBJS_DEPEND)" bench: $(BENCH_OBJS) $(LD) $(LDFLAGS) $(BENCH_OBJS) -o bench diff -Nrup john-1.7.2-a/src/SHA1SUM_fmt.c john-1.7.2-b/src/SHA1SUM_fmt.c --- john-1.7.2-a/src/SHA1SUM_fmt.c 1970-01-01 02:00:00.000000000 +0200 +++ john-1.7.2-b/src/SHA1SUM_fmt.c 2007-10-14 14:17:54.000000000 +0300 @@ -0,0 +1,153 @@ +/* + * This file is part of John the Ripper password cracker, + * Copyright (c) 2007 Tommi Saviranta + */ + +#include "SHASUM_std.h" + +#include +#include + +#include "arch.h" +#include "misc.h" +#include "common.h" +#include "formats.h" + +#define FORMAT_LABEL "sha1sum" +#define FORMAT_NAME "SHA1SUM" +#define ALGORITHM_NAME "OpenSSL/SHA1" + +#define BENCHMARK_COMMENT "" +#define BENCHMARK_LENGTH -1 + +/* Assume passwords do not exceed 63 characters in length. */ +#define PLAINTEXT_LENGTH 64 +#define CIPHERTEXT_LENGTH SHA_DIGEST_LENGTH + +#define BINARY_SIZE 4 +#define SALT_SIZE 0 + +#define MIN_KEYS_PER_CRYPT 1 +#define MAX_KEYS_PER_CRYPT 1 + + +static struct fmt_tests tests[] = { + {"dde677e94792ee98d99dea11316e9dbbb7953a33", "0123456789ABCDE"}, + {"7c222fb2927d828af22f592134e8932480637c0d", "12345678"}, + {"da39a3ee5e6b4b0d3255bfef95601890afd80709", ""}, + {"7110eda4d09e062aa5e4a390b0a572ac0d2c0220", "1234"}, + {NULL} +}; + +static unsigned char saved_key[PLAINTEXT_LENGTH + 1]; +static unsigned char saved_key_len; +static unsigned char saved_hash[CIPHERTEXT_LENGTH]; + +static int valid(char *ciphertext) +{ + return shasum_valid(ciphertext, SHA_DIGEST_LENGTH * 2); /* bin to hex */ +} + +static void *binary(char *ciphertext) +{ + static char hash[CIPHERTEXT_LENGTH]; + + return shasum_binary(hash, ciphertext, SHA_DIGEST_LENGTH); +} + +static void crypt_all(int count) +{ + SHA_CTX ctx; + + SHA1_Init(&ctx); + SHA1_Update(&ctx, saved_key, saved_key_len); + SHA1_Final(saved_hash, &ctx); +} + +static int get_hash_0(int index) +{ + return ((int *) saved_hash)[0] & 0xF; +} + +static int get_hash_1(int index) +{ + return ((int *) saved_hash)[0] & 0xFF; +} + +static int get_hash_2(int index) +{ + return ((int *) saved_hash)[0] & 0xFFF; +} + +static void set_key(char *key, int index) +{ + saved_key_len = strlen(key); + strncpy((char *) saved_key, key, PLAINTEXT_LENGTH); + saved_key[PLAINTEXT_LENGTH] = '\0'; +} + +static char *get_key(int index) +{ + return (char *) saved_key; +} + +static int cmp_all(void *binary, int index) +{ + return *(int *) binary == ((int *) saved_hash)[0]; +} + +static int cmp_exact(char *source, int index) +{ + unsigned char *i, *j; + for (i = (unsigned char *) source, + j = (unsigned char *) saved_hash; + *i != '\0'; /* nothing */) { + if ((shasum_hex2dec(i[0]) << 4) + shasum_hex2dec(i[1]) != *j) + return 0; + i += 2; + j++; + } + return 1; +} + +struct fmt_main fmt_SHA1SUM = { + { + FORMAT_LABEL, + FORMAT_NAME, + ALGORITHM_NAME, + BENCHMARK_COMMENT, + BENCHMARK_LENGTH, + PLAINTEXT_LENGTH, + BINARY_SIZE, + SALT_SIZE, + MIN_KEYS_PER_CRYPT, + MAX_KEYS_PER_CRYPT, + FMT_CASE | FMT_8_BIT, + tests + }, { + fmt_default_init, + valid, + fmt_default_split, + binary, + shasum_salt, + { + shasum_binary_hash_0, + shasum_binary_hash_1, + shasum_binary_hash_2 + }, + shasum_salt_hash, + shasum_set_salt, + set_key, + get_key, + fmt_default_clear_keys, + crypt_all, + { + get_hash_0, + get_hash_1, + get_hash_2 + }, + cmp_all, + cmp_all, + cmp_exact + } +}; diff -Nrup john-1.7.2-a/src/SHA224SUM_fmt.c john-1.7.2-b/src/SHA224SUM_fmt.c --- john-1.7.2-a/src/SHA224SUM_fmt.c 1970-01-01 02:00:00.000000000 +0200 +++ john-1.7.2-b/src/SHA224SUM_fmt.c 2007-10-14 14:17:55.000000000 +0300 @@ -0,0 +1,157 @@ +/* + * This file is part of John the Ripper password cracker, + * Copyright (c) 2007 Tommi Saviranta + */ + +#include "SHASUM_std.h" + +#include +#include + +#include "arch.h" +#include "misc.h" +#include "common.h" +#include "formats.h" + +#define FORMAT_LABEL "sha224sum" +#define FORMAT_NAME "SHA224SUM" +#define ALGORITHM_NAME "OpenSSL/SHA224" + +#define BENCHMARK_COMMENT "" +#define BENCHMARK_LENGTH -1 + +/* Assume passwords do not exceed 63 characters in length. */ +#define PLAINTEXT_LENGTH 64 +#define CIPHERTEXT_LENGTH SHA224_DIGEST_LENGTH + +#define BINARY_SIZE 4 +#define SALT_SIZE 0 + +#define MIN_KEYS_PER_CRYPT 1 +#define MAX_KEYS_PER_CRYPT 1 + + +static struct fmt_tests tests[] = { + {"377189874b8fa08fe42595943de1948ccaa0631b21b8e5ea9e799cce", + "0123456789ABCDE"}, + {"7e6a4309ddf6e8866679f61ace4f621b0e3455ebac2e831a60f13cd1", + "12345678"}, + {"d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f", + ""}, + {"99fb2f48c6af4761f904fc85f95eb56190e5d40b1f44ec3a9c1fa319", + "1234"}, + {NULL} +}; + +static unsigned char saved_key[PLAINTEXT_LENGTH + 1]; +static unsigned char saved_key_len; +static unsigned char saved_hash[CIPHERTEXT_LENGTH]; + +static int valid(char *ciphertext) +{ + return shasum_valid(ciphertext, SHA224_DIGEST_LENGTH * 2); /* bin to hex */ +} + +static void *binary(char *ciphertext) +{ + static char hash[CIPHERTEXT_LENGTH]; + + return shasum_binary(hash, ciphertext, SHA_DIGEST_LENGTH); +} + +static void crypt_all(int count) +{ + SHA256_CTX ctx; + + SHA224_Init(&ctx); + SHA224_Update(&ctx, saved_key, saved_key_len); + SHA224_Final(saved_hash, &ctx); +} + +static int get_hash_0(int index) +{ + return ((int *) saved_hash)[0] & 0xF; +} + +static int get_hash_1(int index) +{ + return ((int *) saved_hash)[0] & 0xFF; +} + +static int get_hash_2(int index) +{ + return ((int *) saved_hash)[0] & 0xFFF; +} + +static void set_key(char *key, int index) +{ + saved_key_len = strlen(key); + strncpy((char *) saved_key, key, PLAINTEXT_LENGTH); + saved_key[PLAINTEXT_LENGTH] = '\0'; +} + +static char *get_key(int index) +{ + return (char *) saved_key; +} + +static int cmp_all(void *binary, int index) +{ + return *(int *) binary == ((int *) saved_hash)[0]; +} + +static int cmp_exact(char *source, int index) +{ + unsigned char *i, *j; + for (i = (unsigned char *) source, + j = (unsigned char *) saved_hash; + *i != '\0'; /* nothing */) { + if ((shasum_hex2dec(i[0]) << 4) + shasum_hex2dec(i[1]) != *j) + return 0; + i += 2; + j++; + } + return 1; +} + +struct fmt_main fmt_SHA224SUM = { + { + FORMAT_LABEL, + FORMAT_NAME, + ALGORITHM_NAME, + BENCHMARK_COMMENT, + BENCHMARK_LENGTH, + PLAINTEXT_LENGTH, + BINARY_SIZE, + SALT_SIZE, + MIN_KEYS_PER_CRYPT, + MAX_KEYS_PER_CRYPT, + FMT_CASE | FMT_8_BIT, + tests + }, { + fmt_default_init, + valid, + fmt_default_split, + binary, + shasum_salt, + { + shasum_binary_hash_0, + shasum_binary_hash_1, + shasum_binary_hash_2 + }, + shasum_salt_hash, + shasum_set_salt, + set_key, + get_key, + fmt_default_clear_keys, + crypt_all, + { + get_hash_0, + get_hash_1, + get_hash_2 + }, + cmp_all, + cmp_all, + cmp_exact + } +}; diff -Nrup john-1.7.2-a/src/SHA256SUM_fmt.c john-1.7.2-b/src/SHA256SUM_fmt.c --- john-1.7.2-a/src/SHA256SUM_fmt.c 1970-01-01 02:00:00.000000000 +0200 +++ john-1.7.2-b/src/SHA256SUM_fmt.c 2007-10-14 14:17:57.000000000 +0300 @@ -0,0 +1,157 @@ +/* + * This file is part of John the Ripper password cracker, + * Copyright (c) 2007 Tommi Saviranta + */ + +#include "SHASUM_std.h" + +#include +#include + +#include "arch.h" +#include "misc.h" +#include "common.h" +#include "formats.h" + +#define FORMAT_LABEL "sha256sum" +#define FORMAT_NAME "SHA256SUM" +#define ALGORITHM_NAME "OpenSSL/SHA256" + +#define BENCHMARK_COMMENT "" +#define BENCHMARK_LENGTH -1 + +/* Assume passwords do not exceed 63 characters in length. */ +#define PLAINTEXT_LENGTH 64 +#define CIPHERTEXT_LENGTH SHA256_DIGEST_LENGTH + +#define BINARY_SIZE 4 +#define SALT_SIZE 0 + +#define MIN_KEYS_PER_CRYPT 1 +#define MAX_KEYS_PER_CRYPT 1 + + +static struct fmt_tests tests[] = { + {"fa6b86f30f55fc38d1e98443ab7b6184a2d67acc438329476bade54c634192e5", + "0123456789ABCDE"}, + {"ef797c8118f02dfb649607dd5d3f8c7623048c9c063d532cc95c5ed7a898a64f", + "12345678"}, + {"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + ""}, + {"03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4", + "1234"}, + {NULL} +}; + +static unsigned char saved_key[PLAINTEXT_LENGTH + 1]; +static unsigned char saved_key_len; +static unsigned char saved_hash[CIPHERTEXT_LENGTH]; + +static int valid(char *ciphertext) +{ + return shasum_valid(ciphertext, SHA256_DIGEST_LENGTH * 2); /* bin to hex */ +} + +static void *binary(char *ciphertext) +{ + static char hash[CIPHERTEXT_LENGTH]; + + return shasum_binary(hash, ciphertext, SHA_DIGEST_LENGTH); +} + +static void crypt_all(int count) +{ + SHA256_CTX ctx; + + SHA256_Init(&ctx); + SHA256_Update(&ctx, saved_key, saved_key_len); + SHA256_Final(saved_hash, &ctx); +} + +static int get_hash_0(int index) +{ + return ((int *) saved_hash)[0] & 0xF; +} + +static int get_hash_1(int index) +{ + return ((int *) saved_hash)[0] & 0xFF; +} + +static int get_hash_2(int index) +{ + return ((int *) saved_hash)[0] & 0xFFF; +} + +static void set_key(char *key, int index) +{ + saved_key_len = strlen(key); + strncpy((char *) saved_key, key, PLAINTEXT_LENGTH); + saved_key[PLAINTEXT_LENGTH] = '\0'; +} + +static char *get_key(int index) +{ + return (char *) saved_key; +} + +static int cmp_all(void *binary, int index) +{ + return *(int *) binary == ((int *) saved_hash)[0]; +} + +static int cmp_exact(char *source, int index) +{ + unsigned char *i, *j; + for (i = (unsigned char *) source, + j = (unsigned char *) saved_hash; + *i != '\0'; /* nothing */) { + if ((shasum_hex2dec(i[0]) << 4) + shasum_hex2dec(i[1]) != *j) + return 0; + i += 2; + j++; + } + return 1; +} + +struct fmt_main fmt_SHA256SUM = { + { + FORMAT_LABEL, + FORMAT_NAME, + ALGORITHM_NAME, + BENCHMARK_COMMENT, + BENCHMARK_LENGTH, + PLAINTEXT_LENGTH, + BINARY_SIZE, + SALT_SIZE, + MIN_KEYS_PER_CRYPT, + MAX_KEYS_PER_CRYPT, + FMT_CASE | FMT_8_BIT, + tests + }, { + fmt_default_init, + valid, + fmt_default_split, + binary, + shasum_salt, + { + shasum_binary_hash_0, + shasum_binary_hash_1, + shasum_binary_hash_2 + }, + shasum_salt_hash, + shasum_set_salt, + set_key, + get_key, + fmt_default_clear_keys, + crypt_all, + { + get_hash_0, + get_hash_1, + get_hash_2 + }, + cmp_all, + cmp_all, + cmp_exact + } +}; diff -Nrup john-1.7.2-a/src/SHA384SUM_fmt.c john-1.7.2-b/src/SHA384SUM_fmt.c --- john-1.7.2-a/src/SHA384SUM_fmt.c 1970-01-01 02:00:00.000000000 +0200 +++ john-1.7.2-b/src/SHA384SUM_fmt.c 2007-10-14 14:18:00.000000000 +0300 @@ -0,0 +1,161 @@ +/* + * This file is part of John the Ripper password cracker, + * Copyright (c) 2007 Tommi Saviranta + */ + +#include "SHASUM_std.h" + +#include +#include + +#include "arch.h" +#include "misc.h" +#include "common.h" +#include "formats.h" + +#define FORMAT_LABEL "sha384sum" +#define FORMAT_NAME "SHA384SUM" +#define ALGORITHM_NAME "OpenSSL/SHA384" + +#define BENCHMARK_COMMENT "" +#define BENCHMARK_LENGTH -1 + +/* Assume passwords do not exceed 63 characters in length. */ +#define PLAINTEXT_LENGTH 64 +#define CIPHERTEXT_LENGTH SHA384_DIGEST_LENGTH + +#define BINARY_SIZE 4 +#define SALT_SIZE 0 + +#define MIN_KEYS_PER_CRYPT 1 +#define MAX_KEYS_PER_CRYPT 1 + + +static struct fmt_tests tests[] = { + {"9895a96bbbd52c8f5dce5f34ef485b2e2d63775291ccdb93" + "6500ebfbaa86de9af15ad110cc2a67fa479f3f6d6d646933", + "0123456789ABCDE"}, + {"8cafed2235386cc5855e75f0d34f103ccc183912e5f02446" + "b77c66539f776e4bf2bf87339b4518a7cb1c2441c568b0f8", + "12345678"}, + {"38b060a751ac96384cd9327eb1b1e36a21fdb71114be0743" + "4c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b", + ""}, + {"504f008c8fcf8b2ed5dfcde752fc5464ab8ba064215d9c5b" + "5fc486af3d9ab8c81b14785180d2ad7cee1ab792ad44798c", + "1234"}, + {NULL} +}; + +static unsigned char saved_key[PLAINTEXT_LENGTH + 1]; +static unsigned char saved_key_len; +static unsigned char saved_hash[CIPHERTEXT_LENGTH]; + +static int valid(char *ciphertext) +{ + return shasum_valid(ciphertext, SHA384_DIGEST_LENGTH * 2); /* bin to hex */ +} + +static void *binary(char *ciphertext) +{ + static char hash[CIPHERTEXT_LENGTH]; + + return shasum_binary(hash, ciphertext, SHA_DIGEST_LENGTH); +} + +static void crypt_all(int count) +{ + SHA512_CTX ctx; + + SHA384_Init(&ctx); + SHA384_Update(&ctx, saved_key, saved_key_len); + SHA384_Final(saved_hash, &ctx); +} + +static int get_hash_0(int index) +{ + return ((int *) saved_hash)[0] & 0xF; +} + +static int get_hash_1(int index) +{ + return ((int *) saved_hash)[0] & 0xFF; +} + +static int get_hash_2(int index) +{ + return ((int *) saved_hash)[0] & 0xFFF; +} + +static void set_key(char *key, int index) +{ + saved_key_len = strlen(key); + strncpy((char *) saved_key, key, PLAINTEXT_LENGTH); + saved_key[PLAINTEXT_LENGTH] = '\0'; +} + +static char *get_key(int index) +{ + return (char *) saved_key; +} + +static int cmp_all(void *binary, int index) +{ + return *(int *) binary == ((int *) saved_hash)[0]; +} + +static int cmp_exact(char *source, int index) +{ + unsigned char *i, *j; + for (i = (unsigned char *) source, + j = (unsigned char *) saved_hash; + *i != '\0'; /* nothing */) { + if ((shasum_hex2dec(i[0]) << 4) + shasum_hex2dec(i[1]) != *j) + return 0; + i += 2; + j++; + } + return 1; +} + +struct fmt_main fmt_SHA384SUM = { + { + FORMAT_LABEL, + FORMAT_NAME, + ALGORITHM_NAME, + BENCHMARK_COMMENT, + BENCHMARK_LENGTH, + PLAINTEXT_LENGTH, + BINARY_SIZE, + SALT_SIZE, + MIN_KEYS_PER_CRYPT, + MAX_KEYS_PER_CRYPT, + FMT_CASE | FMT_8_BIT, + tests + }, { + fmt_default_init, + valid, + fmt_default_split, + binary, + shasum_salt, + { + shasum_binary_hash_0, + shasum_binary_hash_1, + shasum_binary_hash_2 + }, + shasum_salt_hash, + shasum_set_salt, + set_key, + get_key, + fmt_default_clear_keys, + crypt_all, + { + get_hash_0, + get_hash_1, + get_hash_2 + }, + cmp_all, + cmp_all, + cmp_exact + } +}; diff -Nrup john-1.7.2-a/src/SHA512SUM_fmt.c john-1.7.2-b/src/SHA512SUM_fmt.c --- john-1.7.2-a/src/SHA512SUM_fmt.c 1970-01-01 02:00:00.000000000 +0200 +++ john-1.7.2-b/src/SHA512SUM_fmt.c 2007-10-14 14:18:04.000000000 +0300 @@ -0,0 +1,165 @@ +/* + * This file is part of John the Ripper password cracker, + * Copyright (c) 2007 Tommi Saviranta + */ + +#include "SHASUM_std.h" + +#include +#include + +#include "arch.h" +#include "misc.h" +#include "common.h" +#include "formats.h" + +#define FORMAT_LABEL "sha512sum" +#define FORMAT_NAME "SHA512SUM" +#define ALGORITHM_NAME "OpenSSL/SHA512" + +#define BENCHMARK_COMMENT "" +#define BENCHMARK_LENGTH -1 + +/* Assume passwords do not exceed 63 characters in length. */ +#define PLAINTEXT_LENGTH 64 +#define CIPHERTEXT_LENGTH SHA512_DIGEST_LENGTH + +#define BINARY_SIZE 4 +#define SALT_SIZE 0 + +#define MIN_KEYS_PER_CRYPT 1 +#define MAX_KEYS_PER_CRYPT 1 + + +static struct fmt_tests tests[] = { + {"c169bcab3bcff4bf3d57a3390c2ae05775a124c02ed4d8be" + "6e2a4933d30c0ab5a6ba18ea1c798d6dcdc8d5a7a859436c" + "8e8e38689a5fc6fbe893e49d3ab2d5e9", + "0123456789ABCDE"}, + {"fa585d89c851dd338a70dcf535aa2a92fee7836dd6aff122" + "6583e88e0996293f16bc009c652826e0fc5c706695a03cdd" + "ce372f139eff4d13959da6f1f5d3eabe", + "12345678"}, + {"cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc" + "83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f" + "63b931bd47417a81a538327af927da3e", + ""}, + {"d404559f602eab6fd602ac7680dacbfaadd13630335e951f" + "097af3900e9de176b6db28512f2e000b9d04fba5133e8b1c" + "6e8df59db3a8ab9d60be4b97cc9e81db", + "1234"}, + {NULL} +}; + +static unsigned char saved_key[PLAINTEXT_LENGTH + 1]; +static unsigned char saved_key_len; +static unsigned char saved_hash[CIPHERTEXT_LENGTH]; + +static int valid(char *ciphertext) +{ + return shasum_valid(ciphertext, SHA512_DIGEST_LENGTH * 2); /* bin to hex */ +} + +static void *binary(char *ciphertext) +{ + static char hash[CIPHERTEXT_LENGTH]; + + return shasum_binary(hash, ciphertext, SHA_DIGEST_LENGTH); +} + +static void crypt_all(int count) +{ + SHA512_CTX ctx; + + SHA512_Init(&ctx); + SHA512_Update(&ctx, saved_key, saved_key_len); + SHA512_Final(saved_hash, &ctx); +} + +static int get_hash_0(int index) +{ + return ((int *) saved_hash)[0] & 0xF; +} + +static int get_hash_1(int index) +{ + return ((int *) saved_hash)[0] & 0xFF; +} + +static int get_hash_2(int index) +{ + return ((int *) saved_hash)[0] & 0xFFF; +} + +static void set_key(char *key, int index) +{ + saved_key_len = strlen(key); + strncpy((char *) saved_key, key, PLAINTEXT_LENGTH); + saved_key[PLAINTEXT_LENGTH] = '\0'; +} + +static char *get_key(int index) +{ + return (char *) saved_key; +} + +static int cmp_all(void *binary, int index) +{ + return *(int *) binary == ((int *) saved_hash)[0]; +} + +static int cmp_exact(char *source, int index) +{ + unsigned char *i, *j; + for (i = (unsigned char *) source, + j = (unsigned char *) saved_hash; + *i != '\0'; /* nothing */) { + if ((shasum_hex2dec(i[0]) << 4) + shasum_hex2dec(i[1]) != *j) + return 0; + i += 2; + j++; + } + return 1; +} + +struct fmt_main fmt_SHA512SUM = { + { + FORMAT_LABEL, + FORMAT_NAME, + ALGORITHM_NAME, + BENCHMARK_COMMENT, + BENCHMARK_LENGTH, + PLAINTEXT_LENGTH, + BINARY_SIZE, + SALT_SIZE, + MIN_KEYS_PER_CRYPT, + MAX_KEYS_PER_CRYPT, + FMT_CASE | FMT_8_BIT, + tests + }, { + fmt_default_init, + valid, + fmt_default_split, + binary, + shasum_salt, + { + shasum_binary_hash_0, + shasum_binary_hash_1, + shasum_binary_hash_2 + }, + shasum_salt_hash, + shasum_set_salt, + set_key, + get_key, + fmt_default_clear_keys, + crypt_all, + { + get_hash_0, + get_hash_1, + get_hash_2 + }, + cmp_all, + cmp_all, + cmp_exact + } +}; diff -Nrup john-1.7.2-a/src/SHASUM_std.c john-1.7.2-b/src/SHASUM_std.c --- john-1.7.2-a/src/SHASUM_std.c 1970-01-01 02:00:00.000000000 +0200 +++ john-1.7.2-b/src/SHASUM_std.c 2007-10-14 14:19:04.000000000 +0300 @@ -0,0 +1,68 @@ +/* + * This file is part of John the Ripper password cracker, + * Copyright (c) 2007 Tommi Saviranta + */ + +#include "SHASUM_std.h" + +#include +#include + +int shasum_valid(char *ciphertext, int len) +{ + static char validchar[] = "0123456789abcdefABCDEF"; + char *i; + int t_len = 0; + + if (strlen(ciphertext) != len) return 0; + + for (i = ciphertext, t_len = 0; *i != '\0'; i++, t_len++) + if (! strchr(validchar, (int) *i)) return 0; + + return len == t_len; +} + +void *shasum_binary(char *hash, char *ciphertext, int len) +{ + char *src, *dest; + + for (src = ciphertext, dest = hash; *src != '\0'; /* empty */) { + *dest = (unsigned char) + ((shasum_hex2dec(src[0]) << 4) + shasum_hex2dec(src[1])); + src += 2; + dest++; + } + + return hash; +} + +int shasum_binary_hash_0(void *binary) +{ + return ((int *) binary)[0] & 0xF; +} + +int shasum_binary_hash_1(void *binary) +{ + return ((int *) binary)[0] & 0xFF; +} + +int shasum_binary_hash_2(void *binary) +{ + return ((int *) binary)[0] & 0xFFF; +} + +void *shasum_salt(char *ciphertext) +{ + static char t = '\0'; + return &t; +} + +void shasum_set_salt(void *salt) +{ + /* nothing here */ +} + +int shasum_salt_hash(void *salt) +{ + return 0; +} diff -Nrup john-1.7.2-a/src/SHASUM_std.h john-1.7.2-b/src/SHASUM_std.h --- john-1.7.2-a/src/SHASUM_std.h 1970-01-01 02:00:00.000000000 +0200 +++ john-1.7.2-b/src/SHASUM_std.h 2007-10-14 14:17:09.000000000 +0300 @@ -0,0 +1,54 @@ +/* + * This file is part of John the Ripper password cracker, + * Copyright (c) 2007 Tommi Saviranta + */ + +#ifndef _JOHN_SHASUM_STD_H +#define _JOHN_SHASUM_STD_H + +static inline unsigned int shasum_hex2dec(char c) +{ + static unsigned int hexlookup[256] = { + ['0'] = 0, + ['1'] = 1, + ['2'] = 2, + ['3'] = 3, + ['4'] = 4, + ['5'] = 5, + ['6'] = 6, + ['7'] = 7, + ['8'] = 8, + ['9'] = 9, + ['a'] = 10, + ['b'] = 11, + ['c'] = 12, + ['d'] = 13, + ['e'] = 14, + ['f'] = 15, + ['A'] = 10, + ['B'] = 11, + ['C'] = 12, + ['D'] = 13, + ['E'] = 14, + ['F'] = 15, + }; + return hexlookup[(unsigned int) c]; +} + +int shasum_valid(char *ciphertext, int len); + +void *shasum_binary(char *hash, char *ciphertext, int len); + +int shasum_binary_hash_0(void *binary); + +int shasum_binary_hash_1(void *binary); + +int shasum_binary_hash_2(void *binary); + +void *shasum_salt(char *ciphertext); + +void shasum_set_salt(void *salt); + +int shasum_salt_hash(void *salt); + +#endif diff -Nrup john-1.7.2-a/src/john.c john-1.7.2-b/src/john.c --- john-1.7.2-a/src/john.c 2006-05-08 17:48:48.000000000 +0300 +++ john-1.7.2-b/src/john.c 2007-10-14 14:05:41.000000000 +0300 @@ -38,6 +38,8 @@ extern int CPU_detect(void); extern struct fmt_main fmt_DES, fmt_BSDI, fmt_MD5, fmt_BF; extern struct fmt_main fmt_AFS, fmt_LM; +extern struct fmt_main fmt_SHA1SUM, fmt_SHA224SUM, fmt_SHA256SUM; +extern struct fmt_main fmt_SHA384SUM, fmt_SHA512SUM; extern int unshadow(int argc, char **argv); extern int unafs(int argc, char **argv); @@ -64,6 +66,11 @@ static void john_register_all(void) john_register_one(&fmt_BF); john_register_one(&fmt_AFS); john_register_one(&fmt_LM); + john_register_one(&fmt_SHA1SUM); + john_register_one(&fmt_SHA224SUM); + john_register_one(&fmt_SHA256SUM); + john_register_one(&fmt_SHA384SUM); + john_register_one(&fmt_SHA512SUM); if (!fmt_list) { fprintf(stderr, "Unknown ciphertext format name requested\n");