Skip to content

SERVER-122356 Fix HMAC_Init_ex when reusing key context#1636

Open
cuiweixie wants to merge 1 commit intomongodb:masterfrom
cuiweixie:fix/hmac-reuse-key-init
Open

SERVER-122356 Fix HMAC_Init_ex when reusing key context#1636
cuiweixie wants to merge 1 commit intomongodb:masterfrom
cuiweixie:fix/hmac-reuse-key-init

Conversation

@cuiweixie
Copy link

When reuse key is enabled and the context has already been used, the code intended to call HMAC_Init_ex with a null key to reuse the existing key. An unconditional second HMAC_Init_ex call always re-passed the key, overwriting that path.

Use an else branch so only one initialization runs, matching the reuse semantics and aligning with similar crypto context lifecycle fixes (e.g. SERVER-119317 for MD5 hash state).

Anything in this description will be included in the commit message. Replace or delete this text before merging. Add links to testing in the comments of the PR.

When reuse key is enabled and the context has already been used, the code intended to call HMAC_Init_ex with a null key to reuse the existing key. An unconditional second HMAC_Init_ex call always re-passed the key, overwriting that path.

Use an else branch so only one initialization runs, matching the reuse semantics and aligning with similar crypto context lifecycle fixes (e.g. SERVER-119317 for MD5 hash state).
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