libcoap 4.3.5-develop-19cef11
OSCORE Support

Internal API for interfacing with OSCORE (RFC8613) More...

+ Collaboration diagram for OSCORE Support:

Data Structures

struct  coap_oscore_conf_t
 The structure used to hold the OSCORE configuration information. More...
 
struct  oscore_ctx_t
 
struct  oscore_sender_ctx_t
 
struct  oscore_recipient_ctx_t
 
struct  oscore_association_t
 

Macros

#define COAP_MAX_HEADER_SIZE   70
 
#define OSCORE_DECRYPTION_ERROR   100
 
#define PACKET_SERIALIZATION_ERROR   102
 
#define CONTEXT_KEY_LEN   16
 
#define TOKEN_SEQ_NUM   2 /* to be set by application */
 
#define EP_CTX_NUM   10 /* to be set by application */
 
#define CONTEXT_INIT_VECT_LEN   13
 
#define CONTEXT_SEQ_LEN   sizeof(uint64_t)
 
#define ED25519_PRIVATE_KEY_LEN   32
 
#define ED25519_PUBLIC_KEY_LEN   32
 
#define ED25519_SEED_LEN   32
 
#define ED25519_SIGNATURE_LEN   64
 
#define OSCORE_SEQ_MAX   (((uint64_t)1 << 40) - 1)
 
#define OSCORE_ASSOCIATIONS_ADD(r, obj)    HASH_ADD(hh, (r), token->s[0], (obj)->token->length, (obj))
 
#define OSCORE_ASSOCIATIONS_DELETE(r, obj)   HASH_DELETE(hh, (r), (obj))
 
#define OSCORE_ASSOCIATIONS_ITER(r, tmp)
 
#define OSCORE_ASSOCIATIONS_ITER_SAFE(e, el, rtmp)    for ((el) = (e); (el) && ((rtmp) = (el)->hh.next, 1); (el) = (rtmp))
 
#define OSCORE_ASSOCIATIONS_FIND(r, k, res)    { HASH_FIND(hh, (r), (k)->s, (k)->length, (res)); }
 
#define HKDF_INFO_MAXLEN   25
 
#define HKDF_OUTPUT_MAXLEN   25
 
#define AES_CCM_TAG   8
 
#define AEAD_PLAINTEXT_MAXLEN   COAP_MAX_CHUNK_SIZE
 
#define AEAD_TAG_MAXLEN   COAP_MAX_CHUNK_SIZE
 

Typedefs

typedef enum oscore_partial_iv_t oscore_partial_iv_t
 
typedef struct oscore_sender_ctx_t oscore_sender_ctx_t
 
typedef struct oscore_recipient_ctx_t oscore_recipient_ctx_t
 
typedef struct oscore_association_t oscore_association_t
 

Enumerations

enum  oscore_partial_iv_t { OSCORE_SEND_NO_IV , OSCORE_SEND_PARTIAL_IV }
 
enum  oscore_mode_t { OSCORE_MODE_SINGLE = 0 , OSCORE_MODE_GROUP , OSCORE_MODE_PAIRWISE }
 

Functions

COAP_API coap_pdu_tcoap_oscore_new_pdu_encrypted (coap_session_t *session, coap_pdu_t *pdu, coap_bin_const_t *kid_context, oscore_partial_iv_t send_partial_iv)
 Encrypts the specified pdu when OSCORE encryption is required on session. More...
 
coap_pdu_tcoap_oscore_new_pdu_encrypted_lkd (coap_session_t *session, coap_pdu_t *pdu, coap_bin_const_t *kid_context, oscore_partial_iv_t send_partial_iv)
 Encrypts the specified pdu when OSCORE encryption is required on session. More...
 
struct coap_pdu_tcoap_oscore_decrypt_pdu (coap_session_t *session, coap_pdu_t *pdu)
 Decrypts the OSCORE-encrypted parts of pdu when OSCORE is used. More...
 
void coap_delete_all_oscore (coap_context_t *context)
 Cleanup all allocated OSCORE information. More...
 
void coap_delete_oscore_associations (coap_session_t *session)
 Cleanup all allocated OSCORE association information. More...
 
size_t coap_oscore_overhead (coap_session_t *session, coap_pdu_t *pdu)
 Determine the additional data size requirements for adding in OSCORE. More...
 
int coap_rebuild_pdu_for_proxy (coap_pdu_t *pdu)
 Convert PDU to use Proxy-Scheme option if Proxy-Uri option is present. More...
 
int coap_oscore_initiate (coap_session_t *session, coap_oscore_conf_t *oscore_conf)
 Initiate an OSCORE session. More...
 
int coap_context_oscore_server_lkd (coap_context_t *context, coap_oscore_conf_t *oscore_conf)
 Set the context's default OSCORE configuration for a server. More...
 
int coap_delete_oscore_recipient_lkd (coap_context_t *context, coap_bin_const_t *recipient_id)
 Release all the information associated for the specific Recipient ID (and hence and stop any further OSCORE protection for this Recipient). More...
 
coap_session_tcoap_new_client_session_oscore_lkd (coap_context_t *ctx, const coap_address_t *local_if, const coap_address_t *server, coap_proto_t proto, coap_oscore_conf_t *oscore_conf)
 Creates a new client session to the designated server, protecting the data using OSCORE. More...
 
coap_session_tcoap_new_client_session_oscore_pki_lkd (coap_context_t *ctx, const coap_address_t *local_if, const coap_address_t *server, coap_proto_t proto, coap_dtls_pki_t *pki_data, coap_oscore_conf_t *oscore_conf)
 Creates a new client session to the designated server with PKI credentials as well as protecting the data using OSCORE. More...
 
coap_session_tcoap_new_client_session_oscore_psk_lkd (coap_context_t *ctx, const coap_address_t *local_if, const coap_address_t *server, coap_proto_t proto, coap_dtls_cpsk_t *psk_data, coap_oscore_conf_t *oscore_conf)
 Creates a new client session to the designated server with PSK credentials as well as protecting the data using OSCORE. More...
 
int coap_new_oscore_recipient_lkd (coap_context_t *context, coap_bin_const_t *recipient_id)
 Add in the specific Recipient ID into the OSCORE context (server only). More...
 
uint8_t * oscore_cs_params (int8_t param, int8_t param_type, size_t *len)
 
uint8_t * oscore_cs_key_params (cose_curve_t param, int8_t param_type, size_t *len)
 
size_t oscore_encode_option_value (uint8_t *option_buffer, size_t option_buf_len, cose_encrypt0_t *cose, uint8_t group, uint8_t appendix_b_2)
 
int oscore_decode_option_value (const uint8_t *option_value, size_t option_len, cose_encrypt0_t *cose)
 
size_t oscore_prepare_aad (const uint8_t *external_aad_buffer, size_t external_aad_len, uint8_t *aad_buffer, size_t aad_size)
 
size_t oscore_prepare_e_aad (oscore_ctx_t *ctx, cose_encrypt0_t *cose, const uint8_t *oscore_option, size_t oscore_option_len, coap_bin_const_t *sender_public_key, uint8_t *external_aad_ptr, size_t external_aad_size)
 
void oscore_generate_nonce (cose_encrypt0_t *ptr, oscore_ctx_t *ctx, uint8_t *buffer, uint8_t size)
 
uint8_t oscore_validate_sender_seq (oscore_recipient_ctx_t *ctx, cose_encrypt0_t *cose)
 
uint8_t oscore_increment_sender_seq (oscore_ctx_t *ctx)
 
void oscore_roll_back_seq (oscore_recipient_ctx_t *ctx)
 
oscore_ctx_toscore_derive_ctx (coap_context_t *c_context, coap_oscore_conf_t *oscore_conf)
 oscore_derive_ctx - derive a osc_ctx from oscore_conf information More...
 
