Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redefine ExpandHKDF as a one shot function #73

Merged
merged 1 commit into from
Nov 22, 2024
Merged

Conversation

qmuntal
Copy link
Member

@qmuntal qmuntal commented Nov 20, 2024

Go 1.24 will most probably move the golang.org/x/crypto/hkdf package into the standard library: golang/go#61477. The new API will be a little bit simpler, basically hkdf.Expand won't return a io.Reader but a slice of bytes as bis as the keyLength parameter.

Our cng.ExpandHKDF function is not well fitted to implement the new API, as it also returns an io.Reader and internally allocated a buffer that might not have the same size as keyLength, which will end up causing unnecessary allocations.

This PR redefines and reimplements cng.ExpandHKDF so it fits better with the new Go API. As a bonus, the resulting implementation is much simpler.

Note that this repository is still in v0, so we are free to introduce breaking changes.

@qmuntal qmuntal merged commit 1db5157 into main Nov 22, 2024
16 checks passed
@qmuntal qmuntal deleted the dev/qmuntal/hkdfos branch November 22, 2024 13:12
@qmuntal
Copy link
Member Author

qmuntal commented Dec 12, 2024

For microsoft/go#1416.

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.

3 participants