-
Notifications
You must be signed in to change notification settings - Fork 123
CAPABILITIES: Add SupportedAlgorithms #2968
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -164,8 +164,41 @@ typedef struct { | |
uint32_t max_spdm_msg_size; | ||
} spdm_get_capabilities_request_t; | ||
|
||
/* SPDM GET_CAPABILITIES response*/ | ||
/* SPDM extended algorithm */ | ||
typedef struct { | ||
uint8_t registry_id; | ||
uint8_t reserved; | ||
uint16_t algorithm_id; | ||
} spdm_extended_algorithm_t; | ||
|
||
typedef struct { | ||
uint8_t alg_type; | ||
uint8_t alg_count; | ||
uint16_t alg_supported; | ||
} spdm_negotiate_algorithms_common_struct_table_t; | ||
|
||
/* SPDM supported algorithms block */ | ||
typedef struct { | ||
uint8_t param1; /* Number of Algorithms Structure Tables */ | ||
uint8_t param2; /* Reserved */ | ||
uint16_t length; | ||
uint8_t measurement_specification; | ||
uint8_t other_params_support; | ||
uint32_t base_asym_algo; | ||
uint32_t base_hash_algo; | ||
uint8_t reserved2[12]; | ||
uint8_t ext_asym_count; | ||
uint8_t ext_hash_count; | ||
uint8_t reserved3; | ||
uint8_t mel_specification; | ||
/* Followed by dynamic arrays for ext_asym, ext_hash, and struct_tableif needed | ||
* spdm_extended_algorithm_t ext_asym[ext_asym_count]; | ||
* spdm_extended_algorithm_t ext_hash[ext_hash_count]; | ||
* spdm_negotiate_algorithms_common_struct_table_t struct_table[ | ||
* SPDM_NEGOTIATE_ALGORITHMS_MAX_NUM_STRUCT_TABLE_ALG];*/ | ||
} spdm_supported_algorithms_block_t; | ||
|
||
/* SPDM GET_CAPABILITIES response*/ | ||
typedef struct { | ||
spdm_message_header_t header; | ||
/* param1 == RSVD | ||
|
@@ -177,6 +210,8 @@ typedef struct { | |
/* Below field is added in 1.2.*/ | ||
uint32_t data_transfer_size; | ||
uint32_t max_spdm_msg_size; | ||
/* Below field is added in 1.3.*/ | ||
spdm_supported_algorithms_block_t supported_algorithms; | ||
steven-bellock marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I gave feedback before to remove You can comment this line here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for your feedback and for referencing the earlier discussion.t - cbda82c#r2151455599 To summarize, I understand the concern about including spdm_supported_algorithms_block_t in spdm_capabilities_response_t, especially since it’s a variable-length structure and may be considered a special case. However, I added it here because, based on my reading of the SPDM 1.3 specification, it seems that spdm_supported_algorithms_block_t was introduced specifically for version 1.3, and including it in the structure aligns with the spec for that version. That said, I may be wrong, so I’m just trying to understand how we make this decision. I’m also looping in @steven-bellock to get his perspective. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, I don't there is any requirement to add anything defined in the spec. I prefer to not include it for convenience. |
||
} spdm_capabilities_response_t; | ||
|
||
#define SPDM_MIN_DATA_TRANSFER_SIZE_VERSION_12 42 | ||
|
@@ -360,12 +395,6 @@ typedef struct { | |
#define SPDM_NEGOTIATE_ALGORITHMS_ALG_SUPPORTED_AEAD_12_MASK 0x000f | ||
#define SPDM_NEGOTIATE_ALGORITHMS_ALG_SUPPORTED_REQ_BASE_ASYM_ALG_12_MASK 0x0fff | ||
|
||
typedef struct { | ||
uint8_t alg_type; | ||
uint8_t alg_count; | ||
uint16_t alg_supported; | ||
} spdm_negotiate_algorithms_common_struct_table_t; | ||
|
||
|
||
/* SPDM NEGOTIATE_ALGORITHMS request base_asym_algo/REQ_BASE_ASYM_ALG */ | ||
#define SPDM_ALGORITHMS_BASE_ASYM_ALGO_TPM_ALG_RSASSA_2048 0x00000001 | ||
|
@@ -484,13 +513,6 @@ typedef struct { | |
/*opaque_element_table_t opaque_list[];*/ | ||
} spdm_general_opaque_data_table_header_t; | ||
|
||
/* SPDM extended algorithm */ | ||
typedef struct { | ||
uint8_t registry_id; | ||
uint8_t reserved; | ||
uint16_t algorithm_id; | ||
} spdm_extended_algorithm_t; | ||
|
||
/* SPDM registry_id */ | ||
#define SPDM_REGISTRY_ID_DMTF 0x0 | ||
#define SPDM_REGISTRY_ID_TCG 0x1 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,10 +129,35 @@ libspdm_return_t libspdm_get_version(libspdm_context_t *spdm_context, | |
uint8_t *version_number_entry_count, | ||
spdm_version_number_t *version_number_entry); | ||
|
||
#define LIBSPDM_MAX_EXT_ALG_COUNT 5 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. libspdm does not support ext_alg. I think we can ignore them totally. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #2968 (comment). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, I don't suggest to keep the complexity. As we already said, libspdm does not support ext_alg. |
||
|
||
#pragma pack(1) | ||
typedef struct { | ||
spdm_negotiate_algorithms_common_struct_table_t alg_struct; | ||
spdm_extended_algorithm_t alg_external[LIBSPDM_MAX_EXT_ALG_COUNT]; | ||
} libspdm_supported_algorithms_alg_struct_t; | ||
#pragma pack() | ||
|
||
typedef struct { | ||
uint8_t spdm_version; | ||
uint8_t measurement_specification; | ||
ShitalJumbad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
uint8_t other_params_support; | ||
uint32_t base_asym_algo; | ||
uint32_t base_hash_algo; | ||
uint8_t mel_specification; | ||
uint8_t ext_asym_count; | ||
spdm_extended_algorithm_t ext_asym[LIBSPDM_MAX_EXT_ALG_COUNT]; | ||
uint8_t ext_hash_count; | ||
spdm_extended_algorithm_t ext_hash[LIBSPDM_MAX_EXT_ALG_COUNT]; | ||
uint8_t struct_table_count; | ||
libspdm_supported_algorithms_alg_struct_t | ||
struct_table[LIBSPDM_MAX_EXT_ALG_COUNT]; | ||
} libspdm_responder_supported_algorithms_13_t; | ||
|
||
/** | ||
* This function sends GET_CAPABILITIES and receives CAPABILITIES. | ||
* | ||
* @param spdm_context A pointer to the SPDM context. | ||
* @param spdm_context A pointer to the SPDM context. | ||
* @param RequesterCTExponent RequesterCTExponent to the GET_CAPABILITIES request. | ||
* @param RequesterFlags RequesterFlags to the GET_CAPABILITIES request. | ||
* @param ResponderCTExponent ResponderCTExponent from the CAPABILITIES response. | ||
|
@@ -143,6 +168,26 @@ libspdm_return_t libspdm_get_version(libspdm_context_t *spdm_context, | |
**/ | ||
libspdm_return_t libspdm_get_capabilities(libspdm_context_t *spdm_context); | ||
|
||
/** | ||
* This function sends GET_CAPABILITIES and receives CAPABILITIES. | ||
* | ||
* @param spdm_context A pointer to the SPDM context. | ||
* @param get_supported_algorithms If true, indicates that the requester wants the responder to include its supported algorithms in the CAPABILITIES response. | ||
* @param supported_algs_length On input, the size of the supported_algs buffer. | ||
* @param supported_algs A pointer to a buffer to store the supported algorithms. | ||
* @param RequesterCTExponent RequesterCTExponent to the GET_CAPABILITIES request. | ||
* @param RequesterFlags RequesterFlags to the GET_CAPABILITIES request. | ||
* @param ResponderCTExponent ResponderCTExponent from the CAPABILITIES response. | ||
* @param ResponderFlags ResponderFlags from the CAPABILITIES response. | ||
* | ||
* @retval RETURN_SUCCESS The GET_CAPABILITIES is sent and the CAPABILITIES is received. | ||
* @retval RETURN_DEVICE_ERROR A device error occurs when communicates with the device. | ||
**/ | ||
libspdm_return_t libspdm_get_capabilities_with_supported_algs(libspdm_context_t *spdm_context, | ||
bool get_supported_algorithms, | ||
size_t *supported_algs_length, | ||
void *supported_algs); | ||
|
||
/** | ||
* This function sends NEGOTIATE_ALGORITHMS and receives ALGORITHMS. | ||
* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -525,6 +525,33 @@ libspdm_return_t libspdm_start_session(void *spdm_context, bool use_psk, | |
uint8_t *heartbeat_period, | ||
void *measurement_hash); | ||
|
||
/** | ||
* This function retrieves the supported algorithms from the responder. | ||
* It sends the GET_VERSION and GET_CAPABILITIES requests, where GET_CAPABILITIES.Param1[0] is set. | ||
* If the Responder supports this extended capability, the Responder will include the Supported | ||
* Algorithms Block in its CAPABILITIES response. | ||
* | ||
* @param spdm_context A pointer to the SPDM context. | ||
* @param responder_supported_algorithms_length On input, indicates the size in bytes of the provided buffer. | ||
* The buffer must be at least sizeof(libspdm_responder_supported_algorithms_13_t) bytes. | ||
* On output, the size in bytes of the supported algorithms data. | ||
* @param responder_supported_algorithms_buffer A pointer to a destination buffer to store the supported algorithms. | ||
* Must not be NULL. The buffer must be large enough to hold the supported algorithms data. | ||
* @param spdm_version A pointer to store the SPDM version used for the request. | ||
* | ||
* @retval RETURN_SUCCESS The supported algorithms were successfully retrieved. | ||
* @retval RETURN_DEVICE_ERROR A device error occurs when communicates with the device. | ||
* @retval RETURN_UNSUPPORTED The operation is not supported by the device. | ||
* @retval RETURN_SECURITY_VIOLATION Any verification fails. | ||
* | ||
* @note The buffer must be at least sizeof(libspdm_responder_supported_algorithms_13_t) bytes. | ||
* The function will assert if responder_supported_algorithms_buffer is NULL. | ||
*/ | ||
libspdm_return_t libspdm_get_supported_algorithms(void *spdm_context, | ||
size_t *responder_supported_algorithms_length, | ||
void *responder_supported_algorithms_buffer, | ||
uint8_t *spdm_version); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you include There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The Integrator still needs to know what There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the suggestion! I think having the spdm_version parameter improves the convenience and usability of the API. Let me know if you have a strong preference here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we can guarantee that Or we can define following
I really cannot see the need to have |
||
|
||
/** | ||
* This function sends KEY_EXCHANGE/FINISH or PSK_EXCHANGE/PSK_FINISH to start an SPDM Session. | ||
* | ||
|
Uh oh!
There was an error while loading. Please reload this page.