History log of /kvm-unit-tests/lib/rand.c (Results 1 – 2 of 2)
Revision Date Author Comments
# 6b801c89 20-Aug-2024 Andrew Jones <andrew.jones@linux.dev>

Merge branch 'riscv/sbi' into 'master'

Mainly riscv stuff, but also limits.h and pseudo random numbers

See merge request kvm-unit-tests/kvm-unit-tests!65


# e8337330 20-Jun-2024 Nina Schoetterl-Glausch <nsg@linux.ibm.com>

lib: Add pseudo random functions

Add functions for generating pseudo random 32 and 64 bit values.
The implementation uses SHA-256 and so the randomness should have good
quality.
Implement the necess

lib: Add pseudo random functions

Add functions for generating pseudo random 32 and 64 bit values.
The implementation uses SHA-256 and so the randomness should have good
quality.
Implement the necessary subset of SHA-256.
The PRNG algorithm is equivalent to the following python snippet:

def prng32(seed):
from hashlib import sha256
state = seed.to_bytes(8, byteorder="big")
while True:
state = sha256(state).digest()
for i in range(8):
yield int.from_bytes(state[i*4:(i+1)*4], byteorder="big")

Acked-by: Andrew Jones <andrew.jones@linux.dev>
Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Acked-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Andrew Jones <andrew.jones@linux.dev>

show more ...