mirror of
https://github.com/openwall/john.git
synced 2026-12-03 18:45:21 +07:00
[GH-ISSUE #1577] Raw-SHA384 ASan error #1034
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#1034
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 @frank-dittrich on GitHub (Jul 26, 2015).
Original GitHub issue: https://github.com/openwall/john/issues/1577
Originally assigned to: @magnumripper on GitHub.
@jfoug commented on GitHub (Jul 26, 2015):
This brings up the question: (for @magnumripper )
since we do not use this hash for anything later in these raw formats, why are we reversing the entire 64 bytes? Could we just get by with simply reversing the first 16, and know that there will be no 128 bit collisions That should speed things up, along with require a smaller memory footprint to be kept for the binary() ?
@jfoug commented on GitHub (Jul 26, 2015):
So we would see this:
First off, I think this was already wrong to start with:
Since it is longer than the BINARY_SIZE of the format.
@jfoug commented on GitHub (Jul 26, 2015):
NOTE, rawsha224 has the same bug. BINARY_SIZE is only 28, but in the REVERSE_STEPS, 32 bytes are reversed. It does not 'trip' an ASAN error, but that is probably due to the MEM_ALIGN_WORD giving it an extra 4 bytes (often) at the end of the buffer (buffer is allocated large, so that we can align if needed).
@jfoug commented on GitHub (Jul 26, 2015):
I am waiting on 'fixing' raw-sha224 to hear from @magnumripper on this, since he was the reverser and knows what he intended to do.
@magnumripper commented on GitHub (Jul 26, 2015):
It's still on my (or our) to-do list to find ways to improve SHA2 reversing similar to what I just did to SHA-1 in
48c80a44(not my idea, I saw it in Tavis' raw-sha1-ng).I might have introduced these (and possibly other) bugs in this first step towards more reversing (sorry!). We should always check the full binary size (or DIGEST_SIZE). We can (and perhaps should) use a BINARY_SIZE as small as 4 (32 bits) but then we must implement a proper cmp_exact such as in latest raw md4/md5/sha1 formats.
@jfoug commented on GitHub (Jul 26, 2015):
So, in the 'current' sha384-raw, I have switched the binary to have a 64 byte buffer. That is probably wrong, correct? The correct fix would be to only reverse 48 bytes with the first 6 constants, correct?
Same for sha224 (first 7 constants into 28 bytes.
@magnumripper commented on GitHub (Jul 26, 2015):
We obviously need the SIMD buffers to be full sized. Only core's buffer (list) of loaded binaries should be using the smaller figure, nothing else.
Note also that it's perfectly sane and sometimes very useful to have a binary() that returns a buffer of DIGEST_SIZE, with all of it byte-swapped and sums reversed. The smaller BINARY_SIZE is what will be copied from that returned buffer by loader.c but we can use binary() in other places if needed, eg. in cmp_exact().
@magnumripper commented on GitHub (Jul 26, 2015):
I can clean up this mess of mine if you want, but I'm not touching it until you back off since you are on it (by all means feel free to continue). To sum up, I think (taking SHA384 as example):
4EDIT it should be 8 for SHA384/512 and 4 for SHA224/256.@magnumripper commented on GitHub (Jul 26, 2015):
We have this in simd-intrinsics.c, that's what made me introduce the original bug
I believe this is totally correct BUT in the format's binary, we can obviously only reverse up to INIT_F.
@jfoug commented on GitHub (Jul 26, 2015):
I am not working on this, I was simply asking. I did an initial stab at it when seeing that a 48 byte buffer was being smashed with 64 bytes, but that simply brought up 'what IS the right way'
Yes, WITHIN the SIMD code, the full 64 bytes is required, because you do not know if the users is going to use that as input to the next limb. But outside (in this raw format), we know that we only care about 48 bytes.
I do agree with your assessment about binary(). It should do the FULL proper 48 byte item, then we can simply use it in cmp_exact to do a full compare, while making BINARY_SIZE only 1 uint64_t sized.
@magnumripper commented on GitHub (Jul 26, 2015):
OK, I will review and fix all raw SHA-2.
@magnumripper commented on GitHub (Jul 26, 2015):
This will save PLENTY of memory when loading 100 million hashes... For raw MD5 and things like that, we save 12 bytes per hash. In SHA512 we save 60 bytes per hash...
@jfoug commented on GitHub (Jul 27, 2015):
The problem is, john still stores the full TEXT string in memory. It is a trade off. We put in the source() function to allow john to only store the full binary hash. BUT there is a trade off, in that we may have the 'hot' memory be much larger.
I know Solar talked about splitting the binary into hot/warm parts. Has there been any progress on that?
@magnumripper commented on GitHub (Jul 27, 2015):
Yes. SHA1 had source() but that is not compatible with reduced binary. The reversing (beyond constant adds) implies reduced binary so its source() was dropped. I picture the SHA-2 formats will go that way too so there's no point in adding source() now.