oscore_ctx_toscore_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 More...
 
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 More...
 
void oscore_free_context (oscore_ctx_t *osc_ctx)
 
void oscore_free_contexts (coap_context_t *c_context)
 
int oscore_remove_context (coap_context_t *c_context, oscore_ctx_t *osc_ctx)
 
oscore_recipient_ctx_toscore_add_recipient (oscore_ctx_t *ctx, coap_bin_const_t *rid, uint32_t break_key)
 oscore_add_recipient - add in recipient information More...
 
int oscore_delete_recipient (oscore_ctx_t *osc_ctx, coap_bin_const_t *rid)
 
uint8_t oscore_bytes_equal (uint8_t *a_ptr, uint8_t a_len, uint8_t *b_ptr, uint8_t b_len)
 
void oscore_convert_to_hex (const uint8_t *src, size_t src_len, char *dest, size_t dst_len)
 
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)
 
void oscore_log_char_value (coap_log_t level, const char *name, const char *value)
 
oscore_ctx_toscore_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) More...
 
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)
 
oscore_association_toscore_find_association (coap_session_t *session, coap_bin_const_t *token)
 
int oscore_delete_association (coap_session_t *session, oscore_association_t *association)
 
void oscore_delete_server_associations (coap_session_t *session)
 
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)
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 

Detailed Description

Internal API for interfacing with OSCORE (RFC8613)

Macro Definition Documentation

◆ AEAD_PLAINTEXT_MAXLEN

#define AEAD_PLAINTEXT_MAXLEN   COAP_MAX_CHUNK_SIZE

Definition at line 64 of file oscore_crypto.h.

◆ AEAD_TAG_MAXLEN

#define AEAD_TAG_MAXLEN   COAP_MAX_CHUNK_SIZE

Definition at line 65 of file oscore_crypto.h.

◆ AES_CCM_TAG

#define AES_CCM_TAG   8

Definition at line 61 of file oscore_crypto.h.

◆ COAP_MAX_HEADER_SIZE

#define COAP_MAX_HEADER_SIZE   70

Definition at line 61 of file oscore.h.

◆ CONTEXT_INIT_VECT_LEN

#define CONTEXT_INIT_VECT_LEN   13

Definition at line 64 of file oscore_context.h.

◆ CONTEXT_KEY_LEN

#define CONTEXT_KEY_LEN   16

Definition at line 61 of file oscore_context.h.

◆ CONTEXT_SEQ_LEN

#define CONTEXT_SEQ_LEN   sizeof(uint64_t)

Definition at line 65 of file oscore_context.h.

◆ ED25519_PRIVATE_KEY_LEN

#define ED25519_PRIVATE_KEY_LEN   32

Definition at line 67 of file oscore_context.h.

◆ ED25519_PUBLIC_KEY_LEN

#define ED25519_PUBLIC_KEY_LEN   32

Definition at line 68 of file oscore_context.h.

◆ ED25519_SEED_LEN

#define ED25519_SEED_LEN   32

Definition at line 69 of file oscore_context.h.

◆ ED25519_SIGNATURE_LEN

#define ED25519_SIGNATURE_LEN   64

Definition at line 70 of file oscore_context.h.

◆ EP_CTX_NUM

#define EP_CTX_NUM   10 /* to be set by application */

Definition at line 63 of file oscore_context.h.

◆ HKDF_INFO_MAXLEN

#define HKDF_INFO_MAXLEN   25

Definition at line 59 of file oscore_crypto.h.

◆ HKDF_OUTPUT_MAXLEN

#define HKDF_OUTPUT_MAXLEN   25

Definition at line 60 of file oscore_crypto.h.

◆ OSCORE_ASSOCIATIONS_ADD

#define OSCORE_ASSOCIATIONS_ADD (   r,
  obj 
)     HASH_ADD(hh, (r), token->s[0], (obj)->token->length, (obj))

Definition at line 127 of file oscore_context.h.

