File tree Expand file tree Collapse file tree
proposals/random/wit-0.3.0-draft Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,16 +5,23 @@ package wasi:random@0.3.0-rc-2026-02-09;
55/// Windows.
66@since (version = 0.3.0-rc-2026-02-09 )
77interface insecure {
8- /// Return ` len` insecure pseudo-random bytes.
8+ /// Return up to `max- len` insecure pseudo-random bytes.
99 ///
1010 /// This function is not cryptographically secure. Do not use it for
1111 /// anything related to security.
1212 ///
1313 /// There are no requirements on the values of the returned bytes, however
1414 /// implementations are encouraged to return evenly distributed values with
1515 /// a long period.
16+ ///
17+ /// Implementations MAY return fewer bytes than requested (a short read).
18+ /// Callers that require exactly `max-len` bytes MUST call this function in
19+ /// a loop until the desired number of bytes has been accumulated.
20+ /// Implementations MUST return at least 1 byte when `max-len` is greater
21+ /// than zero. When `max-len` is zero, implementations MUST return an empty
22+ /// list without trapping.
1623 @since (version = 0.3.0-rc-2026-02-09 )
17- get-insecure-random-bytes : func (len : u64 ) -> list <u8 >;
24+ get-insecure-random-bytes : func (max- len: u64 ) -> list <u8 >;
1825
1926 /// Return an insecure pseudo-random `u64` value.
2027 ///
Original file line number Diff line number Diff line change @@ -5,7 +5,8 @@ package wasi:random@0.3.0-rc-2026-02-09;
55/// Windows.
66@since (version = 0.3.0-rc-2026-02-09 )
77interface random {
8- /// Return `len` cryptographically-secure random or pseudo-random bytes.
8+ /// Return up to `max-len` cryptographically-secure random or pseudo-random
9+ /// bytes.
910 ///
1011 /// This function must produce data at least as cryptographically secure and
1112 /// fast as an adequately seeded cryptographically-secure pseudo-random
@@ -14,11 +15,18 @@ interface random {
1415 /// request and on requests for numbers of bytes. The returned data must
1516 /// always be unpredictable.
1617 ///
18+ /// Implementations MAY return fewer bytes than requested (a short read).
19+ /// Callers that require exactly `max-len` bytes MUST call this function in
20+ /// a loop until the desired number of bytes has been accumulated.
21+ /// Implementations MUST return at least 1 byte when `max-len` is greater
22+ /// than zero. When `max-len` is zero, implementations MUST return an empty
23+ /// list without trapping.
24+ ///
1725 /// This function must always return fresh data. Deterministic environments
1826 /// must omit this function, rather than implementing it with deterministic
1927 /// data.
2028 @since (version = 0.3.0-rc-2026-02-09 )
21- get-random-bytes : func (len : u64 ) -> list <u8 >;
29+ get-random-bytes : func (max- len: u64 ) -> list <u8 >;
2230
2331 /// Return a cryptographically-secure random or pseudo-random `u64` value.
2432 ///
You can’t perform that action at this time.
0 commit comments