Index | Thread | Search

From:
Stuart Henderson <stu@spacehopper.org>
Subject:
opensc vs llvm22 on i386 (DES_LONG)
To:
Klemens Nanni <kn@openbsd.org>, Theo Buehler <tb@openbsd.org>
Cc:
ports <ports@openbsd.org>
Date:
Mon, 8 Jun 2026 22:45:23 +0100

Download raw body.

Thread
opensc builds ok on 64-bit archs with llvm22, but fails on i386:

> security/opensc
cc -DHAVE_CONFIG_H -I. -I../.. -I../../src -I../../src/include -I/usr/local/include/PCSC -Wall -Wextra -Wno-unused-parameter -Werror -Wstrict-aliasing=2 -O2 -pipe -Wno-error -MT libsm_la-sm-common.lo -MD -MP -MF .deps/libsm_la-sm-common.Tpo -c sm-common.c -fPIC -DPIC -o .libs/libsm_la-sm-common.o
sm-common.c:163:16: error: incompatible pointer types passing 'unsigned int *' to parameter of type 'unsigned long *' [-Wincompatible-pointer-types]
  163 |                 DES_encrypt1((unsigned int *)tin, &ks, DES_ENCRYPT);
      |                              ^~~~~~~~~~~~~~~~~~~
/usr/include/openssl/des.h:145:29: note: passing argument to parameter 'data' here
  145 | void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc);
      |                             ^
sm-common.c:177:15: error: incompatible pointer types passing 'unsigned int *' to parameter of type 'unsigned long *' [-Wincompatible-pointer-types]
  177 |         DES_encrypt3((unsigned int *)tin, &ks, &ks2, &ks);
      |                      ^~~~~~~~~~~~~~~~~~~
/usr/include/openssl/des.h:155:29: note: passing argument to parameter 'data' here
  155 | void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1,
      |                             ^
sm-common.c:304:16: error: incompatible pointer types passing 'unsigned int *' to parameter of type 'unsigned long *' [-Wincompatible-pointer-types]
  304 |                 DES_encrypt3((unsigned int *)tin, &ks, &ks2, &ks);
      |                              ^~~~~~~~~~~~~~~~~~~
/usr/include/openssl/des.h:155:29: note: passing argument to parameter 'data' here
  155 | void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1,
      |                             ^

helpfully, DES_LONG is an unsigned long on i386, but an unsigned int
on other archs:

/usr/include/openssl/des.h:
 64 #ifndef DES_LONG
 65 /* XXX - typedef to unsigned int everywhere. */
 66 #ifdef __i386__
 67 #define DES_LONG unsigned long
 68 #else
 69 #define DES_LONG unsigned int
 70 #endif
 71 #endif

is this an appropriate fix for now?

Index: patches/patch-src_sm_sm-common_c
===================================================================
RCS file: patches/patch-src_sm_sm-common_c
diff -N patches/patch-src_sm_sm-common_c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_sm_sm-common_c	8 Jun 2026 21:43:11 -0000
@@ -0,0 +1,48 @@
+Index: src/sm/sm-common.c
+--- src/sm/sm-common.c.orig
++++ src/sm/sm-common.c
+@@ -137,7 +137,7 @@ DES_cbc_cksum_3des_emv96(struct sc_context *ctx,
+ 	const unsigned char *iv = &(*ivec)[0];
+ #if OPENSSL_VERSION_NUMBER < 0x30000000L
+ 	register unsigned int tout0,tout1,tin0,tin1;
+-	unsigned int tin[2];
++	DES_LONG tin[2];
+ 	sm_des_cblock kk, k2;
+ 	DES_key_schedule ks,ks2;
+ 
+@@ -160,7 +160,7 @@ DES_cbc_cksum_3des_emv96(struct sc_context *ctx,
+ 
+ 		tin0^=tout0; tin[0]=tin0;
+ 		tin1^=tout1; tin[1]=tin1;
+-		DES_encrypt1((unsigned int *)tin, &ks, DES_ENCRYPT);
++		DES_encrypt1((DES_LONG *)tin, &ks, DES_ENCRYPT);
+ 		tout0=tin[0];
+ 		tout1=tin[1];
+ 	}
+@@ -174,7 +174,7 @@ DES_cbc_cksum_3des_emv96(struct sc_context *ctx,
+ 
+ 	tin0^=tout0; tin[0]=tin0;
+ 	tin1^=tout1; tin[1]=tin1;
+-	DES_encrypt3((unsigned int *)tin, &ks, &ks2, &ks);
++	DES_encrypt3((DES_LONG *)tin, &ks, &ks2, &ks);
+ 	tout1=tin[1];
+ 	if (out != NULL)
+ 		{
+@@ -277,7 +277,7 @@ DES_cbc_cksum_3des(struct sc_context *ctx,
+ 	const unsigned char *iv = &(*ivec)[0];
+ #if OPENSSL_VERSION_NUMBER < 0x30000000L
+ 	register unsigned int tout0,tout1,tin0,tin1;
+-	unsigned int tin[2];
++	DES_LONG tin[2];
+ 	sm_des_cblock kk, k2;
+ 	DES_key_schedule ks,ks2;
+ 
+@@ -301,7 +301,7 @@ DES_cbc_cksum_3des(struct sc_context *ctx,
+ 
+ 		tin0^=tout0; tin[0]=tin0;
+ 		tin1^=tout1; tin[1]=tin1;
+-		DES_encrypt3((unsigned int *)tin, &ks, &ks2, &ks);
++		DES_encrypt3((DES_LONG *)tin, &ks, &ks2, &ks);
+ 		/* fix 15/10/91 eay - thanks to keithr@sco.COM */
+ 		tout0=tin[0];
+ 		tout1=tin[1];