Repository navigation
Fixes UUIDv7 lack of randomness - #10865
Conversation
|
Thanks for your pull request and interest in making D better, @denizzzka! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + phobos#10865" |
3e23208 to
3ab5013
Compare
3ab5013 to
3c2f87e
Compare
3c2f87e to
32956dd
Compare
|
Changed to a less radical changes: Spending TRNG data to UUIDs seems too expensive Looks like after merging unittest can be removed? Seems is very unlikely that this kind of error will happen again and will be caught by this test |
|
At first I was thinking, hm... what is this actually changing? Then I realized, it was only using a I don't think the unittest is acceptable. Yes, it's going to pass most of the time, but it's going to introduce a possibility of failures that a) have nothing to do with what is being tested and b) will not be reproducible. We do not want these kinds of tests in CI. This might be something we don't need a unittest for. The cost of adding it is not worth it. And I doubt someone's going to come along and switch it back to a |
|
A good test could do some statistical analysis and check for odd patterns in the results, but that might be a bit expensive. |
|
LightBender
left a comment
There was a problem hiding this comment.
Could you add a comment to the documentation for UUIDv7 noting that it does NOT use a CSPRNG in all cases?
After that I'll approve this.
Actually it uses CSPRNG now. And so it should be. |
|
@denizzzka, unpredictableSeed has a note that it doesn't always use a CSPRNG, which means we need to either link to that note or note it directly. |
|
I don't know how to write this: I'm not a native speaker. Write something.. |
|
@denizzzka Something like: This implementation is not guaranteed to use a cryptographically secure PRNG. For more information please see: |
4b997ef to
e99cfd1
Compare
|
Can't we use random data from /dev/urandom on linux? |
Strictly, /dev/urandom is poor choise because it is (surprisingly) can be unavailable on some cases (on booting, for example) |
|
Actually, /dev/urandom never becomes "unavailable": its core design principle is to never block. The issue during the very early boot phase (which is a highly specific edge case that most applications never hit) is about the quality of the entropy, not its availability. If you read from it before the kernel's entropy pool is fully initialized, it will still return data immediately, but that data will be cryptographically weak. However, if our current implementation is already generating cryptographically weak data anyway, using /dev/urandom at early boot wouldn't put us in a worse position. The crucial difference is that for the other 99.9% of normal use cases, we would actually be getting cryptographically secure data. |
Ok, another case: whole /dev/* pathnames will become invisible if chroot is used |
|
What benefit does |
|
@Herringway /dev/urandom is cryptographically secure, that was my point. (also getrandom() syscall) |
|
We'd still need cryptographically secure RNG implementations for other platforms for feature parity. Then there will be multiple implementations. If any of those other implementations can also function on linux, why use |
|
There's no other secure implementations for this. And I don't think "feature parity" is a thing. |
Use |
That’s why |
|
I don’t remember whether I wrote this link here or not |
|
CS PRN generation in Phobos v2 is an unfortunate thing. You might remember my reply to the thread you’ve linked: https://forum.dlang.org/post/[email protected] Phobos v2 has a backwards-compatibility policy. Given that we are shoehorning crypto security into APIs that weren’t designed with that in mind, one — unfortunately — has to lower one’s sights. |
First commit: this test fails
on my machineSecond commit fixes issue
I decided to use getEntropy directly instead as seed here because UUID requires a just a little more than 8 bytes of ulong needed for generate quality random sequence. So there is no point in calling Random for this.