Let's say I need to generate a key, I have these three options as to where to get random data:
- Yubikey (
gpg-connect-agent 'SCD RANDOM 16384' /bye)
/dev/random
- Combine bytes from the 2 sources
There is a better option: You can write data from your Yubikey to /dev/random, and then read from /dev/urandom (or use getentropy).
On the system you are designing where you know there is a Yubikey and you know gpg-connect-agent will work to talk to it and so on, you can get data from the Yubikey and write it to /dev/random to incorporate it into the system's entropy pool and affect subsequent system RNG output before running applications that need entropy.
Every major Unixish operating system supports this—for example, Linux, FreeBSD, NetBSD, OpenBSD, illumos.
That will help your key generation application and all other applications you're using on the same system.
Then, after you have done that in your system, your application software should always just use /dev/urandom (or getentropy, on more recent systems) so that they generate keys based on all the entropy sources gathered by the system, including your Yubikey output, keystroke timings, environmental sensors, other hardware RNGs like RDRAND or TPM, and so on.
Applications should never read from the legacy /dev/random interface for key generation; the idea that reading from /dev/random is better is a myth, and you should just use /dev/urandom, and even the Linux man page now calls /dev/random a legacy interface and advises against it. (You can write your Yubikey's output to /dev/urandom too, instead of to /dev/random, if you like.)
There is also another interface from Linux, getrandom, which is unnecessarily complicated and confusing with a variety of flags to choose between incoherent and inconsistently implemented behavior.
But as long as you engineer your system to feed samples from an unpredictable process—e.g., your Yubikey—into /dev/random before applications generate keys, there is no security difference between the various different ways to use it.
So you should just use getentropy anyway.