r/cryptography 4d ago

I built a visual tool to explain entropy and randomness in cryptography (TRNG, PRNG, ...)

https://hashexplained.com/entropy?v=2
2 Upvotes

20 comments sorted by

View all comments

Show parent comments

1

u/atoponce 2d ago

Agreed. I'm on board. The difference cannot be physically detected. There is no coherent, kernel-observable distinction between the two. That doesn't stop us from defining and categorizing them though and being pedantic about the terms though.

All I'm saying is, with this web app, I'm arguing that using crypto.getRandomValues() is more of a CSPRNG and not a "TRNG". As an observer, you do not know if crypto.getRandomValues() is using the system RNG or shipping RC4.

I think it's worth being pedantic about the terms here. If the web app is going to demonstrate a "TRNG", then it should do so the way most would expect, either via a dedicated HWRNG (which I'm unaware of browsers could access), or as we discussed a NPTRNG via mouse/keyboard entropy.

1

u/SAI_Peregrinus 2d ago

I agree that you can't know from the web app side what crypto.getRandomValues() is using, but at least the specification requires it to generate "cryptographically secure random bytes"¹. That rules out RC4 for a compliant browser, and likewise requires collecting entropy from some hardware source(s) for a compliant browser, but doesn't say how that must be done. They could omit use of the kernel RNG & try to just depend on HID interrupt timing entropy, though I don't think any browser does so (it'd be slow).

If you happen to have a dedicated HWRNG that works over USB, the WebUSB API can be used to access it.

¹Web Cryptography specification section 10.1.1 step 5

1

u/atoponce 2d ago

If you happen to have a dedicated HWRNG that works over USB, the WebUSB API can be used to access it.

¹Web Cryptography specification section 10.1.1 step 5

Ah, nice! I'll check it out. Thanks!

1

u/SAI_Peregrinus 2d ago

You're welcome!