Skip to content
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

Enable little-endian signing and dual-endian verification in SPDM 1.0… #2324

Closed
wants to merge 5 commits into from

Conversation

richkong88
Copy link
Contributor

@richkong88 richkong88 commented Aug 24, 2023

…\1.1

Fix: #2151

@jyao1
Copy link
Member

jyao1 commented Aug 25, 2023

@richkong88 , would you please squash the commit? There is no need to add patch for coding style fix.

@@ -383,4 +383,68 @@
#define LIBSPDM_CHECK_SPDM_CONTEXT 1
#endif

/* Enable Endianness for signatures on SPDM1.0 and SPDM1.1.
* Big-endian is default, but little-endian may need to be supported as well.
* See issue: https://github.com/DMTF/libspdm/issues/2151 */
Copy link
Member

Choose a reason for hiding this comment

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

I dont think we need this line.

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.

@richkong88
Copy link
Contributor Author

@richkong88 , would you please squash the commit? There is no need to add patch for coding style fix.

Yes, I'll put everything into a single CL, once all feedback is incorporated.

@jyao1
Copy link
Member

jyao1 commented Aug 25, 2023

I think we need to update req_asym version as well, such as libspdm_req_asym_sign, libspdm_req_asym_verify.

Also, can we have some unit test or CI to ensure there will be no regression?

{
#if LIBSPDM_SPDM_10_11_SIGN_LITTLE_ENDIAN_RSA_ECDSA
uint32_t swap_endian_rsa = 0;
uint32_t swap_endian_ecdsa = 0;
Copy link
Member

Choose a reason for hiding this comment

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

I think swap_endian_rsa and swap_endian_ecdsa should be a bool type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree.

static void libspdm_copy_signature_swap_endian(
uint8_t *endian_swapped_signature_buffer,
size_t endian_swapped_signature_buffer_size,
bool is_dual_buffer,
Copy link
Member

Choose a reason for hiding this comment

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

is_dual_buffer brings confusion to me, and it takes me sometime to understand what it really means.

Maybe just define two functions: libspdm_copy_signature_swap_endian_for_ecdsa() and libspdm_copy_signature_swap_endian_for_rsa() ?

Then those functions can be reused by libspdm_asym_signature_swap_endian_if_necessary().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree. I split into rsa and ecdsa versions and tried to make the code clearer.

@richkong88
Copy link
Contributor Author

I think we need to update req_asym version as well, such as libspdm_req_asym_sign, libspdm_req_asym_verify.

Also, can we have some unit test or CI to ensure there will be no regression?

Will update req_asym versions and add unit tests.

@steven-bellock
Copy link
Contributor

In general the macros should only be used if they impart a significant reduction in size. In this case they don't so I would like to see this set at runtime through libspdm_set_data. Also I don't think we need to differentiate between 1.0 and 1.1. Just lump them together. I can't imagine a Responder that would use LE for 1.0 and BE for 1.1.

@richkong88
Copy link
Contributor Author

In general the macros should only be used if they impart a significant reduction in size. In this case they don't so I would like to see this set at runtime through libspdm_set_data.

While I'm not generally opposed to a runtime decision, it seems that the libspdm_crypt_asym routines do not receive an "spdm_context" to extract the libspdm_set_data field? I think any "context" parameters are crypto contexts. So making it runtime would involve changing a lot of interfaces (to take another parameter to indicate the runtime choic) which I was trying to minimize. Please correct me if I'm misunderstanding this.

Also I don't think we need to differentiate between 1.0 and 1.1. Just lump them together. I can't imagine a Responder that would use LE for 1.0 and BE for 1.1.

I'm fine lumping 1.0 and 1.1 together. @jyao1 Jiewen, do you think lumping them together is ok?

@jyao1
Copy link
Member

jyao1 commented Aug 30, 2023

If we use runtime mechanism, we can combine 1.0 and 1.1 because the integrator can make final decision based upon version.

But if we want to keep MACRO, then I think we should separate them to allow the flexibility, because the text in 1.0 and 1.1 are different.

@richkong88 richkong88 marked this pull request as draft August 30, 2023 19:49
@richkong88
Copy link
Contributor Author

Going to try a runtime mechanism. Closing this pull request.

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

Successfully merging this pull request may close these issues.

question on RSA/ECDSA signature endianness in SPDM 1.0/1.1
3 participants