Bug 2077532

Summary: Hardware without AES-NI: use xchacha12/Adiantum instead of AES-XTS
Product: [Fedora] Fedora Reporter: Christopher Klooz <py0xc3>
Component: python-blivetAssignee: Vojtech Trefny <vtrefny>
Status: NEW --- QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: low    
Version: rawhideCC: anaconda-maint-list, blivet-maint-list, dlehman, dominik, gmazyland, japokorn, jonathan, kellin, mkolman, okozina, rvykydal, vanmeeuwen+fedora, vponcova, vtrefny, w, zbyszek
Target Milestone: ---Keywords: FutureFeature, Reopened
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Fedora 35 KDE spin on an old Intel Celeron N2940 (issue is anaconda-specific and thus, likely to exist on all Fedora Workstations and architectures).
Last Closed: 2022-12-13 17:47:06 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Christopher Klooz 2022-04-21 14:29:56 UTC
Description of problem:
This is a feature request, not a bug.

When setting up a new Fedora installation, Anaconda (both "Custom" and "Advanced Custom (Blivet-GUI)") always uses aes-xts-plain64 for disk encryption, even if the hardware does not support AES-NI.

If there is no AES-NI in the hardware, it makes sense to use xchacha12,aes-adiantum-plain64 or xchacha20,aes-adiantum-plain64 (xchacha12,aes-adiantum-plain64 is in my opinion sufficiently, especially for weak or battery-operated hardware).

Anaconda needs a function that determines the existence of an AES-NI in the CPU when setting up encrypted storage in order to choose aes-xts if AES-NI is available, and xchacha/adiantum if AES-NI is not available.

For an average kernel-operated block-based disk encryption use case, the security advantages of xchacha-adiantum compared to software-based aes-xts can be neglected: both aes-xts and chacha-adiantum are sufficiently secure for that.

But there are big performance disadvantages of AES when there is no AES-NI (this was the major reason for merging Adiantum into the kernel).

Besides the use of system resources, netbooks/laptops may have strongly decreased battery life times with aes-xts due to the high power consumption (the issue is primarily aes, not xts).

I tested with Fedora 35, KDE spin; but as the issue is Anaconda-centric, I expect that other Workstation installations tend to the same behavior, including different architectures.

Adjustments seem to be limited to Anaconda.

Might be interesting for upstream distributions as well.

Version-Release number of selected component (if applicable):
KDE spin of Fedora 35; 36 not yet tested for this issue.

How reproducible:
Use anaconda to install Fedora with storage configuration "Custom" or "Advanced Custom (Blivet-GUI)" (both behave equal in this respect) and enable disk encryption.

Actual results:
aes-xts encryption on hardware without aes-ni

Expected results:
xchacha-adiantum encryption on hardware without aes-ni

Additional info:
It is possible to create the xchacha-adiantum storage in advance using 

"cryptsetup --type luks2 --sector-size 4096 --cipher=xchacha12,aes-adiantum-plain64 --offset=0 --pbkdf argon2id --iter-time 2000 luksFormat /dev/sdx"; cryptsetup luksOpen /dev/sdx x1; mkfs.ext4 /dev/mapper/x1; cryptsetup luksClose x1;"

Anaconda storage configuration "custom" (Blivet not yet tested with this) is properly able to decrypt and open the xchacha12-adiantum later to use it in the installation. Installation works properly since. At first glance, no errors in this process.

Comment 1 Vendula Poncova 2022-05-03 13:11:37 UTC
It looks like it could be automatically detected by our storage library. Reassigning to Blivet for further investigation.

Comment 2 Christopher Klooz 2022-06-09 17:38:33 UTC
Casper added a related benchmark with a comparison of 256bit AES (XTS-512) against 256bit XChaCha20, which illustrates the impact on machines without AES-NI:

```
blackbird:~ # cryptsetup benchmark -c xchacha20,aes-adiantum                
# Tests approximatifs en utilisant uniquement la mémoire (pas de stockage E/S).
#            Algorithme |       Clé |     Chiffrement |    Déchiffrement
xchacha20,aes-adiantum        256b       327,8 MiB/s       345,0 MiB/s
```
```
blackbird:~ # cryptsetup benchmark -c aes-xts-plain64 --key-size 512
# Tests approximatifs en utilisant uniquement la mémoire (pas de stockage E/S).
# Algorithme |       Clé |     Chiffrement |    Déchiffrement
    aes-xts        512b        84,3 MiB/s        83,5 MiB/s
```

His note that Raspberry Pi models up to and including the current 4(B) have no AES-NI might be relevant, too.

See devel mailing list topic "Hardware without AES-NI: use xchacha12/Adiantum instead of AES-XTS".

Comment 3 Ben Cotton 2022-11-29 18:47:43 UTC
This message is a reminder that Fedora Linux 35 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora Linux 35 on 2022-12-13.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
'version' of '35'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, change the 'version' 
to a later Fedora Linux version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora Linux 35 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora Linux, you are encouraged to change the 'version' to a later version
prior to this bug being closed.

Comment 4 Ben Cotton 2022-12-13 17:47:06 UTC
Fedora Linux 35 entered end-of-life (EOL) status on 2022-12-13.

Fedora Linux 35 is no longer maintained, which means that it
will not receive any further security or bug fix updates. As a result we
are closing this bug.

If you can reproduce this bug against a currently maintained version of Fedora Linux
please feel free to reopen this bug against that version. Note that the version
field may be hidden. Click the "Show advanced fields" button if you do not see
the version field.

If you are unable to reopen this bug, please file a new report against an
active release.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 5 Zbigniew Jędrzejewski-Szmek 2023-04-23 19:34:52 UTC
This sounds to be worth considering. This was closed as EOL with no reply from maintainers, so I'm reopening this.

Comment 6 Vojtech Trefny 2023-04-24 05:46:13 UTC
(In reply to Zbigniew Jędrzejewski-Szmek from comment #5)
> This sounds to be worth considering. This was closed as EOL with no reply
> from maintainers, so I'm reopening this.

We have a tracking issue for this upstream, but we unfortunately won't have capacity to work on this in the near future so I can't promise any target release for implementing this feature.

Comment 7 Christopher Klooz 2023-04-24 12:38:27 UTC
Upstream ticket: https://github.com/storaged-project/blivet/issues/1108

Some data from testing: Adiantum works properly with F37. I use it on two production systems since 2022 (since the F36 release cycle). I prepared the disks manually with cryptsetup and then installed F36 (system with lxqt spin), and since Jan 2023 also on another system F37 (kde spin). So Anaconda has no problem with using Adiantum when installing Fedora if the Adiantum devices already exist in advance. The upgrade from the lxQt system's F36 to F37 was also without issues (outside the kernel, this is just dm-crypt, it should not have further impacts if dm-crypt internally deploys adiantum instead of AES-XTS).

Comment 8 Ondrej Kozina 2023-04-24 13:54:15 UTC
Just a note from dm-crypt perspective. The benchmark performance data produced by cryptsetup benchmark command is informational only. It does not reflect how dm-crypt would perform while mapped over block device. Encryption/decryption (benchmark command) is run in memory only and does not perform encryption in smaller blocks typically used by dm-crypt (512 bytes, 1024 bytes, 2KiB or 4KiB). Encrypting smaller blocks affect performance significantly.

It would be much more interesting to see for example fio performance tests run on top of dm-crypt using with AES versus dm-crypt with xchacha12 and appropriate modes.

Comment 9 Christopher Klooz 2023-04-24 14:04:57 UTC
Relevant should be 4 KiB. As far as I remember, this is the default that Anaconda creates anyway (isn't it?), and Adiantum is designed for 4 KiB as well.

Some complementary performance measurements from the author: https://github.com/google/adiantum/tree/master/specification/performance (the "output4096" file is obviously most interesting).

Comment 10 Fedora Admin user for bugzilla script actions 2023-04-26 00:29:57 UTC
This package has changed maintainer in Fedora. Reassigning to the new maintainer of this component.

Comment 11 Fedora Admin user for bugzilla script actions 2023-04-26 12:05:56 UTC
This package has changed maintainer in Fedora. Reassigning to the new maintainer of this component.