Merge crypto and other misc fixes / features
* Increase minimum gnutls to 3.7.5
* Increase minimum libgcrypt to 1.9.4
* Increase minimum nettle to 3.7.3
* Drop obsolete in-tree XTS impl
* Fix memory leak when loading certificates
* Remove/reduce duplication when loading certifcates
* Fix possible crash when certificates are unloaded
while an active TLS connection is using when in a
TLS handshake operation
* Deprecate use of dh-params.pem file
* Document how to create certificates with Post-Quantum
Cryptography compliant algorithms.
* Support loading multiple certificate identities to
allow support for Post-Quantum crypto in parallel
with traditional RSA/ECC
* Add "-run-with exit-with-parent=on" parameter
* Flush pending errors when seeing ENOBUFS with
a zero-copy send attempt
* Fix data buffer parameters in hash & IO channel APIs
to use 'void *'
-----BEGIN PGP SIGNATURE-----
iQIzBAABCAAdFiEE2vOm/bJrYpEtDo4/vobrtBUQT98FAmkIr/8ACgkQvobrtBUQ
T9+2RhAAhEak/krdlTJw8OlJonUop7G5mlLU2TEoX0duRORcFhScsdSwb2pyc/wM
tnwfWXsnsKFItJx1y3STkOICtdNqizGoU3+c7wl4anQBurydu+XTs4ESBtVJtMYr
1lTYvp0HFyKvaXwDWKE+ztltlJiog51tHPDLUIBCnyJysLVqxCHMHmkbG46IPBZo
A2XXxp3j/VBPmhls0JHpbAD4iVE3PChdK7zhyeGe/rld9+0JA12EPCvZ5Uokdj41
aYP/okvnVH1atucoygPdDE3P5GYBKaSXZUWqzfkKhU7FgaF2863Td7ff1ip+WyWN
FFPNEU1hVg+T5hfsZVQmmIFDdSJWqoZaZM/WJVYdrRY4dKUCPnJ9OINbbnhuWz5E
JFmZOPibRZKQ44XcHX49JRfJEBvoq1z9OT1r7HkEP4D9/O7V/riIunbAESMk0sgi
0/fatvdhNKMN6YBQM3mtN3yNOcfRSWFtSy9XS9zDjdpEKT7ui2t9FC0ZNSP0FRkS
aTY31FyacjHwU3zaoh6NoqqpxV9wwHrgsJwNbA/IztjmX/jvGG0Gb/sXVEqM59tR
e3VWTmlmZ1T8OLImh1hG4t+nY+XzI64QpVX8H9RCGm21o28DyTcOnTFK4OyIfWe5
ttnNfEJN8WCVCsA8tcM8yAbZ/0qXrYfiZSO7hq79wE7LvyholAQ=
=9ESG
-----END PGP SIGNATURE-----
Merge tag 'next-pr-pull-request' of https://gitlab.com/berrange/qemu into staging
Merge crypto and other misc fixes / features
* Increase minimum gnutls to 3.7.5
* Increase minimum libgcrypt to 1.9.4
* Increase minimum nettle to 3.7.3
* Drop obsolete in-tree XTS impl
* Fix memory leak when loading certificates
* Remove/reduce duplication when loading certifcates
* Fix possible crash when certificates are unloaded
while an active TLS connection is using when in a
TLS handshake operation
* Deprecate use of dh-params.pem file
* Document how to create certificates with Post-Quantum
Cryptography compliant algorithms.
* Support loading multiple certificate identities to
allow support for Post-Quantum crypto in parallel
with traditional RSA/ECC
* Add "-run-with exit-with-parent=on" parameter
* Flush pending errors when seeing ENOBUFS with
a zero-copy send attempt
* Fix data buffer parameters in hash & IO channel APIs
to use 'void *'
# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEE2vOm/bJrYpEtDo4/vobrtBUQT98FAmkIr/8ACgkQvobrtBUQ
# T9+2RhAAhEak/krdlTJw8OlJonUop7G5mlLU2TEoX0duRORcFhScsdSwb2pyc/wM
# tnwfWXsnsKFItJx1y3STkOICtdNqizGoU3+c7wl4anQBurydu+XTs4ESBtVJtMYr
# 1lTYvp0HFyKvaXwDWKE+ztltlJiog51tHPDLUIBCnyJysLVqxCHMHmkbG46IPBZo
# A2XXxp3j/VBPmhls0JHpbAD4iVE3PChdK7zhyeGe/rld9+0JA12EPCvZ5Uokdj41
# aYP/okvnVH1atucoygPdDE3P5GYBKaSXZUWqzfkKhU7FgaF2863Td7ff1ip+WyWN
# FFPNEU1hVg+T5hfsZVQmmIFDdSJWqoZaZM/WJVYdrRY4dKUCPnJ9OINbbnhuWz5E
# JFmZOPibRZKQ44XcHX49JRfJEBvoq1z9OT1r7HkEP4D9/O7V/riIunbAESMk0sgi
# 0/fatvdhNKMN6YBQM3mtN3yNOcfRSWFtSy9XS9zDjdpEKT7ui2t9FC0ZNSP0FRkS
# aTY31FyacjHwU3zaoh6NoqqpxV9wwHrgsJwNbA/IztjmX/jvGG0Gb/sXVEqM59tR
# e3VWTmlmZ1T8OLImh1hG4t+nY+XzI64QpVX8H9RCGm21o28DyTcOnTFK4OyIfWe5
# ttnNfEJN8WCVCsA8tcM8yAbZ/0qXrYfiZSO7hq79wE7LvyholAQ=
# =9ESG
# -----END PGP SIGNATURE-----
# gpg: Signature made Mon 03 Nov 2025 02:37:03 PM CET
# gpg: using RSA key DAF3A6FDB26B62912D0E8E3FBE86EBB415104FDF
# gpg: Good signature from "Daniel P. Berrange <dan@berrange.com>" [unknown]
# gpg: aka "Daniel P. Berrange <berrange@redhat.com>" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg: There is no indication that the signature belongs to the owner.
# Primary key fingerprint: DAF3 A6FD B26B 6291 2D0E 8E3F BE86 EBB4 1510 4FDF
* tag 'next-pr-pull-request' of https://gitlab.com/berrange/qemu: (32 commits)
docs: creation of x509 certs compliant with post-quantum crypto
crypto: support upto 5 parallel certificate identities
crypto: expand logic to cope with multiple certificate identities
crypto: avoid loading the identity certs twice
crypto: avoid loading the CA certs twice
crypto: deprecate use of external dh-params.pem file
crypto: make TLS credentials structs private
crypto: fix lifecycle handling of gnutls credentials objects
crypto: introduce a wrapper around gnutls credentials
crypto: introduce method for reloading TLS creds
crypto: reduce duplication in handling TLS priority strings
crypto: remove duplication loading x509 CA cert
crypto: shorten the endpoint == server check in TLS creds
crypto: move release of DH parameters into TLS creds parent
crypto: remove needless indirection via parent_obj field
crypto: use g_autofree when loading x509 credentials
crypto: move check for TLS creds 'dir' property
crypto: remove redundant access() checks before loading certs
crypto: replace stat() with access() for credential checks
crypto: add missing free of certs array
...
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
commit
e9c692eabb
42 changed files with 1216 additions and 1533 deletions
|
|
@ -122,7 +122,7 @@ int qcrypto_hash_bytesv(QCryptoHashAlgo alg,
|
|||
* Returns: 0 on success, -1 on error
|
||||
*/
|
||||
int qcrypto_hash_bytes(QCryptoHashAlgo alg,
|
||||
const char *buf,
|
||||
const void *buf,
|
||||
size_t len,
|
||||
uint8_t **result,
|
||||
size_t *resultlen,
|
||||
|
|
@ -180,7 +180,7 @@ int qcrypto_hash_updatev(QCryptoHash *hash,
|
|||
* Returns: 0 on success, -1 on error
|
||||
*/
|
||||
int qcrypto_hash_update(QCryptoHash *hash,
|
||||
const char *buf,
|
||||
const void *buf,
|
||||
size_t len,
|
||||
Error **errp);
|
||||
|
||||
|
|
@ -289,7 +289,7 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(QCryptoHash, qcrypto_hash_free)
|
|||
* Returns: 0 on success, -1 on error
|
||||
*/
|
||||
int qcrypto_hash_digest(QCryptoHashAlgo alg,
|
||||
const char *buf,
|
||||
const void *buf,
|
||||
size_t len,
|
||||
char **digest,
|
||||
Error **errp);
|
||||
|
|
@ -335,7 +335,7 @@ int qcrypto_hash_base64v(QCryptoHashAlgo alg,
|
|||
* Returns: 0 on success, -1 on error
|
||||
*/
|
||||
int qcrypto_hash_base64(QCryptoHashAlgo alg,
|
||||
const char *buf,
|
||||
const void *buf,
|
||||
size_t len,
|
||||
char **base64,
|
||||
Error **errp);
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ int qcrypto_hmac_bytesv(QCryptoHmac *hmac,
|
|||
* 0 on success, -1 on error
|
||||
*/
|
||||
int qcrypto_hmac_bytes(QCryptoHmac *hmac,
|
||||
const char *buf,
|
||||
const void *buf,
|
||||
size_t len,
|
||||
uint8_t **result,
|
||||
size_t *resultlen,
|
||||
|
|
@ -187,7 +187,7 @@ int qcrypto_hmac_digestv(QCryptoHmac *hmac,
|
|||
* Returns: 0 on success, -1 on error
|
||||
*/
|
||||
int qcrypto_hmac_digest(QCryptoHmac *hmac,
|
||||
const char *buf,
|
||||
const void *buf,
|
||||
size_t len,
|
||||
char **digest,
|
||||
Error **errp);
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ typedef bool (*CryptoTLSCredsReload)(QCryptoTLSCreds *, Error **);
|
|||
struct QCryptoTLSCredsClass {
|
||||
ObjectClass parent_class;
|
||||
CryptoTLSCredsReload reload;
|
||||
const char *prioritySuffix;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -64,4 +65,29 @@ bool qcrypto_tls_creds_check_endpoint(QCryptoTLSCreds *creds,
|
|||
QCryptoTLSCredsEndpoint endpoint,
|
||||
Error **errp);
|
||||
|
||||
|
||||
/**
|
||||
* qcrypto_tls_creds_get_priority:
|
||||
* @creds: pointer to a TLS credentials object
|
||||
*
|
||||
* Get the TLS credentials priority string. The caller
|
||||
* must free the returned string when no longer required.
|
||||
*
|
||||
* Returns: a non-NULL priority string
|
||||
*/
|
||||
char *qcrypto_tls_creds_get_priority(QCryptoTLSCreds *creds);
|
||||
|
||||
|
||||
/**
|
||||
* qcrypto_tls_creds_reload:
|
||||
* @creds: pointer to a TLS credentials object
|
||||
* @errp: pointer to a NULL-initialized error object
|
||||
*
|
||||
* Request a reload of the TLS credentials, if supported
|
||||
*
|
||||
* Returns: true on success, false on error or if not supported
|
||||
*/
|
||||
bool qcrypto_tls_creds_reload(QCryptoTLSCreds *creds,
|
||||
Error **errp);
|
||||
|
||||
#endif /* QCRYPTO_TLSCREDS_H */
|
||||
|
|
|
|||
|
|
@ -37,7 +37,13 @@ typedef struct QCryptoTLSCredsX509Class QCryptoTLSCredsX509Class;
|
|||
#define QCRYPTO_TLS_CREDS_X509_SERVER_CERT "server-cert.pem"
|
||||
#define QCRYPTO_TLS_CREDS_X509_CLIENT_KEY "client-key.pem"
|
||||
#define QCRYPTO_TLS_CREDS_X509_CLIENT_CERT "client-cert.pem"
|
||||
#define QCRYPTO_TLS_CREDS_X509_SERVER_KEY_N "server-key-%zu.pem"
|
||||
#define QCRYPTO_TLS_CREDS_X509_SERVER_CERT_N "server-cert-%zu.pem"
|
||||
#define QCRYPTO_TLS_CREDS_X509_CLIENT_KEY_N "client-key-%zu.pem"
|
||||
#define QCRYPTO_TLS_CREDS_X509_CLIENT_CERT_N "client-cert-%zu.pem"
|
||||
|
||||
/* Max number of additional cert/key pairs (ie _N constants) */
|
||||
#define QCRYPTO_TLS_CREDS_X509_IDENTITY_MAX 4
|
||||
|
||||
/**
|
||||
* QCryptoTLSCredsX509:
|
||||
|
|
|
|||
|
|
@ -199,11 +199,11 @@ int qcrypto_tls_session_check_credentials(QCryptoTLSSession *sess,
|
|||
* These must return QCRYPTO_TLS_SESSION_ERR_BLOCK if the I/O
|
||||
* would block, but on other errors, must fill 'errp'
|
||||
*/
|
||||
typedef ssize_t (*QCryptoTLSSessionWriteFunc)(const char *buf,
|
||||
typedef ssize_t (*QCryptoTLSSessionWriteFunc)(const void *buf,
|
||||
size_t len,
|
||||
void *opaque,
|
||||
Error **errp);
|
||||
typedef ssize_t (*QCryptoTLSSessionReadFunc)(char *buf,
|
||||
typedef ssize_t (*QCryptoTLSSessionReadFunc)(void *buf,
|
||||
size_t len,
|
||||
void *opaque,
|
||||
Error **errp);
|
||||
|
|
|
|||
|
|
@ -1,82 +0,0 @@
|
|||
/*
|
||||
* QEMU Crypto XTS cipher mode
|
||||
*
|
||||
* Copyright (c) 2015-2016 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This code is originally derived from public domain / WTFPL code in
|
||||
* LibTomCrypt crytographic library http://libtom.org. The XTS code
|
||||
* was donated by Elliptic Semiconductor Inc (www.ellipticsemi.com)
|
||||
* to the LibTom Projects
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef QCRYPTO_XTS_H
|
||||
#define QCRYPTO_XTS_H
|
||||
|
||||
|
||||
#define XTS_BLOCK_SIZE 16
|
||||
|
||||
typedef void xts_cipher_func(const void *ctx,
|
||||
size_t length,
|
||||
uint8_t *dst,
|
||||
const uint8_t *src);
|
||||
|
||||
/**
|
||||
* xts_decrypt:
|
||||
* @datactx: the cipher context for data decryption
|
||||
* @tweakctx: the cipher context for tweak decryption
|
||||
* @encfunc: the cipher function for encryption
|
||||
* @decfunc: the cipher function for decryption
|
||||
* @iv: the initialization vector tweak of XTS_BLOCK_SIZE bytes
|
||||
* @length: the length of @dst and @src
|
||||
* @dst: buffer to hold the decrypted plaintext
|
||||
* @src: buffer providing the ciphertext
|
||||
*
|
||||
* Decrypts @src into @dst
|
||||
*/
|
||||
void xts_decrypt(const void *datactx,
|
||||
const void *tweakctx,
|
||||
xts_cipher_func *encfunc,
|
||||
xts_cipher_func *decfunc,
|
||||
uint8_t *iv,
|
||||
size_t length,
|
||||
uint8_t *dst,
|
||||
const uint8_t *src);
|
||||
|
||||
/**
|
||||
* xts_decrypt:
|
||||
* @datactx: the cipher context for data encryption
|
||||
* @tweakctx: the cipher context for tweak encryption
|
||||
* @encfunc: the cipher function for encryption
|
||||
* @decfunc: the cipher function for decryption
|
||||
* @iv: the initialization vector tweak of XTS_BLOCK_SIZE bytes
|
||||
* @length: the length of @dst and @src
|
||||
* @dst: buffer to hold the encrypted ciphertext
|
||||
* @src: buffer providing the plaintext
|
||||
*
|
||||
* Decrypts @src into @dst
|
||||
*/
|
||||
void xts_encrypt(const void *datactx,
|
||||
const void *tweakctx,
|
||||
xts_cipher_func *encfunc,
|
||||
xts_cipher_func *decfunc,
|
||||
uint8_t *iv,
|
||||
size_t length,
|
||||
uint8_t *dst,
|
||||
const uint8_t *src);
|
||||
|
||||
|
||||
#endif /* QCRYPTO_XTS_H */
|
||||
|
|
@ -49,6 +49,12 @@ struct QIOChannelSocket {
|
|||
socklen_t remoteAddrLen;
|
||||
ssize_t zero_copy_queued;
|
||||
ssize_t zero_copy_sent;
|
||||
bool blocking;
|
||||
/**
|
||||
* This flag indicates whether any new data was successfully sent with
|
||||
* zerocopy since the last qio_channel_socket_flush() call.
|
||||
*/
|
||||
bool new_zero_copy_sent_success;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -437,7 +437,7 @@ ssize_t qio_channel_writev(QIOChannel *ioc,
|
|||
* a single memory region.
|
||||
*/
|
||||
ssize_t qio_channel_read(QIOChannel *ioc,
|
||||
char *buf,
|
||||
void *buf,
|
||||
size_t buflen,
|
||||
Error **errp);
|
||||
|
||||
|
|
@ -453,7 +453,7 @@ ssize_t qio_channel_read(QIOChannel *ioc,
|
|||
* single memory region.
|
||||
*/
|
||||
ssize_t qio_channel_write(QIOChannel *ioc,
|
||||
const char *buf,
|
||||
const void *buf,
|
||||
size_t buflen,
|
||||
Error **errp);
|
||||
|
||||
|
|
@ -475,7 +475,7 @@ ssize_t qio_channel_write(QIOChannel *ioc,
|
|||
* without data, or -1 on error
|
||||
*/
|
||||
int coroutine_mixed_fn qio_channel_read_all_eof(QIOChannel *ioc,
|
||||
char *buf,
|
||||
void *buf,
|
||||
size_t buflen,
|
||||
Error **errp);
|
||||
|
||||
|
|
@ -495,7 +495,7 @@ int coroutine_mixed_fn qio_channel_read_all_eof(QIOChannel *ioc,
|
|||
* Returns: 0 if all bytes were read, or -1 on error
|
||||
*/
|
||||
int coroutine_mixed_fn qio_channel_read_all(QIOChannel *ioc,
|
||||
char *buf,
|
||||
void *buf,
|
||||
size_t buflen,
|
||||
Error **errp);
|
||||
|
||||
|
|
@ -514,7 +514,7 @@ int coroutine_mixed_fn qio_channel_read_all(QIOChannel *ioc,
|
|||
* Returns: 0 if all bytes were written, or -1 on error
|
||||
*/
|
||||
int coroutine_mixed_fn qio_channel_write_all(QIOChannel *ioc,
|
||||
const char *buf,
|
||||
const void *buf,
|
||||
size_t buflen,
|
||||
Error **errp);
|
||||
|
||||
|
|
@ -595,7 +595,7 @@ ssize_t qio_channel_pwritev(QIOChannel *ioc, const struct iovec *iov,
|
|||
* flag QIO_CHANNEL_FEATURE_SEEKABLE prior to calling this method.
|
||||
*
|
||||
*/
|
||||
ssize_t qio_channel_pwrite(QIOChannel *ioc, char *buf, size_t buflen,
|
||||
ssize_t qio_channel_pwrite(QIOChannel *ioc, void *buf, size_t buflen,
|
||||
off_t offset, Error **errp);
|
||||
|
||||
/**
|
||||
|
|
@ -631,7 +631,7 @@ ssize_t qio_channel_preadv(QIOChannel *ioc, const struct iovec *iov,
|
|||
* flag QIO_CHANNEL_FEATURE_SEEKABLE prior to calling this method.
|
||||
*
|
||||
*/
|
||||
ssize_t qio_channel_pread(QIOChannel *ioc, char *buf, size_t buflen,
|
||||
ssize_t qio_channel_pread(QIOChannel *ioc, void *buf, size_t buflen,
|
||||
off_t offset, Error **errp);
|
||||
|
||||
/**
|
||||
|
|
|
|||
57
include/qemu/exit-with-parent.h
Normal file
57
include/qemu/exit-with-parent.h
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
* Originally derived from nbdkit common/utils/exit-with-parent.h
|
||||
* Copyright Red Hat
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* * Neither the name of Red Hat nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef NBDKIT_EXIT_WITH_PARENT_H
|
||||
#define NBDKIT_EXIT_WITH_PARENT_H
|
||||
|
||||
/* Test if the feature is available on the platform. */
|
||||
static inline bool can_exit_with_parent(void)
|
||||
{
|
||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__)
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* --exit-with-parent: kill the current process if the parent exits.
|
||||
* This may return -1 on error.
|
||||
*
|
||||
* Note this will abort on platforms where can_exit_with_parent()
|
||||
* returned false.
|
||||
*/
|
||||
extern int set_exit_with_parent(void);
|
||||
|
||||
#endif /* NBDKIT_EXIT_WITH_PARENT_H */
|
||||
Loading…
Add table
Add a link
Reference in a new issue