All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/7] crypto: Make QCryptoTLSCreds* structures private
@ 2021-06-16 16:22 Philippe Mathieu-Daudé
  2021-06-16 16:22 ` [PATCH v4 1/7] crypto/tlscreds: Introduce qcrypto_tls_creds_check_endpoint() helper Philippe Mathieu-Daudé
                   ` (6 more replies)
  0 siblings, 7 replies; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-06-16 16:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: Philippe Mathieu-Daudé, Daniel P . Berrangé

Follow Daniel suggestion to simplify qcrypto TLS implementations,\r
aiming to solve the OSX build failure.\r
\r
Since v3:\r
- Added missing @errp docstring description\r
\r
Since v2:\r
- Add Error* argument (Daniel)\r
- Move structure definitions to "tlscredspriv.h"\r
\r
Philippe Mathieu-Daudé (7):\r
  crypto/tlscreds: Introduce qcrypto_tls_creds_check_endpoint() helper\r
  block/nbd: Use qcrypto_tls_creds_check_endpoint()\r
  chardev/socket: Use qcrypto_tls_creds_check_endpoint()\r
  migration/tls: Use qcrypto_tls_creds_check_endpoint()\r
  crypto/tlssession: Introduce qcrypto_tls_creds_check_endpoint() helper\r
  ui/vnc: Use qcrypto_tls_session_check_role()\r
  crypto: Make QCryptoTLSCreds* structures private\r
\r
 crypto/tlscredspriv.h              | 45 ++++++++++++++++++++++++++++++\r
 include/crypto/tls-cipher-suites.h |  6 ----\r
 include/crypto/tlscreds.h          | 30 ++++++++++----------\r
 include/crypto/tlscredsanon.h      | 12 --------\r
 include/crypto/tlscredspsk.h       | 12 --------\r
 include/crypto/tlscredsx509.h      | 10 -------\r
 include/crypto/tlssession.h        | 15 ++++++++++\r
 block/nbd.c                        |  6 ++--\r
 blockdev-nbd.c                     |  6 ++--\r
 chardev/char-socket.c              | 18 ++++--------\r
 crypto/tls-cipher-suites.c         |  7 +++++\r
 crypto/tlscreds.c                  | 12 ++++++++\r
 crypto/tlscredsanon.c              |  2 ++\r
 crypto/tlscredspsk.c               |  2 ++\r
 crypto/tlscredsx509.c              |  1 +\r
 crypto/tlssession.c                |  8 ++++++\r
 migration/tls.c                    |  6 +---\r
 ui/vnc.c                           |  6 ++--\r
 18 files changed, 122 insertions(+), 82 deletions(-)\r
\r
-- \r
2.31.1\r
\r



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

* [PATCH v4 1/7] crypto/tlscreds: Introduce qcrypto_tls_creds_check_endpoint() helper
  2021-06-16 16:22 [PATCH v4 0/7] crypto: Make QCryptoTLSCreds* structures private Philippe Mathieu-Daudé
@ 2021-06-16 16:22 ` Philippe Mathieu-Daudé
  2021-06-16 19:08   ` Richard Henderson
  2021-06-17  9:30   ` Daniel P. Berrangé
  2021-06-16 16:22 ` [PATCH v4 2/7] block/nbd: Use qcrypto_tls_creds_check_endpoint() Philippe Mathieu-Daudé
                   ` (5 subsequent siblings)
  6 siblings, 2 replies; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-06-16 16:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: Philippe Mathieu-Daudé, Daniel P . Berrangé

Introduce the qcrypto_tls_creds_check_endpoint() helper
to access QCryptoTLSCreds internal 'endpoint' field.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 include/crypto/tlscreds.h | 14 ++++++++++++++
 crypto/tlscreds.c         | 12 ++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/include/crypto/tlscreds.h b/include/crypto/tlscreds.h
index d0808e391e9..a14e44fac15 100644
--- a/include/crypto/tlscreds.h
+++ b/include/crypto/tlscreds.h
@@ -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 */
diff --git a/crypto/tlscreds.c b/crypto/tlscreds.c
index b68735f06fe..084ce0d51ae 100644
--- a/crypto/tlscreds.c
+++ b/crypto/tlscreds.c
@@ -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,
-- 
2.31.1



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

* [PATCH v4 2/7] block/nbd: Use qcrypto_tls_creds_check_endpoint()
  2021-06-16 16:22 [PATCH v4 0/7] crypto: Make QCryptoTLSCreds* structures private Philippe Mathieu-Daudé
  2021-06-16 16:22 ` [PATCH v4 1/7] crypto/tlscreds: Introduce qcrypto_tls_creds_check_endpoint() helper Philippe Mathieu-Daudé
