[GH-ISSUE #677] rawSHA256_fmt_plug.c rawSHA256_ng_fmt_plug.c rawSHA256_ng_i_fmt_plug.c #329

Closed
opened 2026-10-14 03:01:30 +07:00 by bsakaguchi · 6 comments
Owner

Originally created by @frank-dittrich on GitHub (Jun 27, 2014).
Original GitHub issue: https://github.com/openwall/john/issues/677

On what platforms are the rawSHA256_ng_fmt_plug.c and rawSHA256_ng_i_fmt_plug.c implementations faster than the rawSHA256_fmt_plug.c one?
Are the ng implementations needed?

If so, they need to be enhanced to process these hashes as well:

$cisco4$LcV6aBcc/53FoCJjXQMd7rBUDEpeevrK8V5jQVoJEhU
LcV6aBcc/53FoCJjXQMd7rBUDEpeevrK8V5jQVoJEhU

These shoud be converted into

$SHA256$5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8
Originally created by @frank-dittrich on GitHub (Jun 27, 2014). Original GitHub issue: https://github.com/openwall/john/issues/677 On what platforms are the rawSHA256_ng_fmt_plug.c and rawSHA256_ng_i_fmt_plug.c implementations faster than the rawSHA256_fmt_plug.c one? Are the __ng__ implementations needed? If so, they need to be enhanced to process these hashes as well: ``` $cisco4$LcV6aBcc/53FoCJjXQMd7rBUDEpeevrK8V5jQVoJEhU LcV6aBcc/53FoCJjXQMd7rBUDEpeevrK8V5jQVoJEhU ``` These shoud be converted into ``` $SHA256$5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8 ```
bsakaguchi 2026-10-14 03:01:30 +07:00
Author
Owner

@frank-dittrich commented on GitHub (Jun 27, 2014):

dynamic_60 also computes raw SHA256.

(bleeding-jumbo)src $ ../run/john --test --format=raw-sha256*
Will run 4 OpenMP threads
Benchmarking: Raw-SHA256 [SHA256 128/128 SSE4.1 4x]... (4xOMP) DONE
Raw:    31604K c/s real, 7920K c/s virtual

Benchmarking: Raw-SHA256-ng [SHA256 128/128 SSE4.1 4x]... (4xOMP) DONE
Raw:    25354K c/s real, 6338K c/s virtual

Benchmarking: Raw-SHA256-ng-i [SHA256 128/128 SSE4.1 4x]... (4xOMP) DONE
Raw:    27901K c/s real, 6975K c/s virtual

All 3 formats passed self-tests!
(bleeding-jumbo)src $ ../run/john --test --format=dynamic_60 
Will run 4 OpenMP threads
Benchmarking: dynamic_60 [sha256($p) 128/128 AVX 4x]... (4xOMP) DONE
Raw:    19845K c/s real, 4973K c/s virtual
<!-- gh-comment-id:47341777 --> @frank-dittrich commented on GitHub (Jun 27, 2014): dynamic_60 also computes raw SHA256. ``` (bleeding-jumbo)src $ ../run/john --test --format=raw-sha256* Will run 4 OpenMP threads Benchmarking: Raw-SHA256 [SHA256 128/128 SSE4.1 4x]... (4xOMP) DONE Raw: 31604K c/s real, 7920K c/s virtual Benchmarking: Raw-SHA256-ng [SHA256 128/128 SSE4.1 4x]... (4xOMP) DONE Raw: 25354K c/s real, 6338K c/s virtual Benchmarking: Raw-SHA256-ng-i [SHA256 128/128 SSE4.1 4x]... (4xOMP) DONE Raw: 27901K c/s real, 6975K c/s virtual All 3 formats passed self-tests! (bleeding-jumbo)src $ ../run/john --test --format=dynamic_60 Will run 4 OpenMP threads Benchmarking: dynamic_60 [sha256($p) 128/128 AVX 4x]... (4xOMP) DONE Raw: 19845K c/s real, 4973K c/s virtual ```
Author
Owner

@magnumripper commented on GitHub (Jun 27, 2014):

Raw-SHA256-ng is self-contained while Raw-SHA256 uses shared code. The former has room for a lot more optimizations that the shared code "can't" do (would screw iterated formats) unless we add interfaces. But the ng format only builds on intel SIMD CPUs. I think both of them should be kept.

The Raw-SHA256-ng-i though, if memory serves me, is just an interim format that should be deleted. I think it got the shared intrinsics before the generic format got them, as a test format more or less. @jfoug?

<!-- gh-comment-id:47373748 --> @magnumripper commented on GitHub (Jun 27, 2014): Raw-SHA256-ng is self-contained while Raw-SHA256 uses shared code. The former has room for a lot more optimizations that the shared code "can't" do (would screw iterated formats) unless we add interfaces. But the ng format only builds on intel SIMD CPUs. I think both of them should be kept. The Raw-SHA256-ng-i though, if memory serves me, is just an interim format that should be deleted. I think it got the shared intrinsics before the generic format got them, as a test format more or less. @jfoug?
Author
Owner

@jfoug commented on GitHub (Jun 27, 2014):

I do not remember all of the ins-outs of these formats, BUT they should be audited now, and the best items taken from each, and get us down to singluar formats.

If the shared code version 'cant' do optimizations, then should we get rid of it? I find the shared ones to be hard to debug and figure out what they are doing. I could really see having certain format functions be 'shared'. Things like valid, split, source, etc probably should be shared. BUT if we do this, then please create them in a stand alone .c file, and use headers to define the function names (i.e. stop using static functions and including code in the header files). To be honest, we probalby could make fmt_default_valid, add a couple things to the format structure, and the default could be used for about 50% of our formats. (same for split, prepare, source, etc). But that is way past scope of this message.

In total, I really do not know what has happened on the SHA2 code. I remember it was not SIMD. Someone did some SIMD code. I started from there and improved it, BUT those original format files still exist. But do we realy need 3 or 4 CPU versions of the same format? Yes, I know we have dyna and a real raw format. But dyna is simply a 'fragment' that can be used as a primative to do a LOT more with, and do it without having to code. But having numerous flat 'raw' formats really does not make sense to me.

<!-- gh-comment-id:47377147 --> @jfoug commented on GitHub (Jun 27, 2014): I do not remember all of the ins-outs of these formats, BUT they should be audited now, and the best items taken from each, and get us down to singluar formats. If the shared code version 'cant' do optimizations, then should we get rid of it? I find the shared ones to be hard to debug and figure out what they are doing. I could really see having certain format functions be 'shared'. Things like valid, split, source, etc probably should be shared. BUT if we do this, then please create them in a stand alone .c file, and use headers to define the function names (i.e. stop using static functions and including code in the header files). To be honest, we probalby could make fmt_default_valid, add a couple things to the format structure, and the default could be used for about 50% of our formats. (same for split, prepare, source, etc). But that is way past scope of this message. In total, I really do not know what has happened on the SHA2 code. I remember it was not SIMD. Someone did some SIMD code. I started from there and improved it, BUT those original format files still exist. But do we realy need 3 or 4 CPU versions of the same format? Yes, I know we have dyna and a real raw format. But dyna is simply a 'fragment' that can be used as a primative to do a LOT more with, and do it without having to code. But having numerous flat 'raw' formats really does not make sense to me.
Author
Owner

@magnumripper commented on GitHub (Jun 27, 2014):

With "shared code" I just meant it's using sse-intrinsics.c

<!-- gh-comment-id:47377462 --> @magnumripper commented on GitHub (Jun 27, 2014): With "shared code" I just meant it's using sse-intrinsics.c
Author
Owner

@magnumripper commented on GitHub (Jun 27, 2014):

Also, despite optimizations "can't" be done, it's the fastest of them all. Gosney's format can be optimized (eg. for shorter pw len) but isn't.

<!-- gh-comment-id:47377680 --> @magnumripper commented on GitHub (Jun 27, 2014): Also, despite optimizations "can't" be done, it's the fastest of them all. Gosney's format _can_ be optimized (eg. for shorter pw len) but isn't.
Author
Owner

@jfoug commented on GitHub (Jun 27, 2014):

By 'shared code' I was refering to those that use a .h file (I think sha256 does this), and they have lots of code in there, that is static. Ignore for now, it is off topic for this thread.

<!-- gh-comment-id:47380086 --> @jfoug commented on GitHub (Jun 27, 2014): By 'shared code' I was refering to those that use a .h file (I think sha256 does this), and they have lots of code in there, that is static. Ignore for now, it is off topic for this thread.
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#329
No description provided.