What changed, and why it matters
This commit is a simple internal code cleanup: it extracts a small piece of repeated HMAC logic into a private helper function. The public behavior of the firmware does not change, and no security bug is fixed or introduced.
No security action required; treat as routine code maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change refactors optiga_kdf_external() in src/optiga/optiga.c by introducing a static helper _kdf_hmac() that takes an optiga_oid parameter. The existing optiga_kdf_external() now calls _kdf_hmac(OID_HMAC, …), preserving identical behavior. No callers, return values, cryptographic parameters, or access controls are modified. This is a pure refactoring commit.
Changed components
src/optiga/optiga.cInspect captured patch +7 / −2
diff --git a/src/optiga/optiga.c b/src/optiga/optiga.c
index d8f1389..09af726 100644
--- a/src/optiga/optiga.c
+++ b/src/optiga/optiga.c
@@ -1484,7 +1484,7 @@ int optiga_setup(const securechip_interface_functions_t* ifs)
return 0;
}
-int optiga_kdf_external(const uint8_t* msg, size_t len, uint8_t* mac_out)
+static int _kdf_hmac(uint16_t optiga_oid, const uint8_t* msg, size_t len, uint8_t* mac_out)
{
if (len != 32) {
return SC_ERR_INVALID_ARGS;
@@ -1496,7 +1496,7 @@ int optiga_kdf_external(const uint8_t* msg, size_t len, uint8_t* mac_out)
uint32_t mac_out_len = 32;
res = optiga_ops_crypt_hmac_sync(
- _crypt, OPTIGA_HMAC_SHA_256, OID_HMAC, msg, len, mac_out, &mac_out_len);
+ _crypt, OPTIGA_HMAC_SHA_256, optiga_oid, msg, len, mac_out, &mac_out_len);
if (res != OPTIGA_LIB_SUCCESS) {
util_log("kdf fail err=%x", res);
return res;
@@ -1508,6 +1508,11 @@ int optiga_kdf_external(const uint8_t* msg, size_t len, uint8_t* mac_out)
return 0;
}
+int optiga_kdf_external(const uint8_t* msg, size_t len, uint8_t* mac_out)
+{
+ return _kdf_hmac(OID_HMAC, msg, len, mac_out);
+}
+
static int _kdf_internal(const uint8_t* msg, size_t len, uint8_t* kdf_out)
{
if (len != 32) {
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.