mirror of
https://github.com/openwall/john.git
synced 2026-12-03 18:45:21 +07:00
Labels
No labels
bug
core branch
documentation
enhancement
enhancement
fixed - pending verify
fuzz bug
good first issue
invalid
invalid
maintenance/cleanup
new cracking mode
new format
new tool
non-trivial
notes/external issues
portability
question
RFC / discussion
testing
WONTFIX
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
openwall/john#1455
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kholia on GitHub (Jul 18, 2016).
Original GitHub issue: https://github.com/openwall/john/issues/2176
PKCS#12 KDF resides in the "pkcs12_plug.c" file.
It would be great to have a SIMD and OpenCL version of it.
@jfoug commented on GitHub (Jul 18, 2016):
Should pfx_fmt_plug.c be redone using the pkcs12_plug.c functions, and rip it off of the oSSL / algorithm anchor?
@kholia commented on GitHub (Jul 19, 2016):
We already have a new
pfx_ng_fmt_plug.cfile which uses the new PKCS#12 code. We can simply drop the oldpfx_fmt_plug.cfile when the new format is feature complete (and fast).@jfoug commented on GitHub (Jul 20, 2016):
To do SIMD, we will need to do this like we do the PBKDF2 stuff, where each format will need to handle loading proper arrays of input, then calling the PKCS#12 functions. Should be doable for sure.
@jfoug commented on GitHub (Jul 21, 2016):
NOTE:
Since we fail based on pwlen, which is (plaintext_len << 1) + 2 should we be limiting plaintext length of all formats using this code to 31 bytes ???
Question is for @kholia
@jfoug commented on GitHub (Jul 21, 2016):
Only 2.4 now (still POC). Note, it is not 100% SIMD, I only SIMD the iteration block. BUT this is only 4x SIMD. We should see a 5x improvement for 8x SIMD chips (with the current POC code).
That looks a bit better ;) Looks like the BKS has a lot of data that is done in the final hmac. We do not have SIMD code for hmac (but might be able to steal logic from pbkdf2-hmac-sha1.h file).
@jfoug commented on GitHub (Jul 21, 2016):
Ok, getting ready to check this in. Now the speeds are 'better'. I also have 1 line in pkcs12.h which we can set to #if 1 and build in non-SIMD mode, for easier testing.
Both are about 4.1-4.2x faster on my AVX (SIMD-4x) so being > 4x makes me smile a bit ;)
@jfoug commented on GitHub (Jul 21, 2016):
Gonna just directly check in the SIMD changes. This is NOT opencl, someone else can play with that one ;)
@jfoug commented on GitHub (Jul 21, 2016):
NOTE, I set Plaintext length to 31 for both of these formats (until I hear otherwise).
@jfoug commented on GitHub (Jul 21, 2016):
@kholia please test on your AVX2, to make sure I did not bone anything. I have only tested on AVX (SIMD-4x).
@jfoug commented on GitHub (Jul 21, 2016):
Does PKCS12 also use other hashing algo? I am surprised that only sha1 is supported, and would think all (or many) SHA2 hashes should also be there.
@kholia commented on GitHub (Jul 22, 2016):
Before SIMD,
After SIMD changes,
Speed-up is around 5.6x.
@kholia commented on GitHub (Jul 22, 2016):
Yes, other hashes are supported too. See
/run/pfxng2john.pyfor a list. Various SHA2 hashes are there.I should have named
mbedtls_pkcs12_derivationasmbedtls_pkcs12_derivation_sha1in the first place.@jfoug commented on GitHub (Jul 22, 2016):
do you have the specific differences. I would like to take a shot at getting at least non-SIMD of all hashes. I see:
sha1, 224, 256, 384, 512. Also 512_224/512_256 which I am not sure john handles. But I REALLY think we should target 256 and 512 out of the gate. Yes, there 'are' others, but I think sha1 (default), along with the 'normal' sha2 hashes should be what we get working now.
@kholia commented on GitHub (Jul 22, 2016):
I am not sure about this one. The "pwdlen > 64" check in
mbedtls_pkcs12_derivationseems to be a limitation of this particular implementation.https://github.com/doublereedkurt/pyjks/blob/master/jks/rfc7292.py#L21 has another implementation of
PKCS#12 key derivation.
For now, setting PLAINTEXT_LENGTH to 32 is OK I think.
@jfoug commented on GitHub (Jul 22, 2016):
32 would not work, since the UTF16 null looks like it is required.
But now that I have figure out how to generate these things, I can build hashes with longer passwords, to see just what would crack. I see no reason why it should not 'work', but i really do not understand the algo 'yet'
@kholia commented on GitHub (Jul 22, 2016):
I can attempt getting sha256 support working. Give me a day or two.
32 was a typo in my last comment, I meant 31 :-)
@kholia commented on GitHub (Jul 22, 2016):
You can use this information to generate .pfx files for testing.
@jfoug commented on GitHub (Jul 22, 2016):
NOTE, it appears that 30 char pw is 'max' for the current code (sha1) for pfx-ng I built a 30 char and a 31 char, and only the 30 char can be found.
@jfoug commented on GitHub (Jul 22, 2016):
new issue added #2183 (original pfx format does not have this problem)
@jfoug commented on GitHub (Jul 22, 2016):
Sha256 SIMD added (along with cost stuff since we now have algo costs). Only saw 2.5x improvement for SHA256, but i think the SIMD improvements are a bit less for that hash. Also, the hmac being done in oSSL for sha256, 'may' have a larger impact on overall speed.
sha256 also seems to have 30 byte max password length for pfx-ng
@jfoug commented on GitHub (Jul 22, 2016):
NOTE, pfx format also is only finding 30 byte passwords. I wonder if our *2john are right? Possibly, 30 character is MAX possible??? (My bad, that was ng)
@jfoug commented on GitHub (Jul 23, 2016):
@kholia I already have sha512 in there, BUT I have to find/fix a problem with SHA256 simd code (I think I know the issue). Once I get sha256 figured out, the 512 code should be trivial (the oSSL version / pfxng2john.py code already is working fine).
@kholia commented on GitHub (Jul 27, 2016):
The actual length limit of 30 needs further investigation. This said, 30 should not be a problem in practice.
@jfoug commented on GitHub (Jul 27, 2016):
Ok, all 3 hashes (sha1, sha256, sha512), for SIMD (at least) only detect 30, and not 31:
I will check to make sure non-SIMD has same limitation, but I would bet it does (and will only post a follow up if I find otherwise)
@jfoug commented on GitHub (Jul 27, 2016):
It should be easy to increase that count, but we will probably have to dig into oSSL source, and see just how the data is used. Likely it will simply be within the pkcs12_fill_buffer function(s)
@jfoug commented on GitHub (Jul 27, 2016):
Ok, I am able to get 31 byte passwords to work. BUT to do that, I have to set PLAINTEXT_LENGTH to 32 ?!?!?! Yes, we do need to figure this out. It really should NOT be an issue to make the password length longer. The encryption of the password seems to play very little in overall speed. It simply preloads the hash contexts. The main loop is just re-encrypting the prior steps, thus the speed will be constant.
@jfoug commented on GitHub (Jul 27, 2016):
I have been able to increase PLAINTEXT_LENGTH up (at least on sha1). I think SHA256 would be the same. I am surprised that > 31 for SHA512 was not working (it may have been already.
However, it appears there is some max length WITHIN the openssl process on key length. We should find that out, and make sure that we can at least handle up to that size. (it is less than 60 I think).
@jfoug commented on GitHub (Jul 27, 2016):
Ok, this DEBUG_KEYGEN build is oSSL shows (I think) the limit. The password is 1234567890123.....90 (50 bytes long.) But look at the 'last' password length (only 100). The last '0' character was truncated off, so only a 49 byte password was used, AND cracks the hash if used.
NOTE, this may also simply be a bug in the oSSL version I am building against (1.0.2d)
The final 'key' CCB8...14D9 is the key generated by mbedtls_pkcs12_derivation() if we use the first 49 bytes of that number password.
@jfoug commented on GitHub (Jul 28, 2016):
sha224/sha384 added (non-simd). I am not sure the ROI on SIMD for those hashes are worthwhile. Likely they will not be seen ITW.
Also, that python lib only does sha1, 224, 256, 384 and 512. oSSL does Whirlpool, sha0, md5, md4, mdc2 and likely others, but those were the only ones macalgo's I could get oSSL to do, there were others documented ,but my cygwin ossl would not do them (like RIPEMD160, blake2, etc). I think if we want 'full' PCSS#12 support, we will need to write our own .c pfgng2john.c conversion program, not using python. But again, is that worth the ROI?
@kholia commented on GitHub (Jul 28, 2016):
No, I don't think that full PKCS#12 support is worth the effort. I think that the existing Python script can easily support all the possible mac algorithms.
@jfoug commented on GitHub (Jul 28, 2016):
The asn1crypto lib does macalgo of sha1, sha224-512 only. But that likely can be 'deemed' as full enough support.
@jfoug commented on GitHub (Jul 28, 2016):
PLAINTEXT_LENGTH bumped up to 48 for all formats. From my usage of openssl, this seems like the max it will do anyway. If you add a 49 byte pw, ossl trims it to 48. Also, if you add a longer password, ossl bails saying no password entered. (likely a bug in ossl, but I do not care). 48 byte password checking is long enough.
@jfoug commented on GitHub (Jul 28, 2016):
The SIMD code is done for now. All sha1 and sha2 are handled by the format. SIMD code is there for all hashes except the textbook ones of sha224 and sha384 (which no one ITW will use for real hashes).
36a7264@kholia commented on GitHub (Mar 8, 2017):
Jetico BestCrypt also makes use of this KDF. It would be nice to get an OpenCL port of this KDF.
@magnumripper commented on GitHub (Mar 8, 2017):
What exactly do we need? Just saying "PKCS#12 KDF" is akin to saying "PBKDF2" without stating a PRNG.
@kholia commented on GitHub (Mar 8, 2017):
Oh, right! Starting with the OpenCL port of PKCS#12 KDF with SHA-1 as the hashing function would be good.
@kholia commented on GitHub (Jun 21, 2017):
This is partially done in https://github.com/magnumripper/JohnTheRipper/pull/2583.
@kholia commented on GitHub (Jun 26, 2017):
@magnumripper Great work in commit
22eb8e345e👍I think that the license of
src/opencl_pkcs12.hfile needs to be the same as thepkcs12_plug.cone. I will send a pull request soon to fix this.@kholia commented on GitHub (Sep 27, 2017):
This issue can be closed now.