[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 1/7] crypto/tlscreds: Introduce qcrypto_tls_creds_check_endpoint()
From: |
Daniel P . Berrangé |
Subject: |
[PULL 1/7] crypto/tlscreds: Introduce qcrypto_tls_creds_check_endpoint() helper |
Date: |
Wed, 30 Jun 2021 12:56:06 +0100 |
From: Philippe Mathieu-Daudé <philmd@redhat.com>
Introduce the qcrypto_tls_creds_check_endpoint() helper
to access QCryptoTLSCreds internal 'endpoint' field.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
crypto/tlscreds.c | 12 ++++++++++++
include/crypto/tlscreds.h | 14 ++++++++++++++
2 files changed, 26 insertions(+)
diff --git a/crypto/tlscreds.c b/crypto/tlscreds.c
index b68735f06f..084ce0d51a 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,
diff --git a/include/crypto/tlscreds.h b/include/crypto/tlscreds.h
index d0808e391e..a14e44fac1 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 */
--
2.31.1
- [PULL 0/7] crypto patches, Daniel P . Berrangé, 2021/06/30
- [PULL 1/7] crypto/tlscreds: Introduce qcrypto_tls_creds_check_endpoint() helper,
Daniel P . Berrangé <=
- [PULL 2/7] block/nbd: Use qcrypto_tls_creds_check_endpoint(), Daniel P . Berrangé, 2021/06/30
- [PULL 3/7] qemu-nbd: Use qcrypto_tls_creds_check_endpoint(), Daniel P . Berrangé, 2021/06/30
- [PULL 4/7] chardev/socket: Use qcrypto_tls_creds_check_endpoint(), Daniel P . Berrangé, 2021/06/30
- [PULL 5/7] migration/tls: Use qcrypto_tls_creds_check_endpoint(), Daniel P . Berrangé, 2021/06/30
- [PULL 6/7] ui/vnc: Use qcrypto_tls_creds_check_endpoint(), Daniel P . Berrangé, 2021/06/30
- [PULL 7/7] crypto: Make QCryptoTLSCreds* structures private, Daniel P . Berrangé, 2021/06/30