Test crypto_kdf constants, add _PRIMITIVE

This commit is contained in:
Frank Denis 2017-02-26 21:30:40 +01:00
parent 8a213f021c
commit c0c645da45
3 changed files with 21 additions and 0 deletions

View File

@ -2,6 +2,12 @@
#include "crypto_kdf.h"
#include "randombytes.h"
const char *
crypto_kdf_primitive(void)
{
return crypto_kdf_PRIMITIVE;
}
size_t
crypto_kdf_bytes_min(void)
{

View File

@ -30,6 +30,10 @@ size_t crypto_kdf_contextbytes(void);
SODIUM_EXPORT
size_t crypto_kdf_keybytes(void);
#define crypto_kdf_PRIMITIVE "blake2b"
SODIUM_EXPORT
const char *crypto_kdf_primitive(void);
SODIUM_EXPORT
int crypto_kdf_derive_from_key(unsigned char *subkey, size_t subkey_len,
uint64_t subkey_id,

View File

@ -38,6 +38,17 @@ tv_kdf(void)
}
sodium_free(subkey);
}
assert(strcmp(crypto_kdf_primitive(), crypto_kdf_PRIMITIVE) == 0);
assert(crypto_kdf_BYTES_MAX > 0);
assert(crypto_kdf_BYTES_MIN <= crypto_kdf_BYTES_MAX);
assert(crypto_kdf_bytes_min() == crypto_kdf_BYTES_MIN);
assert(crypto_kdf_bytes_max() == crypto_kdf_BYTES_MAX);
assert(crypto_kdf_CONTEXTBYTES > 0);
assert(crypto_kdf_contextbytes() == crypto_kdf_CONTEXTBYTES);
assert(crypto_kdf_KEYBYTES >= 16);
assert(crypto_kdf_keybytes() == crypto_kdf_KEYBYTES);
printf("tv_kdf: ok\n");
}