Skip to content

Commit d455a53

Browse files
Encapsulate SEND_EVENT for Requester as recipient
Signed-off-by: Steven Bellock <sbellock@nvidia.com>
1 parent 18a2654 commit d455a53

15 files changed

+1397
-8
lines changed

include/industry_standard/spdm.h

+41-2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
/* SPDM response code (1.3) */
5858
#define SPDM_SUPPORTED_EVENT_TYPES 0x62
5959
#define SPDM_SUBSCRIBE_EVENT_TYPES_ACK 0x70
60+
#define SPDM_EVENT_ACK 0x71
6061
#define SPDM_MEASUREMENT_EXTENSION_LOG 0x6F
6162
#define SPDM_KEY_PAIR_INFO 0x7C
6263
#define SPDM_SET_KEY_PAIR_INFO_ACK 0x7D
@@ -92,6 +93,7 @@
9293
/* SPDM request code (1.3) */
9394
#define SPDM_GET_SUPPORTED_EVENT_TYPES 0xE2
9495
#define SPDM_SUBSCRIBE_EVENT_TYPES 0xF0
96+
#define SPDM_SEND_EVENT 0xF1
9597
#define SPDM_GET_MEASUREMENT_EXTENSION_LOG 0xEF
9698
#define SPDM_GET_KEY_PAIR_INFO 0xFC
9799
#define SPDM_SET_KEY_PAIR_INFO 0xFD
@@ -1305,6 +1307,20 @@ typedef struct {
13051307
* param2 == RSVD */
13061308
} spdm_subscribe_event_types_ack_response_t;
13071309

1310+
typedef struct {
1311+
spdm_message_header_t header;
1312+
/* param1 == RSVD
1313+
* param2 == RSVD */
1314+
uint32_t event_count;
1315+
/* event_list[event_count]*/
1316+
} spdm_send_event_request_t;
1317+
1318+
typedef struct {
1319+
spdm_message_header_t header;
1320+
/* param1 == RSVD
1321+
* param2 == RSVD */
1322+
} spdm_event_ack_response_t;
1323+
13081324
/* SPDM GET_MEASUREMENT_EXTENSION_LOG request */
13091325
typedef struct {
13101326
spdm_message_header_t header;
@@ -1415,8 +1431,6 @@ typedef struct {
14151431
* param2 == RSVD*/
14161432
} spdm_set_key_pair_info_ack_response_t;
14171433

1418-
#pragma pack()
1419-
14201434
#define SPDM_VERSION_1_1_BIN_CONCAT_LABEL "spdm1.1 "
14211435
#define SPDM_VERSION_1_2_BIN_CONCAT_LABEL "spdm1.2 "
14221436
#define SPDM_VERSION_1_3_BIN_CONCAT_LABEL "spdm1.3 "
@@ -1468,9 +1482,34 @@ typedef struct {
14681482
#define SPDM_DMTF_EVENT_TYPE_MEASUREMENT_PRE_UPDATE 3
14691483
#define SPDM_DMTF_EVENT_TYPE_CERTIFICATE_CHANGED 4
14701484

1485+
/* DMTF Event sizes in bytes. */
1486+
#define SPDM_DMTF_EVENT_TYPE_EVENT_LOST_SIZE 8
1487+
#define SPDM_DMTF_EVENT_TYPE_MEASUREMENT_CHANGED_SIZE 32
1488+
#define SPDM_DMTF_EVENT_TYPE_MEASUREMENT_PRE_UPDATE_SIZE 32
1489+
#define SPDM_DMTF_EVENT_TYPE_CERTIFICATE_CHANGED_SIZE 1
1490+
1491+
typedef struct {
1492+
uint32_t last_acked_event_inst_id;
1493+
uint32_t last_lost_event_inst_id;
1494+
} spdm_dmtf_event_type_event_lost_t;
1495+
1496+
typedef struct {
1497+
uint8_t changed_measurements[SPDM_DMTF_EVENT_TYPE_MEASUREMENT_CHANGED_SIZE];
1498+
} spdm_dmtf_event_type_measurement_changed_t;
1499+
1500+
typedef struct {
1501+
uint8_t pre_update_measurement_changes[SPDM_DMTF_EVENT_TYPE_MEASUREMENT_PRE_UPDATE_SIZE];
1502+
} spdm_dmtf_event_type_measurement_pre_update_t;
1503+
1504+
typedef struct {
1505+
uint8_t certificate_changed;
1506+
} spdm_dmtf_event_type_certificate_changed_t;
1507+
14711508
/*SPDM SET_KEY_PAIR_INFO operation*/
14721509
#define SPDM_SET_KEY_PAIR_INFO_CHANGE_OPERATION 0
14731510
#define SPDM_SET_KEY_PAIR_INFO_ERASE_OPERATION 1
14741511
#define SPDM_SET_KEY_PAIR_INFO_GENERATE_OPERATION 2
14751512

1513+
#pragma pack()
1514+
14761515
#endif /* SPDM_H */

include/internal/libspdm_common_lib.h

+15
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,10 @@ typedef struct {
623623
libspdm_vendor_response_callback_func vendor_response_callback;
624624
libspdm_vendor_get_id_callback_func vendor_response_get_id;
625625
#endif /* LIBSPDM_ENABLE_VENDOR_DEFINED_MESSAGES */
626+
627+
#if LIBSPDM_EVENT_RECIPIENT_SUPPORT
628+
libspdm_process_event_func process_event;
629+
#endif /* LIBSPDM_EVENT_RECIPIENT_SUPPORT */
626630
} libspdm_context_t;
627631

628632
#define LIBSPDM_CONTEXT_SIZE_WITHOUT_SECURED_CONTEXT (sizeof(libspdm_context_t))
@@ -1780,4 +1784,15 @@ uint8_t libspdm_mask_mel_specification(libspdm_context_t *spdm_context, uint8_t
17801784
*/
17811785
uint32_t libspdm_mask_base_asym_algo(libspdm_context_t *spdm_context, uint32_t base_asym_algo);
17821786

1787+
/**
1788+
* Check if the combination of SVH ID and VendorIDLen are legal.
1789+
*
1790+
* @param id Registry or standards body identifier (SPDM_REGISTRY_ID_*).
1791+
* @param vendor_id_len Length, in bytes, of the VendorID field.
1792+
*
1793+
* @retval true The ID and VendorIDLen are legal.
1794+
* @retval false The ID and VendorIDLen are illegal.
1795+
*/
1796+
bool libspdm_validate_svh_vendor_id_len(uint8_t id, uint8_t vendor_id_len);
1797+
17831798
#endif /* SPDM_COMMON_LIB_INTERNAL_H */

include/internal/libspdm_requester_lib.h

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Copyright Notice:
3-
* Copyright 2021-2024 DMTF. All rights reserved.
3+
* Copyright 2021-2025 DMTF. All rights reserved.
44
* License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
55
**/
66

@@ -473,6 +473,14 @@ libspdm_return_t libspdm_get_encap_response_key_update(void *spdm_context,
473473
void *request,
474474
size_t *response_size,
475475
void *response);
476+
477+
#if LIBSPDM_EVENT_RECIPIENT_SUPPORT
478+
libspdm_return_t libspdm_get_encap_response_event_ack(void *spdm_context,
479+
size_t request_size,
480+
void *request,
481+
size_t *response_size,
482+
void *response);
483+
#endif /* LIBSPDM_EVENT_RECIPIENT_SUPPORT */
476484
#endif /* LIBSPDM_ENABLE_CAPABILITY_ENCAP_CAP */
477485

478486
/**

include/library/spdm_common_lib.h

+42
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,48 @@ typedef libspdm_return_t (*libspdm_vendor_response_callback_func)(
10051005

10061006
#endif /* LIBSPDM_ENABLE_VENDOR_DEFINED_MESSAGES */
10071007

1008+
#if LIBSPDM_EVENT_RECIPIENT_SUPPORT
1009+
/**
1010+
* SPDM Event callback function.
1011+
*
1012+
* When an event is received the library performs basic validation to ensure that SVH ID and SVH
1013+
* VendorIDLen are legal. If the event is of a DMTF event type then the library will ensure that
1014+
* EventTypeId and EventDetailLen are legal. If a SEND_EVENT message contains multiple events then
1015+
* the library will call this function with sequentially-increasing Event Instance ID.
1016+
*
1017+
* @param spdm_context A pointer to the SPDM context.
1018+
* @param session_id Secure session ID.
1019+
* @param event_instance_id Counter that increases by one for each event.
1020+
* @param svh_id Registry or standards body identifier (SPDM_REGISTRY_ID_*).
1021+
* @param svh_vendor_id_len Length, in bytes, of the svh_vendor_id field.
1022+
* @param svh_vendor_id Vendor ID assigned by the Registry or Standards Body. If the value of
1023+
* svh_vendor_id_len is 0 then this is NULL.
1024+
* @param event_type_id Event type identifier. If svh_id is SPDM_REGISTRY_ID_ DMTF then this is
1025+
* one of the SPDM_DMTF_EVENT_TYPE_* macros.
1026+
* @param event_detail_len Size, in bytes, of event_detail.
1027+
* @param event_detail Details of the event.
1028+
**/
1029+
typedef libspdm_return_t (*libspdm_process_event_func)(void *spdm_context,
1030+
uint32_t session_id,
1031+
uint32_t event_instance_id,
1032+
uint8_t svh_id,
1033+
uint8_t svh_vendor_id_len,
1034+
void *svh_vendor_id,
1035+
uint16_t event_type_id,
1036+
uint16_t event_detail_len,
1037+
void *event_detail);
1038+
1039+
/**
1040+
* Register callback to process SPDM events.
1041+
*
1042+
* @param spdm_context A pointer to the SPDM context.
1043+
* @param process_event_func Function that processes individual SPDM events. If NULL then function
1044+
* will not be called as events are processed.
1045+
**/
1046+
void libspdm_register_event_callback(void *spdm_context,
1047+
libspdm_process_event_func process_event_func);
1048+
#endif /* LIBSPDM_EVENT_RECIPIENT_SUPPORT */
1049+
10081050
#ifdef __cplusplus
10091051
}
10101052
#endif

library/spdm_common_lib/libspdm_com_context_data.c

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Copyright Notice:
3-
* Copyright 2021-2024 DMTF. All rights reserved.
3+
* Copyright 2021-2025 DMTF. All rights reserved.
44
* License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
55
**/
66

@@ -3278,3 +3278,14 @@ bool libspdm_negotiate_connection_version(spdm_version_number_t *common_version,
32783278
}
32793279
return false;
32803280
}
3281+
3282+
#if LIBSPDM_EVENT_RECIPIENT_SUPPORT
3283+
void libspdm_register_event_callback(void *context,
3284+
libspdm_process_event_func process_event_func)
3285+
{
3286+
libspdm_context_t *spdm_context;
3287+
3288+
spdm_context = context;
3289+
spdm_context->process_event = process_event_func;
3290+
}
3291+
#endif /* LIBSPDM_EVENT_RECIPIENT_SUPPORT */

library/spdm_common_lib/libspdm_com_support.c

+23
Original file line numberDiff line numberDiff line change
@@ -457,3 +457,26 @@ uint16_t libspdm_mask_alg_supported(libspdm_context_t *spdm_context, uint8_t alg
457457
return 0;
458458
}
459459
}
460+
461+
bool libspdm_validate_svh_vendor_id_len(uint8_t id, uint8_t vendor_id_len)
462+
{
463+
switch (id) {
464+
case SPDM_REGISTRY_ID_DMTF:
465+
case SPDM_REGISTRY_ID_VESA:
466+
return (vendor_id_len == 0);
467+
case SPDM_REGISTRY_ID_TCG:
468+
case SPDM_REGISTRY_ID_USB:
469+
case SPDM_REGISTRY_ID_PCISIG:
470+
case SPDM_REGISTRY_ID_MIPI:
471+
case SPDM_REGISTRY_ID_CXL:
472+
case SPDM_REGISTRY_ID_JEDEC:
473+
return ((vendor_id_len == 0) || (vendor_id_len == 2));
474+
case SPDM_REGISTRY_ID_IANA:
475+
case SPDM_REGISTRY_ID_HDBASET:
476+
return ((vendor_id_len == 0) || (vendor_id_len == 4));
477+
case SPDM_REGISTRY_ID_IANA_CBOR:
478+
return true;
479+
default:
480+
return false;
481+
}
482+
}

library/spdm_requester_lib/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ target_sources(spdm_requester_lib
1717
libspdm_req_encap_digests.c
1818
libspdm_req_encap_error.c
1919
libspdm_req_encap_key_update.c
20+
libspdm_req_encap_event_ack.c
2021
libspdm_req_encap_request.c
2122
libspdm_req_end_session.c
2223
libspdm_req_finish.c

0 commit comments

Comments
 (0)