qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 00/15] hw/misc/aspeed_hace: Fix SG Accumulative Hash Calculations
@ 2024-08-07 19:51 Alejandro Zeise
  2024-08-07 19:51 ` [PATCH v4 01/15] crypto: accumulative hashing API Alejandro Zeise
                   ` (15 more replies)
  0 siblings, 16 replies; 38+ messages in thread
From: Alejandro Zeise @ 2024-08-07 19:51 UTC (permalink / raw)
  To: qemu-arm
  Cc: alejandro.zeise, kris.conklin, jonathan.henze, evan.burgess, clg,
	peter.maydell, berrange, qemu-devel

The goal of this patch series is to fix accumulative hashing support in the 
Aspeed HACE module. The issue that stemmed this patch was a failure to boot an
OpenBMC image using the "ast2600-evb" machine. The U-boot
2019.04 loader failed to verify image hashes.

These incorrect image hashes given by the HACE to the U-boot guest are due to 
an oversight in the HACE module. Previously when operating in 
scatter-gather accumulative mode, the HACE would cache the address provided by 
the guest which contained the source data. However, there was no deep copy, 
so when HACE generated the digest upon the reception of the final accumulative chunk 
the digest was incorrect, as the addresses provided had their regions overwritten
by that time.

This fix consists of two main steps:
* Add an accumulative hashing function to the qcrypto library
* Modify the HACE module to use the accumulative hashing functions

All the crypto library backends (nettle, gnutls, etc.) support accumulative hashing,
so it was trivial to create wrappers for those functions.

Changes in V4:
* Restructured patches so unit tests pass for each independently.
* Freeing hash context is now a void function.
* Added autoptr cleanup function definition for qcrypto_hash_free.
* Separated qcrypto_hash_update into qcrypto_hash_update and qcrypto_hash_updatev.
* Changed public hash functions to use afalg implementation correctly if support
  is enabled.
* Fixed accumulative hashing in afalg driver (pass MSG_MORE socket flag).

Changes in V3:
* Reworked crypto hash API with comments from Daniel
  * Creation/Deletion of contexts, updating, and finalizing
  * Modified existing API functions to use the new 4 main core functions
  * Added test for accumulative hashing
  * Added afalg driver implementation
* Fixed bug in HACE module where hash context fails to allocate,
  causing the HACE internal state to be incorrect and segfault.

Changes in V2:
* Fixed error checking bug in libgcrypt crypto backend of
  accumulate_bytesv

Alejandro Zeise (15):
  crypto: accumulative hashing API
  crypto/hash-glib: Implement new hash API
  crypto/hash-gcrypt: Implement new hash API
  crypto/hash-gnutls: Implement new hash API
  crypto/hash-nettle: Implement new hash API
  crypto/hash-afalg: Implement new hash API
  crypto/hash: Implement and use new hash API
  tests/unit/test-crypto-hash: accumulative hashing
  crypto/hash-glib: Remove old hash API functions
  crypto/hash-gcrypt: Remove old hash API functions
  crypto/hash-gnutls: Remove old hash API functions
  crypto/hash-nettle: Remove old hash API functions
  crypto/hash-afalg: Remove old hash API functions
  crypto/hashpriv: Remove old hash API function
  hw/misc/aspeed_hace: Fix SG Accumulative hashing

 crypto/hash-afalg.c           | 171 ++++++++++++++++++++++++----------
 crypto/hash-gcrypt.c          | 110 ++++++++++++----------
 crypto/hash-glib.c            |  96 ++++++++++++-------
 crypto/hash-gnutls.c          |  92 +++++++++++-------
 crypto/hash-nettle.c          |  78 ++++++++++------
 crypto/hash.c                 | 163 +++++++++++++++++++++++++-------
 crypto/hashpriv.h             |  13 ++-
 hw/misc/aspeed_hace.c         |  94 ++++++++++---------
 include/crypto/hash.h         | 119 +++++++++++++++++++++++
 include/hw/misc/aspeed_hace.h |   4 +
 include/qemu/iov.h            |  26 ++++++
 tests/unit/test-crypto-hash.c |  48 ++++++++++
 util/iov.c                    |  22 +++--
 13 files changed, 753 insertions(+), 283 deletions(-)

-- 
2.34.1



^ permalink raw reply	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2024-08-27 13:54 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-07 19:51 [PATCH v4 00/15] hw/misc/aspeed_hace: Fix SG Accumulative Hash Calculations Alejandro Zeise
2024-08-07 19:51 ` [PATCH v4 01/15] crypto: accumulative hashing API Alejandro Zeise
2024-08-08 16:04   ` Daniel P. Berrangé
2024-08-08 17:00     ` Markus Armbruster
2024-08-07 19:51 ` [PATCH v4 02/15] crypto/hash-glib: Implement new hash API Alejandro Zeise
2024-08-08 16:58   ` Daniel P. Berrangé
2024-08-07 19:51 ` [PATCH v4 03/15] crypto/hash-gcrypt: " Alejandro Zeise
2024-08-08 17:00   ` Daniel P. Berrangé
2024-08-08 17:05   ` Daniel P. Berrangé
2024-08-08 18:24     ` Alejandro Zeise
2024-08-09  8:37       ` Daniel P. Berrangé
2024-08-08 17:10   ` Daniel P. Berrangé
2024-08-07 19:51 ` [PATCH v4 04/15] crypto/hash-gnutls: " Alejandro Zeise
2024-08-08 17:10   ` Daniel P. Berrangé
2024-08-07 19:51 ` [PATCH v4 05/15] crypto/hash-nettle: " Alejandro Zeise
2024-08-07 19:51 ` [PATCH v4 06/15] crypto/hash-afalg: " Alejandro Zeise
2024-08-08 17:16   ` Daniel P. Berrangé
2024-08-07 19:51 ` [PATCH v4 07/15] crypto/hash: Implement and use " Alejandro Zeise
2024-08-08 16:21   ` Daniel P. Berrangé
2024-08-07 19:51 ` [PATCH v4 08/15] tests/unit/test-crypto-hash: accumulative hashing Alejandro Zeise
2024-08-08 17:18   ` Daniel P. Berrangé
2024-08-07 19:51 ` [PATCH v4 09/15] crypto/hash-glib: Remove old hash API functions Alejandro Zeise
2024-08-08 17:19   ` Daniel P. Berrangé
2024-08-07 19:51 ` [PATCH v4 10/15] crypto/hash-gcrypt: " Alejandro Zeise
2024-08-08 17:19   ` Daniel P. Berrangé
2024-08-07 19:51 ` [PATCH v4 11/15] crypto/hash-gnutls: " Alejandro Zeise
2024-08-08 17:20   ` Daniel P. Berrangé
2024-08-07 19:51 ` [PATCH v4 12/15] crypto/hash-nettle: " Alejandro Zeise
2024-08-08 17:22   ` Daniel P. Berrangé
2024-08-07 19:51 ` [PATCH v4 13/15] crypto/hash-afalg: " Alejandro Zeise
2024-08-08 17:23   ` Daniel P. Berrangé
2024-08-07 19:51 ` [PATCH v4 14/15] crypto/hashpriv: Remove old hash API function Alejandro Zeise
2024-08-08 17:24   ` Daniel P. Berrangé
2024-08-07 19:51 ` [PATCH v4 15/15] hw/misc/aspeed_hace: Fix SG Accumulative hashing Alejandro Zeise
2024-08-27 13:53   ` Cédric Le Goater
2024-08-07 20:01 ` [PATCH v4 00/15] hw/misc/aspeed_hace: Fix SG Accumulative Hash Calculations Philippe Mathieu-Daudé
2024-08-07 20:30   ` Alejandro Zeise
2024-08-08  8:46   ` Daniel P. Berrangé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).