Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

CAPABILITIES: Add SupportedAlgorithms #2968

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ShitalJumbad
Copy link
Contributor

fix #2279

@ShitalJumbad ShitalJumbad force-pushed the fix-2279 branch 3 times, most recently from a061ee9 to c0d1cd5 Compare January 25, 2025 03:08
Copy link
Contributor

@steven-bellock steven-bellock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still need to figure out how this information is conveyed to the Integrator.

include/industry_standard/spdm.h Outdated Show resolved Hide resolved
include/internal/libspdm_common_lib.h Outdated Show resolved Hide resolved
@@ -251,6 +251,10 @@ static libspdm_return_t libspdm_try_get_capabilities(libspdm_context_t *spdm_con
}
spdm_request->header.request_response_code = SPDM_GET_CAPABILITIES;
spdm_request->header.param1 = 0;
if (spdm_request->header.spdm_version >= SPDM_MESSAGE_VERSION_13 &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The check for Requester's CHUNK_CAP should be a LIBSPDM_ASSERT done near the top of this function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

status = LIBSPDM_STATUS_INVALID_MSG_SIZE;
goto receive_done;
}
}
if (spdm_request->header.spdm_version >= SPDM_MESSAGE_VERSION_12) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to size checks there are some checks that can be performed based on the Responder's algorithms and capabilities. For example if Responder's KEY_EX_CAP is set then it needs DHE algorithms. See #2947 for more information.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the change, please let me know if it looks okay.

if (spdm_response->header.spdm_version >= SPDM_MESSAGE_VERSION_13 &&
(spdm_request->header.param1 & 0x01) &&
((spdm_request->flags &
SPDM_GET_CAPABILITIES_REQUEST_FLAGS_CHUNK_CAP) == 0)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both the Requester and Responder's CHUNK_CAP needs to be set for this to occur.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, they need to be checked.

include/internal/libspdm_common_lib.h Outdated Show resolved Hide resolved
*response_size = sizeof(spdm_capabilities_response_t);

spdm_response->supported_algorithms.param1 = spdm_context->local_context.algorithm.param1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to check if dhe_named_group, aead_cipher_suite, etc, is non-zero to populate this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

library/spdm_responder_lib/libspdm_rsp_capabilities.c Outdated Show resolved Hide resolved
@ShitalJumbad ShitalJumbad force-pushed the fix-2279 branch 10 times, most recently from 4b465cb to d8be4bf Compare February 13, 2025 00:59
fix DMTF#2279

Signed-off-by: Shital Jumbad <sjumbad@nvidia.com>
@@ -417,3 +466,23 @@ libspdm_return_t libspdm_get_capabilities(libspdm_context_t *spdm_context)

return status;
}

libspdm_return_t libspdm_get_supported_algorithms(void *spdm_context)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should go in libspdm_req_communications.c.

if (LIBSPDM_STATUS_IS_ERROR(status)) {
return status;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to check that the negotiated version is >= 1.3. If it isn't then there's no point in calling libspdm_get_capabilities.

{
libspdm_return_t status;
libspdm_context_t *context;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can add assert that at least one of the versions supported by the Requester is >= 1.3, and that the Requester supports CHUNK_CAP.

* @retval RETURN_SUCCESS The connection is initialized successfully.
* @retval RETURN_DEVICE_ERROR A device error occurs when communicates with the device.
**/
libspdm_return_t libspdm_get_supported_algorithms(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function needs to return the supported algorithms to the caller, presumably as a struct that looks a bit like spdm_supported_algorithms_block_t, but without the params and whatnot.

@@ -271,10 +271,98 @@ libspdm_return_t libspdm_get_response_capabilities(libspdm_context_t *spdm_conte
spdm_context->local_context.capability.max_spdm_msg_size;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a basic validation step, need to check that if negotiated version is >= 1.3 and Param1[0] is set then the Requester's CHUNK_CAP is also set.

@@ -271,10 +271,98 @@ libspdm_return_t libspdm_get_response_capabilities(libspdm_context_t *spdm_conte
spdm_context->local_context.capability.max_spdm_msg_size;
}

if (spdm_response->header.spdm_version >= SPDM_MESSAGE_VERSION_12) {
if (spdm_response->header.spdm_version >= SPDM_MESSAGE_VERSION_13 &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also conditional on both Requester and Responder supporting CHUNK_CAP.

spdm_response->supported_algorithms.mel_specification =
spdm_context->local_context.algorithm.mel_spec;

uint8_t index = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to declare this at line 277 before any statements. The libspdm codebase tries to be as C89-compatible as possible.

(spdm_negotiate_algorithms_common_struct_table_t*)(&spdm_response->supported_algorithms
+1);

if ((spdm_context->connection_info.capability.flags &
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the Responder side I don't think the capability checks are needed. If Integrator has a non-zero algorithm then just send it. libspdm_check_context can be used by the Integrator to check if they have configured things correctly.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[SPDM 1.3] CAPABILITIES: Add SupportedAlgorithms
3 participants