Files
Julian Squires 1ef175a682 Loop on rdrand flag return
According to the Intel instruction set reference manual, we need to
check the carry flag after calling rdrand, and loop if it's not set.
2016-06-14 15:56:59 -04:00

29 lines
679 B
NASM

; # RDRAND
; True random number generator!
; This Intel engineer says its based on quantum effects:
; http://stackoverflow.com/a/18004959/895245
; Generated some polemic when kernel devs wanted to use it as part of `/dev/random`,
; because it could be used as a cryptographic backdoor by Intel since it is a black box.
; rdrand sets the carry flag when data is ready; one must loop if
; the carry flag isn't set, but unlike in this example, one should
; bound the number of attempts.
%include "lib/asm_io.inc"
ENTRY
.loop0:
rdrand eax
jnc .loop0
call print_int
.loop1:
rdrand eax
jnc .loop1
call print_int
EXIT