summaryrefslogtreecommitdiff
path: root/libs/libsodium/src/include
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-06-21 14:29:17 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-06-21 14:29:17 +0300
commit46ea86584a9787c8b9dc3983cf23d9b5b93b5841 (patch)
treefbaf3793ae2170f7982f08a62c028a23cd9afedd /libs/libsodium/src/include
parent82e75be329dd0f30c0281ef9c3c08488b89d109f (diff)
fixes #4477 (libsodium: update to 1.0.20)
Diffstat (limited to 'libs/libsodium/src/include')
-rw-r--r--libs/libsodium/src/include/Makefile.am16
-rw-r--r--libs/libsodium/src/include/sodium.h13
-rw-r--r--libs/libsodium/src/include/sodium/crypto_aead_aegis128l.h92
-rw-r--r--libs/libsodium/src/include/sodium/crypto_aead_aegis256.h92
-rw-r--r--libs/libsodium/src/include/sodium/crypto_aead_aes256gcm.h2
-rw-r--r--libs/libsodium/src/include/sodium/crypto_aead_xchacha20poly1305.h2
-rw-r--r--libs/libsodium/src/include/sodium/crypto_auth.h4
-rw-r--r--libs/libsodium/src/include/sodium/crypto_auth_hmacsha256.h6
-rw-r--r--libs/libsodium/src/include/sodium/crypto_auth_hmacsha512.h6
-rw-r--r--libs/libsodium/src/include/sodium/crypto_auth_hmacsha512256.h10
-rw-r--r--libs/libsodium/src/include/sodium/crypto_box.h22
-rw-r--r--libs/libsodium/src/include/sodium/crypto_box_curve25519xchacha20poly1305.h10
-rw-r--r--libs/libsodium/src/include/sodium/crypto_box_curve25519xsalsa20poly1305.h11
-rw-r--r--libs/libsodium/src/include/sodium/crypto_core_ed25519.h32
-rw-r--r--libs/libsodium/src/include/sodium/crypto_core_ristretto255.h121
-rw-r--r--libs/libsodium/src/include/sodium/crypto_generichash.h2
-rw-r--r--libs/libsodium/src/include/sodium/crypto_generichash_blake2b.h10
-rw-r--r--libs/libsodium/src/include/sodium/crypto_hash.h4
-rw-r--r--libs/libsodium/src/include/sodium/crypto_hash_sha256.h6
-rw-r--r--libs/libsodium/src/include/sodium/crypto_hash_sha512.h6
-rw-r--r--libs/libsodium/src/include/sodium/crypto_kdf_blake2b.h2
-rw-r--r--libs/libsodium/src/include/sodium/crypto_kdf_hkdf_sha256.h74
-rw-r--r--libs/libsodium/src/include/sodium/crypto_kdf_hkdf_sha512.h75
-rw-r--r--libs/libsodium/src/include/sodium/crypto_onetimeauth.h6
-rw-r--r--libs/libsodium/src/include/sodium/crypto_onetimeauth_poly1305.h20
-rw-r--r--libs/libsodium/src/include/sodium/crypto_pwhash.h16
-rw-r--r--libs/libsodium/src/include/sodium/crypto_pwhash_argon2i.h14
-rw-r--r--libs/libsodium/src/include/sodium/crypto_pwhash_argon2id.h14
-rw-r--r--libs/libsodium/src/include/sodium/crypto_pwhash_scryptsalsa208sha256.h12
-rw-r--r--libs/libsodium/src/include/sodium/crypto_scalarmult.h2
-rw-r--r--libs/libsodium/src/include/sodium/crypto_scalarmult_curve25519.h2
-rw-r--r--libs/libsodium/src/include/sodium/crypto_scalarmult_ed25519.h2
-rw-r--r--libs/libsodium/src/include/sodium/crypto_scalarmult_ristretto255.h43
-rw-r--r--libs/libsodium/src/include/sodium/crypto_secretbox.h13
-rw-r--r--libs/libsodium/src/include/sodium/crypto_secretbox_xchacha20poly1305.h4
-rw-r--r--libs/libsodium/src/include/sodium/crypto_secretbox_xsalsa20poly1305.h38
-rw-r--r--libs/libsodium/src/include/sodium/crypto_shorthash.h2
-rw-r--r--libs/libsodium/src/include/sodium/crypto_shorthash_siphash24.h4
-rw-r--r--libs/libsodium/src/include/sodium/crypto_sign.h8
-rw-r--r--libs/libsodium/src/include/sodium/crypto_sign_ed25519.h10
-rw-r--r--libs/libsodium/src/include/sodium/crypto_sign_edwards25519sha512batch.h55
-rw-r--r--libs/libsodium/src/include/sodium/crypto_vrf.h75
-rw-r--r--libs/libsodium/src/include/sodium/crypto_vrf_rfc9381.h78
-rw-r--r--libs/libsodium/src/include/sodium/private/asm_cet.h11
-rw-r--r--libs/libsodium/src/include/sodium/private/chacha20_ietf_ext.h2
-rw-r--r--libs/libsodium/src/include/sodium/private/common.h60
-rw-r--r--libs/libsodium/src/include/sodium/private/ed25519_ref10.h45
-rw-r--r--libs/libsodium/src/include/sodium/private/ed25519_ref10_fe_25_5.h154
-rw-r--r--libs/libsodium/src/include/sodium/private/ed25519_ref10_fe_51.h309
-rw-r--r--libs/libsodium/src/include/sodium/private/implementations.h4
-rw-r--r--libs/libsodium/src/include/sodium/private/mutex.h2
-rw-r--r--libs/libsodium/src/include/sodium/private/quirks.h87
-rw-r--r--libs/libsodium/src/include/sodium/private/softaes.h56
-rw-r--r--libs/libsodium/src/include/sodium/private/sse2_64_32.h4
-rw-r--r--libs/libsodium/src/include/sodium/randombytes.h2
-rw-r--r--libs/libsodium/src/include/sodium/randombytes_internal_random.h22
-rw-r--r--libs/libsodium/src/include/sodium/randombytes_nativeclient.h23
-rw-r--r--libs/libsodium/src/include/sodium/randombytes_salsa20_random.h19
-rw-r--r--libs/libsodium/src/include/sodium/runtime.h3
-rw-r--r--libs/libsodium/src/include/sodium/utils.h23
-rw-r--r--libs/libsodium/src/include/sodium/version.h7
-rw-r--r--libs/libsodium/src/include/sodium/version.h.in33
62 files changed, 1377 insertions, 525 deletions
diff --git a/libs/libsodium/src/include/Makefile.am b/libs/libsodium/src/include/Makefile.am
index 0e1ed2634c..d1ea666cb6 100644
--- a/libs/libsodium/src/include/Makefile.am
+++ b/libs/libsodium/src/include/Makefile.am
@@ -3,6 +3,8 @@ SODIUM_EXPORT = \
sodium.h \
sodium/core.h \
sodium/crypto_aead_aes256gcm.h \
+ sodium/crypto_aead_aegis128l.h \
+ sodium/crypto_aead_aegis256.h \
sodium/crypto_aead_chacha20poly1305.h \
sodium/crypto_aead_xchacha20poly1305.h \
sodium/crypto_auth.h \
@@ -13,6 +15,7 @@ SODIUM_EXPORT = \
sodium/crypto_box_curve25519xchacha20poly1305.h \
sodium/crypto_box_curve25519xsalsa20poly1305.h \
sodium/crypto_core_ed25519.h \
+ sodium/crypto_core_ristretto255.h \
sodium/crypto_core_hchacha20.h \
sodium/crypto_core_hsalsa20.h \
sodium/crypto_core_salsa20.h \
@@ -25,6 +28,8 @@ SODIUM_EXPORT = \
sodium/crypto_hash_sha512.h \
sodium/crypto_kdf.h \
sodium/crypto_kdf_blake2b.h \
+ sodium/crypto_kdf_hkdf_sha256.h \
+ sodium/crypto_kdf_hkdf_sha512.h \
sodium/crypto_kx.h \
sodium/crypto_onetimeauth.h \
sodium/crypto_onetimeauth_poly1305.h \
@@ -35,6 +40,7 @@ SODIUM_EXPORT = \
sodium/crypto_scalarmult.h \
sodium/crypto_scalarmult_curve25519.h \
sodium/crypto_scalarmult_ed25519.h \
+ sodium/crypto_scalarmult_ristretto255.h \
sodium/crypto_secretbox.h \
sodium/crypto_secretbox_xchacha20poly1305.h \
sodium/crypto_secretbox_xsalsa20poly1305.h \
@@ -43,7 +49,6 @@ SODIUM_EXPORT = \
sodium/crypto_shorthash_siphash24.h \
sodium/crypto_sign.h \
sodium/crypto_sign_ed25519.h \
- sodium/crypto_sign_edwards25519sha512batch.h \
sodium/crypto_stream.h \
sodium/crypto_stream_chacha20.h \
sodium/crypto_stream_salsa20.h \
@@ -54,18 +59,15 @@ SODIUM_EXPORT = \
sodium/crypto_verify_16.h \
sodium/crypto_verify_32.h \
sodium/crypto_verify_64.h \
+ sodium/crypto_vrf.h \
+ sodium/crypto_vrf_rfc9381.h \
sodium/export.h \
sodium/randombytes.h \
- sodium/randombytes_salsa20_random.h \
+ sodium/randombytes_internal_random.h \
sodium/randombytes_sysrandom.h \
sodium/runtime.h \
sodium/utils.h
-if NATIVECLIENT
-SODIUM_EXPORT += \
- sodium/randombytes_nativeclient.h
-endif
-
EXTRA_SRC = $(SODIUM_EXPORT) \
sodium/version.h.in
diff --git a/libs/libsodium/src/include/sodium.h b/libs/libsodium/src/include/sodium.h
index 3cd9b5b79a..a47300c36f 100644
--- a/libs/libsodium/src/include/sodium.h
+++ b/libs/libsodium/src/include/sodium.h
@@ -6,6 +6,8 @@
#include "sodium/core.h"
#include "sodium/crypto_aead_aes256gcm.h"
+#include "sodium/crypto_aead_aegis128l.h"
+#include "sodium/crypto_aead_aegis256.h"
#include "sodium/crypto_aead_chacha20poly1305.h"
#include "sodium/crypto_aead_xchacha20poly1305.h"
#include "sodium/crypto_auth.h"
@@ -25,6 +27,8 @@
#include "sodium/crypto_hash_sha256.h"
#include "sodium/crypto_hash_sha512.h"
#include "sodium/crypto_kdf.h"
+#include "sodium/crypto_kdf_hkdf_sha256.h"
+#include "sodium/crypto_kdf_hkdf_sha512.h"
#include "sodium/crypto_kdf_blake2b.h"
#include "sodium/crypto_kx.h"
#include "sodium/crypto_onetimeauth.h"
@@ -47,11 +51,10 @@
#include "sodium/crypto_verify_16.h"
#include "sodium/crypto_verify_32.h"
#include "sodium/crypto_verify_64.h"
+#include "sodium/crypto_vrf.h"
+#include "sodium/crypto_vrf_rfc9381.h"
#include "sodium/randombytes.h"
-#ifdef __native_client__
-# include "sodium/randombytes_nativeclient.h"
-#endif
-#include "sodium/randombytes_salsa20_random.h"
+#include "sodium/randombytes_internal_random.h"
#include "sodium/randombytes_sysrandom.h"
#include "sodium/runtime.h"
#include "sodium/utils.h"
@@ -59,7 +62,9 @@
#ifndef SODIUM_LIBRARY_MINIMAL
# include "sodium/crypto_box_curve25519xchacha20poly1305.h"
# include "sodium/crypto_core_ed25519.h"
+# include "sodium/crypto_core_ristretto255.h"
# include "sodium/crypto_scalarmult_ed25519.h"
+# include "sodium/crypto_scalarmult_ristretto255.h"
# include "sodium/crypto_secretbox_xchacha20poly1305.h"
# include "sodium/crypto_pwhash_scryptsalsa208sha256.h"
# include "sodium/crypto_stream_salsa2012.h"
diff --git a/libs/libsodium/src/include/sodium/crypto_aead_aegis128l.h b/libs/libsodium/src/include/sodium/crypto_aead_aegis128l.h
new file mode 100644
index 0000000000..0ad019fc94
--- /dev/null
+++ b/libs/libsodium/src/include/sodium/crypto_aead_aegis128l.h
@@ -0,0 +1,92 @@
+#ifndef crypto_aead_aegis128l_H
+#define crypto_aead_aegis128l_H
+
+#include <stddef.h>
+
+#include "export.h"
+
+#ifdef __cplusplus
+#ifdef __GNUC__
+#pragma GCC diagnostic ignored "-Wlong-long"
+#endif
+extern "C" {
+#endif
+
+#define crypto_aead_aegis128l_KEYBYTES 16U
+SODIUM_EXPORT
+size_t crypto_aead_aegis128l_keybytes(void);
+
+#define crypto_aead_aegis128l_NSECBYTES 0U
+SODIUM_EXPORT
+size_t crypto_aead_aegis128l_nsecbytes(void);
+
+#define crypto_aead_aegis128l_NPUBBYTES 16U
+SODIUM_EXPORT
+size_t crypto_aead_aegis128l_npubbytes(void);
+
+#define crypto_aead_aegis128l_ABYTES 32U
+SODIUM_EXPORT
+size_t crypto_aead_aegis128l_abytes(void);
+
+#define crypto_aead_aegis128l_MESSAGEBYTES_MAX \
+ SODIUM_MIN(SODIUM_SIZE_MAX - crypto_aead_aegis128l_ABYTES, (1ULL << 61) - 1)
+SODIUM_EXPORT
+size_t crypto_aead_aegis128l_messagebytes_max(void);
+
+SODIUM_EXPORT
+int crypto_aead_aegis128l_encrypt(unsigned char *c,
+ unsigned long long *clen_p,
+ const unsigned char *m,
+ unsigned long long mlen,
+ const unsigned char *ad,
+ unsigned long long adlen,
+ const unsigned char *nsec,
+ const unsigned char *npub,
+ const unsigned char *k) __attribute__((nonnull(1, 8, 9)));
+
+SODIUM_EXPORT
+int crypto_aead_aegis128l_decrypt(unsigned char *m,
+ unsigned long long *mlen_p,
+ unsigned char *nsec,
+ const unsigned char *c,
+ unsigned long long clen,
+ const unsigned char *ad,
+ unsigned long long adlen,
+ const unsigned char *npub,
+ const unsigned char *k) __attribute__((warn_unused_result))
+__attribute__((nonnull(4, 8, 9)));
+
+SODIUM_EXPORT
+int crypto_aead_aegis128l_encrypt_detached(unsigned char *c,
+ unsigned char *mac,
+ unsigned long long *maclen_p,
+ const unsigned char *m,
+ unsigned long long mlen,
+ const unsigned char *ad,
+ unsigned long long adlen,
+ const unsigned char *nsec,
+ const unsigned char *npub,
+ const unsigned char *k)
+ __attribute__((nonnull(1, 2, 9, 10)));
+
+SODIUM_EXPORT
+int crypto_aead_aegis128l_decrypt_detached(unsigned char *m,
+ unsigned char *nsec,
+ const unsigned char *c,
+ unsigned long long clen,
+ const unsigned char *mac,
+ const unsigned char *ad,
+ unsigned long long adlen,
+ const unsigned char *npub,
+ const unsigned char *k)
+ __attribute__((warn_unused_result)) __attribute__((nonnull(3, 5, 8, 9)));
+
+SODIUM_EXPORT
+void crypto_aead_aegis128l_keygen(unsigned char k[crypto_aead_aegis128l_KEYBYTES])
+ __attribute__((nonnull));
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libs/libsodium/src/include/sodium/crypto_aead_aegis256.h b/libs/libsodium/src/include/sodium/crypto_aead_aegis256.h
new file mode 100644
index 0000000000..26bd18ace1
--- /dev/null
+++ b/libs/libsodium/src/include/sodium/crypto_aead_aegis256.h
@@ -0,0 +1,92 @@
+#ifndef crypto_aead_aegis256_H
+#define crypto_aead_aegis256_H
+
+#include <stddef.h>
+
+#include "export.h"
+
+#ifdef __cplusplus
+#ifdef __GNUC__
+#pragma GCC diagnostic ignored "-Wlong-long"
+#endif
+extern "C" {
+#endif
+
+#define crypto_aead_aegis256_KEYBYTES 32U
+SODIUM_EXPORT
+size_t crypto_aead_aegis256_keybytes(void);
+
+#define crypto_aead_aegis256_NSECBYTES 0U
+SODIUM_EXPORT
+size_t crypto_aead_aegis256_nsecbytes(void);
+
+#define crypto_aead_aegis256_NPUBBYTES 32U
+SODIUM_EXPORT
+size_t crypto_aead_aegis256_npubbytes(void);
+
+#define crypto_aead_aegis256_ABYTES 32U
+SODIUM_EXPORT
+size_t crypto_aead_aegis256_abytes(void);
+
+#define crypto_aead_aegis256_MESSAGEBYTES_MAX \
+ SODIUM_MIN(SODIUM_SIZE_MAX - crypto_aead_aegis256_ABYTES, (1ULL << 61) - 1)
+SODIUM_EXPORT
+size_t crypto_aead_aegis256_messagebytes_max(void);
+
+SODIUM_EXPORT
+int crypto_aead_aegis256_encrypt(unsigned char *c,
+ unsigned long long *clen_p,
+ const unsigned char *m,
+ unsigned long long mlen,
+ const unsigned char *ad,
+ unsigned long long adlen,
+ const unsigned char *nsec,
+ const unsigned char *npub,
+ const unsigned char *k) __attribute__((nonnull(1, 8, 9)));
+
+SODIUM_EXPORT
+int crypto_aead_aegis256_decrypt(unsigned char *m,
+ unsigned long long *mlen_p,
+ unsigned char *nsec,
+ const unsigned char *c,
+ unsigned long long clen,
+ const unsigned char *ad,
+ unsigned long long adlen,
+ const unsigned char *npub,
+ const unsigned char *k) __attribute__((warn_unused_result))
+__attribute__((nonnull(4, 8, 9)));
+
+SODIUM_EXPORT
+int crypto_aead_aegis256_encrypt_detached(unsigned char *c,
+ unsigned char *mac,
+ unsigned long long *maclen_p,
+ const unsigned char *m,
+ unsigned long long mlen,
+ const unsigned char *ad,
+ unsigned long long adlen,
+ const unsigned char *nsec,
+ const unsigned char *npub,
+ const unsigned char *k)
+ __attribute__((nonnull(1, 2, 9, 10)));
+
+SODIUM_EXPORT
+int crypto_aead_aegis256_decrypt_detached(unsigned char *m,
+ unsigned char *nsec,
+ const unsigned char *c,
+ unsigned long long clen,
+ const unsigned char *mac,
+ const unsigned char *ad,
+ unsigned long long adlen,
+ const unsigned char *npub,
+ const unsigned char *k)
+ __attribute__((warn_unused_result)) __attribute__((nonnull(3, 5, 8, 9)));
+
+SODIUM_EXPORT
+void crypto_aead_aegis256_keygen(unsigned char k[crypto_aead_aegis256_KEYBYTES])
+ __attribute__((nonnull));
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libs/libsodium/src/include/sodium/crypto_aead_aes256gcm.h b/libs/libsodium/src/include/sodium/crypto_aead_aes256gcm.h
index 47c32b06df..78b6138240 100644
--- a/libs/libsodium/src/include/sodium/crypto_aead_aes256gcm.h
+++ b/libs/libsodium/src/include/sodium/crypto_aead_aes256gcm.h
@@ -56,7 +56,7 @@ size_t crypto_aead_aes256gcm_abytes(void);
SODIUM_EXPORT
size_t crypto_aead_aes256gcm_messagebytes_max(void);
-typedef CRYPTO_ALIGN(16) struct crypto_aead_aes256gcm_state_ {
+typedef struct CRYPTO_ALIGN(16) crypto_aead_aes256gcm_state_ {
unsigned char opaque[512];
} crypto_aead_aes256gcm_state;
diff --git a/libs/libsodium/src/include/sodium/crypto_aead_xchacha20poly1305.h b/libs/libsodium/src/include/sodium/crypto_aead_xchacha20poly1305.h
index 5e2eb5bb61..e179543517 100644
--- a/libs/libsodium/src/include/sodium/crypto_aead_xchacha20poly1305.h
+++ b/libs/libsodium/src/include/sodium/crypto_aead_xchacha20poly1305.h
@@ -79,7 +79,7 @@ int crypto_aead_xchacha20poly1305_ietf_decrypt_detached(unsigned char *m,
unsigned long long adlen,
const unsigned char *npub,
const unsigned char *k)
- __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 5, 9, 9)));
+ __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 5, 8, 9)));
SODIUM_EXPORT
void crypto_aead_xchacha20poly1305_ietf_keygen(unsigned char k[crypto_aead_xchacha20poly1305_ietf_KEYBYTES])
diff --git a/libs/libsodium/src/include/sodium/crypto_auth.h b/libs/libsodium/src/include/sodium/crypto_auth.h
index 44e8f7e91a..e98f8a3bf7 100644
--- a/libs/libsodium/src/include/sodium/crypto_auth.h
+++ b/libs/libsodium/src/include/sodium/crypto_auth.h
@@ -28,12 +28,12 @@ const char *crypto_auth_primitive(void);
SODIUM_EXPORT
int crypto_auth(unsigned char *out, const unsigned char *in,
unsigned long long inlen, const unsigned char *k)
- __attribute__ ((nonnull));
+ __attribute__ ((nonnull(1, 4)));
SODIUM_EXPORT
int crypto_auth_verify(const unsigned char *h, const unsigned char *in,
unsigned long long inlen, const unsigned char *k)
- __attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
+ __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4)));
SODIUM_EXPORT
void crypto_auth_keygen(unsigned char k[crypto_auth_KEYBYTES])
diff --git a/libs/libsodium/src/include/sodium/crypto_auth_hmacsha256.h b/libs/libsodium/src/include/sodium/crypto_auth_hmacsha256.h
index 7c3959cb52..07e63d9a19 100644
--- a/libs/libsodium/src/include/sodium/crypto_auth_hmacsha256.h
+++ b/libs/libsodium/src/include/sodium/crypto_auth_hmacsha256.h
@@ -24,14 +24,14 @@ SODIUM_EXPORT
int crypto_auth_hmacsha256(unsigned char *out,
const unsigned char *in,
unsigned long long inlen,
- const unsigned char *k) __attribute__ ((nonnull));
+ const unsigned char *k) __attribute__ ((nonnull(1, 4)));
SODIUM_EXPORT
int crypto_auth_hmacsha256_verify(const unsigned char *h,
const unsigned char *in,
unsigned long long inlen,
const unsigned char *k)
- __attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
+ __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4)));
/* ------------------------------------------------------------------------- */
@@ -52,7 +52,7 @@ SODIUM_EXPORT
int crypto_auth_hmacsha256_update(crypto_auth_hmacsha256_state *state,
const unsigned char *in,
unsigned long long inlen)
- __attribute__ ((nonnull));
+ __attribute__ ((nonnull(1)));
SODIUM_EXPORT
int crypto_auth_hmacsha256_final(crypto_auth_hmacsha256_state *state,
diff --git a/libs/libsodium/src/include/sodium/crypto_auth_hmacsha512.h b/libs/libsodium/src/include/sodium/crypto_auth_hmacsha512.h
index fe49556329..c3b3e7176c 100644
--- a/libs/libsodium/src/include/sodium/crypto_auth_hmacsha512.h
+++ b/libs/libsodium/src/include/sodium/crypto_auth_hmacsha512.h
@@ -24,14 +24,14 @@ SODIUM_EXPORT
int crypto_auth_hmacsha512(unsigned char *out,
const unsigned char *in,
unsigned long long inlen,
- const unsigned char *k) __attribute__ ((nonnull));
+ const unsigned char *k) __attribute__ ((nonnull(1, 4)));
SODIUM_EXPORT
int crypto_auth_hmacsha512_verify(const unsigned char *h,
const unsigned char *in,
unsigned long long inlen,
const unsigned char *k)
- __attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
+ __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4)));
/* ------------------------------------------------------------------------- */
@@ -51,7 +51,7 @@ int crypto_auth_hmacsha512_init(crypto_auth_hmacsha512_state *state,
SODIUM_EXPORT
int crypto_auth_hmacsha512_update(crypto_auth_hmacsha512_state *state,
const unsigned char *in,
- unsigned long long inlen) __attribute__ ((nonnull));
+ unsigned long long inlen) __attribute__ ((nonnull(1)));
SODIUM_EXPORT
int crypto_auth_hmacsha512_final(crypto_auth_hmacsha512_state *state,
diff --git a/libs/libsodium/src/include/sodium/crypto_auth_hmacsha512256.h b/libs/libsodium/src/include/sodium/crypto_auth_hmacsha512256.h
index 8754baa142..a7752f152a 100644
--- a/libs/libsodium/src/include/sodium/crypto_auth_hmacsha512256.h
+++ b/libs/libsodium/src/include/sodium/crypto_auth_hmacsha512256.h
@@ -21,15 +21,17 @@ SODIUM_EXPORT
size_t crypto_auth_hmacsha512256_keybytes(void);
SODIUM_EXPORT
-int crypto_auth_hmacsha512256(unsigned char *out, const unsigned char *in,
- unsigned long long inlen,const unsigned char *k);
+int crypto_auth_hmacsha512256(unsigned char *out,
+ const unsigned char *in,
+ unsigned long long inlen,
+ const unsigned char *k) __attribute__ ((nonnull(1, 4)));
SODIUM_EXPORT
int crypto_auth_hmacsha512256_verify(const unsigned char *h,
const unsigned char *in,
unsigned long long inlen,
const unsigned char *k)
- __attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
+ __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4)));
/* ------------------------------------------------------------------------- */
@@ -46,7 +48,7 @@ int crypto_auth_hmacsha512256_init(crypto_auth_hmacsha512256_state *state,
SODIUM_EXPORT
int crypto_auth_hmacsha512256_update(crypto_auth_hmacsha512256_state *state,
const unsigned char *in,
- unsigned long long inlen) __attribute__ ((nonnull));
+ unsigned long long inlen) __attribute__ ((nonnull(1)));
SODIUM_EXPORT
int crypto_auth_hmacsha512256_final(crypto_auth_hmacsha512256_state *state,
diff --git a/libs/libsodium/src/include/sodium/crypto_box.h b/libs/libsodium/src/include/sodium/crypto_box.h
index 33787e9d8d..8f7835f184 100644
--- a/libs/libsodium/src/include/sodium/crypto_box.h
+++ b/libs/libsodium/src/include/sodium/crypto_box.h
@@ -61,7 +61,7 @@ SODIUM_EXPORT
int crypto_box_easy(unsigned char *c, const unsigned char *m,
unsigned long long mlen, const unsigned char *n,
const unsigned char *pk, const unsigned char *sk)
- __attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
+ __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4, 5, 6)));
SODIUM_EXPORT
int crypto_box_open_easy(unsigned char *m, const unsigned char *c,
@@ -74,7 +74,7 @@ int crypto_box_detached(unsigned char *c, unsigned char *mac,
const unsigned char *m, unsigned long long mlen,
const unsigned char *n, const unsigned char *pk,
const unsigned char *sk)
- __attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
+ __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 2, 5, 6, 7)));
SODIUM_EXPORT
int crypto_box_open_detached(unsigned char *m, const unsigned char *c,
@@ -99,7 +99,7 @@ int crypto_box_beforenm(unsigned char *k, const unsigned char *pk,
SODIUM_EXPORT
int crypto_box_easy_afternm(unsigned char *c, const unsigned char *m,
unsigned long long mlen, const unsigned char *n,
- const unsigned char *k) __attribute__ ((nonnull));
+ const unsigned char *k) __attribute__ ((nonnull(1, 4, 5)));
SODIUM_EXPORT
int crypto_box_open_easy_afternm(unsigned char *m, const unsigned char *c,
@@ -111,7 +111,7 @@ SODIUM_EXPORT
int crypto_box_detached_afternm(unsigned char *c, unsigned char *mac,
const unsigned char *m, unsigned long long mlen,
const unsigned char *n, const unsigned char *k)
- __attribute__ ((nonnull));
+ __attribute__ ((nonnull(1, 2, 5, 6)));
SODIUM_EXPORT
int crypto_box_open_detached_afternm(unsigned char *m, const unsigned char *c,
@@ -129,7 +129,7 @@ size_t crypto_box_sealbytes(void);
SODIUM_EXPORT
int crypto_box_seal(unsigned char *c, const unsigned char *m,
unsigned long long mlen, const unsigned char *pk)
- __attribute__ ((nonnull));
+ __attribute__ ((nonnull(1, 4)));
SODIUM_EXPORT
int crypto_box_seal_open(unsigned char *m, const unsigned char *c,
@@ -141,34 +141,34 @@ int crypto_box_seal_open(unsigned char *m, const unsigned char *c,
#define crypto_box_ZEROBYTES crypto_box_curve25519xsalsa20poly1305_ZEROBYTES
SODIUM_EXPORT
-size_t crypto_box_zerobytes(void);
+size_t crypto_box_zerobytes(void) __attribute__ ((deprecated));
#define crypto_box_BOXZEROBYTES crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES
SODIUM_EXPORT
-size_t crypto_box_boxzerobytes(void);
+size_t crypto_box_boxzerobytes(void) __attribute__ ((deprecated));
SODIUM_EXPORT
int crypto_box(unsigned char *c, const unsigned char *m,
unsigned long long mlen, const unsigned char *n,
const unsigned char *pk, const unsigned char *sk)
- __attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
+ __attribute__ ((deprecated)) __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4, 5, 6)));
SODIUM_EXPORT
int crypto_box_open(unsigned char *m, const unsigned char *c,
unsigned long long clen, const unsigned char *n,
const unsigned char *pk, const unsigned char *sk)
- __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5, 6)));
+ __attribute__ ((deprecated)) __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5, 6)));
SODIUM_EXPORT
int crypto_box_afternm(unsigned char *c, const unsigned char *m,
unsigned long long mlen, const unsigned char *n,
- const unsigned char *k) __attribute__ ((nonnull));
+ const unsigned char *k) __attribute__ ((deprecated)) __attribute__ ((nonnull(1, 4, 5)));
SODIUM_EXPORT
int crypto_box_open_afternm(unsigned char *m, const unsigned char *c,
unsigned long long clen, const unsigned char *n,
const unsigned char *k)
- __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
+ __attribute__ ((warn_unused_result)) __attribute__ ((deprecated)) __attribute__ ((nonnull(2, 4, 5)));
#ifdef __cplusplus
}
diff --git a/libs/libsodium/src/include/sodium/crypto_box_curve25519xchacha20poly1305.h b/libs/libsodium/src/include/sodium/crypto_box_curve25519xchacha20poly1305.h
index 2616e9b2b8..50288b35f3 100644
--- a/libs/libsodium/src/include/sodium/crypto_box_curve25519xchacha20poly1305.h
+++ b/libs/libsodium/src/include/sodium/crypto_box_curve25519xchacha20poly1305.h
@@ -60,7 +60,7 @@ int crypto_box_curve25519xchacha20poly1305_easy(unsigned char *c,
const unsigned char *n,
const unsigned char *pk,
const unsigned char *sk)
- __attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
+ __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4, 5, 6)));
SODIUM_EXPORT
int crypto_box_curve25519xchacha20poly1305_open_easy(unsigned char *m,
@@ -79,7 +79,7 @@ int crypto_box_curve25519xchacha20poly1305_detached(unsigned char *c,
const unsigned char *n,
const unsigned char *pk,
const unsigned char *sk)
- __attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
+ __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 2, 5, 6, 7)));
SODIUM_EXPORT
int crypto_box_curve25519xchacha20poly1305_open_detached(unsigned char *m,
@@ -105,7 +105,7 @@ int crypto_box_curve25519xchacha20poly1305_easy_afternm(unsigned char *c,
unsigned long long mlen,
const unsigned char *n,
const unsigned char *k)
- __attribute__ ((nonnull));
+ __attribute__ ((nonnull(1, 4, 5)));
SODIUM_EXPORT
int crypto_box_curve25519xchacha20poly1305_open_easy_afternm(unsigned char *m,
@@ -122,7 +122,7 @@ int crypto_box_curve25519xchacha20poly1305_detached_afternm(unsigned char *c,
unsigned long long mlen,
const unsigned char *n,
const unsigned char *k)
- __attribute__ ((nonnull));
+ __attribute__ ((nonnull(1, 2, 5, 6)));
SODIUM_EXPORT
int crypto_box_curve25519xchacha20poly1305_open_detached_afternm(unsigned char *m,
@@ -147,7 +147,7 @@ int crypto_box_curve25519xchacha20poly1305_seal(unsigned char *c,
const unsigned char *m,
unsigned long long mlen,
const unsigned char *pk)
- __attribute__ ((nonnull));
+ __attribute__ ((nonnull(1, 4)));
SODIUM_EXPORT
int crypto_box_curve25519xchacha20poly1305_seal_open(unsigned char *m,
diff --git a/libs/libsodium/src/include/sodium/crypto_box_curve25519xsalsa20poly1305.h b/libs/libsodium/src/include/sodium/crypto_box_curve25519xsalsa20poly1305.h
index ffaead2bff..a5d8a3947e 100644
--- a/libs/libsodium/src/include/sodium/crypto_box_curve25519xsalsa20poly1305.h
+++ b/libs/libsodium/src/include/sodium/crypto_box_curve25519xsalsa20poly1305.h
@@ -69,7 +69,8 @@ size_t crypto_box_curve25519xsalsa20poly1305_boxzerobytes(void);
(crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES + \
crypto_box_curve25519xsalsa20poly1305_MACBYTES)
SODIUM_EXPORT
-size_t crypto_box_curve25519xsalsa20poly1305_zerobytes(void);
+size_t crypto_box_curve25519xsalsa20poly1305_zerobytes(void)
+ __attribute__ ((deprecated));
SODIUM_EXPORT
int crypto_box_curve25519xsalsa20poly1305(unsigned char *c,
@@ -78,7 +79,7 @@ int crypto_box_curve25519xsalsa20poly1305(unsigned char *c,
const unsigned char *n,
const unsigned char *pk,
const unsigned char *sk)
- __attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
+ __attribute__ ((deprecated)) __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4, 5, 6)));
SODIUM_EXPORT
int crypto_box_curve25519xsalsa20poly1305_open(unsigned char *m,
@@ -87,7 +88,7 @@ int crypto_box_curve25519xsalsa20poly1305_open(unsigned char *m,
const unsigned char *n,
const unsigned char *pk,
const unsigned char *sk)
- __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5, 6)));
+ __attribute__ ((deprecated)) __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5, 6)));
SODIUM_EXPORT
int crypto_box_curve25519xsalsa20poly1305_afternm(unsigned char *c,
@@ -95,7 +96,7 @@ int crypto_box_curve25519xsalsa20poly1305_afternm(unsigned char *c,
unsigned long long mlen,
const unsigned char *n,
const unsigned char *k)
- __attribute__ ((nonnull));
+ __attribute__ ((deprecated)) __attribute__ ((nonnull(1, 4, 5)));
SODIUM_EXPORT
int crypto_box_curve25519xsalsa20poly1305_open_afternm(unsigned char *m,
@@ -103,7 +104,7 @@ int crypto_box_curve25519xsalsa20poly1305_open_afternm(unsigned char *m,
unsigned long long clen,
const unsigned char *n,
const unsigned char *k)
- __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
+ __attribute__ ((deprecated)) __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
#ifdef __cplusplus
}
diff --git a/libs/libsodium/src/include/sodium/crypto_core_ed25519.h b/libs/libsodium/src/include/sodium/crypto_core_ed25519.h
index 003ac3565b..dd9a0439ad 100644
--- a/libs/libsodium/src/include/sodium/crypto_core_ed25519.h
+++ b/libs/libsodium/src/include/sodium/crypto_core_ed25519.h
@@ -16,6 +16,10 @@ size_t crypto_core_ed25519_bytes(void);
SODIUM_EXPORT
size_t crypto_core_ed25519_uniformbytes(void);
+#define crypto_core_ed25519_HASHBYTES 64
+SODIUM_EXPORT
+size_t crypto_core_ed25519_hashbytes(void);
+
#define crypto_core_ed25519_SCALARBYTES 32
SODIUM_EXPORT
size_t crypto_core_ed25519_scalarbytes(void);
@@ -24,6 +28,9 @@ size_t crypto_core_ed25519_scalarbytes(void);
SODIUM_EXPORT
size_t crypto_core_ed25519_nonreducedscalarbytes(void);
+#define crypto_core_ed25519_H2CSHA256 1
+#define crypto_core_ed25519_H2CSHA512 2
+
SODIUM_EXPORT
int crypto_core_ed25519_is_valid_point(const unsigned char *p)
__attribute__ ((nonnull));
@@ -43,6 +50,22 @@ int crypto_core_ed25519_from_uniform(unsigned char *p, const unsigned char *r)
__attribute__ ((nonnull));
SODIUM_EXPORT
+int crypto_core_ed25519_from_string(unsigned char p[crypto_core_ed25519_BYTES],
+ const char *ctx, const unsigned char *msg,
+ size_t msg_len, int hash_alg)
+ __attribute__ ((nonnull(1)));
+
+SODIUM_EXPORT
+int crypto_core_ed25519_from_string_ro(unsigned char p[crypto_core_ed25519_BYTES],
+ const char *ctx, const unsigned char *msg,
+ size_t msg_len, int hash_alg)
+ __attribute__ ((nonnull(1)));
+
+SODIUM_EXPORT
+void crypto_core_ed25519_random(unsigned char *p)
+ __attribute__ ((nonnull));
+
+SODIUM_EXPORT
void crypto_core_ed25519_scalar_random(unsigned char *r)
__attribute__ ((nonnull));
@@ -68,6 +91,11 @@ void crypto_core_ed25519_scalar_sub(unsigned char *z, const unsigned char *x,
const unsigned char *y)
__attribute__ ((nonnull));
+SODIUM_EXPORT
+void crypto_core_ed25519_scalar_mul(unsigned char *z, const unsigned char *x,
+ const unsigned char *y)
+ __attribute__ ((nonnull));
+
/*
* The interval `s` is sampled from should be at least 317 bits to ensure almost
* uniformity of `r` over `L`.
@@ -76,6 +104,10 @@ SODIUM_EXPORT
void crypto_core_ed25519_scalar_reduce(unsigned char *r, const unsigned char *s)
__attribute__ ((nonnull));
+SODIUM_EXPORT
+int crypto_core_ed25519_scalar_is_canonical(const unsigned char *s)
+ __attribute__ ((nonnull));
+
#ifdef __cplusplus
}
#endif
diff --git a/libs/libsodium/src/include/sodium/crypto_core_ristretto255.h b/libs/libsodium/src/include/sodium/crypto_core_ristretto255.h
new file mode 100644
index 0000000000..5fc3a1be6e
--- /dev/null
+++ b/libs/libsodium/src/include/sodium/crypto_core_ristretto255.h
@@ -0,0 +1,121 @@
+#ifndef crypto_core_ristretto255_H
+#define crypto_core_ristretto255_H
+
+#include <stddef.h>
+#include "export.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define crypto_core_ristretto255_BYTES 32
+SODIUM_EXPORT
+size_t crypto_core_ristretto255_bytes(void);
+
+#define crypto_core_ristretto255_HASHBYTES 64
+SODIUM_EXPORT
+size_t crypto_core_ristretto255_hashbytes(void);
+
+#define crypto_core_ristretto255_SCALARBYTES 32
+SODIUM_EXPORT
+size_t crypto_core_ristretto255_scalarbytes(void);
+
+#define crypto_core_ristretto255_NONREDUCEDSCALARBYTES 64
+SODIUM_EXPORT
+size_t crypto_core_ristretto255_nonreducedscalarbytes(void);
+
+#define crypto_core_ristretto255_H2CSHA256 1
+#define crypto_core_ristretto255_H2CSHA512 2
+
+SODIUM_EXPORT
+int crypto_core_ristretto255_is_valid_point(const unsigned char *p)
+ __attribute__ ((nonnull));
+
+SODIUM_EXPORT
+int crypto_core_ristretto255_add(unsigned char *r,
+ const unsigned char *p, const unsigned char *q)
+ __attribute__ ((nonnull));
+
+SODIUM_EXPORT
+int crypto_core_ristretto255_sub(unsigned char *r,
+ const unsigned char *p, const unsigned char *q)
+ __attribute__ ((nonnull));
+
+SODIUM_EXPORT
+int crypto_core_ristretto255_from_hash(unsigned char *p,
+ const unsigned char *r)
+ __attribute__ ((nonnull));
+
+SODIUM_EXPORT
+int crypto_core_ristretto255_from_string(unsigned char p[crypto_core_ristretto255_BYTES],
+ const char *ctx,
+ const unsigned char *msg,
+ size_t msg_len, int hash_alg)
+ __attribute__ ((nonnull(1)));
+
+SODIUM_EXPORT
+int crypto_core_ristretto255_from_string_ro(unsigned char p[crypto_core_ristretto255_BYTES],
+ const char *ctx,
+ const unsigned char *msg,
+ size_t msg_len, int hash_alg)
+ __attribute__ ((nonnull(1)));
+
+SODIUM_EXPORT
+void crypto_core_ristretto255_random(unsigned char *p)
+ __attribute__ ((nonnull));
+
+SODIUM_EXPORT
+void crypto_core_ristretto255_scalar_random(unsigned char *r)
+ __attribute__ ((nonnull));
+
+SODIUM_EXPORT
+int crypto_core_ristretto255_scalar_invert(unsigned char *recip,
+ const unsigned char *s)
+ __attribute__ ((nonnull));
+
+SODIUM_EXPORT
+void crypto_core_ristretto255_scalar_negate(unsigned char *neg,
+ const unsigned char *s)
+ __attribute__ ((nonnull));
+
+SODIUM_EXPORT
+void crypto_core_ristretto255_scalar_complement(unsigned char *comp,
+ const unsigned char *s)
+ __attribute__ ((nonnull));
+
+SODIUM_EXPORT
+void crypto_core_ristretto255_scalar_add(unsigned char *z,
+ const unsigned char *x,
+ const unsigned char *y)
+ __attribute__ ((nonnull));
+
+SODIUM_EXPORT
+void crypto_core_ristretto255_scalar_sub(unsigned char *z,
+ const unsigned char *x,
+ const unsigned char *y)
+ __attribute__ ((nonnull));
+
+SODIUM_EXPORT
+void crypto_core_ristretto255_scalar_mul(unsigned char *z,
+ const unsigned char *x,
+ const unsigned char *y)
+ __attribute__ ((nonnull));
+
+/*
+ * The interval `s` is sampled from should be at least 317 bits to ensure almost
+ * uniformity of `r` over `L`.
+ */
+SODIUM_EXPORT
+void crypto_core_ristretto255_scalar_reduce(unsigned char *r,
+ const unsigned char *s)
+ __attribute__ ((nonnull));
+
+SODIUM_EXPORT
+int crypto_core_ristretto255_scalar_is_canonical(const unsigned char *s)
+ __attribute__ ((nonnull));
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libs/libsodium/src/include/sodium/crypto_generichash.h b/libs/libsodium/src/include/sodium/crypto_generichash.h
index c1cc435fd7..a240d5f9ff 100644
--- a/libs/libsodium/src/include/sodium/crypto_generichash.h
+++ b/libs/libsodium/src/include/sodium/crypto_generichash.h
@@ -66,7 +66,7 @@ SODIUM_EXPORT
int crypto_generichash_update(crypto_generichash_state *state,
const unsigned char *in,
unsigned long long inlen)
- __attribute__ ((nonnull));
+ __attribute__ ((nonnull(1)));
SODIUM_EXPORT
int crypto_generichash_final(crypto_generichash_state *state,
diff --git a/libs/libsodium/src/include/sodium/crypto_generichash_blake2b.h b/libs/libsodium/src/include/sodium/crypto_generichash_blake2b.h
index 3e4b8a1059..d3064ab409 100644
--- a/libs/libsodium/src/include/sodium/crypto_generichash_blake2b.h
+++ b/libs/libsodium/src/include/sodium/crypto_generichash_blake2b.h
@@ -14,7 +14,9 @@
extern "C" {
#endif
-#if defined(__IBMC__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
+#ifdef __IBMC__
+# pragma pack(1)
+#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
# pragma pack(1)
#else
# pragma pack(push, 1)
@@ -24,7 +26,9 @@ typedef struct CRYPTO_ALIGN(64) crypto_generichash_blake2b_state {
unsigned char opaque[384];
} crypto_generichash_blake2b_state;
-#if defined(__IBMC__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
+#ifdef __IBMC__
+# pragma pack(pop)
+#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
# pragma pack()
#else
# pragma pack(pop)
@@ -100,7 +104,7 @@ SODIUM_EXPORT
int crypto_generichash_blake2b_update(crypto_generichash_blake2b_state *state,
const unsigned char *in,
unsigned long long inlen)
- __attribute__ ((nonnull));
+ __attribute__ ((nonnull(1)));
SODIUM_EXPORT
int crypto_generichash_blake2b_final(crypto_generichash_blake2b_state *state,
diff --git a/libs/libsodium/src/include/sodium/crypto_hash.h b/libs/libsodium/src/include/sodium/crypto_hash.h
index c5e338e3ba..57db1f5381 100644
--- a/libs/libsodium/src/include/sodium/crypto_hash.h
+++ b/libs/libsodium/src/include/sodium/crypto_hash.h
@@ -2,7 +2,7 @@
#define crypto_hash_H
/*
- * WARNING: Unless you absolutely need to use SHA512 for interoperatibility,
+ * WARNING: Unless you absolutely need to use SHA512 for interoperability,
* purposes, you might want to consider crypto_generichash() instead.
* Unlike SHA512, crypto_generichash() is not vulnerable to length
* extension attacks.
@@ -26,7 +26,7 @@ size_t crypto_hash_bytes(void);
SODIUM_EXPORT
int crypto_hash(unsigned char *out, const unsigned char *in,
- unsigned long long inlen) __attribute__ ((nonnull));
+ unsigned long long inlen) __attribute__ ((nonnull(1)));
#define crypto_hash_PRIMITIVE "sha512"
SODIUM_EXPORT
diff --git a/libs/libsodium/src/include/sodium/crypto_hash_sha256.h b/libs/libsodium/src/include/sodium/crypto_hash_sha256.h
index a53c2f104d..d3be86a8e1 100644
--- a/libs/libsodium/src/include/sodium/crypto_hash_sha256.h
+++ b/libs/libsodium/src/include/sodium/crypto_hash_sha256.h
@@ -2,7 +2,7 @@
#define crypto_hash_sha256_H
/*
- * WARNING: Unless you absolutely need to use SHA256 for interoperatibility,
+ * WARNING: Unless you absolutely need to use SHA256 for interoperability,
* purposes, you might want to consider crypto_generichash() instead.
* Unlike SHA256, crypto_generichash() is not vulnerable to length
* extension attacks.
@@ -36,7 +36,7 @@ size_t crypto_hash_sha256_bytes(void);
SODIUM_EXPORT
int crypto_hash_sha256(unsigned char *out, const unsigned char *in,
- unsigned long long inlen) __attribute__ ((nonnull));
+ unsigned long long inlen) __attribute__ ((nonnull(1)));
SODIUM_EXPORT
int crypto_hash_sha256_init(crypto_hash_sha256_state *state)
@@ -46,7 +46,7 @@ SODIUM_EXPORT
int crypto_hash_sha256_update(crypto_hash_sha256_state *state,
const unsigned char *in,
unsigned long long inlen)
- __attribute__ ((nonnull));
+ __attribute__ ((nonnull(1)));
SODIUM_EXPORT
int crypto_hash_sha256_final(crypto_hash_sha256_state *state,
diff --git a/libs/libsodium/src/include/sodium/crypto_hash_sha512.h b/libs/libsodium/src/include/sodium/crypto_hash_sha512.h
index 02aea29641..2c5cfd5a8c 100644
--- a/libs/libsodium/src/include/sodium/crypto_hash_sha512.h
+++ b/libs/libsodium/src/include/sodium/crypto_hash_sha512.h
@@ -2,7 +2,7 @@
#define crypto_hash_sha512_H
/*
- * WARNING: Unless you absolutely need to use SHA512 for interoperatibility,
+ * WARNING: Unless you absolutely need to use SHA512 for interoperability,
* purposes, you might want to consider crypto_generichash() instead.
* Unlike SHA512, crypto_generichash() is not vulnerable to length
* extension attacks.
@@ -36,7 +36,7 @@ size_t crypto_hash_sha512_bytes(void);
SODIUM_EXPORT
int crypto_hash_sha512(unsigned char *out, const unsigned char *in,
- unsigned long long inlen) __attribute__ ((nonnull));
+ unsigned long long inlen) __attribute__ ((nonnull(1)));
SODIUM_EXPORT
int crypto_hash_sha512_init(crypto_hash_sha512_state *state)
@@ -46,7 +46,7 @@ SODIUM_EXPORT
int crypto_hash_sha512_update(crypto_hash_sha512_state *state,
const unsigned char *in,
unsigned long long inlen)
- __attribute__ ((nonnull));
+ __attribute__ ((nonnull(1)));
SODIUM_EXPORT
int crypto_hash_sha512_final(crypto_hash_sha512_state *state,
diff --git a/libs/libsodium/src/include/sodium/crypto_kdf_blake2b.h b/libs/libsodium/src/include/sodium/crypto_kdf_blake2b.h
index add4a1921c..be917017f6 100644
--- a/libs/libsodium/src/include/sodium/crypto_kdf_blake2b.h
+++ b/libs/libsodium/src/include/sodium/crypto_kdf_blake2b.h
@@ -3,8 +3,8 @@
#include <stddef.h>
#include <stdint.h>
+#include <stdlib.h>
-#include "crypto_kdf_blake2b.h"
#include "export.h"
#ifdef __cplusplus
diff --git a/libs/libsodium/src/include/sodium/crypto_kdf_hkdf_sha256.h b/libs/libsodium/src/include/sodium/crypto_kdf_hkdf_sha256.h
new file mode 100644
index 0000000000..e7e7f4db6d
--- /dev/null
+++ b/libs/libsodium/src/include/sodium/crypto_kdf_hkdf_sha256.h
@@ -0,0 +1,74 @@
+#ifndef crypto_kdf_hkdf_sha256_H
+#define crypto_kdf_hkdf_sha256_H
+
+#include <stddef.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#include "crypto_kdf.h"
+#include "crypto_auth_hmacsha256.h"
+#include "export.h"
+
+#ifdef __cplusplus
+# ifdef __GNUC__
+# pragma GCC diagnostic ignored "-Wlong-long"
+# endif
+extern "C" {
+#endif
+
+#define crypto_kdf_hkdf_sha256_KEYBYTES crypto_auth_hmacsha256_BYTES
+SODIUM_EXPORT
+size_t crypto_kdf_hkdf_sha256_keybytes(void);
+
+#define crypto_kdf_hkdf_sha256_BYTES_MIN 0U
+SODIUM_EXPORT
+size_t crypto_kdf_hkdf_sha256_bytes_min(void);
+
+#define crypto_kdf_hkdf_sha256_BYTES_MAX (0xff * crypto_auth_hmacsha256_BYTES)
+SODIUM_EXPORT
+size_t crypto_kdf_hkdf_sha256_bytes_max(void);
+
+SODIUM_EXPORT
+int crypto_kdf_hkdf_sha256_extract(unsigned char prk[crypto_kdf_hkdf_sha256_KEYBYTES],
+ const unsigned char *salt, size_t salt_len,
+ const unsigned char *ikm, size_t ikm_len)
+ __attribute__ ((nonnull(4)));
+
+SODIUM_EXPORT
+void crypto_kdf_hkdf_sha256_keygen(unsigned char prk[crypto_kdf_hkdf_sha256_KEYBYTES]);
+
+SODIUM_EXPORT
+int crypto_kdf_hkdf_sha256_expand(unsigned char *out, size_t out_len,
+ const char *ctx, size_t ctx_len,
+ const unsigned char prk[crypto_kdf_hkdf_sha256_KEYBYTES])
+ __attribute__ ((nonnull(1)));
+
+/* ------------------------------------------------------------------------- */
+
+typedef struct crypto_kdf_hkdf_sha256_state {
+ crypto_auth_hmacsha256_state st;
+} crypto_kdf_hkdf_sha256_state;
+
+SODIUM_EXPORT
+size_t crypto_kdf_hkdf_sha256_statebytes(void);
+
+SODIUM_EXPORT
+int crypto_kdf_hkdf_sha256_extract_init(crypto_kdf_hkdf_sha256_state *state,
+ const unsigned char *salt, size_t salt_len)
+ __attribute__ ((nonnull(1)));
+
+SODIUM_EXPORT
+int crypto_kdf_hkdf_sha256_extract_update(crypto_kdf_hkdf_sha256_state *state,
+ const unsigned char *ikm, size_t ikm_len)
+ __attribute__ ((nonnull));
+
+SODIUM_EXPORT
+int crypto_kdf_hkdf_sha256_extract_final(crypto_kdf_hkdf_sha256_state *state,
+ unsigned char prk[crypto_kdf_hkdf_sha256_KEYBYTES])
+ __attribute__ ((nonnull));
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libs/libsodium/src/include/sodium/crypto_kdf_hkdf_sha512.h b/libs/libsodium/src/include/sodium/crypto_kdf_hkdf_sha512.h
new file mode 100644
index 0000000000..0ed205dfb8
--- /dev/null
+++ b/libs/libsodium/src/include/sodium/crypto_kdf_hkdf_sha512.h
@@ -0,0 +1,75 @@
+#ifndef crypto_kdf_hkdf_sha512_H
+#define crypto_kdf_hkdf_sha512_H
+
+#include <stddef.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#include "crypto_kdf.h"
+#include "crypto_auth_hmacsha512.h"
+#include "export.h"
+
+#ifdef __cplusplus
+# ifdef __GNUC__
+# pragma GCC diagnostic ignored "-Wlong-long"
+# endif
+extern "C" {
+#endif
+
+#define crypto_kdf_hkdf_sha512_KEYBYTES crypto_auth_hmacsha512_BYTES
+SODIUM_EXPORT
+size_t crypto_kdf_hkdf_sha512_keybytes(void);
+
+#define crypto_kdf_hkdf_sha512_BYTES_MIN 0U
+SODIUM_EXPORT
+size_t crypto_kdf_hkdf_sha512_bytes_min(void);
+
+#define crypto_kdf_hkdf_sha512_BYTES_MAX (0xff * crypto_auth_hmacsha512_BYTES)
+SODIUM_EXPORT
+size_t crypto_kdf_hkdf_sha512_bytes_max(void);
+
+SODIUM_EXPORT
+int crypto_kdf_hkdf_sha512_extract(unsigned char prk[crypto_kdf_hkdf_sha512_KEYBYTES],
+ const unsigned char *salt, size_t salt_len,
+ const unsigned char *ikm, size_t ikm_len)
+ __attribute__ ((nonnull(1)));
+
+SODIUM_EXPORT
+void crypto_kdf_hkdf_sha512_keygen(unsigned char prk[crypto_kdf_hkdf_sha512_KEYBYTES])
+ __attribute__ ((nonnull));
+
+SODIUM_EXPORT
+int crypto_kdf_hkdf_sha512_expand(unsigned char *out, size_t out_len,
+ const char *ctx, size_t ctx_len,
+ const unsigned char prk[crypto_kdf_hkdf_sha512_KEYBYTES])
+ __attribute__ ((nonnull(1)));
+
+/* ------------------------------------------------------------------------- */
+
+typedef struct crypto_kdf_hkdf_sha512_state {
+ crypto_auth_hmacsha512_state st;
+} crypto_kdf_hkdf_sha512_state;
+
+SODIUM_EXPORT
+size_t crypto_kdf_hkdf_sha512_statebytes(void);
+
+SODIUM_EXPORT
+int crypto_kdf_hkdf_sha512_extract_init(crypto_kdf_hkdf_sha512_state *state,
+ const unsigned char *salt, size_t salt_len)
+ __attribute__ ((nonnull(1)));
+
+SODIUM_EXPORT
+int crypto_kdf_hkdf_sha512_extract_update(crypto_kdf_hkdf_sha512_state *state,
+ const unsigned char *ikm, size_t ikm_len)
+ __attribute__ ((nonnull));
+
+SODIUM_EXPORT
+int crypto_kdf_hkdf_sha512_extract_final(crypto_kdf_hkdf_sha512_state *state,
+ unsigned char prk[crypto_kdf_hkdf_sha512_KEYBYTES])
+ __attribute__ ((nonnull));
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libs/libsodium/src/include/sodium/crypto_onetimeauth.h b/libs/libsodium/src/include/sodium/crypto_onetimeauth.h
index ab856b9cbe..4aee8b4b5d 100644
--- a/libs/libsodium/src/include/sodium/crypto_onetimeauth.h
+++ b/libs/libsodium/src/include/sodium/crypto_onetimeauth.h
@@ -33,12 +33,12 @@ const char *crypto_onetimeauth_primitive(void);
SODIUM_EXPORT
int crypto_onetimeauth(unsigned char *out, const unsigned char *in,
unsigned long long inlen, const unsigned char *k)
- __attribute__ ((nonnull));
+ __attribute__ ((nonnull(1, 4)));
SODIUM_EXPORT
int crypto_onetimeauth_verify(const unsigned char *h, const unsigned char *in,
unsigned long long inlen, const unsigned char *k)
- __attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
+ __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4)));
SODIUM_EXPORT
int crypto_onetimeauth_init(crypto_onetimeauth_state *state,
@@ -48,7 +48,7 @@ SODIUM_EXPORT
int crypto_onetimeauth_update(crypto_onetimeauth_state *state,
const unsigned char *in,
unsigned long long inlen)
- __attribute__ ((nonnull));
+ __attribute__ ((nonnull(1)));
SODIUM_EXPORT
int crypto_onetimeauth_final(crypto_onetimeauth_state *state,
diff --git a/libs/libsodium/src/include/sodium/crypto_onetimeauth_poly1305.h b/libs/libsodium/src/include/sodium/crypto_onetimeauth_poly1305.h
index 510f20561b..67f6dee122 100644
--- a/libs/libsodium/src/include/sodium/crypto_onetimeauth_poly1305.h
+++ b/libs/libsodium/src/include/sodium/crypto_onetimeauth_poly1305.h
@@ -1,13 +1,6 @@
#ifndef crypto_onetimeauth_poly1305_H
#define crypto_onetimeauth_poly1305_H
-#ifdef __cplusplus
-# ifdef __GNUC__
-# pragma GCC diagnostic ignored "-Wlong-long"
-# endif
-extern "C" {
-#endif
-
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -16,6 +9,13 @@ extern "C" {
#include "export.h"
+#ifdef __cplusplus
+# ifdef __GNUC__
+# pragma GCC diagnostic ignored "-Wlong-long"
+# endif
+extern "C" {
+#endif
+
typedef struct CRYPTO_ALIGN(16) crypto_onetimeauth_poly1305_state {
unsigned char opaque[256];
} crypto_onetimeauth_poly1305_state;
@@ -36,14 +36,14 @@ int crypto_onetimeauth_poly1305(unsigned char *out,
const unsigned char *in,
unsigned long long inlen,
const unsigned char *k)
- __attribute__ ((nonnull));
+ __attribute__ ((nonnull(1, 4)));
SODIUM_EXPORT
int crypto_onetimeauth_poly1305_verify(const unsigned char *h,
const unsigned char *in,
unsigned long long inlen,
const unsigned char *k)
- __attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
+ __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4)));
SODIUM_EXPORT
int crypto_onetimeauth_poly1305_init(crypto_onetimeauth_poly1305_state *state,
@@ -54,7 +54,7 @@ SODIUM_EXPORT
int crypto_onetimeauth_poly1305_update(crypto_onetimeauth_poly1305_state *state,
const unsigned char *in,
unsigned long long inlen)
- __attribute__ ((nonnull));
+ __attribute__ ((nonnull(1)));
SODIUM_EXPORT
int crypto_onetimeauth_poly1305_final(crypto_onetimeauth_poly1305_state *state,
diff --git a/libs/libsodium/src/include/sodium/crypto_pwhash.h b/libs/libsodium/src/include/sodium/crypto_pwhash.h
index e398522b82..60efc9f570 100644
--- a/libs/libsodium/src/include/sodium/crypto_pwhash.h
+++ b/libs/libsodium/src/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
@@ -125,17 +125,17 @@ int crypto_pwhash_str_alg(char out[crypto_pwhash_STRBYTES],
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
SODIUM_EXPORT
-int crypto_pwhash_str_verify(const char str[crypto_pwhash_STRBYTES],
+int crypto_pwhash_str_verify(const char *str,
const char * const passwd,
unsigned long long passwdlen)
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
SODIUM_EXPORT
-int crypto_pwhash_str_needs_rehash(const char str[crypto_pwhash_STRBYTES],
+int crypto_pwhash_str_needs_rehash(const char *str,
unsigned long long opslimit, size_t memlimit)
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
-#define crypto_pwhash_PRIMITIVE "argon2i"
+#define crypto_pwhash_PRIMITIVE "argon2id,argon2i"
SODIUM_EXPORT
const char *crypto_pwhash_primitive(void)
__attribute__ ((warn_unused_result));
diff --git a/libs/libsodium/src/include/sodium/crypto_pwhash_argon2i.h b/libs/libsodium/src/include/sodium/crypto_pwhash_argon2i.h
index c5e940c869..44b7d6fa02 100644
--- a/libs/libsodium/src/include/sodium/crypto_pwhash_argon2i.h
+++ b/libs/libsodium/src/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
@@ -105,13 +105,13 @@ int crypto_pwhash_argon2i_str(char out[crypto_pwhash_argon2i_STRBYTES],
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
SODIUM_EXPORT
-int crypto_pwhash_argon2i_str_verify(const char str[crypto_pwhash_argon2i_STRBYTES],
+int crypto_pwhash_argon2i_str_verify(const char * str,
const char * const passwd,
unsigned long long passwdlen)
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
SODIUM_EXPORT
-int crypto_pwhash_argon2i_str_needs_rehash(const char str[crypto_pwhash_argon2i_STRBYTES],
+int crypto_pwhash_argon2i_str_needs_rehash(const char * str,
unsigned long long opslimit, size_t memlimit)
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
diff --git a/libs/libsodium/src/include/sodium/crypto_pwhash_argon2id.h b/libs/libsodium/src/include/sodium/crypto_pwhash_argon2id.h
index a8dd1a5260..9d4ae6a8ae 100644
--- a/libs/libsodium/src/include/sodium/crypto_pwhash_argon2id.h
+++ b/libs/libsodium/src/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
@@ -105,13 +105,13 @@ int crypto_pwhash_argon2id_str(char out[crypto_pwhash_argon2id_STRBYTES],
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
SODIUM_EXPORT
-int crypto_pwhash_argon2id_str_verify(const char str[crypto_pwhash_argon2id_STRBYTES],
+int crypto_pwhash_argon2id_str_verify(const char * str,
const char * const passwd,
unsigned long long passwdlen)
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
SODIUM_EXPORT
-int crypto_pwhash_argon2id_str_needs_rehash(const char str[crypto_pwhash_argon2id_STRBYTES],
+int crypto_pwhash_argon2id_str_needs_rehash(const char * str,
unsigned long long opslimit, size_t memlimit)
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
diff --git a/libs/libsodium/src/include/sodium/crypto_pwhash_scryptsalsa208sha256.h b/libs/libsodium/src/include/sodium/crypto_pwhash_scryptsalsa208sha256.h
index 71893bdd65..c9c0469bbb 100644
--- a/libs/libsodium/src/include/sodium/crypto_pwhash_scryptsalsa208sha256.h
+++ b/libs/libsodium/src/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
@@ -95,7 +95,7 @@ int crypto_pwhash_scryptsalsa208sha256_str(char out[crypto_pwhash_scryptsalsa208
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
SODIUM_EXPORT
-int crypto_pwhash_scryptsalsa208sha256_str_verify(const char str[crypto_pwhash_scryptsalsa208sha256_STRBYTES],
+int crypto_pwhash_scryptsalsa208sha256_str_verify(const char * str,
const char * const passwd,
unsigned long long passwdlen)
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
@@ -108,7 +108,7 @@ int crypto_pwhash_scryptsalsa208sha256_ll(const uint8_t * passwd, size_t passwdl
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
SODIUM_EXPORT
-int crypto_pwhash_scryptsalsa208sha256_str_needs_rehash(const char str[crypto_pwhash_scryptsalsa208sha256_STRBYTES],
+int crypto_pwhash_scryptsalsa208sha256_str_needs_rehash(const char * str,
unsigned long long opslimit,
size_t memlimit)
__attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
diff --git a/libs/libsodium/src/include/sodium/crypto_scalarmult.h b/libs/libsodium/src/include/sodium/crypto_scalarmult.h
index 842281371f..f72ee55c81 100644
--- a/libs/libsodium/src/include/sodium/crypto_scalarmult.h
+++ b/libs/libsodium/src/include/sodium/crypto_scalarmult.h
@@ -27,7 +27,7 @@ int crypto_scalarmult_base(unsigned char *q, const unsigned char *n)
__attribute__ ((nonnull));
/*
- * NOTE: Do not use the result of this function directly.
+ * NOTE: Do not use the result of this function directly for key exchange.
*
* Hash the result with the public keys in order to compute a shared
* secret key: H(q || client_pk || server_pk)
diff --git a/libs/libsodium/src/include/sodium/crypto_scalarmult_curve25519.h b/libs/libsodium/src/include/sodium/crypto_scalarmult_curve25519.h
index 8a59123303..d97c8db212 100644
--- a/libs/libsodium/src/include/sodium/crypto_scalarmult_curve25519.h
+++ b/libs/libsodium/src/include/sodium/crypto_scalarmult_curve25519.h
@@ -18,7 +18,7 @@ SODIUM_EXPORT
size_t crypto_scalarmult_curve25519_scalarbytes(void);
/*
- * NOTE: Do not use the result of this function directly.
+ * NOTE: Do not use the result of this function directly for key exchange.
*
* Hash the result with the public keys in order to compute a shared
* secret key: H(q || client_pk || server_pk)
diff --git a/libs/libsodium/src/include/sodium/crypto_scalarmult_ed25519.h b/libs/libsodium/src/include/sodium/crypto_scalarmult_ed25519.h
index a3d562b207..15f7258c06 100644
--- a/libs/libsodium/src/include/sodium/crypto_scalarmult_ed25519.h
+++ b/libs/libsodium/src/include/sodium/crypto_scalarmult_ed25519.h
@@ -19,7 +19,7 @@ SODIUM_EXPORT
size_t crypto_scalarmult_ed25519_scalarbytes(void);
/*
- * NOTE: Do not use the result of this function directly.
+ * NOTE: Do not use the result of this function directly for key exchange.
*
* Hash the result with the public keys in order to compute a shared
* secret key: H(q || client_pk || server_pk)
diff --git a/libs/libsodium/src/include/sodium/crypto_scalarmult_ristretto255.h b/libs/libsodium/src/include/sodium/crypto_scalarmult_ristretto255.h
new file mode 100644
index 0000000000..40a45ccef0
--- /dev/null
+++ b/libs/libsodium/src/include/sodium/crypto_scalarmult_ristretto255.h
@@ -0,0 +1,43 @@
+
+#ifndef crypto_scalarmult_ristretto255_H
+#define crypto_scalarmult_ristretto255_H
+
+#include <stddef.h>
+
+#include "export.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define crypto_scalarmult_ristretto255_BYTES 32U
+SODIUM_EXPORT
+size_t crypto_scalarmult_ristretto255_bytes(void);
+
+#define crypto_scalarmult_ristretto255_SCALARBYTES 32U
+SODIUM_EXPORT
+size_t crypto_scalarmult_ristretto255_scalarbytes(void);
+
+/*
+ * NOTE: Do not use the result of this function directly for key exchange.
+ *
+ * Hash the result with the public keys in order to compute a shared
+ * secret key: H(q || client_pk || server_pk)
+ *
+ * Or unless this is not an option, use the crypto_kx() API instead.
+ */
+SODIUM_EXPORT
+int crypto_scalarmult_ristretto255(unsigned char *q, const unsigned char *n,
+ const unsigned char *p)
+ __attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
+
+SODIUM_EXPORT
+int crypto_scalarmult_ristretto255_base(unsigned char *q,
+ const unsigned char *n)
+ __attribute__ ((nonnull));
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libs/libsodium/src/include/sodium/crypto_secretbox.h b/libs/libsodium/src/include/sodium/crypto_secretbox.h
index c5f653c0a2..d3d3e3005b 100644
--- a/libs/libsodium/src/include/sodium/crypto_secretbox.h
+++ b/libs/libsodium/src/include/sodium/crypto_secretbox.h
@@ -36,7 +36,7 @@ size_t crypto_secretbox_messagebytes_max(void);
SODIUM_EXPORT
int crypto_secretbox_easy(unsigned char *c, const unsigned char *m,
unsigned long long mlen, const unsigned char *n,
- const unsigned char *k) __attribute__ ((nonnull));
+ const unsigned char *k) __attribute__ ((nonnull(1, 4, 5)));
SODIUM_EXPORT
int crypto_secretbox_open_easy(unsigned char *m, const unsigned char *c,
@@ -50,7 +50,7 @@ int crypto_secretbox_detached(unsigned char *c, unsigned char *mac,
unsigned long long mlen,
const unsigned char *n,
const unsigned char *k)
- __attribute__ ((nonnull));
+ __attribute__ ((nonnull(1, 2, 5, 6)));
SODIUM_EXPORT
int crypto_secretbox_open_detached(unsigned char *m,
@@ -69,22 +69,23 @@ void crypto_secretbox_keygen(unsigned char k[crypto_secretbox_KEYBYTES])
#define crypto_secretbox_ZEROBYTES crypto_secretbox_xsalsa20poly1305_ZEROBYTES
SODIUM_EXPORT
-size_t crypto_secretbox_zerobytes(void);
+size_t crypto_secretbox_zerobytes(void) __attribute__ ((deprecated));
#define crypto_secretbox_BOXZEROBYTES crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES
SODIUM_EXPORT
-size_t crypto_secretbox_boxzerobytes(void);
+size_t crypto_secretbox_boxzerobytes(void) __attribute__ ((deprecated));
SODIUM_EXPORT
int crypto_secretbox(unsigned char *c, const unsigned char *m,
unsigned long long mlen, const unsigned char *n,
- const unsigned char *k) __attribute__ ((nonnull));
+ const unsigned char *k)
+ __attribute__ ((deprecated)) __attribute__ ((nonnull(1, 4, 5)));
SODIUM_EXPORT
int crypto_secretbox_open(unsigned char *m, const unsigned char *c,
unsigned long long clen, const unsigned char *n,
const unsigned char *k)
- __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
+ __attribute__ ((deprecated)) __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
#ifdef __cplusplus
}
diff --git a/libs/libsodium/src/include/sodium/crypto_secretbox_xchacha20poly1305.h b/libs/libsodium/src/include/sodium/crypto_secretbox_xchacha20poly1305.h
index eb1754e8a6..91576eb858 100644
--- a/libs/libsodium/src/include/sodium/crypto_secretbox_xchacha20poly1305.h
+++ b/libs/libsodium/src/include/sodium/crypto_secretbox_xchacha20poly1305.h
@@ -35,7 +35,7 @@ int crypto_secretbox_xchacha20poly1305_easy(unsigned char *c,
unsigned long long mlen,
const unsigned char *n,
const unsigned char *k)
- __attribute__ ((nonnull));
+ __attribute__ ((nonnull(1, 4, 5)));
SODIUM_EXPORT
int crypto_secretbox_xchacha20poly1305_open_easy(unsigned char *m,
@@ -52,7 +52,7 @@ int crypto_secretbox_xchacha20poly1305_detached(unsigned char *c,
unsigned long long mlen,
const unsigned char *n,
const unsigned char *k)
- __attribute__ ((nonnull));
+ __attribute__ ((nonnull(1, 2, 5, 6)));
SODIUM_EXPORT
int crypto_secretbox_xchacha20poly1305_open_detached(unsigned char *m,
diff --git a/libs/libsodium/src/include/sodium/crypto_secretbox_xsalsa20poly1305.h b/libs/libsodium/src/include/sodium/crypto_secretbox_xsalsa20poly1305.h
index f4d83aa562..9b4f2dcb4f 100644
--- a/libs/libsodium/src/include/sodium/crypto_secretbox_xsalsa20poly1305.h
+++ b/libs/libsodium/src/include/sodium/crypto_secretbox_xsalsa20poly1305.h
@@ -31,22 +31,6 @@ SODIUM_EXPORT
size_t crypto_secretbox_xsalsa20poly1305_messagebytes_max(void);
SODIUM_EXPORT
-int crypto_secretbox_xsalsa20poly1305(unsigned char *c,
- const unsigned char *m,
- unsigned long long mlen,
- const unsigned char *n,
- const unsigned char *k)
- __attribute__ ((nonnull));
-
-SODIUM_EXPORT
-int crypto_secretbox_xsalsa20poly1305_open(unsigned char *m,
- const unsigned char *c,
- unsigned long long clen,
- const unsigned char *n,
- const unsigned char *k)
- __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
-
-SODIUM_EXPORT
void crypto_secretbox_xsalsa20poly1305_keygen(unsigned char k[crypto_secretbox_xsalsa20poly1305_KEYBYTES])
__attribute__ ((nonnull));
@@ -54,13 +38,31 @@ void crypto_secretbox_xsalsa20poly1305_keygen(unsigned char k[crypto_secretbox_x
#define crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES 16U
SODIUM_EXPORT
-size_t crypto_secretbox_xsalsa20poly1305_boxzerobytes(void);
+size_t crypto_secretbox_xsalsa20poly1305_boxzerobytes(void)
+ __attribute__ ((deprecated));
#define crypto_secretbox_xsalsa20poly1305_ZEROBYTES \
(crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES + \
crypto_secretbox_xsalsa20poly1305_MACBYTES)
SODIUM_EXPORT
-size_t crypto_secretbox_xsalsa20poly1305_zerobytes(void);
+size_t crypto_secretbox_xsalsa20poly1305_zerobytes(void)
+ __attribute__ ((deprecated));
+
+SODIUM_EXPORT
+int crypto_secretbox_xsalsa20poly1305(unsigned char *c,
+ const unsigned char *m,
+ unsigned long long mlen,
+ const unsigned char *n,
+ const unsigned char *k)
+ __attribute__ ((deprecated)) __attribute__ ((nonnull(1, 4, 5)));
+
+SODIUM_EXPORT
+int crypto_secretbox_xsalsa20poly1305_open(unsigned char *m,
+ const unsigned char *c,
+ unsigned long long clen,
+ const unsigned char *n,
+ const unsigned char *k)
+ __attribute__ ((deprecated)) __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(2, 4, 5)));
#ifdef __cplusplus
}
diff --git a/libs/libsodium/src/include/sodium/crypto_shorthash.h b/libs/libsodium/src/include/sodium/crypto_shorthash.h
index a55d98f170..15ed47c71d 100644
--- a/libs/libsodium/src/include/sodium/crypto_shorthash.h
+++ b/libs/libsodium/src/include/sodium/crypto_shorthash.h
@@ -28,7 +28,7 @@ const char *crypto_shorthash_primitive(void);
SODIUM_EXPORT
int crypto_shorthash(unsigned char *out, const unsigned char *in,
unsigned long long inlen, const unsigned char *k)
- __attribute__ ((nonnull));
+ __attribute__ ((nonnull(1, 4)));
SODIUM_EXPORT
void crypto_shorthash_keygen(unsigned char k[crypto_shorthash_KEYBYTES])
diff --git a/libs/libsodium/src/include/sodium/crypto_shorthash_siphash24.h b/libs/libsodium/src/include/sodium/crypto_shorthash_siphash24.h
index 0b4efd5156..e22633d529 100644
--- a/libs/libsodium/src/include/sodium/crypto_shorthash_siphash24.h
+++ b/libs/libsodium/src/include/sodium/crypto_shorthash_siphash24.h
@@ -24,7 +24,7 @@ size_t crypto_shorthash_siphash24_keybytes(void);
SODIUM_EXPORT
int crypto_shorthash_siphash24(unsigned char *out, const unsigned char *in,
unsigned long long inlen, const unsigned char *k)
- __attribute__ ((nonnull));
+ __attribute__ ((nonnull(1, 4)));
#ifndef SODIUM_LIBRARY_MINIMAL
/* -- 128-bit output -- */
@@ -40,7 +40,7 @@ size_t crypto_shorthash_siphashx24_keybytes(void);
SODIUM_EXPORT
int crypto_shorthash_siphashx24(unsigned char *out, const unsigned char *in,
unsigned long long inlen, const unsigned char *k)
- __attribute__ ((nonnull));
+ __attribute__ ((nonnull(1, 4)));
#endif
#ifdef __cplusplus
diff --git a/libs/libsodium/src/include/sodium/crypto_sign.h b/libs/libsodium/src/include/sodium/crypto_sign.h
index 7b2febbcb5..a20fbd3955 100644
--- a/libs/libsodium/src/include/sodium/crypto_sign.h
+++ b/libs/libsodium/src/include/sodium/crypto_sign.h
@@ -61,7 +61,7 @@ int crypto_sign_keypair(unsigned char *pk, unsigned char *sk)
SODIUM_EXPORT
int crypto_sign(unsigned char *sm, unsigned long long *smlen_p,
const unsigned char *m, unsigned long long mlen,
- const unsigned char *sk) __attribute__ ((nonnull(1, 3, 5)));
+ const unsigned char *sk) __attribute__ ((nonnull(1, 5)));
SODIUM_EXPORT
int crypto_sign_open(unsigned char *m, unsigned long long *mlen_p,
@@ -72,14 +72,14 @@ int crypto_sign_open(unsigned char *m, unsigned long long *mlen_p,
SODIUM_EXPORT
int crypto_sign_detached(unsigned char *sig, unsigned long long *siglen_p,
const unsigned char *m, unsigned long long mlen,
- const unsigned char *sk) __attribute__ ((nonnull(1, 3, 5)));
+ const unsigned char *sk) __attribute__ ((nonnull(1, 5)));
SODIUM_EXPORT
int crypto_sign_verify_detached(const unsigned char *sig,
const unsigned char *m,
unsigned long long mlen,
const unsigned char *pk)
- __attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
+ __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4)));
SODIUM_EXPORT
int crypto_sign_init(crypto_sign_state *state);
@@ -87,7 +87,7 @@ int crypto_sign_init(crypto_sign_state *state);
SODIUM_EXPORT
int crypto_sign_update(crypto_sign_state *state,
const unsigned char *m, unsigned long long mlen)
- __attribute__ ((nonnull));
+ __attribute__ ((nonnull(1)));
SODIUM_EXPORT
int crypto_sign_final_create(crypto_sign_state *state, unsigned char *sig,
diff --git a/libs/libsodium/src/include/sodium/crypto_sign_ed25519.h b/libs/libsodium/src/include/sodium/crypto_sign_ed25519.h
index c2024da017..cb230252ad 100644
--- a/libs/libsodium/src/include/sodium/crypto_sign_ed25519.h
+++ b/libs/libsodium/src/include/sodium/crypto_sign_ed25519.h
@@ -43,7 +43,7 @@ SODIUM_EXPORT
int crypto_sign_ed25519(unsigned char *sm, unsigned long long *smlen_p,
const unsigned char *m, unsigned long long mlen,
const unsigned char *sk)
- __attribute__ ((nonnull(1, 3, 5)));
+ __attribute__ ((nonnull(1, 5)));
SODIUM_EXPORT
int crypto_sign_ed25519_open(unsigned char *m, unsigned long long *mlen_p,
@@ -57,14 +57,14 @@ int crypto_sign_ed25519_detached(unsigned char *sig,
const unsigned char *m,
unsigned long long mlen,
const unsigned char *sk)
- __attribute__ ((nonnull(1, 3)));
+ __attribute__ ((nonnull(1, 5)));
SODIUM_EXPORT
int crypto_sign_ed25519_verify_detached(const unsigned char *sig,
const unsigned char *m,
unsigned long long mlen,
const unsigned char *pk)
- __attribute__ ((warn_unused_result));
+ __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4)));
SODIUM_EXPORT
int crypto_sign_ed25519_keypair(unsigned char *pk, unsigned char *sk)
@@ -102,14 +102,14 @@ SODIUM_EXPORT
int crypto_sign_ed25519ph_update(crypto_sign_ed25519ph_state *state,
const unsigned char *m,
unsigned long long mlen)
- __attribute__ ((nonnull));
+ __attribute__ ((nonnull(1)));
SODIUM_EXPORT
int crypto_sign_ed25519ph_final_create(crypto_sign_ed25519ph_state *state,
unsigned char *sig,
unsigned long long *siglen_p,
const unsigned char *sk)
- __attribute__ ((nonnull));
+ __attribute__ ((nonnull(1, 2, 4)));
SODIUM_EXPORT
int crypto_sign_ed25519ph_final_verify(crypto_sign_ed25519ph_state *state,
diff --git a/libs/libsodium/src/include/sodium/crypto_sign_edwards25519sha512batch.h b/libs/libsodium/src/include/sodium/crypto_sign_edwards25519sha512batch.h
deleted file mode 100644
index 208de4016c..0000000000
--- a/libs/libsodium/src/include/sodium/crypto_sign_edwards25519sha512batch.h
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef crypto_sign_edwards25519sha512batch_H
-#define crypto_sign_edwards25519sha512batch_H
-
-/*
- * WARNING: This construction was a prototype, which should not be used
- * any more in new projects.
- *
- * crypto_sign_edwards25519sha512batch is provided for applications
- * initially built with NaCl, but as recommended by the author of this
- * construction, new applications should use ed25519 instead.
- *
- * In Sodium, you should use the high-level crypto_sign_*() functions instead.
- */
-
-#include <stddef.h>
-#include "export.h"
-
-#ifdef __cplusplus
-# ifdef __GNUC__
-# pragma GCC diagnostic ignored "-Wlong-long"
-# endif
-extern "C" {
-#endif
-
-#define crypto_sign_edwards25519sha512batch_BYTES 64U
-#define crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES 32U
-#define crypto_sign_edwards25519sha512batch_SECRETKEYBYTES (32U + 32U)
-#define crypto_sign_edwards25519sha512batch_MESSAGEBYTES_MAX (SODIUM_SIZE_MAX - crypto_sign_edwards25519sha512batch_BYTES)
-
-SODIUM_EXPORT
-int crypto_sign_edwards25519sha512batch(unsigned char *sm,
- unsigned long long *smlen_p,
- const unsigned char *m,
- unsigned long long mlen,
- const unsigned char *sk)
- __attribute__ ((deprecated)) __attribute__ ((nonnull(1, 3, 5)));
-
-SODIUM_EXPORT
-int crypto_sign_edwards25519sha512batch_open(unsigned char *m,
- unsigned long long *mlen_p,
- const unsigned char *sm,
- unsigned long long smlen,
- const unsigned char *pk)
- __attribute__ ((deprecated)) __attribute__ ((nonnull(3, 5)));
-
-SODIUM_EXPORT
-int crypto_sign_edwards25519sha512batch_keypair(unsigned char *pk,
- unsigned char *sk)
- __attribute__ ((deprecated)) __attribute__ ((nonnull));
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/libs/libsodium/src/include/sodium/crypto_vrf.h b/libs/libsodium/src/include/sodium/crypto_vrf.h
new file mode 100644
index 0000000000..e3b65b94e9
--- /dev/null
+++ b/libs/libsodium/src/include/sodium/crypto_vrf.h
@@ -0,0 +1,75 @@
+#ifndef crypto_vrf_H
+#define crypto_vrf_H
+
+/*
+ * THREAD SAFETY: crypto_vrf_keypair() is thread-safe,
+ * provided that sodium_init() was called before.
+ *
+ * Other functions, including crypto_vrf_keypair_from_seed(), are always thread-safe.
+ */
+
+#include <stddef.h>
+
+#include "crypto_vrf_rfc9381.h"
+#include "export.h"
+
+#ifdef __cplusplus
+# ifdef __GNUC__
+# pragma GCC diagnostic ignored "-Wlong-long"
+# endif
+extern "C" {
+#endif
+
+#define crypto_vrf_PROOFBYTES crypto_vrf_rfc9381_BYTES
+SODIUM_EXPORT
+size_t crypto_vrf_bytes(void);
+
+#define crypto_vrf_OUTPUTBYTES crypto_vrf_rfc9381_OUTPUTBYTES
+SODIUM_EXPORT
+size_t crypto_vrf_outputbytes(void);
+
+#define crypto_vrf_SEEDBYTES crypto_vrf_rfc9381_SEEDBYTES
+SODIUM_EXPORT
+size_t crypto_vrf_seedbytes(void);
+
+#define crypto_vrf_PUBLICKEYBYTES crypto_vrf_rfc9381_PUBLICKEYBYTES
+SODIUM_EXPORT
+size_t crypto_vrf_publickeybytes(void);
+
+#define crypto_vrf_SECRETKEYBYTES crypto_vrf_rfc9381_SECRETKEYBYTES
+SODIUM_EXPORT
+size_t crypto_vrf_secretkeybytes(void);
+
+#define crypto_vrf_PRIMITIVE "rfc9381"
+SODIUM_EXPORT
+const char *crypto_vrf_primitive(void);
+
+SODIUM_EXPORT
+int crypto_vrf_keypair(unsigned char *pk, unsigned char *sk)
+ __attribute__ ((nonnull));
+
+SODIUM_EXPORT
+int crypto_vrf_seed_keypair(unsigned char *pk, unsigned char *sk,
+ const unsigned char *seed)
+ __attribute__ ((nonnull));
+
+SODIUM_EXPORT
+int crypto_vrf_prove(unsigned char *proof, const unsigned char *m,
+ unsigned long long mlen, const unsigned char *sk)
+ __attribute__ ((nonnull));
+
+SODIUM_EXPORT
+int crypto_vrf_verify(unsigned char *output,
+ const unsigned char *pk,
+ const unsigned char *proof,
+ const unsigned char *m, unsigned long long mlen)
+ __attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
+
+SODIUM_EXPORT
+int crypto_vrf_proof_to_hash(unsigned char *hash, const unsigned char *proof);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libs/libsodium/src/include/sodium/crypto_vrf_rfc9381.h b/libs/libsodium/src/include/sodium/crypto_vrf_rfc9381.h
new file mode 100644
index 0000000000..14bf2d06ea
--- /dev/null
+++ b/libs/libsodium/src/include/sodium/crypto_vrf_rfc9381.h
@@ -0,0 +1,78 @@
+
+#ifndef crypto_vrf_rfc9381_H
+#define crypto_vrf_rfc9381_H
+
+#include <stddef.h>
+
+#include "export.h"
+
+#ifdef __cplusplus
+# ifdef __GNUC__
+# pragma GCC diagnostic ignored "-Wlong-long"
+# endif
+extern "C" {
+#endif
+
+#define crypto_vrf_rfc9381_BYTES 80U
+SODIUM_EXPORT
+size_t crypto_vrf_rfc9381_bytes(void);
+
+#define crypto_vrf_rfc9381_OUTPUTBYTES 64U
+SODIUM_EXPORT
+size_t crypto_vrf_rfc9381_outputbytes(void);
+
+#define crypto_vrf_rfc9381_SEEDBYTES 32U
+SODIUM_EXPORT
+size_t crypto_vrf_rfc9381_seedbytes(void);
+
+#define crypto_vrf_rfc9381_PUBLICKEYBYTES 32U
+SODIUM_EXPORT
+size_t crypto_vrf_rfc9381_publickeybytes(void);
+
+#define crypto_vrf_rfc9381_SECRETKEYBYTES 64U
+SODIUM_EXPORT
+size_t crypto_vrf_rfc9381_secretkeybytes(void);
+
+SODIUM_EXPORT
+int crypto_vrf_rfc9381_prove(unsigned char *proof,
+ const unsigned char *m,
+ unsigned long long mlen, const unsigned char *sk);
+
+SODIUM_EXPORT
+int crypto_vrf_rfc9381_verify(unsigned char *output,
+ const unsigned char *pk,
+ const unsigned char *proof,
+ const unsigned char *m,
+ unsigned long long mlen)
+ __attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
+
+SODIUM_EXPORT
+int crypto_vrf_rfc9381_proof_to_hash(unsigned char *hash,
+ const unsigned char *proof)
+ __attribute__ ((nonnull));
+
+SODIUM_EXPORT
+int crypto_vrf_rfc9381_keypair(unsigned char *pk, unsigned char *sk)
+ __attribute__ ((nonnull));
+
+SODIUM_EXPORT
+int crypto_vrf_rfc9381_seed_keypair(unsigned char *pk,
+ unsigned char *sk,
+ const unsigned char *seed)
+ __attribute__ ((nonnull));
+
+SODIUM_EXPORT
+void crypto_vrf_rfc9381_sk_to_seed(unsigned char *seed,
+ const unsigned char *sk)
+ __attribute__ ((nonnull));
+
+SODIUM_EXPORT
+void crypto_vrf_rfc9381_sk_to_pk(unsigned char *pk,
+ const unsigned char *sk)
+ __attribute__ ((nonnull));
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libs/libsodium/src/include/sodium/private/asm_cet.h b/libs/libsodium/src/include/sodium/private/asm_cet.h
new file mode 100644
index 0000000000..4428c97f32
--- /dev/null
+++ b/libs/libsodium/src/include/sodium/private/asm_cet.h
@@ -0,0 +1,11 @@
+#ifndef asm_cet_H
+#define asm_cet_H 1
+
+#if HAVE_CET_H
+# include <cet.h>
+#endif
+#ifndef _CET_ENDBR
+# define _CET_ENDBR
+#endif
+
+#endif
diff --git a/libs/libsodium/src/include/sodium/private/chacha20_ietf_ext.h b/libs/libsodium/src/include/sodium/private/chacha20_ietf_ext.h
index d03cfd3329..d863013650 100644
--- a/libs/libsodium/src/include/sodium/private/chacha20_ietf_ext.h
+++ b/libs/libsodium/src/include/sodium/private/chacha20_ietf_ext.h
@@ -3,6 +3,8 @@
#include <stdint.h>
+#include "private/quirks.h"
+
/* The ietf_ext variant allows the internal counter to overflow into the IV */
int crypto_stream_chacha20_ietf_ext(unsigned char *c, unsigned long long clen,
diff --git a/libs/libsodium/src/include/sodium/private/common.h b/libs/libsodium/src/include/sodium/private/common.h
index aaf6030248..0ed3c63456 100644
--- a/libs/libsodium/src/include/sodium/private/common.h
+++ b/libs/libsodium/src/include/sodium/private/common.h
@@ -1,7 +1,7 @@
#ifndef common_H
#define common_H 1
-#if !defined(_MSC_VER) && 0
+#if !defined(_MSC_VER) && !defined(DEV_MODE) && 1
# warning *** This is unstable, untested, development code.
# warning It might not compile. It might not work as expected.
# warning It might be totally insecure.
@@ -20,6 +20,8 @@
#include <stdlib.h>
#include <string.h>
+#include "private/quirks.h"
+
#define COMPILER_ASSERT(X) (void) sizeof(char[(X) ? 1 : -1])
#ifdef HAVE_TI_MODE
@@ -226,24 +228,40 @@ xor_buf(unsigned char *out, const unsigned char *in, size_t n)
# endif
#endif
-#if defined(_MSC_VER) && \
- (defined(_M_X64) || defined(_M_AMD64) || defined(_M_IX86))
+#ifdef _MSC_VER
-# include <intrin.h>
+# if defined(_M_X64) || defined(_M_IX86)
+# include <intrin.h>
+
+# define HAVE_INTRIN_H 1
+# define HAVE_MMINTRIN_H 1
+# define HAVE_EMMINTRIN_H 1
+# define HAVE_PMMINTRIN_H 1
+# define HAVE_TMMINTRIN_H 1
+# define HAVE_SMMINTRIN_H 1
+# define HAVE_AVXINTRIN_H 1
+# if _MSC_VER >= 1600
+# define HAVE_WMMINTRIN_H 1
+# endif
+# if _MSC_VER >= 1700 && defined(_M_X64)
+# define HAVE_AVX2INTRIN_H 1
+# endif
+# if _MSC_VER >= 1910 && defined(_M_X64)
+# define HAVE_AVX512FINTRIN_H 1
+# endif
+
+# elif defined(_M_ARM64)
+
+# ifndef __ARM_ARCH
+# define __ARM_ARCH 1
+# endif
+# ifndef __ARM_NEON
+# define __ARM_NEON 1
+# endif
+# define HAVE_ARMCRYPTO 1
+
+# endif /* _MSC_VER */
-# define HAVE_INTRIN_H 1
-# define HAVE_MMINTRIN_H 1
-# define HAVE_EMMINTRIN_H 1
-# define HAVE_PMMINTRIN_H 1
-# define HAVE_TMMINTRIN_H 1
-# define HAVE_SMMINTRIN_H 1
-# define HAVE_AVXINTRIN_H 1
-# if _MSC_VER >= 1600
-# define HAVE_WMMINTRIN_H 1
-# endif
-# if _MSC_VER >= 1700 && defined(_M_X64)
-# define HAVE_AVX2INTRIN_H 1
-# endif
#elif defined(HAVE_INTRIN_H)
# include <intrin.h>
#endif
@@ -258,4 +276,12 @@ extern void ct_unpoison(const void *, size_t);
# define UNPOISON(X, L) (void) 0
#endif
+#ifdef HAVE_GCC_MEMORY_FENCES
+# define ACQUIRE_FENCE __atomic_thread_fence(__ATOMIC_ACQUIRE)
+#elif defined(HAVE_C11_MEMORY_FENCES)
+# define ACQUIRE_FENCE atomic_thread_fence(memory_order_acquire)
+#else
+# define ACQUIRE_FENCE (void) 0
+#endif
+
#endif
diff --git a/libs/libsodium/src/include/sodium/private/ed25519_ref10.h b/libs/libsodium/src/include/sodium/private/ed25519_ref10.h
index cbf258e0c1..9477df3ca4 100644
--- a/libs/libsodium/src/include/sodium/private/ed25519_ref10.h
+++ b/libs/libsodium/src/include/sodium/private/ed25519_ref10.h
@@ -4,6 +4,8 @@
#include <stddef.h>
#include <stdint.h>
+#include "private/quirks.h"
+
/*
fe means field element.
Here the field is \Z/(2^255-19).
@@ -25,7 +27,6 @@ void fe25519_tobytes(unsigned char *s, const fe25519 h);
# include "ed25519_ref10_fe_25_5.h"
#endif
-
/*
ge means group element.
@@ -81,35 +82,58 @@ int ge25519_frombytes(ge25519_p3 *h, const unsigned char *s);
int ge25519_frombytes_negate_vartime(ge25519_p3 *h, const unsigned char *s);
-void ge25519_p3_to_cached(ge25519_cached *r, const ge25519_p3 *p);
-
void ge25519_p1p1_to_p2(ge25519_p2 *r, const ge25519_p1p1 *p);
void ge25519_p1p1_to_p3(ge25519_p3 *r, const ge25519_p1p1 *p);
-void ge25519_add(ge25519_p1p1 *r, const ge25519_p3 *p, const ge25519_cached *q);
+void ge25519_p2_to_p3(ge25519_p3 *r, const ge25519_p2 *p);
-void ge25519_sub(ge25519_p1p1 *r, const ge25519_p3 *p, const ge25519_cached *q);
+void ge25519_p3_add(ge25519_p3 *r, const ge25519_p3 *p, const ge25519_p3 *q);
+
+void ge25519_p3_sub(ge25519_p3 *r, const ge25519_p3 *p, const ge25519_p3 *q);
void ge25519_scalarmult_base(ge25519_p3 *h, const unsigned char *a);
void ge25519_double_scalarmult_vartime(ge25519_p2 *r, const unsigned char *a,
const ge25519_p3 *A,
- const unsigned char *b);
+ const unsigned char *b,
+ const ge25519_p3 *B);
void ge25519_scalarmult(ge25519_p3 *h, const unsigned char *a,
const ge25519_p3 *p);
+void ge25519_clear_cofactor(ge25519_p3 *p3);
+
int ge25519_is_canonical(const unsigned char *s);
int ge25519_is_on_curve(const ge25519_p3 *p);
int ge25519_is_on_main_subgroup(const ge25519_p3 *p);
-int ge25519_has_small_order(const unsigned char s[32]);
+int ge25519_has_small_order(const ge25519_p3 *p);
void ge25519_from_uniform(unsigned char s[32], const unsigned char r[32]);
+void ge25519_from_hash(unsigned char s[32], const unsigned char h[64]);
+
+int ge25519_from_string(unsigned char p[32],
+ const char *ctx, const unsigned char *msg,
+ size_t msg_len, int hash_alg);
+
+int ge25519_from_string_ro(unsigned char p[32],
+ const char *ctx, const unsigned char *msg,
+ size_t msg_len, int hash_alg);
+
+/*
+ Ristretto group
+ */
+
+int ristretto255_frombytes(ge25519_p3 *h, const unsigned char *s);
+
+void ristretto255_p3_tobytes(unsigned char *s, const ge25519_p3 *h);
+
+void ristretto255_from_hash(unsigned char s[32], const unsigned char h[64]);
+
/*
The set of scalars is \Z/l
where l = 2^252 + 27742317777372353535851937790883648493.
@@ -117,11 +141,18 @@ void ge25519_from_uniform(unsigned char s[32], const unsigned char r[32]);
void sc25519_invert(unsigned char recip[32], const unsigned char s[32]);
+void sc25519_negate(unsigned char neg[32], const unsigned char s[32]);
+
void sc25519_reduce(unsigned char s[64]);
+void sc25519_mul(unsigned char s[32], const unsigned char a[32],
+ const unsigned char b[32]);
+
void sc25519_muladd(unsigned char s[32], const unsigned char a[32],
const unsigned char b[32], const unsigned char c[32]);
int sc25519_is_canonical(const unsigned char s[32]);
+void ge25519_clear_cofactor(ge25519_p3 *p3);
+
#endif
diff --git a/libs/libsodium/src/include/sodium/private/ed25519_ref10_fe_25_5.h b/libs/libsodium/src/include/sodium/private/ed25519_ref10_fe_25_5.h
index ffb689e4a4..4e933dba06 100644
--- a/libs/libsodium/src/include/sodium/private/ed25519_ref10_fe_25_5.h
+++ b/libs/libsodium/src/include/sodium/private/ed25519_ref10_fe_25_5.h
@@ -1,6 +1,7 @@
#include <string.h>
#include "private/common.h"
+#include "private/quirks.h"
#include "utils.h"
/*
@@ -147,29 +148,35 @@ fe25519_neg(fe25519 h, const fe25519 f)
static void
fe25519_cmov(fe25519 f, const fe25519 g, unsigned int b)
{
- const uint32_t mask = (uint32_t) (-(int32_t) b);
-
- int32_t f0 = f[0];
- int32_t f1 = f[1];
- int32_t f2 = f[2];
- int32_t f3 = f[3];
- int32_t f4 = f[4];
- int32_t f5 = f[5];
- int32_t f6 = f[6];
- int32_t f7 = f[7];
- int32_t f8 = f[8];
- int32_t f9 = f[9];
-
- int32_t x0 = f0 ^ g[0];
- int32_t x1 = f1 ^ g[1];
- int32_t x2 = f2 ^ g[2];
- int32_t x3 = f3 ^ g[3];
- int32_t x4 = f4 ^ g[4];
- int32_t x5 = f5 ^ g[5];
- int32_t x6 = f6 ^ g[6];
- int32_t x7 = f7 ^ g[7];
- int32_t x8 = f8 ^ g[8];
- int32_t x9 = f9 ^ g[9];
+ uint32_t mask = (uint32_t) (-(int32_t) b);
+ int32_t f0, f1, f2, f3, f4, f5, f6, f7, f8, f9;
+ int32_t x0, x1, x2, x3, x4, x5, x6, x7, x8, x9;
+
+ f0 = f[0];
+ f1 = f[1];
+ f2 = f[2];
+ f3 = f[3];
+ f4 = f[4];
+ f5 = f[5];
+ f6 = f[6];
+ f7 = f[7];
+ f8 = f[8];
+ f9 = f[9];
+
+ x0 = f0 ^ g[0];
+ x1 = f1 ^ g[1];
+ x2 = f2 ^ g[2];
+ x3 = f3 ^ g[3];
+ x4 = f4 ^ g[4];
+ x5 = f5 ^ g[5];
+ x6 = f6 ^ g[6];
+ x7 = f7 ^ g[7];
+ x8 = f8 ^ g[8];
+ x9 = f9 ^ g[9];
+
+#ifdef HAVE_INLINE_ASM
+ __asm__ __volatile__("" : "+r"(mask));
+#endif
x0 &= mask;
x1 &= mask;
@@ -197,40 +204,47 @@ fe25519_cmov(fe25519 f, const fe25519 g, unsigned int b)
static void
fe25519_cswap(fe25519 f, fe25519 g, unsigned int b)
{
- const uint32_t mask = (uint32_t) (-(int64_t) b);
-
- int32_t f0 = f[0];
- int32_t f1 = f[1];
- int32_t f2 = f[2];
- int32_t f3 = f[3];
- int32_t f4 = f[4];
- int32_t f5 = f[5];
- int32_t f6 = f[6];
- int32_t f7 = f[7];
- int32_t f8 = f[8];
- int32_t f9 = f[9];
-
- int32_t g0 = g[0];
- int32_t g1 = g[1];
- int32_t g2 = g[2];
- int32_t g3 = g[3];
- int32_t g4 = g[4];
- int32_t g5 = g[5];
- int32_t g6 = g[6];
- int32_t g7 = g[7];
- int32_t g8 = g[8];
- int32_t g9 = g[9];
-
- int32_t x0 = f0 ^ g0;
- int32_t x1 = f1 ^ g1;
- int32_t x2 = f2 ^ g2;
- int32_t x3 = f3 ^ g3;
- int32_t x4 = f4 ^ g4;
- int32_t x5 = f5 ^ g5;
- int32_t x6 = f6 ^ g6;
- int32_t x7 = f7 ^ g7;
- int32_t x8 = f8 ^ g8;
- int32_t x9 = f9 ^ g9;
+ uint32_t mask = (uint32_t) (-(int64_t) b);
+ int32_t f0, f1, f2, f3, f4, f5, f6, f7, f8, f9;
+ int32_t g0, g1, g2, g3, g4, g5, g6, g7, g8, g9;
+ int32_t x0, x1, x2, x3, x4, x5, x6, x7, x8, x9;
+
+ f0 = f[0];
+ f1 = f[1];
+ f2 = f[2];
+ f3 = f[3];
+ f4 = f[4];
+ f5 = f[5];
+ f6 = f[6];
+ f7 = f[7];
+ f8 = f[8];
+ f9 = f[9];
+
+ g0 = g[0];
+ g1 = g[1];
+ g2 = g[2];
+ g3 = g[3];
+ g4 = g[4];
+ g5 = g[5];
+ g6 = g[6];
+ g7 = g[7];
+ g8 = g[8];
+ g9 = g[9];
+
+ x0 = f0 ^ g0;
+ x1 = f1 ^ g1;
+ x2 = f2 ^ g2;
+ x3 = f3 ^ g3;
+ x4 = f4 ^ g4;
+ x5 = f5 ^ g5;
+ x6 = f6 ^ g6;
+ x7 = f7 ^ g7;
+ x8 = f8 ^ g8;
+ x9 = f9 ^ g9;
+
+#ifdef HAVE_INLINE_ASM
+ __asm__ __volatile__("" : "+r"(mask));
+#endif
x0 &= mask;
x1 &= mask;
@@ -273,27 +287,7 @@ fe25519_cswap(fe25519 f, fe25519 g, unsigned int b)
static inline void
fe25519_copy(fe25519 h, const fe25519 f)
{
- int32_t f0 = f[0];
- int32_t f1 = f[1];
- int32_t f2 = f[2];
- int32_t f3 = f[3];
- int32_t f4 = f[4];
- int32_t f5 = f[5];
- int32_t f6 = f[6];
- int32_t f7 = f[7];
- int32_t f8 = f[8];
- int32_t f9 = f[9];
-
- h[0] = f0;
- h[1] = f1;
- h[2] = f2;
- h[3] = f3;
- h[4] = f4;
- h[5] = f5;
- h[6] = f6;
- h[7] = f7;
- h[8] = f8;
- h[9] = f9;
+ memcpy(h, f, 10 * sizeof h[0]);
}
/*
@@ -978,8 +972,8 @@ fe25519_sq2(fe25519 h, const fe25519 f)
h[9] = (int32_t) h9;
}
-static void
-fe25519_scalar_product(fe25519 h, const fe25519 f, uint32_t n)
+static inline void
+fe25519_mul32(fe25519 h, const fe25519 f, uint32_t n)
{
int64_t sn = (int64_t) n;
int32_t f0 = f[0];
diff --git a/libs/libsodium/src/include/sodium/private/ed25519_ref10_fe_51.h b/libs/libsodium/src/include/sodium/private/ed25519_ref10_fe_51.h
index 28363083d9..ec6f3f3c40 100644
--- a/libs/libsodium/src/include/sodium/private/ed25519_ref10_fe_51.h
+++ b/libs/libsodium/src/include/sodium/private/ed25519_ref10_fe_51.h
@@ -1,6 +1,7 @@
#include <string.h>
#include "private/common.h"
+#include "private/quirks.h"
#include "utils.h"
/*
@@ -108,19 +109,50 @@ fe25519_neg(fe25519 h, const fe25519 f)
static void
fe25519_cmov(fe25519 f, const fe25519 g, unsigned int b)
{
- const uint64_t mask = (uint64_t) (-(int64_t) b);
+#ifdef HAVE_AMD64_ASM
+ uint64_t t0, t1, t2;
+
+ __asm__ __volatile__
+ (
+ "test %[c], %[c]\n"
+ "movq (%[b]), %[t0]\n"
+ "cmoveq (%[a]), %[t0]\n"
+ "movq 8(%[b]), %[t1]\n"
+ "cmoveq 8(%[a]), %[t1]\n"
+ "movq 16(%[b]), %[t2]\n"
+ "cmoveq 16(%[a]), %[t2]\n"
+ "movq %[t0], (%[a])\n"
+ "movq %[t1], 8(%[a])\n"
+ "movq 24(%[b]), %[t0]\n"
+ "cmoveq 24(%[a]), %[t0]\n"
+ "movq 32(%[b]), %[t1]\n"
+ "cmoveq 32(%[a]), %[t1]\n"
+ "movq %[t2], 16(%[a])\n"
+ "movq %[t0], 24(%[a])\n"
+ "movq %[t1], 32(%[a])\n"
+ : [ t0 ] "=&r"(t0), [ t1 ] "=&r"(t1), [ t2 ] "=&r"(t2)
+ : [ a ] "r"(f), [ b ] "r"(g), [ c ] "r"(b)
+ : "cc", "memory");
+#else
+ uint64_t mask = (uint64_t) (-(int64_t) b);
+ uint64_t f0, f1, f2, f3, f4;
+ uint64_t x0, x1, x2, x3, x4;
- uint64_t f0 = f[0];
- uint64_t f1 = f[1];
- uint64_t f2 = f[2];
- uint64_t f3 = f[3];
- uint64_t f4 = f[4];
+ f0 = f[0];
+ f1 = f[1];
+ f2 = f[2];
+ f3 = f[3];
+ f4 = f[4];
+
+ x0 = f0 ^ g[0];
+ x1 = f1 ^ g[1];
+ x2 = f2 ^ g[2];
+ x3 = f3 ^ g[3];
+ x4 = f4 ^ g[4];
- uint64_t x0 = f0 ^ g[0];
- uint64_t x1 = f1 ^ g[1];
- uint64_t x2 = f2 ^ g[2];
- uint64_t x3 = f3 ^ g[3];
- uint64_t x4 = f4 ^ g[4];
+# ifdef HAVE_INLINE_ASM
+ __asm__ __volatile__("" : "+r"(mask));
+# endif
x0 &= mask;
x1 &= mask;
@@ -133,6 +165,7 @@ fe25519_cmov(fe25519 f, const fe25519 g, unsigned int b)
f[2] = f2 ^ x2;
f[3] = f3 ^ x3;
f[4] = f4 ^ x4;
+#endif
}
/*
@@ -145,25 +178,32 @@ Preconditions: b in {0,1}.
static void
fe25519_cswap(fe25519 f, fe25519 g, unsigned int b)
{
- const uint64_t mask = (uint64_t) (-(int64_t) b);
-
- uint64_t f0 = f[0];
- uint64_t f1 = f[1];
- uint64_t f2 = f[2];
- uint64_t f3 = f[3];
- uint64_t f4 = f[4];
-
- uint64_t g0 = g[0];
- uint64_t g1 = g[1];
- uint64_t g2 = g[2];
- uint64_t g3 = g[3];
- uint64_t g4 = g[4];
-
- uint64_t x0 = f0 ^ g0;
- uint64_t x1 = f1 ^ g1;
- uint64_t x2 = f2 ^ g2;
- uint64_t x3 = f3 ^ g3;
- uint64_t x4 = f4 ^ g4;
+ uint64_t mask = (uint64_t) (-(int64_t) b);
+ uint64_t f0, f1, f2, f3, f4;
+ uint64_t g0, g1, g2, g3, g4;
+ uint64_t x0, x1, x2, x3, x4;
+
+ f0 = f[0];
+ f1 = f[1];
+ f2 = f[2];
+ f3 = f[3];
+ f4 = f[4];
+
+ g0 = g[0];
+ g1 = g[1];
+ g2 = g[2];
+ g3 = g[3];
+ g4 = g[4];
+
+ x0 = f0 ^ g0;
+ x1 = f1 ^ g1;
+ x2 = f2 ^ g2;
+ x3 = f3 ^ g3;
+ x4 = f4 ^ g4;
+
+# ifdef HAVE_INLINE_ASM
+ __asm__ __volatile__("" : "+r"(mask));
+# endif
x0 &= mask;
x1 &= mask;
@@ -191,17 +231,7 @@ fe25519_cswap(fe25519 f, fe25519 g, unsigned int b)
static inline void
fe25519_copy(fe25519 h, const fe25519 f)
{
- uint64_t f0 = f[0];
- uint64_t f1 = f[1];
- uint64_t f2 = f[2];
- uint64_t f3 = f[3];
- uint64_t f4 = f[4];
-
- h[0] = f0;
- h[1] = f1;
- h[2] = f2;
- h[3] = f3;
- h[4] = f4;
+ memcpy(h, f, 5 * sizeof h[0]);
}
/*
@@ -243,80 +273,57 @@ static void
fe25519_mul(fe25519 h, const fe25519 f, const fe25519 g)
{
const uint64_t mask = 0x7ffffffffffffULL;
- uint128_t r0, r1, r2, r3, r4, carry;
- uint64_t f0, f1, f2, f3, f4;
- uint64_t f1_19, f2_19, f3_19, f4_19;
- uint64_t g0, g1, g2, g3, g4;
+ uint128_t r0, r1, r2, r3, r4;
+ uint128_t f0, f1, f2, f3, f4;
+ uint128_t f1_19, f2_19, f3_19, f4_19;
+ uint128_t g0, g1, g2, g3, g4;
uint64_t r00, r01, r02, r03, r04;
+ uint64_t carry;
- f0 = f[0];
- f1 = f[1];
- f2 = f[2];
- f3 = f[3];
- f4 = f[4];
+ f0 = (uint128_t) f[0];
+ f1 = (uint128_t) f[1];
+ f2 = (uint128_t) f[2];
+ f3 = (uint128_t) f[3];
+ f4 = (uint128_t) f[4];
- g0 = g[0];
- g1 = g[1];
- g2 = g[2];
- g3 = g[3];
- g4 = g[4];
+ g0 = (uint128_t) g[0];
+ g1 = (uint128_t) g[1];
+ g2 = (uint128_t) g[2];
+ g3 = (uint128_t) g[3];
+ g4 = (uint128_t) g[4];
f1_19 = 19ULL * f1;
f2_19 = 19ULL * f2;
f3_19 = 19ULL * f3;
f4_19 = 19ULL * f4;
- r0 = ((uint128_t) f0 ) * ((uint128_t) g0);
- r0 += ((uint128_t) f1_19) * ((uint128_t) g4);
- r0 += ((uint128_t) f2_19) * ((uint128_t) g3);
- r0 += ((uint128_t) f3_19) * ((uint128_t) g2);
- r0 += ((uint128_t) f4_19) * ((uint128_t) g1);
-
- r1 = ((uint128_t) f0 ) * ((uint128_t) g1);
- r1 += ((uint128_t) f1 ) * ((uint128_t) g0);
- r1 += ((uint128_t) f2_19) * ((uint128_t) g4);
- r1 += ((uint128_t) f3_19) * ((uint128_t) g3);
- r1 += ((uint128_t) f4_19) * ((uint128_t) g2);
-
- r2 = ((uint128_t) f0 ) * ((uint128_t) g2);
- r2 += ((uint128_t) f1 ) * ((uint128_t) g1);
- r2 += ((uint128_t) f2 ) * ((uint128_t) g0);
- r2 += ((uint128_t) f3_19) * ((uint128_t) g4);
- r2 += ((uint128_t) f4_19) * ((uint128_t) g3);
-
- r3 = ((uint128_t) f0 ) * ((uint128_t) g3);
- r3 += ((uint128_t) f1 ) * ((uint128_t) g2);
- r3 += ((uint128_t) f2 ) * ((uint128_t) g1);
- r3 += ((uint128_t) f3 ) * ((uint128_t) g0);
- r3 += ((uint128_t) f4_19) * ((uint128_t) g4);
-
- r4 = ((uint128_t) f0 ) * ((uint128_t) g4);
- r4 += ((uint128_t) f1 ) * ((uint128_t) g3);
- r4 += ((uint128_t) f2 ) * ((uint128_t) g2);
- r4 += ((uint128_t) f3 ) * ((uint128_t) g1);
- r4 += ((uint128_t) f4 ) * ((uint128_t) g0);
+ r0 = f0 * g0 + f1_19 * g4 + f2_19 * g3 + f3_19 * g2 + f4_19 * g1;
+ r1 = f0 * g1 + f1 * g0 + f2_19 * g4 + f3_19 * g3 + f4_19 * g2;
+ r2 = f0 * g2 + f1 * g1 + f2 * g0 + f3_19 * g4 + f4_19 * g3;
+ r3 = f0 * g3 + f1 * g2 + f2 * g1 + f3 * g0 + f4_19 * g4;
+ r4 = f0 * g4 + f1 * g3 + f2 * g2 + f3 * g1 + f4 * g0;
r00 = ((uint64_t) r0) & mask;
- carry = r0 >> 51;
+ carry = (uint64_t) (r0 >> 51);
r1 += carry;
r01 = ((uint64_t) r1) & mask;
- carry = r1 >> 51;
+ carry = (uint64_t) (r1 >> 51);
r2 += carry;
r02 = ((uint64_t) r2) & mask;
- carry = r2 >> 51;
+ carry = (uint64_t) (r2 >> 51);
r3 += carry;
r03 = ((uint64_t) r3) & mask;
- carry = r3 >> 51;
+ carry = (uint64_t) (r3 >> 51);
r4 += carry;
r04 = ((uint64_t) r4) & mask;
- carry = r4 >> 51;
- r00 += 19ULL * (uint64_t) carry;
+ carry = (uint64_t) (r4 >> 51);
+ r00 += 19ULL * carry;
carry = r00 >> 51;
r00 &= mask;
- r01 += (uint64_t) carry;
+ r01 += carry;
carry = r01 >> 51;
r01 &= mask;
- r02 += (uint64_t) carry;
+ r02 += carry;
h[0] = r00;
h[1] = r01;
@@ -334,16 +341,17 @@ static void
fe25519_sq(fe25519 h, const fe25519 f)
{
const uint64_t mask = 0x7ffffffffffffULL;
- uint128_t r0, r1, r2, r3, r4, carry;
- uint64_t f0, f1, f2, f3, f4;
- uint64_t f0_2, f1_2, f1_38, f2_38, f3_38, f3_19, f4_19;
+ uint128_t r0, r1, r2, r3, r4;
+ uint128_t f0, f1, f2, f3, f4;
+ uint128_t f0_2, f1_2, f1_38, f2_38, f3_38, f3_19, f4_19;
uint64_t r00, r01, r02, r03, r04;
+ uint64_t carry;
- f0 = f[0];
- f1 = f[1];
- f2 = f[2];
- f3 = f[3];
- f4 = f[4];
+ f0 = (uint128_t) f[0];
+ f1 = (uint128_t) f[1];
+ f2 = (uint128_t) f[2];
+ f3 = (uint128_t) f[3];
+ f4 = (uint128_t) f[4];
f0_2 = f0 << 1;
f1_2 = f1 << 1;
@@ -355,47 +363,33 @@ fe25519_sq(fe25519 h, const fe25519 f)
f3_19 = 19ULL * f3;
f4_19 = 19ULL * f4;
- r0 = ((uint128_t) f0 ) * ((uint128_t) f0);
- r0 += ((uint128_t) f1_38) * ((uint128_t) f4);
- r0 += ((uint128_t) f2_38) * ((uint128_t) f3);
-
- r1 = ((uint128_t) f0_2 ) * ((uint128_t) f1);
- r1 += ((uint128_t) f2_38) * ((uint128_t) f4);
- r1 += ((uint128_t) f3_19) * ((uint128_t) f3);
-
- r2 = ((uint128_t) f0_2 ) * ((uint128_t) f2);
- r2 += ((uint128_t) f1 ) * ((uint128_t) f1);
- r2 += ((uint128_t) f3_38) * ((uint128_t) f4);
-
- r3 = ((uint128_t) f0_2 ) * ((uint128_t) f3);
- r3 += ((uint128_t) f1_2 ) * ((uint128_t) f2);
- r3 += ((uint128_t) f4_19) * ((uint128_t) f4);
-
- r4 = ((uint128_t) f0_2 ) * ((uint128_t) f4);
- r4 += ((uint128_t) f1_2 ) * ((uint128_t) f3);
- r4 += ((uint128_t) f2 ) * ((uint128_t) f2);
+ r0 = f0 * f0 + f1_38 * f4 + f2_38 * f3;
+ r1 = f0_2 * f1 + f2_38 * f4 + f3_19 * f3;
+ r2 = f0_2 * f2 + f1 * f1 + f3_38 * f4;
+ r3 = f0_2 * f3 + f1_2 * f2 + f4_19 * f4;
+ r4 = f0_2 * f4 + f1_2 * f3 + f2 * f2;
r00 = ((uint64_t) r0) & mask;
- carry = r0 >> 51;
+ carry = (uint64_t) (r0 >> 51);
r1 += carry;
r01 = ((uint64_t) r1) & mask;
- carry = r1 >> 51;
+ carry = (uint64_t) (r1 >> 51);
r2 += carry;
r02 = ((uint64_t) r2) & mask;
- carry = r2 >> 51;
+ carry = (uint64_t) (r2 >> 51);
r3 += carry;
r03 = ((uint64_t) r3) & mask;
- carry = r3 >> 51;
+ carry = (uint64_t) (r3 >> 51);
r4 += carry;
r04 = ((uint64_t) r4) & mask;
- carry = r4 >> 51;
- r00 += 19ULL * (uint64_t) carry;
+ carry = (uint64_t) (r4 >> 51);
+ r00 += 19ULL * carry;
carry = r00 >> 51;
r00 &= mask;
- r01 += (uint64_t) carry;
+ r01 += carry;
carry = r01 >> 51;
r01 &= mask;
- r02 += (uint64_t) carry;
+ r02 += carry;
h[0] = r00;
h[1] = r01;
@@ -413,16 +407,17 @@ static void
fe25519_sq2(fe25519 h, const fe25519 f)
{
const uint64_t mask = 0x7ffffffffffffULL;
- uint128_t r0, r1, r2, r3, r4, carry;
- uint64_t f0, f1, f2, f3, f4;
- uint64_t f0_2, f1_2, f1_38, f2_38, f3_38, f3_19, f4_19;
+ uint128_t r0, r1, r2, r3, r4;
+ uint128_t f0, f1, f2, f3, f4;
+ uint128_t f0_2, f1_2, f1_38, f2_38, f3_38, f3_19, f4_19;
uint64_t r00, r01, r02, r03, r04;
+ uint64_t carry;
- f0 = f[0];
- f1 = f[1];
- f2 = f[2];
- f3 = f[3];
- f4 = f[4];
+ f0 = (uint128_t) f[0];
+ f1 = (uint128_t) f[1];
+ f2 = (uint128_t) f[2];
+ f3 = (uint128_t) f[3];
+ f4 = (uint128_t) f[4];
f0_2 = f0 << 1;
f1_2 = f1 << 1;
@@ -434,25 +429,11 @@ fe25519_sq2(fe25519 h, const fe25519 f)
f3_19 = 19ULL * f3;
f4_19 = 19ULL * f4;
- r0 = ((uint128_t) f0 ) * ((uint128_t) f0);
- r0 += ((uint128_t) f1_38) * ((uint128_t) f4);
- r0 += ((uint128_t) f2_38) * ((uint128_t) f3);
-
- r1 = ((uint128_t) f0_2 ) * ((uint128_t) f1);
- r1 += ((uint128_t) f2_38) * ((uint128_t) f4);
- r1 += ((uint128_t) f3_19) * ((uint128_t) f3);
-
- r2 = ((uint128_t) f0_2 ) * ((uint128_t) f2);
- r2 += ((uint128_t) f1 ) * ((uint128_t) f1);
- r2 += ((uint128_t) f3_38) * ((uint128_t) f4);
-
- r3 = ((uint128_t) f0_2 ) * ((uint128_t) f3);
- r3 += ((uint128_t) f1_2 ) * ((uint128_t) f2);
- r3 += ((uint128_t) f4_19) * ((uint128_t) f4);
-
- r4 = ((uint128_t) f0_2 ) * ((uint128_t) f4);
- r4 += ((uint128_t) f1_2 ) * ((uint128_t) f3);
- r4 += ((uint128_t) f2 ) * ((uint128_t) f2);
+ r0 = f0 * f0 + f1_38 * f4 + f2_38 * f3;
+ r1 = f0_2 * f1 + f2_38 * f4 + f3_19 * f3;
+ r2 = f0_2 * f2 + f1 * f1 + f3_38 * f4;
+ r3 = f0_2 * f3 + f1_2 * f2 + f4_19 * f4;
+ r4 = f0_2 * f4 + f1_2 * f3 + f2 * f2;
r0 <<= 1;
r1 <<= 1;
@@ -461,26 +442,26 @@ fe25519_sq2(fe25519 h, const fe25519 f)
r4 <<= 1;
r00 = ((uint64_t) r0) & mask;
- carry = r0 >> 51;
+ carry = (uint64_t) (r0 >> 51);
r1 += carry;
r01 = ((uint64_t) r1) & mask;
- carry = r1 >> 51;
+ carry = (uint64_t) (r1 >> 51);
r2 += carry;
r02 = ((uint64_t) r2) & mask;
- carry = r2 >> 51;
+ carry = (uint64_t) (r2 >> 51);
r3 += carry;
r03 = ((uint64_t) r3) & mask;
- carry = r3 >> 51;
+ carry = (uint64_t) (r3 >> 51);
r4 += carry;
r04 = ((uint64_t) r4) & mask;
- carry = r4 >> 51;
- r00 += 19ULL * (uint64_t) carry;
+ carry = (uint64_t) (r4 >> 51);
+ r00 += 19ULL * carry;
carry = r00 >> 51;
r00 &= mask;
- r01 += (uint64_t) carry;
+ r01 += carry;
carry = r01 >> 51;
r01 &= mask;
- r02 += (uint64_t) carry;
+ r02 += carry;
h[0] = r00;
h[1] = r01;
@@ -489,8 +470,8 @@ fe25519_sq2(fe25519 h, const fe25519 f)
h[4] = r04;
}
-static void
-fe25519_scalar_product(fe25519 h, const fe25519 f, uint32_t n)
+static inline void
+fe25519_mul32(fe25519 h, const fe25519 f, uint32_t n)
{
const uint64_t mask = 0x7ffffffffffffULL;
uint128_t a;
diff --git a/libs/libsodium/src/include/sodium/private/implementations.h b/libs/libsodium/src/include/sodium/private/implementations.h
index 926c3a61a6..b322dbadf3 100644
--- a/libs/libsodium/src/include/sodium/private/implementations.h
+++ b/libs/libsodium/src/include/sodium/private/implementations.h
@@ -1,11 +1,15 @@
#ifndef implementations_H
#define implementations_H
+#include "private/quirks.h"
+
int _crypto_generichash_blake2b_pick_best_implementation(void);
int _crypto_onetimeauth_poly1305_pick_best_implementation(void);
int _crypto_pwhash_argon2_pick_best_implementation(void);
int _crypto_scalarmult_curve25519_pick_best_implementation(void);
int _crypto_stream_chacha20_pick_best_implementation(void);
int _crypto_stream_salsa20_pick_best_implementation(void);
+int _crypto_aead_aegis128l_pick_best_implementation(void);
+int _crypto_aead_aegis256_pick_best_implementation(void);
#endif
diff --git a/libs/libsodium/src/include/sodium/private/mutex.h b/libs/libsodium/src/include/sodium/private/mutex.h
index 03433173eb..0e198c7aa0 100644
--- a/libs/libsodium/src/include/sodium/private/mutex.h
+++ b/libs/libsodium/src/include/sodium/private/mutex.h
@@ -1,6 +1,8 @@
#ifndef mutex_H
#define mutex_H 1
+#include "private/quirks.h"
+
extern int sodium_crit_enter(void);
extern int sodium_crit_leave(void);
diff --git a/libs/libsodium/src/include/sodium/private/quirks.h b/libs/libsodium/src/include/sodium/private/quirks.h
new file mode 100644
index 0000000000..ffd861ee43
--- /dev/null
+++ b/libs/libsodium/src/include/sodium/private/quirks.h
@@ -0,0 +1,87 @@
+/* This is an automatically generated file */
+
+#ifndef quirks_H
+#ifndef NO_QUIRKS
+
+#define argon2_ctx _sodium_argon2_ctx
+#define argon2_decode_string _sodium_argon2_decode_string
+#define argon2_encode_string _sodium_argon2_encode_string
+#define argon2_fill_memory_blocks _sodium_argon2_fill_memory_blocks
+#define argon2_fill_segment_avx2 _sodium_argon2_fill_segment_avx2
+#define argon2_fill_segment_avx512f _sodium_argon2_fill_segment_avx512f
+#define argon2_fill_segment_ref _sodium_argon2_fill_segment_ref
+#define argon2_fill_segment_ssse3 _sodium_argon2_fill_segment_ssse3
+#define argon2_finalize _sodium_argon2_finalize
+#define argon2_hash _sodium_argon2_hash
+#define argon2_initialize _sodium_argon2_initialize
+#define argon2_validate_inputs _sodium_argon2_validate_inputs
+#define argon2_verify _sodium_argon2_verify
+#define argon2i_hash_encoded _sodium_argon2i_hash_encoded
+#define argon2i_hash_raw _sodium_argon2i_hash_raw
+#define argon2i_verify _sodium_argon2i_verify
+#define argon2id_hash_encoded _sodium_argon2id_hash_encoded
+#define argon2id_hash_raw _sodium_argon2id_hash_raw
+#define argon2id_verify _sodium_argon2id_verify
+#define blake2b _sodium_blake2b
+#define blake2b_compress_avx2 _sodium_blake2b_compress_avx2
+#define blake2b_compress_ref _sodium_blake2b_compress_ref
+#define blake2b_compress_sse41 _sodium_blake2b_compress_sse41
+#define blake2b_compress_ssse3 _sodium_blake2b_compress_ssse3
+#define blake2b_final _sodium_blake2b_final
+#define blake2b_init _sodium_blake2b_init
+#define blake2b_init_key _sodium_blake2b_init_key
+#define blake2b_init_key_salt_personal _sodium_blake2b_init_key_salt_personal
+#define blake2b_init_param _sodium_blake2b_init_param
+#define blake2b_init_salt_personal _sodium_blake2b_init_salt_personal
+#define blake2b_long _sodium_blake2b_long
+#define blake2b_pick_best_implementation _sodium_blake2b_pick_best_implementation
+#define blake2b_salt_personal _sodium_blake2b_salt_personal
+#define blake2b_update _sodium_blake2b_update
+#define core_h2c_string_to_hash _sodium_core_h2c_string_to_hash
+#define escrypt_PBKDF2_SHA256 _sodium_escrypt_PBKDF2_SHA256
+#define escrypt_alloc_region _sodium_escrypt_alloc_region
+#define escrypt_free_local _sodium_escrypt_free_local
+#define escrypt_free_region _sodium_escrypt_free_region
+#define escrypt_gensalt_r _sodium_escrypt_gensalt_r
+#define escrypt_init_local _sodium_escrypt_init_local
+#define escrypt_kdf_nosse _sodium_escrypt_kdf_nosse
+#define escrypt_kdf_sse _sodium_escrypt_kdf_sse
+#define escrypt_parse_setting _sodium_escrypt_parse_setting
+#define escrypt_r _sodium_escrypt_r
+#define fe25519_frombytes _sodium_fe25519_frombytes
+#define fe25519_invert _sodium_fe25519_invert
+#define fe25519_tobytes _sodium_fe25519_tobytes
+#define ge25519_clear_cofactor _sodium_ge25519_clear_cofactor
+#define ge25519_double_scalarmult_vartime _sodium_ge25519_double_scalarmult_vartime
+#define ge25519_from_hash _sodium_ge25519_from_hash
+#define ge25519_from_string _sodium_ge25519_from_string
+#define ge25519_from_string_ro _sodium_ge25519_from_string_ro
+#define ge25519_from_uniform _sodium_ge25519_from_uniform
+#define ge25519_frombytes _sodium_ge25519_frombytes
+#define ge25519_frombytes_negate_vartime _sodium_ge25519_frombytes_negate_vartime
+#define ge25519_has_small_order _sodium_ge25519_has_small_order
+#define ge25519_is_canonical _sodium_ge25519_is_canonical
+#define ge25519_is_on_curve _sodium_ge25519_is_on_curve
+#define ge25519_is_on_main_subgroup _sodium_ge25519_is_on_main_subgroup
+#define ge25519_p1p1_to_p2 _sodium_ge25519_p1p1_to_p2
+#define ge25519_p1p1_to_p3 _sodium_ge25519_p1p1_to_p3
+#define ge25519_p2_to_p3 _sodium_ge25519_p2_to_p3
+#define ge25519_p3_add _sodium_ge25519_p3_add
+#define ge25519_p3_sub _sodium_ge25519_p3_sub
+#define ge25519_p3_tobytes _sodium_ge25519_p3_tobytes
+#define ge25519_scalarmult _sodium_ge25519_scalarmult
+#define ge25519_scalarmult_base _sodium_ge25519_scalarmult_base
+#define ge25519_tobytes _sodium_ge25519_tobytes
+#define ristretto255_from_hash _sodium_ristretto255_from_hash
+#define ristretto255_frombytes _sodium_ristretto255_frombytes
+#define ristretto255_p3_tobytes _sodium_ristretto255_p3_tobytes
+#define sc25519_invert _sodium_sc25519_invert
+#define sc25519_is_canonical _sodium_sc25519_is_canonical
+#define sc25519_mul _sodium_sc25519_mul
+#define sc25519_muladd _sodium_sc25519_muladd
+#define sc25519_negate _sodium_sc25519_negate
+#define sc25519_reduce _sodium_sc25519_reduce
+#define softaes_block_encrypt _sodium_softaes_block_encrypt
+
+#endif
+#endif
diff --git a/libs/libsodium/src/include/sodium/private/softaes.h b/libs/libsodium/src/include/sodium/private/softaes.h
new file mode 100644
index 0000000000..f7a2bd24e4
--- /dev/null
+++ b/libs/libsodium/src/include/sodium/private/softaes.h
@@ -0,0 +1,56 @@
+#ifndef softaes_H
+#define softaes_H 1
+
+#include <stdint.h>
+
+#include "private/common.h"
+
+typedef struct SoftAesBlock {
+ uint32_t w0;
+ uint32_t w1;
+ uint32_t w2;
+ uint32_t w3;
+} SoftAesBlock;
+
+SoftAesBlock softaes_block_encrypt(const SoftAesBlock block, const SoftAesBlock rk);
+
+static inline SoftAesBlock
+softaes_block_load(const uint8_t in[16])
+{
+ const SoftAesBlock out = { LOAD32_LE(in + 0), LOAD32_LE(in + 4), LOAD32_LE(in + 8),
+ LOAD32_LE(in + 12) };
+ return out;
+}
+
+static inline SoftAesBlock
+softaes_block_load64x2(const uint64_t a, const uint64_t b)
+{
+ const SoftAesBlock out = { (uint32_t) b, (uint32_t) (b >> 32), (uint32_t) a,
+ (uint32_t) (a >> 32) };
+ return out;
+}
+
+static inline void
+softaes_block_store(uint8_t out[16], const SoftAesBlock in)
+{
+ STORE32_LE(out + 0, in.w0);
+ STORE32_LE(out + 4, in.w1);
+ STORE32_LE(out + 8, in.w2);
+ STORE32_LE(out + 12, in.w3);
+}
+
+static inline SoftAesBlock
+softaes_block_xor(const SoftAesBlock a, const SoftAesBlock b)
+{
+ const SoftAesBlock out = { a.w0 ^ b.w0, a.w1 ^ b.w1, a.w2 ^ b.w2, a.w3 ^ b.w3 };
+ return out;
+}
+
+static inline SoftAesBlock
+softaes_block_and(const SoftAesBlock a, const SoftAesBlock b)
+{
+ const SoftAesBlock out = { a.w0 & b.w0, a.w1 & b.w1, a.w2 & b.w2, a.w3 & b.w3 };
+ return out;
+}
+
+#endif
diff --git a/libs/libsodium/src/include/sodium/private/sse2_64_32.h b/libs/libsodium/src/include/sodium/private/sse2_64_32.h
index 8c4889a05e..bea6713d1b 100644
--- a/libs/libsodium/src/include/sodium/private/sse2_64_32.h
+++ b/libs/libsodium/src/include/sodium/private/sse2_64_32.h
@@ -1,7 +1,7 @@
#ifndef sse2_64_32_H
#define sse2_64_32_H 1
-#include "common.h"
+#include "private/common.h"
#ifdef HAVE_INTRIN_H
# include <intrin.h>
@@ -9,7 +9,7 @@
#if defined(HAVE_EMMINTRIN_H) && \
!(defined(__amd64) || defined(__amd64__) || defined(__x86_64__) || \
- defined(_M_X64) || defined(_M_AMD64))
+ defined(_M_X64))
# include <emmintrin.h>
# include <stdint.h>
diff --git a/libs/libsodium/src/include/sodium/randombytes.h b/libs/libsodium/src/include/sodium/randombytes.h
index 47dc62f63e..8bb4c62a6b 100644
--- a/libs/libsodium/src/include/sodium/randombytes.h
+++ b/libs/libsodium/src/include/sodium/randombytes.h
@@ -53,7 +53,7 @@ SODIUM_EXPORT
int randombytes_close(void);
SODIUM_EXPORT
-int randombytes_set_implementation(randombytes_implementation *impl)
+int randombytes_set_implementation(const randombytes_implementation *impl)
__attribute__ ((nonnull));
SODIUM_EXPORT
diff --git a/libs/libsodium/src/include/sodium/randombytes_internal_random.h b/libs/libsodium/src/include/sodium/randombytes_internal_random.h
new file mode 100644
index 0000000000..2b2b7d6edc
--- /dev/null
+++ b/libs/libsodium/src/include/sodium/randombytes_internal_random.h
@@ -0,0 +1,22 @@
+
+#ifndef randombytes_internal_random_H
+#define randombytes_internal_random_H
+
+#include "export.h"
+#include "randombytes.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+SODIUM_EXPORT
+extern struct randombytes_implementation randombytes_internal_implementation;
+
+/* Backwards compatibility with libsodium < 1.0.18 */
+#define randombytes_salsa20_implementation randombytes_internal_implementation
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/libs/libsodium/src/include/sodium/randombytes_nativeclient.h b/libs/libsodium/src/include/sodium/randombytes_nativeclient.h
deleted file mode 100644
index ba014929e4..0000000000
--- a/libs/libsodium/src/include/sodium/randombytes_nativeclient.h
+++ /dev/null
@@ -1,23 +0,0 @@
-
-#ifndef randombytes_nativeclient_H
-#define randombytes_nativeclient_H
-
-#ifdef __native_client__
-
-# include "export.h"
-# include "randombytes.h"
-
-# ifdef __cplusplus
-extern "C" {
-# endif
-
-SODIUM_EXPORT
-extern struct randombytes_implementation randombytes_nativeclient_implementation;
-
-# ifdef __cplusplus
-}
-# endif
-
-#endif
-
-#endif
diff --git a/libs/libsodium/src/include/sodium/randombytes_salsa20_random.h b/libs/libsodium/src/include/sodium/randombytes_salsa20_random.h
deleted file mode 100644
index d3a1da6ad5..0000000000
--- a/libs/libsodium/src/include/sodium/randombytes_salsa20_random.h
+++ /dev/null
@@ -1,19 +0,0 @@
-
-#ifndef randombytes_salsa20_random_H
-#define randombytes_salsa20_random_H
-
-#include "export.h"
-#include "randombytes.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-SODIUM_EXPORT
-extern struct randombytes_implementation randombytes_salsa20_implementation;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/libs/libsodium/src/include/sodium/runtime.h b/libs/libsodium/src/include/sodium/runtime.h
index 4cd8c2c499..85228bd840 100644
--- a/libs/libsodium/src/include/sodium/runtime.h
+++ b/libs/libsodium/src/include/sodium/runtime.h
@@ -12,6 +12,9 @@ SODIUM_EXPORT_WEAK
int sodium_runtime_has_neon(void);
SODIUM_EXPORT_WEAK
+int sodium_runtime_has_armcrypto(void);
+
+SODIUM_EXPORT_WEAK
int sodium_runtime_has_sse2(void);
SODIUM_EXPORT_WEAK
diff --git a/libs/libsodium/src/include/sodium/utils.h b/libs/libsodium/src/include/sodium/utils.h
index 8054e1ab4a..655431bf56 100644
--- a/libs/libsodium/src/include/sodium/utils.h
+++ b/libs/libsodium/src/include/sodium/utils.h
@@ -19,7 +19,7 @@ extern "C" {
#endif
SODIUM_EXPORT
-void sodium_memzero(void * const pnt, const size_t len) __attribute__ ((nonnull));
+void sodium_memzero(void * const pnt, const size_t len);
SODIUM_EXPORT
void sodium_stackzero(const size_t len);
@@ -32,7 +32,7 @@ void sodium_stackzero(const size_t len);
*/
SODIUM_EXPORT
int sodium_memcmp(const void * const b1_, const void * const b2_, size_t len)
- __attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
+ __attribute__ ((warn_unused_result));
/*
* sodium_compare() returns -1 if b1_ < b2_, 1 if b1_ > b2_ and 0 if b1_ == b2_
@@ -42,8 +42,7 @@ int sodium_memcmp(const void * const b1_, const void * const b2_, size_t len)
*/
SODIUM_EXPORT
int sodium_compare(const unsigned char *b1_, const unsigned char *b2_,
- size_t len)
- __attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
+ size_t len) __attribute__ ((warn_unused_result));
SODIUM_EXPORT
int sodium_is_zero(const unsigned char *n, const size_t nlen);
@@ -52,24 +51,22 @@ SODIUM_EXPORT
void sodium_increment(unsigned char *n, const size_t nlen);
SODIUM_EXPORT
-void sodium_add(unsigned char *a, const unsigned char *b, const size_t len)
- __attribute__ ((nonnull));
+void sodium_add(unsigned char *a, const unsigned char *b, const size_t len);
SODIUM_EXPORT
-void sodium_sub(unsigned char *a, const unsigned char *b, const size_t len)
- __attribute__ ((nonnull));
+void sodium_sub(unsigned char *a, const unsigned char *b, const size_t len);
SODIUM_EXPORT
char *sodium_bin2hex(char * const hex, const size_t hex_maxlen,
const unsigned char * const bin, const size_t bin_len)
- __attribute__ ((nonnull));
+ __attribute__ ((nonnull(1)));
SODIUM_EXPORT
int sodium_hex2bin(unsigned char * const bin, const size_t bin_maxlen,
const char * const hex, const size_t hex_len,
const char * const ignore, size_t * const bin_len,
const char ** const hex_end)
- __attribute__ ((nonnull(1, 3)));
+ __attribute__ ((nonnull(1)));
#define sodium_base64_VARIANT_ORIGINAL 1
#define sodium_base64_VARIANT_ORIGINAL_NO_PADDING 3
@@ -91,14 +88,14 @@ size_t sodium_base64_encoded_len(const size_t bin_len, const int variant);
SODIUM_EXPORT
char *sodium_bin2base64(char * const b64, const size_t b64_maxlen,
const unsigned char * const bin, const size_t bin_len,
- const int variant) __attribute__ ((nonnull));
+ const int variant) __attribute__ ((nonnull(1)));
SODIUM_EXPORT
int sodium_base642bin(unsigned char * const bin, const size_t bin_maxlen,
const char * const b64, const size_t b64_len,
const char * const ignore, size_t * const bin_len,
const char ** const b64_end, const int variant)
- __attribute__ ((nonnull(1, 3)));
+ __attribute__ ((nonnull(1)));
SODIUM_EXPORT
int sodium_mlock(void * const addr, const size_t len)
@@ -137,7 +134,7 @@ int sodium_munlock(void * const addr, const size_t len)
* either 357 or 361 bytes. For this reason, when using sodium_malloc() to
* allocate a crypto_generichash_state structure, padding must be added in
* order to ensure proper alignment. crypto_generichash_statebytes()
- * returns the rounded up structure size, and should be prefered to sizeof():
+ * returns the rounded up structure size, and should be preferred to sizeof():
* state = sodium_malloc(crypto_generichash_statebytes());
*/
diff --git a/libs/libsodium/src/include/sodium/version.h b/libs/libsodium/src/include/sodium/version.h
index 8dce217855..18ec63f3bc 100644
--- a/libs/libsodium/src/include/sodium/version.h
+++ b/libs/libsodium/src/include/sodium/version.h
@@ -4,10 +4,11 @@
#include "export.h"
-#define SODIUM_VERSION_STRING "1.0.17"
+#define SODIUM_VERSION_STRING "1.0.21"
+
+#define SODIUM_LIBRARY_VERSION_MAJOR 28
+#define SODIUM_LIBRARY_VERSION_MINOR 0
-#define SODIUM_LIBRARY_VERSION_MAJOR 10
-#define SODIUM_LIBRARY_VERSION_MINOR 2
#ifdef __cplusplus
extern "C" {
diff --git a/libs/libsodium/src/include/sodium/version.h.in b/libs/libsodium/src/include/sodium/version.h.in
new file mode 100644
index 0000000000..8a72044b4b
--- /dev/null
+++ b/libs/libsodium/src/include/sodium/version.h.in
@@ -0,0 +1,33 @@
+
+#ifndef sodium_version_H
+#define sodium_version_H
+
+#include "export.h"
+
+#define SODIUM_VERSION_STRING "@VERSION@"
+
+#define SODIUM_LIBRARY_VERSION_MAJOR @SODIUM_LIBRARY_VERSION_MAJOR@
+#define SODIUM_LIBRARY_VERSION_MINOR @SODIUM_LIBRARY_VERSION_MINOR@
+@SODIUM_LIBRARY_MINIMAL_DEF@
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+SODIUM_EXPORT
+const char *sodium_version_string(void);
+
+SODIUM_EXPORT
+int sodium_library_version_major(void);
+
+SODIUM_EXPORT
+int sodium_library_version_minor(void);
+
+SODIUM_EXPORT
+int sodium_library_minimal(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif