diff mbox series

[v2,1/7] crypto/tlscreds: Introduce qcrypto_tls_creds_check_endpoint() helper

Message ID 20210615164751.2192807-2-philmd@redhat.com (mailing list archive)
State New, archived
Headers show
Series crypto: Make QCryptoTLSCreds* structures private | expand

Commit Message

Philippe Mathieu-Daudé June 15, 2021, 4:47 p.m. UTC
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 | 12 ++++++++++++
 crypto/tlscreds.c         |  5 +++++
 2 files changed, 17 insertions(+)
diff mbox series

Patch

diff --git a/include/crypto/tlscreds.h b/include/crypto/tlscreds.h
index d0808e391e9..eb9d5e75a84 100644
--- a/include/crypto/tlscreds.h
+++ b/include/crypto/tlscreds.h
@@ -65,5 +65,17 @@  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);
 
 #endif /* QCRYPTO_TLSCREDS_H */
diff --git a/crypto/tlscreds.c b/crypto/tlscreds.c
index b68735f06fe..f9f45e12db1 100644
--- a/crypto/tlscreds.c
+++ b/crypto/tlscreds.c
@@ -259,6 +259,11 @@  qcrypto_tls_creds_finalize(Object *obj)
     g_free(creds->priority);
 }
 
+bool qcrypto_tls_creds_check_endpoint(QCryptoTLSCreds *creds,
+                                      QCryptoTLSCredsEndpoint endpoint)
+{
+    return creds->endpoint == endpoint;
+}
 
 static const TypeInfo qcrypto_tls_creds_info = {
     .parent = TYPE_OBJECT,