1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-19 10:05:05 -07:00

Add secretstream constants

This commit is contained in:
Frank Denis 2017-08-25 14:51:02 +02:00
parent 49f1d87cfe
commit aa20d2e86e
3 changed files with 87 additions and 1 deletions

View File

@ -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;
}

View File

@ -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];

View File

@ -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;