Commit dc63a41
Expose RAND_poll / RAND_add to user code via crypto module.
The purpose of this patch is to allow Node applications to add
additional entropy to OpenSSL's pool. This is useful in environments
where a running Node process can be cloned (e.g. VM snapshotting or
live migration), resulting in a chance of the cloned process sharing
an entropy pool with the original process.
The new AddEntropy function works as follows:
- If no parameters are passed, it calls RAND_poll. Performance was
evaluated at about 140k ops/sec, but this will vary by OS and
hardware.
- If one parameter is passed, it is expected to be a buffer, which
is passed to RAND_add. Performance was evaluated at about
1.8m ops/sec.
The AddEntropy function is bound to crypto.addEntropy().
Usage:
var crypto = require('crypto');
// Add entropy from system-supplied source
crypto.addEntropy();
// Add entropy from a user-supplied source
crypto.addEntropy(new Uint8Array([38, 4, 19, 22]));1 parent 56efb3d commit dc63a41
3 files changed
Lines changed: 34 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
621 | 622 | | |
622 | 623 | | |
623 | 624 | | |
| 625 | + | |
| 626 | + | |
624 | 627 | | |
625 | 628 | | |
626 | 629 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5354 | 5354 | | |
5355 | 5355 | | |
5356 | 5356 | | |
| 5357 | + | |
| 5358 | + | |
| 5359 | + | |
| 5360 | + | |
| 5361 | + | |
| 5362 | + | |
| 5363 | + | |
| 5364 | + | |
| 5365 | + | |
| 5366 | + | |
| 5367 | + | |
| 5368 | + | |
| 5369 | + | |
| 5370 | + | |
| 5371 | + | |
| 5372 | + | |
| 5373 | + | |
| 5374 | + | |
| 5375 | + | |
5357 | 5376 | | |
5358 | 5377 | | |
5359 | 5378 | | |
| |||
5648 | 5667 | | |
5649 | 5668 | | |
5650 | 5669 | | |
| 5670 | + | |
5651 | 5671 | | |
5652 | 5672 | | |
5653 | 5673 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
40 | 51 | | |
41 | 52 | | |
42 | 53 | | |
| |||
0 commit comments