@ 2021-06-16 16:22 ` Philippe Mathieu-Daudé
  2021-06-16 19:08   ` Richard Henderson
  2021-06-17  9:31   ` Daniel P. Berrangé
  2021-06-16 16:22 ` [PATCH v4 3/7] chardev/socket: " Philippe Mathieu-Daudé
                   ` (4 subsequent siblings)
  6 siblings, 2 replies; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-06-16 16:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: Philippe Mathieu-Daudé, Daniel P . Berrangé

Avoid accessing QCryptoTLSCreds internals by using
the qcrypto_tls_creds_check_endpoint() helper.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 block/nbd.c    | 6 +++---
 blockdev-nbd.c | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/block/nbd.c b/block/nbd.c
index 616f9ae6c4d..b13a33c3d21 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -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);
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index b264620b98d..bdfa7ed3a5a 100644
--- a/blockdev-nbd.c
+++ b/blockdev-nbd.c
@@ -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);
-- 
2.31.1



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

* [PATCH v4 3/7] chardev/socket: Use qcrypto_tls_creds_check_endpoint()
  2021-06-16 16:22 [PATCH v4 0/7] crypto: Make QCryptoTLSCreds* structures private Philippe Mathieu-Daudé
  2021-06-16 16:22 ` [PATCH v4 1/7] crypto/tlscreds: Introduce qcrypto_tls_creds_check_endpoint() helper Philippe Mathieu-Daudé
  2021-06-16 16:22 ` [PATCH v4 2/7] block/nbd: Use qcrypto_tls_creds_check_endpoint() Philippe Mathieu-Daudé
@ 2021-06-16 16:22 ` Philippe Mathieu-Daudé
  2021-06-16 19:09   ` Richard Henderson
  2021-06-17  9:31   ` Daniel P. Berrangé
  2021-06-16 16:22 ` [PATCH v4 4/7] migration/tls: " Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  6 siblings, 2 replies; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-06-16 16:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: Philippe Mathieu-Daudé, Daniel P . Berrangé

Avoid accessing QCryptoTLSCreds internals by using
the qcrypto_tls_creds_check_endpoint() helper.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 chardev/char-socket.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/chardev/char-socket.c b/chardev/char-socket.c
index daa89fe5d1d..d0fb5459638 100644
--- a/chardev/char-socket.c
+++ b/chardev/char-socket.c
@@ -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);
-- 
2.31.1



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

* [PATCH v4 4/7] migration/tls: Use qcrypto_tls_creds_check_endpoint()
  2021-06-16 16:22 [PATCH v4 0/7] crypto: Make QCryptoTLSCreds* structures private Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2021-06-16 16:22 ` [PATCH v4 3/7] chardev/socket: " Philippe Mathieu-Daudé
@ 2021-06-16 16:22 ` Philippe Mathieu-Daudé
  2021-06-16 19:09   ` Richard Henderson
  2021-06-17  9:32   ` Daniel P. Berrangé
  2021-06-16 16:22 ` [PATCH v4 5/7] crypto/tlssession: Introduce qcrypto_tls_creds_check_endpoint() helper Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  6 siblings, 2 replies; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-06-16 16:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: Philippe Mathieu-Daudé, Daniel P . Berrangé

Avoid accessing QCryptoTLSCreds internals by using
the qcrypto_tls_creds_check_endpoint() helper.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 migration/tls.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/migration/tls.c b/migration/tls.c
index abb149d8325..ca1ea3bbdd4 100644
--- a/migration/tls.c
+++ b/migration/tls.c
@@ -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;
     }
 
-- 
2.31.1



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

* [PATCH v4 5/7] crypto/tlssession: Introduce qcrypto_tls_creds_check_endpoint() helper
  2021-06-16 16:22 [PATCH v4 0/7] crypto: Make QCryptoTLSCreds* structures private Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2021-06-16 16:22 ` [PATCH v4 4/7] migration/tls: " Philippe Mathieu-Daudé
@ 2021-06-16 16:22 ` Philippe Mathieu-Daudé
  2021-06-16 19:12   ` Richard Henderson
  2021-06-16 16:22 ` [PATCH v4 6/7] ui/vnc: Use qcrypto_tls_session_check_role() Philippe Mathieu-Daudé
  2021-06-16 16:22 ` [PATCH v4 7/7] crypto: Make QCryptoTLSCreds* structures private Philippe Mathieu-Daudé
  6 siblings, 1 reply; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-06-16 16:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: Philippe Mathieu-Daudé, Daniel P . Berrangé

Introduce the qcrypto_tls_creds_check_endpoint() helper
to avoid accessing QCryptoTLSCreds internal 'endpoint' field
directly.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 include/crypto/tlssession.h | 15 +++++++++++++++
 crypto/tlssession.c         |  7 +++++++
 2 files changed, 22 insertions(+)

diff --git a/include/crypto/tlssession.h b/include/crypto/tlssession.h
index 15b9cef086c..2fb0bb02d9f 100644
--- a/include/crypto/tlssession.h
+++ b/include/crypto/tlssession.h
@@ -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
diff --git a/crypto/tlssession.c b/crypto/tlssession.c
index 33203e8ca71..4e614b73a28 100644
--- a/crypto/tlssession.c
+++ b/crypto/tlssession.c
@@ -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);
+}
-- 
2.31.1



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

* [PATCH v4 6/7] ui/vnc: Use qcrypto_tls_session_check_role()
  2021-06-16 16:22 [PATCH v4 0/7] crypto: Make QCryptoTLSCreds* structures private Philippe Mathieu-Daudé
                   ` (4 preceding siblings ...)
  2021-06-16 16:22 ` [PATCH v4 5/7] crypto/tlssession: Introduce qcrypto_tls_creds_check_endpoint() helper Philippe Mathieu-Daudé
@ 2021-06-16 16:22 ` Philippe Mathieu-Daudé
  2021-06-16 16:22 ` [PATCH v4 7/7] crypto: Make QCryptoTLSCreds* structures private Philippe Mathieu-Daudé
  6 siblings, 0 replies; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-06-16 16:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: Philippe Mathieu-Daudé, Daniel P . Berrangé

Avoid accessing QCryptoTLSCreds internals by using
the qcrypto_tls_session_check_role() helper.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 ui/vnc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/ui/vnc.c b/ui/vnc.c
index b3d4d7b9a5f..c7c8454b873 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -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;
         }
     }
-- 
2.31.1



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

* [PATCH v4 7/7] crypto: Make QCryptoTLSCreds* structures private
  2021-06-16 16:22 [PATCH v4 0/7] crypto: Make QCryptoTLSCreds* structures private Philippe Mathieu-Daudé
                   ` (5 preceding siblings ...)
  2021-06-16 16:22 ` [PATCH v4 6/7] ui/vnc: Use qcrypto_tls_session_check_role() Philippe Mathieu-Daudé
@ 2021-06-16 16:22 ` Philippe Mathieu-Daudé
  2021-06-17  9:35   ` Daniel P. Berrangé
  6 siblings, 1 reply; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-06-16 16:22 UTC (permalink / raw)
  To: qemu-devel
  Cc: Philippe Mathieu-Daudé, Daniel P . Berrangé, Stefan Weil

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.

Reported-by: Stefan Weil <sw@weilnetz.de>
Suggested-by: Daniel P. Berrangé <berrange@redhat.com>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/407
Fixes: 7de2e856533 ("yank: Unregister function when using TLS migration")
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 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(-)

diff --git a/crypto/tlscredspriv.h b/crypto/tlscredspriv.h
index 39f1a91c413..df9815a2863 100644
--- a/crypto/tlscredspriv.h
+++ b/crypto/tlscredspriv.h
@@ -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,
diff --git a/include/crypto/tls-cipher-suites.h b/include/crypto/tls-cipher-suites.h
index bb9ee53e03a..7eb1b76122d 100644
--- a/include/crypto/tls-cipher-suites.h
+++ b/include/crypto/tls-cipher-suites.h
@@ -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
diff --git a/include/crypto/tlscreds.h b/include/crypto/tlscreds.h
index a14e44fac15..2a8a8570109 100644
--- a/include/crypto/tlscreds.h
+++ b/include/crypto/tlscreds.h
@@ -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;
diff --git a/include/crypto/tlscredsanon.h b/include/crypto/tlscredsanon.h
index 3f464a38095..bd3023f9ea7 100644
--- a/include/crypto/tlscredsanon.h
+++ b/include/crypto/tlscredsanon.h
@@ -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;
 };
diff --git a/include/crypto/tlscredspsk.h b/include/crypto/tlscredspsk.h
index d7e6bdb5edf..bcd07dc4f62 100644
--- a/include/crypto/tlscredspsk.h
+++ b/include/crypto/tlscredspsk.h
@@ -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;
 };
diff --git a/include/crypto/tlscredsx509.h b/include/crypto/tlscredsx509.h
index c6d89b78819..c4daba21a6b 100644
--- a/include/crypto/tlscredsx509.h
+++ b/include/crypto/tlscredsx509.h
@@ -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;
 };
diff --git a/crypto/tls-cipher-suites.c b/crypto/tls-cipher-suites.c
index 55fb5f7c19d..5e4f5974645 100644
--- a/crypto/tls-cipher-suites.c
+++ b/crypto/tls-cipher-suites.c
@@ -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
diff --git a/crypto/tlscredsanon.c b/crypto/tlscredsanon.c
index bea5f76c55d..6fb83639ecd 100644
--- a/crypto/tlscredsanon.c
+++ b/crypto/tlscredsanon.c
@@ -29,6 +29,8 @@
 
 #ifdef CONFIG_GNUTLS
 
+#include <gnutls/gnutls.h>
+
 
 static int
 qcrypto_tls_creds_anon_load(QCryptoTLSCredsAnon *creds,
diff --git a/crypto/tlscredspsk.c b/crypto/tlscredspsk.c
index f5a31108d15..752f2d92bee 100644
--- a/crypto/tlscredspsk.c
+++ b/crypto/tlscredspsk.c
@@ -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)
diff --git a/crypto/tlscredsx509.c b/crypto/tlscredsx509.c
index d9d6f4421e5..32948a6bdc4 100644
--- a/crypto/tlscredsx509.c
+++ b/crypto/tlscredsx509.c
@@ -30,6 +30,7 @@
 
 #ifdef CONFIG_GNUTLS
 
+#include <gnutls/gnutls.h>
 #include <gnutls/x509.h>
 
 
diff --git a/crypto/tlssession.c b/crypto/tlssession.c
index 4e614b73a28..e5d5675ef30 100644
--- a/crypto/tlssession.c
+++ b/crypto/tlssession.c
@@ -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
-- 
2.31.1



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

* Re: [PATCH v4 1/7] crypto/tlscreds: Introduce qcrypto_tls_creds_check_endpoint() helper
  2021-06-16 16:22 ` [PATCH v4 1/7] crypto/tlscreds: Introduce qcrypto_tls_creds_check_endpoint() helper Philippe Mathieu-Daudé
