[GH-ISSUE #465] Something's wrong with SSE pbkdf2 (in pbkdf2_hmac_sha1.h) #182

Closed
opened 2026-10-14 02:55:29 +07:00 by bsakaguchi · 4 comments
Owner

Originally created by @magnumripper on GitHub (Jan 5, 2014).
Original GitHub issue: https://github.com/openwall/john/issues/465

Originally assigned to: @jfoug on GitHub.

SSE is slower than non-SSE:

Benchmarking: aix-ssha1, AIX LPA {ssha1} [PBKDF2-SHA1 8x SSE2]... DONE
Raw:    31080 c/s real, 30772 c/s virtual

Applying this patch:

diff --git a/src/aix_ssha_fmt_plug.c b/src/aix_ssha_fmt_plug.c
index b06b3c4..b78f76a 100644
--- a/src/aix_ssha_fmt_plug.c
+++ b/src/aix_ssha_fmt_plug.c
@@ -15,6 +15,9 @@
 #include <assert.h>
 #include <errno.h>
 #include "arch.h"
+#undef MMX_COEF
+#undef MMX_COEF_SHA256
+#undef MMX_COEF_SHA512
 #include "misc.h"
 #include "common.h"
 #include "formats.h"

...results in this:

Benchmarking: aix-ssha1, AIX LPA {ssha1} [PBKDF2-SHA1 32/64]... DONE
Raw:    33670 c/s real, 33670 c/s virtual
Originally created by @magnumripper on GitHub (Jan 5, 2014). Original GitHub issue: https://github.com/openwall/john/issues/465 Originally assigned to: @jfoug on GitHub. SSE is slower than non-SSE: ``` Benchmarking: aix-ssha1, AIX LPA {ssha1} [PBKDF2-SHA1 8x SSE2]... DONE Raw: 31080 c/s real, 30772 c/s virtual ``` Applying this patch: ``` diff --git a/src/aix_ssha_fmt_plug.c b/src/aix_ssha_fmt_plug.c index b06b3c4..b78f76a 100644 --- a/src/aix_ssha_fmt_plug.c +++ b/src/aix_ssha_fmt_plug.c @@ -15,6 +15,9 @@ #include <assert.h> #include <errno.h> #include "arch.h" +#undef MMX_COEF +#undef MMX_COEF_SHA256 +#undef MMX_COEF_SHA512 #include "misc.h" #include "common.h" #include "formats.h" ``` ...results in this: ``` Benchmarking: aix-ssha1, AIX LPA {ssha1} [PBKDF2-SHA1 32/64]... DONE Raw: 33670 c/s real, 33670 c/s virtual ```
bsakaguchi 2026-10-14 02:55:29 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@magnumripper commented on GitHub (Jan 5, 2014):

It seems to only be a problem with non-OMP. An OMP build running on just one thread is a whole lot faster.

$ OMP_NUM_THREADS=1 ../run/john -t -form:aix-ssha1 
Warning: OpenMP is disabled; a non-OpenMP build may be faster
Benchmarking: aix-ssha1, AIX LPA {ssha1} [PBKDF2-SHA1 8x SSE2]... DONE
Raw:    160256 c/s real, 160256 c/s virtual
<!-- gh-comment-id:31606907 --> @magnumripper commented on GitHub (Jan 5, 2014): It seems to only be a problem with non-OMP. An OMP build running on just one thread is a whole lot faster. ``` $ OMP_NUM_THREADS=1 ../run/john -t -form:aix-ssha1 Warning: OpenMP is disabled; a non-OpenMP build may be faster Benchmarking: aix-ssha1, AIX LPA {ssha1} [PBKDF2-SHA1 8x SSE2]... DONE Raw: 160256 c/s real, 160256 c/s virtual ```
Author
Owner

@magnumripper commented on GitHub (Jan 6, 2014):

This is bad, it affects 14 or so formats, including AIX, DMG, EncFS, OSX keychain, KRB5pa-sha1 but not WPAPSK for some reason.

<!-- gh-comment-id:31620449 --> @magnumripper commented on GitHub (Jan 6, 2014): This is bad, it affects 14 or so formats, including AIX, DMG, EncFS, OSX keychain, KRB5pa-sha1 but not WPAPSK for some reason.
Author
Owner

@magnumripper commented on GitHub (Jan 6, 2014):

Looking at preprocessor output, everything seems OK. Max keys per crypt is 4 (my SHA1_SSE_PARA is 1) and it is the SSE function that's being used. I'm stumped.

Edit: Hm wait a minute. My PARA is 2 but it's 1 in the preprocessed file. But this doesn't really account for that much performance loss, does it?

Edit2: Scrap that, with -march=native I get (4_2) in the preprocessed file from (MMX_COEF_SHA1_SSE_PARA). So everything looks dandy except I don't get the SSE performance I should get! And somehow building with OMP make the problem go away.

<!-- gh-comment-id:31620721 --> @magnumripper commented on GitHub (Jan 6, 2014): Looking at preprocessor output, everything seems OK. Max keys per crypt is 4 (my SHA1_SSE_PARA is 1) and it _is_ the SSE function that's being used. I'm stumped. _Edit_: Hm wait a minute. My PARA is 2 but it's 1 in the preprocessed file. But this doesn't really account for that much performance loss, does it? _Edit2_: Scrap that, with -march=native I get (4_2) in the preprocessed file from (MMX_COEF_SHA1_SSE_PARA). So everything looks dandy except I don't get the SSE performance I should get! And somehow building with OMP make the problem go away.
Author
Owner

@magnumripper commented on GitHub (Jan 6, 2014):

Red Herring, it was a hardware problem. Extremely weird.

<!-- gh-comment-id:31621324 --> @magnumripper commented on GitHub (Jan 6, 2014): Red Herring, it was a hardware problem. Extremely weird.
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#182
No description provided.