TianoCore EDK2 master
Loading...
Searching...
No Matches
SpdmLibStub.h
Go to the documentation of this file.
1
8#ifndef __LIBSPDM_STUB_H__
9#define __LIBSPDM_STUB_H__
10
11#include <library/spdm_common_lib.h>
12#include <library/spdm_return_status.h>
13#include <library/spdm_crypt_lib.h>
14#include <library/spdm_requester_lib.h>
15#include <library/spdm_responder_lib.h>
16#include <library/spdm_transport_pcidoe_lib.h>
17
18#pragma pack(1)
19
20/* The layout of SPDM_RETURN is
21 * [31:28] - Severity
22 * [27:24] - Reserved
23 * [23:16] - Source
24 * [15:00] - Code
25 */
26typedef UINT32 SPDM_RETURN;
27
28/*Interface of spdm.h*/
29/* SPDM message header*/
30typedef struct {
31 UINT8 SPDMVersion;
32 UINT8 RequestResponseCode;
33 UINT8 Param1;
34 UINT8 Param2;
36
37/* SPDM VERSION structure
38 * Bit[15:12] MajorVersion
39 * Bit[11:8] MinorVersion
40 * Bit[7:4] UpdateVersionNumber
41 * Bit[3:0] Alpha*/
42typedef UINT16 SPDM_VERSION_NUMBER;
43
44typedef struct {
45 /* Total length of the certificate chain, in bytes,
46 * including all fields in this table.*/
47
48 UINT16 Length;
49 UINT16 Reserved;
50
51 /* digest of the Root Certificate.
52 * Note that Root Certificate is ASN.1 DER-encoded for this digest.
53 * The hash size is determined by the SPDM device.*/
54
55 /*UINT8 RootHash[HashSize];*/
56
57 /* One or more ASN.1 DER-encoded X509v3 certificates where the first certificate is signed by the Root
58 * Certificate or is the Root Certificate itself and each subsequent certificate is signed by the preceding
59 * certificate. The last certificate is the Leaf Certificate.*/
60
61 /*UINT8 Certificates[length - 4 - HashSize];*/
63
64/* SPDM MEASUREMENTS block common header */
65typedef struct {
66 UINT8 Index;
67 UINT8 MeasurementSpecification;
68 UINT16 MeasurementSize;
69 /*UINT8 Measurement[MeasurementSize];*/
71
72/* SPDM MEASUREMENTS block DMTF header */
73typedef struct {
74 UINT8 DMTFSpecMeasurementValueType;
75 UINT16 DMTFSpecMeasurementValueSize;
76 /*UINT8 DMTFSpecMeasurementValue[DMTFSpecMeasurementValueSize];*/
78
79typedef struct {
80 SPDM_MEASUREMENT_BLOCK_COMMON_HEADER MeasurementBlockCommonHeader;
81 SPDM_MEASUREMENT_BLOCK_DMTF_HEADER MeasurementBlockDmtfHeader;
82 /*UINT8 HashValue[HashSize];*/
84
85#define SPDM_DATA_PARAMETER libspdm_data_parameter_t
86
87typedef enum {
88 //
89 // SPDM parameter
90 //
91 SpdmDataSpdmVersion,
92 SpdmDataSecuredMessageVersion,
93 //
94 // SPDM capability
95 //
96 SpdmDataCapabilityFlags,
97 SpdmDataCapabilityCTExponent,
98 SpdmDataCapabilityRttUs,
99 SpdmDataCapabilityDataTransferSize,
100 SpdmDataCapabilityMaxSpdmMsgSize,
101 SpdmDataCapabilitySenderDataTransferSize,
102
103 //
104 // SPDM Algorithm setting
105 //
106 SpdmDataMeasurementSpec,
107 SpdmDataMeasurementHashAlgo,
108 SpdmDataBaseAsymAlgo,
109 SpdmDataBaseHashAlgo,
110 SpdmDataDHENameGroup,
111 SpdmDataAEADCipherSuite,
112 SpdmDataReqBaseAsymAlg,
113 SpdmDataKeySchedule,
114 SpdmDataOtherParamsSupport,
115 SpdmDataMelSpec,
116
117 //
118 // Connection State
119 //
120 SpdmDataConnectionState,
121 //
122 // ResponseState
123 //
124 SpdmDataResponseState,
125 //
126 // Certificate info
127 //
128 SpdmDataLocalPublicCertChain,
129 SpdmDataPeerPublicRootCert,
130 SpdmDataPeerPublicKey,
131 SpdmDataLocalPublicKey,
132 SpdmDataLocalSupportedSlotMask,
133 SpdmDataLocalKeyPairId,
134 SpdmDataLocalCertInfo,
135 SpdmDataLocalKeyUsageBitMask,
136
137 SpdmDataBasicMutAuthRequested,
138 SpdmDataMutAuthRequested,
139 SpdmDataHeartBeatPeriod,
140 //
141 // Negotiated result
142 //
143 SpdmDataPeerUsedCertChainBuffer,
144 SpdmDataPeerSlotMask,
145 SpdmDataPeerProvisionedSlotMask = SpdmDataPeerSlotMask,
146 SpdmDataPeerSupportedSlotMask,
147 SpdmDataPeerTotalDigestBuffer,
148 SpdmDataPeerKeyPairId,
149 SpdmDataPeerCertInfo,
150 SpdmDataPeerKeyUsageBitMask,
151
152 //
153 // Pre-shared Key Hint
154 // If PSK is present, then PSK_EXCHANGE is used.
155 // Otherwise, the KEY_EXCHANGE is used.
156 //
157 SpdmDataPskHint,
158 //
159 // SessionData
160 //
161 SpdmDataSessionUsePsk,
162 SpdmDataSessionMutAuthRequested,
163 SpdmDataSessionEndSessionAttributes,
164 SpdmDataSessionPolicy,
165
166 SpdmDataAppContextData,
167
168 SpdmDataHandleErrorReturnPolicy,
169
170 /* VCA cached for CACHE_CAP in 1.2 for transcript.*/
171 SpdmDataVcaCache,
172
173 /* if the context is for a requester. It only needs to be set in VCA cache.*/
174 SpdmDataIsRequester,
175
176 // If the Responder replies with a Busy `ERROR` response to a request
177 // then the Requester is free to retry sending the request.
178 // This value specifies the maximum number of times libspdm will retry
179 // sending the request before returning an error.
180 // If its value is 0 then libspdm will not send any retry requests.
181 SpdmDataRequestRetryTimes,
182
183 // If the Responder replies with a Busy `ERROR` response to a request
184 // then the Requester is free to retry sending the request.
185 // This value specifies the delay time in microseconds between each retry requests.
186 // If its value is 0 then libspdm will send retry request immediately.
187 SpdmDataRequestRetryDelayTime,
188
189 /* limit the number of DHE session and PSK session separately.*/
190 SpdmDataMaxDheSessionConut,
191 SpdmDataMaxPskSessionConut,
192
193 SpdmDataSessionSequenceNumberRspDir,
194 SpdmDataSessionSequenceNumberReqDir,
195 SpdmDataMaxSessionSequenceNumber,
196
197 /* For SPDM 1.0 and 1.1, allow signature verification in big, little, or both endians. */
198 SpdmDataSpdmVersion1011VerifySigatureEndian,
199
200 SpdmDataSequenceNumberEndian,
201 SpdmDataSessionSequenceNumberEndian,
202
203 SpdmDataMultiKeyConnReq,
204 SpdmDataMultiKeyConnRsp,
205 //
206 // MAX
207 //
208 SpdmDataMax,
209} SPDM_DATA_TYPE;
210
211typedef enum {
212 SpdmDataLocationLocal,
213 SpdmDataLocationConnection,
214 SpdmDataLocationSession,
215 SpdmDataLocationMax,
216} SPDM_DATA_LOCATION;
217
218typedef enum {
219 //
220 // Before GET_VERSION/VERSION
221 //
222 SpdmConnectionStateNotStarted,
223 //
224 // After GET_VERSION/VERSION
225 //
226 SpdmConnectionStateAfterVersion,
227 //
228 // After GET_CAPABILITIES/CAPABILITIES
229 //
230 SpdmConnectionStateAfterCapabilities,
231 //
232 // After NEGOTIATE_ALGORITHMS/ALGORITHMS
233 //
234 SpdmConnectionStateNegotiated,
235 //
236 // After GET_DIGESTS/DIGESTS
237 //
238 SpdmConnectionStateAfterDigests,
239 //
240 // After GET_CERTIFICATE/CERTIFICATE
241 //
242 SpdmConnectionStateAfterCertificate,
243 //
244 // After CHALLENGE/CHALLENGE_AUTH, and ENCAP CALLENGE/CHALLENG_AUTH if MUT_AUTH is enabled.
245 //
246 SpdmConnectionStateAuthenticated,
247 //
248 // MAX
249 //
250 SpdmConnectionStateMax,
251} SPDM_CONNECTION_STATE;
252
253typedef enum {
254 //
255 // Normal response.
256 //
257 SpdmResponseStateNormal,
258 //
259 // Other component is busy.
260 //
261 SpdmResponseStateBusy,
262 #if LIBSPDM_RESPOND_IF_READY_SUPPORT
263 //
264 // Hardware is not ready.
265 //
266 SpdmResponseStateNotReady,
267 #endif /* LIBSPDM_RESPOND_IF_READY_SUPPORT */
268 //
269 // Firmware Update is done. Need resync.
270 //
271 SpdmResponseStateNeedResync,
272 //
273 // Processing Encapsulated message.
274 //
275 SpdmResponseStateProcessingEncap,
276 //
277 // MAX
278 //
279 SpdmResponseStateMax,
280} SPDM_RESPONSE_STATE;
281
282/* DOE header*/
283
284typedef struct {
285 UINT16 VendorId;
286 UINT8 DataObjectType;
287 UINT8 Reserved;
288
289 /* length of the data object being transfered in number of DW, including the header (2 DW)
290 * It only includes bit[0~17], bit[18~31] are reserved.
291 * A value of 00000h indicate 2^18 DW == 2^20 byte.*/
292 UINT32 Length;
293 /*UINT32 DataObjectDw[Length];*/
295
296#pragma pack()
297
298/* FUNCTION */
299#define SpdmSetData libspdm_set_data
300#define SpdmGetData libspdm_get_data
301#define SpdmInitContext libspdm_init_context
302#define SpdmGetContextSize libspdm_get_context_size
303#define SpdmRegisterDeviceIoFunc libspdm_register_device_io_func
304#define SpdmRegisterTransportLayerFunc libspdm_register_transport_layer_func
305#define SpdmGetSizeofRequiredScratchBuffer libspdm_get_sizeof_required_scratch_buffer
306#define SpdmRegisterDeviceBufferFunc libspdm_register_device_buffer_func
307#define SpdmSetScratchBuffer libspdm_set_scratch_buffer
308
309#define SpdmGetHashSize libspdm_get_hash_size
310#define SpdmHashAll libspdm_hash_all
311#define SpdmGetMeasurementHashSize libspdm_get_measurement_hash_size
312#define SpdmMeasurementHashAll libspdm_measurement_hash_all
313#define SpdmHmacAll libspdm_hmac_all
314#define SpdmHkdfExpand libspdm_hkdf_expand
315#define SpdmAsymFree libspdm_asym_free
316#define SpdmAsymGetPrivateKeyFromPem libspdm_asym_get_private_key_from_pem
317#define SpdmAsymSign libspdm_asym_sign
318#define SpdmAsymSignHash libspdm_asym_sign_hash
319
320#define SpdmInitConnection libspdm_init_connection
321#define SpdmGetDigest libspdm_get_digest
322#define SpdmGetCertificate libspdm_get_certificate
323#define SpdmGetCertificateEx libspdm_get_certificate_ex
324#define SpdmChallenge libspdm_challenge
325#define SpdmChallengeEx libspdm_challenge_ex
326#define SpdmGetMeasurement libspdm_get_measurement
327#define SpdmGetMeasurementEx libspdm_get_measurement_ex
328#define SpdmStartSession libspdm_start_session
329#define SpdmStopSession libspdm_stop_session
330#define SpdmSendReceiveData libspdm_send_receive_data
331#define SpdmRegisterGetResponseFunc libspdm_register_get_response_func
332#define SpdmProcessRequest libspdm_process_request
333#define SpdmBuildResponse libspdm_build_response
334#define SpdmGenerateErrorResponse libspdm_generate_error_response
335#define SpdmTransportPciDoeEncodeMessage libspdm_transport_pci_doe_encode_message
336#define SpdmTransportPciDoeDecodeMessage libspdm_transport_pci_doe_decode_message
337
338#define SpdmMeasurementCollectionFunc libspdm_measurement_collection
339#define SpdmRequesterDataSignFunc libspdm_requester_data_sign
340#define SpdmResponderDataSignFunc libspdm_responder_data_sign
341#define SpdmGenerateMeasurementSummaryHash libspdm_generate_measurement_summary_hash
342#define SpdmPskMasterSecretHkdfExpandFunc libspdm_psk_master_secret_hkdf_expand
343#define SpdmPskHandshakeSecretHkdfExpandFunc libspdm_psk_handshake_secret_hkdf_expand
344#define SpdmMeasurementOpaqueData libspdm_measurement_opaque_data
345#define SpdmChallengeOpaqueData libspdm_challenge_opaque_data
346
347#endif
UINT16 SPDM_VERSION_NUMBER
Definition: Spdm.h:125