Add crypto_generichash_statebytes()

sizeof() is not always an option when accessing the library from
other languages.
This commit is contained in:
Frank Denis 2015-01-23 10:56:01 +01:00
parent 4921836512
commit c9ba75a48f
3 changed files with 11 additions and 1 deletions

View File

@ -37,11 +37,18 @@ crypto_generichash_keybytes(void)
return crypto_generichash_KEYBYTES; return crypto_generichash_KEYBYTES;
} }
const char *crypto_generichash_primitive(void) const char *
crypto_generichash_primitive(void)
{ {
return crypto_generichash_PRIMITIVE; return crypto_generichash_PRIMITIVE;
} }
size_t
crypto_generichash_statebytes(void)
{
return sizeof(crypto_generichash_state);
}
int int
crypto_generichash(unsigned char *out, size_t outlen, const unsigned char *in, crypto_generichash(unsigned char *out, size_t outlen, const unsigned char *in,
unsigned long long inlen, const unsigned char *key, unsigned long long inlen, const unsigned char *key,

View File

@ -42,6 +42,8 @@ SODIUM_EXPORT
const char *crypto_generichash_primitive(void); const char *crypto_generichash_primitive(void);
typedef crypto_generichash_blake2b_state crypto_generichash_state; typedef crypto_generichash_blake2b_state crypto_generichash_state;
SODIUM_EXPORT
size_t crypto_generichash_statebytes(void);
SODIUM_EXPORT SODIUM_EXPORT
int crypto_generichash(unsigned char *out, size_t outlen, int crypto_generichash(unsigned char *out, size_t outlen,

View File

@ -10,6 +10,7 @@ int main(void)
k[crypto_generichash_KEYBYTES_MAX]; k[crypto_generichash_KEYBYTES_MAX];
size_t h, i, j; size_t h, i, j;
assert(crypto_generichash_statebytes() == sizeof st);
for (h = 0; h < crypto_generichash_KEYBYTES_MAX; ++h) for (h = 0; h < crypto_generichash_KEYBYTES_MAX; ++h)
k[h] = h; k[h] = h;