eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'RandomRDRand':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: RandomRDRand


Inheritance:

   Object
   |
   +--RandomRDRand

Package:
stx:libbasic2
Category:
Magnitude-Numbers-Random
Version:
rev: 1.11 date: 2019/07/25 11:33:47
user: cg
file: RandomRDRand.st directory: libbasic2
module: stx stc-classLibrary: libbasic2
Author:
Claus Gittinger.

Description:


This generator uses the rdgen random generator which is built into modern intel chips.
Before using, you should check via the isSupported query.

Warning:
    there have been discussions about the security of the intel rdgen instruction
    and whether there are NSA backdoors built into it.
    Linus Torwalds refuses to use it for /dev/urandom in the linux kernel, for that very reason.
    Be sure you know what you are doing, if you use this generator for sensitive cryptographic stuff.
    We recommend using one of the libcrypt-based generators and use this only to get additional
    entropy for the seed.

Warning2:
    the initial release of the AMD Ryzen3000 (without BIOS update) has a bug in returning the same
    (all 1s) random number every time.
    The code here checks for that an raises an error in the constructor if that bug is detected.
    Be sure to catch this exception in your code and fall back to another random generator if raised.
    
NO WARRANTY

RandomRDGen new nextInteger


Related information:

    RandomGenerator
    -
    the
    default;
    uses
    the
    machine's
    /dev/random
    if
    available
    Random
    -
    fast,
    but
    generates
    less
    quality
    random
    numbers
    RandomTT800
    -
    another
    random
    generator
    RandomParkMiller
    -
    another
    random
    generator
    RandomMT19937
    -
    another
    random
    generator
    RandomKISS
    -
    another
    random
    generator
    [xept]
    -
    a
    library
    containing
    more
    stuff
    based
    on
    hashes
    and
    cyphers

Class protocol:

instance creation
o  new
self new nextInteger

o  new: seed
seed is actually ignored

queries
o  isSupported
true if this architecture supports hardware random numbers

usage example(s):

     self isSupported


Instance protocol:

initialization
o  initialize
check for Ryzen RDRAND bug (returning the same all-ones everytime)

o  seed: seed
ignored

random numbers
o  nextBoolean
generates a boolean random

o  nextInteger
generates the next integer in 0..MAXINT.
Notice, it may raise an illegal instruction exception on some cpu chips,
even though the cpuid instruction says that it is available

usage example(s):

     self new nextInteger



ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Fri, 26 Apr 2024 16:04:25 GMT