diff --git a/src/libsodium/crypto_secretstream/xchacha20poly1305/secretstream_xchacha20poly1305.c b/src/libsodium/crypto_secretstream/xchacha20poly1305/secretstream_xchacha20poly1305.c index b2ed5141..ff915362 100644 --- a/src/libsodium/crypto_secretstream/xchacha20poly1305/secretstream_xchacha20poly1305.c +++ b/src/libsodium/crypto_secretstream/xchacha20poly1305/secretstream_xchacha20poly1305.c @@ -235,3 +235,53 @@ crypto_secretstream_xchacha20poly1305_statebytes(void) { return sizeof(crypto_secretstream_xchacha20poly1305_state); } + + +size_t +crypto_secretstream_xchacha20poly1305_abytes(void) +{ + return crypto_secretstream_xchacha20poly1305_ABYTES; +} + +size_t +crypto_secretstream_xchacha20poly1305_initbytes(void) +{ + return crypto_secretstream_xchacha20poly1305_INITBYTES; +} + + +size_t +crypto_secretstream_xchacha20poly1305_keybytes(void) +{ + return crypto_secretstream_xchacha20poly1305_KEYBYTES; +} + +size_t +crypto_secretstream_xchacha20poly1305_messagesbytes_max(void) +{ + return crypto_secretstream_xchacha20poly1305_MESSAGESBYTES_MAX; +} + +unsigned char +crypto_secretstream_xchacha20poly1305_tag_message(void) +{ + return crypto_secretstream_xchacha20poly1305_TAG_MESSAGE; +} + +unsigned char +crypto_secretstream_xchacha20poly1305_tag_push(void) +{ + return crypto_secretstream_xchacha20poly1305_TAG_PUSH; +} + +unsigned char +crypto_secretstream_xchacha20poly1305_tag_rekey(void) +{ + return crypto_secretstream_xchacha20poly1305_TAG_REKEY; +} + +unsigned char +crypto_secretstream_xchacha20poly1305_tag_final(void) +{ + return crypto_secretstream_xchacha20poly1305_TAG_FINAL; +} diff --git a/src/libsodium/include/sodium/crypto_secretstream_xchacha20poly1305.h b/src/libsodium/include/sodium/crypto_secretstream_xchacha20poly1305.h index 79c4f4c2..5d446efa 100644 --- a/src/libsodium/include/sodium/crypto_secretstream_xchacha20poly1305.h +++ b/src/libsodium/include/sodium/crypto_secretstream_xchacha20poly1305.h @@ -16,23 +16,41 @@ extern "C" { #define crypto_secretstream_xchacha20poly1305_ABYTES \ (1U + crypto_aead_xchacha20poly1305_ietf_ABYTES) +SODIUM_EXPORT +size_t crypto_secretstream_xchacha20poly1305_abytes(void); #define crypto_secretstream_xchacha20poly1305_INITBYTES \ crypto_aead_xchacha20poly1305_ietf_NPUBBYTES +SODIUM_EXPORT +size_t crypto_secretstream_xchacha20poly1305_initbytes(void); #define crypto_secretstream_xchacha20poly1305_KEYBYTES \ crypto_aead_xchacha20poly1305_ietf_KEYBYTES +SODIUM_EXPORT +size_t crypto_secretstream_xchacha20poly1305_keybytes(void); #define crypto_secretstream_xchacha20poly1305_MESSAGESBYTES_MAX \ ((1ULL << 32) - 2ULL * 64ULL) +SODIUM_EXPORT +size_t crypto_secretstream_xchacha20poly1305_messagesbytes_max(void); #define crypto_secretstream_xchacha20poly1305_TAG_MESSAGE 0x00 +SODIUM_EXPORT +unsigned char crypto_secretstream_xchacha20poly1305_tag_message(void); + #define crypto_secretstream_xchacha20poly1305_TAG_PUSH 0x01 +SODIUM_EXPORT +unsigned char crypto_secretstream_xchacha20poly1305_tag_push(void); + #define crypto_secretstream_xchacha20poly1305_TAG_REKEY 0x02 +SODIUM_EXPORT +unsigned char crypto_secretstream_xchacha20poly1305_tag_rekey(void); #define crypto_secretstream_xchacha20poly1305_TAG_FINAL \ (crypto_secretstream_xchacha20poly1305_TAG_PUSH | \ crypto_secretstream_xchacha20poly1305_TAG_REKEY) +SODIUM_EXPORT +unsigned char crypto_secretstream_xchacha20poly1305_tag_final(void); typedef struct crypto_secretstream_xchacha20poly1305_state { unsigned char k[crypto_stream_chacha20_ietf_KEYBYTES]; diff --git a/test/default/secretstream.c b/test/default/secretstream.c index bd080667..3492ca27 100644 --- a/test/default/secretstream.c +++ b/test/default/secretstream.c @@ -174,7 +174,25 @@ main(void) sodium_free(k); sodium_free(header); sodium_free(state); - + + assert(crypto_secretstream_xchacha20poly1305_abytes() == + crypto_secretstream_xchacha20poly1305_ABYTES); + assert(crypto_secretstream_xchacha20poly1305_initbytes() == + crypto_secretstream_xchacha20poly1305_INITBYTES); + assert(crypto_secretstream_xchacha20poly1305_keybytes() == + crypto_secretstream_xchacha20poly1305_KEYBYTES); + assert(crypto_secretstream_xchacha20poly1305_messagesbytes_max() == + crypto_secretstream_xchacha20poly1305_MESSAGESBYTES_MAX); + + assert(crypto_secretstream_xchacha20poly1305_tag_message() == + crypto_secretstream_xchacha20poly1305_TAG_MESSAGE); + assert(crypto_secretstream_xchacha20poly1305_tag_push() == + crypto_secretstream_xchacha20poly1305_TAG_PUSH); + assert(crypto_secretstream_xchacha20poly1305_tag_rekey() == + crypto_secretstream_xchacha20poly1305_TAG_REKEY); + assert(crypto_secretstream_xchacha20poly1305_tag_final() == + crypto_secretstream_xchacha20poly1305_TAG_FINAL); + printf("OK\n"); return 0;