82 if (salt == NULL || salt->
s == NULL) {
83 uint8_t zeroes_data[32];
86 memset(zeroes_data, 0,
sizeof(zeroes_data));
87 zeroes.
s = zeroes_data;
88 zeroes.
length =
sizeof(zeroes_data);
107 size_t N = (okm_len + 32 - 1) / 32;
109 uint8_t *out_buffer =
119 memcpy(aggregate_buffer, info, info_len);
120 aggregate_buffer[info_len] = 0x01;
122 data.
s = aggregate_buffer;
123 data.
length = info_len + 1;
126 memcpy(&out_buffer[0], hkdf->
s, hkdf->
length);
130 memcpy(aggregate_buffer, &(out_buffer[0]), 32);
131 for (i = 1; i < N; i++) {
132 memcpy(&(aggregate_buffer[32]), info, info_len);
133 aggregate_buffer[32 + info_len] = (uint8_t)(i + 1);
134 data.
s = aggregate_buffer;
135 data.
length = 32 + info_len + 1;
138 memcpy(&out_buffer[i * 32], hkdf->
s, hkdf->
length);
140 memcpy(aggregate_buffer, &(out_buffer[i * 32]), 32);
142 memcpy(okm, out_buffer, okm_len);
Pulls together all the internal only header files.
void * coap_malloc_type(coap_memory_tag_t type, size_t size)
Allocates a chunk of size bytes and returns a pointer to the newly allocated memory.
void coap_free_type(coap_memory_tag_t type, void *p)
Releases the memory that was allocated by coap_malloc_type().
int coap_crypto_hmac(cose_hmac_alg_t hmac_alg, coap_bin_const_t *key, coap_bin_const_t *data, coap_bin_const_t **hmac)
Create a HMAC hash of the provided data.
#define coap_log_warn(...)
int cose_get_hmac_alg_for_hkdf(cose_hkdf_alg_t hkdf_alg, cose_hmac_alg_t *hmac_alg)
int oscore_hkdf_expand(cose_hkdf_alg_t hkdf_alg, coap_bin_const_t *prk, uint8_t *info, size_t info_len, uint8_t *okm, size_t okm_len)
Derive the key using HKDF-Expand() function.
int oscore_hkdf(cose_hkdf_alg_t hkdf_alg, coap_bin_const_t *salt, coap_bin_const_t *ikm, uint8_t *info, size_t info_len, uint8_t *okm, size_t okm_len)
Derive the key using HKDF() function.
int oscore_hmac_hash(cose_hmac_alg_t hmac_alg, coap_bin_const_t *key, coap_bin_const_t *data, coap_bin_const_t **hmac)
Derive the hmac hash using HMAC-HASH() function.
int oscore_hkdf_extract(cose_hkdf_alg_t hkdf_alg, coap_bin_const_t *salt, coap_bin_const_t *ikm, coap_bin_const_t **hkdf_extract)
Derive the pseudorandom key using HKDF-Extract() function.
void coap_delete_bin_const(coap_bin_const_t *s)
Deletes the given const binary data and releases any memory allocated.
CoAP binary data definition with const data.
size_t length
length of binary data
const uint8_t * s
read-only binary data