x86-64 machine code, 10 bytes
Fortunately, there is a built-in RNG. Requires the RDRAND instruction.
00000000: c1e1 020f c7f0 abe2 fac3 ..........
Disassembled:
shl ecx, 2
label:
rdrand eax
stosd
loop label
ret
Outputs to a pre-allocated buffer in rdi
. n
is passed in ecx
(arrays with 2^30 elements and more are not supported).
Try it online! (a helper function is needed because of the unusual calling convention)