Skip to content

Feature/1.2.0/vla removal - #131

Draft
Grom- wants to merge 6 commits into
dev/1.2.0from
feature/1.2.0/vla_removal
Draft

Grom- wants to merge 6 commits into
dev/1.2.0from
feature/1.2.0/vla_removal

Conversation

@Grom-

@Grom- Grom- commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

This pull request makes significant improvements to buffer safety, portability, and maintainability across the STSE middleware codebase. The main theme is replacing variable-length stack allocations with fixed-size buffers, using new constants for maximum sizes, and adding additional input validation. This enhances code safety, prevents potential stack overflows, and makes the code more portable across different compilers.

The most important changes are:

Buffer Safety and Consistency

  • Replaced variable-length arrays (VLAs) with fixed-size buffers using new maximum-size constants (e.g., STSE_ECC_MAX_PUB_KEY_SIZE, STSE_ECC_MAX_SIGNATURE_SIZE, STSE_MAX_TBS_SIZE, etc.) throughout the codebase, especially in cryptographic and key management functions. This improves stack safety and portability.

  • Added input validation to ensure buffer sizes do not exceed defined maximums, returning an error if limits are exceeded (e.g., for certificates and key slots).

New and Updated Definitions

  • Introduced new buffer size and ECC-related constants in stse_generic_typedef.h (e.g., STSE_ECC_MAX_COORD_LEN, STSE_ECC_MAX_PUB_KEY_SIZE, STSE_ECC_MAX_SIGNATURE_SIZE, STSE_MAX_HOST_KEYS_ENVELOPE_SIZE, STSE_MAX_KEK_ENVELOPE_SIZE, STSE_MAX_TBS_SIZE, STSE_MAX_HKDF_INFO_SIZE, STSE_MAX_OKM_BUFFER_SIZE) for consistent use across the codebase. Also added the STSE_NOINLINE macro for better cross-compiler support.

  • Defined STSE_DEVICE_MAX_CERTIFICATE_SIZE in stse_device_authentication.h to standardize certificate buffer sizes.

Other Improvements

  • Ensured all cryptographic operations use the largest possible buffer size for the relevant algorithm (e.g., always using STSAFEA_SHA_512_HASH_SIZE for digests) to avoid buffer overflows and simplify code paths.

These changes collectively improve the robustness, maintainability, and portability of the code.

@Grom-
Grom- added this pull request to stack #132 November 6, 2026 11:37
Base automatically changed from feature/code_cleanup_harmonization to dev/1.2.0 November 12, 2026 16:15
@Grom-
Grom- force-pushed the feature/1.2.0/vla_removal branch from a65952b to 2d35993 Compare November 12, 2026 16:15
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.

1 participant