| 1 | /* |
| 2 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | * |
| 4 | * QEMU crypto TLS credential support |
| 5 | * |
| 6 | * Copyright (c) 2025 Red Hat, Inc. |
| 7 | */ |
| 8 | |
| 9 | #ifndef QCRYPTO_TLSCREDS_BOX_H |
| 10 | #define QCRYPTO_TLSCREDS_BOX_H |
| 11 | |
| 12 | #include "qom/object.h" |
| 13 | |
| 14 | #ifdef CONFIG_GNUTLS |
| 15 | #include <gnutls/gnutls.h> |
| 16 | #endif |
| 17 | |
| 18 | typedef struct QCryptoTLSCredsBox QCryptoTLSCredsBox; |
| 19 | |
| 20 | struct QCryptoTLSCredsBox { |
| 21 | uint32_t ref; |
| 22 | bool server; |
| 23 | int type; |
| 24 | union { |
| 25 | void *any; |
| 26 | #ifdef CONFIG_GNUTLS |
| 27 | /* |
| 28 | * All of these gnutls_XXXX_credentials_t types are |
| 29 | * pointers, hence matching the 'any' field above |
| 30 | */ |
| 31 | gnutls_anon_server_credentials_t anonserver; |
| 32 | gnutls_anon_client_credentials_t anonclient; |
| 33 | gnutls_psk_server_credentials_t pskserver; |
| 34 | gnutls_psk_client_credentials_t pskclient; |
| 35 | gnutls_certificate_credentials_t cert; |
| 36 | #endif |
| 37 | } data; |
| 38 | #ifdef CONFIG_GNUTLS |
| 39 | gnutls_dh_params_t dh_params; |
| 40 | #endif |
| 41 | }; |
| 42 | |
| 43 | QCryptoTLSCredsBox *qcrypto_tls_creds_box_new_server(int type); |
| 44 | QCryptoTLSCredsBox *qcrypto_tls_creds_box_new_client(int type); |
| 45 | void qcrypto_tls_creds_box_ref(QCryptoTLSCredsBox *credsbox); |
| 46 | void qcrypto_tls_creds_box_unref(QCryptoTLSCredsBox *credsbox); |
| 47 | |
| 48 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(QCryptoTLSCredsBox, qcrypto_tls_creds_box_unref); |
| 49 | |
| 50 | #endif /* QCRYPTO_TLSCREDS_BOX_H */ |