| 1 |
package wasi:[email protected]; |
| 2 |
/// WASI Random is a random data API. |
| 3 |
/// |
| 4 |
/// It is intended to be portable at least between Unix-family platforms and |
| 5 |
/// Windows. |
| 6 |
interface random { |
| 7 |
/// Return `len` cryptographically-secure random or pseudo-random bytes. |
| 8 |
/// |
| 9 |
/// This function must produce data at least as cryptographically secure and |
| 10 |
/// fast as an adequately seeded cryptographically-secure pseudo-random |
| 11 |
/// number generator (CSPRNG). It must not block, from the perspective of |
| 12 |
/// the calling program, under any circumstances, including on the first |
| 13 |
/// request and on requests for numbers of bytes. The returned data must |
| 14 |
/// always be unpredictable. |
| 15 |
/// |
| 16 |
/// This function must always return fresh data. Deterministic environments |
| 17 |
/// must omit this function, rather than implementing it with deterministic |
| 18 |
/// data. |
| 19 |
get-random-bytes: func(len: u64) -> list<u8>; |
| 20 |
|
| 21 |
/// Return a cryptographically-secure random or pseudo-random `u64` value. |
| 22 |
/// |
| 23 |
/// This function returns the same type of data as `get-random-bytes`, |
| 24 |
/// represented as a `u64`. |
| 25 |
get-random-u64: func() -> u64; |
| 26 |
} |