Skip to content

Commit 69699f3

Browse files
committed
crypto/tls-cipher-suites: Produce fw_cfg consumable blob
Since our format is consumable by the fw_cfg device, we can implement the FW_CFG_DATA_GENERATOR interface. Example of use to dump the cipher suites (if tracing enabled): $ qemu-system-x86_64 -S \ -object tls-cipher-suites,id=mysuite1,priority=@System \ -fw_cfg name=etc/path/to/ciphers,gen_id=mysuite1 \ -trace qcrypto\* 1590664444.197123:qcrypto_tls_cipher_suite_priority priority: @System 1590664444.197219:qcrypto_tls_cipher_suite_info data=[0x13,0x02] version=TLS1.3 name=TLS_AES_256_GCM_SHA384 1590664444.197228:qcrypto_tls_cipher_suite_info data=[0x13,0x03] version=TLS1.3 name=TLS_CHACHA20_POLY1305_SHA256 1590664444.197233:qcrypto_tls_cipher_suite_info data=[0x13,0x01] version=TLS1.3 name=TLS_AES_128_GCM_SHA256 1590664444.197236:qcrypto_tls_cipher_suite_info data=[0x13,0x04] version=TLS1.3 name=TLS_AES_128_CCM_SHA256 1590664444.197240:qcrypto_tls_cipher_suite_info data=[0xc0,0x30] version=TLS1.2 name=TLS_ECDHE_RSA_AES_256_GCM_SHA384 1590664444.197245:qcrypto_tls_cipher_suite_info data=[0xcc,0xa8] version=TLS1.2 name=TLS_ECDHE_RSA_CHACHA20_POLY1305 1590664444.197250:qcrypto_tls_cipher_suite_info data=[0xc0,0x14] version=TLS1.0 name=TLS_ECDHE_RSA_AES_256_CBC_SHA1 1590664444.197254:qcrypto_tls_cipher_suite_info data=[0xc0,0x2f] version=TLS1.2 name=TLS_ECDHE_RSA_AES_128_GCM_SHA256 1590664444.197258:qcrypto_tls_cipher_suite_info data=[0xc0,0x13] version=TLS1.0 name=TLS_ECDHE_RSA_AES_128_CBC_SHA1 1590664444.197261:qcrypto_tls_cipher_suite_info data=[0xc0,0x2c] version=TLS1.2 name=TLS_ECDHE_ECDSA_AES_256_GCM_SHA384 1590664444.197266:qcrypto_tls_cipher_suite_info data=[0xcc,0xa9] version=TLS1.2 name=TLS_ECDHE_ECDSA_CHACHA20_POLY1305 1590664444.197270:qcrypto_tls_cipher_suite_info data=[0xc0,0xad] version=TLS1.2 name=TLS_ECDHE_ECDSA_AES_256_CCM 1590664444.197274:qcrypto_tls_cipher_suite_info data=[0xc0,0x0a] version=TLS1.0 name=TLS_ECDHE_ECDSA_AES_256_CBC_SHA1 1590664444.197278:qcrypto_tls_cipher_suite_info data=[0xc0,0x2b] version=TLS1.2 name=TLS_ECDHE_ECDSA_AES_128_GCM_SHA256 1590664444.197283:qcrypto_tls_cipher_suite_info data=[0xc0,0xac] version=TLS1.2 name=TLS_ECDHE_ECDSA_AES_128_CCM 1590664444.197287:qcrypto_tls_cipher_suite_info data=[0xc0,0x09] version=TLS1.0 name=TLS_ECDHE_ECDSA_AES_128_CBC_SHA1 1590664444.197291:qcrypto_tls_cipher_suite_info data=[0x00,0x9d] version=TLS1.2 name=TLS_RSA_AES_256_GCM_SHA384 1590664444.197296:qcrypto_tls_cipher_suite_info data=[0xc0,0x9d] version=TLS1.2 name=TLS_RSA_AES_256_CCM 1590664444.197300:qcrypto_tls_cipher_suite_info data=[0x00,0x35] version=TLS1.0 name=TLS_RSA_AES_256_CBC_SHA1 1590664444.197304:qcrypto_tls_cipher_suite_info data=[0x00,0x9c] version=TLS1.2 name=TLS_RSA_AES_128_GCM_SHA256 1590664444.197308:qcrypto_tls_cipher_suite_info data=[0xc0,0x9c] version=TLS1.2 name=TLS_RSA_AES_128_CCM 1590664444.197312:qcrypto_tls_cipher_suite_info data=[0x00,0x2f] version=TLS1.0 name=TLS_RSA_AES_128_CBC_SHA1 1590664444.197316:qcrypto_tls_cipher_suite_info data=[0x00,0x9f] version=TLS1.2 name=TLS_DHE_RSA_AES_256_GCM_SHA384 1590664444.197320:qcrypto_tls_cipher_suite_info data=[0xcc,0xaa] version=TLS1.2 name=TLS_DHE_RSA_CHACHA20_POLY1305 1590664444.197325:qcrypto_tls_cipher_suite_info data=[0xc0,0x9f] version=TLS1.2 name=TLS_DHE_RSA_AES_256_CCM 1590664444.197329:qcrypto_tls_cipher_suite_info data=[0x00,0x39] version=TLS1.0 name=TLS_DHE_RSA_AES_256_CBC_SHA1 1590664444.197333:qcrypto_tls_cipher_suite_info data=[0x00,0x9e] version=TLS1.2 name=TLS_DHE_RSA_AES_128_GCM_SHA256 1590664444.197337:qcrypto_tls_cipher_suite_info data=[0xc0,0x9e] version=TLS1.2 name=TLS_DHE_RSA_AES_128_CCM 1590664444.197341:qcrypto_tls_cipher_suite_info data=[0x00,0x33] version=TLS1.0 name=TLS_DHE_RSA_AES_128_CBC_SHA1 1590664444.197345:qcrypto_tls_cipher_suite_count count: 29 Signed-off-by: Philippe Mathieu-Daudé <[email protected]> Reviewed-by: Daniel P. Berrangé <[email protected]> Acked-by: Laszlo Ersek <[email protected]> Message-Id: <[email protected]>
1 parent f7d8afb commit 69699f3

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

