blob: 2a8a8570109488b8787e00cf2936eda9f53bd963 [file] [log] [blame]
Daniel P. Berrangea0901872015-03-13 17:39:26 +00001/*
2 * QEMU crypto TLS credential support
3 *
4 * Copyright (c) 2015 Red Hat, Inc.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
Thomas Huthb7cbb872019-02-13 16:54:59 +01009 * version 2.1 of the License, or (at your option) any later version.
Daniel P. Berrangea0901872015-03-13 17:39:26 +000010 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
Markus Armbruster121d0712016-06-29 10:12:57 +020021#ifndef QCRYPTO_TLSCREDS_H
22#define QCRYPTO_TLSCREDS_H
Daniel P. Berrangea0901872015-03-13 17:39:26 +000023
Markus Armbruster9af23982018-02-11 10:36:01 +010024#include "qapi/qapi-types-crypto.h"
Daniel P. Berrangea0901872015-03-13 17:39:26 +000025#include "qom/object.h"
26
Daniel P. Berrangea0901872015-03-13 17:39:26 +000027#define TYPE_QCRYPTO_TLS_CREDS "tls-creds"
Eduardo Habkostdb1015e2020-09-03 16:43:22 -040028typedef struct QCryptoTLSCreds QCryptoTLSCreds;
Daniel P. Berrangea0901872015-03-13 17:39:26 +000029typedef struct QCryptoTLSCredsClass QCryptoTLSCredsClass;
Zihao Changa29acc92021-03-16 15:58:43 +080030DECLARE_OBJ_CHECKERS(QCryptoTLSCreds, QCryptoTLSCredsClass, QCRYPTO_TLS_CREDS,
31 TYPE_QCRYPTO_TLS_CREDS)
32
Daniel P. Berrangea0901872015-03-13 17:39:26 +000033
34#define QCRYPTO_TLS_CREDS_DH_PARAMS "dh-params.pem"
35
36
Zihao Changa29acc92021-03-16 15:58:43 +080037typedef bool (*CryptoTLSCredsReload)(QCryptoTLSCreds *, Error **);
Daniel P. Berrangea0901872015-03-13 17:39:26 +000038/**
39 * QCryptoTLSCreds:
40 *
41 * The QCryptoTLSCreds object is an abstract base for different
42 * types of TLS handshake credentials. Most commonly the
43 * QCryptoTLSCredsX509 subclass will be used to provide x509
44 * certificate credentials.
45 */
46
Daniel P. Berrangea0901872015-03-13 17:39:26 +000047struct QCryptoTLSCredsClass {
48 ObjectClass parent_class;
Zihao Changa29acc92021-03-16 15:58:43 +080049 CryptoTLSCredsReload reload;
Daniel P. Berrangea0901872015-03-13 17:39:26 +000050};
51
Philippe Mathieu-Daudée9ac6802021-06-28 18:09:08 +020052/**
53 * qcrypto_tls_creds_check_endpoint:
54 * @creds: pointer to a TLS credentials object
55 * @endpoint: type of network endpoint that will be using the credentials
56 * @errp: pointer to a NULL-initialized error object
57 *
58 * Check whether the credentials is setup according to
59 * the type of @endpoint argument.
60 *
61 * Returns true if the credentials is setup for the endpoint, false otherwise
62 */
63bool qcrypto_tls_creds_check_endpoint(QCryptoTLSCreds *creds,
64 QCryptoTLSCredsEndpoint endpoint,
65 Error **errp);
Daniel P. Berrangea0901872015-03-13 17:39:26 +000066
Markus Armbruster121d0712016-06-29 10:12:57 +020067#endif /* QCRYPTO_TLSCREDS_H */