From d88a0f5f3944535dd83d55bedc4d239544c5678d Mon Sep 17 00:00:00 2001 From: Marcin Kolny Date: Mon, 3 Jul 2023 00:38:40 +0100 Subject: [PATCH] Add limited support for WebAssembly WASI target CLA: trivial Reviewed-by: Tim Hudson Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/21344) --- crypto/bio/bss_log.c | 2 ++ providers/implementations/rands/seeding/rand_unix.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/crypto/bio/bss_log.c b/crypto/bio/bss_log.c index f2c84606d2..a90aebe0b4 100644 --- a/crypto/bio/bss_log.c +++ b/crypto/bio/bss_log.c @@ -24,6 +24,8 @@ #if defined(OPENSSL_SYS_WINCE) #elif defined(OPENSSL_SYS_WIN32) +#elif defined(__wasi__) +# define NO_SYSLOG #elif defined(OPENSSL_SYS_VMS) # include # include diff --git a/providers/implementations/rands/seeding/rand_unix.c b/providers/implementations/rands/seeding/rand_unix.c index 2aae396f23..a6d246ad23 100644 --- a/providers/implementations/rands/seeding/rand_unix.c +++ b/providers/implementations/rands/seeding/rand_unix.c @@ -395,6 +395,10 @@ static ssize_t syscall_random(void *buf, size_t buflen) # elif (defined(__DragonFly__) && __DragonFly_version >= 500700) \ || (defined(__NetBSD__) && __NetBSD_Version >= 1000000000) return getrandom(buf, buflen, 0); +# elif defined(__wasi__) + if (getentropy(buf, buflen) == 0) + return (ssize_t)buflen; + return -1; # else errno = ENOSYS; return -1;