[GH-ISSUE #1331] Fix 32-bit builds breakage from Stribog #837

Closed
opened 2026-10-14 03:25:36 +07:00 by bsakaguchi · 5 comments
Owner

Originally created by @magnumripper on GitHub (May 18, 2015).
Original GitHub issue: https://github.com/openwall/john/issues/1331

Originally assigned to: @kholia on GitHub.

Problem introduced by ebbbfc1a8

One possibility (although not the best) is to just #ifdef the whole file outside of the plugin stanza. Similar to eg. rawSHA1_ng_fmt_plug.c but in this case checking for eg. ARCH_SIZE after including arch.h

But it should be very trivial to actually fix it instead. Why does it break at all?

Originally created by @magnumripper on GitHub (May 18, 2015). Original GitHub issue: https://github.com/openwall/john/issues/1331 Originally assigned to: @kholia on GitHub. Problem introduced by ebbbfc1a8 One possibility (although not the best) is to just #ifdef the whole file outside of the plugin stanza. Similar to eg. rawSHA1_ng_fmt_plug.c but in this case checking for eg. ARCH_SIZE after including arch.h But it should be very trivial to actually fix it instead. Why does it break at all?
bsakaguchi 2026-10-14 03:25:36 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@jfoug commented on GitHub (May 19, 2015):

Why does it break at all?

The intrinsic _mm_insert_epi64 is not a valid instruction under 32 bit (tested cygwin and ubuntu 32 bit)

Also, the intrisic _mm_cvtsi64_si128 is not in 32 bit land.

But it should be very trivial to actually fix it instead.

The fix 'could' be to build our own _mm_insert_epi64 that has #ifdef for 32 bit wrapper around it.

<!-- gh-comment-id:103628408 --> @jfoug commented on GitHub (May 19, 2015): > Why does it break at all? The intrinsic _mm_insert_epi64 is not a valid instruction under 32 bit (tested cygwin and ubuntu 32 bit) Also, the intrisic _mm_cvtsi64_si128 is not in 32 bit land. > But it should be very trivial to actually fix it instead. The fix 'could' be to build our own _mm_insert_epi64 that has #ifdef for 32 bit wrapper around it.
Author
Owner

@jfoug commented on GitHub (May 19, 2015):

This patch at least allows this file to be built on 32 bit systems. It will fail however. NOTE, I think this will build properly on a < sse4.1 system, but if run there, it will core.

$ git diff gost3411-2012-sse41_plug.c
diff --git a/src/gost3411-2012-sse41_plug.c b/src/gost3411-2012-sse41_plug.c
index 97a91e0..7e16305 100644
--- a/src/gost3411-2012-sse41_plug.c
+++ b/src/gost3411-2012-sse41_plug.c
@@ -22,6 +22,15 @@
 #include "gost3411-tables.h"
 #include "gost3411-2012-sse41.h"

+#include "arch.h"
+
+#if ARCH_BITS==32
+// this is NOT right, but at least it allows 32 bit to build.
+// NOTE, this file depends upon SSE4.1, so it should NOT be a *plug.c
+static inline __m128i _mm_cvtsi64_si128(uint64_t b) { __m128i a; return a; }
+static inline __m128i _mm_insert_epi64(__m128i a, uint64_t b, int c) { return a; }
+#endif
+
 static inline void add512(const union uint512_u* x, const union uint512_u* y, union uint512_u* r)
 {
        uint_fast8_t i, CF;

<!-- gh-comment-id:103643364 --> @jfoug commented on GitHub (May 19, 2015): This patch at least allows this file to be built on 32 bit systems. It will fail however. NOTE, I think this will build properly on a < sse4.1 system, but if run there, it will core. ``` diff $ git diff gost3411-2012-sse41_plug.c diff --git a/src/gost3411-2012-sse41_plug.c b/src/gost3411-2012-sse41_plug.c index 97a91e0..7e16305 100644 --- a/src/gost3411-2012-sse41_plug.c +++ b/src/gost3411-2012-sse41_plug.c @@ -22,6 +22,15 @@ #include "gost3411-tables.h" #include "gost3411-2012-sse41.h" +#include "arch.h" + +#if ARCH_BITS==32 +// this is NOT right, but at least it allows 32 bit to build. +// NOTE, this file depends upon SSE4.1, so it should NOT be a *plug.c +static inline __m128i _mm_cvtsi64_si128(uint64_t b) { __m128i a; return a; } +static inline __m128i _mm_insert_epi64(__m128i a, uint64_t b, int c) { return a; } +#endif + static inline void add512(const union uint512_u* x, const union uint512_u* y, union uint512_u* r) { uint_fast8_t i, CF; ```
Author
Owner

@magnumripper commented on GitHub (May 19, 2015):

NOTE, this file depends upon SSE4.1, so it should NOT be a *plug.c

Plugs can easily depend on things like SSE4.1. Look at rawSHA1_ng_fmt_plug.c just before plugin stanza.

<!-- gh-comment-id:103648938 --> @magnumripper commented on GitHub (May 19, 2015): > NOTE, this file depends upon SSE4.1, so it should NOT be a *plug.c Plugs can easily depend on things like SSE4.1. Look at rawSHA1_ng_fmt_plug.c just before plugin stanza.
Author
Owner

@magnumripper commented on GitHub (May 19, 2015):

Should be easy to write proper (albeit slow) emulation functions though. With some luck we may already have something usable in pseudo-intrinsics.c

<!-- gh-comment-id:103649446 --> @magnumripper commented on GitHub (May 19, 2015): Should be easy to write proper (albeit slow) emulation functions though. With some luck we may already have something usable in pseudo-intrinsics.c
Author
Owner

@magnumripper commented on GitHub (May 19, 2015):

This is proper emulation (works fine):

static inline __m128i _mm_cvtsi64_si128(long long a) {
    return _mm_set_epi32(0, 0, (unsigned int)(a >> 32), (unsigned int)a);
}

static inline __m128i _mm_insert_epi64(__m128i a, uint64_t b, int c) {
    c <<= 1;
    a = _mm_insert_epi32(a, (unsigned int)b, c);
    return _mm_insert_epi32(a, (unsigned int)(b >> 32), c + 1);
}
<!-- gh-comment-id:103680674 --> @magnumripper commented on GitHub (May 19, 2015): This is proper emulation (works fine): ``` C static inline __m128i _mm_cvtsi64_si128(long long a) { return _mm_set_epi32(0, 0, (unsigned int)(a >> 32), (unsigned int)a); } static inline __m128i _mm_insert_epi64(__m128i a, uint64_t b, int c) { c <<= 1; a = _mm_insert_epi32(a, (unsigned int)b, c); return _mm_insert_epi32(a, (unsigned int)(b >> 32), c + 1); } ```
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#837
No description provided.