[GH-ISSUE #317] Drop all use of DEFAULT_ALIGN #59

Closed
opened 2026-10-14 02:50:54 +07:00 by bsakaguchi · 17 comments
Owner

Originally created by @magnumripper on GitHub (May 29, 2013).
Original GitHub issue: https://github.com/openwall/john/issues/317

Any format using DEFAULT_ALIGN should be using BINARY_ALIGN and SALT_ALIGN instead, with correct values assigned to them.

After that is done, drop the actual definition of DEFAULT_ALIGN too, stopping anyone from using it.

Originally created by @magnumripper on GitHub (May 29, 2013). Original GitHub issue: https://github.com/openwall/john/issues/317 Any format using DEFAULT_ALIGN should be using BINARY_ALIGN and SALT_ALIGN instead, with correct values assigned to them. After that is done, drop the actual definition of DEFAULT_ALIGN too, stopping anyone from using it.
bsakaguchi 2026-10-14 02:50:54 +07:00
Author
Owner

@magnumripper commented on GitHub (Jun 3, 2013):

Basically, any format that has DEFAULT_ALIGN in its format struct (like NT_fmt.c in current bleeding-jumbo tree) should be modified to use BINARY_ALIGN and SALT_ALIGN instead, and those two new macros should be defined in top of format (like nt2_fmt_plug.c in current tree). The correct value for them depends on binary() and salt() and possibly also salt_hash(), binary_hash() and cmp_*(). The vast majority would have both set to either 1 or 4. For a salt- or binary size of 0, the corresponding align could be 1. Any format that casts the salt or binary eg. in binary_hash() or cmp_all() needs to have alignment set accordingly.

<!-- gh-comment-id:18858283 --> @magnumripper commented on GitHub (Jun 3, 2013): Basically, any format that has DEFAULT_ALIGN in its format struct (like NT_fmt.c in current bleeding-jumbo tree) should be modified to use BINARY_ALIGN and SALT_ALIGN instead, and those two new macros should be defined in top of format (like nt2_fmt_plug.c in current tree). The correct value for them depends on binary() and salt() and possibly also salt_hash(), binary_hash() and cmp_*(). The vast majority would have both set to either 1 or 4. For a salt- or binary size of 0, the corresponding align could be 1. Any format that casts the salt or binary eg. in binary_hash() or cmp_all() needs to have alignment set accordingly.
Author
Owner

@kholia commented on GitHub (Jun 5, 2013):

I have started working on this issue.

<!-- gh-comment-id:18965727 --> @kholia commented on GitHub (Jun 5, 2013): I have started working on this issue.
Author
Owner

@magnumripper commented on GitHub (Jun 9, 2013):

I fixed all formats that had my name in them (for any reason). Still 74 to go :-/

<!-- gh-comment-id:19170629 --> @magnumripper commented on GitHub (Jun 9, 2013): I fixed all formats that had my name in them (for any reason). Still 74 to go :-/
Author
Owner

@magnumripper commented on GitHub (Feb 28, 2014):

Here's a way to make them show up:

diff --git a/src/formats.h b/src/formats.h
index ef76189..83e9693 100644
--- a/src/formats.h
+++ b/src/formats.h
@@ -20,7 +20,7 @@ struct fmt_main;
 /*
  * Default alignment (used unless known)
  */
-#define DEFAULT_ALIGN MEM_ALIGN_WORD
+#define DEFAULT_ALIGN (MEM_ALIGN_WORD+1)

 /*
  * Some format methods accept pointers to these, yet we can't just include

Result:

$ ../run/john -t=0 | grep FAILED
Testing: FormSpring [sha256($s.$p) 128/128 AVX 4x]... FAILED (binary_align)
Testing: mysql, MySQL pre-4.1 [32/64]... FAILED (binary_align)
Testing: md5ns, Netscreen [MD5 32/64]... FAILED (binary_align)
Testing: osc, osCommerce [md5($s.$p) (OSC) 128/128 AVX 10x4x3]... FAILED (binary_align)
Testing: PHPS [md5(md5($p).$s) 128/128 AVX 10x4x3]... FAILED (binary_align)
Testing: OpenVMS, Purdy [32/64]... FAILED (binary_align)
Testing: agilekeychain, 1Password Agile Keychain [PBKDF2-SHA1 AES 8x SSE2]... FAILED (binary_align)
Testing: asa-md5, Cisco ASA [Cisco ASA (MD5 salted) 128/128 AVX 10x4x3]... FAILED (binary_align)
Testing: Bitcoin [SHA256 AES 32/64]... FAILED (binary_align)
Testing: chap, iSCSI CHAP authentication [MD5 32/64]... FAILED (binary_align)
Testing: dmg, Apple DMG [PBKDF2-SHA1 3DES/AES 32/64]... FAILED (binary_align)
Testing: EFS [PBKDF2-SHA1-crap 3DES 32/64]... FAILED (binary_align)
Testing: fde, Android FDE [PBKDF2-SHA1 32/64]... FAILED (binary_align)
Testing: gost, GOST R 34.11-94 [64/64]... FAILED (binary_align)
Testing: gpg, OpenPGP / GnuPG Secret Key [32/64]... FAILED (binary_align)
Testing: IKE, PSK [HMAC MD5/SHA1 32/64]... FAILED (binary_align)
Testing: keychain, Mac OS X Keychain [PBKDF2-SHA1 3DES 8x SSE2]... FAILED (binary_align)
Testing: keyring, GNOME Keyring [SHA256 AES 32/64 OpenSSL]... FAILED (binary_align)
Testing: kwallet, KDE KWallet [SHA1 32/64]... FAILED (binary_align)
Testing: lp, LastPass offline [PBKDF2-SHA256 128/128 SSE4.1 4x]... FAILED (binary_align)
Testing: lotus5, Lotus Notes/Domino 5 [8/64]... FAILED (binary_align)
Testing: LUKS [PBKDF2-SHA1 32/64]... FAILED (binary_align)
Testing: MediaWiki [md5($s.md5($p)) 128/128 AVX 10x4x3]... FAILED (binary_align)
Testing: MongoDB, system / network [MD5 32/64]... FAILED (binary_align)
Testing: net-md5, "Keyed MD5" RIPv2, OSPF, BGP, SNMPv2 [MD5 32/64]... FAILED (binary_align)
Testing: net-sha1, "Keyed SHA1" RIPv2, OSPF, BGP, SNMPv2 [SHA1 32/64]... FAILED (binary_align)
Testing: nk, Nuked-Klan CMS [SHA1 MD5 32/64]... FAILED (binary_align)
Testing: o5logon, Oracle O5LOGON protocol [SHA1 AES 32/64]... FAILED (binary_align)
Testing: ODF [SHA1 BF / SHA256 AES 8x SSE2]... FAILED (binary_align)
Testing: Office, 2007/2010 (SHA-1) / 2013 (SHA-512), with AES [32/64 OpenSSL]... FAILED (binary_align)
Testing: oldoffice, MS Office <= 2003 [MD5/SHA1 RC4 32/64]... FAILED (binary_align)
Testing: openssl-enc, OpenSSL "enc" encryption [32/64]... FAILED (binary_align)
Testing: PDF [MD5 SHA2 RC4/AES 32/64]... FAILED (binary_align)
Testing: phpass ($P$9) [phpass ($P$ or $H$) 128/128 AVX 4x4x3]... FAILED (binary_align)
Testing: pix-md5, Cisco PIX [Cisco PIX (MD5) 128/128 AVX 10x4x3]... FAILED (binary_align)
Testing: PST, custom CRC-32 [32/64]... FAILED (binary_align)
Testing: pwsafe, Password Safe [SHA256 32/64]... FAILED (binary_align)
Testing: RACF [DES 32/64]... FAILED (binary_align)
Testing: RAR5 [(experimental) PBKDF2-SHA256 32/64]... FAILED (binary_align)
Testing: Siemens-S7 [HMAC-SHA1 32/64]... FAILED (binary_align)
Testing: SIP [MD5 32/64]... FAILED (binary_align)
Testing: LastPass, sniffed sessions [PBKDF2-SHA256 AES 128/128 SSE4.1 4x]... FAILED (binary_align)
Testing: SSH-ng [RSA/DSA 32/64]... FAILED (binary_align)
Testing: STRIP, Password Manager [PBKDF2-SHA1 8x SSE2]... FAILED (binary_align)
Testing: sxc, StarOffice .sxc [SHA1 Blowfish 8x SSE2]... FAILED (binary_align)
Testing: tcp-md5, TCP MD5 Signatures, BGP [MD5 32/64]... FAILED (binary_align)
Testing: VNC [DES 32/64]... FAILED (binary_align)
Testing: wbb3, WoltLab BB3 [SHA1 32/64]... FAILED (binary_align)
Testing: Django (x10000) [PBKDF2-SHA256 128/128 SSE4.1 4x]... FAILED (binary_align)
Testing: Mozilla, key3.db [SHA1 3DES 32/64]... FAILED (binary_align)
Testing: PFX, PKCS12 (.pfx, .p12) [32/64]... FAILED (binary_align)
Testing: SSH (one 2048-bit RSA and one 1024-bit DSA key) [RSA/DSA 32/64]... FAILED (binary_align)
52 out of 369 tests have FAILED
<!-- gh-comment-id:36387078 --> @magnumripper commented on GitHub (Feb 28, 2014): Here's a way to make them show up: ``` diff --git a/src/formats.h b/src/formats.h index ef76189..83e9693 100644 --- a/src/formats.h +++ b/src/formats.h @@ -20,7 +20,7 @@ struct fmt_main; /* * Default alignment (used unless known) */ -#define DEFAULT_ALIGN MEM_ALIGN_WORD +#define DEFAULT_ALIGN (MEM_ALIGN_WORD+1) /* * Some format methods accept pointers to these, yet we can't just include ``` Result: ``` $ ../run/john -t=0 | grep FAILED Testing: FormSpring [sha256($s.$p) 128/128 AVX 4x]... FAILED (binary_align) Testing: mysql, MySQL pre-4.1 [32/64]... FAILED (binary_align) Testing: md5ns, Netscreen [MD5 32/64]... FAILED (binary_align) Testing: osc, osCommerce [md5($s.$p) (OSC) 128/128 AVX 10x4x3]... FAILED (binary_align) Testing: PHPS [md5(md5($p).$s) 128/128 AVX 10x4x3]... FAILED (binary_align) Testing: OpenVMS, Purdy [32/64]... FAILED (binary_align) Testing: agilekeychain, 1Password Agile Keychain [PBKDF2-SHA1 AES 8x SSE2]... FAILED (binary_align) Testing: asa-md5, Cisco ASA [Cisco ASA (MD5 salted) 128/128 AVX 10x4x3]... FAILED (binary_align) Testing: Bitcoin [SHA256 AES 32/64]... FAILED (binary_align) Testing: chap, iSCSI CHAP authentication [MD5 32/64]... FAILED (binary_align) Testing: dmg, Apple DMG [PBKDF2-SHA1 3DES/AES 32/64]... FAILED (binary_align) Testing: EFS [PBKDF2-SHA1-crap 3DES 32/64]... FAILED (binary_align) Testing: fde, Android FDE [PBKDF2-SHA1 32/64]... FAILED (binary_align) Testing: gost, GOST R 34.11-94 [64/64]... FAILED (binary_align) Testing: gpg, OpenPGP / GnuPG Secret Key [32/64]... FAILED (binary_align) Testing: IKE, PSK [HMAC MD5/SHA1 32/64]... FAILED (binary_align) Testing: keychain, Mac OS X Keychain [PBKDF2-SHA1 3DES 8x SSE2]... FAILED (binary_align) Testing: keyring, GNOME Keyring [SHA256 AES 32/64 OpenSSL]... FAILED (binary_align) Testing: kwallet, KDE KWallet [SHA1 32/64]... FAILED (binary_align) Testing: lp, LastPass offline [PBKDF2-SHA256 128/128 SSE4.1 4x]... FAILED (binary_align) Testing: lotus5, Lotus Notes/Domino 5 [8/64]... FAILED (binary_align) Testing: LUKS [PBKDF2-SHA1 32/64]... FAILED (binary_align) Testing: MediaWiki [md5($s.md5($p)) 128/128 AVX 10x4x3]... FAILED (binary_align) Testing: MongoDB, system / network [MD5 32/64]... FAILED (binary_align) Testing: net-md5, "Keyed MD5" RIPv2, OSPF, BGP, SNMPv2 [MD5 32/64]... FAILED (binary_align) Testing: net-sha1, "Keyed SHA1" RIPv2, OSPF, BGP, SNMPv2 [SHA1 32/64]... FAILED (binary_align) Testing: nk, Nuked-Klan CMS [SHA1 MD5 32/64]... FAILED (binary_align) Testing: o5logon, Oracle O5LOGON protocol [SHA1 AES 32/64]... FAILED (binary_align) Testing: ODF [SHA1 BF / SHA256 AES 8x SSE2]... FAILED (binary_align) Testing: Office, 2007/2010 (SHA-1) / 2013 (SHA-512), with AES [32/64 OpenSSL]... FAILED (binary_align) Testing: oldoffice, MS Office <= 2003 [MD5/SHA1 RC4 32/64]... FAILED (binary_align) Testing: openssl-enc, OpenSSL "enc" encryption [32/64]... FAILED (binary_align) Testing: PDF [MD5 SHA2 RC4/AES 32/64]... FAILED (binary_align) Testing: phpass ($P$9) [phpass ($P$ or $H$) 128/128 AVX 4x4x3]... FAILED (binary_align) Testing: pix-md5, Cisco PIX [Cisco PIX (MD5) 128/128 AVX 10x4x3]... FAILED (binary_align) Testing: PST, custom CRC-32 [32/64]... FAILED (binary_align) Testing: pwsafe, Password Safe [SHA256 32/64]... FAILED (binary_align) Testing: RACF [DES 32/64]... FAILED (binary_align) Testing: RAR5 [(experimental) PBKDF2-SHA256 32/64]... FAILED (binary_align) Testing: Siemens-S7 [HMAC-SHA1 32/64]... FAILED (binary_align) Testing: SIP [MD5 32/64]... FAILED (binary_align) Testing: LastPass, sniffed sessions [PBKDF2-SHA256 AES 128/128 SSE4.1 4x]... FAILED (binary_align) Testing: SSH-ng [RSA/DSA 32/64]... FAILED (binary_align) Testing: STRIP, Password Manager [PBKDF2-SHA1 8x SSE2]... FAILED (binary_align) Testing: sxc, StarOffice .sxc [SHA1 Blowfish 8x SSE2]... FAILED (binary_align) Testing: tcp-md5, TCP MD5 Signatures, BGP [MD5 32/64]... FAILED (binary_align) Testing: VNC [DES 32/64]... FAILED (binary_align) Testing: wbb3, WoltLab BB3 [SHA1 32/64]... FAILED (binary_align) Testing: Django (x10000) [PBKDF2-SHA256 128/128 SSE4.1 4x]... FAILED (binary_align) Testing: Mozilla, key3.db [SHA1 3DES 32/64]... FAILED (binary_align) Testing: PFX, PKCS12 (.pfx, .p12) [32/64]... FAILED (binary_align) Testing: SSH (one 2048-bit RSA and one 1024-bit DSA key) [RSA/DSA 32/64]... FAILED (binary_align) 52 out of 369 tests have FAILED ```
Author
Owner

@jfoug commented on GitHub (Nov 21, 2014):

worked through some more: f5366a2

Cuda stuff untested, but set safe. Binary align set to how binary used, and salt align set to largest member of salt struct. That is safe. Since cuda might be on intel only, alignment may not matter.

These changes tested on Sparc (Btw, I LOVELOVELOVE having ./configure now that sets up the sparc build properly, even though there are plenty of warnings)

Tested on 32/64 bit cygwin, 64 bit linux, 32 bit BE sparc. Did have one fix: 2603301

<!-- gh-comment-id:63991364 --> @jfoug commented on GitHub (Nov 21, 2014): worked through some more: f5366a2 Cuda stuff untested, but set safe. Binary align set to how binary used, and salt align set to largest member of salt struct. That is safe. Since cuda might be on intel only, alignment may not matter. These changes tested on Sparc (Btw, I LOVELOVELOVE having ./configure now that sets up the sparc build properly, even though there are plenty of warnings) Tested on 32/64 bit cygwin, 64 bit linux, 32 bit BE sparc. Did have one fix: 2603301
Author
Owner

@kholia commented on GitHub (Nov 21, 2014):

I hate to say it, but I am loving all the configure magic too 👍

I was trying to get something like configure --with-asan working but no luck so far.

@magnumripper @jfoug it would be awesome to get something like configure --with-asan working :)