crypto/tls-cipher-suites.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "qom/object_interfaces.h"
1414
#include "crypto/tlscreds.h"
1515
#include "crypto/tls-cipher-suites.h"
16+
#include "hw/nvram/fw_cfg.h"
1617
#include "trace.h"
1718

1819
/*
@@ -88,11 +89,20 @@ static void qcrypto_tls_cipher_suites_complete(UserCreatable *uc,
8889
}
8990
}
9091

92+
static GByteArray *qcrypto_tls_cipher_suites_fw_cfg_gen_data(Object *obj,
93+
Error **errp)
94+
{
95+
return qcrypto_tls_cipher_suites_get_data(QCRYPTO_TLS_CIPHER_SUITES(obj),
96+
errp);
97+
}
98+
9199
static void qcrypto_tls_cipher_suites_class_init(ObjectClass *oc, void *data)
92100
{
93101
UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc);
102+
FWCfgDataGeneratorClass *fwgc = FW_CFG_DATA_GENERATOR_CLASS(oc);
94103

95104
ucc->complete = qcrypto_tls_cipher_suites_complete;
105+
fwgc->get_data = qcrypto_tls_cipher_suites_fw_cfg_gen_data;
96106
}
97107

98108
static const TypeInfo qcrypto_tls_cipher_suites_info = {
@@ -103,6 +113,7 @@ static const TypeInfo qcrypto_tls_cipher_suites_info = {
103113
.class_init = qcrypto_tls_cipher_suites_class_init,
104114
.interfaces = (InterfaceInfo[]) {
105115
{ TYPE_USER_CREATABLE },
116+
{ TYPE_FW_CFG_DATA_GENERATOR_INTERFACE },
106117
{ }
107118
}
108119
};

qemu-options.hx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4586,6 +4586,24 @@ SRST
45864586
string as described at
45874587
https://gnutls.org/manual/html_node/Priority-Strings.html.
45884588

4589+
An example of use of this object is to control UEFI HTTPS Boot.
4590+
The tls-cipher-suites object exposes the ordered list of permitted
4591+
TLS cipher suites from the host side to the guest firmware, via
4592+
fw_cfg. The list is represented as an array of IANA_TLS_CIPHER
4593+
objects. The firmware uses the IANA_TLS_CIPHER array for configuring
4594+
guest-side TLS.
4595+
4596+
In the following example, the priority at which the host-side policy
4597+
is retrieved is given by the ``priority`` property.
4598+
Given that QEMU uses GNUTLS, ``priority=@SYSTEM`` may be used to
4599+
refer to /etc/crypto-policies/back-ends/gnutls.config.
4600+
4601+
.. parsed-literal::
4602+
4603+
# |qemu_system| \
4604+
-object tls-cipher-suites,id=mysuite0,priority=@SYSTEM \
4605+
-fw_cfg name=etc/edk2/https/ciphers,gen_id=mysuite0
4606+
45894607
``-object filter-buffer,id=id,netdev=netdevid,interval=t[,queue=all|rx|tx][,status=on|off][,position=head|tail|id=<id>][,insert=behind|before]``
45904608
Interval t can't be 0, this filter batches the packet delivery:
45914609
all packets arriving in a given interval on netdev netdevid are

0 commit comments

Comments
 (0)