[refactor][api] simplify stse_get_ecc_key_type_from_curve_id() signature#101
Open
parmi93 wants to merge 2 commits into
Open
[refactor][api] simplify stse_get_ecc_key_type_from_curve_id() signature#101parmi93 wants to merge 2 commits into
stse_get_ecc_key_type_from_curve_id() signature#101parmi93 wants to merge 2 commits into
Conversation
stse_get_ecc_key_type_from_curve_id signature
stse_get_ecc_key_type_from_curve_id signaturestse_get_ecc_key_type_from_curve_id() signature
7deaab7 to
533f561
Compare
Return the key type directly and accept a single packed stsafea_ecc_curve_id_t argument instead of separate length/value pointers and an output parameter.
Remove the STSE_CONF_ECC_* conditional-compilation guards around the stse_get_ecc_key_type_from_curve_id declaration and definition. The function is now always compiled and exposed regardless of which ECC curves are enabled in the configuration.
e94bdf8 to
f481a1f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Reworks
stse_get_ecc_key_type_from_curve_id():stse_ecc_key_type_tdirectly (orSTSE_ECC_KT_INVALIDif the curve is unknown) and takes a single packedstsafea_ecc_curve_id_tpointer, instead of the previous three parameters (PLAT_UI8 curve_id_length,const PLAT_UI8 *pCurve_id_value,stse_ecc_key_type_t *pKey_type output).#if defined(STSE_CONF_ECC_*)conditional-compilation blocks around the declaration and definition are dropped; the function is now always available.Why this change
The curve identifier returned by
stse_get_ecc_key_slot_info(), thecurve_idfield ofstsafea_private_key_slot_information_t, is already astsafea_ecc_curve_id_t. With the old signature the caller had to manually unpack it into a scalar length (length is a 2-byte array) and a value pointer before resolving the key type. The new signature lets that output be passed straight through:A clearer, less error-prone contract.
The function never had a real failure path, it always returned
STSE_OKand signalled "not found" through*pKey_type == STSE_ECC_KT_INVALID. Returning the key type directly makes that the single, obvious result value and removes the redundant output pointer and return-code plumbing. The[static 1]array parameter also documents (and, on supporting compilers, enforces) that a non-null pointer is required.Removing the config guards.
Guarding the symbol behind
STSE_CONF_ECC_*made its availability depend on which curves happen to be enabled, so any generic caller had to replicate the same long#if defined(...)condition to avoid link errors. Since the function only readsstse_ecc_info_tableand safely returnsSTSE_ECC_KT_INVALIDwhen no curve matches, there is no reason to compile it out. Exposing it unconditionally gives callers a stable API surface.Notes
memcmpover the packed struct is safe becausestsafea_ecc_curve_id_tis aPLAT_PACKED_STRUCT(no padding betweenlengthandvalue); this is now documented with an inline comment.CHANGELOG.mdupdated to match the new signature.