Skip to content

crypto: misc cleanup and introduce gnutls backend driver

Daniel P. Berrangé qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest18 patches 24 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/18crypto: remove conditional around 3DES crypto test casestests/unit/test-crypto-cipher.c+0 -21 reply
2/18crypto: remove obsolete crypto test conditiontests/unit/test-crypto-pbkdf.c+1 -41 reply
3/18crypto: skip essiv ivgen tests if AES+ECB isn't availabletests/unit/test-crypto-ivgen.c+9 -51 reply
4/18crypto: use &error_fatal in crypto teststests/unit/test-crypto-hash.c tests/unit/test-crypto-hmac.c+14 -261 reply
5/18crypto: fix gcrypt min version 1.8 regressionmeson.build+1 -11 reply
6/18crypto: drop gcrypt thread initialization codecrypto/init.c+0 -621 reply
7/18crypto: drop custom XTS support in gcrypt drivercrypto/cipher-gcrypt.c.inc meson.build+1 -1401 reply
8/18crypto: add crypto tests for single block DES-ECB and DES-CBCtests/unit/test-crypto-cipher.c+23 -02 replies
9/18crypto: delete built-in DES implementationcrypto/cipher-builtin.c.inc crypto/desrfb.c crypto/meson.build+0 -4891 reply
10/18crypto: delete built-in XTS cipher mode supportcrypto/cipher-builtin.c.inc crypto/meson.build meson.build+6 -671 reply
11/18crypto: rename des-rfb cipher to just descrypto/cipher-gcrypt.c.inc crypto/cipher-nettle.c.inc crypto/cipher.c +3 more+47 -655 replies
12/18crypto: flip priority of backends to prefer gcryptmeson.build+11 -111 reply
13/18crypto: introduce build system for gnutls crypto backendmeson.build+32 -41 reply
14/18crypto: add gnutls cipher providercrypto/cipher-gnutls.c.inc crypto/cipher.c+327 -01 reply
15/18crypto: add gnutls hash providercrypto/hash-gnutls.c crypto/meson.build+106 -01 reply
16/18crypto: add gnutls hmac providercrypto/hmac-gnutls.c+136 -02 replies
17/18crypto: add gnutls pbkdf providercrypto/meson.build crypto/pbkdf-gnutls.c+91 -11 reply
18/18crypto: prefer gnutls as the crypto backend if new enoughmeson.build+35 -241 reply

Reviews trailers per patch

All 18 patches have a Reviewed-by or Acked-by.

PatchMarkus ArmbrusterEric Blake
1/18R-b
2/18R-b
3/18R-b
4/18R-b
5/18R-b
6/18R-b
7/18R-b
8/18R-b
9/18R-b
10/18R-b
11/18R-b R-b
12/18R-b
13/18R-b
14/18R-b
15/18R-b
16/18R-b
17/18R-b
18/18R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 00/18] crypto: misc cleanup and introduce gnutls backend driver

Currently the crypto layer has a choice of backend drivers

* builtin - AES/DES for ciphers using in-tree impl, glib for hash / hmac
* gcrypt - all ciphers and al hash/hmac algs
* nettle - all ciphers and al hash/hmac algs

We currently default to nettle because that minimizes the deps from QEMU, as gnutls already pulls in nettle.

In retrospect, however, this was the wrong metric to optimize for. Instead we should have picked backend based on the performance of the drivers.

The nettle impls have some limited CPU hardware acceleration, but aside from in ECB mode, nettle is slower than gcrypt in every case. In the most important AES-XTS case used for luks disk encryption, nettle is achieves just 15% of the performance of gcrypt. It is clear we should prefer gcrypt over nettle.

gnutls uses nettle internally and also exposes many of the ciphers for direct usage. Unexpectedly, gnutls is actually faster than nettle, despite using nettle. The reason for this is that gnutls provides CPU accelerated code for handling CBC and XTS modes. This lets gnutls get in the same ballpark as gcrypt for the most important encryption modes. It is also good for hash impls.

This series thus does a number of things

- Introduce gnutls as a backe driver
- Change priority order gnutls > gcrypt > nettle > builtin
- Cleanup cruft from older versions of crypto libraries
- Make some tests more robust and easier to debug
- Drop support for built-in XTS impl, as it is too slow to be useful for LUKS
- Drop support for built-in DES impl, to minize amount of custom crypto code carried. VNC password auth will require use of an grypt/nettle/gnutls

Daniel P. Berrangé (18):
crypto: remove conditional around 3DES crypto test cases
crypto: remove obsolete crypto test condition
crypto: skip essiv ivgen tests if AES+ECB isn't available
crypto: use &error_fatal in crypto tests
crypto: fix gcrypt min version 1.8 regression
crypto: drop gcrypt thread initialization code
crypto: drop custom XTS support in gcrypt driver
crypto: add crypto tests for single block DES-ECB and DES-CBC
crypto: delete built-in DES implementation
crypto: delete built-in XTS cipher mode support
crypto: rename des-rfb cipher to just des
crypto: flip priority of backends to prefer gcrypt
crypto: introduce build system for gnutls crypto backend
crypto: add gnutls cipher provider
crypto: add gnutls hash provider
crypto: add gnutls hmac provider
crypto: add gnutls pbkdf provider
crypto: prefer gnutls as the crypto backend if new enough

 crypto/cipher-builtin.c.inc     | 132 ----------
 crypto/cipher-gcrypt.c.inc      | 143 +----------
 crypto/cipher-gnutls.c.inc      | 325 +++++++++++++++++++++++++
 crypto/cipher-nettle.c.inc      |  26 +-
 crypto/cipher.c                 |  30 +--
 crypto/desrfb.c                 | 416 --------------------------------
 crypto/hash-gnutls.c            | 104 ++++++++
 crypto/hmac-gnutls.c            | 136 +++++++++++
 crypto/init.c                   |  62 -----
 crypto/meson.build              |   9 +-
 crypto/pbkdf-gnutls.c           |  90 +++++++
 meson.build                     | 102 +++++---
 qapi/crypto.json                |   4 +-
 tests/unit/test-crypto-cipher.c |  31 ++-
 tests/unit/test-crypto-hash.c   |  12 +-
 tests/unit/test-crypto-hmac.c   |  28 +--
 tests/unit/test-crypto-ivgen.c  |  14 +-
 tests/unit/test-crypto-pbkdf.c  |   5 +-
 ui/vnc.c                        |  20 +-
 19 files changed, 814 insertions(+), 875 deletions(-)
 create mode 100644 crypto/cipher-gnutls.c.inc
 delete mode 100644 crypto/desrfb.c
 create mode 100644 crypto/hash-gnutls.c
 create mode 100644 crypto/hmac-gnutls.c
 create mode 100644 crypto/pbkdf-gnutls.c
Signature · 1 line
2.31.1