<!-- gh-comment-id:64000398 --> @kholia commented on GitHub (Nov 21, 2014): I hate to say it, but I am loving all the `configure` magic too :+1: I was trying to get something like `configure --with-asan` working but no luck so far. @magnumripper @jfoug it would be awesome to get something like `configure --with-asan` working :)
Author
Owner

@magnumripper commented on GitHub (Nov 21, 2014):

That should be trivial. But context-switching into M4 takes me a while every time 😵

<!-- gh-comment-id:64010096 --> @magnumripper commented on GitHub (Nov 21, 2014): That should be trivial. But context-switching into M4 takes me a while every time :dizzy_face:
Author
Owner

@jfoug commented on GitHub (Nov 21, 2014):

LOLOLOL M4 is your friend

(from hell)

<!-- gh-comment-id:64029783 --> @jfoug commented on GitHub (Nov 21, 2014): LOLOLOL M4 is your friend (from hell)
Author
Owner

@jfoug commented on GitHub (Nov 21, 2014):

Some more: 6c1b599

gpg fixed (f02231c) I do not understand why what one required 4 byte alignment, but it cored withouth it???

<!-- gh-comment-id:64048830 --> @jfoug commented on GitHub (Nov 21, 2014): Some more: 6c1b599 gpg fixed (f02231c) I do not understand why what one required 4 byte alignment, but it cored withouth it???
Author
Owner

@jfoug commented on GitHub (Nov 21, 2014):

More ea17835 I will test on BE, and this might be the last for a bit.

ONLY 34 left...

<!-- gh-comment-id:64053313 --> @jfoug commented on GitHub (Nov 21, 2014): More ea17835 I will test on BE, and this might be the last for a bit. ONLY 34 left...
Author
Owner

@jfoug commented on GitHub (Nov 22, 2014):

@magnum, I am going to do opencl (I am just finishing up all non-opencl). For opencl,, I simply am going to make all of them MEM_ALIGN_WORD. There are no issue for BE systems, but I want ot keep them the same as they are today. If you want me to handle this differently let me know.

<!-- gh-comment-id:64059461 --> @jfoug commented on GitHub (Nov 22, 2014): @magnum, I am going to do opencl (I am just finishing up all non-opencl). For opencl,, I simply am going to make all of them MEM_ALIGN_WORD. There are no issue for BE systems, but I want ot keep them the same as they are today. If you want me to handle this differently let me know.
Author
Owner

@jfoug commented on GitHub (Nov 22, 2014):

11a81c0 will test on BE. Only ones left now are opencl, and of course formats.h

<!-- gh-comment-id:64059686 --> @jfoug commented on GitHub (Nov 22, 2014): 11a81c0 will test on BE. Only ones left now are opencl, and of course formats.h
Author
Owner

