DCIT / perl-CryptX

https://metacpan.org/pod/CryptX
Other
35 stars 23 forks source link

libcryptx-perl: t/sshkey.t fails on some architectures #111

Closed gregoa closed 1 month ago

gregoa commented 1 month ago

We have the following bug reported to the Debian package of CryptX, c.f. https://bugs.debian.org/1082952

It doesn't seem to be a bug in the packaging, so you may want to take a look. Thanks!

------8<-----------8<-----------8<-----------8<-----------8<-----

Source: libcryptx-perl
Version: 0.081-1
Severity: serious
Tags: upstream ftbfs
Justification: fails to build from source (but built successfully in the past)

0.081-1 has test failures on some architectures (s390x, ppc64,
sparc64, x32):
https://buildd.debian.org/status/package.php?p=libcryptx-perl

At least for the first three the failure is the same:

FATAL: pem_decode_openssh failed: Invalid argument provided. at t/sshkey.t line 129.
t/sshkey.t .......................... 
1..756
ok 1 - RSA new
ok 2 - ECC new
ok 3 - DSA new
ok 4 - ssh_rsa_1024/ssh_rsa_1024_pkcs8/e
ok 5 - ssh_rsa_1024/ssh_rsa_1024_pkcs8/N
ok 6 - ssh_rsa_1024/ssh_rsa_1024_pkcs8/is_private
ok 7 - ssh_rsa_1024/ssh_rsa_1024_pkcs8/d
ok 8 - ssh_rsa_1024/ssh_rsa_1024_pkcs8/p
ok 9 - ssh_rsa_1024/ssh_rsa_1024_pkcs8/q
ok 10 - ssh_rsa_1024/ssh_rsa_1024_pkcs8/qP
ok 11 - ssh_rsa_1024/ssh_rsa_1024_pkcs8/dP
ok 12 - ssh_rsa_1024/ssh_rsa_1024_pkcs8/dQ
ok 13 - ssh_rsa_1024/ssh_rsa_1024_pkcs8_pw/e
ok 14 - ssh_rsa_1024/ssh_rsa_1024_pkcs8_pw/N
ok 15 - ssh_rsa_1024/ssh_rsa_1024_pkcs8_pw/is_private
ok 16 - ssh_rsa_1024/ssh_rsa_1024_pkcs8_pw/d
ok 17 - ssh_rsa_1024/ssh_rsa_1024_pkcs8_pw/p
ok 18 - ssh_rsa_1024/ssh_rsa_1024_pkcs8_pw/q
ok 19 - ssh_rsa_1024/ssh_rsa_1024_pkcs8_pw/qP
ok 20 - ssh_rsa_1024/ssh_rsa_1024_pkcs8_pw/dP
ok 21 - ssh_rsa_1024/ssh_rsa_1024_pkcs8_pw/dQ
ok 22 - ssh_rsa_1024/ssh_rsa_1024_pkcs8.pub/e
ok 23 - ssh_rsa_1024/ssh_rsa_1024_pkcs8.pub/N
ok 24 - ssh_rsa_1024/ssh_rsa_1024_pkcs8.pub/is_not_private
ok 25 - ssh_rsa_1024/ssh_rsa_1024_pem/e
ok 26 - ssh_rsa_1024/ssh_rsa_1024_pem/N
ok 27 - ssh_rsa_1024/ssh_rsa_1024_pem/is_private
ok 28 - ssh_rsa_1024/ssh_rsa_1024_pem/d
ok 29 - ssh_rsa_1024/ssh_rsa_1024_pem/p
ok 30 - ssh_rsa_1024/ssh_rsa_1024_pem/q
ok 31 - ssh_rsa_1024/ssh_rsa_1024_pem/qP
ok 32 - ssh_rsa_1024/ssh_rsa_1024_pem/dP
ok 33 - ssh_rsa_1024/ssh_rsa_1024_pem/dQ
ok 34 - ssh_rsa_1024/ssh_rsa_1024_pem_pw/e
ok 35 - ssh_rsa_1024/ssh_rsa_1024_pem_pw/N
ok 36 - ssh_rsa_1024/ssh_rsa_1024_pem_pw/is_private
ok 37 - ssh_rsa_1024/ssh_rsa_1024_pem_pw/d
ok 38 - ssh_rsa_1024/ssh_rsa_1024_pem_pw/p
ok 39 - ssh_rsa_1024/ssh_rsa_1024_pem_pw/q
ok 40 - ssh_rsa_1024/ssh_rsa_1024_pem_pw/qP
ok 41 - ssh_rsa_1024/ssh_rsa_1024_pem_pw/dP
ok 42 - ssh_rsa_1024/ssh_rsa_1024_pem_pw/dQ
ok 43 - ssh_rsa_1024/ssh_rsa_1024_pem.pub/e
ok 44 - ssh_rsa_1024/ssh_rsa_1024_pem.pub/N
ok 45 - ssh_rsa_1024/ssh_rsa_1024_pem.pub/is_not_private
ok 46 - ssh_rsa_1024/ssh_rsa_1024_openssh/e
ok 47 - ssh_rsa_1024/ssh_rsa_1024_openssh/N
ok 48 - ssh_rsa_1024/ssh_rsa_1024_openssh/is_private
ok 49 - ssh_rsa_1024/ssh_rsa_1024_openssh/d
ok 50 - ssh_rsa_1024/ssh_rsa_1024_openssh/p
ok 51 - ssh_rsa_1024/ssh_rsa_1024_openssh/q
ok 52 - ssh_rsa_1024/ssh_rsa_1024_openssh/qP
ok 53 - ssh_rsa_1024/ssh_rsa_1024_openssh/dP
ok 54 - ssh_rsa_1024/ssh_rsa_1024_openssh/dQ
Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 702/756 subtests 

