Coverage Report

Created: 2026-03-12 07:05

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libspdm/include/internal/libspdm_common_lib.h
Line
Count
Source
1
/**
2
 *  Copyright Notice:
3
 *  Copyright 2021-2026 DMTF. All rights reserved.
4
 *  License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
5
 **/
6
7
#ifndef SPDM_COMMON_LIB_INTERNAL_H
8
#define SPDM_COMMON_LIB_INTERNAL_H
9
10
#include "library/spdm_common_lib.h"
11
#include "library/spdm_secured_message_lib.h"
12
#include "library/spdm_return_status.h"
13
#include "library/spdm_crypt_lib.h"
14
#include "hal/library/debuglib.h"
15
#include "hal/library/memlib.h"
16
#include "hal/library/requester/reqasymsignlib.h"
17
#include "hal/library/requester/psklib.h"
18
#include "hal/library/responder/asymsignlib.h"
19
#include "hal/library/responder/csrlib.h"
20
#include "hal/library/responder/measlib.h"
21
#include "hal/library/responder/keyexlib.h"
22
#include "hal/library/responder/key_pair_info.h"
23
#include "hal/library/responder/psklib.h"
24
#include "hal/library/responder/setcertlib.h"
25
#include "hal/library/endpointinfolib.h"
26
#include "hal/library/eventlib.h"
27
#include "hal/library/cryptlib.h"
28
29
181k
#define INVALID_SESSION_ID LIBSPDM_INVALID_SESSION_ID
30
/* The SPDM specification does not limit the values of CTExponent and RDTExponent.
31
 * libspdm artificially limits their values to 31, which corresponds to approximately 35 minutes
32
 * for CT and RDT. If an endpoint takes longer than 35 minutes to generate an SPDM message then
33
 * libspdm assumes the Integrator would not want to interact with such an endpoint. A maximum value
34
 * of 31 also means that, when calculating CT and RDT, a left-shift will not result in C undefined
35
 * behavior.
36
 */
37
191
#define LIBSPDM_MAX_CT_EXPONENT 31
38
2.17k
#define LIBSPDM_MAX_RDT_EXPONENT 31
39
40
49.2k
#define LIBSPDM_MAX_SPDM_SESSION_SEQUENCE_NUMBER 0xFFFFFFFFFFFFFFFFull
41
42
typedef struct {
43
    uint8_t spdm_version_count;
44
    spdm_version_number_t spdm_version[SPDM_MAX_VERSION_COUNT];
45
} libspdm_device_version_t;
46
47
typedef struct {
48
    uint8_t secured_message_version_count;
49
    spdm_version_number_t secured_message_version[SECURED_SPDM_MAX_VERSION_COUNT];
50
} libspdm_secured_message_version_t;
51
52
typedef struct {
53
    uint8_t ct_exponent;
54
    uint64_t rtt;
55
    uint32_t st1;
56
    uint32_t flags;
57
    uint16_t ext_flags;
58
    uint32_t data_transfer_size;
59
    uint32_t sender_data_transfer_size;
60
    uint32_t max_spdm_msg_size;
61
    uint32_t transport_header_size;
62
    uint32_t transport_tail_size;
63
} libspdm_device_capability_t;
64
65
typedef struct {
66
    uint8_t measurement_spec;
67
    uint8_t other_params_support;
68
    uint8_t mel_spec;
69
    uint32_t measurement_hash_algo;
70
    uint32_t base_asym_algo;
71
    uint32_t base_hash_algo;
72
    uint16_t dhe_named_group;
73
    uint16_t aead_cipher_suite;
74
    uint16_t req_base_asym_alg;
75
    uint16_t key_schedule;
76
    uint32_t pqc_asym_algo;
77
    uint32_t req_pqc_asym_alg;
78
    uint32_t kem_alg;
79
    bool pqc_first;
80
} libspdm_device_algorithm_t;
81
82
typedef struct {
83
#if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
84
    uint8_t buffer[LIBSPDM_MAX_CERT_CHAIN_SIZE];
85
    size_t buffer_size;
86
#else
87
    uint8_t buffer_hash[LIBSPDM_MAX_HASH_SIZE];
88
    uint32_t buffer_hash_size;
89
    /* leaf cert public key of the peer */
90
    void *leaf_cert_public_key;
91
#endif
92
} libspdm_peer_used_cert_chain_t;
93
94
typedef struct {
95
    /* Local device info */
96
    libspdm_device_version_t version;
97
    libspdm_device_capability_t capability;
98
    libspdm_device_algorithm_t algorithm;
99
    libspdm_secured_message_version_t secured_message_version;
100
101
    /* My Certificate */
102
    const void *local_cert_chain_provision[SPDM_MAX_SLOT_COUNT];
103
    size_t local_cert_chain_provision_size[SPDM_MAX_SLOT_COUNT];
104
    uint8_t local_supported_slot_mask;
105
    uint8_t cert_slot_reset_mask;
106
    spdm_key_pair_id_t local_key_pair_id[SPDM_MAX_SLOT_COUNT];
107
    spdm_certificate_info_t local_cert_info[SPDM_MAX_SLOT_COUNT];
108
    spdm_key_usage_bit_mask_t local_key_usage_bit_mask[SPDM_MAX_SLOT_COUNT];
109
    /* My raw public key (slot_id - 0xFF) */
110
    const void *local_public_key_provision;
111
    size_t local_public_key_provision_size;
112
113
    /* Peer Root Certificate */
114
    const void *peer_root_cert_provision[LIBSPDM_MAX_ROOT_CERT_SUPPORT];
115
    size_t peer_root_cert_provision_size[LIBSPDM_MAX_ROOT_CERT_SUPPORT];
116
    /* Peer raw public key (slot_id - 0xFF) */
117
    const void *peer_public_key_provision;
118
    size_t peer_public_key_provision_size;
119
120
    /* Peer Cert verify*/
121
    libspdm_verify_spdm_cert_chain_func verify_peer_spdm_cert_chain;
122
123
    /* Responder policy*/
124
    bool basic_mut_auth_requested;
125
    uint8_t heartbeat_period;
126
127
    /*The device role*/
128
    bool is_requester;
129
} libspdm_local_context_t;
130
131
typedef struct {
132
    /* Connection State */
133
    libspdm_connection_state_t connection_state;
134
135
    /* Peer device info (negotiated) */
136
    spdm_version_number_t version;
137
    libspdm_device_capability_t capability;
138
    libspdm_device_algorithm_t algorithm;
139
140
    /* Peer digests buffer */
141
    uint8_t peer_provisioned_slot_mask;
142
    uint8_t peer_supported_slot_mask;
143
144
    spdm_key_pair_id_t peer_key_pair_id[SPDM_MAX_SLOT_COUNT];
145
    spdm_certificate_info_t peer_cert_info[SPDM_MAX_SLOT_COUNT];
146
    spdm_key_usage_bit_mask_t peer_key_usage_bit_mask[SPDM_MAX_SLOT_COUNT];
147
148
    /* Peer CertificateChain */
149
    libspdm_peer_used_cert_chain_t peer_used_cert_chain[SPDM_MAX_SLOT_COUNT];
150
151
    /* Specifies whether the cached negotiated state should be invalidated. (responder only)
152
     * This is a "sticky" bit wherein if it is set to 1 then it cannot be set to 0. */
153
    uint8_t end_session_attributes;
154
155
    /* multi-key negotiated result */
156
    bool multi_key_conn_req;
157
    bool multi_key_conn_rsp;
158
} libspdm_connection_info_t;
159
160
typedef struct {
161
    size_t max_buffer_size;
162
    size_t buffer_size;
163
    /*uint8_t   buffer[max_buffer_size];*/
164
} libspdm_managed_buffer_t;
165
166
typedef struct {
167
    size_t max_buffer_size;
168
    size_t buffer_size;
169
    uint8_t buffer[LIBSPDM_MAX_MESSAGE_VCA_BUFFER_SIZE];
170
} libspdm_vca_managed_buffer_t;
171
172
/*
173
 * +--------------------------+------------------------------------------+---------+
174
 * | DIGESTS 1.4              | 4 + (H [+ 4]) * SlotNum = [36, 548]      | [1, 18] |
175
 * +--------------------------+------------------------------------------+---------+
176
 * It is for multi-key.
177
 */
178
#define LIBSPDM_MAX_MESSAGE_D_BUFFER_SIZE (4 + \
179
                                           (LIBSPDM_MAX_HASH_SIZE + 4) * SPDM_MAX_SLOT_COUNT)
180
181
typedef struct {
182
    size_t max_buffer_size;
183
    size_t buffer_size;
184
    uint8_t buffer[LIBSPDM_MAX_MESSAGE_D_BUFFER_SIZE];
185
} libspdm_message_d_managed_buffer_t;
186
187
#if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
188
189
/*
190
 * +--------------------------+------------------------------------------+---------+
191
 * | GET_DIGESTS 1.4          | 4                                        | 1       |
192
 * | DIGESTS 1.4              | 4 + (H [+ 4]) * SlotNum = [36, 548]      | [1, 18] |
193
 * +--------------------------+------------------------------------------+---------+
194
 * | GET_CERTIFICATE 1.4      | 16                                       | 1       |
195
 * | CERTIFICATE 1.4          | 16 + PortionLen                          | [1, ]   |
196
 * +--------------------------+------------------------------------------+---------+
197
 */
198
#define LIBSPDM_MAX_MESSAGE_B_BUFFER_SIZE (40 + \
199
                                           (LIBSPDM_MAX_HASH_SIZE + 4) * SPDM_MAX_SLOT_COUNT + \
200
                                           LIBSPDM_MAX_CERT_CHAIN_SIZE)
201
202
/*
203
 * +--------------------------+------------------------------------------+---------+
204
 * | CHALLENGE 1.4            | 44                                       | 1       |
205
 * | CHALLENGE_AUTH 1.4       | 46 + H * 2 + S [+ O] = [166, 678]        | [6, 23] |
206
 * +--------------------------+------------------------------------------+---------+
207
 */
208
#define LIBSPDM_MAX_MESSAGE_C_BUFFER_SIZE (90 + \
209
                                           LIBSPDM_MAX_HASH_SIZE * 2 + \
210
                                           LIBSPDM_RSP_SIGNATURE_DATA_MAX_SIZE + \
211
                                           SPDM_MAX_OPAQUE_DATA_SIZE)
212
213
/*
214
 * +--------------------------+------------------------------------------+---------+
215
 * | GET_MEASUREMENTS 1.4     | 13 + Nonce (0 or 32)                     | 1       |
216
 * | MEASUREMENTS 1.4         | 50 + MeasRecLen (+ S) [+ O] = [106, 554] | [4, 19] |
217
 * +--------------------------+------------------------------------------+---------+
218
 */
219
#define LIBSPDM_MAX_MESSAGE_M_BUFFER_SIZE (63 + SPDM_NONCE_SIZE + \
220
                                           LIBSPDM_MAX_MEASUREMENT_RECORD_SIZE + \
221
                                           LIBSPDM_RSP_SIGNATURE_DATA_MAX_SIZE + \
222
                                           SPDM_MAX_OPAQUE_DATA_SIZE)
223
224
/*
225
 * +--------------------------+------------------------------------------+---------+
226
 * | KEY_EXCHANGE 1.4         | 42 + D [+ O] = [106, 554]                | [4, 19] |
227
 * | KEY_EXCHANGE_RSP 1.4     | 42 + D + H + S (+ H) [+ O] = [234, 1194] | [8, 40] |
228
 * +--------------------------+------------------------------------------+---------+
229
 * | PSK_EXCHANGE 1.4         | 12 [+ PSKHint] + R [+ O] = 44            | 2       |
230
 * | PSK_EXCHANGE_RSP 1.4     | 12 + R + H (+ H) [+ O] = [108, 172]      | [4, 6]  |
231
 * +--------------------------+------------------------------------------+---------+
232
 */
233
#define LIBSPDM_MAX_MESSAGE_K_BUFFER_SIZE (84 + LIBSPDM_REQ_EXCHANGE_DATA_MAX_SIZE + \
234
                                           LIBSPDM_RSP_EXCHANGE_DATA_MAX_SIZE + \
235
                                           LIBSPDM_MAX_HASH_SIZE * 2 + \
236
                                           LIBSPDM_RSP_SIGNATURE_DATA_MAX_SIZE + \
237
                                           SPDM_MAX_OPAQUE_DATA_SIZE * 2)
238
239
/*
240
 * +--------------------------+------------------------------------------+---------+
241
 * | FINISH 1.4               | 6 (+ S) + H [+ O] = [100, 580]           | [4, 20] |
242
 * | FINISH_RSP 1.4           | 6 (+ H) [+ O] = [36, 69]                 | [1, 3]  |
243
 * +--------------------------+------------------------------------------+---------+
244
 * | PSK_FINISH 1.4           | 6 + H [+ O] = [36, 68]                   | [1, 3]  |
245
 * | PSK_FINISH_RSP 1.4       | 6 [+ O]                                  | 1       |
246
 * +--------------------------+------------------------------------------+---------+
247
 */
248
#define LIBSPDM_MAX_MESSAGE_F_BUFFER_SIZE (12 + LIBSPDM_MAX_HASH_SIZE * 2 + \
249
                                           LIBSPDM_REQ_SIGNATURE_DATA_MAX_SIZE + \
250
                                           SPDM_MAX_OPAQUE_DATA_SIZE * 2)
251
252
/*
253
 * +--------------------------+------------------------------------------+---------+
254
 * | GET_EP_INFO 1.4          | 8 + Nonce (0 or 32) = [8, 40]            | 1       |
255
 * | EP_INFO 1.4              | 12 + Nonce + EPInfoLen (+ S) = [12, 1024]| [1, 25] |
256
 * +--------------------------+------------------------------------------+---------+
257
 */
258
#define LIBSPDM_MAX_MESSAGE_E_BUFFER_SIZE (20 + SPDM_NONCE_SIZE * 2 + \
259
                                           LIBSPDM_MAX_ENDPOINT_INFO_LENGTH + \
260
                                           LIBSPDM_RSP_SIGNATURE_DATA_MAX_SIZE)
261
262
#define LIBSPDM_MAX_MESSAGE_L1L2_BUFFER_SIZE \
263
    (LIBSPDM_MAX_MESSAGE_VCA_BUFFER_SIZE + LIBSPDM_MAX_MESSAGE_M_BUFFER_SIZE)
264
265
#define LIBSPDM_MAX_MESSAGE_M1M2_BUFFER_SIZE \
266
    (LIBSPDM_MAX_MESSAGE_VCA_BUFFER_SIZE + \
267
     LIBSPDM_MAX_MESSAGE_B_BUFFER_SIZE + LIBSPDM_MAX_MESSAGE_C_BUFFER_SIZE)
268
269
#define LIBSPDM_MAX_MESSAGE_TH_BUFFER_SIZE \
270
    (LIBSPDM_MAX_MESSAGE_VCA_BUFFER_SIZE + \
271
     LIBSPDM_MAX_MESSAGE_D_BUFFER_SIZE + \
272
     LIBSPDM_MAX_HASH_SIZE + LIBSPDM_MAX_MESSAGE_K_BUFFER_SIZE + \
273
     LIBSPDM_MAX_MESSAGE_D_BUFFER_SIZE + \
274
     LIBSPDM_MAX_HASH_SIZE + LIBSPDM_MAX_MESSAGE_F_BUFFER_SIZE)
275
276
#define LIBSPDM_MAX_MESSAGE_IL1IL2_BUFFER_SIZE \
277
    (LIBSPDM_MAX_MESSAGE_VCA_BUFFER_SIZE + LIBSPDM_MAX_MESSAGE_E_BUFFER_SIZE)
278
279
typedef struct {
280
    size_t max_buffer_size;
281
    size_t buffer_size;
282
    uint8_t buffer[LIBSPDM_MAX_MESSAGE_B_BUFFER_SIZE];
283
} libspdm_message_b_managed_buffer_t;
284
285
typedef struct {
286
    size_t max_buffer_size;
287
    size_t buffer_size;
288
    uint8_t buffer[LIBSPDM_MAX_MESSAGE_C_BUFFER_SIZE];
289
} libspdm_message_c_managed_buffer_t;
290
291
typedef struct {
292
    size_t max_buffer_size;
293
    size_t buffer_size;
294
    uint8_t buffer[LIBSPDM_MAX_MESSAGE_M_BUFFER_SIZE];
295
} libspdm_message_m_managed_buffer_t;
296
297
typedef struct {
298
    size_t max_buffer_size;
299
    size_t buffer_size;
300
    uint8_t buffer[LIBSPDM_MAX_MESSAGE_K_BUFFER_SIZE];
301
} libspdm_message_k_managed_buffer_t;
302
303
typedef struct {
304
    size_t max_buffer_size;
305
    size_t buffer_size;
306
    uint8_t buffer[LIBSPDM_MAX_MESSAGE_F_BUFFER_SIZE];
307
} libspdm_message_f_managed_buffer_t;
308
309
typedef struct {
310
    size_t max_buffer_size;
311
    size_t buffer_size;
312
    uint8_t buffer[LIBSPDM_MAX_MESSAGE_E_BUFFER_SIZE];
313
} libspdm_message_e_managed_buffer_t;
314
315
typedef struct {
316
    size_t max_buffer_size;
317
    size_t buffer_size;
318
    uint8_t buffer[LIBSPDM_MAX_MESSAGE_L1L2_BUFFER_SIZE];
319
} libspdm_l1l2_managed_buffer_t;
320
321
typedef struct {
322
    size_t max_buffer_size;
323
    size_t buffer_size;
324
    uint8_t buffer[LIBSPDM_MAX_MESSAGE_M1M2_BUFFER_SIZE];
325
} libspdm_m1m2_managed_buffer_t;
326
327
typedef struct {
328
    size_t max_buffer_size;
329
    size_t buffer_size;
330
    uint8_t buffer[LIBSPDM_MAX_MESSAGE_IL1IL2_BUFFER_SIZE];
331
} libspdm_il1il2_managed_buffer_t;
332
333
typedef struct {
334
    size_t max_buffer_size;
335
    size_t buffer_size;
336
    uint8_t buffer[LIBSPDM_MAX_MESSAGE_TH_BUFFER_SIZE];
337
} libspdm_th_managed_buffer_t;
338
339
#endif /* LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT */
340
341
/* signature = Sign(SK, hash(M1))
342
 * Verify(PK, hash(M2), signature)*/
343
344
/* M1/M2 = Concatenate (A, B, C)
345
 * A = Concatenate (GET_VERSION, VERSION, GET_CAPABILITIES, CAPABILITIES, NEGOTIATE_ALGORITHMS, ALGORITHMS)
346
 * B = Concatenate (GET_DIGEST, DIGEST, GET_CERTIFICATE, CERTIFICATE)
347
 * C = Concatenate (CHALLENGE, CHALLENGE_AUTH\signature)*/
348
349
/* Mut M1/M2 = Concatenate (MutB, MutC)
350
 * MutB = Concatenate (GET_DIGEST, DIGEST, GET_CERTIFICATE, CERTIFICATE)
351
 * MutC = Concatenate (CHALLENGE, CHALLENGE_AUTH\signature)*/
352
353
/* signature = Sign(SK, hash(L1))
354
 * Verify(PK, hash(L2), signature)*/
355
356
/* L1/L2 = Concatenate (M)
357
 * M = Concatenate (GET_MEASUREMENT, MEASUREMENT\signature)*/
358
359
/* IL1/IL2 = Concatenate (A, E)
360
 * E = Concatenate (GET_ENDPOINT_INFO, ENDPOINT_INFO\signature)*/
361
362
/* Encap IL1/IL2 = Concatenate (A, Encap E)
363
 * Encap E = Concatenate (GET_ENDPOINT_INFO, ENDPOINT_INFO\signature)*/
364
365
typedef struct {
366
    /* the message_a must be plan text because we do not know the algorithm yet.*/
367
    libspdm_vca_managed_buffer_t message_a;
368
    libspdm_message_d_managed_buffer_t message_d;
369
#if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
370
    libspdm_message_b_managed_buffer_t message_b;
371
    libspdm_message_c_managed_buffer_t message_c;
372
    libspdm_message_b_managed_buffer_t message_mut_b;
373
    libspdm_message_c_managed_buffer_t message_mut_c;
374
    libspdm_message_m_managed_buffer_t message_m;
375
    libspdm_message_e_managed_buffer_t message_e;
376
    libspdm_message_e_managed_buffer_t message_encap_e;
377
#else
378
    void *digest_context_m1m2;
379
    void *digest_context_mut_m1m2;
380
    void *digest_context_l1l2;
381
    void *digest_context_il1il2;
382
    void *digest_context_encap_il1il2;
383
#endif
384
} libspdm_transcript_t;
385
386
/* TH for KEY_EXCHANGE response signature: Concatenate (A, D, Ct, K)
387
 * D = DIGEST, if MULTI_KEY_CONN_RSP
388
 * Ct = certificate chain
389
 * K  = Concatenate (KEY_EXCHANGE request, KEY_EXCHANGE response\signature+verify_data)*/
390
391
/* TH for KEY_EXCHANGE response HMAC: Concatenate (A, D, Ct, K)
392
 * D = DIGEST, if MULTI_KEY_CONN_RSP
393
 * Ct = certificate chain
394
 * K  = Concatenate (KEY_EXCHANGE request, KEY_EXCHANGE response\verify_data)*/
395
396
/* TH for FINISH request signature: Concatenate (A, D, Ct, K, EncapD, CM, F)
397
 * D = DIGEST, if MULTI_KEY_CONN_RSP
398
 * Ct = certificate chain
399
 * K  = Concatenate (KEY_EXCHANGE request, KEY_EXCHANGE response)
400
 * EncapD = Encap DIGEST, if MULTI_KEY_CONN_REQ
401
 * CM = mutual certificate chain
402
 * F  = Concatenate (FINISH request\signature+verify_data)*/
403
404
/* TH for FINISH response HMAC: Concatenate (A, D, Ct, K, EncapD, CM, F)
405
 * D = DIGEST, if MULTI_KEY_CONN_RSP
406
 * Ct = certificate chain
407
 * K = Concatenate (KEY_EXCHANGE request, KEY_EXCHANGE response)
408
 * EncapD = Encap DIGEST, if MULTI_KEY_CONN_REQ
409
 * CM = mutual certificate chain, if MutAuth
410
 * F = Concatenate (FINISH request\verify_data)*/
411
412
/* th1: Concatenate (A, D, Ct, K)
413
 * D = DIGEST, if MULTI_KEY_CONN_RSP
414
 * Ct = certificate chain
415
 * K  = Concatenate (KEY_EXCHANGE request, KEY_EXCHANGE response)*/
416
417
/* th2: Concatenate (A, D, Ct, K, EncapD, CM, F)
418
 * D = DIGEST, if MULTI_KEY_CONN_RSP
419
 * Ct = certificate chain
420
 * K  = Concatenate (KEY_EXCHANGE request, KEY_EXCHANGE response)
421
 * EncapD = Encap DIGEST, if MULTI_KEY_CONN_REQ
422
 * CM = mutual certificate chain, if MutAuth
423
 * F  = Concatenate (FINISH request, FINISH response)*/
424
425
/* TH for PSK_EXCHANGE response HMAC: Concatenate (A, K)
426
 * K  = Concatenate (PSK_EXCHANGE request, PSK_EXCHANGE response\verify_data)*/
427
428
/* TH for PSK_FINISH response HMAC: Concatenate (A, K, F)
429
 * K  = Concatenate (PSK_EXCHANGE request, PSK_EXCHANGE response)
430
 * F  = Concatenate (PSK_FINISH request\verify_data)*/
431
432
/* TH1_PSK1: Concatenate (A, K)
433
 * K  = Concatenate (PSK_EXCHANGE request, PSK_EXCHANGE response\verify_data)*/
434
435
/* TH1_PSK2: Concatenate (A, K, F)
436
 * K  = Concatenate (PSK_EXCHANGE request, PSK_EXCHANGE response)
437
 * F  = Concatenate (PSK_FINISH request\verify_data)*/
438
439
/* TH2_PSK: Concatenate (A, K, F)
440
 * K  = Concatenate (PSK_EXCHANGE request, PSK_EXCHANGE response)
441
 * F  = Concatenate (PSK_FINISH request, PSK_FINISH response)*/
442
443
typedef struct {
444
    libspdm_message_d_managed_buffer_t message_encap_d;
445
#if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
446
    libspdm_message_k_managed_buffer_t message_k;
447
    libspdm_message_f_managed_buffer_t message_f;
448
    libspdm_message_m_managed_buffer_t message_m;
449
    libspdm_message_e_managed_buffer_t message_e;
450
    libspdm_message_e_managed_buffer_t message_encap_e;
451
#else
452
    bool message_f_initialized;
453
    void *digest_context_th;
454
    void *digest_context_l1l2;
455
    void *digest_context_il1il2;
456
    void *digest_context_encap_il1il2;
457
    /* this is back up for message F reset.*/
458
    void *digest_context_th_backup;
459
#endif
460
} libspdm_session_transcript_t;
461
462
typedef struct {
463
    uint32_t session_id;
464
    bool use_psk;
465
    uint8_t mut_auth_requested;
466
    uint8_t end_session_attributes;
467
    uint8_t session_policy;
468
    uint8_t heartbeat_period;
469
    libspdm_session_transcript_t session_transcript;
470
    /* Register for the last KEY_UPDATE token and operation (responder only)*/
471
    spdm_key_update_request_t last_key_update_request;
472
    void *secured_message_context;
473
    /* Only present in session info as it is currently only used within a secure session. */
474
    uint8_t local_used_cert_chain_slot_id;
475
    uint8_t peer_used_cert_chain_slot_id;
476
} libspdm_session_info_t;
477
478
1.55k
#define LIBSPDM_MAX_ENCAP_REQUEST_OP_CODE_SEQUENCE_COUNT 3
479
typedef struct {
480
    /* Valid OpCode: GET_DIGEST/GET_CERTIFICATE/CHALLENGE/KEY_UPDATE/GET_ENDPOINT_INFO/SEND_EVENT
481
     * The last one is 0x00, as a terminator. */
482
    uint8_t request_op_code_sequence[LIBSPDM_MAX_ENCAP_REQUEST_OP_CODE_SEQUENCE_COUNT + 1];
483
    uint8_t request_op_code_count;
484
    uint8_t current_request_op_code;
485
    uint8_t request_id;
486
    uint8_t req_slot_id;
487
    spdm_message_header_t last_encap_request_header;
488
    size_t last_encap_request_size;
489
    uint32_t cert_chain_total_len;
490
    uint8_t req_context[SPDM_REQ_CONTEXT_SIZE];
491
    uint32_t session_id;
492
    bool use_large_cert_chain;
493
} libspdm_encap_context_t;
494
495
#if LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP
496
typedef struct {
497
    bool chunk_in_use;
498
    uint8_t chunk_handle;
499
    uint32_t chunk_seq_no;
500
    size_t chunk_bytes_transferred;
501
502
    void* large_message;
503
    size_t large_message_size;
504
    size_t large_message_capacity;
505
} libspdm_chunk_info_t;
506
507
typedef struct {
508
    libspdm_chunk_info_t send;
509
    libspdm_chunk_info_t get;
510
} libspdm_chunk_context_t;
511
#endif /* LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP */
512
513
#if LIBSPDM_ENABLE_MSG_LOG
514
typedef struct {
515
    void *buffer;
516
    size_t max_buffer_size;
517
    uint32_t mode;
518
    size_t buffer_size;
519
    uint32_t status;
520
} libspdm_msg_log_t;
521
#endif /* LIBSPDM_ENABLE_MSG_LOG */
522
523
#if LIBSPDM_FIPS_MODE
524
typedef struct {
525
    /**
526
     * Tested algo flag: 0 represents that the algo is not tested.
527
     * See LIBSPDM_FIPS_SELF_TEST_xxx;
528
     **/
529
    uint32_t tested_algo;
530
    /**
531
     * Flag for the result of run algo self_test, 0 represents the result is failed.
532
     * See LIBSPDM_FIPS_SELF_TEST_xxx;
533
     **/
534
    uint32_t self_test_result;
535
    /**
536
     * Buffer provided by integrator to hold large intermediate results.
537
     **/
538
    void *selftest_buffer;
539
    size_t selftest_buffer_size;
540
} libspdm_fips_selftest_context_t;
541
#endif /* LIBSPDM_FIPS_MODE */
542
543
49.2k
#define LIBSPDM_CONTEXT_STRUCT_VERSION 0x3
544
545
typedef struct {
546
    uint32_t version;
547
548
    /* IO information */
549
    libspdm_device_send_message_func send_message;
550
    libspdm_device_receive_message_func receive_message;
551
552
    /*
553
     * reserved for request and response in the main dispatch function in SPDM responder.
554
     * this buffer is the transport message received from spdm_context->receive_message()
555
     * or sent to spdm_context->send_message().
556
     * This message may be SPDM transport message or secured SPDM transport message.
557
     **/
558
    libspdm_device_acquire_sender_buffer_func acquire_sender_buffer;
559
    libspdm_device_release_sender_buffer_func release_sender_buffer;
560
    libspdm_device_acquire_receiver_buffer_func acquire_receiver_buffer;
561
    libspdm_device_release_receiver_buffer_func release_receiver_buffer;
562
563
    /* Transport Layer information */
564
    libspdm_transport_encode_message_func transport_encode_message;
565
    libspdm_transport_decode_message_func transport_decode_message;
566
567
    /* Cached plain text command
568
     * If the command is cipher text, decrypt then cache it. */
569
    void *last_spdm_request;
570
    size_t last_spdm_request_size;
571
572
    /* Buffers used for data processing and transport. */
573
    void *scratch_buffer;
574
    size_t scratch_buffer_size;
575
    void *sender_buffer;
576
    size_t sender_buffer_size;
577
    void *receiver_buffer;
578
    size_t receiver_buffer_size;
579
580
    /* Cache session_id in this spdm_message, only valid for secured message. */
581
    uint32_t last_spdm_request_session_id;
582
    bool last_spdm_request_session_id_valid;
583
584
    /* Cache the error in libspdm_process_request. It is handled in libspdm_build_response. */
585
    libspdm_error_struct_t last_spdm_error;
586
587
    /* Register GetResponse function (responder only) */
588
    void *get_response_func;
589
590
    /* Register GetEncapResponse function (requester only) */
591
    void *get_encap_response_func;
592
    libspdm_encap_context_t encap_context;
593
594
    /* Register spdm_session_state_callback function (responder only)
595
    * Register can know the state after StartSession / EndSession. */
596
    void *spdm_session_state_callback;
597
598
    /* Register spdm_connection_state_callback function (responder only)
599
     * Register can know the connection state such as negotiated. */
600
    void *spdm_connection_state_callback;
601
602
    /* Register libspdm_key_update_callback function (responder only)
603
     * Register can know when session keys are updated during KEY_UPDATE operations. */
604
    void *spdm_key_update_callback;
605
606
    libspdm_local_context_t local_context;
607
608
    libspdm_connection_info_t connection_info;
609
    libspdm_transcript_t transcript;
610
611
    libspdm_session_info_t session_info[LIBSPDM_MAX_SESSION_COUNT];
612
613
    /* Buffer that the Responder uses to store the Requester's certificate chain for
614
     * mutual authentication. */
615
    void *mut_auth_cert_chain_buffer;
616
    size_t mut_auth_cert_chain_buffer_size;
617
    size_t mut_auth_cert_chain_buffer_max_size;
618
619
    /* Cache latest session ID for HANDSHAKE_IN_THE_CLEAR */
620
    uint32_t latest_session_id;
621
622
    /* Register for Responder state, be initial to Normal (responder only) */
623
    libspdm_response_state_t response_state;
624
625
    /* Cached data for SPDM_ERROR_CODE_RESPONSE_NOT_READY/SPDM_RESPOND_IF_READY */
626
    spdm_error_data_response_not_ready_t error_data;
627
#if LIBSPDM_RESPOND_IF_READY_SUPPORT
628
    void *cache_spdm_request;
629
    size_t cache_spdm_request_size;
630
#endif
631
    uint8_t current_token;
632
633
    /* Register for the retry times when receive "BUSY" Error response (requester only) */
634
    uint8_t retry_times;
635
    /* Register for the delay time in microseconds between retry requests
636
     * when receive "BUSY" Error response (requester only) */
637
    uint64_t retry_delay_time;
638
    bool crypto_request;
639
640
    /* App context data for use by application */
641
    void *app_context_data_ptr;
642
643
    /* See LIBSPDM_DATA_HANDLE_ERROR_RETURN_POLICY_*. */
644
    uint8_t handle_error_return_policy;
645
646
    /* Max session count for DHE session and PSK session
647
     * Set via LIBSPDM_DATA_MAX_DHE_SESSION_COUNT and LIBSPDM_DATA_MAX_PSK_SESSION_COUNT */
648
    uint32_t max_dhe_session_count;
649
    uint32_t max_psk_session_count;
650
651
    /* Current session count for DHE session and PSK session */
652
    uint32_t current_dhe_session_count;
653
    uint32_t current_psk_session_count;
654
655
    /* see LIBSPDM_DATA_MAX_SPDM_SESSION_SEQUENCE_NUMBER */
656
    uint64_t max_spdm_session_sequence_number;
657
658
    uint8_t sequence_number_endian;
659
660
#if LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP
661
    /* Chunk specific context */
662
    libspdm_chunk_context_t chunk_context;
663
#endif /* LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP */
664
665
#if LIBSPDM_ENABLE_MSG_LOG
666
    libspdm_msg_log_t msg_log;
667
#endif /* LIBSPDM_ENABLE_MSG_LOG */
668
669
#if LIBSPDM_FIPS_MODE
670
    libspdm_fips_selftest_context_t fips_selftest_context;
671
#endif /* LIBSPDM_FIPS_MODE */
672
673
    /* Endianness (BE/LE/Both) to use for signature verification on SPDM 1.0 and 1.1
674
     * This field is ignored for other SPDM versions */
675
    uint8_t spdm_10_11_verify_signature_endian;
676
677
#if LIBSPDM_ENABLE_VENDOR_DEFINED_MESSAGES
678
    libspdm_vendor_response_callback_func vendor_response_callback;
679
#endif /* LIBSPDM_ENABLE_VENDOR_DEFINED_MESSAGES */
680
681
#if LIBSPDM_EVENT_RECIPIENT_SUPPORT
682
    libspdm_process_event_func process_event;
683
#endif /* LIBSPDM_EVENT_RECIPIENT_SUPPORT */
684
685
#if (LIBSPDM_ENABLE_CAPABILITY_ENCAP_CAP) && (LIBSPDM_SEND_GET_ENDPOINT_INFO_SUPPORT)
686
    libspdm_get_endpoint_info_callback_func get_endpoint_info_callback;
687
#endif /* (LIBSPDM_ENABLE_CAPABILITY_ENCAP_CAP) && (LIBSPDM_SEND_GET_ENDPOINT_INFO_SUPPORT) */
688
689
#if LIBSPDM_ENABLE_CAPABILITY_MEAS_CAP
690
    libspdm_meas_log_reset_callback_func spdm_meas_log_reset_callback;
691
#endif /* LIBSPDM_ENABLE_CAPABILITY_MEAS_CAP */
692
} libspdm_context_t;
693
694
#define LIBSPDM_CONTEXT_SIZE_WITHOUT_SECURED_CONTEXT (sizeof(libspdm_context_t))
695
#define LIBSPDM_CONTEXT_SIZE_ALL (LIBSPDM_CONTEXT_SIZE_WITHOUT_SECURED_CONTEXT + \
696
                                  LIBSPDM_SECURED_MESSAGE_CONTEXT_SIZE * LIBSPDM_MAX_SESSION_COUNT)
697
698
#if LIBSPDM_DEBUG_PRINT_ENABLE
699
/**
700
 * Return the request code name based on given request code.
701
 *
702
 * @param  request_code                  The SPDM request code.
703
 *
704
 * @return request code name according to the request code.
705
 **/
706
const char *libspdm_get_code_str(uint8_t request_code);
707
708
#ifdef LIBSPDM_INTERNAL_DUMP_HEX_STR_OVERRIDE
709
extern void LIBSPDM_INTERNAL_DUMP_HEX_STR_OVERRIDE(const uint8_t *data, size_t size);
710
#define LIBSPDM_INTERNAL_DUMP_HEX_STR(data, size) LIBSPDM_INTERNAL_DUMP_HEX_STR_OVERRIDE(data, size)
711
#else
712
/**
713
 * This function dump raw data.
714
 *
715
 * @param  data  raw data
716
 * @param  size  raw data size
717
 **/
718
void libspdm_internal_dump_hex_str(const uint8_t *data, size_t size);
719
#define LIBSPDM_INTERNAL_DUMP_HEX_STR(data, size) libspdm_internal_dump_hex_str(data, size)
720
#endif /* LIBSPDM_INTERNAL_DUMP_HEX_STR_OVERRIDE */
721
722
#ifdef LIBSPDM_INTERNAL_DUMP_DATA_OVERRIDE
723
extern void LIBSPDM_INTERNAL_DUMP_DATA_OVERRIDE(const uint8_t *data, size_t size);
724
#define LIBSPDM_INTERNAL_DUMP_DATA(data, size) LIBSPDM_INTERNAL_DUMP_DATA_OVERRIDE(data, size)
725
#else
726
/**
727
 * This function dump raw data.
728
 *
729
 * @param  data  raw data
730
 * @param  size  raw data size
731
 **/
732
void libspdm_internal_dump_data(const uint8_t *data, size_t size);
733
#define LIBSPDM_INTERNAL_DUMP_DATA(data, size) libspdm_internal_dump_data(data, size)
734
#endif /* LIBSPDM_INTERNAL_DUMP_DATA_OVERRIDE */
735
736
#ifdef LIBSPDM_INTERNAL_DUMP_HEX_OVERRIDE
737
extern void LIBSPDM_INTERNAL_DUMP_HEX_OVERRIDE(const uint8_t *data, size_t size);
738
#define LIBSPDM_INTERNAL_DUMP_HEX(data, size) LIBSPDM_INTERNAL_DUMP_HEX_OVERRIDE(data, size)
739
#else
740
/**
741
 * This function dump raw data with column format.
742
 *
743
 * @param  data  raw data
744
 * @param  size  raw data size
745
 **/
746
void libspdm_internal_dump_hex(const uint8_t *data, size_t size);
747
#define LIBSPDM_INTERNAL_DUMP_HEX(data, size) libspdm_internal_dump_hex(data, size)
748
#endif /* LIBSPDM_INTERNAL_DUMP_HEX_OVERRIDE */
749
750
#else /* LIBSPDM_DEBUG_PRINT_ENABLE */
751
#define LIBSPDM_INTERNAL_DUMP_HEX(data, size)
752
#define LIBSPDM_INTERNAL_DUMP_HEX_STR(data, size)
753
#define LIBSPDM_INTERNAL_DUMP_DATA(data, size)
754
#endif /* LIBSPDM_DEBUG_PRINT_ENABLE */
755
756
/* Required scratch buffer size for libspdm internal usage.
757
 * It may be used to hold the encrypted/decrypted message and/or last sent/received message.
758
 * It may be used to hold the large request/response and intermediate send/receive buffer
759
 * in case of chunking.
760
 *
761
 * If chunking is not supported, it should be at least below.
762
 * +--------------------------+-----------------+-----------------+
763
 * |    SENDER_RECEIVER       |MAX_SPDM_MSG_SIZE|MAX_SPDM_MSG_SIZE|
764
 * +--------------------------+-----------------+-----------------+
765
 * |<-Snd/Rcv buf for chunk ->|<-last request ->|<-cache request->|
766
 *
767
 *
768
 * If chunking is supported, it should be at least below.
769
 * +---------------+--------------+--------------------------+------------------------------+-----------------+-----------------+
770
 * |SECURE_MESSAGE |LARGE_MESSAGE |    SENDER_RECEIVER       | LARGE SENDER_RECEIVER        |MAX_SPDM_MSG_SIZE|MAX_SPDM_MSG_SIZE|
771
 * +---------------+--------------+--------------------------+------------------------------+-----------------+-----------------+
772
 * |<-Secure msg ->|<-Large msg ->|<-Snd/Rcv buf for chunk ->|<-Snd/Rcv buf for large msg ->|<-last request ->|<-cache request->|
773
 *
774
 *
775
 * The value is configurable based on max_spdm_msg_size.
776
 * The value MAY be changed in different libspdm version.
777
 * It is exposed here, just in case the libspdm consumer wants to configure the setting at build time.
778
 */
779
#if LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP
780
/* first section */
781
uint32_t libspdm_get_scratch_buffer_secure_message_offset(void);
782
uint32_t libspdm_get_scratch_buffer_secure_message_capacity(libspdm_context_t *spdm_context);
783
784
/* second section */
785
uint32_t libspdm_get_scratch_buffer_large_message_offset(libspdm_context_t *spdm_context);
786
uint32_t libspdm_get_scratch_buffer_large_message_capacity(libspdm_context_t *spdm_context);
787
#endif
788
789
/* third section */
790
uint32_t libspdm_get_scratch_buffer_sender_receiver_offset(libspdm_context_t *spdm_context);
791
uint32_t libspdm_get_scratch_buffer_sender_receiver_capacity(libspdm_context_t *spdm_context);
792
793
#if LIBSPDM_ENABLE_CAPABILITY_CHUNK_CAP
794
/* fourth section */
795
uint32_t libspdm_get_scratch_buffer_large_sender_receiver_offset(libspdm_context_t *spdm_context);
796
uint32_t libspdm_get_scratch_buffer_large_sender_receiver_capacity(libspdm_context_t *spdm_context);
797
#endif
798
799
/* fifth section */
800
uint32_t libspdm_get_scratch_buffer_last_spdm_request_offset(libspdm_context_t *spdm_context);
801
uint32_t libspdm_get_scratch_buffer_last_spdm_request_capacity(libspdm_context_t *spdm_context);
802
803
#if LIBSPDM_RESPOND_IF_READY_SUPPORT
804
/* sixth section */
805
uint32_t libspdm_get_scratch_buffer_cache_spdm_request_offset(libspdm_context_t *spdm_context);
806
uint32_t libspdm_get_scratch_buffer_cache_spdm_request_capacity(libspdm_context_t *spdm_context);
807
#endif
808
809
/* combination */
810
uint32_t libspdm_get_scratch_buffer_capacity(libspdm_context_t *spdm_context);
811
812
/**
813
 * Append a new data buffer to the managed buffer.
814
 *
815
 * @param  managed_buffer                The managed buffer to be appended.
816
 * @param  buffer                       The address of the data buffer to be appended to the managed buffer.
817
 * @param  buffer_size                   The size in bytes of the data buffer to be appended to the managed buffer.
818
 *
819
 * @retval RETURN_SUCCESS               The new data buffer is appended to the managed buffer.
820
 * @retval RETURN_BUFFER_TOO_SMALL      The managed buffer is too small to be appended.
821
 **/
822
libspdm_return_t libspdm_append_managed_buffer(void *managed_buffer,
823
                                               const void *buffer, size_t buffer_size);
824
825
/**
826
 * Reset the managed buffer.
827
 * The buffer_size is reset to 0.
828
 * The max_buffer_size is unchanged.
829
 * The buffer is not freed.
830
 *
831
 * @param  managed_buffer                The managed buffer.
832
 **/
833
void libspdm_reset_managed_buffer(void *managed_buffer);
834
835
/**
836
 * Return the size of managed buffer.
837
 *
838
 * @param  managed_buffer                The managed buffer.
839
 *
840
 * @return the size of managed buffer.
841
 **/
842
size_t libspdm_get_managed_buffer_size(void *managed_buffer);
843
844
/**
845
 * Return the address of managed buffer.
846
 *
847
 * @param  managed_buffer                The managed buffer.
848
 *
849
 * @return the address of managed buffer.
850
 **/
851
void *libspdm_get_managed_buffer(void *managed_buffer);
852
853
/**
854
 * Init the managed buffer.
855
 *
856
 * @param  managed_buffer                The managed buffer.
857
 * @param  max_buffer_size                The maximum size in bytes of the managed buffer.
858
 **/
859
void libspdm_init_managed_buffer(void *managed_buffer, size_t max_buffer_size);
860
861
/**
862
 * Reset message buffer in SPDM context according to request code.
863
 *
864
 * @param  spdm_context                   A pointer to the SPDM context.
865
 * @param  spdm_session_info             A pointer to the SPDM session context.
866
 * @param  spdm_request                   The SPDM request code.
867
 */
868
void libspdm_reset_message_buffer_via_request_code(void *context, void *session_info,
869
                                                   uint8_t request_code);
870
871
/**
872
 * This function initializes the session info.
873
 *
874
 * @param  spdm_context                  A pointer to the SPDM context.
875
 * @param  session_id                    The SPDM session ID.
876
 **/
877
void libspdm_session_info_init(libspdm_context_t *spdm_context,
878
                               libspdm_session_info_t *session_info,
879
                               uint32_t session_id, spdm_version_number_t secured_message_version,
880
                               bool use_psk);
881
882
#if LIBSPDM_ENABLE_CAPABILITY_PSK_CAP
883
/**
884
 * Set the psk_hint to a session info.
885
 *
886
 * @param  session_info   A pointer to a session info.
887
 * @param  psk_hint       Indicate the PSK hint.
888
 * @param  psk_hint_size  The size in bytes of the PSK hint.
889
 */
890
void libspdm_session_info_set_psk_hint(libspdm_session_info_t *session_info,
891
                                       const void *psk_hint,
892
                                       size_t psk_hint_size);
893
#endif /* LIBSPDM_ENABLE_CAPABILITY_PSK_CAP */
894
895
/**
896
 * This function returns if a given version is supported based upon the GET_VERSION/VERSION.
897
 *
898
 * @param  spdm_context                  A pointer to the SPDM context.
899
 * @param  version                      The SPDM version.
900
 *
901
 * @retval true  the version is supported.
902
 * @retval false the version is not supported.
903
 **/
904
bool libspdm_is_version_supported(const libspdm_context_t *spdm_context, uint8_t version);
905
906
/**
907
 * This function returns connection version negotiated by GET_VERSION/VERSION.
908
 *
909
 * @param  spdm_context                  A pointer to the SPDM context.
910
 *
911
 * @return the connection version.
912
 **/
913
uint8_t libspdm_get_connection_version(const libspdm_context_t *spdm_context);
914
915
/**
916
 * This function returns if a capabilities flag is supported in current SPDM connection.
917
 *
918
 * @param  spdm_context                  A pointer to the SPDM context.
919
 * @param  is_requester                  Is the function called from a requester.
920
 * @param  requester_capabilities_flag    The requester capabilities flag to be checked
921
 * @param  responder_capabilities_flag    The responder capabilities flag to be checked
922
 *
923
 * @retval true  the capabilities flag is supported.
924
 * @retval false the capabilities flag is not supported.
925
 **/
926
bool libspdm_is_capabilities_flag_supported(const libspdm_context_t *spdm_context,
927
                                            bool is_requester,
928
                                            uint32_t requester_capabilities_flag,
929
                                            uint32_t responder_capabilities_flag);
930
931
/**
932
 * This function returns if a capabilities extended flag is supported in current SPDM connection.
933
 *
934
 * @param  spdm_context                     A pointer to the SPDM context.
935
 * @param  is_requester                     Is the function called from a requester.
936
 * @param  requester_capabilities_ext_flag  The requester capabilities extended flag to be checked
937
 * @param  responder_capabilities_ext_flag  The responder capabilities extended flag to be checked
938
 *
939
 * @retval true  the capabilities extended flag is supported.
940
 * @retval false the capabilities extended flag is not supported.
941
 **/
942
bool libspdm_is_capabilities_ext_flag_supported(const libspdm_context_t *spdm_context,
943
                                                bool is_requester,
944
                                                uint16_t requester_capabilities_ext_flag,
945
                                                uint16_t responder_capabilities_ext_flag);
946
947
/**
948
 * Checks the negotiated SPDM version and endpoint capabilities to determine if encapsulated
949
 * messages are supported or not.
950
 *
951
 * @param  spdm_context  A pointer to the SPDM context.
952
 *
953
 * @retval true   Both endpoints support encapsulated messages.
954
 * @retval false  At least one endpoint does not support encapsulated messages.
955
 **/
956
bool libspdm_is_encap_supported(const libspdm_context_t *spdm_context);
957
958
/**
959
 * This function generates the certificate chain hash.
960
 *
961
 * @param  spdm_context                  A pointer to the SPDM context.
962
 * @param  slot_id                    The slot index of the certificate chain.
963
 * @param  signature                    The buffer to store the certificate chain hash.
964
 *
965
 * @retval true  certificate chain hash is generated.
966
 * @retval false certificate chain hash is not generated.
967
 **/
968
bool libspdm_generate_cert_chain_hash(libspdm_context_t *spdm_context,
969
                                      size_t slot_id, uint8_t *hash);
970
971
/**
972
 * This function generates the public key hash.
973
 *
974
 * @param  spdm_context               A pointer to the SPDM context.
975
 * @param  hash                       The buffer to store the public key hash.
976
 *
977
 * @retval true  public key hash is generated.
978
 * @retval false public key hash is not generated.
979
 **/
980
bool libspdm_generate_public_key_hash(libspdm_context_t *spdm_context,
981
                                      uint8_t *hash);
982
983
/**
984
 * This function verifies the integrity of peer certificate chain buffer including
985
 * spdm_cert_chain_t header.
986
 *
987
 * @param  spdm_context                  A pointer to the SPDM context.
988
 * @param  cert_chain_buffer              Certificate chain buffer including spdm_cert_chain_t header.
989
 * @param  cert_chain_buffer_size          size in bytes of the certificate chain buffer.
990
 *
991
 * @retval true  Peer certificate chain buffer integrity verification passed.
992
 * @retval false Peer certificate chain buffer integrity verification failed.
993
 **/
994
bool libspdm_verify_peer_cert_chain_buffer_integrity(libspdm_context_t *spdm_context,
995
                                                     const void *cert_chain_buffer,
996
                                                     size_t cert_chain_buffer_size);
997
998
/**
999
 * This function verifies peer certificate chain authority.
1000
 *
1001
 * @param  spdm_context                  A pointer to the SPDM context.
1002
 * @param  cert_chain_buffer              Certificate chain buffer including spdm_cert_chain_t header.
1003
 * @param  cert_chain_buffer_size          size in bytes of the certificate chain buffer.
1004
 * @param  trust_anchor                  A buffer to hold the trust_anchor which is used to validate the peer certificate, if not NULL.
1005
 * @param  trust_anchor_size             A buffer to hold the trust_anchor_size, if not NULL.
1006
 *
1007
 * @retval true  Peer certificate chain buffer authority verification passed.
1008
 *               Or there is no root_cert in local_context.
1009
 * @retval false Peer certificate chain buffer authority verification failed.
1010
 **/
1011
bool libspdm_verify_peer_cert_chain_buffer_authority(libspdm_context_t *spdm_context,
1012
                                                     const void *cert_chain_buffer,
1013
                                                     size_t cert_chain_buffer_size,
1014
                                                     const void **trust_anchor,
1015
                                                     size_t *trust_anchor_size);
