* [PATCH 1/3] crypto: testmgr - Add Adiantum vectors with a partial last ChaCha block
2026-11-30 5:55 [PATCH 0/3] crypto: adiantum - Use the ChaCha library Laveesh Bansal
@ 2026-11-30 5:55 ` Laveesh Bansal
2026-11-30 5:55 ` [PATCH 2/3] crypto: adiantum - Derive the subkeys with the ChaCha library Laveesh Bansal
2026-11-30 5:55 ` [PATCH 3/3] crypto: adiantum - Use the ChaCha library for the stream cipher Laveesh Bansal
2 siblings, 0 replies; 6+ messages in thread
From: Laveesh Bansal @ 2026-11-30 5:55 UTC (permalink / raw)
To: Eric Biggers; +Cc: Herbert Xu, David S. Miller, linux-crypto, linux-kernel
None of the existing adiantum vectors has full ChaCha blocks
followed by a partial one. testmgr does not have any other
implementation to compare adiantum against.
Add new 145 and 1041-byte vectors. These end in a 1-byte partial
block after full blocks.
They were generated with the Python reference implementation from
https://github.com/google/adiantum and then formatted with a script.
Signed-off-by: Laveesh Bansal <laveeshb@laveeshbansal.com>
---
Notes:
I tested this patch on arm64 with KASAN, lockdep and CRYPTO_SELFTESTS
enabled. I applied the setkey and aeslib patches first (in that order).
The selftests passed for both xchacha12 and xchacha20.
I also verified that the new test vector failed when I changed
one byte of the 1041-byte ciphertext for both algorithms.
crypto/testmgr.h | 644 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 644 insertions(+)
diff --git a/crypto/testmgr.h b/crypto/testmgr.h
index 14b0e1181b7b3..8635a388eb679 100644
--- a/crypto/testmgr.h
+++ b/crypto/testmgr.h
@@ -31786,6 +31786,328 @@ static const struct cipher_testvec adiantum_xchacha12_aes_tv_template[] = {
"\x60\x1f\x88\xae\xbf\x14\x2d\x05"
"\x4c\x60\x85\x8a\x45\xac\x0f\xc2",
.len = 4096,
+ }, {
+ .key = "\x13\x40\x42\xb6\xab\xb3\x70\x17"
+ "\x03\xcf\x23\x3d\x9a\xb8\xed\x7b"
+ "\xd6\xcd\x7d\x9a\x32\x01\xdd\x57"
+ "\x0c\x10\x04\xff\x50\x7e\x78\x73",
+ .klen = 32,
+ .iv = "\xa8\x55\x16\x03\xc9\xc5\x60\x22"
+ "\xe7\xb4\x4a\x0b\xe8\x3d\xb8\x2b"
+ "\xc1\x03\xa7\xe2\x54\x0d\x90\xab"
+ "\x79\xc7\x41\x6d\xef\x54\xf1\xac",
+ .ptext = "\x06\xda\x37\x95\x43\xd2\xc6\xb0"
+ "\x4e\x39\xc4\xed\x21\x41\xa4\x02"
+ "\x43\x22\x42\x90\x9c\x47\x9d\x6d"
+ "\x05\xfe\xc7\xe8\x59\x55\xe2\x87"
+ "\x11\x25\xb5\x20\x2c\x76\x6d\xdc"
+ "\xb9\x1f\xc8\x72\x6d\x69\xd0\xb6"
+ "\x7e\xe4\xd8\x34\xf6\x9a\x7d\xb3"
+ "\x2b\xed\x91\xef\x61\xf4\x6c\x80"
+ "\x0e\x2c\x22\xc7\x01\xd5\xdf\x7f"
+ "\x8f\xd9\xb0\xaf\x56\x8b\x5a\x0b"
+ "\x38\x0f\xc9\xac\x7f\x1d\x28\x3e"
+ "\x3a\xd4\xd1\xd1\x5b\x43\x54\x83"
+ "\x1d\xe9\xbf\x28\x02\x49\x42\x65"
+ "\x34\xb7\x1f\x26\x0c\x15\xa2\xcb"
+ "\xac\x14\x30\x0c\x8a\x19\x03\x10"
+ "\xd6\x24\xf6\x3e\x3d\xab\x6c\x0e"
+ "\x24\x31\xcb\xb8\x70\xe2\xfc\xc1"
+ "\x90\x7e\xba\x74\x01\x24\xbe\x3f"
+ "\x5f",
+ .ctext = "\x61\xbe\x4c\xab\xae\x40\x15\x7f"
+ "\x15\x7f\x50\x34\xa7\xd8\xc2\x36"
+ "\x7c\xea\x41\xd9\x4e\x62\xf4\x5c"
+ "\xf4\x0d\x24\x5b\x23\x28\xbc\x3b"
+ "\x41\xe7\x70\xa1\x2a\xbe\xbf\xef"
+ "\xbe\x2a\x66\xa4\xcc\x9e\x16\x66"
+ "\xb2\x5a\x61\x8f\x22\xba\xce\x2f"
+ "\x87\x4d\xec\xaf\x56\x99\x88\x51"
+ "\x9a\x72\x45\xc3\x1f\x88\x37\x30"
+ "\x79\xf6\xac\x40\x68\x7d\x5f\x4a"
+ "\x93\x0a\x5b\x7a\xd4\xac\x34\xb4"
+ "\xb8\xc1\xf0\x85\x9c\x5c\x1e\x52"
+ "\x03\xfc\x55\x6b\x32\xb1\x90\x8f"
+ "\x53\x38\xdc\x9f\x30\x0e\x70\x61"
+ "\x5f\x1b\x86\x96\xe1\xfd\xd4\xf9"
+ "\xb5\x06\xfe\x1d\x97\xf5\xcb\x81"
+ "\xd1\xa8\xa8\x5d\xff\xa7\x55\xf2"
+ "\x39\xa3\x8a\x5f\xe2\xcd\x59\x9e"
+ "\xd1",
+ .len = 145,
+ }, {
+ .key = "\x7e\xbb\xdf\xf8\xce\x25\x3a\xf4"
+ "\x2c\xfa\x58\xbb\x2f\xcd\x24\x28"
+ "\xd0\x6f\xcf\xb3\x1a\x7b\x3c\xdf"
+ "\x8a\xa7\x5f\xbc\xa5\x0c\xe6\x65",
+ .klen = 32,
+ .iv = "\x92\xbb\xac\x2a\xcc\x86\x0a\xbe"
+ "\x6b\x55\x12\xbf\x23\x41\x02\xd5"
+ "\x35\xfe\x5f\xde\x90\x67\x9a\xce"
+ "\x15\x45\x56\xa6\xd3\xf7\x3c\x0e",
+ .ptext = "\x4e\x9b\xa2\x32\x92\x00\x4e\xd6"
+ "\x23\x47\x73\x80\xde\x09\x22\x3c"
+ "\x67\x0a\xce\xdb\xa7\xb8\xb9\xdf"
+ "\x9d\x05\x50\x7f\x83\xac\x1c\xf2"
+ "\x80\x1e\x72\x0c\xa1\x65\xc7\x04"
+ "\x51\xcc\x76\xd6\x89\x94\x53\x9c"
+ "\xc1\x1d\x45\x55\xde\xf0\x84\x94"
+ "\x5d\x95\xdf\x81\x90\xb3\x20\x95"
+ "\xb2\x41\x36\x54\xa7\x7f\x8a\x1c"
+ "\x50\xcf\x82\x46\x42\xed\x34\x48"
+ "\x38\x26\x31\x28\xf4\x48\xf8\x3f"
+ "\xe8\x3b\x78\xef\x96\xac\xd1\x15"
+ "\x0f\xca\xee\x85\xc9\xc0\xb5\xba"
+ "\xaf\xe7\x40\xef\x25\x2e\xc7\xdb"
+ "\xb3\x5f\x54\x57\x0a\x1c\x64\x51"
+ "\x31\x7a\x22\x6c\x39\x8b\xcb\xe1"
+ "\xf6\x32\xdd\x24\x5d\xe6\x58\x0e"
+ "\x69\x47\xdc\x2b\xad\x13\x9e\x10"
+ "\xcb\x41\xc4\xca\x16\xaf\xdc\x32"
+ "\x7d\x26\x70\xc7\x20\xa2\x3e\xa7"
+ "\x49\xdf\xef\xc0\x90\x8b\x9e\x4c"
+ "\x06\xd5\x17\x41\x5f\xe8\xa5\xe8"
+ "\x73\xef\xda\x5b\xe9\xe1\x28\x87"
+ "\xc7\x92\x39\xbc\xe6\x9f\xc2\x07"
+ "\xfe\x3f\xf1\x1e\xc0\x94\x00\xbe"
+ "\xe3\x10\xee\xe0\x11\x23\x40\x30"
+ "\xfc\x47\xff\x2a\x1d\xdf\x35\x74"
+ "\xd8\x37\x07\xd1\xd3\x64\x7f\xb2"
+ "\xaa\xe8\xb5\x5d\xe1\xb8\x29\x53"
+ "\xc4\xc6\xfd\xd9\x23\xa5\x2b\xac"
+ "\x8d\x60\xf2\x1f\x73\x11\x57\x8b"
+ "\x2d\x04\xf4\x48\xb0\x28\xd3\xbc"
+ "\x65\x45\x49\xe6\xb4\x9d\x5f\x77"
+ "\xc5\x5b\xdd\x25\xd3\x79\x09\x2d"
+ "\x33\x07\x65\xa9\xbf\xa6\x72\x76"
+ "\x27\xb7\xcf\x1c\xb1\x1f\x9f\x9c"
+ "\x42\x04\x55\x31\xa3\xa8\xb8\x2c"
+ "\x1f\x45\x2c\xa0\xae\x02\x8c\x5f"
+ "\x66\x7e\x6a\x76\xe3\xb1\xb4\xe3"
+ "\x65\xb5\x35\xe1\x17\x7e\xf2\x09"
+ "\xa9\x4f\x13\x1b\x02\x07\xbf\xaf"
+ "\x78\xc8\x89\xde\xb5\xa0\x00\x55"
+ "\xcd\x44\x9c\x17\x39\x3e\x68\xb5"
+ "\xee\x28\x6a\x06\x55\xcd\x35\xa7"
+ "\x4c\x5b\xbc\xa9\xcc\x01\x62\xf3"
+ "\x00\x0b\xc9\xd8\xc8\xa3\x9a\x47"
+ "\xea\x50\xae\xc1\x79\x46\xae\x11"
+ "\x0e\x48\x01\x9f\xf4\x13\xd3\x22"
+ "\x6b\xc9\x30\x99\x3f\xd9\x8b\x49"
+ "\x53\x76\xb6\x88\x40\x99\xf2\x9f"
+ "\x72\xbb\x8a\x71\xea\xce\x87\xe6"
+ "\x7b\x3d\xed\x21\x91\x84\x60\x4f"
+ "\xe2\x5d\x92\x9a\xa0\xc6\x20\x8a"
+ "\xc2\xda\x4d\x46\xec\xf0\x68\xb3"
+ "\xe8\x86\xbb\xc7\x81\x6d\x28\xc1"
+ "\x22\xcd\x90\xaf\x24\x54\x9e\x99"
+ "\xc1\x18\xcb\xd4\x82\x90\x42\xa0"
+ "\xeb\x96\x0b\x0a\x59\x0e\xb8\x42"
+ "\x32\xfe\xc3\xd1\xc9\x99\x48\x49"
+ "\xe3\x15\x5b\x3e\xd5\x04\xd7\xaa"
+ "\xb0\xc9\x14\x29\x48\xa8\x9d\x3f"
+ "\xf6\x53\xd7\xc0\xdc\x89\x27\xc7"
+ "\x5e\xbe\xb3\x25\x96\xfb\x23\x7d"
+ "\x54\x11\x13\x8c\x02\xf4\xf0\xe5"
+ "\xea\x74\x4d\x80\x12\x3f\x15\x35"
+ "\x16\x34\x86\x69\xff\xd4\xdd\xf0"
+ "\x23\xe7\x3b\x1c\xff\xde\xe5\x41"
+ "\x6b\xef\x15\x85\x43\xa5\x06\x8d"
+ "\x2b\x0a\xe2\x08\x54\xbf\x43\xaa"
+ "\xbe\xd0\x7f\x1d\x1a\x48\x10\x8c"
+ "\x77\xe9\x04\x87\xc9\xa1\x46\xd9"
+ "\x51\xf5\x2f\x36\x54\xc3\x03\x90"
+ "\x80\x30\x40\x45\x79\x31\xf6\xc2"
+ "\x34\x9d\x8d\x91\x4b\x1a\xa7\x95"
+ "\x3a\xdb\xd4\x87\x98\x37\x1d\xe5"
+ "\x39\x20\xbb\x33\xfd\x52\x99\x4a"
+ "\x1a\x27\x39\x64\x6c\x52\xb5\x88"
+ "\xf5\xd0\x32\x61\xbf\xae\x1c\xdf"
+ "\x2e\x1b\x8d\x92\x40\x8a\xc9\x35"
+ "\x63\xd1\x8e\xca\xce\xea\xd9\xfb"
+ "\x67\xe7\x9a\xd5\xae\x8e\x2e\x4a"
+ "\x39\x44\x70\xcc\xf0\x42\x07\x91"
+ "\x22\xad\x20\x0f\x9b\xc1\x6d\x8e"
+ "\x32\x43\xf2\x48\xe4\x24\x76\x78"
+ "\x87\x95\x2d\x68\xea\xa1\x00\x15"
+ "\xc8\x50\x7d\x6c\xc1\x1f\x79\x9f"
+ "\xda\xd2\xf1\xc5\x07\xa8\x3e\x63"
+ "\x5e\x49\x1c\xa1\xa3\xb1\x8b\x5d"
+ "\xb2\xd5\xe3\x96\x5f\x14\x1a\xa5"
+ "\xb7\x9a\x87\x52\x60\x2b\x7f\xd1"
+ "\xe3\xaa\x78\xd8\xb9\xe9\xf5\xdd"
+ "\x28\xe4\xeb\x3d\x19\x5e\xeb\x2a"
+ "\x50\x58\x94\xf5\x44\x3b\xef\xc7"
+ "\x0a\xc2\xed\x59\xe5\xc1\x48\x1a"
+ "\x2c\x11\x0f\xf3\x26\x44\xf6\x8b"
+ "\xd1\x84\x78\x19\x48\xae\xd1\x6c"
+ "\xc2\x82\x42\x71\x5f\xaa\xbf\xe1"
+ "\xf6\xa2\x76\x5d\x4e\x7d\x51\x29"
+ "\xc9\x9c\x5a\x9d\x56\x57\x84\x89"
+ "\x21\x81\xe8\x5f\x99\xfd\x39\xb7"
+ "\x79\xdd\x49\x89\xc3\xe7\x5d\x6b"
+ "\x3b\x4c\x2f\x22\xcd\xa2\x7f\x00"
+ "\xce\xed\x82\x1a\x69\x8d\x84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x20\xbd"
+ "\x9e\x68\x55\x9c\xfa\xc4\x6c\x79"
+ "\x28\x49\xa3\xfe\x04\x3a\xbb\x74"
+ "\x13\x4e\x2b\x59\x1e\x97\x55\xba"
+ "\xd8\x37\xea\xfd\x73\x89\xde\xb6"
+ "\x6a\xaa\x50\x4e\x48\x43\x7a\x73"
+ "\x81\x7d\x88\x8e\xe6\xbc\x7d\xf9"
+ "\x4d\x1c\xf4\xe7\x34\xaf\x70\xcc"
+ "\x06\x68\x59\x1d\x83\x73\x78\x5f"
+ "\x43\xb8\xbd\xc1\xa7\x68\x73\xac"
+ "\x61\x73\x80\x93\x1e\x06\x9c\xc5"
+ "\x9f\xfb\xbf\x86\xed\x3e\x67\x8d"
+ "\x06\x1c\xbb\x62\xef\x4b\xe1\xa7"
+ "\x9f\x0e\x6f\xb6\x09\x00\x67\xcf"
+ "\x84\x3e\xa9\x9e\xaa\x6f\xb5\xf0"
+ "\xc9\xf9\x03\x84\x7c\x13\x45\x81"
+ "\x57\xe2\x78\x83\x78\x3d\xe9\x20"
+ "\xd0\x39\xfd\xbe\xc6\x1b\xe1\x34"
+ "\xa4\x62\x0b\x05\x12\x26\x66\x3e"
+ "\xcd\x88\x96\x25\x0c\xe9\x2e\x35"
+ "\x57\xcc\xc6\x7a\x54\x31\xdf\xa1"
+ "\x4b\xe8\x16\xd8\x13\x13\x62\x6a"
+ "\xfc\x29\x62\xe1\xbc\x2d\xb4\x75"
+ "\xe5\x1c\xa5\x0d\xe0\xbb\xf2\x63"
+ "\xd8\xd0\x78\x2d\x8c\x30\x6a\xe9"
+ "\x93\x11\x3a\x67\xc8\xca\xce\x00"
+ "\x26\x97\x03\x2a\x0d\x31\x0c\x85"
+ "\x85\x50\xda\xd2\x32\xf7\x2a\x75"
+ "\x74\x6f\x63\x5e\xb8\x8a\xe4\x62"
+ "\x05\x38\xaa\xd2\x35\xdd\xf9\x16"
+ "\xce\xf0\x6f\xcd\x90\x05\xd3\xa1"
+ "\x4e\x6c\x50\x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43"
+ "\xca\x20\x76\xe0\x4e\x1d\x98\xa5"
+ "\x0c\x18\xcb\x23\x19\x19\x36\x18"
+ "\x39\xb1\x36\xe9\x26\xba\x0e\x16"
+ "\xf1\xf1\xc9\xe1\x41\x40\xf4\xfe"
+ "\x8d\x03\x19\xce\x63\x3d\x34\x61"
+ "\x34\x3c\x3e\xf7\xb0\x28\xa2\x9f"
+ "\x1b\xa4\x52\xcd\xd6\xd3\x9e\x78"
+ "\x4e\x6b\x95\x29\x0b\x44\xd7\xf8"
+ "\x36\xb1\xe6\x11\x8f\xc8\x88\x79"
+ "\x71\xd2\x36\xe2\x49\x3d\x59\x13"
+ "\xd4\x0b\x58\x2b\xc5\x8e\xab\x67"
+ "\x4b\xd6\xa3\x48\x5f\xff\x3d\x2f"
+ "\x6f\xd9\x81\x14\x8b\xeb\x93\x0b"
+ "\xdb\x04\x02\x6f\xae\x9f\x73\xa3"
+ "\x6f\x33\x61\x8e\x0d\x44\xb8\xa0"
+ "\x06\x6f\x05\x68\xe6\x98\x3f\x8f"
+ "\xd9\x42\xf0\xe5\x71\x6a\x87\xf2"
+ "\x99\xe7\xe1\x60\x9a\x2d\xe0\x21"
+ "\x22\x64\x7d\x5c\xb2\x01\xa6\x87"
+ "\x02\xab\x8d\x85\x2e\x1d\x5f\x99"
+ "\x4d\xcb\x6a\x66\x79\x42\x54\xb7"
+ "\x08\x54\x3d\x4a\xd9\xc5\x8c\x04"
+ "\x8a\xd4\xdf\x95\x78\xf8\x5d\x6f"
+ "\x2a\x60\x1d\x0a\xf6\x1a\xae\xe6"
+ "\x59\x14\x81\xa6\x34\xc3\xdd\x87"
+ "\xdb\x71\xfc\x91\xbb\x6e\x72\x8a"
+ "\x6e\x80\xe2\x32\x8f\x6c\x6f\x30"
+ "\x39\x06\x7d\x1f\x7b\x86\xba\x23"
+ "\x45\xa4\x2d\x5f\xee\x77\x4e\x6a"
+ "\x43\x77\x9f\xcf\xe2\xba\x7d\x17"
+ "\x2f\x1f\x89\x47\xd5\xac\x95\x91"
+ "\xd9\xb9\xe3\x6b\xa7\x1e\xbb\x85"
+ "\xe0\x22\xc5\xd3\xf0\xfa\xcf\x05"
+ "\x7d\x50\x19\x78\x77\x11\x8f\xa5"
+ "\x9e\x85\xfd\x89\x79\xf3\x6f\xc8"
+ "\xc2\xd3\xda\x6f\x27\x09\x84\x64"
+ "\x04\xc3\xb1\xa9\xb3\x01\x02\x2a"
+ "\x0e\xc0\x07\x22\x48\xbf\xb8\xd1"
+ "\x05\xb4\x36\xe0\x3c\xaa\x1f\x67"
+ "\xb2\x17\x04\x98\xb8\xdb\x25\x6e"
+ "\xdc\x8c\x79\xeb\x10\xa2\x13\xc8"
+ "\x52\xa0\x85\x9b\xf8\x53\x43\x10"
+ "\x98\x92\x3e\x45\x7c\xc3\xea\x76"
+ "\xe7\xb5\x09\xe9\x63\x69\xc4\xd8"
+ "\x36\xab\xc7\x68\x24\xaf\x68\x2d"
+ "\x08\xae\x0b\x8d\x04\x30\xd0\x86"
+ "\xc2\x4e\xd9\xda\x7d\xe9\x8c\xe7"
+ "\xa0\x1f\x57\xfb\x44\xff\xbe\x87"
+ "\xee\x78\xd6\x50\x28\xd5\xce\x2c"
+ "\xc5\xac\xae\x5d\x5f\x17\x4c\xba"
+ "\x0d\x72\xc9\x53\xe4\x1d\xf2\x83"
+ "\x4c\xba\xe6\xec\xf0\x28\xea\x09"
+ "\x82\x09\xca\x87\x09\x8a\xdf\xcb"
+ "\xca\x86\x52\xb7\x4e\xdc\x6c\xef"
+ "\x70\x6d\xa6\xdb\x35\x43\x84\xbd"
+ "\xa5\x30\x11\xdc\x2d\x49\xcb\xc9"
+ "\xeb\x3f\xb7\xbb\x30\xa7\xcd\x0b"
+ "\x3b\xdc\x03\x4f\xe1\xbe\x75\xa8"
+ "\xe4\x45\x36\x73\x28\x02\xd4\x31"
+ "\x93\x0b\x64\x53\xfe\x34\xf3\x31"
+ "\x46\x14\xd3\x08\x89\x03\x62\xcd"
+ "\x51\xf0\x6f\x40\x74\x67\x8d\x1d"
+ "\x65\x91\xdf\x27\x84\x9e\x50\x04"
+ "\x35\x86\xd2\x17\x62\x76\x21\xd0"
+ "\x3b\xf8\xee\x7b\xf9\xd6\x53\x18"
+ "\x8c\xfd\xa3\x1a\x5c\x74\x34\xae"
+ "\x64",
+ .len = 1041,
}
};
@@ -33438,6 +33760,328 @@ static const struct cipher_testvec adiantum_xchacha20_aes_tv_template[] = {
"\xe9\xe1\xa0\xfe\xb2\xc3\x80\x77"
"\x20\x05\xe4\x9b\x47\x3b\xb2\xbd",
.len = 4096,
+ }, {
+ .key = "\xd7\xa8\x52\x8d\xe2\x34\xfc\x71"
+ "\xaf\x36\x65\xca\x8b\xc1\xa5\x34"
+ "\xbe\x55\x79\xbb\x43\xce\x3d\x34"
+ "\x2c\x82\x42\x53\x46\xa8\xf5\xbe",
+ .klen = 32,
+ .iv = "\x79\xe4\x92\xc7\xf4\xb0\xdc\xff"
+ "\x4c\x3f\x9d\x90\x88\x19\xa0\x89"
+ "\xd0\x80\x69\x26\xcb\xc4\x32\x44"
+ "\xba\x7a\xf7\x0b\xb8\x89\x03\x2e",
+ .ptext = "\xcb\x40\xa4\xa8\x5c\xec\x08\xcf"
+ "\xb2\xa0\xc6\x7e\xf9\x08\xfe\x1a"
+ "\xe6\x56\x72\x5a\xa1\x49\x6c\x62"
+ "\xdf\xaf\xed\xe2\xda\xa4\x80\x92"
+ "\xfd\x23\xd7\xc9\xe7\x57\x00\x22"
+ "\x41\x1d\xca\x04\xe0\xd7\x0a\x88"
+ "\x0e\x27\x78\x23\xf8\xab\x30\x44"
+ "\xf5\xf3\xa1\x52\x1e\x5f\xe0\xc4"
+ "\x04\x57\x63\x0f\xb6\x36\x95\x14"
+ "\x04\x39\xef\x52\xc8\xed\xa5\x17"
+ "\x35\x45\xed\x08\xcf\x42\x2f\x8c"
+ "\x84\x17\x96\xc5\x91\x6a\x7c\x7d"
+ "\x9e\xdc\x49\x7a\xb1\x80\xbf\xa5"
+ "\x11\x4c\x24\x11\x74\x19\x21\x46"
+ "\xdc\x8e\xf1\xa2\x5e\xba\x74\x6f"
+ "\x23\x76\xfb\x38\xb9\xa2\xb5\x49"
+ "\x27\xba\xf7\x1e\x98\x6b\x1d\x59"
+ "\x04\xcf\xc6\xd9\xbd\xfb\xf2\x59"
+ "\x0f",
+ .ctext = "\xed\x16\xaf\xbb\xc0\xdf\x40\xc4"
+ "\xe1\x48\xa2\xab\xc6\x0b\x73\x9c"
+ "\x0b\xd1\xf1\x94\x98\x47\x1b\x3d"
+ "\x1e\x2b\xef\xfd\x49\xb0\x68\xf9"
+ "\x43\x11\xe4\x4d\x09\x8b\x68\x85"
+ "\x31\x28\xd6\xdc\x54\x14\x05\x38"
+ "\x8d\x43\x49\xa1\xe4\x82\x06\x37"
+ "\xd9\xff\x48\x60\x42\x42\xd6\xc1"
+ "\x1d\x5f\x9b\x0e\x7a\xf2\x0b\x35"
+ "\x6f\x7c\x74\x5d\x40\x7d\xaf\xda"
+ "\xbd\x6f\xbf\x03\xa2\x8c\xa4\x3f"
+ "\x34\x06\xcd\xe6\x40\x61\xe4\xd4"
+ "\xc5\x54\x83\x4c\x8c\x8f\x4a\x31"
+ "\x73\xd0\x85\x34\x45\x32\xc4\x73"
+ "\xaa\xf3\x84\x1b\xf6\x39\xc0\xd7"
+ "\x51\x2f\xd1\x1f\xfa\xad\x11\xa1"
+ "\xc6\x97\x61\x87\x44\xd7\xe9\x05"
+ "\x9c\x56\x88\xa8\x3d\xd5\x89\x92"
+ "\xd4",
+ .len = 145,
+ }, {
+ .key = "\x9c\x13\x01\x95\x85\xc6\x9e\x28"
+ "\xb8\x8e\x53\x7a\x5a\x1b\x56\x07"
+ "\x52\xde\x1f\x62\xc8\xc6\x8a\x6d"
+ "\x6a\xcd\xd6\xff\xae\x61\x5a\x34",
+ .klen = 32,
+ .iv = "\xa2\x81\xcb\x52\xd0\x66\xef\x39"
+ "\x96\x80\x81\xff\x9f\x7b\x43\x59"
+ "\xf2\xbb\x0c\x6b\xae\xff\xb0\x3f"
+ "\xab\x6a\x8c\xc6\xcb\x12\x96\xe4",
+ .ptext = "\x17\x2e\xf2\x1f\x72\xcc\xed\x2f"
+ "\x8b\xaa\x52\xa5\x34\xa2\x9c\x30"
+ "\xc2\x4b\x76\xd7\xe0\xcb\xaa\x2f"
+ "\x3c\x53\x79\x44\xe8\xdd\x3f\xee"
+ "\x51\x15\xcd\x33\xaf\x16\xa2\xde"
+ "\x52\x1d\x47\x5a\x9f\xc8\xa0\x78"
+ "\xc6\x88\xe0\x90\xe6\x8a\x8c\x4b"
+ "\x39\xdf\x26\x13\x49\xfb\x89\x2e"
+ "\x69\x6e\x7a\x70\xa2\xb2\x30\x2b"
+ "\x96\x9e\xe3\xba\x54\xb0\x3a\x6c"
+ "\x16\x79\xd3\x59\xed\x31\xa3\x22"
+ "\x53\x6d\x36\x3c\x67\xe8\x7f\xbb"
+ "\x64\x6b\xb2\x9d\x63\xdf\x5d\x96"
+ "\x19\xc6\x2c\xbe\x50\x8c\x00\x1e"
+ "\x4e\x5a\x6a\x6e\x84\xa0\xda\xfd"
+ "\x8a\xb0\x63\x2e\xe3\x56\x7f\xac"
+ "\xa7\x7b\xef\x50\x20\x80\xde\xfb"
+ "\x06\x24\x81\x0c\x3f\x9e\xaf\x97"
+ "\xe5\xa9\x63\x2f\x47\x7b\x59\x9a"
+ "\x65\xe4\x66\x18\x33\xeb\xba\xf2"
+ "\xb2\x93\x72\xf7\x5f\x20\xe6\x81"
+ "\xb7\xd3\x12\x13\x1c\x1d\x7b\xb7"
+ "\x01\x5d\xed\x40\x2c\x9a\x71\x4b"
+ "\xb0\x24\x61\x60\xd0\x89\x9b\x27"
+ "\xd8\xcf\x7a\x0d\xa5\x80\x5b\x00"
+ "\xf5\xeb\xf8\x25\xfd\x24\x41\x15"
+ "\xd4\x07\x18\x24\xdb\xfa\x85\x56"
+ "\x34\x58\xf6\x99\x83\xe4\x71\x76"
+ "\xa7\xd3\x8e\xbb\x4d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 "\xcc\x49\x4b\xfa\x50\x96\xd7\x0c"
+ "\x5d\xb4\x2e\x2a\xfc\x86\x8d\xeb"
+ "\xd0\xef\x8c\xae\x56\xf5\x2b\xec"
+ "\x01\x67\x4e\xa2\x04\xd8\x5d\x7a"
+ "\x57\xfb\xba\xf5\x2a\x39\xa4\x4a"
+ "\xa7\x5a\x50\x16\x08\xed\xee\x82"
+ "\x47\x93\xf2\x60\x5f\x82\x2a\x70"
+ "\x72\x1f\x34\xfb\xfe\x74\x0b\xb6"
+ "\x66\x7a\x96\x3e\xde\x91\x66\xfc"
+ "\x73\xaa\xe1\x30\x7c\x67\x46\xca"
+ "\x88\xa2\x5d\x7f\x6e\xc2\xdc\xe4"
+ "\x5a\x73\x45\x1c\x3b\x68\x27\x1d"
+ "\x92\xe0\x9d\x00\xa5\x3c\x7c\xc9"
+ "\x5b\xaf\x28\x05\x56\xeb\x57\x1e"
+ "\x55\x82\xc9\xaf\x09\x67\x64\x45"
+ "\x0f\xf6\x98\x53\x20\x7f\x75\x07"
+ "\xcb\xd0\x2f\x83\x38\x42\xe0\xaa"
+ "\xe8\x01\xf8\xaa\xd6\xe8\xec\x06"
+ "\xb4\xbd\xde\x31\x4a\x29\x4b\xba"
+ "\x07\xb2\x61\x71\x0f\x87\xfe\x77"
+ "\x3c\xb7\xbe\xc9\x10\x02\x43\x2b"
+ "\x4a\x4e\x3c\x1f\x6c\x42\x6e\xe6"
+ "\x51\x89\xab\xe4\xe0\xec\xaa\x4f"
+ "\xcb\x8f\x06\xec\xa1\xc0\x4d\xac"
+ "\x65\xa4\xdf\x7a\xa1\xb3\x63\xcd"
+ "\x58\x8e\x93\xb1\xf8\x6a\x45\xf8"
+ "\xa4\x2d\x89\xea\x90\x8d\xa9\x54"
+ "\x17\xf6\x04\x16\xe9\x4d\xfa\xc5"
+ "\xf7\x64\x25\x75\xad\xb8\x11\x4a"
+ "\xb5\xa5\x80\xf7\x26\x94\xc8\x5a"
+ "\x09\x65\x72\x65\x73\x45\xe5\x7f"
+ "\xbc\xba\x27\xf9\x9f\x07\xb7\x3e"
+ "\x9e\x79\x90\x02\x1a\xaf\x56\x91"
+ "\x3b\xff\x0b\x34\x69\x72\xef\x7b"
+ "\xb9\x17\x5e\x87\xdf\xd8\xd0\x76"
+ "\x27\xf1\x73\x35\x68\xf1\x7b\xe7"
+ "\x75\x33\xd1\xe2\x64\x7f\xba\x1e"
+ "\x3c\x6d\xbd\xa5\xdf\xca\xe0\x88"
+ "\xfd\xc9\x98\x19\x32\x53\xdb\xad"
+ "\xa7\xf7\xba\x55\xbc\x2c\x68\x19"
+ "\xb0\x95\x29\xea\x78\x13\xe9\xee"
+ "\x0c\xdd\xc2\xf9\x8e\xa8\x3e\x4f"
+ "\x42\xca\xbd\x24\x4b\xb3\x8d\xce"
+ "\x17\x7e\xda\x2f\xc9\x30\xa7\x75"
+ "\x82\x49\x86\x39\x39\x73\x13\xb3"
+ "\xd9\xc9\x08\xe4\xcf\xe9\x93\x8a"
+ "\x1e\x5c\x58\x0d\x4a\xbb\xec\x49"
+ "\x38\xec\xc2\xab\x8a\x1b\x31\xbb"
+ "\xed\xca\xf7\xf6\xf7\xc1\x44\x19"
+ "\xd2\xca\x5c\xa9\xaa\x7a\x1c\x0f"
+ "\x86\xcd\x7d\xbe\x7d\xd6\xcf\xc4"
+ "\x99\x5f\x6b\x0a\xdb\x9c\xbe\xd7"
+ "\x65\xbe\x9e\xd0\x81\x47\xdd\x2c"
+ "\x42\x7f\xee\x16\xbd\xe4\xa3\x6d"
+ "\xf4\xcd\x5a\xfb\x90\x8d\x1a\x17"
+ "\x6a\xe7\x98\x18\xe0\x08\x86\x9c"
+ "\x34\x04\x0a\xca\xf9\xed\x65\x56"
+ "\xe4\x96\x44\xd3\x09\xea\x70\x50"
+ "\x4e\x17\x73\x49\xdf\xbe\x80\xcb"
+ "\xb9\x44\xcc\xba\x4a\xff\xdb\xc0"
+ "\x46\xe8\xc8\x07\xe0\x18\x38\xfb"
+ "\x38\xf0\x47\xee\x0d\x27\x18\x8c"
+ "\xb3\xa0\x8f\x67\x08\x46\xf7\x7c"
+ "\x24\xa1\x03\x0d\xd2\xea\x02\x50"
+ "\xce\xe3\x4f\x31\x91\x2e\xee\x70"
+ "\x4f\x2b\x77\x9b\xb6\x97\x87\x32"
+ "\x23\x56\xef\x43\xcb\xbb\x7e\xb3"
+ "\xfe\xe4\xcc\x95\x05\x24\xc5\x43"
+ "\xcc\x23\x6c\x86\x53\xc5\x8f\x6c"
+ "\x6c\x9a\xdc\x3f\x5a\x80\x47\x1a"
+ "\xa3\x13\x0e\x25\x7a\xa6\xd5\x04"
+ "\x7c",
+ .ctext = "\x9f\x88\xf5\xc9\x5f\x13\x72\xa1"
+ "\xb6\xee\xd1\x37\xde\xc7\x2e\x77"
+ "\x28\x82\x86\xfa\x56\x68\xe3\x6b"
+ "\x3b\xc3\x68\x04\x3a\x49\x36\xb5"
+ "\x47\xd9\x15\xc4\x30\x2f\x78\x58"
+ "\x5a\xb7\xdf\x89\xf7\xd9\xfc\x1a"
+ "\x5a\xd0\xd0\xd5\x1d\x61\x4d\xfe"
+ "\x6d\xae\xf2\xd8\x6d\xe2\x2f\xac"
+ "\x20\x44\xe9\x10\x25\x1f\x01\x0e"
+ "\xa4\x53\x43\xbb\xd9\xc5\xdf\x40"
+ "\xbb\xd0\x37\x39\x4a\x61\x5a\x8c"
+ "\xa0\xef\xc5\x1c\xa8\x3a\xed\xb0"
+ "\x2e\x56\xbc\x06\x73\x7e\xf1\xbf"
+ "\xeb\xf5\x5f\x7c\x7d\x6b\xde\xeb"
+ "\x95\xf2\xde\xe4\x84\x7e\x29\xff"
+ "\x2a\x85\x43\xa6\x83\x50\x51\x99"
+ "\x0e\xda\xf1\xbd\xd8\x39\x71\xdf"
+ "\xc0\x90\x7d\x34\x2c\xe2\xab\x2f"
+ "\x57\x09\x20\x53\xdf\x67\x2e\x79"
+ "\xa1\x10\xe3\xf6\x03\x2f\xe2\x68"
+ "\x10\x28\xf9\x9d\x4f\x22\xe4\x4e"
+ "\xda\x02\xb3\x8a\x9f\xff\x04\x67"
+ "\x52\x20\x18\xba\x6a\x9e\x76\x15"
+ "\x9c\x24\x95\xf4\x02\xb9\xf6\x9b"
+ "\x42\xdc\x63\x44\x8f\x95\xcd\x3a"
+ "\x3a\xa8\x0d\xeb\x09\x13\x91\xe5"
+ "\xd4\xe6\xfc\x8c\x45\x36\x25\x95"
+ "\x8c\xfd\x8a\xf5\x9f\x5b\x20\xfd"
+ "\x54\x52\x5a\x27\x74\xe8\x31\xc4"
+ "\x0d\x05\xaa\x41\xe2\x84\x9c\xa1"
+ "\x7c\x24\x98\xbb\x00\xbb\x95\x4d"
+ "\x23\xf2\x29\x83\xa9\xc7\x64\xbc"
+ "\xcf\xf3\x2b\xf3\x09\x11\xe2\x96"
+ "\x0b\x60\x34\x78\xc1\x7f\xd0\xfa"
+ "\x8b\x9d\xc0\x02\x8e\x02\xb7\x4d"
+ "\x45\x47\x45\x37\x85\xad\xa2\xec"
+ "\xfd\x2e\x36\xc3\x98\x00\x04\x12"
+ "\xc7\x4c\x78\x57\x70\x2c\xda\x5a"
+ "\xb2\x24\x17\xd9\x77\xd3\xd4\x6a"
+ "\x94\x71\xf3\x4c\x9c\x8c\x3f\x46"
+ "\xee\x49\xd3\x5f\xfe\x59\x95\x91"
+ "\x2c\x2c\xf3\xf2\x95\x68\x22\x92"
+ "\xcd\x39\x9f\xe7\x03\x79\x52\x54"
+ "\x36\xd5\x94\x48\x35\xf9\x22\xa8"
+ "\x68\x20\xe7\xdf\x60\xda\xd8\xaf"
+ "\xe5\x11\xbf\xab\x09\x6f\x35\x97"
+ "\xa3\xbf\x69\x0a\xe6\x01\x4e\xf5"
+ "\x28\x2b\x35\x0a\x43\x0a\x59\x2b"
+ "\xba\x52\x9a\x02\x5a\x7a\x3a\x0f"
+ "\x41\x29\x9c\x09\xfd\xbe\xf6\x95"
+ "\x8b\xe7\x9d\x81\xee\x0e\xa6\x71"
+ "\xc3\xd0\x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xb7\x9e"
+ "\x11\x3d\xd3\x1d\xa8\x29\xe7\x75"
+ "\x4a\x55\x4f\x8e\xc1\x93\x48\x07"
+ "\x37\x80\x85\x35\xf2\x2f\x80\x45"
+ "\x3f\x9c\x8d\x8c\xfb\x23\x0a\xd9"
+ "\x79\xde\x8c\x41\x7e\xcf\xa1\x90"
+ "\xba\xc5\x52\xc4\x1a\x44\xc4\x5d"
+ "\x0f\x0d\x49\xb0\xab\x94\x3d\x32"
+ "\x33\xa3\x52\x13\x29\xa3\xc9\xbf"
+ "\x0a\xff\xb6\xd1\xf7\xc1\xca\x6c"
+ "\xa9\xf7\xde\xee\xc9\x44\x92\x6b"
+ "\x41\x17\x29\x69\x64\x8d\x25\xe6"
+ "\xc7\x11\xc9\x8a\x7a\x4a\x80\xeb"
+ "\x47\x4c\xbd\x66\xc1\x57\xa3\xa6"
+ "\x2d\x81\x78\x93\xdd\xf3\xae\x7e"
+ "\x50\xd4\xa6\x9a\xc8\x69\x7f\x2d"
+ "\xe2\x88\x6c\x41\x99\x7f\x84\xe1"
+ "\xc8\x61\x97\x5f\x24\x1d\xdd\x4c"
+ "\x01\x45\x8f\x95\x55\x5e\xe0\x59"
+ "\x22\xff\x7e\x2a\x5d\x43\xed\xc6"
+ "\x63\xdf\x47\x86\x5d\x8c\x89\x10"
+ "\x94\xf1\x5e\x81\x55\xd8\xa7\x20"
+ "\x12\x75\xbb\x25\x4f\xb1\x9d\x71"
+ "\x21\x78\x0d\xd0\x72\x1e\x66\xa6"
+ "\xf8\x59\x2f\x3b\x22\x49\x2b\xb2"
+ "\x05\xc3\xca\x48\x9c\xb5\x8c\xb9"
+ "\x60\x9d\xf5\x9b\x95\x0a\x23\x39"
+ "\xa4\x37\xab\x06\xfc\x94\xcc\x35"
+ "\xb7\x19\x29\xa4\x4a\x9d\xb0\x48"
+ "\x72\x61\xa3\xdd\x90\xf2\x76\x36"
+ "\xe2\xa5\x7d\xd6\x8e\x07\xa8\xb5"
+ "\x95\x1e\xd7\x3b\xb8\x90\x52\x80"
+ "\x6c\x4a\x3b\xc4\x9b\x79\xcc\x82"
+ "\xd3\x63\xc6\x90\xfe\x21\x40\x5f"
+ "\xe9\x0e\x39\xdb\x9d\x03\xd5\x52"
+ "\xa1\xc2\x02\xc3\xbe\x2f\xac\x5e"
+ "\xa7\x05\xbd\xfc\xc9\x46\x33\xf4"
+ "\x96\x83\xdb\x70\xe7\x98\x4d\x91"
+ "\xf3\xd5\x24\x24\xe9\x4b\x63\xc8"
+ "\xa9\xef\xaf\x24\xd9\x75\x2c\xea"
+ "\x96\x3e\xd0\x15\x2b\x1a\xc6\x18"
+ "\x8f\x12\xb4\x9b\xdd\x3c\x56\xd2"
+ "\x1e\x17\x5d\xa4\xf0\xc8\x19\x0d"
+ "\x1f\x2c\x52\x49\x85\x08\xea\xce"
+ "\xb6\x85\x1a\xc2\xf5\xe2\x8e\x02"
+ "\xc5\xbd\xc4\x42\xae\xa8\xfc\x6f"
+ "\xf2\xa8\xf3\x80\x20\x92\x83\x80"
+ "\xe7\x46\x95\x1c\x19\xec\x8b\xef"
+ "\x4d\xb1\xc7\xd8\xeb\x40\xe2\xd9"
+ "\x67",
+ .len = 1041,
}
};
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH 2/3] crypto: adiantum - Derive the subkeys with the ChaCha library
2026-11-30 5:55 [PATCH 0/3] crypto: adiantum - Use the ChaCha library Laveesh Bansal
2026-11-30 5:55 ` [PATCH 1/3] crypto: testmgr - Add Adiantum vectors with a partial last ChaCha block Laveesh Bansal
@ 2026-11-30 5:55 ` Laveesh Bansal
2026-11-30 19:43 ` Eric Biggers
2026-11-30 5:55 ` [PATCH 3/3] crypto: adiantum - Use the ChaCha library for the stream cipher Laveesh Bansal
2 siblings, 1 reply; 6+ messages in thread
From: Laveesh Bansal @ 2026-11-30 5:55 UTC (permalink / raw)
To: Eric Biggers; +Cc: Herbert Xu, David S. Miller, linux-crypto, linux-kernel
adiantum_setkey() derives K_E and K_H with a crypto_skcipher request
on the stack. SYNC_SKCIPHER_REQUEST_ON_STACK() reserves much more
stack than this needs.
Derive the subkeys with the ChaCha library instead. This replaces
the skcipher request on the stack with a much smaller ChaCha state.
Drop the request-size checks that only guarded that request.
Suggested-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Laveesh Bansal <laveeshb@laveeshbansal.com>
---
Notes:
1. There are already two places where we have similar code to do
xchacha initialization --
xchacha_init() in lib/crypto/chacha20poly1305.c and
crypto_xchacha_crypt() in crypto/chacha.c.
To keep the patch focused, I have added another helper
that does similar logic --
adiantum_xchacha_init() in crypto/adiantum.c.
We should consolidate these into chacha library as a follow up.
2. Test: I tested this patch on arm64, x86_64 and big-endian s390x;
all on QEMU. I had the following in all 3 setups -- KASAN, lockdep
and CRYPTO_SELFTESTS enabled. I applied the setkey, aeslib patches
and patch 1 first (in that order).
The selftests passed for both xchacha12 and xchacha20.
I ran random key test of 400 cases per algorithm. They gave the same
digests as without this patch.
On arm64 and x86_64 -- I did not see any KASAN or lockdep reports.
On s390x -- I found one report in KASAN build of an out-of-bounds
read in aes_decrypt_generic() and lockdep was disabled after it.
The same happened on the unpatched base, so the result is unchanged
with my patch.
crypto/adiantum.c | 75 ++++++++++++++++++++++++++++-------------------
1 file changed, 45 insertions(+), 30 deletions(-)
diff --git a/crypto/adiantum.c b/crypto/adiantum.c
index 5e16d2c4699b6..f53d6d5f56fb9 100644
--- a/crypto/adiantum.c
+++ b/crypto/adiantum.c
@@ -42,11 +42,14 @@
struct adiantum_instance_ctx {
struct crypto_skcipher_spawn streamcipher_spawn;
+ int nrounds;
};
struct adiantum_tfm_ctx {
struct aes_key aes;
struct crypto_skcipher *streamcipher;
+ u32 stream_key[CHACHA_KEY_WORDS];
+ int nrounds;
union {
struct {
struct poly1305_core_key header_hash_key;
@@ -86,6 +89,25 @@ struct adiantum_request_ctx {
} u;
};
+/* The IV is the 24-byte nonce followed by the 8-byte stream position. */
+static void adiantum_xchacha_init(struct chacha_state *state,
+ const u32 key[CHACHA_KEY_WORDS], int nrounds,
+ const u8 iv[XCHACHA_IV_SIZE])
+{
+ u32 subkey[HCHACHA_OUT_WORDS];
+ u8 real_iv[CHACHA_IV_SIZE];
+
+ chacha_init(state, key, iv);
+ hchacha_block(state, subkey, nrounds);
+
+ memcpy(&real_iv[0], iv + 24, 8);
+ memcpy(&real_iv[8], iv + 16, 8);
+
+ chacha_init(state, subkey, real_iv);
+
+ memzero_explicit(subkey, sizeof(subkey));
+}
+
/*
* Given the XChaCha stream key K_S, derive the block cipher key K_E and the
* hash key K_H as follows:
@@ -99,11 +121,9 @@ static int adiantum_setkey(struct crypto_skcipher *tfm, const u8 *key,
unsigned int keylen)
{
struct adiantum_tfm_ctx *tctx = crypto_skcipher_ctx(tfm);
- SYNC_SKCIPHER_REQUEST_ON_STACK(
- req, (struct crypto_sync_skcipher *)tctx->streamcipher);
u8 poly_keys[2 * POLY1305_BLOCK_SIZE];
u8 iv[XCHACHA_IV_SIZE] = { 1 };
- struct scatterlist sg;
+ struct chacha_state state;
int err;
/* Set the stream cipher key (K_S) */
@@ -116,14 +136,13 @@ static int adiantum_setkey(struct crypto_skcipher *tfm, const u8 *key,
return err;
/* Derive the subkeys */
+ for (int i = 0; i < CHACHA_KEY_WORDS; i++)
+ tctx->stream_key[i] = get_unaligned_le32(key + 4 * i);
memset(tctx->derived_keys, 0, sizeof(tctx->derived_keys));
- sg_init_one(&sg, tctx->derived_keys, sizeof(tctx->derived_keys));
- skcipher_request_set_callback(req, 0, NULL, NULL);
- skcipher_request_set_crypt(req, &sg, &sg, sizeof(tctx->derived_keys),
- iv);
- err = crypto_skcipher_encrypt(req);
- if (err)
- goto out;
+ adiantum_xchacha_init(&state, tctx->stream_key, tctx->nrounds, iv);
+ chacha_crypt(&state, tctx->derived_keys, tctx->derived_keys,
+ sizeof(tctx->derived_keys), tctx->nrounds);
+ chacha_zeroize_state(&state);
/* Set the block cipher key (K_E) */
err = aes_preparekey(&tctx->aes, tctx->derived_keys, AES_KEYSIZE_256);
@@ -145,7 +164,6 @@ static int adiantum_setkey(struct crypto_skcipher *tfm, const u8 *key,
if (err)
memzero_explicit(tctx->derived_keys,
sizeof(tctx->derived_keys));
- skcipher_request_zero(req);
return err;
}
@@ -482,13 +500,9 @@ static int adiantum_init_tfm(struct crypto_skcipher *tfm)
streamcipher = crypto_spawn_skcipher(&ictx->streamcipher_spawn);
if (IS_ERR(streamcipher))
return PTR_ERR(streamcipher);
- if (WARN_ON(crypto_skcipher_reqsize(streamcipher) >
- MAX_SYNC_SKCIPHER_REQSIZE)) {
- crypto_free_skcipher(streamcipher);
- return -EINVAL;
- }
tctx->streamcipher = streamcipher;
+ tctx->nrounds = ictx->nrounds;
BUILD_BUG_ON(offsetofend(struct adiantum_request_ctx, u) !=
sizeof(struct adiantum_request_ctx));
@@ -516,23 +530,24 @@ static void adiantum_free_instance(struct skcipher_instance *inst)
}
/*
- * Check for a supported set of inner algorithms.
+ * Check for a supported set of inner algorithms and return
+ * the number of XChaCha rounds, or 0 if they are not supported.
* See the comment at the beginning of this file.
*/
-static bool
-adiantum_supported_algorithms(struct skcipher_alg_common *streamcipher_alg,
- const char *blockcipher_name)
+static int
+adiantum_parse_algorithms(struct skcipher_alg_common *streamcipher_alg,
+ const char *blockcipher_name)
{
- if (strcmp(streamcipher_alg->base.cra_name, "xchacha12") != 0 &&
- strcmp(streamcipher_alg->base.cra_name, "xchacha20") != 0)
- return false;
-
if (strcmp(blockcipher_name, "aes") != 0 &&
/* This is to support the usage by testmgr. */
strcmp(blockcipher_name, "aes-lib") != 0)
- return false;
+ return 0;
- return true;
+ if (strcmp(streamcipher_alg->base.cra_name, "xchacha12") == 0)
+ return 12;
+ if (strcmp(streamcipher_alg->base.cra_name, "xchacha20") == 0)
+ return 20;
+ return 0;
}
static int adiantum_create(struct crypto_template *tmpl, struct rtattr **tb)
@@ -557,8 +572,7 @@ static int adiantum_create(struct crypto_template *tmpl, struct rtattr **tb)
err = crypto_grab_skcipher(&ictx->streamcipher_spawn,
skcipher_crypto_instance(inst),
crypto_attr_alg_name(tb[1]), 0,
- mask | CRYPTO_ALG_ASYNC /* sync only */ |
- CRYPTO_ALG_SKCIPHER_REQSIZE_LARGE);
+ mask | CRYPTO_ALG_ASYNC /* sync only */);
if (err)
goto err_free_inst;
streamcipher_alg = crypto_spawn_skcipher_alg_common(&ictx->streamcipher_spawn);
@@ -581,8 +595,9 @@ static int adiantum_create(struct crypto_template *tmpl, struct rtattr **tb)
}
/* Check the set of algorithms */
- if (!adiantum_supported_algorithms(streamcipher_alg,
- blockcipher_name)) {
+ ictx->nrounds = adiantum_parse_algorithms(streamcipher_alg,
+ blockcipher_name);
+ if (!ictx->nrounds) {
err = -ENOENT;
goto err_free_inst;
}
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH 3/3] crypto: adiantum - Use the ChaCha library for the stream cipher
2026-11-30 5:55 [PATCH 0/3] crypto: adiantum - Use the ChaCha library Laveesh Bansal
2026-11-30 5:55 ` [PATCH 1/3] crypto: testmgr - Add Adiantum vectors with a partial last ChaCha block Laveesh Bansal
2026-11-30 5:55 ` [PATCH 2/3] crypto: adiantum - Derive the subkeys with the ChaCha library Laveesh Bansal
@ 2026-11-30 5:55 ` Laveesh Bansal
2026-11-30 19:40 ` Eric Biggers
2 siblings, 1 reply; 6+ messages in thread
From: Laveesh Bansal @ 2026-11-30 5:55 UTC (permalink / raw)
To: Eric Biggers; +Cc: Herbert Xu, David S. Miller, linux-crypto, linux-kernel
adiantum_crypt() runs the XChaCha step through a child crypto_skcipher.
That needs a spawn, a child tfm and a request sized for the child.
Call chacha_crypt() directly instead and remove the child. The library
works on plain buffers, so adiantum walks the source and destination
scatterlists itself.
Suggested-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Laveesh Bansal <laveeshb@laveeshbansal.com>
---
Notes:
I tested this patch in the same environments as patch 2.
I also ran a test module that splits src and dst at random offsets -
in place and out of place - and compares the result with a plain
buffer. They match. This one I did on arm64 and x86_64.
Another one I ran is the tcrypt adiantum speed test;
I did this on arm64 in a KVM guest with debug options off.
I did not find any slowness in performance when compared
with results on base + setkey + aeslib. I can share specific test
results if anybody is interested.
crypto/Kconfig | 3 +-
crypto/adiantum.c | 164 ++++++++++++++++++++--------------------------
2 files changed, 74 insertions(+), 93 deletions(-)
diff --git a/crypto/Kconfig b/crypto/Kconfig
index 7cac0141a73cb..93996d1240380 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -578,7 +578,8 @@ menu "Length-preserving ciphers and modes"
config CRYPTO_ADIANTUM
tristate "Adiantum"
- select CRYPTO_CHACHA20
+ select CRYPTO_LIB_CHACHA
+ select CRYPTO_SKCIPHER
select CRYPTO_LIB_AES
select CRYPTO_LIB_NH
select CRYPTO_LIB_POLY1305
diff --git a/crypto/adiantum.c b/crypto/adiantum.c
index f53d6d5f56fb9..2358f61e88ce9 100644
--- a/crypto/adiantum.c
+++ b/crypto/adiantum.c
@@ -41,13 +41,11 @@
#define TWEAK_SIZE 32
struct adiantum_instance_ctx {
- struct crypto_skcipher_spawn streamcipher_spawn;
int nrounds;
};
struct adiantum_tfm_ctx {
struct aes_key aes;
- struct crypto_skcipher *streamcipher;
u32 stream_key[CHACHA_KEY_WORDS];
int nrounds;
union {
@@ -78,17 +76,6 @@ struct nhpoly1305_ctx {
__le64 nh_hash[NH_NUM_PASSES];
};
-struct adiantum_request_ctx {
- /*
- * skcipher sub-request size is unknown at compile-time, so it needs to
- * go after the members with known sizes.
- */
- union {
- struct nhpoly1305_ctx hash_ctx;
- struct skcipher_request streamcipher_req;
- } u;
-};
-
/* The IV is the 24-byte nonce followed by the 8-byte stream position. */
static void adiantum_xchacha_init(struct chacha_state *state,
const u32 key[CHACHA_KEY_WORDS], int nrounds,
@@ -126,15 +113,6 @@ static int adiantum_setkey(struct crypto_skcipher *tfm, const u8 *key,
struct chacha_state state;
int err;
- /* Set the stream cipher key (K_S) */
- crypto_skcipher_clear_flags(tctx->streamcipher, CRYPTO_TFM_REQ_MASK);
- crypto_skcipher_set_flags(tctx->streamcipher,
- crypto_skcipher_get_flags(tfm) &
- CRYPTO_TFM_REQ_MASK);
- err = crypto_skcipher_setkey(tctx->streamcipher, key, keylen);
- if (err)
- return err;
-
/* Derive the subkeys */
for (int i = 0; i < CHACHA_KEY_WORDS; i++)
tctx->stream_key[i] = get_unaligned_le32(key + 4 * i);
@@ -347,27 +325,63 @@ static void adiantum_hash_message(struct skcipher_request *req,
{
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
const struct adiantum_tfm_ctx *tctx = crypto_skcipher_ctx(tfm);
- struct adiantum_request_ctx *rctx = skcipher_request_ctx(req);
+ struct nhpoly1305_ctx *hash_ctx = skcipher_request_ctx(req);
unsigned int len = req->cryptlen - AES_BLOCK_SIZE;
struct scatter_walk walk;
- nhpoly1305_init(&rctx->u.hash_ctx);
+ nhpoly1305_init(hash_ctx);
scatterwalk_start(&walk, sgl);
while (len) {
unsigned int n = scatterwalk_next(&walk, len);
- nhpoly1305_update(&rctx->u.hash_ctx, tctx, walk.addr, n);
+ nhpoly1305_update(hash_ctx, tctx, walk.addr, n);
scatterwalk_done_src(&walk, n);
len -= n;
}
- nhpoly1305_final(&rctx->u.hash_ctx, tctx, out);
+ nhpoly1305_final(hash_ctx, tctx, out);
+}
+
+static void adiantum_stream_xor(struct chacha_state *state, int nrounds,
+ struct scatterlist *src,
+ struct scatterlist *dst, unsigned int len)
+{
+ struct scatter_walk swalk, dwalk;
+
+ scatterwalk_start(&swalk, src);
+ scatterwalk_start(&dwalk, dst);
+ while (len) {
+ unsigned int n = min(scatterwalk_clamp(&swalk, len),
+ scatterwalk_clamp(&dwalk, len));
+
+ /*
+ * The ChaCha counter advances in whole blocks, so every
+ * step except the last must be a whole number of blocks.
+ */
+ if (n < len)
+ n = round_down(n, CHACHA_BLOCK_SIZE);
+ if (n) {
+ scatterwalk_map(&swalk);
+ scatterwalk_map(&dwalk);
+ chacha_crypt(state, dwalk.addr, swalk.addr, n, nrounds);
+ scatterwalk_done_dst(&dwalk, n);
+ scatterwalk_done_src(&swalk, n);
+ } else {
+ u8 buf[CHACHA_BLOCK_SIZE];
+
+ n = min(len, CHACHA_BLOCK_SIZE);
+ memcpy_from_scatterwalk(buf, &swalk, n);
+ chacha_crypt(state, buf, buf, n, nrounds);
+ memcpy_to_scatterwalk(&dwalk, buf, n);
+ }
+ len -= n;
+ }
}
static int adiantum_crypt(struct skcipher_request *req, bool enc)
{
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
const struct adiantum_tfm_ctx *tctx = crypto_skcipher_ctx(tfm);
- struct adiantum_request_ctx *rctx = skcipher_request_ctx(req);
+ struct nhpoly1305_ctx *hash_ctx = skcipher_request_ctx(req);
const unsigned int bulk_len = req->cryptlen - AES_BLOCK_SIZE;
struct scatterlist *src = req->src, *dst = req->dst;
/*
@@ -384,8 +398,8 @@ static int adiantum_crypt(struct skcipher_request *req, bool enc)
le128 bignum; /* interpret as element of Z/(2^{128}Z) */
} rbuf;
le128 header_hash, msg_hash;
+ struct chacha_state state;
unsigned int stream_len;
- int err;
if (req->cryptlen < AES_BLOCK_SIZE)
return -EINVAL;
@@ -401,9 +415,9 @@ static int adiantum_crypt(struct skcipher_request *req, bool enc)
/* Fast path for single-page source */
void *virt = kmap_local_page(sg_page(src)) + src->offset;
- nhpoly1305_init(&rctx->u.hash_ctx);
- nhpoly1305_update(&rctx->u.hash_ctx, tctx, virt, bulk_len);
- nhpoly1305_final(&rctx->u.hash_ctx, tctx, &msg_hash);
+ nhpoly1305_init(hash_ctx);
+ nhpoly1305_update(hash_ctx, tctx, virt, bulk_len);
+ nhpoly1305_final(hash_ctx, tctx, &msg_hash);
memcpy(&rbuf.bignum, virt + bulk_len, sizeof(le128));
kunmap_local(virt);
} else {
@@ -439,14 +453,11 @@ static int adiantum_crypt(struct skcipher_request *req, bool enc)
if (round_up(stream_len, CHACHA_BLOCK_SIZE) <= req->cryptlen)
stream_len = round_up(stream_len, CHACHA_BLOCK_SIZE);
- skcipher_request_set_tfm(&rctx->u.streamcipher_req, tctx->streamcipher);
- skcipher_request_set_crypt(&rctx->u.streamcipher_req, req->src,
- req->dst, stream_len, &rbuf);
- skcipher_request_set_callback(&rctx->u.streamcipher_req,
- req->base.flags, NULL, NULL);
- err = crypto_skcipher_encrypt(&rctx->u.streamcipher_req);
- if (err)
- return err;
+ adiantum_xchacha_init(&state, tctx->stream_key, tctx->nrounds,
+ rbuf.bytes);
+ adiantum_stream_xor(&state, tctx->nrounds, req->src, req->dst,
+ stream_len);
+ chacha_zeroize_state(&state);
/* If decrypting, decrypt C_M with the block cipher to get P_M */
if (!enc)
@@ -464,9 +475,9 @@ static int adiantum_crypt(struct skcipher_request *req, bool enc)
struct page *page = sg_page(dst);
void *virt = kmap_local_page(page) + dst->offset;
- nhpoly1305_init(&rctx->u.hash_ctx);
- nhpoly1305_update(&rctx->u.hash_ctx, tctx, virt, bulk_len);
- nhpoly1305_final(&rctx->u.hash_ctx, tctx, &msg_hash);
+ nhpoly1305_init(hash_ctx);
+ nhpoly1305_update(hash_ctx, tctx, virt, bulk_len);
+ nhpoly1305_final(hash_ctx, tctx, &msg_hash);
le128_sub(&rbuf.bignum, &rbuf.bignum, &msg_hash);
memcpy(virt + bulk_len, &rbuf.bignum, sizeof(le128));
flush_dcache_page(page);
@@ -495,37 +506,14 @@ static int adiantum_init_tfm(struct crypto_skcipher *tfm)
struct skcipher_instance *inst = skcipher_alg_instance(tfm);
struct adiantum_instance_ctx *ictx = skcipher_instance_ctx(inst);
struct adiantum_tfm_ctx *tctx = crypto_skcipher_ctx(tfm);
- struct crypto_skcipher *streamcipher;
- streamcipher = crypto_spawn_skcipher(&ictx->streamcipher_spawn);
- if (IS_ERR(streamcipher))
- return PTR_ERR(streamcipher);
-
- tctx->streamcipher = streamcipher;
tctx->nrounds = ictx->nrounds;
-
- BUILD_BUG_ON(offsetofend(struct adiantum_request_ctx, u) !=
- sizeof(struct adiantum_request_ctx));
- crypto_skcipher_set_reqsize(
- tfm, max(sizeof(struct adiantum_request_ctx),
- offsetofend(struct adiantum_request_ctx,
- u.streamcipher_req) +
- crypto_skcipher_reqsize(streamcipher)));
+ crypto_skcipher_set_reqsize(tfm, sizeof(struct nhpoly1305_ctx));
return 0;
}
-static void adiantum_exit_tfm(struct crypto_skcipher *tfm)
-{
- struct adiantum_tfm_ctx *tctx = crypto_skcipher_ctx(tfm);
-
- crypto_free_skcipher(tctx->streamcipher);
-}
-
static void adiantum_free_instance(struct skcipher_instance *inst)
{
- struct adiantum_instance_ctx *ictx = skcipher_instance_ctx(inst);
-
- crypto_drop_skcipher(&ictx->streamcipher_spawn);
kfree(inst);
}
@@ -535,7 +523,7 @@ static void adiantum_free_instance(struct skcipher_instance *inst)
* See the comment at the beginning of this file.
*/
static int
-adiantum_parse_algorithms(struct skcipher_alg_common *streamcipher_alg,
+adiantum_parse_algorithms(const char *streamcipher_name,
const char *blockcipher_name)
{
if (strcmp(blockcipher_name, "aes") != 0 &&
@@ -543,9 +531,11 @@ adiantum_parse_algorithms(struct skcipher_alg_common *streamcipher_alg,
strcmp(blockcipher_name, "aes-lib") != 0)
return 0;
- if (strcmp(streamcipher_alg->base.cra_name, "xchacha12") == 0)
+ if (strcmp(streamcipher_name, "xchacha12") == 0 ||
+ strcmp(streamcipher_name, "xchacha12-lib") == 0)
return 12;
- if (strcmp(streamcipher_alg->base.cra_name, "xchacha20") == 0)
+ if (strcmp(streamcipher_name, "xchacha20") == 0 ||
+ strcmp(streamcipher_name, "xchacha20-lib") == 0)
return 20;
return 0;
}
@@ -555,7 +545,7 @@ static int adiantum_create(struct crypto_template *tmpl, struct rtattr **tb)
u32 mask;
struct skcipher_instance *inst;
struct adiantum_instance_ctx *ictx;
- struct skcipher_alg_common *streamcipher_alg;
+ const char *streamcipher_name;
const char *blockcipher_name;
int err;
@@ -569,13 +559,11 @@ static int adiantum_create(struct crypto_template *tmpl, struct rtattr **tb)
ictx = skcipher_instance_ctx(inst);
/* Stream cipher: "xchacha12" or "xchacha20" */
- err = crypto_grab_skcipher(&ictx->streamcipher_spawn,
- skcipher_crypto_instance(inst),
- crypto_attr_alg_name(tb[1]), 0,
- mask | CRYPTO_ALG_ASYNC /* sync only */);
- if (err)
+ streamcipher_name = crypto_attr_alg_name(tb[1]);
+ if (IS_ERR(streamcipher_name)) {
+ err = PTR_ERR(streamcipher_name);
goto err_free_inst;
- streamcipher_alg = crypto_spawn_skcipher_alg_common(&ictx->streamcipher_spawn);
+ }
/* Block cipher: "aes" */
blockcipher_name = crypto_attr_alg_name(tb[2]);
@@ -595,7 +583,7 @@ static int adiantum_create(struct crypto_template *tmpl, struct rtattr **tb)
}
/* Check the set of algorithms */
- ictx->nrounds = adiantum_parse_algorithms(streamcipher_alg,
+ ictx->nrounds = adiantum_parse_algorithms(streamcipher_name,
blockcipher_name);
if (!ictx->nrounds) {
err = -ENOENT;
@@ -604,29 +592,21 @@ static int adiantum_create(struct crypto_template *tmpl, struct rtattr **tb)
/* Instance fields */
- err = -ENAMETOOLONG;
- if (snprintf(inst->alg.base.cra_name, CRYPTO_MAX_ALG_NAME,
- "adiantum(%s,aes)",
- streamcipher_alg->base.cra_name) >= CRYPTO_MAX_ALG_NAME)
- goto err_free_inst;
- if (snprintf(inst->alg.base.cra_driver_name, CRYPTO_MAX_ALG_NAME,
- "adiantum(%s,aes-lib)",
- streamcipher_alg->base.cra_driver_name) >=
- CRYPTO_MAX_ALG_NAME)
- goto err_free_inst;
+ snprintf(inst->alg.base.cra_name, CRYPTO_MAX_ALG_NAME,
+ "adiantum(xchacha%d,aes)", ictx->nrounds);
+ snprintf(inst->alg.base.cra_driver_name, CRYPTO_MAX_ALG_NAME,
+ "adiantum(xchacha%d-lib,aes-lib)", ictx->nrounds);
inst->alg.base.cra_blocksize = AES_BLOCK_SIZE;
inst->alg.base.cra_ctxsize = sizeof(struct adiantum_tfm_ctx);
- inst->alg.base.cra_alignmask = streamcipher_alg->base.cra_alignmask;
- inst->alg.base.cra_priority = streamcipher_alg->base.cra_priority;
+ inst->alg.base.cra_priority = 300;
inst->alg.setkey = adiantum_setkey;
inst->alg.encrypt = adiantum_encrypt;
inst->alg.decrypt = adiantum_decrypt;
inst->alg.init = adiantum_init_tfm;
- inst->alg.exit = adiantum_exit_tfm;
- inst->alg.min_keysize = streamcipher_alg->min_keysize;
- inst->alg.max_keysize = streamcipher_alg->max_keysize;
+ inst->alg.min_keysize = CHACHA_KEY_SIZE;
+ inst->alg.max_keysize = CHACHA_KEY_SIZE;
inst->alg.ivsize = TWEAK_SIZE;
inst->free = adiantum_free_instance;
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread