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 different endians for signature verification on SPDM 1.0/1.1. … #2360

Merged
merged 2 commits into from
Sep 20, 2023

Conversation

richkong88
Copy link
Contributor

…Version 6. Incorporating all requests so far.

…Version 6

Signed-off-by: Kong, Richard <richard.kong@intel.com>
@steven-bellock steven-bellock added the enhancement New feature or request label Sep 17, 2023
@steven-bellock steven-bellock added this to the Q3 2023 milestone Sep 17, 2023
@@ -414,16 +439,26 @@ void libspdm_asym_free(uint32_t base_asym_algo, void *context);
* @param message_size Size of the message in bytes.
* @param signature Pointer to asymmetric signature to be verified.
* @param sig_size Size of signature in bytes.
* @param endian Endian to be tried. If both endians is selected,
Copy link
Contributor

Choose a reason for hiding this comment

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

both endians is -> both endians are

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Think I fixed it now.

void* context,
const uint8_t* message, size_t message_size,
const uint8_t* signature, size_t sig_size,
uint32_t *endian);
Copy link
Contributor

Choose a reason for hiding this comment

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

I liked how this parameter was called flags, since other information could be passed through. If it's just for endianness then change to uint8_t.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I liked flags too, but it seemed strange to me to have an in/out parameter as flags. I can change it back to flags. It's a little more work to isolate the endian value and modify only it as the out parameter too.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah ok. Since it's an output then using it just for endianness is fine. But it can be a uint8_t.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK.

@@ -688,6 +688,18 @@ libspdm_return_t libspdm_set_data(void *spdm_context, libspdm_data_type_t data_t
context->max_spdm_session_sequence_number = LIBSPDM_MAX_SPDM_SESSION_SEQUENCE_NUMBER;
}
break;
case LIBSPDM_DATA_SPDM_VERSION_10_11_VERIFY_SIGNATURE_ENDIAN:
if (data_size != sizeof(uint32_t)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

uint32_t -> int

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not understanding why this should be int. Should it not follow the flags (or endian) parameter in spdm_crypt_lib.h? (It's not an enum).

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah ok. There's a header issue then. For getting and setting the context LIBSPDM_SPDM_10_11_VERIFY_SIGNATURE_ENDIAN_* should be #defined in spdm_common_lib.h.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Still not understanding. This data member of the context will be used as the "endian" in/out parameter to the verify function described by the previous comment where you were requesting it change from uint32_t* to uin8_t*. It will have one of these values:

/* The Endian values apply only if the spdm version is 1.0/1.1.
 * The default verification mode is big endian only. */
#define LIBSPDM_SPDM_10_11_VERIFY_SIGNATURE_ENDIAN_BIG_ONLY        (0x0)
#define LIBSPDM_SPDM_10_11_VERIFY_SIGNATURE_ENDIAN_LITTLE_ONLY     (0x1)
#define LIBSPDM_SPDM_10_11_VERIFY_SIGNATURE_ENDIAN_BIG_OR_LITTLE   (0x2)

And the parameter type to the verify function will be uint8_t* as you requested in the previous comment.

So shouldn't think member in the context also be of type uint8_t?

Copy link
Contributor

Choose a reason for hiding this comment

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

So shouldn't think member in the context also be of type uint8_t?

Yes, but now the issue is that those #defines are currently in spdm_crypt_lib.h. They should be in spdm_common_lib.h.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok. Thanks.

dst[i] = dst[dst_size - i - 1];
dst[dst_size - i - 1] = byte;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

}
else {

->

} else {

Lots of other instances as well. I'll see if I can configure uncrustify to catch that.

Copy link
Member

Choose a reason for hiding this comment

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

@steven-bellock , I will file a new issue to catch format issue in uncrustify.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will do.

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.

Signed-off-by: Kong, Richard <richard.kong@intel.com>
@jyao1 jyao1 merged commit 7cd09f3 into DMTF:main Sep 20, 2023
90 checks passed
@jyao1
Copy link
Member

jyao1 commented Sep 25, 2023

Fix #2151

@richkong88 richkong88 deleted the rkong_endian_6 branch October 9, 2023 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants