|
722 | 722 | }
|
723 | 723 | }
|
724 | 724 |
|
| 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 | + |
725 | 806 | package wasi:sockets@0.2.0 {
|
726 | 807 | interface network {
|
727 | 808 | /// An opaque resource that represents access to (a subset of) the network.
|
|
2087 | 2168 | import streams;
|
2088 | 2169 | }
|
2089 | 2170 | }
|
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