@ 2021-06-16 19:08   ` Richard Henderson
  2021-06-17  9:30   ` Daniel P. Berrangé
  1 sibling, 0 replies; 23+ messages in thread
From: Richard Henderson @ 2021-06-16 19:08 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Daniel P . Berrangé

On 6/16/21 9:22 AM, Philippe Mathieu-Daudé wrote:
> Introduce the qcrypto_tls_creds_check_endpoint() helper
> to access QCryptoTLSCreds internal 'endpoint' field.
> 
> Signed-off-by: Philippe Mathieu-Daudé<philmd@redhat.com>
> ---
>   include/crypto/tlscreds.h | 14 ++++++++++++++
>   crypto/tlscreds.c         | 12 ++++++++++++
>   2 files changed, 26 insertions(+)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


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

* Re: [PATCH v4 2/7] block/nbd: Use qcrypto_tls_creds_check_endpoint()
  2021-06-16 16:22 ` [PATCH v4 2/7] block/nbd: Use qcrypto_tls_creds_check_endpoint() Philippe Mathieu-Daudé
@ 2021-06-16 19:08   ` Richard Henderson
  2021-06-17  9:31   ` Daniel P. Berrangé
  1 sibling, 0 replies; 23+ messages in thread
From: Richard Henderson @ 2021-06-16 19:08 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Daniel P . Berrangé

On 6/16/21 9:22 AM, Philippe Mathieu-Daudé wrote:
> Avoid accessing QCryptoTLSCreds internals by using
> the qcrypto_tls_creds_check_endpoint() helper.
> 
> Signed-off-by: Philippe Mathieu-Daudé<philmd@redhat.com>
> ---
>   block/nbd.c    | 6 +++---
>   blockdev-nbd.c | 6 +++---
>   2 files changed, 6 insertions(+), 6 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


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

* Re: [PATCH v4 3/7] chardev/socket: Use qcrypto_tls_creds_check_endpoint()
  2021-06-16 16:22 ` [PATCH v4 3/7] chardev/socket: " Philippe Mathieu-Daudé