◆ OSCORE_ASSOCIATIONS_DELETE

#define OSCORE_ASSOCIATIONS_DELETE (   r,
  obj 
)    HASH_DELETE(hh, (r), (obj))

Definition at line 130 of file oscore_context.h.

◆ OSCORE_ASSOCIATIONS_FIND

#define OSCORE_ASSOCIATIONS_FIND (   r,
  k,
  res 
)     { HASH_FIND(hh, (r), (k)->s, (k)->length, (res)); }

Definition at line 139 of file oscore_context.h.

◆ OSCORE_ASSOCIATIONS_ITER

#define OSCORE_ASSOCIATIONS_ITER (   r,
  tmp 
)
Value:
oscore_associations_t *tmp, *rtmp; \
HASH_ITER (hh, (r), tmp, rtmp)

Definition at line 132 of file oscore_context.h.

◆ OSCORE_ASSOCIATIONS_ITER_SAFE

#define OSCORE_ASSOCIATIONS_ITER_SAFE (   e,
  el,
  rtmp 
)     for ((el) = (e); (el) && ((rtmp) = (el)->hh.next, 1); (el) = (rtmp))

Definition at line 136 of file oscore_context.h.

◆ OSCORE_DECRYPTION_ERROR

#define OSCORE_DECRYPTION_ERROR   100

Definition at line 64 of file oscore.h.

◆ OSCORE_SEQ_MAX

#define OSCORE_SEQ_MAX   (((uint64_t)1 << 40) - 1)

Definition at line 72 of file oscore_context.h.

◆ PACKET_SERIALIZATION_ERROR

#define PACKET_SERIALIZATION_ERROR   102

Definition at line 65 of file oscore.h.

◆ TOKEN_SEQ_NUM

#define TOKEN_SEQ_NUM   2 /* to be set by application */

Definition at line 62 of file oscore_context.h.

Typedef Documentation

◆ oscore_association_t

Definition at line 82 of file oscore_context.h.

◆ oscore_partial_iv_t

◆ oscore_recipient_ctx_t

Definition at line 81 of file oscore_context.h.

◆ oscore_sender_ctx_t

Definition at line 80 of file oscore_context.h.

Enumeration Type Documentation

◆ oscore_mode_t

Enumerator
OSCORE_MODE_SINGLE 

Vanilla RFC8613 support.

OSCORE_MODE_GROUP 

TODO draft-ietf-core-oscore-groupcomm.

OSCORE_MODE_PAIRWISE 

TODO draft-ietf-core-oscore-groupcomm.

Definition at line 74 of file oscore_context.h.

◆ oscore_partial_iv_t

Enumerator
OSCORE_SEND_NO_IV 

Do not send partial IV unless added by a response.

OSCORE_SEND_PARTIAL_IV 

Send partial IV with encrypted PDU.

Definition at line 63 of file coap_oscore_internal.h.

Function Documentation

◆ coap_context_oscore_server_lkd()

int coap_context_oscore_server_lkd ( coap_context_t context,
coap_oscore_conf_t oscore_conf 
)

Set the context's default OSCORE configuration for a server.

Note: This function must be called in the locked state.

Parameters
contextThe current coap_context_t object.
oscore_confOSCORE configuration information. This structure is freed off by this call.
Returns
1 if successful, else 0.

◆ coap_delete_all_oscore()

void coap_delete_all_oscore ( coap_context_t context)

Cleanup all allocated OSCORE information.

Parameters
contextThe context that the OSCORE information is associated with.
+ Here is the caller graph for this function:

◆ coap_delete_oscore_associations()

void coap_delete_oscore_associations ( coap_session_t session)

Cleanup all allocated OSCORE association information.

Parameters
sessionThe session that the OSCORE associations are associated with.
+ Here is the caller graph for this function:

◆ coap_delete_oscore_recipient_lkd()

int coap_delete_oscore_recipient_lkd ( coap_context_t context,
coap_bin_const_t recipient_id 
)

Release all the information associated for the specific Recipient ID (and hence and stop any further OSCORE protection for this Recipient).

Note: This is only removed from the OSCORE context as first defined by coap_new_client_session_oscore*_lkd() or coap_context_oscore_server().

Note: This function must be called in the locked state.

Parameters
contextThe CoAP context holding the OSCORE recipient_id to.
recipient_idThe Recipient ID to remove.
Returns
1 Successfully removed, else 0 not found.

◆ coap_new_client_session_oscore_lkd()

coap_session_t * coap_new_client_session_oscore_lkd ( coap_context_t ctx,
const coap_address_t local_if,
const coap_address_t server,
coap_proto_t  proto,
coap_oscore_conf_t oscore_conf 
)

Creates a new client session to the designated server, protecting the data using OSCORE.

Note: This function must be called in the locked state.

Parameters
ctxThe CoAP context.
local_ifAddress of local interface. It is recommended to use NULL to let the operating system choose a suitable local interface. If an address is specified, the port number should be zero, which means that a free port is automatically selected.
serverThe server's address. If the port number is zero, the default port for the protocol will be used.
protoCoAP Protocol.
oscore_confOSCORE configuration information. This structure is freed off by this call.
Returns
A new CoAP session or NULL if failed. Call coap_session_release_lkd() to free.

◆ coap_new_client_session_oscore_pki_lkd()

coap_session_t * coap_new_client_session_oscore_pki_lkd ( coap_context_t ctx,
const coap_address_t local_if,
const coap_address_t server,
coap_proto_t  proto,
coap_dtls_pki_t pki_data,
coap_oscore_conf_t oscore_conf 
)

Creates a new client session to the designated server with PKI credentials as well as protecting the data using OSCORE.

Note: This function must be called in the locked state.

Parameters
ctxThe CoAP context.
local_ifAddress of local interface. It is recommended to use NULL to let the operating system choose a suitable local interface. If an address is specified, the port number should be zero, which means that a free port is automatically selected.
serverThe server's address. If the port number is zero, the default port for the protocol will be used.
protoCoAP Protocol.
pki_dataPKI parameters.
oscore_confOSCORE configuration information. This structure is freed off by this call.
Returns
A new CoAP session or NULL if failed. Call coap_session_release_lkd() to free.

◆ coap_new_client_session_oscore_psk_lkd()

coap_session_t * coap_new_client_session_oscore_psk_lkd ( coap_context_t ctx,
const coap_address_t local_if,
const coap_address_t server,
coap_proto_t  proto,
coap_dtls_cpsk_t psk_data,
coap_oscore_conf_t oscore_conf 
)

Creates a new client session to the designated server with PSK credentials as well as protecting the data using OSCORE.

Note: This function must be called in the locked state.

Parameters
ctxThe CoAP context.
local_ifAddress of local interface. It is recommended to use NULL to let the operating system choose a suitable local interface. If an address is specified, the port number should be zero, which means that a free port is automatically selected.
serverThe server's address. If the port number is zero, the default port for the protocol will be used.
protoCoAP Protocol.
psk_dataPSK parameters.
oscore_confOSCORE configuration information. This structure is freed off by this call.
Returns
A new CoAP session or NULL if failed. Call coap_session_release_lkd() to free.

◆ coap_new_oscore_recipient_lkd()

int coap_new_oscore_recipient_lkd ( coap_context_t context,
coap_bin_const_t recipient_id 
)

Add in the specific Recipient ID into the OSCORE context (server only).

Note: This is only added to the OSCORE context as first defined by coap_new_client_session_oscore*() or coap_context_oscore_server().

Note: This function must be called in the locked state.

Parameters
contextThe CoAP context to add the OSCORE recipient_id to.
recipient_idThe Recipient ID to add.
Returns
1 Successfully added, else 0 there is an issue.

◆ coap_oscore_decrypt_pdu()

