[GH-ISSUE #1082] Possible bug in sse-intrisic for flat mode #676

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

Originally created by @jfoug on GitHub (Mar 8, 2015).
Original GitHub issue: https://github.com/openwall/john/issues/1082

It appears that in flat mode, the way the code is written, the last byte group (32 bit or 64 bit) might need to be in BE format. This was seen when working with Sybase-ASE. When the code was originally done, I think the bits do not get swapped. But what happens when you do a reload (i.e. multiple buffers).

In that case every limb EXCEPT the last one should have that last word swapped.

It would be easy in the intrisic code to simply remove that stipulation, and simply swap it like the others. HOWEVER, all formats using flat would need to be changed. I have to think on this one a bit. I might add a new flag that lists this is NOT the final limb. IF that flag is set, swapping happens on that word. That should not impact any existing formats.

I am not quite sure how dyna is working on multi-limb big crypt stuff (i.e. flat). It might not be working properly, I have to check.

This is more of a research place holder bug report for now. I have seen something I do not like, BUT the fix may be possibly very ugly.

Originally created by @jfoug on GitHub (Mar 8, 2015). Original GitHub issue: https://github.com/openwall/john/issues/1082 It appears that in flat mode, the way the code is written, the last byte group (32 bit or 64 bit) might need to be in BE format. This was seen when working with Sybase-ASE. When the code was originally done, I think the bits do not get swapped. But what happens when you do a reload (i.e. multiple buffers). In that case every limb EXCEPT the last one should have that last word swapped. It would be easy in the intrisic code to simply remove that stipulation, and simply swap it like the others. HOWEVER, all formats using flat would need to be changed. I have to think on this one a bit. I might add a new flag that lists this is NOT the final limb. IF that flag is set, swapping happens on that word. That should not impact any existing formats. I am not quite sure how dyna is working on multi-limb big crypt stuff (i.e. flat). It might not be working properly, I have to check. This is more of a research place holder bug report for now. I have seen something I do not like, BUT the fix may be possibly very ugly.
bsakaguchi 2026-10-14 03:18:58 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@magnumripper commented on GitHub (Mar 8, 2015):

Yes I noticed that (but did not see this coming). This is a design decision. I think we might just want to add a flag for it - eg. SSEi_FLAT_LASTLIMB which would make us not swap last word, while using SSEi_FLAT we should.

<!-- gh-comment-id:77726680 --> @magnumripper commented on GitHub (Mar 8, 2015): Yes I noticed that (but did not see this coming). This is a design decision. I think we might just want to add a flag for it - eg. SSEi_FLAT_LASTLIMB which would make us _not_ swap last word, while using SSEi_FLAT we should.
Author
Owner

@jfoug commented on GitHub (Mar 8, 2015):

That means every format requires change, and if I am doing that, I will simply remove that non-swap, and then everything swaps.

I think it better (amount of code chnage better), to add a SSEi_FLAT_NOT_LASTLIMB instead. That way, if a format knows it needs 10 limbs, the limbs 1-9 all get that flag. The last does not get it. That way, existing code that swaps the length would not have any new flag added, and would still function fine.

<!-- gh-comment-id:77727151 --> @jfoug commented on GitHub (Mar 8, 2015): That means every format requires change, and if I am doing that, I will simply remove that non-swap, and then everything swaps. I think it better (amount of code chnage better), to add a SSEi_FLAT_NOT_LASTLIMB instead. That way, if a format knows it needs 10 limbs, the limbs 1-9 all get that flag. The last does not get it. That way, existing code that swaps the length would not have any new flag added, and would still function fine.
Author
Owner

@magnumripper commented on GitHub (Mar 8, 2015):

Sure, that's better. I'm not quite happy with the name SSEi_FLAT_NOT_LASTLIMB but I can't think of any that is definitely better. We could call it eg. SSEi_FLAT_MULTI or SSEi_FLAT_SWAPLAST. Maybe the latter one describes the difference best?

<!-- gh-comment-id:77727378 --> @magnumripper commented on GitHub (Mar 8, 2015): Sure, that's better. I'm not quite happy with the name SSEi_FLAT_NOT_LASTLIMB but I can't think of any that is definitely better. We could call it eg. SSEi_FLAT_MULTI or SSEi_FLAT_SWAPLAST. Maybe the latter one describes the difference best?
Author
Owner

@jfoug commented on GitHub (Mar 8, 2015):

The last is probably best. I still do not have sybase-ase done. I now get the first 8 limbs, but 9th is still not right. That is sort of an ugly format for doing with simd. Once I get it, it should be slick. Simply add password to first limb (or 2), and clean prior UTF16 items. Then add salt to 2nd to last limb, and last limb (only 8 bytes). I am only working with 4 limbs. Limb 3 to 7 is simply a flat NULL byte buffer, that all threads will share. Keeps working set much smaller. But getting the data setup correctly was not easy. This actually ended up being a 4 dimension array (pretty rare to code into the 4th dimension). But I am close, and I really think it is the 'right' way to go. Doing this in flat mode. Already ugly enough with UTF-BE and the fun we get to have with that, so I did not want to also add BE-MMX_COEF logic on top of that. But this last word swap caught me by surprise.

<!-- gh-comment-id:77727544 --> @jfoug commented on GitHub (Mar 8, 2015): The last is probably best. I still do not have sybase-ase done. I now get the first 8 limbs, but 9th is still not right. That is sort of an ugly format for doing with simd. Once I get it, it should be slick. Simply add password to first limb (or 2), and clean prior UTF16 items. Then add salt to 2nd to last limb, and last limb (only 8 bytes). I am only working with 4 limbs. Limb 3 to 7 is simply a flat NULL byte buffer, that all threads will share. Keeps working set much smaller. But getting the data setup correctly was not easy. This actually ended up being a 4 dimension array (pretty rare to code into the 4th dimension). But I am close, and I really think it is the 'right' way to go. Doing this in flat mode. Already ugly enough with UTF-BE and the fun we get to have with that, so I did not want to also add BE-MMX_COEF logic on top of that. But this last word swap caught me by surprise.
Author
Owner

@jfoug commented on GitHub (Mar 8, 2015):

There is this flag already (I think I will just use this one)

SSEi_4BUF_INPUT_FIRST_BLK=(0x100|0x200),  // input array 4x in size.  This is the first block, so we MUST rotate element 14/15 if in flat mode.
<!-- gh-comment-id:77727801 --> @jfoug commented on GitHub (Mar 8, 2015): There is this flag already (I think I will just use this one) ``` SSEi_4BUF_INPUT_FIRST_BLK=(0x100|0x200), // input array 4x in size. This is the first block, so we MUST rotate element 14/15 if in flat mode. ```
Author
Owner

@jfoug commented on GitHub (Mar 8, 2015):

Nope, can not. What we have here is '1BUF_first_BLK' I think I will use that SSEi_FLAT_SWAPLAST. flag

<!-- gh-comment-id:77727853 --> @jfoug commented on GitHub (Mar 8, 2015): Nope, can not. What we have here is '1BUF_first_BLK' I think I will use that SSEi_FLAT_SWAPLAST. flag
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#676
No description provided.