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).
This commit is contained in:
Stephen Touset 2013-05-16 15:48:08 -07:00
parent 2a0f3d040f
commit 98c02a21d6
9 changed files with 100 additions and 0 deletions

View File

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

View File

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

View File

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

View File

@ -0,0 +1,6 @@
#include "crypto_verify_16.h"
size_t
crypto_verify_16_bytes(void) {
return crypto_verify_16_BYTES;
}

View File

@ -0,0 +1,6 @@
#include "crypto_verify_32.h"
size_t
crypto_verify_32_bytes(void) {
return crypto_verify_32_BYTES;
}

View File

@ -3,6 +3,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <stddef.h>
#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,

View File

@ -1,6 +1,7 @@
#ifndef crypto_onetimeauth_poly1305_H
#define crypto_onetimeauth_poly1305_H
#include <stddef.h>
#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);

View File

@ -1,6 +1,7 @@
#ifndef crypto_verify_16_H
#define crypto_verify_16_H
#include <stddef.h>
#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);

View File

@ -1,6 +1,7 @@
#ifndef crypto_verify_32_H
#define crypto_verify_32_H
#include <stddef.h>
#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);