<p><a href="https://github.com/bitcoin/bitcoin/blob/2aed2b30b112aaaf7d46df4fd947648ca8df4e67/src/key.cpp#L363" rel="nofollow">It uses RAND_bytes from OpenSSL</a>. The relevant call is <code>CKey::MakeNewKey</code>.</p>

<p><code>getnewaddress</code> is in rpcwallet.cpp. It tries to get a key from the pool, and if the pool is empty it allocates a new one which is populated using RAND_bytes.</p>

CC BY-SA 3.0
2014-04-20T21:20:07.523Z
2014-04-20T21:20:07.523Z
Diego Basch
<p>As others mentioned Bitcoin core uses <a href="http://wiki.openssl.org/index.php/Random_Numbers#Sources" rel="nofollow">OpenSSL random sources</a>.</p>

<p>This means that it uses any random source available, like:</p>

<ul>
<li>the operation system, i.e. interrupts</li>
<li>random sources of the CPU or the chip set</li>
<li>dedicated hardware for entropy generation</li>
</ul>

<p>So in order to make sure your hardware random generator works with Bitcoin you must make sure it works with OpenSSL.</p>

CC BY-SA 3.0
2014-04-20T20:23:46.840Z
2014-04-20T20:23:46.840Z
John L. Jegutanis
<p>Is it an internal PRNG? Is it fed  from <code>/dev/random</code> or <code>/dev/urandom</code>? How secure is it? If I have a hardware (TRNG) plugged in feeding my <code>/dev/random</code> will this source of entropy get used by <code>bitcoind</code>?</p>

CC BY-SA 3.0
2014-04-19T17:06:23.870Z
Well OpenSSL handles most cryptography things in Bitcoin.
Jori
CC BY-SA 3.0
2014-04-19T21:46:07.207Z
In this particular case, it's the RAND_bytes call from OpenSSL.
Diego Basch
<bitcoind><api><address-generation><random>
What kind of random numbers source does getnewaddress in Bitcoin Core API (bitcoind) uses?
Felipe
# What kind of random numbers source does getnewaddress in Bitcoin Core API (bitcoind) uses?

(Asked by: username_0 on 2014-04-19)

Is it an internal PRNG? Is it fed from `/dev/random` or `/dev/urandom`? How secure is it? If I have a hardware (TRNG) plugged in feeding my `/dev/random` will this source of entropy get used by `bitcoind`?

**Tags:** bitcoind, api, address-generation, random

> **Comments:**
> **username_1**: Well OpenSSL handles most cryptography things in Bitcoin.  
> **username_2**: In this particular case, it's the RAND_bytes call from OpenSSL.  

---

## 2 answers

### Answer by username_3 on 2014-04-20. Score: 4 | Accepted answer

As others mentioned Bitcoin core uses [OpenSSL random sources](http://wiki.openssl.org/index.php/Random_Numbers#Sources).

This means that it uses any random source available, like:

* the operation system, i.e. interrupts
* random sources of the CPU or the chip set
* dedicated hardware for entropy generation

So in order to make sure your hardware random generator works with Bitcoin you must make sure it works with OpenSSL.


---

### Answer by username_2 on 2014-04-20. Score: 3

[It uses RAND\_bytes from OpenSSL](https://github.com/bitcoin/bitcoin/blob/2aed2b30b112aaaf7d46df4fd947648ca8df4e67/src/key.cpp#L363). The relevant call is `CKey::MakeNewKey`.

`getnewaddress` is in rpcwallet.cpp. It tries to get a key from the pool, and if the pool is empty it allocates a new one which is populated using RAND\_bytes.


---

