Add secretstream constants
This commit is contained in:
parent
49f1d87cfe
commit
aa20d2e86e
@ -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;
|
||||
}
|
||||
|
@ -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];
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user