aboutsummaryrefslogtreecommitdiff
path: root/core/crypto
diff options
context:
space:
mode:
authorLaytan Laats <laytanlaats@hotmail.com>2025-01-18 22:07:19 +0100
committerLaytan Laats <laytanlaats@hotmail.com>2025-01-18 22:23:44 +0100
commite4892f1bb232bbad0795a94f809f3124620653a9 (patch)
tree588e5f69aa996c99b4fc096933e4f1d4776c24be /core/crypto
parent47030501abbdb9b09baf34f1ea1ed15f513ccd6d (diff)
os/os2: wasi target support
Diffstat (limited to 'core/crypto')
-rw-r--r--core/crypto/rand_generic.odin1
-rw-r--r--core/crypto/rand_wasi.odin13
2 files changed, 14 insertions, 0 deletions
diff --git a/core/crypto/rand_generic.odin b/core/crypto/rand_generic.odin
index ef578f5c0..8266f8ffc 100644
--- a/core/crypto/rand_generic.odin
+++ b/core/crypto/rand_generic.odin
@@ -5,6 +5,7 @@
#+build !netbsd
#+build !darwin
#+build !js
+#+build !wasi
package crypto
HAS_RAND_BYTES :: false
diff --git a/core/crypto/rand_wasi.odin b/core/crypto/rand_wasi.odin
new file mode 100644
index 000000000..9653fb985
--- /dev/null
+++ b/core/crypto/rand_wasi.odin
@@ -0,0 +1,13 @@
+package crypto
+
+import "core:fmt"
+import "core:sys/wasm/wasi"
+
+HAS_RAND_BYTES :: true
+
+@(private)
+_rand_bytes :: proc(dst: []byte) {
+ if err := wasi.random_get(dst); err != nil {
+ fmt.panicf("crypto: wasi.random_get failed: %v", err)
+ }
+}