From e1fa9cc90cb325e4362a0e9b58c10a927881af95 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Thu, 3 Aug 2017 13:34:31 +0200 Subject: [PATCH] Add *_messagebytes_max() wrappers --- .../aes256gcm/aesni/aead_aes256gcm_aesni.c | 6 ++++++ .../chacha20poly1305/sodium/aead_chacha20poly1305.c | 12 ++++++++++++ .../sodium/aead_xchacha20poly1305.c | 6 ++++++ src/libsodium/crypto_box/crypto_box.c | 6 ++++++ .../box_curve25519xchacha20poly1305.c | 6 ++++++ .../box_curve25519xsalsa20poly1305.c | 6 ++++++ src/libsodium/crypto_secretbox/crypto_secretbox.c | 6 ++++++ .../xchacha20poly1305/secretbox_xchacha20poly1305.c | 6 ++++++ .../xsalsa20poly1305/secretbox_xsalsa20poly1305.c | 6 ++++++ src/libsodium/crypto_sign/crypto_sign.c | 6 ++++++ src/libsodium/crypto_sign/ed25519/sign_ed25519.c | 6 ++++++ .../crypto_stream/chacha20/stream_chacha20.c | 12 ++++++++++++ src/libsodium/crypto_stream/crypto_stream.c | 6 ++++++ .../crypto_stream/salsa20/stream_salsa20.c | 6 ++++++ .../crypto_stream/salsa2012/stream_salsa2012.c | 6 ++++++ .../crypto_stream/salsa208/stream_salsa208.c | 6 ++++++ .../crypto_stream/xchacha20/stream_xchacha20.c | 6 ++++++ .../crypto_stream/xsalsa20/stream_xsalsa20.c | 6 ++++++ .../include/sodium/crypto_aead_aes256gcm.h | 2 ++ .../include/sodium/crypto_aead_chacha20poly1305.h | 13 +++++++++---- .../include/sodium/crypto_aead_xchacha20poly1305.h | 11 +++++++---- src/libsodium/include/sodium/crypto_box.h | 2 ++ .../sodium/crypto_box_curve25519xchacha20poly1305.h | 2 ++ .../sodium/crypto_box_curve25519xsalsa20poly1305.h | 2 ++ src/libsodium/include/sodium/crypto_secretbox.h | 2 ++ .../sodium/crypto_secretbox_xchacha20poly1305.h | 2 ++ .../sodium/crypto_secretbox_xsalsa20poly1305.h | 2 ++ src/libsodium/include/sodium/crypto_sign.h | 2 ++ src/libsodium/include/sodium/crypto_sign_ed25519.h | 2 ++ src/libsodium/include/sodium/crypto_stream.h | 2 ++ .../include/sodium/crypto_stream_chacha20.h | 4 ++++ .../include/sodium/crypto_stream_salsa20.h | 2 ++ .../include/sodium/crypto_stream_salsa2012.h | 2 ++ .../include/sodium/crypto_stream_salsa208.h | 2 ++ .../include/sodium/crypto_stream_xchacha20.h | 2 ++ .../include/sodium/crypto_stream_xsalsa20.h | 2 ++ test/default/aead_aes256gcm.c | 1 + test/default/aead_chacha20poly1305.c | 2 ++ test/default/aead_xchacha20poly1305.c | 2 ++ test/default/box.c | 3 +++ test/default/chacha20.c | 2 ++ test/default/secretbox.c | 3 +++ test/default/sign.c | 2 ++ test/default/stream.c | 2 ++ test/default/stream2.c | 1 + test/default/xchacha20.c | 1 + 46 files changed, 189 insertions(+), 8 deletions(-) diff --git a/src/libsodium/crypto_aead/aes256gcm/aesni/aead_aes256gcm_aesni.c b/src/libsodium/crypto_aead/aes256gcm/aesni/aead_aes256gcm_aesni.c index 3b3003a5..fbfa208a 100644 --- a/src/libsodium/crypto_aead/aes256gcm/aesni/aead_aes256gcm_aesni.c +++ b/src/libsodium/crypto_aead/aes256gcm/aesni/aead_aes256gcm_aesni.c @@ -1058,6 +1058,12 @@ crypto_aead_aes256gcm_statebytes(void) return (sizeof(crypto_aead_aes256gcm_state) + (size_t) 15U) & ~(size_t) 15U; } +size_t +crypto_aead_aes256gcm_messagebytes_max(void) +{ + return crypto_aead_aes256gcm_MESSAGEBYTES_MAX; +} + void crypto_aead_aes256gcm_keygen(unsigned char k[crypto_aead_aes256gcm_KEYBYTES]) { diff --git a/src/libsodium/crypto_aead/chacha20poly1305/sodium/aead_chacha20poly1305.c b/src/libsodium/crypto_aead/chacha20poly1305/sodium/aead_chacha20poly1305.c index e0fa3948..c79407a1 100644 --- a/src/libsodium/crypto_aead/chacha20poly1305/sodium/aead_chacha20poly1305.c +++ b/src/libsodium/crypto_aead/chacha20poly1305/sodium/aead_chacha20poly1305.c @@ -350,6 +350,12 @@ crypto_aead_chacha20poly1305_ietf_abytes(void) return crypto_aead_chacha20poly1305_ietf_ABYTES; } +size_t +crypto_aead_chacha20poly1305_ietf_messagebytes_max(void) +{ + return crypto_aead_chacha20poly1305_ietf_MESSAGEBYTES_MAX; +} + void crypto_aead_chacha20poly1305_ietf_keygen(unsigned char k[crypto_aead_chacha20poly1305_ietf_KEYBYTES]) { @@ -380,6 +386,12 @@ crypto_aead_chacha20poly1305_abytes(void) return crypto_aead_chacha20poly1305_ABYTES; } +size_t +crypto_aead_chacha20poly1305_messagebytes_max(void) +{ + return crypto_aead_chacha20poly1305_MESSAGEBYTES_MAX; +} + void crypto_aead_chacha20poly1305_keygen(unsigned char k[crypto_aead_chacha20poly1305_KEYBYTES]) { diff --git a/src/libsodium/crypto_aead/xchacha20poly1305/sodium/aead_xchacha20poly1305.c b/src/libsodium/crypto_aead/xchacha20poly1305/sodium/aead_xchacha20poly1305.c index 95960503..c18cdf94 100644 --- a/src/libsodium/crypto_aead/xchacha20poly1305/sodium/aead_xchacha20poly1305.c +++ b/src/libsodium/crypto_aead/xchacha20poly1305/sodium/aead_xchacha20poly1305.c @@ -147,6 +147,12 @@ crypto_aead_xchacha20poly1305_ietf_abytes(void) return crypto_aead_xchacha20poly1305_ietf_ABYTES; } +size_t +crypto_aead_xchacha20poly1305_ietf_messagebytes_max(void) +{ + return crypto_aead_xchacha20poly1305_ietf_MESSAGEBYTES_MAX; +} + void crypto_aead_xchacha20poly1305_ietf_keygen(unsigned char k[crypto_aead_xchacha20poly1305_ietf_KEYBYTES]) { diff --git a/src/libsodium/crypto_box/crypto_box.c b/src/libsodium/crypto_box/crypto_box.c index 7ae4297c..7e4f00bd 100644 --- a/src/libsodium/crypto_box/crypto_box.c +++ b/src/libsodium/crypto_box/crypto_box.c @@ -49,6 +49,12 @@ crypto_box_macbytes(void) return crypto_box_MACBYTES; } +size_t +crypto_box_messagebytes_max(void) +{ + return crypto_box_MESSAGEBYTES_MAX; +} + const char * crypto_box_primitive(void) { diff --git a/src/libsodium/crypto_box/curve25519xchacha20poly1305/box_curve25519xchacha20poly1305.c b/src/libsodium/crypto_box/curve25519xchacha20poly1305/box_curve25519xchacha20poly1305.c index 920a01f2..5e2532ea 100644 --- a/src/libsodium/crypto_box/curve25519xchacha20poly1305/box_curve25519xchacha20poly1305.c +++ b/src/libsodium/crypto_box/curve25519xchacha20poly1305/box_curve25519xchacha20poly1305.c @@ -196,3 +196,9 @@ crypto_box_curve25519xchacha20poly1305_macbytes(void) { return crypto_box_curve25519xchacha20poly1305_MACBYTES; } + +size_t +crypto_box_curve25519xchacha20poly1305_messagebytes_max(void) +{ + return crypto_box_curve25519xchacha20poly1305_MESSAGEBYTES_MAX; +} diff --git a/src/libsodium/crypto_box/curve25519xsalsa20poly1305/box_curve25519xsalsa20poly1305.c b/src/libsodium/crypto_box/curve25519xsalsa20poly1305/box_curve25519xsalsa20poly1305.c index 7d6d603a..4c1d62ed 100644 --- a/src/libsodium/crypto_box/curve25519xsalsa20poly1305/box_curve25519xsalsa20poly1305.c +++ b/src/libsodium/crypto_box/curve25519xsalsa20poly1305/box_curve25519xsalsa20poly1305.c @@ -148,3 +148,9 @@ crypto_box_curve25519xsalsa20poly1305_macbytes(void) { return crypto_box_curve25519xsalsa20poly1305_MACBYTES; } + +size_t +crypto_box_curve25519xsalsa20poly1305_messagebytes_max(void) +{ + return crypto_box_curve25519xsalsa20poly1305_MESSAGEBYTES_MAX; +} diff --git a/src/libsodium/crypto_secretbox/crypto_secretbox.c b/src/libsodium/crypto_secretbox/crypto_secretbox.c index 669b5742..45f678ec 100644 --- a/src/libsodium/crypto_secretbox/crypto_secretbox.c +++ b/src/libsodium/crypto_secretbox/crypto_secretbox.c @@ -32,6 +32,12 @@ crypto_secretbox_macbytes(void) return crypto_secretbox_MACBYTES; } +size_t +crypto_secretbox_messagebytes_max(void) +{ + return crypto_secretbox_MESSAGEBYTES_MAX; +} + const char * crypto_secretbox_primitive(void) { diff --git a/src/libsodium/crypto_secretbox/xchacha20poly1305/secretbox_xchacha20poly1305.c b/src/libsodium/crypto_secretbox/xchacha20poly1305/secretbox_xchacha20poly1305.c index 61b7c26a..e76167d2 100644 --- a/src/libsodium/crypto_secretbox/xchacha20poly1305/secretbox_xchacha20poly1305.c +++ b/src/libsodium/crypto_secretbox/xchacha20poly1305/secretbox_xchacha20poly1305.c @@ -169,3 +169,9 @@ crypto_secretbox_xchacha20poly1305_macbytes(void) { return crypto_secretbox_xchacha20poly1305_MACBYTES; } + +size_t +crypto_secretbox_xchacha20poly1305_messagebytes_max(void) +{ + return crypto_secretbox_xchacha20poly1305_MESSAGEBYTES_MAX; +} diff --git a/src/libsodium/crypto_secretbox/xsalsa20poly1305/secretbox_xsalsa20poly1305.c b/src/libsodium/crypto_secretbox/xsalsa20poly1305/secretbox_xsalsa20poly1305.c index 1094c1f2..7240050d 100644 --- a/src/libsodium/crypto_secretbox/xsalsa20poly1305/secretbox_xsalsa20poly1305.c +++ b/src/libsodium/crypto_secretbox/xsalsa20poly1305/secretbox_xsalsa20poly1305.c @@ -76,6 +76,12 @@ crypto_secretbox_xsalsa20poly1305_macbytes(void) return crypto_secretbox_xsalsa20poly1305_MACBYTES; } +size_t +crypto_secretbox_xsalsa20poly1305_messagebytes_max(void) +{ + return crypto_secretbox_xsalsa20poly1305_MESSAGEBYTES_MAX; +} + void crypto_secretbox_xsalsa20poly1305_keygen(unsigned char k[crypto_secretbox_xsalsa20poly1305_KEYBYTES]) { diff --git a/src/libsodium/crypto_sign/crypto_sign.c b/src/libsodium/crypto_sign/crypto_sign.c index b93fa0ef..127072f7 100644 --- a/src/libsodium/crypto_sign/crypto_sign.c +++ b/src/libsodium/crypto_sign/crypto_sign.c @@ -31,6 +31,12 @@ crypto_sign_secretkeybytes(void) return crypto_sign_SECRETKEYBYTES; } +size_t +crypto_sign_messagebytes_max(void) +{ + return crypto_sign_MESSAGEBYTES_MAX; +} + const char * crypto_sign_primitive(void) { diff --git a/src/libsodium/crypto_sign/ed25519/sign_ed25519.c b/src/libsodium/crypto_sign/ed25519/sign_ed25519.c index 9ec477a1..e2a5a4a6 100644 --- a/src/libsodium/crypto_sign/ed25519/sign_ed25519.c +++ b/src/libsodium/crypto_sign/ed25519/sign_ed25519.c @@ -35,6 +35,12 @@ crypto_sign_ed25519_secretkeybytes(void) return crypto_sign_ed25519_SECRETKEYBYTES; } +size_t +crypto_sign_ed25519_messagebytes_max(void) +{ + return crypto_sign_ed25519_MESSAGEBYTES_MAX; +} + int crypto_sign_ed25519_sk_to_seed(unsigned char *seed, const unsigned char *sk) { diff --git a/src/libsodium/crypto_stream/chacha20/stream_chacha20.c b/src/libsodium/crypto_stream/chacha20/stream_chacha20.c index 0f7520ec..19c6eae9 100644 --- a/src/libsodium/crypto_stream/chacha20/stream_chacha20.c +++ b/src/libsodium/crypto_stream/chacha20/stream_chacha20.c @@ -26,6 +26,12 @@ crypto_stream_chacha20_noncebytes(void) { return crypto_stream_chacha20_NONCEBYTES; } +size_t +crypto_stream_chacha20_messagebytes_max(void) +{ + return crypto_stream_chacha20_MESSAGEBYTES_MAX; +} + size_t crypto_stream_chacha20_ietf_keybytes(void) { return crypto_stream_chacha20_ietf_KEYBYTES; @@ -36,6 +42,12 @@ crypto_stream_chacha20_ietf_noncebytes(void) { return crypto_stream_chacha20_ietf_NONCEBYTES; } +size_t +crypto_stream_chacha20_ietf_messagebytes_max(void) +{ + return crypto_stream_chacha20_ietf_MESSAGEBYTES_MAX; +} + int crypto_stream_chacha20(unsigned char *c, unsigned long long clen, const unsigned char *n, const unsigned char *k) diff --git a/src/libsodium/crypto_stream/crypto_stream.c b/src/libsodium/crypto_stream/crypto_stream.c index 7d93243b..58d25381 100644 --- a/src/libsodium/crypto_stream/crypto_stream.c +++ b/src/libsodium/crypto_stream/crypto_stream.c @@ -14,6 +14,12 @@ crypto_stream_noncebytes(void) return crypto_stream_NONCEBYTES; } +size_t +crypto_stream_messagebytes_max(void) +{ + return crypto_stream_MESSAGEBYTES_MAX; +} + const char * crypto_stream_primitive(void) { diff --git a/src/libsodium/crypto_stream/salsa20/stream_salsa20.c b/src/libsodium/crypto_stream/salsa20/stream_salsa20.c index 1a126dad..8714de11 100644 --- a/src/libsodium/crypto_stream/salsa20/stream_salsa20.c +++ b/src/libsodium/crypto_stream/salsa20/stream_salsa20.c @@ -37,6 +37,12 @@ crypto_stream_salsa20_noncebytes(void) return crypto_stream_salsa20_NONCEBYTES; } +size_t +crypto_stream_salsa20_messagebytes_max(void) +{ + return crypto_stream_salsa20_MESSAGEBYTES_MAX; +} + int crypto_stream_salsa20(unsigned char *c, unsigned long long clen, const unsigned char *n, const unsigned char *k) diff --git a/src/libsodium/crypto_stream/salsa2012/stream_salsa2012.c b/src/libsodium/crypto_stream/salsa2012/stream_salsa2012.c index d6c01b82..d0cc0f68 100644 --- a/src/libsodium/crypto_stream/salsa2012/stream_salsa2012.c +++ b/src/libsodium/crypto_stream/salsa2012/stream_salsa2012.c @@ -13,6 +13,12 @@ crypto_stream_salsa2012_noncebytes(void) return crypto_stream_salsa2012_NONCEBYTES; } +size_t +crypto_stream_salsa2012_messagebytes_max(void) +{ + return crypto_stream_salsa2012_MESSAGEBYTES_MAX; +} + void crypto_stream_salsa2012_keygen(unsigned char k[crypto_stream_salsa2012_KEYBYTES]) { diff --git a/src/libsodium/crypto_stream/salsa208/stream_salsa208.c b/src/libsodium/crypto_stream/salsa208/stream_salsa208.c index 1a7752af..9b525264 100644 --- a/src/libsodium/crypto_stream/salsa208/stream_salsa208.c +++ b/src/libsodium/crypto_stream/salsa208/stream_salsa208.c @@ -13,6 +13,12 @@ crypto_stream_salsa208_noncebytes(void) return crypto_stream_salsa208_NONCEBYTES; } +size_t +crypto_stream_salsa208_messagebyte_max(void) +{ + return crypto_stream_salsa208_MESSAGEBYTES_MAX; +} + void crypto_stream_salsa208_keygen(unsigned char k[crypto_stream_salsa208_KEYBYTES]) { diff --git a/src/libsodium/crypto_stream/xchacha20/stream_xchacha20.c b/src/libsodium/crypto_stream/xchacha20/stream_xchacha20.c index ee2345c2..8b1bc09a 100644 --- a/src/libsodium/crypto_stream/xchacha20/stream_xchacha20.c +++ b/src/libsodium/crypto_stream/xchacha20/stream_xchacha20.c @@ -19,6 +19,12 @@ crypto_stream_xchacha20_noncebytes(void) return crypto_stream_xchacha20_NONCEBYTES; } +size_t +crypto_stream_xchacha20_messagebytes_max(void) +{ + return crypto_stream_xchacha20_MESSAGEBYTES_MAX; +} + int crypto_stream_xchacha20(unsigned char *c, unsigned long long clen, const unsigned char *n, const unsigned char *k) diff --git a/src/libsodium/crypto_stream/xsalsa20/stream_xsalsa20.c b/src/libsodium/crypto_stream/xsalsa20/stream_xsalsa20.c index 1405b699..dc831a94 100644 --- a/src/libsodium/crypto_stream/xsalsa20/stream_xsalsa20.c +++ b/src/libsodium/crypto_stream/xsalsa20/stream_xsalsa20.c @@ -53,6 +53,12 @@ crypto_stream_xsalsa20_noncebytes(void) return crypto_stream_xsalsa20_NONCEBYTES; } +size_t +crypto_stream_xsalsa20_messagebytes_max(void) +{ + return crypto_stream_xsalsa20_MESSAGEBYTES_MAX; +} + void crypto_stream_xsalsa20_keygen(unsigned char k[crypto_stream_xsalsa20_KEYBYTES]) { diff --git a/src/libsodium/include/sodium/crypto_aead_aes256gcm.h b/src/libsodium/include/sodium/crypto_aead_aes256gcm.h index 31ca77b7..30bb7315 100644 --- a/src/libsodium/include/sodium/crypto_aead_aes256gcm.h +++ b/src/libsodium/include/sodium/crypto_aead_aes256gcm.h @@ -33,6 +33,8 @@ size_t crypto_aead_aes256gcm_abytes(void); #define crypto_aead_aes256gcm_MESSAGEBYTES_MAX \ SODIUM_MIN(SODIUM_SIZE_MAX - crypto_aead_aes256gcm_ABYTES, \ (16ULL * ((1ULL << 32) - 2ULL)) - crypto_aead_aes256gcm_ABYTES) +SODIUM_EXPORT +size_t crypto_aead_aes256gcm_messagebytes_max(void); typedef CRYPTO_ALIGN(16) unsigned char crypto_aead_aes256gcm_state[512]; diff --git a/src/libsodium/include/sodium/crypto_aead_chacha20poly1305.h b/src/libsodium/include/sodium/crypto_aead_chacha20poly1305.h index cceb1062..a575ec71 100644 --- a/src/libsodium/include/sodium/crypto_aead_chacha20poly1305.h +++ b/src/libsodium/include/sodium/crypto_aead_chacha20poly1305.h @@ -33,6 +33,8 @@ size_t crypto_aead_chacha20poly1305_ietf_abytes(void); #define crypto_aead_chacha20poly1305_ietf_MESSAGEBYTES_MAX \ SODIUM_MIN(SODIUM_SIZE_MAX - crypto_aead_chacha20poly1305_ietf_ABYTES, \ (64ULL * (1ULL << 32) - 64ULL) - crypto_aead_chacha20poly1305_ietf_ABYTES) +SODIUM_EXPORT +size_t crypto_aead_chacha20poly1305_ietf_messagebytes_max(void); SODIUM_EXPORT int crypto_aead_chacha20poly1305_ietf_encrypt(unsigned char *c, @@ -104,6 +106,8 @@ size_t crypto_aead_chacha20poly1305_abytes(void); #define crypto_aead_chacha20poly1305_MESSAGEBYTES_MAX \ (SODIUM_SIZE_MAX - crypto_aead_chacha20poly1305_ABYTES) +SODIUM_EXPORT +size_t crypto_aead_chacha20poly1305_messagebytes_max(void); SODIUM_EXPORT int crypto_aead_chacha20poly1305_encrypt(unsigned char *c, @@ -157,10 +161,11 @@ void crypto_aead_chacha20poly1305_keygen(unsigned char k[crypto_aead_chacha20pol /* Aliases */ -#define crypto_aead_chacha20poly1305_IETF_KEYBYTES crypto_aead_chacha20poly1305_ietf_KEYBYTES -#define crypto_aead_chacha20poly1305_IETF_NSECBYTES crypto_aead_chacha20poly1305_ietf_NSECBYTES -#define crypto_aead_chacha20poly1305_IETF_NPUBBYTES crypto_aead_chacha20poly1305_ietf_NPUBBYTES -#define crypto_aead_chacha20poly1305_IETF_ABYTES crypto_aead_chacha20poly1305_ietf_ABYTES +#define crypto_aead_chacha20poly1305_IETF_KEYBYTES crypto_aead_chacha20poly1305_ietf_KEYBYTES +#define crypto_aead_chacha20poly1305_IETF_NSECBYTES crypto_aead_chacha20poly1305_ietf_NSECBYTES +#define crypto_aead_chacha20poly1305_IETF_NPUBBYTES crypto_aead_chacha20poly1305_ietf_NPUBBYTES +#define crypto_aead_chacha20poly1305_IETF_ABYTES crypto_aead_chacha20poly1305_ietf_ABYTES +#define crypto_aead_chacha20poly1305_IETF_MESSAGEBYTES_MAX crypto_aead_chacha20poly1305_ietf_MESSAGEBYTES_MAX #ifdef __cplusplus } diff --git a/src/libsodium/include/sodium/crypto_aead_xchacha20poly1305.h b/src/libsodium/include/sodium/crypto_aead_xchacha20poly1305.h index b5b9d317..99692aae 100644 --- a/src/libsodium/include/sodium/crypto_aead_xchacha20poly1305.h +++ b/src/libsodium/include/sodium/crypto_aead_xchacha20poly1305.h @@ -29,6 +29,8 @@ size_t crypto_aead_xchacha20poly1305_ietf_abytes(void); #define crypto_aead_xchacha20poly1305_ietf_MESSAGEBYTES_MAX \ (SODIUM_SIZE_MAX - crypto_aead_xchacha20poly1305_ietf_ABYTES) +SODIUM_EXPORT +size_t crypto_aead_xchacha20poly1305_ietf_messagebytes_max(void); SODIUM_EXPORT int crypto_aead_xchacha20poly1305_ietf_encrypt(unsigned char *c, @@ -82,10 +84,11 @@ void crypto_aead_xchacha20poly1305_ietf_keygen(unsigned char k[crypto_aead_xchac /* Aliases */ -#define crypto_aead_xchacha20poly1305_IETF_KEYBYTES crypto_aead_xchacha20poly1305_ietf_KEYBYTES -#define crypto_aead_xchacha20poly1305_IETF_NSECBYTES crypto_aead_xchacha20poly1305_ietf_NSECBYTES -#define crypto_aead_xchacha20poly1305_IETF_NPUBBYTES crypto_aead_xchacha20poly1305_ietf_NPUBBYTES -#define crypto_aead_xchacha20poly1305_IETF_ABYTES crypto_aead_xchacha20poly1305_ietf_ABYTES +#define crypto_aead_xchacha20poly1305_IETF_KEYBYTES crypto_aead_xchacha20poly1305_ietf_KEYBYTES +#define crypto_aead_xchacha20poly1305_IETF_NSECBYTES crypto_aead_xchacha20poly1305_ietf_NSECBYTES +#define crypto_aead_xchacha20poly1305_IETF_NPUBBYTES crypto_aead_xchacha20poly1305_ietf_NPUBBYTES +#define crypto_aead_xchacha20poly1305_IETF_ABYTES crypto_aead_xchacha20poly1305_ietf_ABYTES +#define crypto_aead_xchacha20poly1305_IETF_MESSAGEBYTES_MAX crypto_aead_xchacha20poly1305_ietf_MESSAGEBYTES_MAX #ifdef __cplusplus } diff --git a/src/libsodium/include/sodium/crypto_box.h b/src/libsodium/include/sodium/crypto_box.h index eb0def73..99ee19a8 100644 --- a/src/libsodium/include/sodium/crypto_box.h +++ b/src/libsodium/include/sodium/crypto_box.h @@ -41,6 +41,8 @@ SODIUM_EXPORT size_t crypto_box_macbytes(void); #define crypto_box_MESSAGEBYTES_MAX crypto_box_curve25519xsalsa20poly1305_MESSAGEBYTES_MAX +SODIUM_EXPORT +size_t crypto_box_messagebytes_max(void); #define crypto_box_PRIMITIVE "curve25519xsalsa20poly1305" SODIUM_EXPORT diff --git a/src/libsodium/include/sodium/crypto_box_curve25519xchacha20poly1305.h b/src/libsodium/include/sodium/crypto_box_curve25519xchacha20poly1305.h index 9b299a0b..c1cf7566 100644 --- a/src/libsodium/include/sodium/crypto_box_curve25519xchacha20poly1305.h +++ b/src/libsodium/include/sodium/crypto_box_curve25519xchacha20poly1305.h @@ -39,6 +39,8 @@ size_t crypto_box_curve25519xchacha20poly1305_macbytes(void); #define crypto_box_curve25519xchacha20poly1305_MESSAGEBYTES_MAX \ (crypto_stream_xchacha20_MESSAGEBYTES_MAX - crypto_box_curve25519xchacha20poly1305_MACBYTES) +SODIUM_EXPORT +size_t crypto_box_curve25519xchacha20poly1305_messagebytes_max(void); SODIUM_EXPORT int crypto_box_curve25519xchacha20poly1305_seed_keypair(unsigned char *pk, diff --git a/src/libsodium/include/sodium/crypto_box_curve25519xsalsa20poly1305.h b/src/libsodium/include/sodium/crypto_box_curve25519xsalsa20poly1305.h index 77c9e3af..c5b15f42 100644 --- a/src/libsodium/include/sodium/crypto_box_curve25519xsalsa20poly1305.h +++ b/src/libsodium/include/sodium/crypto_box_curve25519xsalsa20poly1305.h @@ -39,6 +39,8 @@ size_t crypto_box_curve25519xsalsa20poly1305_macbytes(void); /* Only for the libsodium API - The NaCl compatibility API would require BOXZEROBYTES extra bytes */ #define crypto_box_curve25519xsalsa20poly1305_MESSAGEBYTES_MAX \ (crypto_stream_xsalsa20_MESSAGEBYTES_MAX - crypto_box_curve25519xsalsa20poly1305_MACBYTES) +SODIUM_EXPORT +size_t crypto_box_curve25519xsalsa20poly1305_messagebytes_max(void); SODIUM_EXPORT int crypto_box_curve25519xsalsa20poly1305_seed_keypair(unsigned char *pk, diff --git a/src/libsodium/include/sodium/crypto_secretbox.h b/src/libsodium/include/sodium/crypto_secretbox.h index 7a28a4e2..55e94a02 100644 --- a/src/libsodium/include/sodium/crypto_secretbox.h +++ b/src/libsodium/include/sodium/crypto_secretbox.h @@ -30,6 +30,8 @@ SODIUM_EXPORT const char *crypto_secretbox_primitive(void); #define crypto_secretbox_MESSAGEBYTES_MAX crypto_secretbox_xsalsa20poly1305_MESSAGEBYTES_MAX +SODIUM_EXPORT +size_t crypto_secretbox_messagebytes_max(void); SODIUM_EXPORT int crypto_secretbox_easy(unsigned char *c, const unsigned char *m, diff --git a/src/libsodium/include/sodium/crypto_secretbox_xchacha20poly1305.h b/src/libsodium/include/sodium/crypto_secretbox_xchacha20poly1305.h index 0858ea3e..2919da16 100644 --- a/src/libsodium/include/sodium/crypto_secretbox_xchacha20poly1305.h +++ b/src/libsodium/include/sodium/crypto_secretbox_xchacha20poly1305.h @@ -26,6 +26,8 @@ size_t crypto_secretbox_xchacha20poly1305_macbytes(void); #define crypto_secretbox_xchacha20poly1305_MESSAGEBYTES_MAX \ (crypto_stream_xchacha20_MESSAGEBYTES_MAX - crypto_secretbox_xchacha20poly1305_MACBYTES) +SODIUM_EXPORT +size_t crypto_secretbox_xchacha20poly1305_messagebytes_max(void); SODIUM_EXPORT int crypto_secretbox_xchacha20poly1305_easy(unsigned char *c, diff --git a/src/libsodium/include/sodium/crypto_secretbox_xsalsa20poly1305.h b/src/libsodium/include/sodium/crypto_secretbox_xsalsa20poly1305.h index 471271fd..4b8c7c8e 100644 --- a/src/libsodium/include/sodium/crypto_secretbox_xsalsa20poly1305.h +++ b/src/libsodium/include/sodium/crypto_secretbox_xsalsa20poly1305.h @@ -27,6 +27,8 @@ size_t crypto_secretbox_xsalsa20poly1305_macbytes(void); /* Only for the libsodium API - The NaCl compatibility API would require BOXZEROBYTES extra bytes */ #define crypto_secretbox_xsalsa20poly1305_MESSAGEBYTES_MAX \ (crypto_stream_xsalsa20_MESSAGEBYTES_MAX - crypto_secretbox_xsalsa20poly1305_MACBYTES) +SODIUM_EXPORT +size_t crypto_secretbox_xsalsa20poly1305_messagebytes_max(void); SODIUM_EXPORT int crypto_secretbox_xsalsa20poly1305(unsigned char *c, diff --git a/src/libsodium/include/sodium/crypto_sign.h b/src/libsodium/include/sodium/crypto_sign.h index e1cc8a12..85aff0c9 100644 --- a/src/libsodium/include/sodium/crypto_sign.h +++ b/src/libsodium/include/sodium/crypto_sign.h @@ -42,6 +42,8 @@ SODIUM_EXPORT size_t crypto_sign_secretkeybytes(void); #define crypto_sign_MESSAGEBYTES_MAX crypto_sign_ed25519_MESSAGEBYTES_MAX +SODIUM_EXPORT +size_t crypto_sign_messagebytes_max(void); #define crypto_sign_PRIMITIVE "ed25519" SODIUM_EXPORT diff --git a/src/libsodium/include/sodium/crypto_sign_ed25519.h b/src/libsodium/include/sodium/crypto_sign_ed25519.h index 95f0cbc4..38d2b9dd 100644 --- a/src/libsodium/include/sodium/crypto_sign_ed25519.h +++ b/src/libsodium/include/sodium/crypto_sign_ed25519.h @@ -36,6 +36,8 @@ SODIUM_EXPORT size_t crypto_sign_ed25519_secretkeybytes(void); #define crypto_sign_ed25519_MESSAGEBYTES_MAX (SODIUM_SIZE_MAX - crypto_sign_ed25519_BYTES) +SODIUM_EXPORT +size_t crypto_sign_ed25519_messagebytes_max(void); SODIUM_EXPORT int crypto_sign_ed25519(unsigned char *sm, unsigned long long *smlen_p, diff --git a/src/libsodium/include/sodium/crypto_stream.h b/src/libsodium/include/sodium/crypto_stream.h index 52ab20a9..d288f0b6 100644 --- a/src/libsodium/include/sodium/crypto_stream.h +++ b/src/libsodium/include/sodium/crypto_stream.h @@ -30,6 +30,8 @@ SODIUM_EXPORT size_t crypto_stream_noncebytes(void); #define crypto_stream_MESSAGEBYTES_MAX crypto_stream_xsalsa20_MESSAGEBYTES_MAX +SODIUM_EXPORT +size_t crypto_stream_messagebytes_max(void); #define crypto_stream_PRIMITIVE "xsalsa20" SODIUM_EXPORT diff --git a/src/libsodium/include/sodium/crypto_stream_chacha20.h b/src/libsodium/include/sodium/crypto_stream_chacha20.h index d4e76b79..d3e2b234 100644 --- a/src/libsodium/include/sodium/crypto_stream_chacha20.h +++ b/src/libsodium/include/sodium/crypto_stream_chacha20.h @@ -29,6 +29,8 @@ SODIUM_EXPORT size_t crypto_stream_chacha20_noncebytes(void); #define crypto_stream_chacha20_MESSAGEBYTES_MAX SODIUM_SIZE_MAX +SODIUM_EXPORT +size_t crypto_stream_chacha20_messagebytes_max(void); /* ChaCha20 with a 64-bit nonce and a 64-bit counter, as originally designed */ @@ -62,6 +64,8 @@ size_t crypto_stream_chacha20_ietf_noncebytes(void); #define crypto_stream_chacha20_ietf_MESSAGEBYTES_MAX \ SODIUM_MIN(SODIUM_SIZE_MAX, 64ULL * (1ULL << 32)) +SODIUM_EXPORT +size_t crypto_stream_chacha20_ietf_messagebytes_max(void); SODIUM_EXPORT int crypto_stream_chacha20_ietf(unsigned char *c, unsigned long long clen, diff --git a/src/libsodium/include/sodium/crypto_stream_salsa20.h b/src/libsodium/include/sodium/crypto_stream_salsa20.h index 011b830a..0c7688c7 100644 --- a/src/libsodium/include/sodium/crypto_stream_salsa20.h +++ b/src/libsodium/include/sodium/crypto_stream_salsa20.h @@ -29,6 +29,8 @@ SODIUM_EXPORT size_t crypto_stream_salsa20_noncebytes(void); #define crypto_stream_salsa20_MESSAGEBYTES_MAX SODIUM_SIZE_MAX +SODIUM_EXPORT +size_t crypto_stream_salsa20_messagebytes_max(void); SODIUM_EXPORT int crypto_stream_salsa20(unsigned char *c, unsigned long long clen, diff --git a/src/libsodium/include/sodium/crypto_stream_salsa2012.h b/src/libsodium/include/sodium/crypto_stream_salsa2012.h index cd34501a..c93d1c81 100644 --- a/src/libsodium/include/sodium/crypto_stream_salsa2012.h +++ b/src/libsodium/include/sodium/crypto_stream_salsa2012.h @@ -28,6 +28,8 @@ SODIUM_EXPORT size_t crypto_stream_salsa2012_noncebytes(void); #define crypto_stream_salsa2012_MESSAGEBYTES_MAX SODIUM_SIZE_MAX +SODIUM_EXPORT +size_t crypto_stream_salsa2012_messagebytes_max(void); SODIUM_EXPORT int crypto_stream_salsa2012(unsigned char *c, unsigned long long clen, diff --git a/src/libsodium/include/sodium/crypto_stream_salsa208.h b/src/libsodium/include/sodium/crypto_stream_salsa208.h index ec3f1bee..b7bc0d96 100644 --- a/src/libsodium/include/sodium/crypto_stream_salsa208.h +++ b/src/libsodium/include/sodium/crypto_stream_salsa208.h @@ -28,6 +28,8 @@ SODIUM_EXPORT size_t crypto_stream_salsa208_noncebytes(void); #define crypto_stream_salsa208_MESSAGEBYTES_MAX SODIUM_SIZE_MAX +SODIUM_EXPORT +size_t crypto_stream_salsa208_messagebytes_max(void); SODIUM_EXPORT int crypto_stream_salsa208(unsigned char *c, unsigned long long clen, diff --git a/src/libsodium/include/sodium/crypto_stream_xchacha20.h b/src/libsodium/include/sodium/crypto_stream_xchacha20.h index bcce05cd..cf0407ff 100644 --- a/src/libsodium/include/sodium/crypto_stream_xchacha20.h +++ b/src/libsodium/include/sodium/crypto_stream_xchacha20.h @@ -29,6 +29,8 @@ SODIUM_EXPORT size_t crypto_stream_xchacha20_noncebytes(void); #define crypto_stream_xchacha20_MESSAGEBYTES_MAX SODIUM_SIZE_MAX +SODIUM_EXPORT +size_t crypto_stream_xchacha20_messagebytes_max(void); SODIUM_EXPORT int crypto_stream_xchacha20(unsigned char *c, unsigned long long clen, diff --git a/src/libsodium/include/sodium/crypto_stream_xsalsa20.h b/src/libsodium/include/sodium/crypto_stream_xsalsa20.h index 3912fe3d..cb4c44a8 100644 --- a/src/libsodium/include/sodium/crypto_stream_xsalsa20.h +++ b/src/libsodium/include/sodium/crypto_stream_xsalsa20.h @@ -29,6 +29,8 @@ SODIUM_EXPORT size_t crypto_stream_xsalsa20_noncebytes(void); #define crypto_stream_xsalsa20_MESSAGEBYTES_MAX SODIUM_SIZE_MAX +SODIUM_EXPORT +size_t crypto_stream_xsalsa20_messagebytes_max(void); SODIUM_EXPORT int crypto_stream_xsalsa20(unsigned char *c, unsigned long long clen, diff --git a/test/default/aead_aes256gcm.c b/test/default/aead_aes256gcm.c index 94c9a3e1..abfed6ab 100644 --- a/test/default/aead_aes256gcm.c +++ b/test/default/aead_aes256gcm.c @@ -3236,6 +3236,7 @@ main(void) assert(crypto_aead_aes256gcm_npubbytes() == crypto_aead_aes256gcm_NPUBBYTES); assert(crypto_aead_aes256gcm_abytes() == crypto_aead_aes256gcm_ABYTES); assert(crypto_aead_aes256gcm_statebytes() >= sizeof(crypto_aead_aes256gcm_state)); + assert(crypto_aead_aes256gcm_messagebytes_max() == crypto_aead_aes256gcm_MESSAGEBYTES_MAX); printf("OK\n"); return 0; diff --git a/test/default/aead_chacha20poly1305.c b/test/default/aead_chacha20poly1305.c index 4f867579..85653e69 100644 --- a/test/default/aead_chacha20poly1305.c +++ b/test/default/aead_chacha20poly1305.c @@ -346,10 +346,12 @@ tv_ietf(void) assert(crypto_aead_chacha20poly1305_ietf_npubbytes() > crypto_aead_chacha20poly1305_npubbytes()); assert(crypto_aead_chacha20poly1305_ietf_nsecbytes() == 0U); assert(crypto_aead_chacha20poly1305_ietf_nsecbytes() == crypto_aead_chacha20poly1305_nsecbytes()); + assert(crypto_aead_chacha20poly1305_ietf_messagebytes_max() == crypto_aead_chacha20poly1305_ietf_MESSAGEBYTES_MAX); assert(crypto_aead_chacha20poly1305_IETF_KEYBYTES == crypto_aead_chacha20poly1305_ietf_KEYBYTES); assert(crypto_aead_chacha20poly1305_IETF_NSECBYTES == crypto_aead_chacha20poly1305_ietf_NSECBYTES); assert(crypto_aead_chacha20poly1305_IETF_NPUBBYTES == crypto_aead_chacha20poly1305_ietf_NPUBBYTES); assert(crypto_aead_chacha20poly1305_IETF_ABYTES == crypto_aead_chacha20poly1305_ietf_ABYTES); + assert(crypto_aead_chacha20poly1305_IETF_MESSAGEBYTES_MAX == crypto_aead_chacha20poly1305_ietf_MESSAGEBYTES_MAX); return 0; } diff --git a/test/default/aead_xchacha20poly1305.c b/test/default/aead_xchacha20poly1305.c index e20a8d70..7924038d 100644 --- a/test/default/aead_xchacha20poly1305.c +++ b/test/default/aead_xchacha20poly1305.c @@ -179,10 +179,12 @@ tv(void) assert(crypto_aead_xchacha20poly1305_ietf_npubbytes() == crypto_aead_xchacha20poly1305_ietf_NPUBBYTES); assert(crypto_aead_xchacha20poly1305_ietf_nsecbytes() == 0U); assert(crypto_aead_xchacha20poly1305_ietf_nsecbytes() == crypto_aead_xchacha20poly1305_ietf_NSECBYTES); + assert(crypto_aead_xchacha20poly1305_ietf_messagebytes_max() == crypto_aead_xchacha20poly1305_ietf_MESSAGEBYTES_MAX); assert(crypto_aead_xchacha20poly1305_IETF_KEYBYTES == crypto_aead_xchacha20poly1305_ietf_KEYBYTES); assert(crypto_aead_xchacha20poly1305_IETF_NSECBYTES == crypto_aead_xchacha20poly1305_ietf_NSECBYTES); assert(crypto_aead_xchacha20poly1305_IETF_NPUBBYTES == crypto_aead_xchacha20poly1305_ietf_NPUBBYTES); assert(crypto_aead_xchacha20poly1305_IETF_ABYTES == crypto_aead_xchacha20poly1305_ietf_ABYTES); + assert(crypto_aead_xchacha20poly1305_IETF_MESSAGEBYTES_MAX == crypto_aead_xchacha20poly1305_ietf_MESSAGEBYTES_MAX); return 0; } diff --git a/test/default/box.c b/test/default/box.c index 917e4dc4..228aca7b 100644 --- a/test/default/box.c +++ b/test/default/box.c @@ -87,6 +87,7 @@ main(void) assert(crypto_box_zerobytes() > 0U); assert(crypto_box_boxzerobytes() > 0U); assert(crypto_box_macbytes() > 0U); + assert(crypto_box_messagebytes_max() > 0U); assert(strcmp(crypto_box_primitive(), "curve25519xsalsa20poly1305") == 0); assert(crypto_box_curve25519xsalsa20poly1305_seedbytes() == crypto_box_seedbytes()); @@ -104,6 +105,8 @@ main(void) crypto_box_boxzerobytes()); assert(crypto_box_curve25519xsalsa20poly1305_macbytes() == crypto_box_macbytes()); + assert(crypto_box_curve25519xsalsa20poly1305_messagebytes_max() == + crypto_box_messagebytes_max()); return 0; } diff --git a/test/default/chacha20.c b/test/default/chacha20.c index facd6e60..319403e3 100644 --- a/test/default/chacha20.c +++ b/test/default/chacha20.c @@ -175,10 +175,12 @@ main(void) assert(crypto_stream_chacha20_keybytes() == crypto_stream_chacha20_KEYBYTES); assert(crypto_stream_chacha20_noncebytes() > 0U); assert(crypto_stream_chacha20_noncebytes() == crypto_stream_chacha20_NONCEBYTES); + assert(crypto_stream_chacha20_messagebytes_max() == crypto_stream_chacha20_MESSAGEBYTES_MAX); assert(crypto_stream_chacha20_ietf_keybytes() > 0U); assert(crypto_stream_chacha20_ietf_keybytes() == crypto_stream_chacha20_ietf_KEYBYTES); assert(crypto_stream_chacha20_ietf_noncebytes() > 0U); assert(crypto_stream_chacha20_ietf_noncebytes() == crypto_stream_chacha20_ietf_NONCEBYTES); + assert(crypto_stream_chacha20_ietf_messagebytes_max() == crypto_stream_chacha20_ietf_MESSAGEBYTES_MAX); return 0; } diff --git a/test/default/secretbox.c b/test/default/secretbox.c index cf5823e2..df1d62ff 100644 --- a/test/default/secretbox.c +++ b/test/default/secretbox.c @@ -65,6 +65,7 @@ main(void) assert(crypto_secretbox_zerobytes() > 0U); assert(crypto_secretbox_boxzerobytes() > 0U); assert(crypto_secretbox_macbytes() > 0U); + assert(crypto_secretbox_messagebytes_max() > 0U); assert(strcmp(crypto_secretbox_primitive(), "xsalsa20poly1305") == 0); assert(crypto_secretbox_keybytes() == crypto_secretbox_xsalsa20poly1305_keybytes()); @@ -76,6 +77,8 @@ main(void) crypto_secretbox_xsalsa20poly1305_boxzerobytes()); assert(crypto_secretbox_macbytes() == crypto_secretbox_xsalsa20poly1305_macbytes()); + assert(crypto_secretbox_messagebytes_max() == + crypto_secretbox_xsalsa20poly1305_messagebytes_max()); return 0; } diff --git a/test/default/sign.c b/test/default/sign.c index 193270c8..a577df80 100644 --- a/test/default/sign.c +++ b/test/default/sign.c @@ -1300,9 +1300,11 @@ int main(void) assert(crypto_sign_seedbytes() > 0U); assert(crypto_sign_publickeybytes() > 0U); assert(crypto_sign_secretkeybytes() > 0U); + assert(crypto_sign_messagebytes_max() > 0U); assert(strcmp(crypto_sign_primitive(), "ed25519") == 0); assert(crypto_sign_bytes() == crypto_sign_ed25519_bytes()); assert(crypto_sign_seedbytes() == crypto_sign_ed25519_seedbytes()); + assert(crypto_sign_messagebytes_max() == crypto_sign_ed25519_messagebytes_max()); assert(crypto_sign_publickeybytes() == crypto_sign_ed25519_publickeybytes()); assert(crypto_sign_secretkeybytes() diff --git a/test/default/stream.c b/test/default/stream.c index ccc8d15e..150fe780 100644 --- a/test/default/stream.c +++ b/test/default/stream.c @@ -55,9 +55,11 @@ main(void) assert(crypto_stream_keybytes() > 0U); assert(crypto_stream_noncebytes() > 0U); + assert(crypto_stream_messagebytes_max() > 0U); assert(strcmp(crypto_stream_primitive(), "xsalsa20") == 0); assert(crypto_stream_keybytes() == crypto_stream_xsalsa20_keybytes()); assert(crypto_stream_noncebytes() == crypto_stream_xsalsa20_noncebytes()); + assert(crypto_stream_messagebytes_max() == crypto_stream_xsalsa20_messagebytes_max()); return 0; } diff --git a/test/default/stream2.c b/test/default/stream2.c index 63e0c0ee..8e5b3f67 100644 --- a/test/default/stream2.c +++ b/test/default/stream2.c @@ -41,6 +41,7 @@ main(void) assert(crypto_stream_salsa20_keybytes() > 0U); assert(crypto_stream_salsa20_noncebytes() > 0U); + assert(crypto_stream_salsa20_messagebytes_max() > 0U); return 0; } diff --git a/test/default/xchacha20.c b/test/default/xchacha20.c index dbe29f35..15e5b9a1 100644 --- a/test/default/xchacha20.c +++ b/test/default/xchacha20.c @@ -405,6 +405,7 @@ tv_box_xchacha20poly1305(void) assert(crypto_box_curve25519xchacha20poly1305_beforenmbytes() == crypto_box_curve25519xchacha20poly1305_BEFORENMBYTES); assert(crypto_box_curve25519xchacha20poly1305_noncebytes() == crypto_box_curve25519xchacha20poly1305_NONCEBYTES); assert(crypto_box_curve25519xchacha20poly1305_macbytes() == crypto_box_curve25519xchacha20poly1305_MACBYTES); + assert(crypto_box_curve25519xchacha20poly1305_messagebytes_max() == crypto_box_curve25519xchacha20poly1305_MESSAGEBYTES_MAX); printf("tv_box_xchacha20poly1305: ok\n"); }