1016
/**
1017
 * This function generates the challenge signature based upon m1m2 for authentication.
1018
 *
1019
 * @param  spdm_context                  A pointer to the SPDM context.
1020
 * @param  is_requester                  Indicate of the signature generation for a requester or a responder.
1021
 * @param  signature                    The buffer to store the challenge signature.
1022
 *
1023
 * @retval true  challenge signature is generated.
1024
 * @retval false challenge signature is not generated.
1025
 **/
1026
bool libspdm_generate_challenge_auth_signature(libspdm_context_t *spdm_context,
1027
                                               bool is_requester,
1028
                                               uint8_t slot_id,
1029
                                               uint8_t *signature);
1030
1031
/**
1032
 * This function verifies the certificate chain hash.
1033
 *
1034
 * @param  spdm_context                  A pointer to the SPDM context.
1035
 * @param  certificate_chain_hash         The certificate chain hash data buffer.
1036
 * @param  certificate_chain_hash_size     size in bytes of the certificate chain hash data buffer.
1037
 *
1038
 * @retval true  hash verification pass.
1039
 * @retval false hash verification fail.
1040
 **/
1041
bool libspdm_verify_certificate_chain_hash(libspdm_context_t *spdm_context,
1042
                                           uint8_t slot_id,
1043
                                           const void *certificate_chain_hash,
1044
                                           size_t certificate_chain_hash_size);
1045
1046
/**
1047
 * This function verifies the public key hash.
1048
 *
1049
 * @param  spdm_context            A pointer to the SPDM context.
1050
 * @param  public_key_hash         The public key hash data buffer.
1051
 * @param  public_key_hash_size    size in bytes of the public key hash data buffer.
1052
 *
1053
 * @retval true  hash verification pass.
1054
 * @retval false hash verification fail.
1055
 **/
1056
bool libspdm_verify_public_key_hash(libspdm_context_t *spdm_context,
1057
                                    const void *public_key_hash,
1058
                                    size_t public_key_hash_size);
1059
1060
/**
1061
 * This function verifies the challenge signature based upon m1m2.
1062
 *
1063
 * @param  spdm_context                  A pointer to the SPDM context.
1064
 * @param  is_requester                  Indicate of the signature verification for a requester or a responder.
1065
 * @param  sign_data                     The signature data buffer.
1066
 * @param  sign_data_size                 size in bytes of the signature data buffer.
1067
 *
1068
 * @retval true  signature verification pass.
1069
 * @retval false signature verification fail.
1070
 **/
1071
bool libspdm_verify_challenge_auth_signature(libspdm_context_t *spdm_context,
1072
                                             bool is_requester,
1073
                                             uint8_t slot_id,
1074
                                             const void *sign_data,
1075
                                             size_t sign_data_size);
1076
1077
/**
1078
 * This function calculate the measurement summary hash size.
1079
 *
1080
 * @param  spdm_context                  A pointer to the SPDM context.
1081
 * @param  is_requester                  Is the function called from a requester.
1082
 * @param  measurement_summary_hash_type   The type of the measurement summary hash.
1083
 *
1084
 * @return 0 measurement summary hash type is invalid, NO_MEAS hash type or no MEAS capabilities.
1085
 * @return measurement summary hash size according to type.
1086
 **/
1087
uint32_t libspdm_get_measurement_summary_hash_size(libspdm_context_t *spdm_context,
1088
                                                   bool is_requester,
1089
                                                   uint8_t measurement_summary_hash_type);
1090
1091
/**
1092
 * This function generates the endpoint info signature based upon il1il2 for authentication.
1093
 *
1094
 * @param  spdm_context                  A pointer to the SPDM context.
1095
 * @param  session_info                  A pointer to the SPDM session context.
1096
 * @param  is_requester                  Indicate of the signature generation for a requester or a responder.
1097
 * @param  signature                     The buffer to store the endpoint info signature.
1098
 *
1099
 * @retval true  challenge signature is generated.
1100
 * @retval false challenge signature is not generated.
1101
 **/
1102
bool libspdm_generate_endpoint_info_signature(libspdm_context_t *spdm_context,
1103
                                              libspdm_session_info_t *session_info,
1104
                                              bool is_requester,
1105
                                              uint8_t slot_id,
1106
                                              uint8_t *signature);
1107
1108
/**
1109
 * This function verifies the challenge signature based upon m1m2.
1110
 *
1111
 * @param  spdm_context                  A pointer to the SPDM context.
1112
 * @param  session_info                  A pointer to the SPDM session context.
1113
 * @param  is_requester                  Indicate of the signature verification for a requester or a responder.
1114
 * @param  sign_data                     The signature data buffer.
1115
 * @param  sign_data_size                size in bytes of the signature data buffer.
1116
 *
1117
 * @retval true  signature verification pass.
1118
 * @retval false signature verification fail.
1119
 **/
1120
bool libspdm_verify_endpoint_info_signature(libspdm_context_t *spdm_context,
1121
                                            libspdm_session_info_t *session_info,
1122
                                            bool is_requester,
1123
                                            uint8_t slot_id,
1124
                                            const void *sign_data,
1125
                                            size_t sign_data_size);
1126
1127
#if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
1128
/*
1129
 * This function calculates l1l2.
1130
 * If session_info is NULL, this function will use M cache of SPDM context,
1131
 * else will use M cache of SPDM session context.
1132
 *
1133
 * @param  spdm_context                  A pointer to the SPDM context.
1134
 * @param  session_info                  A pointer to the SPDM session context.
1135
 * @param  l1l2                          The buffer to store the l1l2.
1136
 *
1137
 * @retval RETURN_SUCCESS  l1l2 is calculated.
1138
 */
1139
bool libspdm_calculate_l1l2(libspdm_context_t *spdm_context,
1140
                            void *session_info,
1141
                            libspdm_l1l2_managed_buffer_t *l1l2);
1142
#else
1143
/*
1144
 * This function calculates l1l2 hash.
1145
 * If session_info is NULL, this function will use M cache of SPDM context,
1146
 * else will use M cache of SPDM session context.
1147
 *
1148
 * @param  spdm_context                  A pointer to the SPDM context.
1149
 * @param  session_info                  A pointer to the SPDM session context.
1150
 * @param  l1l2_hash_size               size in bytes of the l1l2 hash
1151
 * @param  l1l2_hash                   The buffer to store the l1l2 hash
1152
 *
1153
 * @retval RETURN_SUCCESS  l1l2 is calculated.
1154
 */
1155
bool libspdm_calculate_l1l2_hash(libspdm_context_t *spdm_context,
1156
                                 void *session_info,
1157
                                 size_t *l1l2_hash_size, void *l1l2_hash);
1158
#endif /* LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT */
1159
1160
/**
1161
 * Get element from multi element opaque data by element id.
1162
 *
1163
 * This function should be called in
1164
 * libspdm_process_opaque_data_supported_version_data/libspdm_process_opaque_data_version_selection_data.
1165
 *
1166
 * @param[in]  data_in_size     Size of multi element opaque data.
1167
 * @param[in]  data_in          A pointer to the multi element opaque data.
1168
 * @param[in]  element_id       Element id.
1169
 * @param[in]  sm_data_id       ID for the Secured Message data type.
1170
 * @param[out] get_element_ptr  Pointer to store found element.
1171
 *
1172
 * @retval true   Get element successfully
1173
 * @retval false  Get element failed
1174
 **/
1175
bool libspdm_get_element_from_opaque_data(libspdm_context_t *spdm_context,
1176
                                          size_t data_in_size, const void *data_in,
1177
                                          uint8_t element_id, uint8_t sm_data_id,
1178
                                          const void **get_element_ptr, size_t *get_element_len);
1179
1180
/**
1181
 * Process opaque data version selection.
1182
 *
1183
 * This function should be called in KEY_EXCHANGE/PSK_EXCHANGE response parsing in requester.
1184
 *
1185
 * @param  data_in_size  Size in bytes of the data_in.
1186
 * @param  data_in       A pointer to the buffer to store the opaque data version selection.
1187
 **/
1188
libspdm_return_t libspdm_process_opaque_data_version_selection_data(
1189
    libspdm_context_t *spdm_context, size_t data_in_size, void *data_in,
1190
    spdm_version_number_t *secured_message_version);
1191
1192
/**
1193
 *  Process general opaque data check
1194
 *
1195
 * @param  data_in_size                  size in bytes of the data_in.
1196
 * @param  data_in                       A pointer to the buffer to store the opaque data version selection.
1197
 *
1198
 * @retval true                           check opaque data successfully
1199
 * @retval false                          check opaque data failed
1200
 **/
1201
bool libspdm_process_general_opaque_data_check(libspdm_context_t *spdm_context,
1202
                                               size_t data_in_size,
1203
                                               const void *data_in);
1204
1205
/**
1206
 * Return the size in bytes of opaque data supported version.
1207
 *
1208
 * This function should be called in libspdm_process_opaque_data_supported_version_data.
1209
 *
1210
 * @param  version_count  Secure version count.
1211
 *
1212
 * @return The size in bytes of opaque data supported version.
1213
 **/
1214
size_t libspdm_get_untrusted_opaque_data_supported_version_data_size(
1215
    libspdm_context_t *spdm_context, uint8_t version_count);
1216
1217
/**
1218
 * Return the size in bytes of opaque data supported version.
1219
 *
1220
 * This function should be called in KEY_EXCHANGE/PSK_EXCHANGE request generation.
1221
 *
1222
 * @return the size in bytes of opaque data supported version.
1223
 **/
1224
size_t libspdm_get_opaque_data_supported_version_data_size(libspdm_context_t *spdm_context);
1225
1226
/**
1227
 * Return the size in bytes of opaque data version selection.
1228
 *
1229
 * This function should be called in KEY_EXCHANGE/PSK_EXCHANGE response generation.
1230
 *
1231
 * @return the size in bytes of opaque data version selection.
1232
 **/
1233
size_t libspdm_get_opaque_data_version_selection_data_size(const libspdm_context_t *spdm_context);
1234
1235
/**
1236
 * Return the SPDMversion field of the version number struct.
1237
 *
1238
 * @param  ver                Spdm version number struct.
1239
 *
1240
 * @return the SPDMversion of the version number struct.
1241
 **/
1242
uint8_t libspdm_get_version_from_version_number(spdm_version_number_t ver);
1243
1244
/**
1245
 * Sort SPDMversion in descending order.
1246
 *
1247
 * @param  spdm_context                A pointer to the SPDM context.
1248
 * @param  ver_set                    A pointer to the version set.
1249
 * @param  ver_num                    Version number.
1250
 */
1251
void libspdm_version_number_sort(spdm_version_number_t *ver_set, size_t ver_num);
1252
1253
/**
1254
 * Negotiate SPDMversion for connection.
1255
 * ver_set is the local version set of requester, res_ver_set is the version set of responder.
1256
 *
1257
 * @param  common_version             A pointer to store the common version.
1258
 * @param  req_ver_set                A pointer to the requester version set.
1259
 * @param  req_ver_num                Version number of requester.
1260
 * @param  res_ver_set                A pointer to the responder version set.
1261
 * @param  res_ver_num                Version number of responder.
1262
 *
1263
 * @retval true                       Negotiation successfully, connect version be saved to common_version.
1264
 * @retval false                      Negotiation failed.
1265
 */
1266
bool libspdm_negotiate_connection_version(spdm_version_number_t *common_version,
1267
                                          spdm_version_number_t *req_ver_set,
1268
                                          size_t req_ver_num,
1269
                                          const spdm_version_number_t *res_ver_set,
1270
                                          size_t res_ver_num);
1271
1272
/**
1273
 * Acquire a device sender buffer for transport layer message.
1274
 *
1275
 * @param  context                       A pointer to the SPDM context.
1276
 * @param  max_msg_size                  size in bytes of the maximum size of sender buffer.
1277
 * @param  msg_buf_ptr                   A pointer to a sender buffer.
1278
 *
1279
 * @retval RETURN_SUCCESS               The sender buffer is acquired.
1280
 **/
1281
libspdm_return_t libspdm_acquire_sender_buffer (
1282
    libspdm_context_t *spdm_context, size_t *max_msg_size, void **msg_buf_ptr);
1283
1284
/**
1285
 * Release a device sender buffer for transport layer message.
1286
 *
1287
 * @param  context                       A pointer to the SPDM context.
1288
 *
1289
 * @retval RETURN_SUCCESS               The sender buffer is Released.
1290
 **/
1291
void libspdm_release_sender_buffer (libspdm_context_t *spdm_context);
1292
1293
/**
1294
 * Get the sender buffer.
1295
 *
1296
 * @param  context                  A pointer to the SPDM context.
1297
 * @param  sender_buffer            Buffer address of the sender buffer.
1298
 * @param  sender_buffer_size       Size of the sender buffer.
1299
 *
1300
 **/
1301
void libspdm_get_sender_buffer (
1302
    libspdm_context_t *spdm_context,
1303
    void **sender_buffer,
1304
    size_t *sender_buffer_size);
1305
1306
/**
1307
 * Acquire a device receiver buffer for transport layer message.
1308
 *
1309
 * @param  context                       A pointer to the SPDM context.
1310
 * @param  max_msg_size                  size in bytes of the maximum size of receiver buffer.
1311
 * @param  msg_buf_pt                    A pointer to a receiver buffer.
1312
 *
1313
 * @retval RETURN_SUCCESS               The receiver buffer is acquired.
1314
 **/
1315
libspdm_return_t libspdm_acquire_receiver_buffer (
1316
    libspdm_context_t *spdm_context, size_t *max_msg_size, void **msg_buf_ptr);
1317
1318
/**
1319
 * Release a device receiver buffer for transport layer message.
1320
 *
1321
 * @param  context                       A pointer to the SPDM context.
1322
 *
1323
 * @retval RETURN_SUCCESS               The receiver buffer is Released.
1324
 **/
1325
void libspdm_release_receiver_buffer (libspdm_context_t *spdm_context);
1326
1327
/**
1328
 * Get the receiver buffer.
1329
 *
1330
 * @param  context                  A pointer to the SPDM context.
1331
 * @param  receiver_buffer            Buffer address of the receiver buffer.
1332
 * @param  receiver_buffer_size       Size of the receiver buffer.
1333
 *
1334
 **/
1335
void libspdm_get_receiver_buffer (
1336
    libspdm_context_t *spdm_context,
1337
    void **receiver_buffer,
1338
    size_t *receiver_buffer_size);
1339
1340
/**
1341
 * Get the certificate slot mask
1342
 *
1343
 * @param[in]   context              A pointer to the SPDM context.
1344
 *
1345
 * @return slot_mask                 get slot mask
1346
 **/
1347
uint8_t libspdm_get_cert_slot_mask (libspdm_context_t *spdm_context);
1348
1349
/**
1350
 * Get the certificate slot count
1351
 *
1352
 * @param[in]   context              A pointer to the SPDM context.
1353
 *
1354
 * @return slot_count                get slot count
1355
 **/
1356
uint8_t libspdm_get_cert_slot_count(libspdm_context_t *spdm_context);
1357
1358
#if LIBSPDM_ENABLE_MSG_LOG
1359
void libspdm_append_msg_log(libspdm_context_t *spdm_context, void *message, size_t message_size);
1360
#endif
1361
1362
/**
1363
 * Reset message A cache in SPDM context.
1364
 *
1365
 * @param  spdm_context  A pointer to the SPDM context.
1366
 **/
1367
void libspdm_reset_message_a(libspdm_context_t *spdm_context);
1368
1369
/**
1370
 * Reset message D cache in SPDM context.
1371
 *
1372
 * @param  spdm_context       A pointer to the SPDM context.
1373
 * @param  spdm_session_info  A pointer to the SPDM session context.
1374
 **/
1375
void libspdm_reset_message_d(libspdm_context_t *spdm_context);
1376
1377
/**
1378
 * Reset message B cache in SPDM context.
1379
 *
1380
 * @param  spdm_context  A pointer to the SPDM context.
1381
 **/
1382
void libspdm_reset_message_b(libspdm_context_t *spdm_context);
1383
1384
/**
1385
 * Reset message C cache in SPDM context.
1386
 *
1387
 * @param  spdm_context  A pointer to the SPDM context.
1388
 **/
1389
void libspdm_reset_message_c(libspdm_context_t *spdm_context);
1390
1391
/**
1392
 * Reset message MutB cache in SPDM context.
1393
 *
1394
 * @param  spdm_context  A pointer to the SPDM context.
1395
 **/
1396
void libspdm_reset_message_mut_b(libspdm_context_t *spdm_context);
1397
1398
/**
1399
 * Reset message MutC cache in SPDM context.
1400
 *
1401
 * @param  spdm_context  A pointer to the SPDM context.
1402
 **/
1403
void libspdm_reset_message_mut_c(libspdm_context_t *spdm_context);
1404
1405
/**
1406
 * Reset message M cache in SPDM context.
1407
 * If session_info is NULL, this function will use M cache of SPDM context,
1408
 * else will use M cache of SPDM session context.
1409
 *
1410
 * @param  spdm_context  A pointer to the SPDM context.
1411
 * @param  session_info  A pointer to the SPDM session context.
1412
 **/
1413
void libspdm_reset_message_m(libspdm_context_t *spdm_context, void *session_info);
1414
1415
/**
1416
 * Reset message K cache in SPDM context.
1417
 *
1418
 * @param  spdm_context       A pointer to the SPDM context.
1419
 * @param  spdm_session_info  A pointer to the SPDM session context.
1420
 **/
1421
void libspdm_reset_message_k(libspdm_context_t *spdm_context, void *spdm_session_info);
1422
1423
/**
1424
 * Reset message EncapD cache in SPDM context.
1425
 *
1426
 * @param  spdm_session_info  A pointer to the SPDM session context.
1427
 **/
1428
void libspdm_reset_message_encap_d(void *spdm_session_info);
1429
1430
/**
1431
 * Reset message F cache in SPDM context.
1432
 *
1433
 * @param  spdm_context       A pointer to the SPDM context.
1434
 * @param  spdm_session_info  A pointer to the SPDM session context.
1435
 **/
1436
void libspdm_reset_message_f(libspdm_context_t *spdm_context, void *spdm_session_info);
1437
1438
/**
1439
 * Reset message E cache in SPDM context.
1440
 * If session_info is NULL, this function will use E cache of SPDM context,
1441
 * else will use E cache of SPDM session context.
1442
 *
1443
 * @param  spdm_context                  A pointer to the SPDM context.
1444
 * @param  spdm_session_info              A pointer to the SPDM session context.
1445
 **/
1446
void libspdm_reset_message_e(libspdm_context_t *spdm_context, void *session_info);
1447
1448
/**
1449
 * Reset message encap E cache in SPDM context.
1450
 * If session_info is NULL, this function will use encap E cache of SPDM context,
1451
 * else will use encap E cache of SPDM session context.
1452
 *
1453
 * @param  spdm_context                  A pointer to the SPDM context.
1454
 * @param  spdm_session_info              A pointer to the SPDM session context.
1455
 **/
1456
void libspdm_reset_message_encap_e(libspdm_context_t *spdm_context, void *session_info);
1457
1458
/**
1459
 * Append message A cache in SPDM context.
1460
 *
1461
 * @param  spdm_context  A pointer to the SPDM context.
1462
 * @param  message       Message buffer.
1463
 * @param  message_size  Size in bytes of message buffer.
1464
 *
1465
 * @retval RETURN_SUCCESS          message is appended.
1466
 * @retval RETURN_OUT_OF_RESOURCES message is not appended because the internal cache is full.
1467
 **/
1468
libspdm_return_t libspdm_append_message_a(libspdm_context_t *spdm_context, const void *message,
1469
                                          size_t message_size);
1470
1471
/**
1472
 * Append message D cache in SPDM context.
1473
 *
1474
 * @param  spdm_context  A pointer to the SPDM context.
1475
 * @param  message       Message buffer.
1476
 * @param  message_size  Size in bytes of message buffer.
1477
 *
1478
 * @retval RETURN_SUCCESS          message is appended.
1479
 * @retval RETURN_OUT_OF_RESOURCES message is not appended because the internal cache is full.
1480
 **/
1481
libspdm_return_t libspdm_append_message_d(libspdm_context_t *spdm_context, const void *message,
1482
                                          size_t message_size);
1483
1484
/**
1485
 * Append message B cache in SPDM context.
1486
 *
1487
 * @param  spdm_context  A pointer to the SPDM context.
1488
 * @param  message       Message buffer.
1489
 * @param  message_size  Size in bytes of message buffer.
1490
 *
1491
 * @retval RETURN_SUCCESS          message is appended.
1492
 * @retval RETURN_OUT_OF_RESOURCES message is not appended because the internal cache is full.
1493
 **/
1494
libspdm_return_t libspdm_append_message_b(libspdm_context_t *spdm_context, const void *message,
1495
                                          size_t message_size);
1496
1497
/**
1498
 * Append message C cache in SPDM context.
1499
 *
1500
 * @param  spdm_context  A pointer to the SPDM context.
1501
 * @param  message       Message buffer.
1502
 * @param  message_size  Size in bytes of message buffer.
1503
 *
1504
 * @retval RETURN_SUCCESS          message is appended.
1505
 * @retval RETURN_OUT_OF_RESOURCES message is not appended because the internal cache is full.
1506
 **/
1507
libspdm_return_t libspdm_append_message_c(libspdm_context_t *spdm_context, const void *message,
1508
                                          size_t message_size);
1509
1510
/**
1511
 * Append message MutB cache in SPDM context.
1512
 *
1513
 * @param  spdm_context  A pointer to the SPDM context.
1514
 * @param  message       Message buffer.
1515
 * @param  message_size  Size in bytes of message buffer.
1516
 *
1517
 * @retval RETURN_SUCCESS          message is appended.
1518
 * @retval RETURN_OUT_OF_RESOURCES message is not appended because the internal cache is full.
1519
 **/
1520
libspdm_return_t libspdm_append_message_mut_b(libspdm_context_t *spdm_context, const void *message,
1521
                                              size_t message_size);
1522
1523
/**
1524
 * Append message MutC cache in SPDM context.
1525
 *
1526
 * @param  spdm_context  A pointer to the SPDM context.
1527
 * @param  message       Message buffer.
1528
 * @param  message_size  Size in bytes of message buffer.
1529
 *
1530
 * @retval RETURN_SUCCESS          message is appended.
1531
 * @retval RETURN_OUT_OF_RESOURCES message is not appended because the internal cache is full.
1532
 **/
1533
libspdm_return_t libspdm_append_message_mut_c(libspdm_context_t *spdm_context, const void *message,
1534
                                              size_t message_size);
1535
1536
/**
1537
 * Append message M cache in SPDM context.
1538
 * If session_info is NULL, this function will use M cache of SPDM context,
1539
 * else will use M cache of SPDM session context.
1540
 *
1541
 * @param  spdm_context  A pointer to the SPDM context.
1542
 * @param  session_info  A pointer to the SPDM session context.
1543
 * @param  message       Message buffer.
1544
 * @param  message_size  Size in bytes of message buffer.
1545
 *
1546
 * @retval RETURN_SUCCESS          message is appended.
1547
 * @retval RETURN_OUT_OF_RESOURCES message is not appended because the internal cache is full.
1548
 **/
1549
libspdm_return_t libspdm_append_message_m(libspdm_context_t *spdm_context,
1550
                                          void *session_info,
1551
                                          const void *message, size_t message_size);
1552
1553
/**
1554
 * Append message K cache in SPDM context.
1555
 *
1556
 * @param  spdm_context       A pointer to the SPDM context.
1557
 * @param  spdm_session_info  A pointer to the SPDM session context.
1558
 * @param  is_requester       Indicate of the key generation for a requester or a responder.
1559
 * @param  message            Message buffer.
1560
 * @param  message_size       Size in bytes of message buffer.
1561
 *
1562
 * @retval RETURN_SUCCESS          message is appended.
1563
 * @retval RETURN_OUT_OF_RESOURCES message is not appended because the internal cache is full.
1564
 **/
1565
libspdm_return_t libspdm_append_message_k(libspdm_context_t *spdm_context,
1566
                                          void *spdm_session_info,
1567
                                          bool is_requester, const void *message,
1568
                                          size_t message_size);
1569
1570
/**
1571
 * Append message EncapD cache in SPDM context.
1572
 *
1573
 * @param  spdm_session_info  A pointer to the SPDM session context.
1574
 * @param  message            Message buffer.
1575
 * @param  message_size       Size in bytes of message buffer.
1576
 *
1577
 * @retval RETURN_SUCCESS          message is appended.
1578
 * @retval RETURN_OUT_OF_RESOURCES message is not appended because the internal cache is full.
1579
 **/
1580
libspdm_return_t libspdm_append_message_encap_d(void *spdm_session_info,
1581
                                                const void *message,
1582
                                                size_t message_size);
1583
1584
/**
1585
 * Append message F cache in SPDM context.
1586
 *
1587
 * @param  spdm_context       A pointer to the SPDM context.
1588
 * @param  spdm_session_info  A pointer to the SPDM session context.
1589
 * @param  is_requester       Indicate of the key generation for a requester or a responder.
1590
 * @param  message            Message buffer.
1591
 * @param  message_size       Size in bytes of message buffer.
1592
 *
1593
 * @retval RETURN_SUCCESS          message is appended.
1594
 * @retval RETURN_OUT_OF_RESOURCES message is not appended because the internal cache is full.
1595
 **/
1596
libspdm_return_t libspdm_append_message_f(libspdm_context_t *spdm_context,
1597
                                          void *spdm_session_info,
1598
                                          bool is_requester, const void *message,
1599
                                          size_t message_size);
1600
1601
/**
1602
 * Append message E cache in SPDM context.
1603
 * If session_info is NULL, this function will use E cache of SPDM context,
1604
 * else will use E cache of SPDM session context.
1605
 *
1606
 * @param  spdm_context                  A pointer to the SPDM context.
1607
 * @param  session_info                  A pointer to the SPDM session context.
1608
 * @param  message                      message buffer.
1609
 * @param  message_size                  size in bytes of message buffer.
1610
 *
1611
 * @retval RETURN_SUCCESS          message is appended.
1612
 * @retval RETURN_OUT_OF_RESOURCES message is not appended because the internal cache is full.
1613
 **/
1614
libspdm_return_t libspdm_append_message_e(libspdm_context_t *spdm_context, void *session_info,
1615
                                          const void *message, size_t message_size);
1616
1617
/**
1618
 * Append message encap E cache in SPDM context.
1619
 * If session_info is NULL, this function will use encap E cache of SPDM context,
1620
 * else will use encap E cache of SPDM session context.
1621
 *
1622
 * @param  spdm_context                  A pointer to the SPDM context.
1623
 * @param  session_info                  A pointer to the SPDM session context.
1624
 * @param  message                      message buffer.
1625
 * @param  message_size                  size in bytes of message buffer.
1626
 *
1627
 * @retval RETURN_SUCCESS          message is appended.
1628
 * @retval RETURN_OUT_OF_RESOURCES message is not appended because the internal cache is full.
1629
 **/
1630
libspdm_return_t libspdm_append_message_encap_e(libspdm_context_t *spdm_context, void *session_info,
1631
                                                const void *message, size_t message_size);
1632
1633
/**
1634
 * This function generates a session ID by concatenating req_session_id and rsp_session_id.
1635
 *
1636
 * @param[in]  req_session_id
1637
 * @param[in]  rsp_session_id
1638
 *
1639
 * @return Session ID.
1640
 **/
1641
uint32_t libspdm_generate_session_id(uint16_t req_session_id, uint16_t rsp_session_id);
1642
1643
/**
1644
 * This function assigns a new session ID.
1645
 *
1646
 * @param  spdm_context  A pointer to the SPDM context.
1647
 * @param  session_id    The SPDM session ID.
1648
 *
1649
 * @return session info associated with this new session ID.
1650
 **/
1651
libspdm_session_info_t *libspdm_assign_session_id(libspdm_context_t *spdm_context,
1652
                                                  uint32_t session_id,
1653
                                                  spdm_version_number_t secured_message_version,
1654
                                                  bool use_psk);
1655
1656
/**
1657
 * This function frees a session ID.
1658
 *
1659
 * @param  spdm_context  A pointer to the SPDM context.
1660
 * @param  session_id    The SPDM session ID.
1661
 **/
1662
void libspdm_free_session_id(libspdm_context_t *spdm_context, uint32_t session_id);
1663
1664
#if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
1665
/*
1666
 * This function calculates current TH data with message A and message K.
1667
 *
1668
 * @param  spdm_context            A pointer to the SPDM context.
1669
 * @param  session_info            The SPDM session ID.
1670
 * @param  cert_chain_buffer       Certificate chain buffer with spdm_cert_chain_t header.
1671
 * @param  cert_chain_buffer_size  Size in bytes of the certificate chain buffer.
1672
 * @param  th_data_buffer_size     Size in bytes of the th_data_buffer
1673
 * @param  th_data_buffer          The buffer to store the th_data_buffer
1674
 *
1675
 * @retval RETURN_SUCCESS  current TH data is calculated.
1676
 */
1677
bool libspdm_calculate_th_for_exchange(
1678
    libspdm_context_t *spdm_context, void *spdm_session_info,
1679
    const uint8_t *cert_chain_buffer, size_t cert_chain_buffer_size,
1680
    libspdm_th_managed_buffer_t *th_curr);
1681
#else
1682
/*
1683
 * This function calculates current TH hash with message A and message K.
1684
 *
1685
 * @param  spdm_context         A pointer to the SPDM context.
1686
 * @param  session_info         The SPDM session ID.
1687
 * @param  th_hash_buffer_size  Size in bytes of the th_hash_buffer
1688
 * @param  th_hash_buffer       The buffer to store the th_hash_buffer
1689
 *
1690
 * @retval RETURN_SUCCESS  current TH hash is calculated.
1691
 */
1692
bool libspdm_calculate_th_hash_for_exchange(
1693
    libspdm_context_t *spdm_context, void *spdm_session_info,
1694
    size_t *th_hash_buffer_size, void *th_hash_buffer);
1695
1696
/*
1697
 * This function calculates current TH hmac with message A and message K, with response finished_key.
1698
 *
1699
 * @param  spdm_context         A pointer to the SPDM context.
1700
 * @param  session_info         The SPDM session ID.
1701
 * @param  th_hmac_buffer_size  Size in bytes of the th_hmac_buffer
1702
 * @param  th_hmac_buffer       The buffer to store the th_hmac_buffer
1703
 *
1704
 * @retval RETURN_SUCCESS  current TH hmac is calculated.
1705
 */
1706
bool libspdm_calculate_th_hmac_for_exchange_rsp(
1707
    libspdm_context_t *spdm_context, void *spdm_session_info,
1708
    size_t *th_hmac_buffer_size, void *th_hmac_buffer);
1709
#endif
1710
1711
#if LIBSPDM_RECORD_TRANSCRIPT_DATA_SUPPORT
1712
/*
1713
 * This function calculates current TH data with message A, message K and message F.
1714
 *
1715
 * @param  spdm_context                A pointer to the SPDM context.
1716
 * @param  session_info                The SPDM session ID.
1717
 * @param  cert_chain_buffer           Certificate chain buffer with spdm_cert_chain_t header.
1718
 * @param  cert_chain_buffer_size      Size in bytes of the certificate chain buffer.
1719
 * @param  mut_cert_chain_buffer       Certificate chain buffer with spdm_cert_chain_t header in mutual authentication.
1720
 * @param  mut_cert_chain_buffer_size  Size in bytes of the certificate chain buffer in mutual authentication.
1721
 * @param  th_data_buffer_size         Size in bytes of the th_data_buffer.
1722
 * @param  th_data_buffer              The buffer to store the th_data_buffer
1723
 *
1724
 * @retval RETURN_SUCCESS  current TH data is calculated.
1725
 */
1726
bool libspdm_calculate_th_for_finish(libspdm_context_t *spdm_context,
1727
                                     void *spdm_session_info,
1728
                                     const uint8_t *cert_chain_buffer,
1729
                                     size_t cert_chain_buffer_size,
1730
                                     const uint8_t *mut_cert_chain_buffer,
1731
                                     size_t mut_cert_chain_buffer_size,
1732
                                     libspdm_th_managed_buffer_t *th_curr);
1733
#else
1734
/*
1735
 * This function calculates current TH hash with message A, message K and message F.
1736
 *
1737
 * @param  spdm_context         A pointer to the SPDM context.
1738
 * @param  session_info         The SPDM session ID.
1739
 * @param  th_hash_buffer_size  Size in bytes of the th_hash_buffer
1740
 * @param  th_hash_buffer       The buffer to store the th_hash_buffer
1741
 *
1742
 * @retval RETURN_SUCCESS  current TH hash is calculated.
1743
 */
1744
bool libspdm_calculate_th_hash_for_finish(libspdm_context_t *spdm_context,
1745
                                          void *spdm_session_info,
1746
                                          size_t *th_hash_buffer_size,
1747
                                          void *th_hash_buffer);
1748
1749
/*
1750
 * This function calculates current TH hmac with message A, message K and message F, with response finished_key.
1751
 *
1752
 * @param  spdm_context         A pointer to the SPDM context.
1753
 * @param  session_info         The SPDM session ID.
1754
 * @param  th_hmac_buffer_size  Size in bytes of the th_hmac_buffer
1755
 * @param  th_hmac_buffer       The buffer to store the th_hmac_buffer
1756
 *
1757
 * @retval RETURN_SUCCESS  current TH hmac is calculated.
1758
 */
1759
bool libspdm_calculate_th_hmac_for_finish_rsp(libspdm_context_t *spdm_context,
1760
                                              void *spdm_session_info,
1761
                                              size_t *th_hmac_buffer_size,
1762
                                              void *th_hmac_buffer);
1763
1764
/*
1765
 * This function calculates current TH hmac with message A, message K and message F, with request finished_key.
1766
 *
1767
 * @param  spdm_context         A pointer to the SPDM context.
1768
 * @param  session_info         The SPDM session ID.
1769
 * @param  th_hmac_buffer_size  Size in bytes of the th_hmac_buffer
1770
 * @param  th_hmac_buffer       The buffer to store the th_hmac_buffer
1771
 *
1772
 * @retval RETURN_SUCCESS  current TH hmac is calculated.
1773
 */
1774
bool libspdm_calculate_th_hmac_for_finish_req(libspdm_context_t *spdm_context,
1775
                                              void *spdm_session_info,
1776
                                              size_t *th_hmac_buffer_size,
1777
                                              void *th_hmac_buffer);
1778
#endif
1779
1780
/*
1781
 * This function calculates th1 hash.
1782
 *
1783
 * @param  spdm_context   A pointer to the SPDM context.
1784
 * @param  session_info   The SPDM session ID.
1785
 * @param  is_requester   Indicate of the key generation for a requester or a responder.
1786
 * @param  th1_hash_data  Th1 hash.
1787
 *
1788
 * @retval RETURN_SUCCESS  th1 hash is calculated.
1789
 */
1790
bool libspdm_calculate_th1_hash(libspdm_context_t *spdm_context,
1791
                                void *spdm_session_info,
1792
                                bool is_requester,
1793
                                uint8_t *th1_hash_data);
1794
1795
/*
1796
 * This function calculates th2 hash.
1797
 *
1798
 * @param  spdm_context   A pointer to the SPDM context.
1799
 * @param  session_info   The SPDM session ID.
1800
 * @param  is_requester   Indicate of the key generation for a requester or a responder.
1801
 * @param  th1_hash_data  Th2 hash
1802
 *
1803
 * @retval RETURN_SUCCESS  th2 hash is calculated.
1804
 */
1805
bool libspdm_calculate_th2_hash(libspdm_context_t *spdm_context,
1806
                                void *spdm_session_info,
1807
                                bool is_requester,
1808
                                uint8_t *th2_hash_data);
1809
1810
/**
1811
 * Reads a 24-bit value from memory that may be unaligned.
1812
 *
1813
 * @param  buffer  The pointer to a 24-bit value that may be unaligned.
1814
 *
1815
 * @return The 24-bit value read from buffer.
1816
 **/
1817
uint32_t libspdm_read_uint24(const uint8_t *buffer);
1818
1819
/**
1820
 * Writes a 24-bit value to memory that may be unaligned.
1821
 *
1822
 * @param  buffer  The pointer to a 24-bit value that may be unaligned.
1823
 * @param  value   24-bit value to write to buffer.
1824
 **/
1825
void libspdm_write_uint24(uint8_t *buffer, uint32_t value);
1826
1827
/**
1828
 * Reads a 16-bit value from memory that may be unaligned.
1829
 *
1830
 * @param  buffer  The pointer to a 16-bit value that may be unaligned.
1831
 *
1832
 * @return The 16-bit value read from buffer.
1833
 **/
1834
uint16_t libspdm_read_uint16(const uint8_t *buffer);
1835
1836
/**
1837
 * Writes a 16-bit value to memory that may be unaligned.
1838
 *
1839
 * @param  buffer  The pointer to a 16-bit value that may be unaligned.
1840
 * @param  value   16-bit value to write to buffer.
1841
 **/
1842
void libspdm_write_uint16(uint8_t *buffer, uint16_t value);
1843
1844
/**
1845
 * Reads a 32-bit value from memory that may be unaligned.
1846
 *
1847
 * @param  buffer  The pointer to a 32-bit value that may be unaligned.
1848
 *
1849
 * @return The 32-bit value read from buffer.
1850
 **/
1851
uint32_t libspdm_read_uint32(const uint8_t *buffer);
1852
1853
/**
1854
 * Writes a 32-bit value to memory that may be unaligned.
1855
 *
1856
 * @param  buffer  The pointer to a 32-bit value that may be unaligned.
1857
 * @param  value   32-bit value to write to buffer.
1858
 **/
1859
void libspdm_write_uint32(uint8_t *buffer, uint32_t value);
1860
1861
/**
1862
 * Reads a 64-bit value from memory that may be unaligned.
1863
 *
1864
 * @param  buffer  The pointer to a 64-bit value that may be unaligned.
1865
 *
1866
 * @return The 64-bit value read from buffer.
1867
 **/
1868
uint64_t libspdm_read_uint64(const uint8_t *buffer);
1869
1870
/**
1871
 * Writes a 64-bit value to memory that may be unaligned.
1872
 *
1873
 * @param  buffer  The pointer to a 64-bit value that may be unaligned.
1874
 * @param  value   64-bit value to write to buffer.
1875
 **/
1876
void libspdm_write_uint64(uint8_t *buffer, uint64_t value);
1877
1878
/**
1879
 * Determine if bitmask has at most one bit set.
1880
 *
1881
 * @param mask  The bitmask to be tested.
1882
 *
1883
 * @retval true   At most one bit is set.
1884
 * @retval false  More than one bit is set.
1885
 */
1886
static inline bool libspdm_onehot0(uint32_t mask)
1887
6.29k
{
1888
6.29k
    return !mask || !(mask & (mask - 1));
1889
6.29k
}
Unexecuted instantiation: csr.c:libspdm_onehot0
Unexecuted instantiation: common.c:libspdm_onehot0
Unexecuted instantiation: algo.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_csr.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_error.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_handle_response_state.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_receive_send.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_respond_if_ready.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_version.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_set_certificate_rsp.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_supported_event_types.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_subscribe_event_types_ack.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_chunk_send_ack.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_chunk_response.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_vendor_defined_response.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_measurement_extension_log.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_key_pair_info.c:libspdm_onehot0
libspdm_rsp_set_key_pair_info_ack.c:libspdm_onehot0
Line
Count
Source
1887
144
{
1888
144
    return !mask || !(mask & (mask - 1));
1889
144
}
Unexecuted instantiation: libspdm_rsp_algorithms.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_capabilities.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_certificate.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_challenge_auth.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_digests.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_encap_response.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_encap_send_event.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_end_session_ack.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_endpoint_info.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_finish_rsp.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_heartbeat.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_key_exchange.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_key_update_ack.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_measurements.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_psk_exchange_rsp.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_psk_finish_rsp.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_common.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_encap_challenge.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_encap_get_certificate.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_encap_get_digests.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_encap_get_endpoint_info.c:libspdm_onehot0
Unexecuted instantiation: libspdm_rsp_encap_key_update.c:libspdm_onehot0
Unexecuted instantiation: libspdm_com_context_data.c:libspdm_onehot0
Unexecuted instantiation: libspdm_com_context_data_session.c:libspdm_onehot0
Unexecuted instantiation: libspdm_com_crypto_service.c:libspdm_onehot0
Unexecuted instantiation: libspdm_com_crypto_service_session.c:libspdm_onehot0
Unexecuted instantiation: libspdm_com_opaque_data.c:libspdm_onehot0
Unexecuted instantiation: libspdm_com_support.c:libspdm_onehot0
Unexecuted instantiation: libspdm_secmes_context_data.c:libspdm_onehot0
Unexecuted instantiation: libspdm_secmes_key_exchange.c:libspdm_onehot0
Unexecuted instantiation: libspdm_secmes_key_exchange_pqc.c:libspdm_onehot0
Unexecuted instantiation: libspdm_secmes_session.c:libspdm_onehot0
Unexecuted instantiation: test.c:libspdm_onehot0
Unexecuted instantiation: chal.c:libspdm_onehot0
Unexecuted instantiation: endpointinfo.c:libspdm_onehot0
Unexecuted instantiation: event.c:libspdm_onehot0
Unexecuted instantiation: key_ex.c:libspdm_onehot0
Unexecuted instantiation: key_pair.c:libspdm_onehot0
Unexecuted instantiation: meas.c:libspdm_onehot0
Unexecuted instantiation: psk.c:libspdm_onehot0
Unexecuted instantiation: read_priv_key_pem.c:libspdm_onehot0
Unexecuted instantiation: read_priv_key_pem_pqc.c:libspdm_onehot0
Unexecuted instantiation: read_priv_key_raw_data.c:libspdm_onehot0
Unexecuted instantiation: read_priv_key_raw_data_pqc.c:libspdm_onehot0
Unexecuted instantiation: read_pub_cert.c:libspdm_onehot0
Unexecuted instantiation: set_cert.c:libspdm_onehot0
Unexecuted instantiation: sign.c:libspdm_onehot0
Unexecuted instantiation: libspdm_crypt_key_schedule.c:libspdm_onehot0
Unexecuted instantiation: libspdm_secmes_encode_decode.c:libspdm_onehot0
Unexecuted instantiation: psk_finish.c:libspdm_onehot0
Unexecuted instantiation: libspdm_req_psk_finish.c:libspdm_onehot0
Unexecuted instantiation: libspdm_req_send_receive.c:libspdm_onehot0
Unexecuted instantiation: libspdm_req_handle_error_response.c:libspdm_onehot0
Unexecuted instantiation: libspdm_com_msg_log.c:libspdm_onehot0
Unexecuted instantiation: spdm_encode_secured_message.c:libspdm_onehot0
Unexecuted instantiation: libspdm_mctp_mctp.c:libspdm_onehot0
Unexecuted instantiation: spdm_transport_mctp_decode_message.c:libspdm_onehot0
Unexecuted instantiation: chunk_get.c:libspdm_onehot0
libspdm_req_negotiate_algorithms.c:libspdm_onehot0
Line
Count
Source
1887
6.08k
{
1888
6.08k
    return !mask || !(mask & (mask - 1));
1889
6.08k
}
Unexecuted instantiation: encap_response.c:libspdm_onehot0
Unexecuted instantiation: key_exchange.c:libspdm_onehot0
Unexecuted instantiation: libspdm_req_key_exchange.c:libspdm_onehot0
Unexecuted instantiation: libspdm_req_common.c:libspdm_onehot0
Unexecuted instantiation: encap_key_update.c:libspdm_onehot0
Unexecuted instantiation: psk_exchange.c:libspdm_onehot0
Unexecuted instantiation: libspdm_req_psk_exchange.c:libspdm_onehot0
Unexecuted instantiation: version.c:libspdm_onehot0
Unexecuted instantiation: measurement_extension_log.c:libspdm_onehot0
Unexecuted instantiation: transport_mctp_encode_message.c:libspdm_onehot0
Unexecuted instantiation: test_process_opaque_data_supported_version_data.c:libspdm_onehot0
Unexecuted instantiation: spdm_transport_storage_encode_message.c:libspdm_onehot0
Unexecuted instantiation: libspdm_storage.c:libspdm_onehot0
Unexecuted instantiation: set_certificate.c:libspdm_onehot0
Unexecuted instantiation: libspdm_req_set_certificate.c:libspdm_onehot0
Unexecuted instantiation: get_key_pair_info.c:libspdm_onehot0
libspdm_req_get_key_pair_info.c:libspdm_onehot0
Line
Count
Source
1887
69
{
1888
69
    return !mask || !(mask & (mask - 1));
1889
69
}
Unexecuted instantiation: heartbeat.c:libspdm_onehot0
Unexecuted instantiation: libspdm_req_heartbeat.c:libspdm_onehot0
Unexecuted instantiation: read_pub_key_der.c:libspdm_onehot0
Unexecuted instantiation: encap_challenge.c:libspdm_onehot0
Unexecuted instantiation: get_certificate.c:libspdm_onehot0
Unexecuted instantiation: libspdm_req_get_certificate.c:libspdm_onehot0
Unexecuted instantiation: spdm_decode_secured_message.c:libspdm_onehot0
Unexecuted instantiation: respond_if_ready.c:libspdm_onehot0
Unexecuted instantiation: event_types.c:libspdm_onehot0
Unexecuted instantiation: x509_certificate_check.c:libspdm_onehot0
Unexecuted instantiation: encap_get_certificate.c:libspdm_onehot0
Unexecuted instantiation: spdm_transport_storage_decode_message.c:libspdm_onehot0
Unexecuted instantiation: challenge.c:libspdm_onehot0
Unexecuted instantiation: libspdm_req_challenge.c:libspdm_onehot0
Unexecuted instantiation: libspdm_req_encap_request.c:libspdm_onehot0
Unexecuted instantiation: libspdm_req_encap_supported_event_types.c:libspdm_onehot0
Unexecuted instantiation: libspdm_req_encap_subscribe_event_types_ack.c:libspdm_onehot0
Unexecuted instantiation: libspdm_req_encap_certificate.c:libspdm_onehot0
Unexecuted instantiation: libspdm_req_encap_challenge_auth.c:libspdm_onehot0
Unexecuted instantiation: libspdm_req_encap_digests.c:libspdm_onehot0
Unexecuted instantiation: libspdm_req_encap_error.c:libspdm_onehot0
Unexecuted instantiation: libspdm_req_encap_key_update_ack.c:libspdm_onehot0
Unexecuted instantiation: libspdm_req_encap_event_ack.c:libspdm_onehot0
Unexecuted instantiation: libspdm_req_encap_endpoint_info.c:libspdm_onehot0
Unexecuted instantiation: libspdm_com_event.c:libspdm_onehot0
Unexecuted instantiation: finish.c:libspdm_onehot0
Unexecuted instantiation: libspdm_req_finish.c:libspdm_onehot0
Unexecuted instantiation: spdm_transport_pci_doe_decode_message.c:libspdm_onehot0
Unexecuted instantiation: libspdm_doe_pcidoe.c:libspdm_onehot0
Unexecuted instantiation: challenge_auth.c:libspdm_onehot0
Unexecuted instantiation: key_pair_info.c:libspdm_onehot0
Unexecuted instantiation: vendor_cmds.c:libspdm_onehot0
Unexecuted instantiation: encap_request.c:libspdm_onehot0
Unexecuted instantiation: psk_exchange_rsp.c:libspdm_onehot0
Unexecuted instantiation: end_session.c:libspdm_onehot0
Unexecuted instantiation: libspdm_req_end_session.c:libspdm_onehot0
Unexecuted instantiation: encap_challenge_auth.c:libspdm_onehot0
Unexecuted instantiation: finish_rsp.c:libspdm_onehot0
Unexecuted instantiation: algorithms.c:libspdm_onehot0
Unexecuted instantiation: heartbeat_ack.c:libspdm_onehot0
Unexecuted instantiation: set_key_pair_info_ack.c:libspdm_onehot0
Unexecuted instantiation: encap_digests.c:libspdm_onehot0
Unexecuted instantiation: chunk_send.c:libspdm_onehot0
Unexecuted instantiation: capabilities.c:libspdm_onehot0
Unexecuted instantiation: get_version.c:libspdm_onehot0
Unexecuted instantiation: libspdm_req_get_version.c:libspdm_onehot0
Unexecuted instantiation: set_key_pair_info.c:libspdm_onehot0
Unexecuted instantiation: libspdm_req_set_key_pair_info.c:libspdm_onehot0
Unexecuted instantiation: encap_certificate.c:libspdm_onehot0
Unexecuted instantiation: get_digests.c:libspdm_onehot0
Unexecuted instantiation: libspdm_req_get_digests.c:libspdm_onehot0
Unexecuted instantiation: get_measurements.c:libspdm_onehot0
Unexecuted instantiation: libspdm_req_get_measurements.c:libspdm_onehot0
Unexecuted instantiation: digests.c:libspdm_onehot0
Unexecuted instantiation: get_capabilities.c:libspdm_onehot0
Unexecuted instantiation: libspdm_req_get_capabilities.c:libspdm_onehot0
Unexecuted instantiation: measurements.c:libspdm_onehot0
Unexecuted instantiation: spdm_transport_pci_doe_encode_message.c:libspdm_onehot0
Unexecuted instantiation: spdm_transport_tcp_decode_message.c:libspdm_onehot0
Unexecuted instantiation: libspdm_tcp_tcp.c:libspdm_onehot0
Unexecuted instantiation: key_update.c:libspdm_onehot0
Unexecuted instantiation: libspdm_req_key_update.c:libspdm_onehot0
Unexecuted instantiation: encap_get_digests.c:libspdm_onehot0
Unexecuted instantiation: psk_finish_rsp.c:libspdm_onehot0
Unexecuted instantiation: spdm_transport_tcp_encode_message.c:libspdm_onehot0
Unexecuted instantiation: set_certificate_rsp.c:libspdm_onehot0
Unexecuted instantiation: get_csr.c:libspdm_onehot0
Unexecuted instantiation: libspdm_req_get_csr.c:libspdm_onehot0
Unexecuted instantiation: libspdm_req_vendor_defined_request.c:libspdm_onehot0
Unexecuted instantiation: certificate.c:libspdm_onehot0
Unexecuted instantiation: get_measurement_extension_log.c:libspdm_onehot0
Unexecuted instantiation: libspdm_req_get_measurement_extension_log.c:libspdm_onehot0
Unexecuted instantiation: chunk_send_ack.c:libspdm_onehot0
Unexecuted instantiation: negotiate_algorithms.c:libspdm_onehot0
Unexecuted instantiation: get_event_types.c:libspdm_onehot0
Unexecuted instantiation: libspdm_req_get_supported_event_types.c:libspdm_onehot0
1890
1891
static inline uint64_t libspdm_byte_swap_64(uint64_t value)
1892
0
{
1893
0
    return (((value & 0x00000000000000ff) << 56) |
1894
0
            ((value & 0x000000000000ff00) << 40) |
1895
0
            ((value & 0x0000000000ff0000) << 24) |
1896
0
            ((value & 0x00000000ff000000) << 8) |
1897
0
            ((value & 0x000000ff00000000) >> 8) |
1898
0
            ((value & 0x0000ff0000000000) >> 24) |
1899
0
            ((value & 0x00ff000000000000) >> 40) |
1900
0
            ((value & 0xff00000000000000) >> 56));
1901
0
}
Unexecuted instantiation: csr.c:libspdm_byte_swap_64
Unexecuted instantiation: common.c:libspdm_byte_swap_64
Unexecuted instantiation: algo.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_csr.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_error.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_handle_response_state.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_receive_send.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_respond_if_ready.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_version.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_set_certificate_rsp.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_supported_event_types.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_subscribe_event_types_ack.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_chunk_send_ack.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_chunk_response.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_vendor_defined_response.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_measurement_extension_log.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_key_pair_info.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_set_key_pair_info_ack.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_algorithms.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_capabilities.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_certificate.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_challenge_auth.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_digests.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_encap_response.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_encap_send_event.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_end_session_ack.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_endpoint_info.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_finish_rsp.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_heartbeat.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_key_exchange.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_key_update_ack.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_measurements.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_psk_exchange_rsp.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_psk_finish_rsp.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_common.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_encap_challenge.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_encap_get_certificate.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_encap_get_digests.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_encap_get_endpoint_info.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_rsp_encap_key_update.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_com_context_data.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_com_context_data_session.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_com_crypto_service.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_com_crypto_service_session.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_com_opaque_data.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_com_support.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_secmes_context_data.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_secmes_key_exchange.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_secmes_key_exchange_pqc.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_secmes_session.c:libspdm_byte_swap_64
Unexecuted instantiation: test.c:libspdm_byte_swap_64
Unexecuted instantiation: chal.c:libspdm_byte_swap_64
Unexecuted instantiation: endpointinfo.c:libspdm_byte_swap_64
Unexecuted instantiation: event.c:libspdm_byte_swap_64
Unexecuted instantiation: key_ex.c:libspdm_byte_swap_64
Unexecuted instantiation: key_pair.c:libspdm_byte_swap_64
Unexecuted instantiation: meas.c:libspdm_byte_swap_64
Unexecuted instantiation: psk.c:libspdm_byte_swap_64
Unexecuted instantiation: read_priv_key_pem.c:libspdm_byte_swap_64
Unexecuted instantiation: read_priv_key_pem_pqc.c:libspdm_byte_swap_64
Unexecuted instantiation: read_priv_key_raw_data.c:libspdm_byte_swap_64
Unexecuted instantiation: read_priv_key_raw_data_pqc.c:libspdm_byte_swap_64
Unexecuted instantiation: read_pub_cert.c:libspdm_byte_swap_64
Unexecuted instantiation: set_cert.c:libspdm_byte_swap_64
Unexecuted instantiation: sign.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_crypt_key_schedule.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_secmes_encode_decode.c:libspdm_byte_swap_64
Unexecuted instantiation: psk_finish.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_req_psk_finish.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_req_send_receive.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_req_handle_error_response.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_com_msg_log.c:libspdm_byte_swap_64
Unexecuted instantiation: spdm_encode_secured_message.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_mctp_mctp.c:libspdm_byte_swap_64
Unexecuted instantiation: spdm_transport_mctp_decode_message.c:libspdm_byte_swap_64
Unexecuted instantiation: chunk_get.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_req_negotiate_algorithms.c:libspdm_byte_swap_64
Unexecuted instantiation: encap_response.c:libspdm_byte_swap_64
Unexecuted instantiation: key_exchange.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_req_key_exchange.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_req_common.c:libspdm_byte_swap_64
Unexecuted instantiation: encap_key_update.c:libspdm_byte_swap_64
Unexecuted instantiation: psk_exchange.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_req_psk_exchange.c:libspdm_byte_swap_64
Unexecuted instantiation: version.c:libspdm_byte_swap_64
Unexecuted instantiation: measurement_extension_log.c:libspdm_byte_swap_64
Unexecuted instantiation: transport_mctp_encode_message.c:libspdm_byte_swap_64
Unexecuted instantiation: test_process_opaque_data_supported_version_data.c:libspdm_byte_swap_64
Unexecuted instantiation: spdm_transport_storage_encode_message.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_storage.c:libspdm_byte_swap_64
Unexecuted instantiation: set_certificate.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_req_set_certificate.c:libspdm_byte_swap_64
Unexecuted instantiation: get_key_pair_info.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_req_get_key_pair_info.c:libspdm_byte_swap_64
Unexecuted instantiation: heartbeat.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_req_heartbeat.c:libspdm_byte_swap_64
Unexecuted instantiation: read_pub_key_der.c:libspdm_byte_swap_64
Unexecuted instantiation: encap_challenge.c:libspdm_byte_swap_64
Unexecuted instantiation: get_certificate.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_req_get_certificate.c:libspdm_byte_swap_64
Unexecuted instantiation: spdm_decode_secured_message.c:libspdm_byte_swap_64
Unexecuted instantiation: respond_if_ready.c:libspdm_byte_swap_64
Unexecuted instantiation: event_types.c:libspdm_byte_swap_64
Unexecuted instantiation: x509_certificate_check.c:libspdm_byte_swap_64
Unexecuted instantiation: encap_get_certificate.c:libspdm_byte_swap_64
Unexecuted instantiation: spdm_transport_storage_decode_message.c:libspdm_byte_swap_64
Unexecuted instantiation: challenge.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_req_challenge.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_req_encap_request.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_req_encap_supported_event_types.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_req_encap_subscribe_event_types_ack.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_req_encap_certificate.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_req_encap_challenge_auth.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_req_encap_digests.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_req_encap_error.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_req_encap_key_update_ack.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_req_encap_event_ack.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_req_encap_endpoint_info.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_com_event.c:libspdm_byte_swap_64
Unexecuted instantiation: finish.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_req_finish.c:libspdm_byte_swap_64
Unexecuted instantiation: spdm_transport_pci_doe_decode_message.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_doe_pcidoe.c:libspdm_byte_swap_64
Unexecuted instantiation: challenge_auth.c:libspdm_byte_swap_64
Unexecuted instantiation: key_pair_info.c:libspdm_byte_swap_64
Unexecuted instantiation: vendor_cmds.c:libspdm_byte_swap_64
Unexecuted instantiation: encap_request.c:libspdm_byte_swap_64
Unexecuted instantiation: psk_exchange_rsp.c:libspdm_byte_swap_64
Unexecuted instantiation: end_session.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_req_end_session.c:libspdm_byte_swap_64
Unexecuted instantiation: encap_challenge_auth.c:libspdm_byte_swap_64
Unexecuted instantiation: finish_rsp.c:libspdm_byte_swap_64
Unexecuted instantiation: algorithms.c:libspdm_byte_swap_64
Unexecuted instantiation: heartbeat_ack.c:libspdm_byte_swap_64
Unexecuted instantiation: set_key_pair_info_ack.c:libspdm_byte_swap_64
Unexecuted instantiation: encap_digests.c:libspdm_byte_swap_64
Unexecuted instantiation: chunk_send.c:libspdm_byte_swap_64
Unexecuted instantiation: capabilities.c:libspdm_byte_swap_64
Unexecuted instantiation: get_version.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_req_get_version.c:libspdm_byte_swap_64
Unexecuted instantiation: set_key_pair_info.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_req_set_key_pair_info.c:libspdm_byte_swap_64
Unexecuted instantiation: encap_certificate.c:libspdm_byte_swap_64
Unexecuted instantiation: get_digests.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_req_get_digests.c:libspdm_byte_swap_64
Unexecuted instantiation: get_measurements.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_req_get_measurements.c:libspdm_byte_swap_64
Unexecuted instantiation: digests.c:libspdm_byte_swap_64
Unexecuted instantiation: get_capabilities.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_req_get_capabilities.c:libspdm_byte_swap_64
Unexecuted instantiation: measurements.c:libspdm_byte_swap_64
Unexecuted instantiation: spdm_transport_pci_doe_encode_message.c:libspdm_byte_swap_64
Unexecuted instantiation: spdm_transport_tcp_decode_message.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_tcp_tcp.c:libspdm_byte_swap_64
Unexecuted instantiation: key_update.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_req_key_update.c:libspdm_byte_swap_64
Unexecuted instantiation: encap_get_digests.c:libspdm_byte_swap_64
Unexecuted instantiation: psk_finish_rsp.c:libspdm_byte_swap_64
Unexecuted instantiation: spdm_transport_tcp_encode_message.c:libspdm_byte_swap_64
Unexecuted instantiation: set_certificate_rsp.c:libspdm_byte_swap_64
Unexecuted instantiation: get_csr.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_req_get_csr.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_req_vendor_defined_request.c:libspdm_byte_swap_64
Unexecuted instantiation: certificate.c:libspdm_byte_swap_64
Unexecuted instantiation: get_measurement_extension_log.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_req_get_measurement_extension_log.c:libspdm_byte_swap_64
Unexecuted instantiation: chunk_send_ack.c:libspdm_byte_swap_64
Unexecuted instantiation: negotiate_algorithms.c:libspdm_byte_swap_64
Unexecuted instantiation: get_event_types.c:libspdm_byte_swap_64
Unexecuted instantiation: libspdm_req_get_supported_event_types.c:libspdm_byte_swap_64
1902
1903
static inline uint32_t libspdm_byte_swap_32(uint32_t value)
1904
0
{
1905
0
    return ((value & 0x000000FF) << 24) |
1906
0
           ((value & 0x0000FF00) << 8)  |
1907
0
           ((value & 0x00FF0000) >> 8)  |
1908
0
           ((value & 0xFF000000) >> 24);
1909
0
}
Unexecuted instantiation: csr.c:libspdm_byte_swap_32
Unexecuted instantiation: common.c:libspdm_byte_swap_32
Unexecuted instantiation: algo.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_csr.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_error.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_handle_response_state.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_receive_send.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_respond_if_ready.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_version.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_set_certificate_rsp.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_supported_event_types.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_subscribe_event_types_ack.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_chunk_send_ack.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_chunk_response.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_vendor_defined_response.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_measurement_extension_log.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_key_pair_info.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_set_key_pair_info_ack.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_algorithms.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_capabilities.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_certificate.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_challenge_auth.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_digests.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_encap_response.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_encap_send_event.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_end_session_ack.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_endpoint_info.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_finish_rsp.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_heartbeat.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_key_exchange.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_key_update_ack.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_measurements.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_psk_exchange_rsp.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_psk_finish_rsp.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_common.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_encap_challenge.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_encap_get_certificate.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_encap_get_digests.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_encap_get_endpoint_info.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_rsp_encap_key_update.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_com_context_data.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_com_context_data_session.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_com_crypto_service.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_com_crypto_service_session.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_com_opaque_data.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_com_support.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_secmes_context_data.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_secmes_key_exchange.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_secmes_key_exchange_pqc.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_secmes_session.c:libspdm_byte_swap_32
Unexecuted instantiation: test.c:libspdm_byte_swap_32
Unexecuted instantiation: chal.c:libspdm_byte_swap_32
Unexecuted instantiation: endpointinfo.c:libspdm_byte_swap_32
Unexecuted instantiation: event.c:libspdm_byte_swap_32
Unexecuted instantiation: key_ex.c:libspdm_byte_swap_32
Unexecuted instantiation: key_pair.c:libspdm_byte_swap_32
Unexecuted instantiation: meas.c:libspdm_byte_swap_32
Unexecuted instantiation: psk.c:libspdm_byte_swap_32
Unexecuted instantiation: read_priv_key_pem.c:libspdm_byte_swap_32
Unexecuted instantiation: read_priv_key_pem_pqc.c:libspdm_byte_swap_32
Unexecuted instantiation: read_priv_key_raw_data.c:libspdm_byte_swap_32
Unexecuted instantiation: read_priv_key_raw_data_pqc.c:libspdm_byte_swap_32
Unexecuted instantiation: read_pub_cert.c:libspdm_byte_swap_32
Unexecuted instantiation: set_cert.c:libspdm_byte_swap_32
Unexecuted instantiation: sign.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_crypt_key_schedule.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_secmes_encode_decode.c:libspdm_byte_swap_32
Unexecuted instantiation: psk_finish.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_req_psk_finish.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_req_send_receive.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_req_handle_error_response.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_com_msg_log.c:libspdm_byte_swap_32
Unexecuted instantiation: spdm_encode_secured_message.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_mctp_mctp.c:libspdm_byte_swap_32
Unexecuted instantiation: spdm_transport_mctp_decode_message.c:libspdm_byte_swap_32
Unexecuted instantiation: chunk_get.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_req_negotiate_algorithms.c:libspdm_byte_swap_32
Unexecuted instantiation: encap_response.c:libspdm_byte_swap_32
Unexecuted instantiation: key_exchange.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_req_key_exchange.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_req_common.c:libspdm_byte_swap_32
Unexecuted instantiation: encap_key_update.c:libspdm_byte_swap_32
Unexecuted instantiation: psk_exchange.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_req_psk_exchange.c:libspdm_byte_swap_32
Unexecuted instantiation: version.c:libspdm_byte_swap_32
Unexecuted instantiation: measurement_extension_log.c:libspdm_byte_swap_32
Unexecuted instantiation: transport_mctp_encode_message.c:libspdm_byte_swap_32
Unexecuted instantiation: test_process_opaque_data_supported_version_data.c:libspdm_byte_swap_32
Unexecuted instantiation: spdm_transport_storage_encode_message.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_storage.c:libspdm_byte_swap_32
Unexecuted instantiation: set_certificate.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_req_set_certificate.c:libspdm_byte_swap_32
Unexecuted instantiation: get_key_pair_info.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_req_get_key_pair_info.c:libspdm_byte_swap_32
Unexecuted instantiation: heartbeat.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_req_heartbeat.c:libspdm_byte_swap_32
Unexecuted instantiation: read_pub_key_der.c:libspdm_byte_swap_32
Unexecuted instantiation: encap_challenge.c:libspdm_byte_swap_32
Unexecuted instantiation: get_certificate.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_req_get_certificate.c:libspdm_byte_swap_32
Unexecuted instantiation: spdm_decode_secured_message.c:libspdm_byte_swap_32
Unexecuted instantiation: respond_if_ready.c:libspdm_byte_swap_32
Unexecuted instantiation: event_types.c:libspdm_byte_swap_32
Unexecuted instantiation: x509_certificate_check.c:libspdm_byte_swap_32
Unexecuted instantiation: encap_get_certificate.c:libspdm_byte_swap_32
Unexecuted instantiation: spdm_transport_storage_decode_message.c:libspdm_byte_swap_32
Unexecuted instantiation: challenge.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_req_challenge.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_req_encap_request.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_req_encap_supported_event_types.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_req_encap_subscribe_event_types_ack.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_req_encap_certificate.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_req_encap_challenge_auth.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_req_encap_digests.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_req_encap_error.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_req_encap_key_update_ack.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_req_encap_event_ack.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_req_encap_endpoint_info.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_com_event.c:libspdm_byte_swap_32
Unexecuted instantiation: finish.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_req_finish.c:libspdm_byte_swap_32
Unexecuted instantiation: spdm_transport_pci_doe_decode_message.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_doe_pcidoe.c:libspdm_byte_swap_32
Unexecuted instantiation: challenge_auth.c:libspdm_byte_swap_32
Unexecuted instantiation: key_pair_info.c:libspdm_byte_swap_32
Unexecuted instantiation: vendor_cmds.c:libspdm_byte_swap_32
Unexecuted instantiation: encap_request.c:libspdm_byte_swap_32
Unexecuted instantiation: psk_exchange_rsp.c:libspdm_byte_swap_32
Unexecuted instantiation: end_session.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_req_end_session.c:libspdm_byte_swap_32
Unexecuted instantiation: encap_challenge_auth.c:libspdm_byte_swap_32
Unexecuted instantiation: finish_rsp.c:libspdm_byte_swap_32
Unexecuted instantiation: algorithms.c:libspdm_byte_swap_32
Unexecuted instantiation: heartbeat_ack.c:libspdm_byte_swap_32
Unexecuted instantiation: set_key_pair_info_ack.c:libspdm_byte_swap_32
Unexecuted instantiation: encap_digests.c:libspdm_byte_swap_32
Unexecuted instantiation: chunk_send.c:libspdm_byte_swap_32
Unexecuted instantiation: capabilities.c:libspdm_byte_swap_32
Unexecuted instantiation: get_version.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_req_get_version.c:libspdm_byte_swap_32
Unexecuted instantiation: set_key_pair_info.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_req_set_key_pair_info.c:libspdm_byte_swap_32
Unexecuted instantiation: encap_certificate.c:libspdm_byte_swap_32
Unexecuted instantiation: get_digests.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_req_get_digests.c:libspdm_byte_swap_32
Unexecuted instantiation: get_measurements.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_req_get_measurements.c:libspdm_byte_swap_32
Unexecuted instantiation: digests.c:libspdm_byte_swap_32
Unexecuted instantiation: get_capabilities.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_req_get_capabilities.c:libspdm_byte_swap_32
Unexecuted instantiation: measurements.c:libspdm_byte_swap_32
Unexecuted instantiation: spdm_transport_pci_doe_encode_message.c:libspdm_byte_swap_32
Unexecuted instantiation: spdm_transport_tcp_decode_message.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_tcp_tcp.c:libspdm_byte_swap_32
Unexecuted instantiation: key_update.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_req_key_update.c:libspdm_byte_swap_32
Unexecuted instantiation: encap_get_digests.c:libspdm_byte_swap_32
Unexecuted instantiation: psk_finish_rsp.c:libspdm_byte_swap_32
Unexecuted instantiation: spdm_transport_tcp_encode_message.c:libspdm_byte_swap_32
Unexecuted instantiation: set_certificate_rsp.c:libspdm_byte_swap_32
Unexecuted instantiation: get_csr.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_req_get_csr.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_req_vendor_defined_request.c:libspdm_byte_swap_32
Unexecuted instantiation: certificate.c:libspdm_byte_swap_32
Unexecuted instantiation: get_measurement_extension_log.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_req_get_measurement_extension_log.c:libspdm_byte_swap_32
Unexecuted instantiation: chunk_send_ack.c:libspdm_byte_swap_32
Unexecuted instantiation: negotiate_algorithms.c:libspdm_byte_swap_32
Unexecuted instantiation: get_event_types.c:libspdm_byte_swap_32
Unexecuted instantiation: libspdm_req_get_supported_event_types.c:libspdm_byte_swap_32
1910
1911
static inline uint16_t libspdm_byte_swap_16(uint16_t value)
1912
0
{
1913
0
    return ((value & 0x00FF) << 8) |
1914
0
           ((value & 0xFF00) >> 8);
1915
0
}
Unexecuted instantiation: csr.c:libspdm_byte_swap_16
Unexecuted instantiation: common.c:libspdm_byte_swap_16
Unexecuted instantiation: algo.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_csr.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_error.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_handle_response_state.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_receive_send.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_respond_if_ready.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_version.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_set_certificate_rsp.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_supported_event_types.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_subscribe_event_types_ack.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_chunk_send_ack.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_chunk_response.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_vendor_defined_response.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_measurement_extension_log.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_key_pair_info.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_set_key_pair_info_ack.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_algorithms.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_capabilities.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_certificate.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_challenge_auth.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_digests.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_encap_response.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_encap_send_event.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_end_session_ack.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_endpoint_info.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_finish_rsp.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_heartbeat.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_key_exchange.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_key_update_ack.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_measurements.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_psk_exchange_rsp.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_psk_finish_rsp.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_common.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_encap_challenge.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_encap_get_certificate.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_encap_get_digests.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_encap_get_endpoint_info.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_rsp_encap_key_update.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_com_context_data.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_com_context_data_session.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_com_crypto_service.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_com_crypto_service_session.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_com_opaque_data.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_com_support.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_secmes_context_data.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_secmes_key_exchange.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_secmes_key_exchange_pqc.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_secmes_session.c:libspdm_byte_swap_16
Unexecuted instantiation: test.c:libspdm_byte_swap_16
Unexecuted instantiation: chal.c:libspdm_byte_swap_16
Unexecuted instantiation: endpointinfo.c:libspdm_byte_swap_16
Unexecuted instantiation: event.c:libspdm_byte_swap_16
Unexecuted instantiation: key_ex.c:libspdm_byte_swap_16
Unexecuted instantiation: key_pair.c:libspdm_byte_swap_16
Unexecuted instantiation: meas.c:libspdm_byte_swap_16
Unexecuted instantiation: psk.c:libspdm_byte_swap_16
Unexecuted instantiation: read_priv_key_pem.c:libspdm_byte_swap_16
Unexecuted instantiation: read_priv_key_pem_pqc.c:libspdm_byte_swap_16
Unexecuted instantiation: read_priv_key_raw_data.c:libspdm_byte_swap_16
Unexecuted instantiation: read_priv_key_raw_data_pqc.c:libspdm_byte_swap_16
Unexecuted instantiation: read_pub_cert.c:libspdm_byte_swap_16
Unexecuted instantiation: set_cert.c:libspdm_byte_swap_16
Unexecuted instantiation: sign.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_crypt_key_schedule.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_secmes_encode_decode.c:libspdm_byte_swap_16
Unexecuted instantiation: psk_finish.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_req_psk_finish.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_req_send_receive.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_req_handle_error_response.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_com_msg_log.c:libspdm_byte_swap_16
Unexecuted instantiation: spdm_encode_secured_message.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_mctp_mctp.c:libspdm_byte_swap_16
Unexecuted instantiation: spdm_transport_mctp_decode_message.c:libspdm_byte_swap_16
Unexecuted instantiation: chunk_get.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_req_negotiate_algorithms.c:libspdm_byte_swap_16
Unexecuted instantiation: encap_response.c:libspdm_byte_swap_16
Unexecuted instantiation: key_exchange.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_req_key_exchange.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_req_common.c:libspdm_byte_swap_16
Unexecuted instantiation: encap_key_update.c:libspdm_byte_swap_16
Unexecuted instantiation: psk_exchange.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_req_psk_exchange.c:libspdm_byte_swap_16
Unexecuted instantiation: version.c:libspdm_byte_swap_16
Unexecuted instantiation: measurement_extension_log.c:libspdm_byte_swap_16
Unexecuted instantiation: transport_mctp_encode_message.c:libspdm_byte_swap_16
Unexecuted instantiation: test_process_opaque_data_supported_version_data.c:libspdm_byte_swap_16
Unexecuted instantiation: spdm_transport_storage_encode_message.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_storage.c:libspdm_byte_swap_16
Unexecuted instantiation: set_certificate.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_req_set_certificate.c:libspdm_byte_swap_16
Unexecuted instantiation: get_key_pair_info.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_req_get_key_pair_info.c:libspdm_byte_swap_16
Unexecuted instantiation: heartbeat.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_req_heartbeat.c:libspdm_byte_swap_16
Unexecuted instantiation: read_pub_key_der.c:libspdm_byte_swap_16
Unexecuted instantiation: encap_challenge.c:libspdm_byte_swap_16
Unexecuted instantiation: get_certificate.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_req_get_certificate.c:libspdm_byte_swap_16
Unexecuted instantiation: spdm_decode_secured_message.c:libspdm_byte_swap_16
Unexecuted instantiation: respond_if_ready.c:libspdm_byte_swap_16
Unexecuted instantiation: event_types.c:libspdm_byte_swap_16
Unexecuted instantiation: x509_certificate_check.c:libspdm_byte_swap_16
Unexecuted instantiation: encap_get_certificate.c:libspdm_byte_swap_16
Unexecuted instantiation: spdm_transport_storage_decode_message.c:libspdm_byte_swap_16
Unexecuted instantiation: challenge.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_req_challenge.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_req_encap_request.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_req_encap_supported_event_types.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_req_encap_subscribe_event_types_ack.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_req_encap_certificate.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_req_encap_challenge_auth.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_req_encap_digests.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_req_encap_error.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_req_encap_key_update_ack.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_req_encap_event_ack.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_req_encap_endpoint_info.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_com_event.c:libspdm_byte_swap_16
Unexecuted instantiation: finish.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_req_finish.c:libspdm_byte_swap_16
Unexecuted instantiation: spdm_transport_pci_doe_decode_message.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_doe_pcidoe.c:libspdm_byte_swap_16
Unexecuted instantiation: challenge_auth.c:libspdm_byte_swap_16
Unexecuted instantiation: key_pair_info.c:libspdm_byte_swap_16
Unexecuted instantiation: vendor_cmds.c:libspdm_byte_swap_16
Unexecuted instantiation: encap_request.c:libspdm_byte_swap_16
Unexecuted instantiation: psk_exchange_rsp.c:libspdm_byte_swap_16
Unexecuted instantiation: end_session.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_req_end_session.c:libspdm_byte_swap_16
Unexecuted instantiation: encap_challenge_auth.c:libspdm_byte_swap_16
Unexecuted instantiation: finish_rsp.c:libspdm_byte_swap_16
Unexecuted instantiation: algorithms.c:libspdm_byte_swap_16
Unexecuted instantiation: heartbeat_ack.c:libspdm_byte_swap_16
Unexecuted instantiation: set_key_pair_info_ack.c:libspdm_byte_swap_16
Unexecuted instantiation: encap_digests.c:libspdm_byte_swap_16
Unexecuted instantiation: chunk_send.c:libspdm_byte_swap_16
Unexecuted instantiation: capabilities.c:libspdm_byte_swap_16
Unexecuted instantiation: get_version.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_req_get_version.c:libspdm_byte_swap_16
Unexecuted instantiation: set_key_pair_info.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_req_set_key_pair_info.c:libspdm_byte_swap_16
Unexecuted instantiation: encap_certificate.c:libspdm_byte_swap_16
Unexecuted instantiation: get_digests.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_req_get_digests.c:libspdm_byte_swap_16
Unexecuted instantiation: get_measurements.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_req_get_measurements.c:libspdm_byte_swap_16
Unexecuted instantiation: digests.c:libspdm_byte_swap_16
Unexecuted instantiation: get_capabilities.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_req_get_capabilities.c:libspdm_byte_swap_16
Unexecuted instantiation: measurements.c:libspdm_byte_swap_16
Unexecuted instantiation: spdm_transport_pci_doe_encode_message.c:libspdm_byte_swap_16
Unexecuted instantiation: spdm_transport_tcp_decode_message.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_tcp_tcp.c:libspdm_byte_swap_16
Unexecuted instantiation: key_update.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_req_key_update.c:libspdm_byte_swap_16
Unexecuted instantiation: encap_get_digests.c:libspdm_byte_swap_16
Unexecuted instantiation: psk_finish_rsp.c:libspdm_byte_swap_16
Unexecuted instantiation: spdm_transport_tcp_encode_message.c:libspdm_byte_swap_16
Unexecuted instantiation: set_certificate_rsp.c:libspdm_byte_swap_16
Unexecuted instantiation: get_csr.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_req_get_csr.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_req_vendor_defined_request.c:libspdm_byte_swap_16
Unexecuted instantiation: certificate.c:libspdm_byte_swap_16
Unexecuted instantiation: get_measurement_extension_log.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_req_get_measurement_extension_log.c:libspdm_byte_swap_16
Unexecuted instantiation: chunk_send_ack.c:libspdm_byte_swap_16
Unexecuted instantiation: negotiate_algorithms.c:libspdm_byte_swap_16
Unexecuted instantiation: get_event_types.c:libspdm_byte_swap_16
Unexecuted instantiation: libspdm_req_get_supported_event_types.c:libspdm_byte_swap_16
1916
1917
/**
1918
 * Return capability flags that are masked by the negotiated SPDM version.
1919
 *
1920
 * @param  spdm_context      A pointer to the SPDM context.
1921
 * @param  is_request_flags  If true then flags are from a request message or Requester.
1922
 *                           If false then flags are from a response message or Responder.
1923
 * @param  flags             A bitmask of capability flags.
1924
 *
1925
 * @return The masked capability flags.
1926
 */
1927
uint32_t libspdm_mask_capability_flags(libspdm_context_t *spdm_context,
1928
                                       bool is_request_flags, uint32_t flags);
1929
1930
/**
1931
 * Return capability extended flags that are masked by the negotiated SPDM version.
1932
 *
1933
 * @param  spdm_context      A pointer to the SPDM context.
1934
 * @param  is_request_flags  If true then flags are from a request message or Requester.
1935
 *                           If false then flags are from a response message or Responder.
1936
 * @param  ext_flags         A bitmask of capability extended flags.
1937
 *
1938
 * @return The masked capability extended flags.
1939
 */
1940
uint16_t libspdm_mask_capability_ext_flags(libspdm_context_t *spdm_context,
1941
                                           bool is_request_flags, uint16_t ext_flags);
1942
1943
/**
1944
 * Return BaseHashAlgo that is masked by the negotiated SPDM version.
1945
 *
1946
 * @param  spdm_context    A pointer to the SPDM context.
1947
 * @param  base_hash_algo  Unmasked BaseHashAlgo.
1948
 *
1949
 * @return The masked BaseHashAlgo.
1950
 */
1951
uint32_t libspdm_mask_base_hash_algo(libspdm_context_t *spdm_context, uint32_t base_hash_algo);
1952
1953
/**
1954
 * Return MeasurementHashAlgo that is masked by the negotiated SPDM version.
1955
 *
1956
 * @param  spdm_context           A pointer to the SPDM context.
1957
 * @param  measurement_hash_algo  Unmasked MeasurementHashAlgo.
1958
 *
1959
 * @return The masked MeasurementHashAlgo.
1960
 */
1961
uint32_t libspdm_mask_measurement_hash_algo(libspdm_context_t *spdm_context,
1962
                                            uint32_t measurement_hash_algo);
1963
1964
/**
1965
 * Return MeasurementSpecification that is masked by the negotiated SPDM version.
1966
 *
1967
 * @param  spdm_context               A pointer to the SPDM context.
1968
 * @param  measurement_specification  Unmasked MeasurementSpecification.
1969
 *
1970
 * @return The masked MeasurementSpecification.
1971
 */
1972
uint8_t libspdm_mask_measurement_specification(uint8_t measurement_specification);
1973
1974
/**
1975
 * Return MELspecification that is masked by the negotiated SPDM version.
1976
 *
1977
 * @param  spdm_context       A pointer to the SPDM context.
1978
 * @param  mel_specification  Unmasked MELspecification.
1979
 *
1980
 * @return The masked MELspecification.
1981
 */
1982
uint8_t libspdm_mask_mel_specification(libspdm_context_t *spdm_context, uint8_t mel_specification);
1983
1984
/**
1985
 * Return BaseAsymAlgo that is masked by the negotiated SPDM version.
1986
 *
1987
 * @param  spdm_context    A pointer to the SPDM context.
1988
 * @param  base_asym_algo  Unmasked BaseAsymAlgo.
1989
 *
1990
 * @return The masked BaseAsymAlgo.
1991
 */
1992
uint32_t libspdm_mask_base_asym_algo(libspdm_context_t *spdm_context, uint32_t base_asym_algo);
1993
1994
/**
1995
 * Check if the combination of SVH ID and VendorIDLen are legal.
1996
 *
1997
 * @param  id             Registry or standards body identifier (SPDM_REGISTRY_ID_*).
1998
 *                        Its size is two bytes due to the vendor-defined messages.
1999
 * @param  vendor_id_len  Length, in bytes, of the VendorID field.
2000
 * @retval true  The ID and VendorIDLen are legal.
2001
 * @retval false The ID and VendorIDLen are illegal.
2002
 */
2003
bool libspdm_validate_svh_vendor_id_len(uint16_t id, uint8_t vendor_id_len);
2004
2005
/**
2006
 * Map slot ID to key pair ID.
2007
 *
2008
 * @param  spdm_context   A pointer to the SPDM context.
2009
 * @param  slot_id        The slot ID.
2010
 * @param  is_requester   Indicate of the key generation for a requester or a responder.
2011
 *
2012
 * @return key pair ID.
2013
 */
2014
uint8_t libspdm_slot_id_to_key_pair_id (
2015
    void *spdm_context,
2016
    uint8_t slot_id,
2017
    bool is_requester);
2018
2019
#if LIBSPDM_EVENT_RECIPIENT_SUPPORT
2020
/**
2021
 * Check if the combination of DMTF EventTypeId and EventDetailLen is legal in a SEND_EVENT message.
2022
 *
2023
 * @param  event_type_id     Value of the DMTF EventTypeId.
2024
 * @param  event_detail_len  Size, in bytes, of EventDetail.
2025
 *
2026
 * @retval true  The EventTypeId and EventDetailLen are legal.
2027
 * @retval false The EventTypeId and EventDetailLen are illegal.
2028
 */
2029
bool libspdm_validate_dmtf_event_type(uint16_t event_type_id, uint16_t event_detail_len);
2030
2031
/**
2032
 * Given a list of events, finds the event identified by the target EventInstanceID.
2033
 *
2034
 * @param  events_list_start         Pointer to list of events.
2035
 * @param  event_count               Number of events in the list.
2036
 * @param  target_event_instance_id  EventInstanceID to be found.
2037
 *
2038
 * @retval  NULL     Could not find the EventInstanceID.
2039
 * @retval  non-NULL Pointer to the event corresponding to the target EventInstanceID
2040
 */
2041
const void *libspdm_find_event_instance_id(const void *events_list_start, uint32_t event_count,
2042
                                           uint32_t target_event_instance_id);
2043
/**
2044
 * Parses and sends an event to the Integrator. This function shall not be called if the Integrator
2045
 * has not registered an event handler via libspdm_register_event_callback.
2046
 *
2047
 * @param  context          A pointer to the SPDM context.
2048
 * @param  session_id       Secure session identifier.
2049
 * @param  event_data       A pointer to the event do be parsed and sent to Integrator.
2050
 * @param  next_event_data  On output, returns a pointer to the next event in event_data.
2051
 *
2052
 * @retval  true   The event was successfully parsed and sent to the Integrator.
2053
 * @retval  false  Unable to parse the event or the Integrator returned an error for the event.
2054
 */
2055
bool libspdm_parse_and_send_event(libspdm_context_t *context, uint32_t session_id,
2056
                                  const void *event_data, const void **next_event_data);
2057
#endif /* LIBSPDM_EVENT_RECIPIENT_SUPPORT */
2058
2059
/**
2060
 * Given a buffer that spans from ptr to end_ptr, check if ptr + increment is within the buffer.
2061
 *
2062
 * @retval true  There is enough space in the buffer.
2063
 * @retval false There is not enough space in the buffer.
2064
 */
2065
bool libspdm_check_for_space(const uint8_t *ptr, const uint8_t *end_ptr, size_t increment);
2066
2067
#endif /* SPDM_COMMON_LIB_INTERNAL_H */