diff options
author | Philippe Mathieu-Daudé <philmd@redhat.com> | 2021-06-28 18:09:08 +0200 |
---|---|---|
committer | Michael Roth <michael.roth@amd.com> | 2021-10-14 16:27:05 -0500 |
commit | 7e84d58e8be9c8b64710982f947f63b95816d311 (patch) | |
tree | e25f8e17ed977b06cc45445af4845240caef465a | |
parent | 072a8d3693b40f46efcc7b05f6f4136760e57612 (diff) | |
download | qemu-7e84d58e8be9c8b64710982f947f63b95816d311.zip qemu-7e84d58e8be9c8b64710982f947f63b95816d311.tar.gz qemu-7e84d58e8be9c8b64710982f947f63b95816d311.tar.bz2 |
crypto/tlscreds: Introduce qcrypto_tls_creds_check_endpoint() helper
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>
(cherry picked from commit e9ac68083f26759b85ef0d871ca2bbe897218f64)
Signed-off-by: Michael Roth <michael.roth@amd.com>
-rw-r--r-- | crypto/tlscreds.c | 12 | ||||
-rw-r--r-- | include/crypto/tlscreds.h | 14 |
2 files changed, 26 insertions, 0 deletions
diff --git a/crypto/tlscreds.c b/crypto/tlscreds.c index b68735f..084ce0d 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 d0808e3..a14e44f 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 */ |