Debian Codegraph @

wasi/p2/wit/deps/wasi-random-0.2.0/package.wit

raw
1 package wasi:[email protected];
2
3 /// The insecure-seed interface for seeding hash-map DoS resistance.
4 ///
5 /// It is intended to be portable at least between Unix-family platforms and
6 /// Windows.
7 interface insecure-seed {
8 /// Return a 128-bit value that may contain a pseudo-random value.
9 ///
10 /// The returned value is not required to be computed from a CSPRNG, and may
11 /// even be entirely deterministic. Host implementations are encouraged to
12 /// provide pseudo-random values to any program exposed to
13 /// attacker-controlled content, to enable DoS protection built into many
14 /// languages' hash-map implementations.
15 ///
16 /// This function is intended to only be called once, by a source language
17 /// to initialize Denial Of Service (DoS) protection in its hash-map
18 /// implementation.
19 ///
20 /// # Expected future evolution
21 ///
22 /// This will likely be changed to a value import, to prevent it from being
23 /// called multiple times and potentially used for purposes other than DoS
24 /// protection.
25 insecure-seed: func() -> tuple<u64, u64>;
26 }
27
28 /// The insecure interface for insecure pseudo-random numbers.
29 ///
30 /// It is intended to be portable at least between Unix-family platforms and
31 /// Windows.
32 interface insecure {
33 /// Return `len` insecure pseudo-random bytes.
34 ///
35 /// This function is not cryptographically secure. Do not use it for
36 /// anything related to security.
37 ///
38 /// There are no requirements on the values of the returned bytes, however
39 /// implementations are encouraged to return evenly distributed values with
40 /// a long period.
41 get-insecure-random-bytes: func(len: u64) -> list<u8>;
42
43 /// Return an insecure pseudo-random `u64` value.
44 ///
45 /// This function returns the same type of pseudo-random data as
46 /// `get-insecure-random-bytes`, represented as a `u64`.
47 get-insecure-random-u64: func() -> u64;
48 }
49
50 /// WASI Random is a random data API.
51 ///
52 /// It is intended to be portable at least between Unix-family platforms and
53 /// Windows.
54 interface random {
55 /// Return `len` cryptographically-secure random or pseudo-random bytes.
56 ///
57 /// This function must produce data at least as cryptographically secure and
58 /// fast as an adequately seeded cryptographically-secure pseudo-random
59 /// number generator (CSPRNG). It must not block, from the perspective of
60 /// the calling program, under any circumstances, including on the first
61 /// request and on requests for numbers of bytes. The returned data must
62 /// always be unpredictable.
63 ///
64 /// This function must always return fresh data. Deterministic environments
65 /// must omit this function, rather than implementing it with deterministic
66 /// data.
67 get-random-bytes: func(len: u64) -> list<u8>;
68
69 /// Return a cryptographically-secure random or pseudo-random `u64` value.
70 ///
71 /// This function returns the same type of data as `get-random-bytes`,
72 /// represented as a `u64`.
73 get-random-u64: func() -> u64;
74 }
75
76 world imports {
77 import random;
78 import insecure;
79 import insecure-seed;
80 }