From 4c6b0ac7629de2362388c250d9617f3c92b331c6 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sun, 19 Feb 2017 18:54:25 +0100 Subject: [PATCH] Add aliases for stream_chacha20 sizes, similar to chacha20poly1305 --- .../crypto_stream/chacha20/stream_chacha20.c | 7 ++++++- src/libsodium/include/sodium/crypto_stream_chacha20.h | 11 ++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/libsodium/crypto_stream/chacha20/stream_chacha20.c b/src/libsodium/crypto_stream/chacha20/stream_chacha20.c index 56b496a1..65585ddd 100644 --- a/src/libsodium/crypto_stream/chacha20/stream_chacha20.c +++ b/src/libsodium/crypto_stream/chacha20/stream_chacha20.c @@ -19,9 +19,14 @@ crypto_stream_chacha20_noncebytes(void) { return crypto_stream_chacha20_NONCEBYTES; } +size_t +crypto_stream_chacha20_ietf_keybytes(void) { + return crypto_stream_chacha20_ietf_KEYBYTES; +} + size_t crypto_stream_chacha20_ietf_noncebytes(void) { - return crypto_stream_chacha20_IETF_NONCEBYTES; + return crypto_stream_chacha20_ietf_NONCEBYTES; } int diff --git a/src/libsodium/include/sodium/crypto_stream_chacha20.h b/src/libsodium/include/sodium/crypto_stream_chacha20.h index 73f32540..a6a9ab24 100644 --- a/src/libsodium/include/sodium/crypto_stream_chacha20.h +++ b/src/libsodium/include/sodium/crypto_stream_chacha20.h @@ -47,7 +47,11 @@ int crypto_stream_chacha20_xor_ic(unsigned char *c, const unsigned char *m, /* ChaCha20 with a 96-bit nonce and a 32-bit counter (IETF) */ -#define crypto_stream_chacha20_IETF_NONCEBYTES 12U +#define crypto_stream_chacha20_ietf_KEYBYTES 32U +SODIUM_EXPORT +size_t crypto_stream_chacha20_ietf_keybytes(void); + +#define crypto_stream_chacha20_ietf_NONCEBYTES 12U SODIUM_EXPORT size_t crypto_stream_chacha20_ietf_noncebytes(void); @@ -70,6 +74,11 @@ int crypto_stream_chacha20_ietf_xor_ic(unsigned char *c, const unsigned char *m, int _crypto_stream_chacha20_pick_best_implementation(void); +/* Aliases */ + +#define crypto_stream_chacha20_IETF_KEYBYTES crypto_stream_chacha20_ietf_KEYBYTES +#define crypto_stream_chacha20_IETF_NONCEBYTES crypto_stream_chacha20_ietf_NONCEBYTES + #ifdef __cplusplus } #endif