Cryptsetup xchacha20,poly1305,adiantum in custom build snapshot

hey guys,

how can i use the xchacha ciphers, poly1305 or adiantum with cryptsetup for full disk encryption ?
do i need a specific kernel config or a cryptsetup build option for that ?
the chacha kernel modules are loaded & /proc/crypto lists them too.

openwrt: latest master snapshot
cryptsetup v.2.4.3
device: r7800 armv7

lsmod | grep -i chacha
chacha_neon            32768  1 libchacha20poly1305
chacha20poly1305       20480  0 
libchacha20poly1305    16384  1 wireguard,[permanent]
poly1305_arm           24576  1 libchacha20poly1305
grep -i chacha /proc/crypto
name         : xchacha12
driver       : xchacha12-neon
module       : chacha_neon
name         : xchacha20
driver       : xchacha20-neon
module       : chacha_neon
name         : chacha20
driver       : chacha20-neon
module       : chacha_neon
name         : xchacha12
driver       : xchacha12-arm
module       : chacha_neon
name         : xchacha20
driver       : xchacha20-arm
module       : chacha_neon
name         : chacha20
driver       : chacha20-arm
module       : chacha_neon
grep -i poly /proc/crypto
name         : poly1305
driver       : poly1305-neon
module       : poly1305_arm
name         : poly1305
driver       : poly1305-arm
module       : poly1305_arm

wireguard & openssl are already using them.

openssl speed -evp chacha20-poly1305
Doing chacha20-poly1305 for 3s on 16 size blocks: 8023661 chacha20-poly1305's in 2.97s
Doing chacha20-poly1305 for 3s on 64 size blocks: 4225973 chacha20-poly1305's in 2.94s
Doing chacha20-poly1305 for 3s on 256 size blocks: 2517239 chacha20-poly1305's in 2.86s
Doing chacha20-poly1305 for 3s on 1024 size blocks: 789042 chacha20-poly1305's in 2.98s
Doing chacha20-poly1305 for 3s on 8192 size blocks: 102964 chacha20-poly1305's in 2.97s
cryptsetup benchmark -c xchacha12
# Tests are approximate using memory only (no storage IO).
Cipher xchacha12 (with 256 bits key) is not available.
cryptsetup benchmark -c xchacha20,aes-adiantum-plain64
# Tests are approximate using memory only (no storage IO).
Cipher xchacha20,aes-adiantum-plain64 (with 256 bits key) is not available.


working example on a raspberry pi kernel build:

https://forums.raspberrypi.com/viewtopic.php?t=275542


also implemented on archlinux arm build:
https://archlinuxarm.org/forum/viewtopic.php?f=23&t=15074


any guidance appreciated.

Regardig the crypto module itself, you can use menuconfig to modify kernel config to include those, and build it.

menu item: Kernel modules > Cryptographic API modules

menuconfig screenshot

.config - OpenWrt Configuration
 > Kernel modules > Cryptographic API modules ────────────────────────────────────────────────────────────
  ┌──────────────────────────────────── Cryptographic API modules ─────────────────────────────────────┐
  │  Arrow keys navigate the menu.  <Enter> selects submenus ---> (or empty submenus ----).            │  
  │  Highlighted letters are hotkeys.  Pressing <Y> includes, <N> excludes, <M> modularizes features.  │  
  │  Press <Esc><Esc> to exit, <?> for Help, </> for Search.  Legend: [*] built-in  [ ] excluded       │  
  │  <M> module  < > module capable                                                                    │  
  │ ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ │  
  │ │             -*- kmod-crypto-aead.................................. CryptoAPI AEAD support      │ │  
  │ │             -*- kmod-crypto-arc4............................ ARC4 cipher CryptoAPI module      │ │  
  │ │             < > kmod-crypto-authenc...................... Combined mode wrapper for IPsec      │ │  
  │ │             < > kmod-crypto-cbc................... Cipher Block Chaining CryptoAPI module      │ │  
  │ │             -*- kmod-crypto-ccm................... Support for Counter with CBC MAC (CCM)      │ │  
  │ │             < > kmod-crypto-chacha20poly1305                                                   │ │  
  │ │             -*- kmod-crypto-cmac                                                               │ │  
  │ │             -*- kmod-crypto-crc32c..................................... CRC32c CRC module      │ │  
  │ │             -*- kmod-crypto-ctr............................ Counter Mode CryptoAPI module      │ │  
  │ │             < > kmod-crypto-cts.................... Cipher Text Stealing CryptoAPI module      │ │  
  │ │             < > kmod-crypto-deflate................. Deflate compression CryptoAPI module      │ │  
  │ │             -*- kmod-crypto-des......................... DES/3DES cipher CryptoAPI module      │ │  
  │ │             -*- kmod-crypto-ecb..................... Electronic CodeBook CryptoAPI module      │ │  

I have never tried to use those, so no special expertise...

1 Like

Adiantum seems to not be a selectable/installable kernel module (kmod).

But you can use "make kernel_menuconfig" to select it to be built-in:

.config - Linux/arm 5.10.136 Kernel Configuration
 > Cryptographic API ─────────────────────────────────────────────────────────────────────────────────────────────────────
  ┌──────────────────────────────────────────────── Cryptographic API ─────────────────────────────────────────────────┐
  │  Arrow keys navigate the menu.  <Enter> selects submenus ---> (or empty submenus ----).  Highlighted letters are   │  
  │  hotkeys.  Pressing <Y> includes, <N> excludes, <M> modularizes features.  Press <Esc><Esc> to exit, <?> for Help, │  
  │  </> for Search.  Legend: [*] built-in  [ ] excluded  <M> module  < > module capable                               │  
  │                                                                                                                    │  
  │ ┌─────────────────────^(-)───────────────────────────────────────────────────────────────────────────────────────┐ │  
  │ │                     < >   CBC support                                                                          │ │  
  │ │                     < >   CFB support                                                                          │ │  
  │ │                     -*-   CTR support                                                                          │ │  
  │ │                     < >   CTS support                                                                          │ │  
  │ │                     < >   ECB support                                                                          │ │  
  │ │                     < >   LRW support                                                                          │ │  
  │ │                     < >   OFB support                                                                          │ │  
  │ │                     < >   PCBC support                                                                         │ │  
  │ │                     < >   XTS support                                                                          │ │  
  │ │                     < >   Key wrapping support                                                                 │ │  
  │ │                     < >   Adiantum support                                                                     │ │  
  │ │                     < >   ESSIV support for block encryption                                                   │ │  
  │ │                           *** Hash modes ***                                                                   │ │  
  │ │                     < >   CMAC support                                                                         │ │  
  │ │                     -*-   HMAC support                                                                         │ │  
  │ │                     < >   XCBC support                                                                         │ │  
  │ │                     < >   VMAC support                                                                         │ │  
  │ │                           *** Digest ***                                                                       │ │
1 Like