@jfoug commented on GitHub (Nov 22, 2014):

Completed:

aac6b4b was last of the formats (I did NOT do anything in ./src/unused)
69523d4 removes the #define from formats.h

<!-- gh-comment-id:64062083 --> @jfoug commented on GitHub (Nov 22, 2014): Completed: aac6b4b was last of the formats (I did NOT do anything in ./src/unused) 69523d4 removes the #define from formats.h
Author
Owner

@magnumripper commented on GitHub (Nov 22, 2014):

Excellent!

For opencl,, I simply am going to make all of them MEM_ALIGN_WORD

If binary() or salt() returns (or may return) smalled alignment than that, we'll get annoying warnings on some systems. I don't see a single warning right now though.

<!-- gh-comment-id:64077805 --> @magnumripper commented on GitHub (Nov 22, 2014): Excellent! > For opencl,, I simply am going to make all of them MEM_ALIGN_WORD If binary() or salt() returns (or may return) smalled alignment than that, we'll get annoying warnings on some systems. I don't see a single warning right now though.
Author
Owner

@magnumripper commented on GitHub (Nov 22, 2014):

Good job. This was a boring issue!

<!-- gh-comment-id:64077852 --> @magnumripper commented on GitHub (Nov 22, 2014): Good job. This was a boring issue!
Author
Owner

@jfoug commented on GitHub (Nov 22, 2014):

If binary() returns (or may return) smalled alignment than that, we'll get annoying warnings on some systems. I don't see a single warning right now though.

the old default already WAS MEM_ALIGN_WORD, so that is why I wanted to keep them that way. I did change so that salt len=0 got a align=1 and binary=0 (with no 4 byte needed hash), then align was set to 1. I think others mostly got MEM_ALIGN_WORD

<!-- gh-comment-id:64078100 --> @jfoug commented on GitHub (Nov 22, 2014): > If binary() returns (or may return) smalled alignment than that, we'll get annoying warnings on some systems. I don't see a single warning right now though. the old default already WAS MEM_ALIGN_WORD, so that is why I wanted to keep them that way. I did change so that salt len=0 got a align=1 and binary=0 (with no 4 byte needed hash), then align was set to 1. I think others mostly got MEM_ALIGN_WORD
Author
Owner

@magnumripper commented on GitHub (Nov 22, 2014):

the old default already WAS MEM_ALIGN_WORD

Ah, yes. I always fixed formats that I saw warnings from so we're probably 99% set now.

<!-- gh-comment-id:64078162 --> @magnumripper commented on GitHub (Nov 22, 2014): > the old default already WAS MEM_ALIGN_WORD Ah, yes. I always fixed formats that I saw warnings from so we're probably 99% set now.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openwall/john#59
No description provided.