1 module dcrypt.random.fortuna.sources.rdrand; 2 3 import dcrypt.random.rdrand; 4 import dcrypt.random.fortuna.entropysource; 5 import dcrypt.random.fortuna.fortuna: addEntropy; 6 7 /// Generate entropy data with intel rdrand instruction. 8 9 @safe 10 public class RDRandEntropySource: EntropySource 11 { 12 13 private { 14 uint delay = 250; 15 RDRand rdrand; 16 } 17 18 override void collectEntropy() nothrow { 19 20 ubyte[32] buf; 21 22 if(rdrand.isSupported) { 23 rdrand.nextBytes(buf); 24 } else { 25 // not supported 26 delay = 0; 27 } 28 29 sendEntropyEvent(buf); 30 } 31 32 @nogc @property nothrow 33 override public string name() { 34 return "RDRand"; 35 } 36 37 @safe @nogc nothrow 38 override uint scheduleNext() { 39 return delay; 40 } 41 42 }