Test Summary Report
-------------------
t/sshkey.t                        (Wstat: 65280 (exited 255) Tests: 54 Failed: 0)
  Non-zero exit status: 255
  Parse errors: Bad plan.  You planned 756 tests but ran 54.
Files=137, Tests=24533, 14 wallclock secs ( 0.77 usr  0.08 sys + 12.84 cusr  0.63 csys = 14.32 CPU)
Result: FAIL
Failed 1/137 test programs. 0/24533 subtests failed.
make[1]: *** [Makefile:1771: test_dynamic] Error 255

Cheers,
gregor

------8<-----------8<-----------8<-----------8<-----------8<-----

Thanks for considering, gregor herrmann, Debian Perl Group

karel-m commented 1 month ago

@sjaeckel it looks like we have an issue in libtomcrypt in pem_decode_openssh

Some relevant info is https://bugs.debian.org/1082952

> FATAL: pem_decode_openssh failed: Invalid argument provided. at t/sshkey.t line 129.

The first three are indeed the same bug: a 64-bit big endian issue in
the bundled libtomcrypt that was updated in 0.081. The x32 failure is
something different and I haven't looked into it.

When decrypting a bcrypt encrypted SSH key, s_decode_header() passes an
'ulong32' pointer for salt length to ssh_decode_sequence_multi() which
expects an 'unsigned long'.  On big endian 64-bit hosts, the half that
gets used is zero and bcrypt_pbkdf_openbsd() later barfs out because it
gets zero as salt length.

The code was originally introduced in libtomcrypt commit

  https://github.com/libtom/libtomcrypt/commit/fec3d45adc00332c811a84f1a8d9b1fdaa303a3d

and it is not present in the 1.18.2 release that Debian uses.

I'm attaching a proposed patch. This makes the test suite pass
for me on s390x, amd64 and i386. Eyeballs would be welcome,
please don't assume that I know what I'm doing.

Hope this helps,
-- 
Niko Tyni   ntyni@debian.org
karel-m commented 1 month ago

@gregoa could you please try CryptX-0.081_001?

gregoa commented 1 month ago

(Sorry for the delay, I was travelling in the past days.)

I've now tried 0.081_001 on the Debian s390x porterbox, and I can confirm that all tests, including the previously failing t/sshkey.t, pass.

Cheers, gregor

karel-m commented 1 month ago

fixed in CryptX-0.082

gregoa commented 1 month ago

On Mon, 07 Oct 2024 06:47:51 -0700, karel-m wrote:

fixed in CryptX-0.082

Thanks!

Uploaded to Debian, the logs from the various build daemons will appear shortly at https://buildd.debian.org/status/package.php?p=libcryptx-perl.

Cheers, gregor

-- .''. https://info.comodo.priv.at -- Debian Developer https://www.debian.org : :' : OpenPGP fingerprint D1E1 316E 93A7 60A8 104D 85FA BB3A 6801 8649 AA06 . ' Member VIBE!AT & SPI Inc. -- Supporter Free Software Foundation Europe -