node.js - randomBytes vs pseudoRandomBytes -
in situations acceptable (from security standpoint) use node's crypto.pseudorandombytes instead of cryptographically-strong crypto.randombytes?
i assume (incorrect), docs don't have how less-strong is.pseudorandombytes performs better @ expense of being more predictable
specifically, i'm wondering if i'm ok using pseudorandombytes generate csrf token.
as turns out, with default openssl (which bundled node, if you've built own, possible configure different engines), the algorithm generate random data same both randombytes (rand_bytes) , pseudorandombytes (rand_pseudo_bytes).
the 1 , difference between 2 calls depends on version of node you're using:
- in node v0.12 , prior,
randombytesreturns error if entropy pool has not yet been seeded enough data.pseudorandombytesreturn bytes, if entropy pool has not been seeded. - in node v4 , later,
randombytesnot return until entropy pool has enough data. should take few milliseconds (unless system has booted).
once the entropy pool has been seeded enough data, never "run out," there absolutely no effective difference between randombytes , pseudorandombytes once entropy pool full.
because exact same algorithm used generate randrom data, there no difference in performance between 2 calls (one-time entropy pool seeding notwithstanding).
Comments
Post a Comment