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

Ensure to actually copy bytes when the specification requests it #42

Closed
oleiade opened this issue Apr 3, 2023 · 1 comment · Fixed by #43
Closed

Ensure to actually copy bytes when the specification requests it #42

oleiade opened this issue Apr 3, 2023 · 1 comment · Fixed by #43
Assignees
Labels
bug Something isn't working

Comments

@oleiade
Copy link
Member

oleiade commented Apr 3, 2023

Certain steps in the WebCrypto API specification state something along the lines of:

Let data be the result of [getting a copy of the bytes held by](http://heycam.github.io/webidl/#dfn-get-buffer-source-copy) the data parameter passed to the [sign](https://www.w3.org/TR/WebCryptoAPI/#dfn-SubtleCrypto-method-sign) method."

So far we had only extracted the bytes, without explicitly copying them. We recently found out this can lead to bugs. We should make sure that everywhere we implement such step, we actually copy the passed in buffer's bytes. This can be achieved with the following snippet:

	ab, err := exportArrayBuffer(sc.vu.Runtime(), signature)
	if err != nil {
		reject(err)
		return promise
	}
	signatureData := make([]byte, len(ab))
	copy(signatureData, ab)
@oleiade oleiade self-assigned this Apr 3, 2023
@oleiade oleiade added the bug Something isn't working label Apr 3, 2023
@oleiade
Copy link
Member Author

oleiade commented Apr 5, 2023

Make sure we use the existing constructs in the digest function 👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant