Skip to content

Commit df34e7b

Browse files
cjen1-msftachamayoueddyashton
authored
Hexstring tcb (#7078)
Co-authored-by: Amaury Chamayou <[email protected]> Co-authored-by: Eddy Ashton <[email protected]> Co-authored-by: Amaury Chamayou <[email protected]>
1 parent c8731cb commit df34e7b

File tree

26 files changed

+766
-238
lines changed

26 files changed

+766
-238
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8+
## [6.0.9]
9+
10+
[6.0.9]: https://github.com/microsoft/CCF/releases/tag/ccf-6.0.9
11+
12+
## Added
13+
14+
- Add governance action that supports specifying minimum TCB versions in hexstring format. This is intended to be the default format going forward. (#7078)
15+
816
## [6.0.8]
917

1018
[6.0.8]: https://github.com/microsoft/CCF/releases/tag/ccf-6.0.8

doc/audit/builtin_maps.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ The minimum trusted TCB version for new nodes allowed to join the network (:doc`
216216
* - CPUID
217217
- TCB Version
218218
* - ``00a00f11``
219-
- ``{boot_loader: 4, tee: 0, snp: 24, microcode: 219}``
219+
- ``{"hexstring": "d315000000000004", "boot_loader": 4, "tee": 0, "snp": 21, "microcode": 211}``
220220

221221
``service.info``
222222
~~~~~~~~~~~~~~~~

doc/build_apps/migration_5_x_to_6_0.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ This introduced a new table, ``nodes.snp.tcb_versions``, which is the minimum TC
2323
Old networks which are migrating to 6.0 will need to populate this table manually, using the ``set_snp_minimum_tcb_version`` governance action.
2424
If they are not populated then new nodes may fail to join the network.
2525

26+
.. note::
27+
In 6.0.9 we introduced ``set_minimum_tcb_version_hex``, a more ergonomic governance action to set the minimum TCB version.
28+
This action takes a CPUID and the hex-string format of a TCB version, as you would find it in an attestation, and stores the parsed fields of the TCB version in the ``nodes.snp.tcb_versions`` table, alongside the original hex-string.
29+
We strongly recommend using this action as we can transparently add support for new CPU models which change the TCB version format, such as Turin.
30+
2631
For example to set the minimum TCB version on Milan CPUs the following proposal can be submitted:
2732

2833
.. code-block:: json

doc/operations/platforms/snp.rst

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,93 @@ The following governance proposals can be issued to add/remove these trusted val
7777
- ``add_snp_host_data``/``remove_snp_host_data``: To add/remove a trusted security policy, e.g. when adding a new trusted container image as part of the code upgrade procedure.
7878
- ``add_snp_uvm_endorsement``/``add_snp_uvm_endorsement``: To add remove a trusted UVM endorsement (Azure deployment only).
7979
- ``add_snp_measurement``/``remove_snp_measurement``: To add/remove a trusted measurement.
80-
- ``set_snp_minimum_tcb_version``/``remove_snp_minimum_tcb_version``: To add/remove a minimum trusted TCB version.
80+
- ``set_snp_minimum_tcb_version_hex``/``remove_snp_minimum_tcb_version``: To add/remove a minimum trusted TCB version.
81+
- ``set_snp_minimum_tcb_version`` was deprecated in CCF 6.0.9 and replaced by ``set_snp_minimum_tcb_version_hex``.
82+
83+
Setting the minimum TCB Version using ``set_snp_minimum_tcb_version_hex``
84+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
85+
86+
The `set_snp_minimum_tcb_version_hex` governance action was introduced in CCF 6.0.9 to simplify the process of setting the minimum TCB version for a specific CPU model. This action allows you to specify the CPUID and the TCB version as hex-strings, which are then parsed and stored in the :ref:`audit/builtin_maps:``nodes.snp.tcb_versions``` table.
87+
To set the minimum TCB version for a specific CPU model, you can use the following governance action:
88+
.. code-block:: json
89+
90+
{
91+
"actions": [
92+
{
93+
"name": "set_snp_minimum_tcb_version_hex",
94+
"args": {
95+
"cpuid": "00a00f11",
96+
"tcb_version": "d315000000000004"
97+
}
98+
}
99+
]
100+
}
101+
102+
The parsed TCB version mapped to that cpuid in the :ref:`audit/builtin_maps:``nodes.snp.tcb_versions``` table, which is used to validate the TCB version of joining nodes.
103+
104+
.. note::
105+
The CPUID and TCB version must be input as lower-case hex-strings. The values in the above example are for Milan CPUs, and can be expanded as follows:
106+
107+
+-----------------+------------+
108+
| | Value |
109+
| CPUID Field +-----+------+
110+
| | dec | hex |
111+
+=================+=====+======+
112+
| Reserved | 0 | 0x0 |
113+
+-----------------+-----+------+
114+
| Extended Family | 10 | 0x0a |
115+
+-----------------+-----+------+
116+
| Extended Model | 0 | 0x0 |
117+
+-----------------+-----+------+
118+
| Reserved | 0 | 0x0 |
119+
+-----------------+-----+------+
120+
| Base Family | 15 | 0xf |
121+
+-----------------+-----+------+
122+
| Base Model | 1 | 0x1 |
123+
+-----------------+-----+------+
124+
| Stepping | 1 | 0x1 |
125+
+-----------------+-----+------+
126+
127+
SNP attestation structures contain the combined Family (``Extended Family + Base Family``) and Model (``Extended Model : Base Model``) values, so 25 (0x19) and 1 (0x01) respectively for the above Milan example.
128+
129+
The above TCB version ``d315000000000004`` is for a Milan CPU.
130+
It, and also TCB versions for Genoa CPUs, can be expanded as follows:
131+
132+
+-------------------+------------------+
133+
| | Value |
134+
| TCB Version Field +-----+------------+
135+
| | dec | hex |
136+
+===================+=====+============+
137+
| Microcode | 211 | 0xd3 |
138+
+-------------------+-----+------------+
139+
| SNP | 21 | 0x15 |
140+
+-------------------+-----+------------+
141+
| Reserved | 0 | 0x00000000 |
142+
+-------------------+-----+------------+
143+
| TEE | 0 | 0x00 |
144+
+-------------------+-----+------------+
145+
| Boot Loader | 4 | 0x04 |
146+
+-------------------+-----+------------+
147+
148+
The TCB version for Turin CPUs have a different format with, for example, ``1100000022334455`` having the following expanded fields:
149+
150+
+-------------------+------------------+
151+
| | Value |
152+
| TCB Version Field +-----+------------+
153+
| | dec | hex |
154+
+===================+=====+============+
155+
| Microcode | 17 | 0x11 |
156+
+-------------------+-----+------------+
157+
| Reserved | 0 | 0x000000 |
158+
+-------------------+-----+------------+
159+
| SNP | 34 | 0x22 |
160+
+-------------------+-----+------------+
161+
| TEE | 51 | 0x33 |
162+
+-------------------+-----+------------+
163+
| Boot Loader | 68 | 0x44 |
164+
+-------------------+-----+------------+
165+
| FMC | 85 | 0x55 |
166+
+-------------------+-----+------------+
81167

82168
.. rubric:: Footnotes
83169

doc/schemas/gov_openapi.json

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,27 +1175,27 @@
11751175
],
11761176
"type": "object"
11771177
},
1178-
"TcbVersion": {
1178+
"TcbVersionPolicy": {
11791179
"properties": {
11801180
"boot_loader": {
1181-
"$ref": "#/components/schemas/uint8"
1181+
"$ref": "#/components/schemas/uint32"
1182+
},
1183+
"fmc": {
1184+
"$ref": "#/components/schemas/uint32"
1185+
},
1186+
"hexstring": {
1187+
"$ref": "#/components/schemas/string"
11821188
},
11831189
"microcode": {
1184-
"$ref": "#/components/schemas/uint8"
1190+
"$ref": "#/components/schemas/uint32"
11851191
},
11861192
"snp": {
1187-
"$ref": "#/components/schemas/uint8"
1193+
"$ref": "#/components/schemas/uint32"
11881194
},
11891195
"tee": {
1190-
"$ref": "#/components/schemas/uint8"
1196+
"$ref": "#/components/schemas/uint32"
11911197
}
11921198
},
1193-
"required": [
1194-
"boot_loader",
1195-
"tee",
1196-
"snp",
1197-
"microcode"
1198-
],
11991199
"type": "object"
12001200
},
12011201
"TransactionId": {
@@ -1310,9 +1310,9 @@
13101310
},
13111311
"type": "object"
13121312
},
1313-
"string_to_TcbVersion": {
1313+
"string_to_TcbVersionPolicy": {
13141314
"additionalProperties": {
1315-
"$ref": "#/components/schemas/TcbVersion"
1315+
"$ref": "#/components/schemas/TcbVersionPolicy"
13161316
},
13171317
"type": "object"
13181318
},
@@ -1340,13 +1340,13 @@
13401340
},
13411341
"type": "object"
13421342
},
1343-
"uint64": {
1344-
"maximum": 18446744073709551615,
1343+
"uint32": {
1344+
"maximum": 4294967295,
13451345
"minimum": 0,
13461346
"type": "integer"
13471347
},
1348-
"uint8": {
1349-
"maximum": 255,
1348+
"uint64": {
1349+
"maximum": 18446744073709551615,
13501350
"minimum": 0,
13511351
"type": "integer"
13521352
}
@@ -1376,7 +1376,7 @@
13761376
"info": {
13771377
"description": "This API is used to submit and query proposals which affect CCF's public governance tables.",
13781378
"title": "CCF Governance API",
1379-
"version": "4.7.3"
1379+
"version": "4.7.4"
13801380
},
13811381
"openapi": "3.0.0",
13821382
"paths": {
@@ -2182,7 +2182,7 @@
21822182
"content": {
21832183
"application/json": {
21842184
"schema": {
2185-
"$ref": "#/components/schemas/string_to_TcbVersion"
2185+
"$ref": "#/components/schemas/string_to_TcbVersionPolicy"
21862186
}
21872187
}
21882188
},

include/ccf/js/extensions/ccf/converters.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ namespace ccf::js::extensions
1515
* - ccf.bufToJsonCompatible
1616
*
1717
* - ccf.pemToId
18+
* - ccf.tcbHexToPolicy
1819
*
1920
* - ccf.enableUntrustedDateTime
2021
* - ccf.enableMetricsLogging

include/ccf/pal/attestation.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,16 +221,17 @@ namespace ccf::pal
221221
const auto& endorsed_tcb = quote_info.endorsed_tcb.value();
222222
auto raw_tcb = ds::from_hex(quote_info.endorsed_tcb.value());
223223

224-
if (raw_tcb.size() != sizeof(snp::TcbVersion))
224+
if (raw_tcb.size() != sizeof(snp::TcbVersionRaw))
225225
{
226226
throw std::logic_error(fmt::format(
227227
"SEV-SNP: TCB of size {}, expected {}",
228228
raw_tcb.size(),
229-
sizeof(snp::TcbVersion)));
229+
sizeof(snp::TcbVersionRaw)));
230230
}
231231

232-
snp::TcbVersion tcb = *reinterpret_cast<snp::TcbVersion*>(raw_tcb.data());
233-
if (tcb != quote.reported_tcb)
232+
if (
233+
memcmp(
234+
raw_tcb.data(), &quote.reported_tcb, sizeof(snp::TcbVersionRaw)) != 0)
234235
{
235236
auto* reported_tcb = reinterpret_cast<uint8_t*>(&quote.reported_tcb);
236237
throw std::logic_error(fmt::format(

0 commit comments

Comments
 (0)