From 0cb4db084ff6e9d2711e2568e1022a99e1325f78 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Wed, 3 Jun 2020 17:33:18 +0200 Subject: [PATCH 1/2] Use unsigned long long for opslimit Fixes #966 --- src/libsodium/crypto_pwhash/argon2/pwhash_argon2i.c | 10 +++++----- src/libsodium/crypto_pwhash/argon2/pwhash_argon2id.c | 10 +++++----- src/libsodium/crypto_pwhash/crypto_pwhash.c | 10 +++++----- .../scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c | 8 ++++---- src/libsodium/include/sodium/crypto_pwhash.h | 10 +++++----- src/libsodium/include/sodium/crypto_pwhash_argon2i.h | 10 +++++----- src/libsodium/include/sodium/crypto_pwhash_argon2id.h | 10 +++++----- .../sodium/crypto_pwhash_scryptsalsa208sha256.h | 8 ++++---- 8 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/libsodium/crypto_pwhash/argon2/pwhash_argon2i.c b/src/libsodium/crypto_pwhash/argon2/pwhash_argon2i.c index 685fa03a..ee50c09f 100644 --- a/src/libsodium/crypto_pwhash/argon2/pwhash_argon2i.c +++ b/src/libsodium/crypto_pwhash/argon2/pwhash_argon2i.c @@ -72,14 +72,14 @@ crypto_pwhash_argon2i_strprefix(void) return crypto_pwhash_argon2i_STRPREFIX; } -size_t +unsigned long long crypto_pwhash_argon2i_opslimit_min(void) { COMPILER_ASSERT(crypto_pwhash_argon2i_OPSLIMIT_MIN >= ARGON2_MIN_TIME); return crypto_pwhash_argon2i_OPSLIMIT_MIN; } -size_t +unsigned long long crypto_pwhash_argon2i_opslimit_max(void) { COMPILER_ASSERT(crypto_pwhash_argon2i_OPSLIMIT_MAX <= ARGON2_MAX_TIME); @@ -100,7 +100,7 @@ crypto_pwhash_argon2i_memlimit_max(void) return crypto_pwhash_argon2i_MEMLIMIT_MAX; } -size_t +unsigned long long crypto_pwhash_argon2i_opslimit_interactive(void) { return crypto_pwhash_argon2i_OPSLIMIT_INTERACTIVE; @@ -112,7 +112,7 @@ crypto_pwhash_argon2i_memlimit_interactive(void) return crypto_pwhash_argon2i_MEMLIMIT_INTERACTIVE; } -size_t +unsigned long long crypto_pwhash_argon2i_opslimit_moderate(void) { return crypto_pwhash_argon2i_OPSLIMIT_MODERATE; @@ -124,7 +124,7 @@ crypto_pwhash_argon2i_memlimit_moderate(void) return crypto_pwhash_argon2i_MEMLIMIT_MODERATE; } -size_t +unsigned long long crypto_pwhash_argon2i_opslimit_sensitive(void) { return crypto_pwhash_argon2i_OPSLIMIT_SENSITIVE; diff --git a/src/libsodium/crypto_pwhash/argon2/pwhash_argon2id.c b/src/libsodium/crypto_pwhash/argon2/pwhash_argon2id.c index 99d3e219..55556d03 100644 --- a/src/libsodium/crypto_pwhash/argon2/pwhash_argon2id.c +++ b/src/libsodium/crypto_pwhash/argon2/pwhash_argon2id.c @@ -68,14 +68,14 @@ crypto_pwhash_argon2id_strprefix(void) return crypto_pwhash_argon2id_STRPREFIX; } -size_t +unsigned long long crypto_pwhash_argon2id_opslimit_min(void) { COMPILER_ASSERT(crypto_pwhash_argon2id_OPSLIMIT_MIN >= ARGON2_MIN_TIME); return crypto_pwhash_argon2id_OPSLIMIT_MIN; } -size_t +unsigned long long crypto_pwhash_argon2id_opslimit_max(void) { COMPILER_ASSERT(crypto_pwhash_argon2id_OPSLIMIT_MAX <= ARGON2_MAX_TIME); @@ -96,7 +96,7 @@ crypto_pwhash_argon2id_memlimit_max(void) return crypto_pwhash_argon2id_MEMLIMIT_MAX; } -size_t +unsigned long long crypto_pwhash_argon2id_opslimit_interactive(void) { return crypto_pwhash_argon2id_OPSLIMIT_INTERACTIVE; @@ -108,7 +108,7 @@ crypto_pwhash_argon2id_memlimit_interactive(void) return crypto_pwhash_argon2id_MEMLIMIT_INTERACTIVE; } -size_t +unsigned long long crypto_pwhash_argon2id_opslimit_moderate(void) { return crypto_pwhash_argon2id_OPSLIMIT_MODERATE; @@ -120,7 +120,7 @@ crypto_pwhash_argon2id_memlimit_moderate(void) return crypto_pwhash_argon2id_MEMLIMIT_MODERATE; } -size_t +unsigned long long crypto_pwhash_argon2id_opslimit_sensitive(void) { return crypto_pwhash_argon2id_OPSLIMIT_SENSITIVE; diff --git a/src/libsodium/crypto_pwhash/crypto_pwhash.c b/src/libsodium/crypto_pwhash/crypto_pwhash.c index a229b9f7..c1659f7b 100644 --- a/src/libsodium/crypto_pwhash/crypto_pwhash.c +++ b/src/libsodium/crypto_pwhash/crypto_pwhash.c @@ -65,13 +65,13 @@ crypto_pwhash_strprefix(void) return crypto_pwhash_STRPREFIX; } -size_t +unsigned long long crypto_pwhash_opslimit_min(void) { return crypto_pwhash_OPSLIMIT_MIN; } -size_t +unsigned long long crypto_pwhash_opslimit_max(void) { return crypto_pwhash_OPSLIMIT_MAX; @@ -89,7 +89,7 @@ crypto_pwhash_memlimit_max(void) return crypto_pwhash_MEMLIMIT_MAX; } -size_t +unsigned long long crypto_pwhash_opslimit_interactive(void) { return crypto_pwhash_OPSLIMIT_INTERACTIVE; @@ -101,7 +101,7 @@ crypto_pwhash_memlimit_interactive(void) return crypto_pwhash_MEMLIMIT_INTERACTIVE; } -size_t +unsigned long long crypto_pwhash_opslimit_moderate(void) { return crypto_pwhash_OPSLIMIT_MODERATE; @@ -113,7 +113,7 @@ crypto_pwhash_memlimit_moderate(void) return crypto_pwhash_MEMLIMIT_MODERATE; } -size_t +unsigned long long crypto_pwhash_opslimit_sensitive(void) { return crypto_pwhash_OPSLIMIT_SENSITIVE; diff --git a/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c b/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c index b77588fa..6ebc4629 100644 --- a/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c +++ b/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c @@ -105,13 +105,13 @@ crypto_pwhash_scryptsalsa208sha256_strprefix(void) return crypto_pwhash_scryptsalsa208sha256_STRPREFIX; } -size_t +unsigned long long crypto_pwhash_scryptsalsa208sha256_opslimit_min(void) { return crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN; } -size_t +unsigned long long crypto_pwhash_scryptsalsa208sha256_opslimit_max(void) { return crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX; @@ -129,7 +129,7 @@ crypto_pwhash_scryptsalsa208sha256_memlimit_max(void) return crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX; } -size_t +unsigned long long crypto_pwhash_scryptsalsa208sha256_opslimit_interactive(void) { return crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVE; @@ -141,7 +141,7 @@ crypto_pwhash_scryptsalsa208sha256_memlimit_interactive(void) return crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVE; } -size_t +unsigned long long crypto_pwhash_scryptsalsa208sha256_opslimit_sensitive(void) { return crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_SENSITIVE; diff --git a/src/libsodium/include/sodium/crypto_pwhash.h b/src/libsodium/include/sodium/crypto_pwhash.h index 585a993e..bc01d150 100644 --- a/src/libsodium/include/sodium/crypto_pwhash.h +++ b/src/libsodium/include/sodium/crypto_pwhash.h @@ -56,11 +56,11 @@ const char *crypto_pwhash_strprefix(void); #define crypto_pwhash_OPSLIMIT_MIN crypto_pwhash_argon2id_OPSLIMIT_MIN SODIUM_EXPORT -size_t crypto_pwhash_opslimit_min(void); +unsigned long long crypto_pwhash_opslimit_min(void); #define crypto_pwhash_OPSLIMIT_MAX crypto_pwhash_argon2id_OPSLIMIT_MAX SODIUM_EXPORT -size_t crypto_pwhash_opslimit_max(void); +unsigned long long crypto_pwhash_opslimit_max(void); #define crypto_pwhash_MEMLIMIT_MIN crypto_pwhash_argon2id_MEMLIMIT_MIN SODIUM_EXPORT @@ -72,7 +72,7 @@ size_t crypto_pwhash_memlimit_max(void); #define crypto_pwhash_OPSLIMIT_INTERACTIVE crypto_pwhash_argon2id_OPSLIMIT_INTERACTIVE SODIUM_EXPORT -size_t crypto_pwhash_opslimit_interactive(void); +unsigned long long crypto_pwhash_opslimit_interactive(void); #define crypto_pwhash_MEMLIMIT_INTERACTIVE crypto_pwhash_argon2id_MEMLIMIT_INTERACTIVE SODIUM_EXPORT @@ -80,7 +80,7 @@ size_t crypto_pwhash_memlimit_interactive(void); #define crypto_pwhash_OPSLIMIT_MODERATE crypto_pwhash_argon2id_OPSLIMIT_MODERATE SODIUM_EXPORT -size_t crypto_pwhash_opslimit_moderate(void); +unsigned long long crypto_pwhash_opslimit_moderate(void); #define crypto_pwhash_MEMLIMIT_MODERATE crypto_pwhash_argon2id_MEMLIMIT_MODERATE SODIUM_EXPORT @@ -88,7 +88,7 @@ size_t crypto_pwhash_memlimit_moderate(void); #define crypto_pwhash_OPSLIMIT_SENSITIVE crypto_pwhash_argon2id_OPSLIMIT_SENSITIVE SODIUM_EXPORT -size_t crypto_pwhash_opslimit_sensitive(void); +unsigned long long crypto_pwhash_opslimit_sensitive(void); #define crypto_pwhash_MEMLIMIT_SENSITIVE crypto_pwhash_argon2id_MEMLIMIT_SENSITIVE SODIUM_EXPORT diff --git a/src/libsodium/include/sodium/crypto_pwhash_argon2i.h b/src/libsodium/include/sodium/crypto_pwhash_argon2i.h index 88ff6221..53e76148 100644 --- a/src/libsodium/include/sodium/crypto_pwhash_argon2i.h +++ b/src/libsodium/include/sodium/crypto_pwhash_argon2i.h @@ -48,11 +48,11 @@ const char *crypto_pwhash_argon2i_strprefix(void); #define crypto_pwhash_argon2i_OPSLIMIT_MIN 3U SODIUM_EXPORT -size_t crypto_pwhash_argon2i_opslimit_min(void); +unsigned long long crypto_pwhash_argon2i_opslimit_min(void); #define crypto_pwhash_argon2i_OPSLIMIT_MAX 4294967295U SODIUM_EXPORT -size_t crypto_pwhash_argon2i_opslimit_max(void); +unsigned long long crypto_pwhash_argon2i_opslimit_max(void); #define crypto_pwhash_argon2i_MEMLIMIT_MIN 8192U SODIUM_EXPORT @@ -65,7 +65,7 @@ size_t crypto_pwhash_argon2i_memlimit_max(void); #define crypto_pwhash_argon2i_OPSLIMIT_INTERACTIVE 4U SODIUM_EXPORT -size_t crypto_pwhash_argon2i_opslimit_interactive(void); +unsigned long long crypto_pwhash_argon2i_opslimit_interactive(void); #define crypto_pwhash_argon2i_MEMLIMIT_INTERACTIVE 33554432U SODIUM_EXPORT @@ -73,7 +73,7 @@ size_t crypto_pwhash_argon2i_memlimit_interactive(void); #define crypto_pwhash_argon2i_OPSLIMIT_MODERATE 6U SODIUM_EXPORT -size_t crypto_pwhash_argon2i_opslimit_moderate(void); +unsigned long long crypto_pwhash_argon2i_opslimit_moderate(void); #define crypto_pwhash_argon2i_MEMLIMIT_MODERATE 134217728U SODIUM_EXPORT @@ -81,7 +81,7 @@ size_t crypto_pwhash_argon2i_memlimit_moderate(void); #define crypto_pwhash_argon2i_OPSLIMIT_SENSITIVE 8U SODIUM_EXPORT -size_t crypto_pwhash_argon2i_opslimit_sensitive(void); +unsigned long long crypto_pwhash_argon2i_opslimit_sensitive(void); #define crypto_pwhash_argon2i_MEMLIMIT_SENSITIVE 536870912U SODIUM_EXPORT diff --git a/src/libsodium/include/sodium/crypto_pwhash_argon2id.h b/src/libsodium/include/sodium/crypto_pwhash_argon2id.h index 7183abd1..7cb651a4 100644 --- a/src/libsodium/include/sodium/crypto_pwhash_argon2id.h +++ b/src/libsodium/include/sodium/crypto_pwhash_argon2id.h @@ -48,11 +48,11 @@ const char *crypto_pwhash_argon2id_strprefix(void); #define crypto_pwhash_argon2id_OPSLIMIT_MIN 1U SODIUM_EXPORT -size_t crypto_pwhash_argon2id_opslimit_min(void); +unsigned long long crypto_pwhash_argon2id_opslimit_min(void); #define crypto_pwhash_argon2id_OPSLIMIT_MAX 4294967295U SODIUM_EXPORT -size_t crypto_pwhash_argon2id_opslimit_max(void); +unsigned long long crypto_pwhash_argon2id_opslimit_max(void); #define crypto_pwhash_argon2id_MEMLIMIT_MIN 8192U SODIUM_EXPORT @@ -65,7 +65,7 @@ size_t crypto_pwhash_argon2id_memlimit_max(void); #define crypto_pwhash_argon2id_OPSLIMIT_INTERACTIVE 2U SODIUM_EXPORT -size_t crypto_pwhash_argon2id_opslimit_interactive(void); +unsigned long long crypto_pwhash_argon2id_opslimit_interactive(void); #define crypto_pwhash_argon2id_MEMLIMIT_INTERACTIVE 67108864U SODIUM_EXPORT @@ -73,7 +73,7 @@ size_t crypto_pwhash_argon2id_memlimit_interactive(void); #define crypto_pwhash_argon2id_OPSLIMIT_MODERATE 3U SODIUM_EXPORT -size_t crypto_pwhash_argon2id_opslimit_moderate(void); +unsigned long long crypto_pwhash_argon2id_opslimit_moderate(void); #define crypto_pwhash_argon2id_MEMLIMIT_MODERATE 268435456U SODIUM_EXPORT @@ -81,7 +81,7 @@ size_t crypto_pwhash_argon2id_memlimit_moderate(void); #define crypto_pwhash_argon2id_OPSLIMIT_SENSITIVE 4U SODIUM_EXPORT -size_t crypto_pwhash_argon2id_opslimit_sensitive(void); +unsigned long long crypto_pwhash_argon2id_opslimit_sensitive(void); #define crypto_pwhash_argon2id_MEMLIMIT_SENSITIVE 1073741824U SODIUM_EXPORT diff --git a/src/libsodium/include/sodium/crypto_pwhash_scryptsalsa208sha256.h b/src/libsodium/include/sodium/crypto_pwhash_scryptsalsa208sha256.h index 5c0bf7d3..db6c0cca 100644 --- a/src/libsodium/include/sodium/crypto_pwhash_scryptsalsa208sha256.h +++ b/src/libsodium/include/sodium/crypto_pwhash_scryptsalsa208sha256.h @@ -45,11 +45,11 @@ const char *crypto_pwhash_scryptsalsa208sha256_strprefix(void); #define crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN 32768U SODIUM_EXPORT -size_t crypto_pwhash_scryptsalsa208sha256_opslimit_min(void); +unsigned long long crypto_pwhash_scryptsalsa208sha256_opslimit_min(void); #define crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX 4294967295U SODIUM_EXPORT -size_t crypto_pwhash_scryptsalsa208sha256_opslimit_max(void); +unsigned long long crypto_pwhash_scryptsalsa208sha256_opslimit_max(void); #define crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN 16777216U SODIUM_EXPORT @@ -62,7 +62,7 @@ size_t crypto_pwhash_scryptsalsa208sha256_memlimit_max(void); #define crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVE 524288U SODIUM_EXPORT -size_t crypto_pwhash_scryptsalsa208sha256_opslimit_interactive(void); +unsigned long long crypto_pwhash_scryptsalsa208sha256_opslimit_interactive(void); #define crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVE 16777216U SODIUM_EXPORT @@ -70,7 +70,7 @@ size_t crypto_pwhash_scryptsalsa208sha256_memlimit_interactive(void); #define crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_SENSITIVE 33554432U SODIUM_EXPORT -size_t crypto_pwhash_scryptsalsa208sha256_opslimit_sensitive(void); +unsigned long long crypto_pwhash_scryptsalsa208sha256_opslimit_sensitive(void); #define crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_SENSITIVE 1073741824U SODIUM_EXPORT From a8fa837aacd310bc08fa72705a738fafc2513125 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Thu, 4 Jun 2020 10:40:25 +0200 Subject: [PATCH 2/2] Don't even include signal.h on WASI Since version 11, wasi-sysroot doesn't ignore it but spits out an error instead. --- azure-pipelines.yml | 2 +- src/libsodium/sodium/utils.c | 5 ++++- test/default/sodium_utils2.c | 4 +++- test/default/sodium_utils3.c | 4 +++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 693569fe..bbc4d55c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -16,7 +16,7 @@ jobs: curl https://get.wasmer.io -sSfL | sh displayName: Install wasmer - script: | - curl -sL -o - https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-10/wasi-sdk-10.0-linux.tar.gz | tar xz -f - -C /opt/ + curl -sL -o - https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-11/wasi-sdk-11.0-linux.tar.gz | tar xz -f - -C /opt/ sudo mv /opt/wasi-sdk-* /opt/wasi-sdk sudo ln -s /opt/wasi-sdk/share/*sysroot* /opt/wasi-sysroot displayName: Install the WASI SDK diff --git a/src/libsodium/sodium/utils.c b/src/libsodium/sodium/utils.c index 0604b284..3c2de173 100644 --- a/src/libsodium/sodium/utils.c +++ b/src/libsodium/sodium/utils.c @@ -4,12 +4,15 @@ #include #include #include -#include #include #include #include #include +#ifndef __wasm__ +# include +#endif + #ifdef HAVE_SYS_MMAN_H # include #endif diff --git a/test/default/sodium_utils2.c b/test/default/sodium_utils2.c index e2cccc8b..7f336687 100644 --- a/test/default/sodium_utils2.c +++ b/test/default/sodium_utils2.c @@ -3,7 +3,9 @@ #include #include -#include +#ifdef HAVE_CATCHABLE_SEGV +# include +#endif #define TEST_NAME "sodium_utils2" #include "cmptest.h" diff --git a/test/default/sodium_utils3.c b/test/default/sodium_utils3.c index a39f0ee4..3bba037a 100644 --- a/test/default/sodium_utils3.c +++ b/test/default/sodium_utils3.c @@ -3,7 +3,9 @@ #include #include -#include +#ifdef HAVE_CATCHABLE_SEGV +# include +#endif #define TEST_NAME "sodium_utils3" #include "cmptest.h"