Skip to content

Use arc4random for entropy on supported systems #9676

@mlmikael

Description

@mlmikael

Please add a check for arc4random support on all OS:es.

When found, GetOSRand() of src/random.cpp should use it for getting entropy from the OS.

int f = open("/dev/urandom", O_RDONLY);

This will have the benefit that BitcoinD will work also in Unix environments where there is no /dev/urandom file, such as certain chroot:ed environments, in particular where the filesystem not supports the creation of device files.

The patch in src/random.cpp will amount to adding this before line 108:

#elif arc4random_supported
arc4random_buf(ent32,32);

I.e. if arc4random() is supported, then simply use this arc4random_buf() call as only code in GetOSRand(). arc4random_buf() has no failure states.

Then, the configure script must check if arc4random is supported, and if so set the arc4random_supported define.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions