crypto: Make QCryptoTLSCreds* structures private
Subsystems (2)
v4 cover crypto: Make QCryptoTLSCreds* structures private
Follow Daniel suggestion to simplify qcrypto TLS implementations, aiming to solve the OSX build failure.
Since v3:
- Added missing @errp docstring description
Since v2:
- Add Error* argument (Daniel)
- Move structure definitions to "tlscredspriv.h"
Philippe Mathieu-Daudé (7):
crypto/tlscreds: Introduce qcrypto_tls_creds_check_endpoint() helper block/nbd: Use qcrypto_tls_creds_check_endpoint() chardev/socket: Use qcrypto_tls_creds_check_endpoint() migration/tls: Use qcrypto_tls_creds_check_endpoint() crypto/tlssession: Introduce qcrypto_tls_creds_check_endpoint() helper ui/vnc: Use qcrypto_tls_session_check_role()
crypto: Make QCryptoTLSCreds* structures private
crypto/tlscredspriv.h | 45 ++++++++++++++++++++++++++++++ include/crypto/tls-cipher-suites.h | 6 ---- include/crypto/tlscreds.h | 30 ++++++++++---------- include/crypto/tlscredsanon.h | 12 -------- include/crypto/tlscredspsk.h | 12 -------- include/crypto/tlscredsx509.h | 10 ------- include/crypto/tlssession.h | 15 ++++++++++ block/nbd.c | 6 ++-- blockdev-nbd.c | 6 ++-- chardev/char-socket.c | 18 ++++-------- crypto/tls-cipher-suites.c | 7 +++++ crypto/tlscreds.c | 12 ++++++++ crypto/tlscredsanon.c | 2 ++ crypto/tlscredspsk.c | 2 ++ crypto/tlscredsx509.c | 1 + crypto/tlssession.c | 8 ++++++ migration/tls.c | 6 +--- ui/vnc.c | 6 ++-- 18 files changed, 122 insertions(+), 82 deletions(-)
Signature · 1 line
2.31.1
PATCH v4 1/7 crypto/tlscreds: Introduce qcrypto_tls_creds_check_endpoint() helper
Introduce the qcrypto_tls_creds_check_endpoint() helper to access QCryptoTLSCreds internal 'endpoint' field.
--- include/crypto/tlscreds.h | 14 ++++++++++++++ crypto/tlscreds.c | 12 ++++++++++++ 2 files changed, 26 insertions(+)
include/crypto/tlscreds.h +14 -0
@@ -65,5 +65,19 @@ struct QCryptoTLSCredsClass { CryptoTLSCredsReload reload; }; +/** +* qcrypto_tls_creds_check_endpoint: +* @creds: pointer to a TLS credentials object +* @endpoint: type of network endpoint that will be using the credentials +* @errp: pointer to a NULL-initialized error object +* +* Check whether the credentials is setup according to +* the type of @endpoint argument. +* +* Returns true if the credentials is setup for the endpoint, false otherwise +*/ +bool qcrypto_tls_creds_check_endpoint (QCryptoTLSCreds *creds, +QCryptoTLSCredsEndpoint endpoint, +Error **errp);#endif /* QCRYPTO_TLSCREDS_H */
crypto/tlscreds.c +12 -0
@@ -20,6 +20,7 @@#include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi-types-crypto.h" #include "qemu/module.h" #include "tlscredspriv.h" #include "trace.h"
@@ -259,6 +260,17 @@ qcrypto_tls_creds_finalize(Object *obj)g_free (creds->priority); } +bool qcrypto_tls_creds_check_endpoint (QCryptoTLSCreds *creds, +QCryptoTLSCredsEndpoint endpoint, +Error **errp) +{ +if (creds->endpoint != endpoint) { +error_setg (errp,"Expected TLS credentials for a %s endpoint" , +QCryptoTLSCredsEndpoint_str (endpoint)); +return false; + } +return true; +}static const TypeInfo qcrypto_tls_creds_info = { .parent =TYPE_OBJECT ,
Signature · 1 line
2.31.1
Re: [PATCH v4 1/7] crypto/tlscreds: Introduce qcrypto_tls_creds_check_endpoint() helper
Quoted 8 lines · Philippe Mathieu-Daudé
Introduce the
qcrypto_tls_creds_check_endpoint()helper to access QCryptoTLSCreds internal 'endpoint' field.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- include/crypto/tlscreds.h | 14 ++++++++++++++ crypto/tlscreds.c | 12 ++++++++++++ 2 files changed, 26 insertions(+)
r~
Re: [PATCH v4 1/7] crypto/tlscreds: Introduce qcrypto_tls_creds_check_endpoint() helper
In reply to Philippe Mathieu-DaudéQuoted 8 lines · Philippe Mathieu-Daudé
Introduce the
qcrypto_tls_creds_check_endpoint()helper to access QCryptoTLSCreds internal 'endpoint' field.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/crypto/tlscreds.h | 14 ++++++++++++++ crypto/tlscreds.c | 12 ++++++++++++ 2 files changed, 26 insertions(+)
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
PATCH v4 2/7 block/nbd: Use qcrypto_tls_creds_check_endpoint()
In reply to Philippe Mathieu-DaudéAvoid accessing QCryptoTLSCreds internals by using the qcrypto_tls_creds_check_endpoint() helper.
--- block/nbd.c | 6 +++--- blockdev-nbd.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)
block/nbd.c +3 -3
@@ -2159,9 +2159,9 @@ static QCryptoTLSCreds *nbd_get_tls_creds(const char *id, Error **errp)return NULL ; } -if (creds->endpoint !=QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT ) { -error_setg (errp, -"Expecting TLS credentials with a client endpoint" ); +if (!qcrypto_tls_creds_check_endpoint (creds, +QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT , + errp)) {return NULL ; }object_ref (obj);
blockdev-nbd.c +3 -3
@@ -108,9 +108,9 @@ static QCryptoTLSCreds *nbd_get_tls_creds(const char *id, Error **errp)return NULL ; } -if (creds->endpoint !=QCRYPTO_TLS_CREDS_ENDPOINT_SERVER ) { -error_setg (errp, -"Expecting TLS credentials with a server endpoint" ); +if (!qcrypto_tls_creds_check_endpoint (creds, +QCRYPTO_TLS_CREDS_ENDPOINT_SERVER , + errp)) {return NULL ; }object_ref (obj);
Signature · 1 line
2.31.1
Re: [PATCH v4 2/7] block/nbd: Use qcrypto_tls_creds_check_endpoint()
Quoted 8 lines · Philippe Mathieu-Daudé
Avoid accessing QCryptoTLSCreds internals by using the
qcrypto_tls_creds_check_endpoint()helper.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- block/nbd.c | 6 +++--- blockdev-nbd.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)
r~
Re: [PATCH v4 2/7] block/nbd: Use qcrypto_tls_creds_check_endpoint()
In reply to Philippe Mathieu-DaudéQuoted 8 lines · Philippe Mathieu-Daudé
Avoid accessing QCryptoTLSCreds internals by using the
qcrypto_tls_creds_check_endpoint()helper.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- block/nbd.c | 6 +++--- blockdev-nbd.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
PATCH v4 3/7 chardev/socket: Use qcrypto_tls_creds_check_endpoint()
In reply to Philippe Mathieu-DaudéAvoid accessing QCryptoTLSCreds internals by using the qcrypto_tls_creds_check_endpoint() helper.
--- chardev/char-socket.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
chardev/char-socket.c +6 -12
@@ -1402,18 +1402,12 @@ static void qmp_chardev_open_socket(Chardev *chr,return ; }object_ref (OBJECT (s->tls_creds)); -if (is_listen) { -if (s->tls_creds->endpoint !=QCRYPTO_TLS_CREDS_ENDPOINT_SERVER ) { -error_setg (errp,"%s" , -"Expected TLS credentials for server endpoint" ); -return ; - } - }else { -if (s->tls_creds->endpoint !=QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT ) { -error_setg (errp,"%s" , -"Expected TLS credentials for client endpoint" ); -return ; - } +if (!qcrypto_tls_creds_check_endpoint (s->tls_creds, + is_listen + ?QCRYPTO_TLS_CREDS_ENDPOINT_SERVER + :QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT , + errp)) { +return ; } } s->tls_authz =g_strdup (sock->tls_authz);
Signature · 1 line
2.31.1
Re: [PATCH v4 3/7] chardev/socket: Use qcrypto_tls_creds_check_endpoint()
Quoted 7 lines · Philippe Mathieu-Daudé
Avoid accessing QCryptoTLSCreds internals by using the
qcrypto_tls_creds_check_endpoint()helper.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- chardev/char-socket.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
r~
Re: [PATCH v4 3/7] chardev/socket: Use qcrypto_tls_creds_check_endpoint()
In reply to Philippe Mathieu-DaudéQuoted 7 lines · Philippe Mathieu-Daudé
Avoid accessing QCryptoTLSCreds internals by using the
qcrypto_tls_creds_check_endpoint()helper.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- chardev/char-socket.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
PATCH v4 4/7 migration/tls: Use qcrypto_tls_creds_check_endpoint()
In reply to Philippe Mathieu-DaudéAvoid accessing QCryptoTLSCreds internals by using the qcrypto_tls_creds_check_endpoint() helper.
--- migration/tls.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
migration/tls.c +1 -5
@@ -49,11 +49,7 @@ migration_tls_get_creds(MigrationState *s, s->parameters.tls_creds);return NULL ; } -if (ret->endpoint != endpoint) { -error_setg (errp, -"Expected TLS credentials for a %s endpoint" , - endpoint ==QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT ? -"client" :"server" ); +if (!qcrypto_tls_creds_check_endpoint (ret, endpoint, errp)) {return NULL ; }
Signature · 1 line
2.31.1
Re: [PATCH v4 4/7] migration/tls: Use qcrypto_tls_creds_check_endpoint()
Quoted 7 lines · Philippe Mathieu-Daudé
Avoid accessing QCryptoTLSCreds internals by using the
qcrypto_tls_creds_check_endpoint()helper.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- migration/tls.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
r~
Re: [PATCH v4 4/7] migration/tls: Use qcrypto_tls_creds_check_endpoint()
In reply to Philippe Mathieu-DaudéQuoted 7 lines · Philippe Mathieu-Daudé
Avoid accessing QCryptoTLSCreds internals by using the
qcrypto_tls_creds_check_endpoint()helper.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- migration/tls.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
PATCH v4 5/7 crypto/tlssession: Introduce qcrypto_tls_creds_check_endpoint() helper
In reply to Philippe Mathieu-DaudéIntroduce the qcrypto_tls_creds_check_endpoint() helper to avoid accessing QCryptoTLSCreds internal 'endpoint' field directly.
--- include/crypto/tlssession.h | 15 +++++++++++++++ crypto/tlssession.c | 7 +++++++ 2 files changed, 22 insertions(+)
include/crypto/tlssession.h +15 -0
@@ -162,6 +162,21 @@ void qcrypto_tls_session_free(QCryptoTLSSession *sess);G_DEFINE_AUTOPTR_CLEANUP_FUNC (QCryptoTLSSession, qcrypto_tls_session_free) +/** +* qcrypto_tls_session_check_role: +* @creds: pointer to a TLS credentials object +* @endpoint: role of the TLS session, client or server +* @errp: pointer to a NULL-initialized error object +* +* Check whether the session object operates according to +* the role of the @endpoint argument. +* +* Returns true if the session is setup for the endpoint role, false otherwise + */ +bool qcrypto_tls_session_check_role (QCryptoTLSCreds *creds, +QCryptoTLSCredsEndpoint endpoint, +Error **errp); +/** * qcrypto_tls_session_check_credentials: * @sess: the TLS session object
crypto/tlssession.c +7 -0
@@ -640,3 +640,10 @@ qcrypto_tls_session_get_peer_name(QCryptoTLSSession *sess) }#endif + +bool qcrypto_tls_session_check_role (QCryptoTLSCreds *creds, +QCryptoTLSCredsEndpoint endpoint, +Error **errp) +{ +return qcrypto_tls_creds_check_endpoint (creds, endpoint, errp); +}
Signature · 1 line
2.31.1
Re: [PATCH v4 5/7] crypto/tlssession: Introduce qcrypto_tls_creds_check_endpoint() helper
Quoted 3 lines · Philippe Mathieu-Daudé
Introduce the
qcrypto_tls_creds_check_endpoint()helper to avoid accessing QCryptoTLSCreds internal 'endpoint' field directly.
I don't understand this one. Comment ...
crypto/tlssession.c qcrypto_tls_session_get_peer_name(QCryptoTLSSession *sess) · line 649
Quoted 6 lines
crypto/tlssession.c +6
-0+bool qcrypto_tls_session_check_role (QCryptoTLSCreds *creds, +QCryptoTLSCredsEndpoint endpoint, +Error **errp) +{ +return qcrypto_tls_creds_check_endpoint (creds, endpoint, errp); +}
... doesn't match the function.
The new function is a pure forwarder, and begs the question of why the caller isn't using qcrypto_tls_creds_check_endpoint directly.
r~
Re: [PATCH v4 5/7] crypto/tlssession: Introduce qcrypto_tls_creds_check_endpoint() helper
Quoted 16 lines · Richard Henderson
Quoted 3 lines · Philippe Mathieu-Daudé
Introduce the
qcrypto_tls_creds_check_endpoint()helper to avoid accessing QCryptoTLSCreds internal 'endpoint' field directly.I don't understand this one. Comment ...
crypto/tlssession.c qcrypto_tls_session_get_peer_name(QCryptoTLSSession *sess) · line 649
Quoted 6 lines
crypto/tlssession.c +6
-0+bool qcrypto_tls_session_check_role (QCryptoTLSCreds *creds, + QCryptoTLSCredsEndpoint endpoint, + Error **errp) +{ + return qcrypto_tls_creds_check_endpoint(creds, endpoint, errp); +}... doesn't match the function.
Quoted 2 lines
The new function is a pure forwarder, and begs the question of why the caller isn't using
qcrypto_tls_creds_check_endpointdirectly.
I tried to follow the maintainer/subsystem style (I was also tempted to use qcrypto_tls_creds_check_endpoint directly). ui/vnc uses the TLS "session" API and not the "creds" one. Daniel, what is your preference?
Re: [PATCH v4 5/7] crypto/tlssession: Introduce qcrypto_tls_creds_check_endpoint() helper
Quoted 17 lines · Philippe Mathieu-Daudé
Quoted 16 lines · Richard Henderson
Quoted 3 lines · Philippe Mathieu-Daudé
Introduce the
qcrypto_tls_creds_check_endpoint()helper to avoid accessing QCryptoTLSCreds internal 'endpoint' field directly.I don't understand this one. Comment ...
crypto/tlssession.c qcrypto_tls_session_get_peer_name(QCryptoTLSSession *sess) · line 649
Quoted 6 lines
crypto/tlssession.c +6
-0+bool qcrypto_tls_session_check_role (QCryptoTLSCreds *creds, + QCryptoTLSCredsEndpoint endpoint, + Error **errp) +{ + return qcrypto_tls_creds_check_endpoint(creds, endpoint, errp); +}... doesn't match the function.
Quoted 6 lines
Quoted 2 lines
The new function is a pure forwarder, and begs the question of why the caller isn't using
qcrypto_tls_creds_check_endpointdirectly.I tried to follow the maintainer/subsystem style (I was also tempted to use
qcrypto_tls_creds_check_endpointdirectly). ui/vnc uses the TLS "session" API and not the "creds" one. Daniel, what is your preference?
I think we don't need this extra function - just use the function from earlier directly.
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH v4 5/7] crypto/tlssession: Introduce qcrypto_tls_creds_check_endpoint() helper
Quoted 21 lines · Daniel P. Berrangé
Quoted 20 lines · Philippe Mathieu-Daudé
Quoted 18 lines · Richard Henderson
Quoted 3 lines · Philippe Mathieu-Daudé
Introduce the
qcrypto_tls_creds_check_endpoint()helper to avoid accessing QCryptoTLSCreds internal 'endpoint' field directly.I don't understand this one. Comment ...
crypto/tlssession.c qcrypto_tls_session_get_peer_name(QCryptoTLSSession *sess) · line 649
Quoted 6 lines
crypto/tlssession.c +6
-0+bool qcrypto_tls_session_check_role (QCryptoTLSCreds *creds, + QCryptoTLSCredsEndpoint endpoint, + Error **errp) +{ + return qcrypto_tls_creds_check_endpoint(creds, endpoint, errp); +}... doesn't match the function.
The new function is a pure forwarder, and begs the question of why the caller isn't using
qcrypto_tls_creds_check_endpointdirectly.
Quoted 6 lines
Quoted 3 lines
I tried to follow the maintainer/subsystem style (I was also tempted to use
qcrypto_tls_creds_check_endpointdirectly). ui/vnc uses the TLS "session" API and not the "creds" one. Daniel, what is your preference?I think we don't need this extra function - just use the function from earlier directly.
Great, simpler :)
PATCH v4 6/7 ui/vnc: Use qcrypto_tls_session_check_role()
In reply to Philippe Mathieu-DaudéAvoid accessing QCryptoTLSCreds internals by using the qcrypto_tls_session_check_role() helper.
--- ui/vnc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
ui/vnc.c +3 -3
@@ -4080,9 +4080,9 @@ void vnc_display_open(const char *id, Error **errp) }object_ref (OBJECT (vd->tlscreds)); -if (vd->tlscreds->endpoint !=QCRYPTO_TLS_CREDS_ENDPOINT_SERVER ) { -error_setg (errp, -"Expecting TLS credentials with a server endpoint" ); +if (!qcrypto_tls_session_check_role (vd->tlscreds, +QCRYPTO_TLS_CREDS_ENDPOINT_SERVER , + errp)) { goto fail; } }
Signature · 1 line
2.31.1
PATCH v4 7/7 crypto: Make QCryptoTLSCreds* structures private
In reply to Philippe Mathieu-DaudéCode consuming the "crypto/tlscreds*.h" APIs doesn't need to access its internals. Move the structure definitions to the "tlscredspriv.h" private header (only accessible by implementations). The public headers (in include/) still forward-declare the structures typedef.
This solves a bug introduced by commit 7de2e856533 which made migration/qemu-file-channel.c include "io/channel-tls.h", itself sometime depends on GNUTLS, leading to build failure on OSX:
[2/35] Compiling C object libmigration.fa.p/migration_qemu-file-channel.c.o
FAILED: libmigration.fa.p/migration_qemu-file-channel.c.o
cc -Ilibmigration.fa.p -I. -I.. -Iqapi [ ... ] -o libmigration.fa.p/migration_qemu-file-channel.c.o -c ../migration/qemu-file-channel.c In file included from ../migration/qemu-file-channel.c:29:
In file included from include/io/channel-tls.h:26:
In file included from include/crypto/tlssession.h:24:
include/crypto/tlscreds.h:28:10: fatal error: 'gnutls/gnutls.h' file not found
#include <gnutls/gnutls.h>
^~~~~~~~~~~~~~~~~1 error generated.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/407
--- crypto/tlscredspriv.h | 45 ++++++++++++++++++++++++++++++ include/crypto/tls-cipher-suites.h | 6 ---- include/crypto/tlscreds.h | 16 ----------- include/crypto/tlscredsanon.h | 12 -------- include/crypto/tlscredspsk.h | 12 -------- include/crypto/tlscredsx509.h | 10 ------- crypto/tls-cipher-suites.c | 7 +++++ crypto/tlscredsanon.c | 2 ++ crypto/tlscredspsk.c | 2 ++ crypto/tlscredsx509.c | 1 + crypto/tlssession.c | 1 + 11 files changed, 58 insertions(+), 56 deletions(-)
crypto/tlscredspriv.h +45 -0
@@ -23,6 +23,51 @@#include "crypto/tlscreds.h" +#ifdef CONFIG_GNUTLS +#include <gnutls/gnutls.h> +#endif + +struct QCryptoTLSCreds { +Object parent_obj; +char *dir; +QCryptoTLSCredsEndpoint endpoint; +#ifdef CONFIG_GNUTLS +gnutls_dh_params_t dh_params; +#endif +bool verifyPeer; +char *priority; +}; + +struct QCryptoTLSCredsAnon { +QCryptoTLSCreds parent_obj; +#ifdef CONFIG_GNUTLS +union { +gnutls_anon_server_credentials_t server; +gnutls_anon_client_credentials_t client; + } data; +#endif +}; + +struct QCryptoTLSCredsPSK { +QCryptoTLSCreds parent_obj; +char *username; +#ifdef CONFIG_GNUTLS +union { +gnutls_psk_server_credentials_t server; +gnutls_psk_client_credentials_t client; + } data; +#endif +}; + +struct QCryptoTLSCredsX509 { +QCryptoTLSCreds parent_obj; +#ifdef CONFIG_GNUTLS +gnutls_certificate_credentials_t data; +#endif +bool sanityCheck; +char *passwordid; +}; +#ifdef CONFIG_GNUTLS int qcrypto_tls_creds_get_path(QCryptoTLSCreds *creds,
include/crypto/tls-cipher-suites.h +0 -6
@@ -19,12 +19,6 @@ typedef struct QCryptoTLSCipherSuites QCryptoTLSCipherSuites;DECLARE_INSTANCE_CHECKER (QCryptoTLSCipherSuites,QCRYPTO_TLS_CIPHER_SUITES ,TYPE_QCRYPTO_TLS_CIPHER_SUITES ) -struct QCryptoTLSCipherSuites { -/* <private> */ -QCryptoTLSCreds parent_obj; -/* <public> */ -}; -/** * qcrypto_tls_cipher_suites_get_data: * @obj: pointer to a TLS cipher suites object
include/crypto/tlscreds.h +0 -16
@@ -24,10 +24,6 @@#include "qapi/qapi-types-crypto.h" #include "qom/object.h" -#ifdef CONFIG_GNUTLS -#include <gnutls/gnutls.h> -#endif -#define TYPE_QCRYPTO_TLS_CREDS "tls-creds"typedef struct QCryptoTLSCreds QCryptoTLSCreds ;typedef struct QCryptoTLSCredsClass QCryptoTLSCredsClass ;
@@ -48,18 +44,6 @@ typedef bool (*CryptoTLSCredsReload)(QCryptoTLSCreds *, Error **);* certificate credentials. */ -struct QCryptoTLSCreds { -Object parent_obj; -char *dir; -QCryptoTLSCredsEndpoint endpoint; -#ifdef CONFIG_GNUTLS -gnutls_dh_params_t dh_params; -#endif -bool verifyPeer; -char *priority; -}; - -struct QCryptoTLSCredsClass {ObjectClass parent_class;CryptoTLSCredsReload reload;
include/crypto/tlscredsanon.h +0 -12
@@ -92,18 +92,6 @@ typedef struct QCryptoTLSCredsAnonClass QCryptoTLSCredsAnonClass;* */ - -struct QCryptoTLSCredsAnon { -QCryptoTLSCreds parent_obj; -#ifdef CONFIG_GNUTLS -union { -gnutls_anon_server_credentials_t server; -gnutls_anon_client_credentials_t client; - } data; -#endif -}; - -struct QCryptoTLSCredsAnonClass {QCryptoTLSCredsClass parent_class; };
include/crypto/tlscredspsk.h +0 -12
@@ -87,18 +87,6 @@ typedef struct QCryptoTLSCredsPSKClass QCryptoTLSCredsPSKClass;* The PSK file can be created and managed using psktool. */ -struct QCryptoTLSCredsPSK { -QCryptoTLSCreds parent_obj; -char *username; -#ifdef CONFIG_GNUTLS -union { -gnutls_psk_server_credentials_t server; -gnutls_psk_client_credentials_t client; - } data; -#endif -}; - -struct QCryptoTLSCredsPSKClass {QCryptoTLSCredsClass parent_class; };
include/crypto/tlscredsx509.h +0 -10
@@ -96,16 +96,6 @@ typedef struct QCryptoTLSCredsX509Class QCryptoTLSCredsX509Class;* */ -struct QCryptoTLSCredsX509 { -QCryptoTLSCreds parent_obj; -#ifdef CONFIG_GNUTLS -gnutls_certificate_credentials_t data; -#endif -bool sanityCheck; -char *passwordid; -}; - -struct QCryptoTLSCredsX509Class {QCryptoTLSCredsClass parent_class; };
crypto/tls-cipher-suites.c +7 -0
@@ -14,8 +14,15 @@#include "crypto/tlscreds.h" #include "crypto/tls-cipher-suites.h" #include "hw/nvram/fw_cfg.h" +#include "tlscredspriv.h" #include "trace.h" +struct QCryptoTLSCipherSuites { +/* <private> */ +QCryptoTLSCreds parent_obj; +/* <public> */ +}; +/* * IANA registered TLS ciphers: * https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-4
crypto/tlscredsanon.c +2 -0
@@ -29,6 +29,8 @@#ifdef CONFIG_GNUTLS +#include <gnutls/gnutls.h> + static int qcrypto_tls_creds_anon_load(QCryptoTLSCredsAnon *creds,
crypto/tlscredspsk.c +2 -0
@@ -29,6 +29,8 @@#ifdef CONFIG_GNUTLS +#include <gnutls/gnutls.h> +static int lookup_key (const char *pskfile,const char *username,gnutls_datum_t *key,Error **errp)
crypto/tlscredsx509.c +1 -0
@@ -30,6 +30,7 @@#ifdef CONFIG_GNUTLS +#include <gnutls/gnutls.h> #include <gnutls/x509.h>
crypto/tlssession.c +1 -0
@@ -25,6 +25,7 @@#include "crypto/tlscredsx509.h" #include "qapi/error.h" #include "authz/base.h" +#include "tlscredspriv.h" #include "trace.h" #ifdef CONFIG_GNUTLS
Signature · 1 line
2.31.1
Quoted 74 lines · Philippe Mathieu-Daudé
Code consuming the "
crypto/tlscreds*.h" APIs doesn't need to access its internals. Move the structure definitions to the "tlscredspriv.h" private header (only accessible by implementations). The public headers (ininclude/) still forward-declare the structures typedef.This solves a bug introduced by commit
7de2e856533which mademigration/qemu-file-channel.cinclude "io/channel-tls.h", itself sometime depends on GNUTLS, leading to build failure on OSX:[2/35] Compiling C object
libmigration.fa.p/migration_qemu-file-channel.c.o
FAILED:libmigration.fa.p/migration_qemu-file-channel.c.o
cc -Ilibmigration.fa.p -I. -I.. -Iqapi [ ... ] -olibmigration.fa.p/migration_qemu-file-channel.c.o-c../migration/qemu-file-channel.cIn file included from../migration/qemu-file-channel.c:29:
In file included frominclude/io/channel-tls.h:26:
In file included frominclude/crypto/tlssession.h:24:
include/crypto/tlscreds.h:28:10: fatal error: 'gnutls/gnutls.h' file not found#include <gnutls/gnutls.h> ^~~~~~~~~~~~~~~~~1 error generated.
Reported-by Stefan Weil <[email protected]>Suggested-by Daniel P. Berrangé <[email protected]>Resolves: https://gitlab.com/qemu-project/qemu/-/issues/407
Fixes 7de2e856533 ("yank: Unregister function when using TLS migration")Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- crypto/tlscredspriv.h | 45 ++++++++++++++++++++++++++++++ include/crypto/tls-cipher-suites.h | 6 ---- include/crypto/tlscreds.h | 16 ----------- include/crypto/tlscredsanon.h | 12 -------- include/crypto/tlscredspsk.h | 12 -------- include/crypto/tlscredsx509.h | 10 ------- crypto/tls-cipher-suites.c | 7 +++++ crypto/tlscredsanon.c | 2 ++ crypto/tlscredspsk.c | 2 ++ crypto/tlscredsx509.c | 1 + crypto/tlssession.c | 1 + 11 files changed, 58 insertions(+), 56 deletions(-)crypto/tlscredsanon.c +2
-0@@ -29,6 +29,8 @@#ifdef CONFIG_GNUTLS +#include <gnutls/gnutls.h> + static int qcrypto_tls_creds_anon_load(QCryptoTLSCredsAnon *creds,crypto/tlscredspsk.c +2
-0@@ -29,6 +29,8 @@#ifdef CONFIG_GNUTLS +#include <gnutls/gnutls.h> +static int lookup_key (const char *pskfile,const char *username,gnutls_datum_t *key,Error **errp)crypto/tlscredsx509.c +0
-0
crypto/tlscredsx509.c line 36
Quoted 7 lines
crypto/tlscredsx509.c +1
-0@@ -30,6 +30,7 @@#ifdef CONFIG_GNUTLS +#include <gnutls/gnutls.h> #include <gnutls/x509.h>
I was expecting all these files, and tlscreds.c to include tlscredspriv.h, otherwise how do they see the struct definition they need ?
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 42 lines · Daniel P. Berrangé
Quoted 27 lines · Philippe Mathieu-Daudé
Code consuming the "
crypto/tlscreds*.h" APIs doesn't need to access its internals. Move the structure definitions to the "tlscredspriv.h" private header (only accessible by implementations). The public headers (ininclude/) still forward-declare the structures typedef.This solves a bug introduced by commit
7de2e856533which mademigration/qemu-file-channel.cinclude "io/channel-tls.h", itself sometime depends on GNUTLS, leading to build failure on OSX:[2/35] Compiling C object
libmigration.fa.p/migration_qemu-file-channel.c.o
FAILED:libmigration.fa.p/migration_qemu-file-channel.c.o
cc -Ilibmigration.fa.p -I. -I.. -Iqapi [ ... ] -olibmigration.fa.p/migration_qemu-file-channel.c.o-c../migration/qemu-file-channel.cIn file included from../migration/qemu-file-channel.c:29:
In file included frominclude/io/channel-tls.h:26:
In file included frominclude/crypto/tlssession.h:24:
include/crypto/tlscreds.h:28:10: fatal error: 'gnutls/gnutls.h' file not found#include <gnutls/gnutls.h> ^~~~~~~~~~~~~~~~~1 error generated.
Reported-by Stefan Weil <[email protected]>Suggested-by Daniel P. Berrangé <[email protected]>Resolves: https://gitlab.com/qemu-project/qemu/-/issues/407
Fixes 7de2e856533 ("yank: Unregister function when using TLS migration")Signed-off-by Philippe Mathieu-Daudé <[email protected]>Quoted 13 lines
--- crypto/tlscredspriv.h | 45 ++++++++++++++++++++++++++++++ include/crypto/tls-cipher-suites.h | 6 ---- include/crypto/tlscreds.h | 16 ----------- include/crypto/tlscredsanon.h | 12 -------- include/crypto/tlscredspsk.h | 12 -------- include/crypto/tlscredsx509.h | 10 ------- crypto/tls-cipher-suites.c | 7 +++++ crypto/tlscredsanon.c | 2 ++ crypto/tlscredspsk.c | 2 ++ crypto/tlscredsx509.c | 1 + crypto/tlssession.c | 1 + 11 files changed, 58 insertions(+), 56 deletions(-)
Quoted 3 lines
I was expecting all these files, and
tlscreds.cto includetlscredspriv.h, otherwise how do they see the struct definition they need ?
They already include it:
$ git grep tlscredspriv.h origin/master origin/master:crypto/tlscreds.c:24:#include "tlscredspriv.h" origin/master:crypto/tlscredsanon.c:23:#include "tlscredspriv.h" origin/master:crypto/tlscredspsk.c:23:#include "tlscredspriv.h" origin/master:crypto/tlscredsx509.c:23:#include "tlscredspriv.h"
This is why in this patch I only added it to tls-cipher-suites.c and tlssession.c.
I'll add a comment about it.
Regards,
Phil.
Quoted 55 lines · Philippe Mathieu-Daudé
Quoted 42 lines · Daniel P. Berrangé
Quoted 27 lines · Philippe Mathieu-Daudé
Code consuming the "
crypto/tlscreds*.h" APIs doesn't need to access its internals. Move the structure definitions to the "tlscredspriv.h" private header (only accessible by implementations). The public headers (ininclude/) still forward-declare the structures typedef.This solves a bug introduced by commit
7de2e856533which mademigration/qemu-file-channel.cinclude "io/channel-tls.h", itself sometime depends on GNUTLS, leading to build failure on OSX:[2/35] Compiling C object
libmigration.fa.p/migration_qemu-file-channel.c.o
FAILED:libmigration.fa.p/migration_qemu-file-channel.c.o
cc -Ilibmigration.fa.p -I. -I.. -Iqapi [ ... ] -olibmigration.fa.p/migration_qemu-file-channel.c.o-c../migration/qemu-file-channel.cIn file included from../migration/qemu-file-channel.c:29:
In file included frominclude/io/channel-tls.h:26:
In file included frominclude/crypto/tlssession.h:24:
include/crypto/tlscreds.h:28:10: fatal error: 'gnutls/gnutls.h' file not found#include <gnutls/gnutls.h> ^~~~~~~~~~~~~~~~~1 error generated.
Reported-by Stefan Weil <[email protected]>Suggested-by Daniel P. Berrangé <[email protected]>Resolves: https://gitlab.com/qemu-project/qemu/-/issues/407
Fixes 7de2e856533 ("yank: Unregister function when using TLS migration")Signed-off-by Philippe Mathieu-Daudé <[email protected]>Quoted 13 lines
--- crypto/tlscredspriv.h | 45 ++++++++++++++++++++++++++++++ include/crypto/tls-cipher-suites.h | 6 ---- include/crypto/tlscreds.h | 16 ----------- include/crypto/tlscredsanon.h | 12 -------- include/crypto/tlscredspsk.h | 12 -------- include/crypto/tlscredsx509.h | 10 ------- crypto/tls-cipher-suites.c | 7 +++++ crypto/tlscredsanon.c | 2 ++ crypto/tlscredspsk.c | 2 ++ crypto/tlscredsx509.c | 1 + crypto/tlssession.c | 1 + 11 files changed, 58 insertions(+), 56 deletions(-)Quoted 3 lines
I was expecting all these files, and
tlscreds.cto includetlscredspriv.h, otherwise how do they see the struct definition they need ?They already include it:
$ git grep tlscredspriv.h origin/master origin/master:crypto/tlscreds.c:24:#include "tlscredspriv.h" origin/master:crypto/tlscredsanon.c:23:#include "tlscredspriv.h" origin/master:crypto/tlscredspsk.c:23:#include "tlscredspriv.h" origin/master:crypto/tlscredsx509.c:23:#include "tlscredspriv.h"
Quoted 4 lines
This is why in this patch I only added it to
tls-cipher-suites.candtlssession.c.I'll add a comment about it.
No matter, I'm just being dumb and not remembering my own code. I thought tlscredspriv.h was a new header in your patch, but its just adding to an existing header.
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|