2 * QEMU crypto TLS Pre-Shared Key (PSK) support
4 * Copyright (c) 2018 Red Hat, Inc.
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
9 * version 2.1 of the License, or (at your option) any later version.
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.
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/>.
21 #ifndef QCRYPTO_TLSCREDSPSK_H
22 #define QCRYPTO_TLSCREDSPSK_H
24 #include "crypto/tlscreds.h"
26 #define TYPE_QCRYPTO_TLS_CREDS_PSK "tls-creds-psk"
27 #define QCRYPTO_TLS_CREDS_PSK(obj) \
28 OBJECT_CHECK(QCryptoTLSCredsPSK, (obj), TYPE_QCRYPTO_TLS_CREDS_PSK)
30 typedef struct QCryptoTLSCredsPSK QCryptoTLSCredsPSK
;
31 typedef struct QCryptoTLSCredsPSKClass QCryptoTLSCredsPSKClass
;
33 #define QCRYPTO_TLS_CREDS_PSKFILE "keys.psk"
38 * The QCryptoTLSCredsPSK object provides a representation
39 * of the Pre-Shared Key credential used to perform a TLS handshake.
41 * This is a user creatable object, which can be instantiated
42 * via object_new_propv():
45 * <title>Creating TLS-PSK credential objects in code</title>
49 * obj = object_new_propv(TYPE_QCRYPTO_TLS_CREDS_PSK,
52 * "dir", "/path/to/dir",
53 * "endpoint", "client",
61 * <title>Creating TLS-PSK credential objects via QMP</title>
64 * "execute": "object-add", "arguments": {
66 * "qom-type": "tls-creds-psk",
68 * "dir": "/path/to/dir",
69 * "endpoint": "client"
79 * <title>Creating TLS-PSK credential objects via CLI</title>
81 * qemu-system-x86_64 --object tls-creds-psk,id=tlscreds0,\
82 * endpoint=client,dir=/path/to/dir[,username=qemu]
86 * The PSK file can be created and managed using psktool.
89 struct QCryptoTLSCredsPSK
{
90 QCryptoTLSCreds parent_obj
;
94 gnutls_psk_server_credentials_t server
;
95 gnutls_psk_client_credentials_t client
;
101 struct QCryptoTLSCredsPSKClass
{
102 QCryptoTLSCredsClass parent_class
;
106 #endif /* QCRYPTO_TLSCREDSPSK_H */