struct coap_pdu_t * coap_oscore_decrypt_pdu ( coap_session_t session,
coap_pdu_t pdu 
)

Decrypts the OSCORE-encrypted parts of pdu when OSCORE is used.

This function returns the decrypted PDU or NULL on error.

Parameters
sessionThe session that will handle the transport of the specified pdu.
pduThe PDU to decrypt if necessary.
Returns
The decrypted pdu, or NULL on error.
+ Here is the caller graph for this function:

◆ coap_oscore_initiate()

int coap_oscore_initiate ( coap_session_t session,
coap_oscore_conf_t oscore_conf 
)

Initiate an OSCORE session.

Parameters
sessionThe session that the OSCORE associations are associated with.
oscore_confThe OSCORE configuration.
Returns
1 success, else 0 failure.

◆ coap_oscore_new_pdu_encrypted()

COAP_API coap_pdu_t * coap_oscore_new_pdu_encrypted ( coap_session_t session,
coap_pdu_t pdu,
coap_bin_const_t kid_context,
oscore_partial_iv_t  send_partial_iv 
)

Encrypts the specified pdu when OSCORE encryption is required on session.

This function returns the encrypted PDU or NULL on error.

Parameters
sessionThe session that will handle the transport of the specified pdu.
pduThe PDU to encrypt if necessary.
kid_contextOptional kid context to use or NULL.
send_partial_ivOSCORE_SEND_PARTIAL_IV if partial_iv is always to be added, else OSCORE_SEND_NO_IV if not to be added for a response if not required.
Returns
The OSCORE encrypted version of pdu, or NULL on error.

◆ coap_oscore_new_pdu_encrypted_lkd()

coap_pdu_t * coap_oscore_new_pdu_encrypted_lkd ( coap_session_t session,
coap_pdu_t pdu,
coap_bin_const_t kid_context,
oscore_partial_iv_t  send_partial_iv 
)

Encrypts the specified pdu when OSCORE encryption is required on session.

This function returns the encrypted PDU or NULL on error.

Note: This function must be called in the locked state.

Parameters
sessionThe session that will handle the transport of the specified pdu.
pduThe PDU to encrypt if necessary.
kid_contextOptional kid context to use or NULL.
send_partial_ivOSCORE_SEND_PARTIAL_IV if partial_iv is always to be added, else OSCORE_SEND_NO_IV if not to be added for a response if not required.
Returns
The OSCORE encrypted version of pdu, or NULL on error.
+ Here is the caller graph for this function:

◆ coap_oscore_overhead()

size_t coap_oscore_overhead ( coap_session_t session,
coap_pdu_t pdu 
)

Determine the additional data size requirements for adding in OSCORE.

Parameters
sessionThe session that the OSCORE associations are associated with.
pduThe non OSCORE protected PDU that is going to be used.
Returns
The OSCORE packet size overhead.
+ Here is the caller graph for this function:

◆ coap_rebuild_pdu_for_proxy()

int coap_rebuild_pdu_for_proxy ( coap_pdu_t pdu)

Convert PDU to use Proxy-Scheme option if Proxy-Uri option is present.

Parameters
pduThe PDU to check and update if appropriate.
Returns
1 success, else 0 failure.
+ Here is the caller graph for this function:

◆ oscore_add_recipient()

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

Parameters
ctxThe OSCORE context to add to.
ridThe recipient ID.
break_key1 if testing for broken keys, else 0.
Returns
NULL if failure or recipient context linked onto ctx chain.

Definition at line 600 of file oscore_context.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ oscore_bytes_equal()

uint8_t oscore_bytes_equal ( uint8_t *  a_ptr,
uint8_t  a_len,
uint8_t *  b_ptr,
uint8_t  b_len 
)

Definition at line 87 of file oscore_context.c.

◆ oscore_convert_to_hex()

void oscore_convert_to_hex ( const uint8_t *  src,
size_t  src_len,
char *  dest,
size_t  dst_len 
)

