Skip to content

Commit 71450c0

Browse files
authored
Merge pull request #253 from bytecodealliance/ydnar/independent-topo-sort
2 parents ec7ef52 + ec2e79e commit 71450c0

File tree

9 files changed

+1228
-1226
lines changed

9 files changed

+1228
-1226
lines changed

testdata/wasi/cli-command.wit.json.golden.wit

Lines changed: 75 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,81 @@ package wasi:filesystem@0.2.0 {
683683
}
684684
}
685685

686+
package wasi:random@0.2.0 {
687+
/// The insecure-seed interface for seeding hash-map DoS resistance.
688+
///
689+
/// It is intended to be portable at least between Unix-family platforms and
690+
/// Windows.
691+
interface insecure-seed {
692+
/// Return a 128-bit value that may contain a pseudo-random value.
693+
///
694+
/// The returned value is not required to be computed from a CSPRNG, and may
695+
/// even be entirely deterministic. Host implementations are encouraged to
696+
/// provide pseudo-random values to any program exposed to
697+
/// attacker-controlled content, to enable DoS protection built into many
698+
/// languages' hash-map implementations.
699+
///
700+
/// This function is intended to only be called once, by a source language
701+
/// to initialize Denial Of Service (DoS) protection in its hash-map
702+
/// implementation.
703+
///
704+
/// # Expected future evolution
705+
///
706+
/// This will likely be changed to a value import, to prevent it from being
707+
/// called multiple times and potentially used for purposes other than DoS
708+
/// protection.
709+
insecure-seed: func() -> tuple<u64, u64>;
710+
}
711+
712+
/// The insecure interface for insecure pseudo-random numbers.
713+
///
714+
/// It is intended to be portable at least between Unix-family platforms and
715+
/// Windows.
716+
interface insecure {
717+
/// Return `len` insecure pseudo-random bytes.
718+
///
719+
/// This function is not cryptographically secure. Do not use it for
720+
/// anything related to security.
721+
///
722+
/// There are no requirements on the values of the returned bytes, however
723+
/// implementations are encouraged to return evenly distributed values with
724+
/// a long period.
725+
get-insecure-random-bytes: func(len: u64) -> list<u8>;
726+
727+
/// Return an insecure pseudo-random `u64` value.
728+
///
729+
/// This function returns the same type of pseudo-random data as
730+
/// `get-insecure-random-bytes`, represented as a `u64`.
731+
get-insecure-random-u64: func() -> u64;
732+
}
733+
734+
/// WASI Random is a random data API.
735+
///
736+
/// It is intended to be portable at least between Unix-family platforms and
737+
/// Windows.
738+
interface random {
739+
/// Return `len` cryptographically-secure random or pseudo-random bytes.
740+
///
741+
/// This function must produce data at least as cryptographically secure and
742+
/// fast as an adequately seeded cryptographically-secure pseudo-random
743+
/// number generator (CSPRNG). It must not block, from the perspective of
744+
/// the calling program, under any circumstances, including on the first
745+
/// request and on requests for numbers of bytes. The returned data must
746+
/// always be unpredictable.
747+
///
748+
/// This function must always return fresh data. Deterministic environments
749+
/// must omit this function, rather than implementing it with deterministic
750+
/// data.
751+
get-random-bytes: func(len: u64) -> list<u8>;
752+
753+
/// Return a cryptographically-secure random or pseudo-random `u64` value.
754+
///
755+
/// This function returns the same type of data as `get-random-bytes`,
756+
/// represented as a `u64`.
757+
get-random-u64: func() -> u64;
758+
}
759+
}
760+
686761
package wasi:sockets@0.2.0 {
687762
interface network {
688763
/// An opaque resource that represents access to (a subset of) the network.
@@ -2022,78 +2097,3 @@ package wasi:io@0.2.0 {
20222097
}
20232098
}
20242099
}
2025-
2026-
package wasi:random@0.2.0 {
2027-
/// The insecure-seed interface for seeding hash-map DoS resistance.
2028-
///
2029-
/// It is intended to be portable at least between Unix-family platforms and
2030-
/// Windows.
2031-
interface insecure-seed {
2032-
/// Return a 128-bit value that may contain a pseudo-random value.
2033-
///
2034-
/// The returned value is not required to be computed from a CSPRNG, and may
2035-
/// even be entirely deterministic. Host implementations are encouraged to
2036-
/// provide pseudo-random values to any program exposed to
2037-
/// attacker-controlled content, to enable DoS protection built into many
2038-
/// languages' hash-map implementations.
2039-
///
2040-
/// This function is intended to only be called once, by a source language
2041-
/// to initialize Denial Of Service (DoS) protection in its hash-map
2042-
/// implementation.
2043-
///
2044-
/// # Expected future evolution
2045-
///
2046-
/// This will likely be changed to a value import, to prevent it from being
2047-
/// called multiple times and potentially used for purposes other than DoS
2048-
/// protection.
2049-
insecure-seed: func() -> tuple<u64, u64>;
2050-
}
2051-
2052-
/// The insecure interface for insecure pseudo-random numbers.
2053-
///
2054-
/// It is intended to be portable at least between Unix-family platforms and
2055-
/// Windows.
2056-
interface insecure {
2057-
/// Return `len` insecure pseudo-random bytes.
2058-
///
2059-
/// This function is not cryptographically secure. Do not use it for
2060-
/// anything related to security.
2061-
///
2062-
/// There are no requirements on the values of the returned bytes, however
2063-
/// implementations are encouraged to return evenly distributed values with
2064-
/// a long period.
2065-
get-insecure-random-bytes: func(len: u64) -> list<u8>;
2066-
2067-
/// Return an insecure pseudo-random `u64` value.
2068-
///
2069-
/// This function returns the same type of pseudo-random data as
2070-
/// `get-insecure-random-bytes`, represented as a `u64`.
2071-
get-insecure-random-u64: func() -> u64;
2072-
}
2073-
2074-
/// WASI Random is a random data API.
2075-
///
2076-
/// It is intended to be portable at least between Unix-family platforms and
2077-
/// Windows.
2078-
interface random {
2079-
/// Return `len` cryptographically-secure random or pseudo-random bytes.
2080-
///
2081-
/// This function must produce data at least as cryptographically secure and
2082-
/// fast as an adequately seeded cryptographically-secure pseudo-random
2083-
/// number generator (CSPRNG). It must not block, from the perspective of
2084-
/// the calling program, under any circumstances, including on the first
2085-
/// request and on requests for numbers of bytes. The returned data must
2086-
/// always be unpredictable.
2087-
///
2088-
/// This function must always return fresh data. Deterministic environments
2089-
/// must omit this function, rather than implementing it with deterministic
2090-
/// data.
2091-
get-random-bytes: func(len: u64) -> list<u8>;
2092-
2093-
/// Return a cryptographically-secure random or pseudo-random `u64` value.
2094-
///
2095-
/// This function returns the same type of data as `get-random-bytes`,
2096-
/// represented as a `u64`.
2097-
get-random-u64: func() -> u64;
2098-
}
2099-
}

testdata/wasi/cli.wit.json.golden.wit

Lines changed: 81 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,87 @@ package wasi:filesystem@0.2.0 {
722722
}
723723
}
724724

725+
package wasi:random@0.2.0 {
726+
/// The insecure-seed interface for seeding hash-map DoS resistance.
727+
///
728+
/// It is intended to be portable at least between Unix-family platforms and
729+
/// Windows.
730+
interface insecure-seed {
731+
/// Return a 128-bit value that may contain a pseudo-random value.
732+
///
733+
/// The returned value is not required to be computed from a CSPRNG, and may
734+
/// even be entirely deterministic. Host implementations are encouraged to
735+
/// provide pseudo-random values to any program exposed to
736+
/// attacker-controlled content, to enable DoS protection built into many
737+
/// languages' hash-map implementations.
738+
///
739+
/// This function is intended to only be called once, by a source language
740+
/// to initialize Denial Of Service (DoS) protection in its hash-map
741+
/// implementation.
742+
///
743+
/// # Expected future evolution
744+
///
745+
/// This will likely be changed to a value import, to prevent it from being
746+
/// called multiple times and potentially used for purposes other than DoS
747+
/// protection.
748+
insecure-seed: func() -> tuple<u64, u64>;
749+
}
750+
751+
/// The insecure interface for insecure pseudo-random numbers.
752+
///
753+
/// It is intended to be portable at least between Unix-family platforms and
754+
/// Windows.
755+
interface insecure {
756+
/// Return `len` insecure pseudo-random bytes.
757+
///
758+
/// This function is not cryptographically secure. Do not use it for
759+
/// anything related to security.
760+
///
761+
/// There are no requirements on the values of the returned bytes, however
762+
/// implementations are encouraged to return evenly distributed values with
763+
/// a long period.
764+
get-insecure-random-bytes: func(len: u64) -> list<u8>;
765+
766+
/// Return an insecure pseudo-random `u64` value.
767+
///
768+
/// This function returns the same type of pseudo-random data as
769+
/// `get-insecure-random-bytes`, represented as a `u64`.
770+
get-insecure-random-u64: func() -> u64;
771+
}
772+
773+
/// WASI Random is a random data API.
774+
///
775+
/// It is intended to be portable at least between Unix-family platforms and
776+
/// Windows.
777+
interface random {
778+
/// Return `len` cryptographically-secure random or pseudo-random bytes.
779+
///
780+
/// This function must produce data at least as cryptographically secure and
781+
/// fast as an adequately seeded cryptographically-secure pseudo-random
782+
/// number generator (CSPRNG). It must not block, from the perspective of
783+
/// the calling program, under any circumstances, including on the first
784+
/// request and on requests for numbers of bytes. The returned data must
785+
/// always be unpredictable.
786+
///
787+
/// This function must always return fresh data. Deterministic environments
788+
/// must omit this function, rather than implementing it with deterministic
789+
/// data.
790+
get-random-bytes: func(len: u64) -> list<u8>;
791+
792+
/// Return a cryptographically-secure random or pseudo-random `u64` value.
793+
///
794+
/// This function returns the same type of data as `get-random-bytes`,
795+
/// represented as a `u64`.
796+
get-random-u64: func() -> u64;
797+
}
798+
799+
world imports {
800+
import random;
801+
import insecure;
802+
import insecure-seed;
803+
}
804+
}
805+
725806
package wasi:sockets@0.2.0 {
726807
interface network {
727808
/// An opaque resource that represents access to (a subset of) the network.
@@ -2087,84 +2168,3 @@ package wasi:io@0.2.0 {
20872168
import streams;
20882169
}
20892170
}
2090-
2091-
package wasi:random@0.2.0 {
2092-
/// The insecure-seed interface for seeding hash-map DoS resistance.
2093-
///
2094-
/// It is intended to be portable at least between Unix-family platforms and
2095-
/// Windows.
2096-
interface insecure-seed {
2097-
/// Return a 128-bit value that may contain a pseudo-random value.
2098-
///
2099-
/// The returned value is not required to be computed from a CSPRNG, and may
2100-
/// even be entirely deterministic. Host implementations are encouraged to
2101-
/// provide pseudo-random values to any program exposed to
2102-
/// attacker-controlled content, to enable DoS protection built into many
2103-
/// languages' hash-map implementations.
2104-
///
2105-
/// This function is intended to only be called once, by a source language
2106-
/// to initialize Denial Of Service (DoS) protection in its hash-map
2107-
/// implementation.
2108-
///
2109-
/// # Expected future evolution
2110-
///
2111-
/// This will likely be changed to a value import, to prevent it from being
2112-
/// called multiple times and potentially used for purposes other than DoS
2113-
/// protection.
2114-
insecure-seed: func() -> tuple<u64, u64>;
2115-
}
2116-
2117-
/// The insecure interface for insecure pseudo-random numbers.
2118-
///
2119-
/// It is intended to be portable at least between Unix-family platforms and
2120-
/// Windows.
2121-
interface insecure {
2122-
/// Return `len` insecure pseudo-random bytes.
2123-
///
2124-
/// This function is not cryptographically secure. Do not use it for
2125-
/// anything related to security.
2126-
///
2127-
/// There are no requirements on the values of the returned bytes, however
2128-
/// implementations are encouraged to return evenly distributed values with
2129-
/// a long period.
2130-
get-insecure-random-bytes: func(len: u64) -> list<u8>;
2131-
2132-
/// Return an insecure pseudo-random `u64` value.
2133-
///
2134-
/// This function returns the same type of pseudo-random data as
2135-
/// `get-insecure-random-bytes`, represented as a `u64`.
2136-
get-insecure-random-u64: func() -> u64;
2137-
}
2138-
2139-
/// WASI Random is a random data API.
2140-
///
2141-
/// It is intended to be portable at least between Unix-family platforms and
2142-
/// Windows.
2143-
interface random {
2144-
/// Return `len` cryptographically-secure random or pseudo-random bytes.
2145-
///
2146-
/// This function must produce data at least as cryptographically secure and
2147-
/// fast as an adequately seeded cryptographically-secure pseudo-random
2148-
/// number generator (CSPRNG). It must not block, from the perspective of
2149-
/// the calling program, under any circumstances, including on the first
2150-
/// request and on requests for numbers of bytes. The returned data must
2151-
/// always be unpredictable.
2152-
///
2153-
/// This function must always return fresh data. Deterministic environments
2154-
/// must omit this function, rather than implementing it with deterministic
2155-
/// data.
2156-
get-random-bytes: func(len: u64) -> list<u8>;
2157-
2158-
/// Return a cryptographically-secure random or pseudo-random `u64` value.
2159-
///
2160-
/// This function returns the same type of data as `get-random-bytes`,
2161-
/// represented as a `u64`.
2162-
get-random-u64: func() -> u64;
2163-
}
2164-
2165-
world imports {
2166-
import random;
2167-
import insecure;
2168-
import insecure-seed;
2169-
}
2170-
}

0 commit comments

Comments
 (0)