Date: Mon, 21 Jan 2013 20:57:27 +0100 From: magnum <john.magnum@...hmail.com> To: "john-dev@...ts.openwall.com" <john-dev@...ts.openwall.com> Subject: How to use SHA-2 in JtR code Dhiru, all, I had to fix several new formats using SHA-2. We can't use OpenSSL for them right away, because that adds a requirement for OpenSSL 0.9.8 or newer and Solar wants 0.9.7 to work. JimF put together a sha2.h that will do all the magic for you: It will use Apple's CommonCrypto if available (because it's faster than OpenSSL), otherwise it will use OpenSSL if version >= 0.9.8 and if all else fails, it reverts to pretty good generic code. Regardless, the syntax is normal OpenSSL one so the difference for you is mostly just using the right header file. Here's how to use this: 1. Include "sha2.h" instead of <openssl/sha.h>. If you also need SHA-1, include "sha.h" as well. I think it may be wise to include any OpenSSL stuff (like AES) *after* our sha2.h. Just look at some existing format if you are unsure. Also, it's a good habit to include arch.h before any other local header. 2. For ALGORITHM_NAME, add SHA2_LIB to the end, like this: For SHA-224/256: #define ALGORITHM_NAME "32/" ARCH_BITS_STR " " SHA2_LIB For SHA-384/512: #if ARCH_BITS >= 64 #define ALGORITHM_NAME "64/" ARCH_BITS_STR " " SHA2_LIB #else #define ALGORITHM_NAME "32/" ARCH_BITS_STR " " SHA2_LIB #endif That will expand to what code ends up being used, eg: Benchmarking: Raw SHA-256 [32/64 generic]... DONE Raw: 3079K c/s real, 3079K c/s virtual Benchmarking: Raw SHA-256 [32/64 CommonCrypto]... DONE Raw: 2541K c/s real, 2541K c/s virtual Benchmarking: Raw SHA-256 [32/64 OpenSSL]... DONE Raw: 2975K c/s real, 2946K c/s virtual (Apparently in this case Jim's code is fastest and CommonCrypto is slowest!) 3. When testing your format, try forcing generic code like this: $ make -s clean && JOHN_CFLAGS=-DFORCE_GENERIC_SHA2 make -sj8 linux-x86-64 Check that this builds and runs without problems. Hopefully Jim will chime in if I missed or confused something. magnum
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.