This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] random_device, use arc4random() on FreeBSD, NetBSD and DragonFlyBSD
ClosedPublic

Authored by brad on Mar 28 2022, 7:59 PM.

Details

Summary

With OpenBSD and now macOS using arc4random() for the random device, might as well look at the other BSD's that have arc4random().

Diff Detail

Event Timeline

brad created this revision.Mar 28 2022, 7:59 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 28 2022, 7:59 PM
brad requested review of this revision.Mar 28 2022, 7:59 PM
Herald added a reviewer: Restricted Project. · View Herald TranscriptMar 28 2022, 7:59 PM
ldionne accepted this revision.Apr 8 2022, 2:07 PM

LGTM if the contact points for those OSes are happy.

This revision is now accepted and ready to land.Apr 8 2022, 2:07 PM
ldionne added a subscriber: Restricted Project.Apr 8 2022, 2:08 PM

I'll note that this is a behavior change though. When I made the change on Apple, I added this release note:

On Apple platforms, std::random_device is now implemented on top of arc4random() instead of reading from /dev/urandom. Any implementation-defined token used when constructing a std::random_device will now be ignored instead of interpreted as a file to read entropy from.

Please add a similar release note here.

emaste added a reviewer: dim.Apr 8 2022, 2:15 PM
emaste accepted this revision.Apr 8 2022, 3:05 PM

Sounds good to me for FreeBSD (w/ the release note as mentioned by @ldionne) arc4random is ChaCha20 in all supported FreeBSD versions.

dim accepted this revision.Apr 8 2022, 4:01 PM

Sure, LGTM.

brad updated this revision to Diff 421673.Apr 8 2022, 7:49 PM

Add release note.

emaste accepted this revision.Apr 11 2022, 5:35 AM