Definition at line 273 of file oscore_context.c.

+ Here is the caller graph for this function:

◆ oscore_cs_key_params()

uint8_t * oscore_cs_key_params ( cose_curve_t  param,
int8_t  param_type,
size_t *  len 
)

Definition at line 74 of file oscore.c.

+ Here is the call graph for this function:

◆ oscore_cs_params()

uint8_t * oscore_cs_params ( int8_t  param,
int8_t  param_type,
size_t *  len 
)

Definition at line 53 of file oscore.c.

+ Here is the call graph for this function:

◆ oscore_decode_option_value()

int oscore_decode_option_value ( const uint8_t *  option_value,
size_t  option_len,
cose_encrypt0_t cose 
)

Definition at line 246 of file oscore.c.

+ Here is the call graph for this function:

◆ oscore_delete_association()

int oscore_delete_association ( coap_session_t session,
oscore_association_t association 
)

Definition at line 757 of file oscore_context.c.

+ Here is the call graph for this function:

◆ oscore_delete_recipient()

int oscore_delete_recipient ( oscore_ctx_t osc_ctx,
coap_bin_const_t rid 
)

Definition at line 654 of file oscore_context.c.

+ Here is the call graph for this function:

◆ oscore_delete_server_associations()

void oscore_delete_server_associations ( coap_session_t session)

Definition at line 768 of file oscore_context.c.

+ Here is the call graph for this function:

◆ oscore_derive_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

Parameters
c_contextThe CoAP context to associate OSCORE context with.
oscore_confThe OSCORE configuration to use.
Returns
NULL if failure or derived OSCORE context linked onto c_context chain.

Definition at line 513 of file oscore_context.c.

+ Here is the call graph for this function:

◆ oscore_derive_keystream()

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_duplicate_ctx()

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

Parameters
c_contextThe CoAP context to associate OSCORE context with.
o_osc_ctxThe OSCORE context to duplicate.
sender_idThe Sender ID to use in the duplication.
recipient_idThe Recipient ID to use in the duplication.
id_contextThe Context ID to use in the duplicate.
Returns
NULL if failure or duplicated OSCORE context linked onto c_context chain.

Definition at line 429 of file oscore_context.c.

+ Here is the call graph for this function:

◆ oscore_encode_option_value()

size_t oscore_encode_option_value ( uint8_t *  option_buffer,
size_t  option_buf_len,
cose_encrypt0_t cose,
uint8_t  group,
uint8_t  appendix_b_2 
)

Definition at line 170 of file oscore.c.

+ Here is the call graph for this function:

◆ oscore_find_association()

oscore_association_t * oscore_find_association ( coap_session_t session,
coap_bin_const_t token 
)

Definition at line 749 of file oscore_context.c.

◆ oscore_find_context()

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)

Parameters
c_contextThe CoAP COntext to search.
rcpkey_idThe Recipient kid.
ctxkey_idThe ID Context to match (or NULL if no check).
oscore_r2Partial id_context to match against or NULL.
recipient_ctxThe recipient context to update.

return The OSCORE context and recipient_ctx updated, or NULL is error.

Definition at line 185 of file oscore_context.c.

◆ oscore_free_association()

void oscore_free_association ( oscore_association_t association)

Definition at line 674 of file oscore_context.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ oscore_free_context()

void oscore_free_context ( oscore_ctx_t osc_ctx)

Definition at line 125 of file oscore_context.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ oscore_free_contexts()

void oscore_free_contexts ( coap_context_t c_context)

Definition at line 149 of file oscore_context.c.

+ Here is the call graph for this function:

◆ oscore_generate_nonce()

void oscore_generate_nonce ( cose_encrypt0_t ptr,
oscore_ctx_t ctx,
uint8_t *  buffer,
uint8_t  size 
)

Definition at line 343 of file oscore.c.

◆ oscore_hkdf()

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.

Invokes the HKDF-Extract() and HKDF-Expand() functions.

