1 
2 #include "crypto_kdf.h"
3 #include "randombytes.h"
4 
5 const char *
crypto_kdf_primitive(void)6 crypto_kdf_primitive(void)
7 {
8     return crypto_kdf_PRIMITIVE;
9 }
10 
11 size_t
crypto_kdf_bytes_min(void)12 crypto_kdf_bytes_min(void)
13 {
14     return crypto_kdf_BYTES_MIN;
15 }
16 
17 size_t
crypto_kdf_bytes_max(void)18 crypto_kdf_bytes_max(void)
19 {
20     return crypto_kdf_BYTES_MAX;
21 }
22 
23 size_t
crypto_kdf_contextbytes(void)24 crypto_kdf_contextbytes(void)
25 {
26     return crypto_kdf_CONTEXTBYTES;
27 }
28 
29 size_t
crypto_kdf_keybytes(void)30 crypto_kdf_keybytes(void)
31 {
32     return crypto_kdf_KEYBYTES;
33 }
34 
35 int
crypto_kdf_derive_from_key(unsigned char * subkey,size_t subkey_len,uint64_t subkey_id,const char ctx[crypto_kdf_CONTEXTBYTES],const unsigned char key[crypto_kdf_KEYBYTES])36 crypto_kdf_derive_from_key(unsigned char *subkey, size_t subkey_len,
37                            uint64_t subkey_id,
38                            const char ctx[crypto_kdf_CONTEXTBYTES],
39                            const unsigned char key[crypto_kdf_KEYBYTES])
40 {
41     return crypto_kdf_blake2b_derive_from_key(subkey, subkey_len,
42                                               subkey_id, ctx, key);
43 }
44 
45 void
crypto_kdf_keygen(unsigned char k[crypto_kdf_KEYBYTES])46 crypto_kdf_keygen(unsigned char k[crypto_kdf_KEYBYTES])
47 {
48     randombytes_buf(k, crypto_kdf_KEYBYTES);
49 }
50