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

Implement Clone for all hashers #167

Merged
merged 3 commits into from
Sep 9, 2024
Merged

Implement Clone for all hashers #167

merged 3 commits into from
Sep 9, 2024

Conversation

qmuntal
Copy link
Collaborator

@qmuntal qmuntal commented Sep 5, 2024

In #161 I refactored our hash implementations to only implement the encoding.BinaryMarshaler interface when using the built-in providers. This raises a new problem, as the standard library uses that interface to clone a hash when doing a TLS 1.3 handshake: https://github.com/golang/go/blob/2707d42966f8985a6663c93e943b9a44b9399fca/src/crypto/tls/handshake_server_tls13.go#L436.

The issue can be fixed by providing a Clone method that is not provider-dependent and patch the standard library to use that instead. In fact, we are already following this approach with the Windows CNG backend in the Microsoft Go fork: https://github.com/microsoft/go/blob/294feac5a41d50e2ef261d6acca9feb017f873d0/patches/0005-Add-CNG-crypto-backend.patch#L1061-L1069. I plan to also use this new Clone method for the OpenSSL backend.

While here, refactor the hash tests so they are a bit more atomic.

hash.go Show resolved Hide resolved
hash_test.go Show resolved Hide resolved
@karianna karianna merged commit 950c5fd into v2 Sep 9, 2024
26 checks passed
@qmuntal qmuntal deleted the hashclone branch October 30, 2024 09:08
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