Parameters
hkdf_algThe HKDF algorith to use (e.g. ed25519).
saltThe optional salt value to use.
ikmThe Input Keying material.
infoOptional context / application specific information.
info_lenLength of info (can be 0).
okmOutput key material.
okm_lenLength of output key material (L).
Returns
0 if failure, else 1.

Definition at line 158 of file oscore_crypto.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ oscore_hkdf_expand()

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.

Uses HMAC-HASH() function.

Parameters
hkdf_algThe HKDF algorith to use (e.g. ed25519).
prkUsually ouptut from HKDF-Extract().
infoOptional context / application specific information.
info_lenLength of info (can be 0).
okmOutput key material.
okm_lenLength of output key material (L).
Returns
0 if failure, else 1.

Definition at line 101 of file oscore_crypto.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ oscore_hkdf_extract()

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.

Uses HMAC-HASH() function.

Parameters
hkdf_algThe HKDF algorith to use (e.g. ed25519).
saltThe optional salt value to use.
ikmThe Input Keying material.
hkdf_extractThe output pseudorandom key (length determined by hkdf_alg).
Returns
0 if failure, else 1.

Definition at line 73 of file oscore_crypto.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ oscore_hmac_hash()

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.

Parameters
hmac_algThe HMAC algorith to use (e.g. sha256).
keyThe key to use.
dataThe data to hash.
hmacThe result of the hash.
Returns
0 if failure, else 1.

Definition at line 57 of file oscore_crypto.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ oscore_increment_sender_seq()

uint8_t oscore_increment_sender_seq ( oscore_ctx_t ctx)

Definition at line 430 of file oscore.c.

◆ oscore_log_char_value()

void oscore_log_char_value ( coap_log_t  level,
const char *  name,
const char *  value 
)

Definition at line 268 of file oscore_context.c.

+ Here is the caller graph for this function:

◆ oscore_log_hex_value()

void oscore_log_hex_value ( coap_log_t  level,
const char *  name,
coap_bin_const_t value 
)

Definition at line 235 of file oscore_context.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ oscore_log_int_value()

void oscore_log_int_value ( coap_log_t  level,
const char *  name,
int  value 
)

Definition at line 263 of file oscore_context.c.

◆ oscore_new_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 
)

Definition at line 687 of file oscore_context.c.

+ Here is the call graph for this function:

◆ oscore_prepare_aad()

size_t oscore_prepare_aad ( const uint8_t *  external_aad_buffer,
size_t  external_aad_len,
uint8_t *  aad_buffer,
size_t  aad_size 
)

Definition at line 312 of file oscore.c.

+ Here is the call graph for this function:

◆ oscore_prepare_e_aad()

size_t oscore_prepare_e_aad ( oscore_ctx_t ctx,
cose_encrypt0_t cose,
const uint8_t *  oscore_option,
size_t  oscore_option_len,
coap_bin_const_t sender_public_key,
uint8_t *  external_aad_ptr,
size_t  external_aad_size 
)

Definition at line 119 of file oscore.c.

+ Here is the call graph for this function:

◆ oscore_remove_context()

int oscore_remove_context ( coap_context_t c_context,
oscore_ctx_t osc_ctx 
)

Definition at line 160 of file oscore_context.c.

+ Here is the call graph for this function:

◆ oscore_roll_back_seq()

void oscore_roll_back_seq ( oscore_recipient_ctx_t ctx)

Definition at line 447 of file oscore.c.

◆ oscore_update_ctx()

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

Parameters
osc_ctxThe OSCORE context to update.
id_contextThe Context ID to use in the duplicate.

Definition at line 387 of file oscore_context.c.

+ Here is the call graph for this function:

◆ oscore_validate_sender_seq()

uint8_t oscore_validate_sender_seq ( oscore_recipient_ctx_t ctx,
cose_encrypt0_t cose 
)

Definition at line 366 of file oscore.c.

+ Here is the call graph for this function: