[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 1/7] crypto/tlscreds: Introduce qcrypto_tls_creds_check_endpoi
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v3 1/7] crypto/tlscreds: Introduce qcrypto_tls_creds_check_endpoint() helper |
Date: |
Tue, 15 Jun 2021 19:27:40 +0200 |
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 | 13 +++++++++++++
crypto/tlscreds.c | 12 ++++++++++++
2 files changed, 25 insertions(+)
diff --git a/include/crypto/tlscreds.h b/include/crypto/tlscreds.h
index d0808e391e9..e45f1e34853 100644
--- a/include/crypto/tlscreds.h
+++ b/include/crypto/tlscreds.h
@@ -65,5 +65,18 @@ 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
+ *
+ * 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
- [PATCH v3 0/7] crypto: Make QCryptoTLSCreds* structures private, Philippe Mathieu-Daudé, 2021/06/15
- [PATCH v3 1/7] crypto/tlscreds: Introduce qcrypto_tls_creds_check_endpoint() helper,
Philippe Mathieu-Daudé <=
- [PATCH v3 2/7] block/nbd: Use qcrypto_tls_creds_check_endpoint(), Philippe Mathieu-Daudé, 2021/06/15
- [PATCH v3 3/7] chardev/socket: Use qcrypto_tls_creds_check_endpoint(), Philippe Mathieu-Daudé, 2021/06/15
- [PATCH v3 4/7] migration/tls: Use qcrypto_tls_creds_check_endpoint(), Philippe Mathieu-Daudé, 2021/06/15
- [PATCH v3 6/7] ui/vnc: Use qcrypto_tls_session_check_role(), Philippe Mathieu-Daudé, 2021/06/15
- [PATCH v3 5/7] crypto/tlssession: Introduce qcrypto_tls_creds_check_endpoint() helper, Philippe Mathieu-Daudé, 2021/06/15
- [PATCH v3 7/7] crypto: Make QCryptoTLSCreds* structures private, Philippe Mathieu-Daudé, 2021/06/15
- Re: [PATCH v3 0/7] crypto: Make QCryptoTLSCreds* structures private, Philippe Mathieu-Daudé, 2021/06/15