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

Accept shared ArrayBufferView also? #213

Open
jimmywarting opened this issue Nov 29, 2018 · 4 comments
Open

Accept shared ArrayBufferView also? #213

jimmywarting opened this issue Nov 29, 2018 · 4 comments

Comments

@jimmywarting
Copy link

jimmywarting commented Nov 29, 2018

I tried to use shared ArrayBuffer view along with crypto api. Didn't work

crypto.getRandomValues(new Uint8Array(new SharedArrayBuffer(1)))
crypto.subtle.digest(algo, sharedBuffer)
Failed to execute 'getRandomValues' on 'Crypto': 
  The provided ArrayBufferView value must not be shared.

Failed to execute 'digest' on 'SubtleCrypto': 
  The provided ArrayBufferView value must not be shared.

Is there any reason why it would not be allowed? didn't find any issue or text in the spec mention anything about sharedArrayBuffer

@sideshowbarker
Copy link
Contributor

Jimmy, do you have a plan for getting some browser implementors engaged in discussion here about this proposal?

@jimmywarting
Copy link
Author

not really

@sideshowbarker
Copy link
Contributor

OK, then unless there’s somebody else who weighs in on this relatively soon with some plan, I’m gonna propose that we close this

@jimmywarting
Copy link
Author

Today i tried to use BigUint64Array with getRandomValues

I think some web crypto stuff have fallen behind since we have got new types of array's (big int, sharedArrayBuffer etc)
This didn't work in chrome, FF, and Safari TP are missing BigUint64Array

crypto.getRandomValues(new BigUint64Array(1))
Chrome:
Uncaught DOMException: Failed to execute 'getRandomValues' on 'Crypto': 
The provided ArrayBufferView is of type 'BigUint64', which is not an integer array type.

BigUint64Array is a ArrayBufferView so it should work imo.
ArrayBuffer.isView(new BigUint64Array(1)) // true

Looking at the spec then it looks to be somewhat outdated... and don't seem to be a specific browser issue.

10.2.1. The getRandomValues method
The getRandomValues method generates cryptographically random values. It must act as follows:

If array is not of an integer type (i.e., Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array or UInt8ClampedArray), throw a TypeMismatchError and terminate the algorithm.

Why should it be just dose types? I think it should be changed to something like eg:
"If array is not of an ArrayBufferView or a (Shared)ArrayBuffer" throw a TypeMismatchError and terminate the algorithm.

tmpfs added a commit to LavaMoat/tss-snap that referenced this issue Dec 3, 2021
Now we have a new error calling Crypto.getRandomValues() backed by a
SharedArrayBuffer.

See: w3c/webcrypto#213
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants