starfive-tech / VisionFive2

445 stars 79 forks source link

Linux Kernel Crypto API produces garbage for AES #25

Open gpshead opened 1 year ago

gpshead commented 1 year ago

Steps to reproduce

  1. Install a system with Debian using the (currently latest available) starfive-jh7110-VF2_515_v2.5.0-69.img image linked to from https://debian.starfivetech.com/ & set the system up with build tools. then do:
mkdir repro-bad-aes && cd repro-bad-aes
git clone https://github.com/python/cpython -b 3.11
mkdir build && cd build
../cpython/configure && make -j4
./python -m test -v test_socket -m '*LinuxKernelCrypto*'

Failures

======================================================================
FAIL: test_aead_aes_gcm (test.test_socket.LinuxKernelCryptoAPI.test_aead_aes_gcm)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "../cpython/Lib/test/test_socket.py", line 6507, in test_aead_aes_gcm
    self.assertEqual(expected_ct, res[assoclen:-taglen])
AssertionError: b'\x93\xfe}\x9e\x9b\xfd\x104\x8aV\x06\xe5\xca\xfasT' != b'^\xcb\x8e3\x7f\xd2wN\xc2W\xccH\xe6\xa1T\x0e'

======================================================================
FAIL: test_aes_cbc (test.test_socket.LinuxKernelCryptoAPI.test_aes_cbc)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "../cpython/Lib/test/test_socket.py", line 6451, in test_aes_cbc
    self.assertEqual(op.recv(msglen), msg)
AssertionError: b'\x06\x8c\x86gk\x0b@0\xbdt^\xfa\xed\xb4:\xa7' != b'Single block msg'

The other LinuxKernelCryptoAPI tests pass, it seems to be the ones attempting to use AES that produce garbage.

$ uname -a
Linux starfive 5.15.0-starfive #1 SMP Mon Dec 19 07:56:37 EST 2022 riscv64 GNU/Linux