@@ -683,6 +683,81 @@ package wasi:filesystem@0.2.0 {
683
683
}
684
684
}
685
685
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
+
686
761
package wasi : sockets @ 0.2.0 {
687
762
interface network {
688
763
/// An opaque resource that represents access to (a subset of) the network.
@@ -2022,78 +2097,3 @@ package wasi:io@0.2.0 {
2022
2097
}
2023
2098
}
2024
2099
}
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
- }
0 commit comments