refactor(crypto): change order of parameters
What changed, and why it matters
This commit simply reorders the arguments of an internal function called dh() and updates every place that calls it. The actual math and security behavior are unchanged; it is a code cleanup with no security effect.
No security action needed; treat as a normal refactoring commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change refactors the static dh() helper in crypto/noise_xxpsk3.c so its parameter order becomes (private_key, public_key, output) instead of (output, private_key, public_key). All call sites are updated with the same argument values in the new order. The underlying curve25519_scalarmult invocation and all surrounding protocol logic remain identical.
Changed components
crypto/noise_xxpsk3.cInspect captured patch +15 / −15
diff --git a/crypto/noise_xxpsk3.c b/crypto/noise_xxpsk3.c
index 6a4effd8..fd188ed2 100644
--- a/crypto/noise_xxpsk3.c
+++ b/crypto/noise_xxpsk3.c
@@ -124,9 +124,9 @@ static void hkdf2(const uint8_t *chaining_key, size_t chaining_key_len,
memzero(buf, sizeof(buf));
}
-static void dh(uint8_t (*output)[NOISE_XXPSK3_DHLEN],
- const uint8_t (*private_key)[NOISE_XXPSK3_DHLEN],
- const uint8_t (*public_key)[NOISE_XXPSK3_DHLEN]) {
+static void dh(const uint8_t (*private_key)[NOISE_XXPSK3_DHLEN],
+ const uint8_t (*public_key)[NOISE_XXPSK3_DHLEN],
+ uint8_t (*output)[NOISE_XXPSK3_DHLEN]) {
curve25519_scalarmult(*output, *private_key, *public_key);
}
@@ -498,8 +498,8 @@ bool noise_xxpsk3_responder_create_response1(
(uint8_t (*)[NOISE_XXPSK3_DHLEN])response);
uint8_t input_key_material[NOISE_XXPSK3_DHLEN] = {0};
- dh(&input_key_material, &state->ephemeral_private,
- &state->remote_ephemeral_public);
+ dh(&state->ephemeral_private, &state->remote_ephemeral_public,
+ &input_key_material);
ss_mix_key(&state->symmetric_state, &input_key_material);
memzero(input_key_material, sizeof(input_key_material));
@@ -509,8 +509,8 @@ bool noise_xxpsk3_responder_create_response1(
goto cleanup;
}
- dh(&input_key_material, &state->static_private,
- &state->remote_ephemeral_public);
+ dh(&state->static_private, &state->remote_ephemeral_public,
+ &input_key_material);
ss_mix_key(&state->symmetric_state, &input_key_material);
memzero(input_key_material, sizeof(input_key_material));
@@ -562,8 +562,8 @@ bool noise_xxpsk3_responder_handle_request2(
state->has_remote_static_public = true;
uint8_t input_key_material[NOISE_XXPSK3_DHLEN] = {0};
- dh(&input_key_material, &state->ephemeral_private,
- &state->remote_static_public);
+ dh(&state->ephemeral_private, &state->remote_static_public,
+ &input_key_material);
ss_mix_key(&state->symmetric_state, &input_key_material);
memzero(input_key_material, sizeof(input_key_material));
@@ -711,8 +711,8 @@ bool noise_xxpsk3_initiator_handle_response1(noise_xxpsk3_initiator_t *intr,
ss_mix_key(&state->symmetric_state, &state->remote_ephemeral_public);
uint8_t input_key_material[NOISE_XXPSK3_DHLEN] = {0};
- dh(&input_key_material, &state->ephemeral_private,
- &state->remote_ephemeral_public);
+ dh(&state->ephemeral_private, &state->remote_ephemeral_public,
+ &input_key_material);
ss_mix_key(&state->symmetric_state, &input_key_material);
memzero(input_key_material, sizeof(input_key_material));
@@ -724,8 +724,8 @@ bool noise_xxpsk3_initiator_handle_response1(noise_xxpsk3_initiator_t *intr,
}
state->has_remote_static_public = true;
- dh(&input_key_material, &state->ephemeral_private,
- &state->remote_static_public);
+ dh(&state->ephemeral_private, &state->remote_static_public,
+ &input_key_material);
ss_mix_key(&state->symmetric_state, &input_key_material);
memzero(input_key_material, sizeof(input_key_material));
@@ -783,8 +783,8 @@ bool noise_xxpsk3_initiator_create_request2(
}
uint8_t input_key_material[NOISE_XXPSK3_DHLEN] = {0};
- dh(&input_key_material, &state->static_private,
- &state->remote_ephemeral_public);
+ dh(&state->static_private, &state->remote_ephemeral_public,
+ &input_key_material);
ss_mix_key(&state->symmetric_state, &input_key_material);
memzero(input_key_material, sizeof(input_key_material));
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.