@ 2021-06-16 19:09   ` Richard Henderson
  2021-06-17  9:31   ` Daniel P. Berrangé
  1 sibling, 0 replies; 23+ messages in thread
From: Richard Henderson @ 2021-06-16 19:09 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Daniel P . Berrangé

On 6/16/21 9:22 AM, Philippe Mathieu-Daudé wrote:
> Avoid accessing QCryptoTLSCreds internals by using
> the qcrypto_tls_creds_check_endpoint() helper.
> 
> Signed-off-by: Philippe Mathieu-Daudé<philmd@redhat.com>
> ---
>   chardev/char-socket.c | 18 ++++++------------
>   1 file changed, 6 insertions(+), 12 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


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

* Re: [PATCH v4 4/7] migration/tls: Use qcrypto_tls_creds_check_endpoint()
  2021-06-16 16:22 ` [PATCH v4 4/7] migration/tls: " Philippe Mathieu-Daudé
@ 2021-06-16 19:09   ` Richard Henderson
  2021-06-17  9:32   ` Daniel P. Berrangé
  1 sibling, 0 replies; 23+ messages in thread
From: Richard Henderson @ 2021-06-16 19:09 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Daniel P . Berrangé

On 6/16/21 9:22 AM, Philippe Mathieu-Daudé wrote:
> Avoid accessing QCryptoTLSCreds internals by using
> the qcrypto_tls_creds_check_endpoint() helper.
> 
> Signed-off-by: Philippe Mathieu-Daudé<philmd@redhat.com>
> ---
>   migration/tls.c | 6 +-----
>   1 file changed, 1 insertion(+), 5 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~


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

* Re: [PATCH v4 5/7] crypto/tlssession: Introduce qcrypto_tls_creds_check_endpoint() helper
  2021-06-16 16:22 ` [PATCH v4 5/7] crypto/tlssession: Introduce qcrypto_tls_creds_check_endpoint() helper Philippe Mathieu-Daudé
@ 2021-06-16 19:12   ` Richard Henderson
  2021-06-16 19:21     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 23+ messages in thread
From: Richard Henderson @ 2021-06-16 19:12 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Daniel P . Berrangé

On 6/16/21 9:22 AM, Philippe Mathieu-Daudé wrote:
> Introduce the qcrypto_tls_creds_check_endpoint() helper
> to avoid accessing QCryptoTLSCreds internal 'endpoint' field
> directly.

I don't understand this one.  Comment ...

> +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~



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

* Re: [PATCH v4 5/7] crypto/tlssession: Introduce qcrypto_tls_creds_check_endpoint() helper
  2021-06-16 19:12   ` Richard Henderson
@ 2021-06-16 19:21     ` Philippe Mathieu-Daudé
  2021-06-17  9:33       ` Daniel P. Berrangé
  0 siblings, 1 reply; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-06-16 19:21 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel; +Cc: Daniel P . Berrangé

On 6/16/21 9:12 PM, Richard Henderson wrote:
> On 6/16/21 9:22 AM, Philippe Mathieu-Daudé wrote:
>> Introduce the qcrypto_tls_creds_check_endpoint() helper
>> to avoid accessing QCryptoTLSCreds internal 'endpoint' field
>> directly.
> 
> I don't understand this one.  Comment ...
> 
>> +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.

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?



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

* Re: [PATCH v4 1/7] crypto/tlscreds: Introduce qcrypto_tls_creds_check_endpoint() helper
  2021-06-16 16:22 ` [PATCH v4 1/7] crypto/tlscreds: Introduce qcrypto_tls_creds_check_endpoint() helper Philippe Mathieu-Daudé
  2021-06-16 19:08   ` Richard Henderson
@ 2021-06-17  9:30   ` Daniel P. Berrangé
  1 sibling, 0 replies; 23+ messages in thread
From: Daniel P. Berrangé @ 2021-06-17  9:30 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: qemu-devel

On Wed, Jun 16, 2021 at 06:22:19PM +0200, Philippe Mathieu-Daudé wrote:
> Introduce the qcrypto_tls_creds_check_endpoint() helper
> to access QCryptoTLSCreds internal 'endpoint' field.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  include/crypto/tlscreds.h | 14 ++++++++++++++
>  crypto/tlscreds.c         | 12 ++++++++++++
>  2 files changed, 26 insertions(+)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: 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 :|



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

* Re: [PATCH v4 2/7] block/nbd: Use qcrypto_tls_creds_check_endpoint()
  2021-06-16 16:22 ` [PATCH v4 2/7] block/nbd: Use qcrypto_tls_creds_check_endpoint() Philippe Mathieu-Daudé
  2021-06-16 19:08   ` Richard Henderson
@ 2021-06-17  9:31   ` Daniel P. Berrangé
  1 sibling, 0 replies; 23+ messages in thread
From: Daniel P. Berrangé @ 2021-06-17  9:31 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: qemu-devel

On Wed, Jun 16, 2021 at 06:22:20PM +0200, Philippe Mathieu-Daudé wrote:
> Avoid accessing QCryptoTLSCreds internals by using
> the qcrypto_tls_creds_check_endpoint() helper.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  block/nbd.c    | 6 +++---
>  blockdev-nbd.c | 6 +++---
>  2 files changed, 6 insertions(+), 6 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: 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 :|



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

* Re: [PATCH v4 3/7] chardev/socket: Use qcrypto_tls_creds_check_endpoint()
  2021-06-16 16:22 ` [PATCH v4 3/7] chardev/socket: " Philippe Mathieu-Daudé
  2021-06-16 19:09   ` Richard Henderson
@ 2021-06-17  9:31   ` Daniel P. Berrangé
  1 sibling, 0 replies; 23+ messages in thread
From: Daniel P. Berrangé @ 2021-06-17  9:31 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: qemu-devel

On Wed, Jun 16, 2021 at 06:22:21PM +0200, Philippe Mathieu-Daudé wrote:
> Avoid accessing QCryptoTLSCreds internals by using
> the qcrypto_tls_creds_check_endpoint() helper.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  chardev/char-socket.c | 18 ++++++------------
>  1 file changed, 6 insertions(+), 12 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: 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 :|



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

* Re: [PATCH v4 4/7] migration/tls: Use qcrypto_tls_creds_check_endpoint()
  2021-06-16 16:22 ` [PATCH v4 4/7] migration/tls: " Philippe Mathieu-Daudé
  2021-06-16 19:09   ` Richard Henderson
@ 2021-06-17  9:32   ` Daniel P. Berrangé
  1 sibling, 0 replies; 23+ messages in thread
From: Daniel P. Berrangé @ 2021-06-17  9:32 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: qemu-devel

On Wed, Jun 16, 2021 at 06:22:22PM +0200, Philippe Mathieu-Daudé wrote:
> Avoid accessing QCryptoTLSCreds internals by using
> the qcrypto_tls_creds_check_endpoint() helper.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  migration/tls.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: 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 :|



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

* Re: [PATCH v4 5/7] crypto/tlssession: Introduce qcrypto_tls_creds_check_endpoint() helper
  2021-06-16 19:21     ` Philippe Mathieu-Daudé
@ 2021-06-17  9:33       ` Daniel P. Berrangé
  2021-06-17 12:02         ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 23+ messages in thread
From: Daniel P. Berrangé @ 2021-06-17  9:33 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: Richard Henderson, qemu-devel

On Wed, Jun 16, 2021 at 09:21:45PM +0200, Philippe Mathieu-Daudé wrote:
> On 6/16/21 9:12 PM, Richard Henderson wrote:
> > On 6/16/21 9:22 AM, Philippe Mathieu-Daudé wrote:
> >> Introduce the qcrypto_tls_creds_check_endpoint() helper
> >> to avoid accessing QCryptoTLSCreds internal 'endpoint' field
> >> directly.
> > 
> > I don't understand this one.  Comment ...
> > 
> >> +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.
> 
> 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?

I think we don't need this extra function - just use the function from
earlier directly.

Regards,
Daniel
-- 
|: 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 :|



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

* Re: [PATCH v4 7/7] crypto: Make QCryptoTLSCreds* structures private
  2021-06-16 16:22 ` [PATCH v4 7/7] crypto: Make QCryptoTLSCreds* structures private Philippe Mathieu-Daudé
@ 2021-06-17  9:35   ` Daniel P. Berrangé
  2021-06-17 12:08     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 23+ messages in thread
From: Daniel P. Berrangé @ 2021-06-17  9:35 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: Stefan Weil, qemu-devel

On Wed, Jun 16, 2021 at 06:22:25PM +0200, Philippe Mathieu-Daudé wrote:
> 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.
> 
> Reported-by: Stefan Weil <sw@weilnetz.de>
> Suggested-by: Daniel P. Berrangé <berrange@redhat.com>
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/407
> Fixes: 7de2e856533 ("yank: Unregister function when using TLS migration")
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  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(-)
> 


> diff --git a/crypto/tlscredsanon.c b/crypto/tlscredsanon.c
> index bea5f76c55d..6fb83639ecd 100644
> --- a/crypto/tlscredsanon.c
> +++ b/crypto/tlscredsanon.c
> @@ -29,6 +29,8 @@
>  
>  #ifdef CONFIG_GNUTLS
>  
> +#include <gnutls/gnutls.h>
> +
>  
>  static int
>  qcrypto_tls_creds_anon_load(QCryptoTLSCredsAnon *creds,
> diff --git a/crypto/tlscredspsk.c b/crypto/tlscredspsk.c
> index f5a31108d15..752f2d92bee 100644
> --- a/crypto/tlscredspsk.c
> +++ b/crypto/tlscredspsk.c
> @@ -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)
> diff --git a/crypto/tlscredsx509.c b/crypto/tlscredsx509.c
> index d9d6f4421e5..32948a6bdc4 100644
> --- a/crypto/tlscredsx509.c
> +++ b/crypto/tlscredsx509.c
> @@ -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
-- 
|: 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 :|



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

* Re: [PATCH v4 5/7] crypto/tlssession: Introduce qcrypto_tls_creds_check_endpoint() helper
  2021-06-17  9:33       ` Daniel P. Berrangé
@ 2021-06-17 12:02         ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-06-17 12:02 UTC (permalink / raw)
  To: Daniel P. Berrangé; +Cc: Richard Henderson, qemu-devel

On 6/17/21 11:33 AM, Daniel P. Berrangé wrote:
> On Wed, Jun 16, 2021 at 09:21:45PM +0200, Philippe Mathieu-Daudé wrote:
>> On 6/16/21 9:12 PM, Richard Henderson wrote:
>>> On 6/16/21 9:22 AM, Philippe Mathieu-Daudé wrote:
>>>> Introduce the qcrypto_tls_creds_check_endpoint() helper
>>>> to avoid accessing QCryptoTLSCreds internal 'endpoint' field
>>>> directly.
>>>
>>> I don't understand this one.  Comment ...
>>>
>>>> +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.
>>
>> 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?
> 
> I think we don't need this extra function - just use the function from
> earlier directly.

Great, simpler :)



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

* Re: [PATCH v4 7/7] crypto: Make QCryptoTLSCreds* structures private
  2021-06-17  9:35   ` Daniel P. Berrangé
@ 2021-06-17 12:08     ` Philippe Mathieu-Daudé
  2021-06-17 12:15       ` Daniel P. Berrangé
  0 siblings, 1 reply; 23+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-06-17 12:08 UTC (permalink / raw)
  To: Daniel P. Berrangé; +Cc: Stefan Weil, qemu-devel

On 6/17/21 11:35 AM, Daniel P. Berrangé wrote:
> On Wed, Jun 16, 2021 at 06:22:25PM +0200, Philippe Mathieu-Daudé wrote:
>> 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.
>>
>> Reported-by: Stefan Weil <sw@weilnetz.de>
>> Suggested-by: Daniel P. Berrangé <berrange@redhat.com>
>> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/407
>> Fixes: 7de2e856533 ("yank: Unregister function when using TLS migration")
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> ---
>>  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(-)

> I was expecting all these files, and tlscreds.c to include
> tlscredspriv.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.



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

* Re: [PATCH v4 7/7] crypto: Make QCryptoTLSCreds* structures private
  2021-06-17 12:08     ` Philippe Mathieu-Daudé
@ 2021-06-17 12:15       ` Daniel P. Berrangé
  0 siblings, 0 replies; 23+ messages in thread
From: Daniel P. Berrangé @ 2021-06-17 12:15 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: Stefan Weil, qemu-devel

On Thu, Jun 17, 2021 at 02:08:17PM +0200, Philippe Mathieu-Daudé wrote:
> On 6/17/21 11:35 AM, Daniel P. Berrangé wrote:
> > On Wed, Jun 16, 2021 at 06:22:25PM +0200, Philippe Mathieu-Daudé wrote:
> >> 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.
> >>
> >> Reported-by: Stefan Weil <sw@weilnetz.de>
> >> Suggested-by: Daniel P. Berrangé <berrange@redhat.com>
> >> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/407
> >> Fixes: 7de2e856533 ("yank: Unregister function when using TLS migration")
> >> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> >> ---
> >>  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(-)
> 
> > I was expecting all these files, and tlscreds.c to include
> > tlscredspriv.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.

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
-- 
|: 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 :|



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

end of thread, other threads:[~2021-06-17 12:19 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-16 16:22 [PATCH v4 0/7] crypto: Make QCryptoTLSCreds* structures private Philippe Mathieu-Daudé
2021-06-16 16:22 ` [PATCH v4 1/7] crypto/tlscreds: Introduce qcrypto_tls_creds_check_endpoint() helper Philippe Mathieu-Daudé
2021-06-16 19:08   ` Richard Henderson
2021-06-17  9:30   ` Daniel P. Berrangé
2021-06-16 16:22 ` [PATCH v4 2/7] block/nbd: Use qcrypto_tls_creds_check_endpoint() Philippe Mathieu-Daudé
2021-06-16 19:08   ` Richard Henderson
2021-06-17  9:31   ` Daniel P. Berrangé
2021-06-16 16:22 ` [PATCH v4 3/7] chardev/socket: " Philippe Mathieu-Daudé
2021-06-16 19:09   ` Richard Henderson
2021-06-17  9:31   ` Daniel P. Berrangé
2021-06-16 16:22 ` [PATCH v4 4/7] migration/tls: " Philippe Mathieu-Daudé
2021-06-16 19:09   ` Richard Henderson
2021-06-17  9:32   ` Daniel P. Berrangé
2021-06-16 16:22 ` [PATCH v4 5/7] crypto/tlssession: Introduce qcrypto_tls_creds_check_endpoint() helper Philippe Mathieu-Daudé
2021-06-16 19:12   ` Richard Henderson
2021-06-16 19:21     ` Philippe Mathieu-Daudé
2021-06-17  9:33       ` Daniel P. Berrangé
2021-06-17 12:02         ` Philippe Mathieu-Daudé
2021-06-16 16:22 ` [PATCH v4 6/7] ui/vnc: Use qcrypto_tls_session_check_role() Philippe Mathieu-Daudé
2021-06-16 16:22 ` [PATCH v4 7/7] crypto: Make QCryptoTLSCreds* structures private Philippe Mathieu-Daudé
2021-06-17  9:35   ` Daniel P. Berrangé
2021-06-17 12:08     ` Philippe Mathieu-Daudé
2021-06-17 12:15       ` Daniel P. Berrangé

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.