48#ifndef _OSCORE_CONTEXT_H
49#define _OSCORE_CONTEXT_H
52#include "coap3/coap_uthash_internal.h"
61#define CONTEXT_KEY_LEN 16
62#define TOKEN_SEQ_NUM 2
64#define CONTEXT_INIT_VECT_LEN 13
65#define CONTEXT_SEQ_LEN sizeof(uint64_t)
67#define ED25519_PRIVATE_KEY_LEN 32
68#define ED25519_PUBLIC_KEY_LEN 32
69#define ED25519_SEED_LEN 32
70#define ED25519_SIGNATURE_LEN 64
72#define OSCORE_SEQ_MAX (((uint64_t)1 << 40) - 1)
127#define OSCORE_ASSOCIATIONS_ADD(r, obj) \
128 HASH_ADD(hh, (r), token->s[0], (obj)->token->length, (obj))
130#define OSCORE_ASSOCIATIONS_DELETE(r, obj) HASH_DELETE(hh, (r), (obj))
132#define OSCORE_ASSOCIATIONS_ITER(r, tmp) \
133 oscore_associations_t *tmp, *rtmp; \
134 HASH_ITER (hh, (r), tmp, rtmp)
136#define OSCORE_ASSOCIATIONS_ITER_SAFE(e, el, rtmp) \
137 for ((el) = (e); (el) && ((rtmp) = (el)->hh.next, 1); (el) = (rtmp))
139#define OSCORE_ASSOCIATIONS_FIND(r, k, res) \
140 { HASH_FIND(hh, (r), (k)->s, (k)->length, (res)); }
270 uint8_t coap_request,
275 size_t keystream_size);
Pulls together all the internal only header files.
uint64_t coap_tick_t
This data type represents internal timer ticks with COAP_TICKS_PER_SECOND resolution.
void oscore_convert_to_hex(const uint8_t *src, size_t src_len, char *dest, size_t dst_len)
int oscore_delete_association(coap_session_t *session, oscore_association_t *association)
oscore_recipient_ctx_t * oscore_add_recipient(oscore_ctx_t *ctx, coap_bin_const_t *rid, uint32_t break_key)
oscore_add_recipient - add in recipient information
int oscore_delete_recipient(oscore_ctx_t *osc_ctx, coap_bin_const_t *rid)
void oscore_update_ctx(oscore_ctx_t *osc_ctx, coap_bin_const_t *id_context)
oscore_update_ctx - update a osc_ctx with a new id_context
void oscore_free_context(oscore_ctx_t *osc_ctx)
oscore_ctx_t * oscore_derive_ctx(coap_context_t *c_context, coap_oscore_conf_t *oscore_conf)
oscore_derive_ctx - derive a osc_ctx from oscore_conf information
void oscore_free_association(oscore_association_t *association)
int oscore_new_association(coap_session_t *session, coap_pdu_t *sent_pdu, coap_bin_const_t *token, oscore_recipient_ctx_t *recipient_ctx, coap_bin_const_t *aad, coap_bin_const_t *nonce, coap_bin_const_t *partial_iv, int is_observe)
void oscore_delete_server_associations(coap_session_t *session)
void oscore_log_char_value(coap_log_t level, const char *name, const char *value)
void oscore_free_contexts(coap_context_t *c_context)
void oscore_log_hex_value(coap_log_t level, const char *name, coap_bin_const_t *value)
void oscore_log_int_value(coap_log_t level, const char *name, int value)
oscore_ctx_t * oscore_duplicate_ctx(coap_context_t *c_context, oscore_ctx_t *o_osc_ctx, coap_bin_const_t *sender_id, coap_bin_const_t *recipient_id, coap_bin_const_t *id_context)
oscore_duplicate_ctx - duplicate a osc_ctx
int oscore_remove_context(coap_context_t *c_context, oscore_ctx_t *osc_ctx)
int oscore_derive_keystream(oscore_ctx_t *osc_ctx, cose_encrypt0_t *code, uint8_t coap_request, coap_bin_const_t *sender_key, coap_bin_const_t *id_context, size_t cs_size, uint8_t *keystream, size_t keystream_size)
oscore_association_t * oscore_find_association(coap_session_t *session, coap_bin_const_t *token)
oscore_ctx_t * oscore_find_context(const coap_context_t *c_context, const coap_bin_const_t rcpkey_id, const coap_bin_const_t *ctxkey_id, uint8_t *oscore_r2, oscore_recipient_ctx_t **recipient_ctx)
oscore_find_context - Locate recipient context (and hence OSCORE context)
uint8_t oscore_bytes_equal(uint8_t *a_ptr, uint8_t a_len, uint8_t *b_ptr, uint8_t b_len)
@ OSCORE_MODE_SINGLE
Vanilla RFC8613 support.
@ OSCORE_MODE_PAIRWISE
TODO draft-ietf-core-oscore-groupcomm.
@ OSCORE_MODE_GROUP
TODO draft-ietf-core-oscore-groupcomm.
int(* coap_oscore_save_seq_num_t)(uint64_t sender_seq_num, void *param)
Definition of the function used to save the current Sender Sequence Number.
CoAP binary data definition with const data.
The CoAP stack's global state is stored in a coap_context_t object.
The structure used to hold the OSCORE configuration information.
Abstraction of virtual session that can be attached to coap_context_t (client) or coap_endpoint_t (se...
coap_bin_const_t * partial_iv
oscore_recipient_ctx_t * recipient_ctx
coap_bin_const_t * master_secret
uint32_t replay_window_size
coap_bin_const_t * common_iv
Derived from Master Secret, Master Salt, and ID Context.
struct oscore_ctx_t * next
uint8_t rfc8613_b_1_2
1 if rfc8613 B.1.2 enabled else 0
void * save_seq_num_func_param
Passed to save_seq_num_func()
oscore_sender_ctx_t * sender_context
uint8_t rfc8613_b_2
1 if rfc8613 B.2 protocol else 0
coap_bin_const_t * master_salt
coap_oscore_save_seq_num_t save_seq_num_func
Called every seq num change.
oscore_recipient_ctx_t * recipient_chain
coap_bin_const_t * id_context
contains GID in case of group
uint32_t ssn_freq
Sender Seq Num update frequency.
uint64_t rollback_sliding_window
oscore_recipient_ctx_t * next_recipient
coap_bin_const_t * recipient_key
coap_bin_const_t * recipient_id
uint64_t rollback_last_seq
coap_bin_const_t * sender_id
coap_bin_const_t * sender_key
uint64_t next_seq
Used for ssn_freq updating.