This commit is contained in:
Frank Denis 2017-02-19 21:17:42 +01:00
parent 7f7e7235c5
commit 7e5d64834c
3 changed files with 7 additions and 7 deletions

View File

@ -39,7 +39,7 @@ int crypto_kdf_blake2b_derive_from_key(unsigned char *subkey, size_t subkey_len,
memcpy(ctx_padded, ctx, crypto_kdf_blake2b_CONTEXTBYTES);
memset(ctx_padded + crypto_kdf_blake2b_CONTEXTBYTES, 0, sizeof ctx_padded - crypto_kdf_blake2b_CONTEXTBYTES);
STORE64_LE(salt, subkey_id);
memset(salt + 8, 0, (sizeof salt) - 8);
memset(salt + 8, 0, (sizeof salt) - 8);
if (subkey_len < crypto_kdf_blake2b_BYTES_MIN ||
subkey_len > crypto_kdf_blake2b_BYTES_MAX) {
errno = EINVAL;

View File

@ -26,7 +26,7 @@ size_t crypto_kdf_bytes_max(void);
SODIUM_EXPORT
size_t crypto_kdf_contextbytes(void);
#define crypto_kdf_KEYBYTES crypto_kdf_blake2b_KEYBYTES
#define crypto_kdf_KEYBYTES crypto_kdf_blake2b_KEYBYTES
SODIUM_EXPORT
size_t crypto_kdf_keybytes(void);

View File

@ -12,8 +12,8 @@ tv_kdf(void)
uint64_t i;
context = (char *) sodium_malloc(crypto_kdf_CONTEXTBYTES);
memcpy(context, "KDF test", strlen("KDF test"));
master_key = (unsigned char *) sodium_malloc(crypto_kdf_KEYBYTES);
memcpy(context, "KDF test", strlen("KDF test"));
master_key = (unsigned char *) sodium_malloc(crypto_kdf_KEYBYTES);
for (i = 0; i < crypto_kdf_KEYBYTES; i++) {
master_key[i] = i;
}
@ -27,7 +27,7 @@ tv_kdf(void)
sodium_free(subkey);
for (i = 0; i < crypto_kdf_BYTES_MAX + 2; i++) {
subkey = (unsigned char *) sodium_malloc(crypto_kdf_BYTES_MAX);
subkey = (unsigned char *) sodium_malloc(crypto_kdf_BYTES_MAX);
if (crypto_kdf_blake2b_derive_from_key(subkey, (size_t) i,
i, context, master_key) == 0) {
sodium_bin2hex(hex, sizeof hex, subkey, (size_t) i);
@ -36,9 +36,9 @@ tv_kdf(void)
printf("Failure -- probably expected for output length=%u\n",
(unsigned int) i);
}
sodium_free(subkey);
sodium_free(subkey);
}
printf("tv_kdf: ok\n");
printf("tv_kdf: ok\n");
}
int