Skip to content

crypto: Optimize the hmac#25686

Merged
spytheman merged 3 commits into
vlang:masterfrom
CryingN:master
Nov 8, 2025
Merged

crypto: Optimize the hmac#25686
spytheman merged 3 commits into
vlang:masterfrom
CryingN:master

Conversation

@CryingN

@CryingN CryingN commented Nov 7, 2025

Copy link
Copy Markdown
Contributor

Without altering the operational logic of HMAC, the computation speed has been optimized, and the block division range has been expanded. A 500,000-cycle test was conducted to compare the time taken by the user for the old HMAC and the new HMAC, as shown below:

Type Old HMAC New HMAC
hmac-sha128-64 3.623s 2.255s
hmac-sha256-64 7.587s 6.257s
hmac-sha512-128 11.088s 8.294s

The new HMAC function supports calculations with a blocksize > 256. Using the old HMAC would cause a V panic (although now, the significance of crypto is minor).

@tankf33der

Copy link
Copy Markdown
Contributor

My own tests against sha512 passed.

@spytheman spytheman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @CryingN .
Thank you @tankf33der .

@spytheman spytheman merged commit fdf28bb into vlang:master Nov 8, 2025
73 checks passed
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.

4 participants