-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[wasm][crypto] RandomNumberGenerator mapped to Web Crypto getRandomValues #42728
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
Merged
marek-safar
merged 19 commits into
dotnet:master
from
kjpou1:wasm-crypto-getRandomValues
Oct 1, 2020
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
f0a662c
[wasm][crypto] RandomNumberGenerator mapped to Web Crypto getRandomVa…
kjpou1 eb46e2f
Remove the emscripten interface code from the driver.c.
kjpou1 ce149c9
Merge branch 'master' of https://github.com/dotnet/runtime into wasm-…
kjpou1 878cfcf
remove extraneous code comment
kjpou1 289efef
Move emscripten definition around.
kjpou1 b5d372b
Address review comment
kjpou1 f657f4f
Merge branch 'master' of https://github.com/dotnet/runtime into wasm-…
kjpou1 cf74a12
Add javascript bridge implementation library to Native source tree.
kjpou1 88fa846
Change tests to set random values of the buffer instead of return a s…
kjpou1 2b8987d
Remove old test code
kjpou1 61f1c19
Remove testing code
kjpou1 ce13ad1
Incorporate the PAL bridge layer into the `--js-library` build process
kjpou1 4eb6639
Merge branch 'master' of https://github.com/dotnet/runtime into wasm-…
kjpou1 5e593bb
Address review comments about directory structure and naming
kjpou1 76de399
Update src/mono/wasm/runtime-test.js
kjpou1 75a81ce
Merge branch 'master' of https://github.com/dotnet/runtime into wasm-…
kjpou1 8077f7c
Add note about insecure code for testing purposes
kjpou1 ec16f1a
Formatting
kjpou1 7b7e9d2
Return -1 if crypto does not exist instead of aborting from js. This…
kjpou1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
var DotNetEntropyLib = { | ||
$DOTNETENTROPY: { | ||
}, | ||
dotnet_browser_entropy : function (buffer, bufferLength) { | ||
// check that we have crypto available | ||
if (typeof crypto === 'object' && typeof crypto['getRandomValues'] === 'function') { | ||
// for modern web browsers | ||
// map the work array to the memory buffer passed with the length | ||
var wrkArray = new Uint8Array(Module.HEAPU8.buffer, buffer, bufferLength); | ||
crypto.getRandomValues(wrkArray); | ||
return 0; | ||
} else { | ||
// we couldn't find a proper implementation, as Math.random() is not suitable | ||
// instead of aborting here we will return and let managed code handle the message | ||
return -1; | ||
} | ||
}, | ||
}; | ||
|
||
autoAddDeps(DotNetEntropyLib, '$DOTNETENTROPY') | ||
mergeInto(LibraryManager.library, DotNetEntropyLib) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.