From 98c02a21d61c45ae62b71d3da7759ab0ccd579bc Mon Sep 17 00:00:00 2001 From: Stephen Touset Date: Thu, 16 May 2013 15:48:08 -0700 Subject: [PATCH] Add remaining functions for looking up constants The automated script that generated functions for looking up #define'd constants didn't handle edge cases in these files, so these have been added by hand. They're thus either more likely or less likely to contain mistakes (depending on one's particular point of view). --- src/libsodium/Makefile.am | 4 +++ .../blake2/generichash_blake2_api.c | 31 +++++++++++++++++++ .../poly1305/onetimeauth_poly1305_api.c | 16 ++++++++++ .../crypto_verify/16/verify_16_api.c | 6 ++++ .../crypto_verify/32/verify_32_api.c | 6 ++++ .../sodium/crypto_generichash_blake2b.h | 19 ++++++++++++ .../sodium/crypto_onetimeauth_poly1305.h | 10 ++++++ .../include/sodium/crypto_verify_16.h | 4 +++ .../include/sodium/crypto_verify_32.h | 4 +++ 9 files changed, 100 insertions(+) create mode 100644 src/libsodium/crypto_generichash/blake2/generichash_blake2_api.c create mode 100644 src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305_api.c create mode 100644 src/libsodium/crypto_verify/16/verify_16_api.c create mode 100644 src/libsodium/crypto_verify/32/verify_32_api.c diff --git a/src/libsodium/Makefile.am b/src/libsodium/Makefile.am index 90caf780..c5f51aba 100644 --- a/src/libsodium/Makefile.am +++ b/src/libsodium/Makefile.am @@ -31,6 +31,7 @@ libsodium_la_SOURCES = \ crypto_core/salsa208/core_salsa208_api.c \ crypto_core/salsa208/ref/api.h \ crypto_generichash/crypto_generichash.c \ + crypto_generichash/blake2/generichash_blake2_api.c \ crypto_generichash/blake2/ref/api.h \ crypto_generichash/blake2/ref/blake2-impl.h \ crypto_generichash/blake2/ref/blake2.h \ @@ -51,6 +52,7 @@ libsodium_la_SOURCES = \ crypto_hashblocks/sha512/ref/api.h \ crypto_onetimeauth/crypto_onetimeauth.c \ crypto_onetimeauth/poly1305/onetimeauth_poly1305.c \ + crypto_onetimeauth/poly1305/onetimeauth_poly1305_api.c \ crypto_onetimeauth/poly1305/onetimeauth_poly1305_try.c \ crypto_onetimeauth/poly1305/53/api.h \ crypto_onetimeauth/poly1305/53/auth_poly1305_53.c \ @@ -165,8 +167,10 @@ libsodium_la_SOURCES = \ crypto_stream/xsalsa20/ref/api.h \ crypto_stream/xsalsa20/ref/stream_xsalsa20.c \ crypto_stream/xsalsa20/ref/xor_xsalsa20.c \ + crypto_verify/16/verify_16_api.c \ crypto_verify/16/ref/api.h \ crypto_verify/16/ref/verify_16.c \ + crypto_verify/32/verify_32_api.c \ crypto_verify/32/ref/api.h \ crypto_verify/32/ref/verify_32.c \ randombytes/randombytes.c \ diff --git a/src/libsodium/crypto_generichash/blake2/generichash_blake2_api.c b/src/libsodium/crypto_generichash/blake2/generichash_blake2_api.c new file mode 100644 index 00000000..c62693f6 --- /dev/null +++ b/src/libsodium/crypto_generichash/blake2/generichash_blake2_api.c @@ -0,0 +1,31 @@ +#include "crypto_generichash_blake2b.h" + +size_t +crypto_generichash_blake2b_bytes_min(void) { + return crypto_generichash_blake2b_BYTES_MIN; +} + +size_t +crypto_generichash_blake2b_bytes_max(void) { + return crypto_generichash_blake2b_BYTES_MAX; +} + +size_t +crypto_generichash_blake2b_keybytes_min(void) { + return crypto_generichash_blake2b_KEYBYTES_MIN; +} + +size_t +crypto_generichash_blake2b_keybytes_max(void) { + return crypto_generichash_blake2b_KEYBYTES_MAX; +} + +size_t +crypto_generichash_blake2b_blockbytes(void) { + return crypto_generichash_blake2b_BLOCKBYTES; +} + +const char * +crypto_generichash_blake2b_blockbytes_primitive(void) { + return "blake2b"; +} diff --git a/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305_api.c b/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305_api.c new file mode 100644 index 00000000..bd36a1f6 --- /dev/null +++ b/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305_api.c @@ -0,0 +1,16 @@ +#include "crypto_onetimeauth_poly1305.h" + +size_t +crypto_onetimeauth_poly1305_bytes(void) { + return crypto_onetimeauth_poly1305_BYTES; +} + +size_t +crypto_onetimeauth_poly1305_keybytes(void) { + return crypto_onetimeauth_poly1305_KEYBYTES; +} + +const char * +crypto_onetimeauth_poly1305_primitive(void) { + return "poly1305"; +} diff --git a/src/libsodium/crypto_verify/16/verify_16_api.c b/src/libsodium/crypto_verify/16/verify_16_api.c new file mode 100644 index 00000000..757f9b63 --- /dev/null +++ b/src/libsodium/crypto_verify/16/verify_16_api.c @@ -0,0 +1,6 @@ +#include "crypto_verify_16.h" + +size_t +crypto_verify_16_bytes(void) { + return crypto_verify_16_BYTES; +} diff --git a/src/libsodium/crypto_verify/32/verify_32_api.c b/src/libsodium/crypto_verify/32/verify_32_api.c new file mode 100644 index 00000000..6241c4d3 --- /dev/null +++ b/src/libsodium/crypto_verify/32/verify_32_api.c @@ -0,0 +1,6 @@ +#include "crypto_verify_32.h" + +size_t +crypto_verify_32_bytes(void) { + return crypto_verify_32_BYTES; +} diff --git a/src/libsodium/include/sodium/crypto_generichash_blake2b.h b/src/libsodium/include/sodium/crypto_generichash_blake2b.h index 0a560c2f..c48a7d13 100644 --- a/src/libsodium/include/sodium/crypto_generichash_blake2b.h +++ b/src/libsodium/include/sodium/crypto_generichash_blake2b.h @@ -3,6 +3,7 @@ #include #include +#include #include "export.h" @@ -33,6 +34,24 @@ CRYPTO_ALIGN(64) typedef struct crypto_generichash_blake2b_state { } crypto_generichash_blake2b_state; #pragma pack(pop) +SODIUM_EXPORT +size_t crypto_generichash_blake2b_bytes_min(void); + +SODIUM_EXPORT +size_t crypto_generichash_blake2b_bytes_max(void); + +SODIUM_EXPORT +size_t crypto_generichash_blake2b_keybytes_min(void); + +SODIUM_EXPORT +size_t crypto_generichash_blake2b_keybytes_max(void); + +SODIUM_EXPORT +size_t crypto_generichash_blake2b_blockbytes(void); + +SODIUM_EXPORT +const char * crypto_generichash_blake2b_blockbytes_primitive(void); + SODIUM_EXPORT int crypto_generichash_blake2b(unsigned char *out, size_t outlen, const unsigned char *in, diff --git a/src/libsodium/include/sodium/crypto_onetimeauth_poly1305.h b/src/libsodium/include/sodium/crypto_onetimeauth_poly1305.h index 70289b4d..19d55f18 100644 --- a/src/libsodium/include/sodium/crypto_onetimeauth_poly1305.h +++ b/src/libsodium/include/sodium/crypto_onetimeauth_poly1305.h @@ -1,6 +1,7 @@ #ifndef crypto_onetimeauth_poly1305_H #define crypto_onetimeauth_poly1305_H +#include #include "export.h" #define crypto_onetimeauth_poly1305_BYTES 16U @@ -26,6 +27,15 @@ typedef struct crypto_onetimeauth_poly1305_implementation { const unsigned char *k); } crypto_onetimeauth_poly1305_implementation; +SODIUM_EXPORT +size_t crypto_onetimeauth_poly1305_bytes(void); + +SODIUM_EXPORT +size_t crypto_onetimeauth_poly1305_keybytes(void); + +SODIUM_EXPORT +const char * crypto_onetimeauth_poly1305_primitive(void); + SODIUM_EXPORT const char *crypto_onetimeauth_poly1305_ref_implementation_name(void); diff --git a/src/libsodium/include/sodium/crypto_verify_16.h b/src/libsodium/include/sodium/crypto_verify_16.h index 1c2c7b23..972a02f3 100644 --- a/src/libsodium/include/sodium/crypto_verify_16.h +++ b/src/libsodium/include/sodium/crypto_verify_16.h @@ -1,6 +1,7 @@ #ifndef crypto_verify_16_H #define crypto_verify_16_H +#include #include "export.h" #define crypto_verify_16_BYTES 16U @@ -9,6 +10,9 @@ extern "C" { #endif +SODIUM_EXPORT +size_t crypto_verify_16_bytes(void); + SODIUM_EXPORT int crypto_verify_16(const unsigned char *x, const unsigned char *y); diff --git a/src/libsodium/include/sodium/crypto_verify_32.h b/src/libsodium/include/sodium/crypto_verify_32.h index a76d1889..f3ada230 100644 --- a/src/libsodium/include/sodium/crypto_verify_32.h +++ b/src/libsodium/include/sodium/crypto_verify_32.h @@ -1,6 +1,7 @@ #ifndef crypto_verify_32_H #define crypto_verify_32_H +#include #include "export.h" #define crypto_verify_32_BYTES 32U @@ -9,6 +10,9 @@ extern "C" { #endif +SODIUM_EXPORT +size_t crypto_verify_32_bytes(void); + SODIUM_EXPORT int crypto_verify_32(const unsigned char *x, const unsigned char *y);