Skip to content
This repository was archived by the owner on Jul 3, 2020. It is now read-only.

Random API and RNG#81

Merged
iefserge merged 40 commits intomasterfrom
tmp-rng
Jul 27, 2015
Merged

Random API and RNG#81
iefserge merged 40 commits intomasterfrom
tmp-rng

Conversation

@iefserge
Copy link
Copy Markdown
Member

Based on #73 by @ArielAbreu
R = @ArielAbreu

Changes:

  • added EntropySource interface
  • renamed none source to js-random
  • fixed virtio-rng driver load (loaded once now, it worked for me)
  • added virtio-rng IRQ isPendingIRQ check
  • added tests
  • other minor improvements

runtime-tools has new option --virtio-rng that enables virtio random source.

Ariel Abreu and others added 30 commits July 5, 2015 14:33
This reverts commit 5143479.
This reverts commit 5143479.
- Move random 'none'  source to another file
- Rename some functions in random
- Push Uint8Arrays to the queue and request them to be filled up
instead of just loading the queue with random numbers
- Get seed from method and use it for isaac.js to generate CS
pseudo-random numbers instead of getting available randomness
* origin/pr/73: (26 commits)
  Fix some stuff
  Only make IRQ callback once
  Fix default random source
  Use IRQ callback in fillQueue, use one-time seed per source
  Optimize code a bit
  Lots of stuff, see details:
  Use Math.random if u8 === null
  Fix runtime.random.rand()
  New interface, better randomness, use isaac
  Revert "Revert "make rng unclassifed""
  Add isaac.js, don't use it yet
  Revert "make rng unclassifed"
  make rng unclassifed
  Fix parameters
  Fix some stuff
  Add optional callback to randomBytes
  Make functions sync, add randomBytes
  resolve conflicts
  Add isaac.js, don't use it yet
  Revert "make rng unclassifed"
  ...
@iefserge
Copy link
Copy Markdown
Member Author

Interesting, that on my linux machine in KVM getRandomValues outputs like 10 bytes a minute (same for cat /dev/random).
I think maybe rename getPseudoRandomValues to getRandomValues because it's going to be used much more frequently.

Comment thread js/core/random/index.js Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to me this shouldn't throw. Instead it use a length of 1.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure it's a good idea to silently return 1 byte buffer instead of error. Why do we want this convenience shortcut?

For example, browser throws when there are no arguments provided

crypto.getRandomValues()
VM931:2 Uncaught TypeError: Failed to execute 'getRandomValues' on 'Crypto': 1 argument required, but only 0 present.
    at TypeError (native)
    at <anonymous>:2:8
    at Object.InjectedScript._evaluateOn (<anonymous>:905:140)
    at Object.InjectedScript._evaluateAndWrap (<anonymous>:838:34)
    at Object.InjectedScript.evaluate (<anonymous>:694:21)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I guess. Nevermind, other than this, 👍!

iefserge added a commit that referenced this pull request Jul 27, 2015
@iefserge iefserge merged commit 70aeaa1 into master Jul 27, 2015
@iefserge iefserge deleted the tmp-rng branch July 27, 2015 22:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants