Subject: | Crypt::SEAL2 tests do not pass on 64bit systems |
Compiling Crypt::SEAL2 works on 64 bit systems, but fails tests:
sizeof(long) gets 8 bytes on my system:
intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
in 64 bit, but when using a 32bit compiler I get 4. Changing all the
unsigned longs to unsigned int passes the test. Patch attached, although
I have don't know the consequences of long->int, it seems works for me.
$ make
cp SEAL2.pm blib/lib/Crypt/SEAL2.pm
/usr/bin/perl /usr/share/perl/5.10/ExtUtils/xsubpp -typemap
/usr/share/perl/5.10/ExtUtils/typemap -typemap typemap SEAL2.xs >
SEAL2.xsc && mv SEAL2.xsc SEAL2.c
cc -c -I. -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing
-pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64 -O2 -g -DVERSION=\"1.0.4\"
-DXS_VERSION=\"1.0.4\" -fPIC "-I/usr/lib/perl/5.10/CORE" SEAL2.c
In file included from SEAL2.xs:4:
ppport.h:227:1: warning: "PERL_UNUSED_DECL" redefined
In file included from SEAL2.xs:2:
/usr/lib/perl/5.10/CORE/perl.h:330:1: warning: this is the location of
the previous definition
Running Mkbootstrap for Crypt::SEAL2 ()
chmod 644 SEAL2.bs
rm -f blib/arch/auto/Crypt/SEAL2/SEAL2.so
cc -shared -O2 -g -L/usr/local/lib -fstack-protector SEAL2.o -o
blib/arch/auto/Crypt/SEAL2/SEAL2.so \
\
chmod 755 blib/arch/auto/Crypt/SEAL2/SEAL2.so
cp SEAL2.bs blib/arch/auto/Crypt/SEAL2/SEAL2.bs
chmod 644 blib/arch/auto/Crypt/SEAL2/SEAL2.bs
Manifying blib/man3/Crypt::SEAL2.3pm
$ make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e"
"test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/01.t .. ok
t/02.t .. 1/2
# Failed test at t/02.t line 15.
# got:
'd98acb4a472bbce09c17102661a384f6be3024c625a100fb05b2e6ff4618'
# expected:
'9b9d91aca7fdfc8faf01d8e3c67df7a6d8073b6a44f2e6e09d11ee63077d'
# Looks like you failed 1 test of 2.
t/02.t .. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/2 subtests
t/03.t .. 1/2
# Failed test at t/03.t line 15.
# got:
'000000000000000000000000000000000000000000000000000000000000'
# expected:
'29785cd6e2b43d10d2dbd161629cfe6e0143deb190425c081611b4e92d07'
# Looks like you failed 1 test of 2.
t/03.t .. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/2 subtests
Test Summary Report
-------------------
t/02.t (Wstat: 256 Tests: 2 Failed: 1)
Failed test: 2
Non-zero exit status: 1
t/03.t (Wstat: 256 Tests: 2 Failed: 1)
Failed test: 2
Non-zero exit status: 1
Files=3, Tests=5, 1 wallclock secs ( 0.02 usr 0.01 sys + 0.28 cusr
0.01 csys = 0.32 CPU)
Result: FAIL
Failed 2/3 test programs. 2/5 subtests failed.
make: *** [test_dynamic] Error 1
Subject: | crypt-seal2-long-to-int.diff |
--- _seal2.c.orig 2010-11-16 12:18:42.000000000 -0500
+++ _seal2.c 2010-11-16 12:18:45.000000000 -0500
@@ -6,11 +6,11 @@
#define WORDS_PER_SEAL2_CALL 1024
typedef struct seal_ctx {
- unsigned long t[520]; /* 512 rounded up to a multiple of 5 + 5 */
- unsigned long s[265]; /* 256 rounded up to a multiple of 5 + 5 */
- unsigned long r[20]; /* 16 rounded up to multiple of 5 */
- unsigned long counter; /* 32-bit synch value. */
- unsigned long ks_buf[WORDS_PER_SEAL2_CALL];
+ unsigned int t[520]; /* 512 rounded up to a multiple of 5 + 5 */
+ unsigned int s[265]; /* 256 rounded up to a multiple of 5 + 5 */
+ unsigned int r[20]; /* 16 rounded up to multiple of 5 */
+ unsigned int counter; /* 32-bit synch value. */
+ unsigned int ks_buf[WORDS_PER_SEAL2_CALL];
int ks_pos;
} seal_ctx;
@@ -28,9 +28,9 @@
#define F3(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
#define F4(x, y, z) ((x) ^ (y) ^ (z))
-int g(unsigned char *in, int i, unsigned long *h)
+int g(unsigned char *in, int i, unsigned int *h)
{
- unsigned long h0, h1, h2, h3, h4, a, b, c, d, e, temp, w[80];
+ unsigned int h0, h1, h2, h3, h4, a, b, c, d, e, temp, w[80];
unsigned char *kp;
kp = in;
@@ -75,7 +75,7 @@
int seal_init( seal_ctx *result, unsigned char *key )
{
int i;
- unsigned long h[5];
+ unsigned int h[5];
for (i = 0; i < 510; i += 5)
g(key, i/5, &(result->t[i]));
@@ -119,10 +119,10 @@
return (ALG_OK);
}
-int seal(seal_ctx *key, unsigned long in, unsigned long *out)
+int seal(seal_ctx *key, unsigned int in, unsigned int *out)
{
int i, j, l;
- unsigned long a, b, c, d, n1, n2, n3, n4, *wp;
+ unsigned int a, b, c, d, n1, n2, n3, n4, *wp;
unsigned short p, q;
wp = out;
@@ -260,14 +260,14 @@
seal_encrypt(c, data_ptr, w, data2_ptr);
}
-void seal_resynch(seal_ctx *c, unsigned long synch_word)
+void seal_resynch(seal_ctx *c, unsigned int synch_word)
{
c->counter = synch_word;
c->ks_pos = WORDS_PER_SEAL2_CALL;
}
/* added by jcd */
-void seal_repos(seal_ctx *c, unsigned long pos)
+void seal_repos(seal_ctx *c, unsigned int pos)
{
c->ks_pos = pos;
}
@@ -279,7 +279,7 @@
unsigned char plain1[COUNT], plain2[COUNT], ciphertext[COUNT];
int i, flag;
int j;
- unsigned long temp, temp1;
+ unsigned int temp, temp1;
unsigned char key[20] = {
0x67, 0x45, 0x23, 0x01, 0xef, 0xcd, 0xab, 0x89, 0x98, 0xba,