libcoap 4.3.2rc2

Data Structures | Macros | Typedefs | Enumerations | Functions
OSCORE Support
Libcoap Internal API

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

## 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_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`. More...
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. 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...
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_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 More...
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 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_t * | oscore_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_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) 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_t * | oscore_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

typedef struct oscore_association_t oscore_association_t

Definition at line 82 of file oscore_context.h.

## ◆ oscore_partial_iv_t

typedef enum oscore_partial_iv_t oscore_partial_iv_t

## ◆ oscore_recipient_ctx_t

typedef struct oscore_recipient_ctx_t oscore_recipient_ctx_t

Definition at line 81 of file oscore_context.h.

## ◆ oscore_sender_ctx_t

typedef struct oscore_sender_ctx_t oscore_sender_ctx_t

Definition at line 80 of file oscore_context.h.

## Enumeration Type Documentation

## ◆ oscore_mode_t

enum 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

enum 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_delete_all_oscore()

void coap_delete_all_oscore | ( | coap_context_t * | context | ) |

Cleanup all allocated OSCORE information.

Parameters

  context | The context that the OSCORE information is associated with.

## ◆ coap_delete_oscore_associations()

void coap_delete_oscore_associations | ( | coap_session_t * | session | ) |

Cleanup all allocated OSCORE association information.

Parameters

  session | The session that the OSCORE associations are associated with.

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

  session | The session that will handle the transport of the specified `pdu`.
  pdu | The PDU to decrypt if necessary.

Returns
  The decrypted `pdu`, or `NULL` on error.

## ◆ coap_oscore_initiate()

int coap_oscore_initiate | ( | coap_session_t * | session,
|  | coap_oscore_conf_t * | oscore_conf
| ) |  |

Initiate an OSCORE session.

Parameters

  session | The session that the OSCORE associations are associated with.
  oscore_conf | The OSCORE configuration.

Returns
  `1` success, else `0` failure.

## ◆ coap_oscore_new_pdu_encrypted()

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

  session | The session that will handle the transport of the specified `pdu`.
  pdu | The PDU to encrypt if necessary.
  kid_context | Optional kid context to use or NULL.
  send_partial_iv | `OSCORE_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_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

  session | The session that the OSCORE associations are associated with.
  pdu | The non OSCORE protected PDU that is going to be used.

Returns
  The OSCORE packet size overhead.

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

  pdu | The PDU to check and update if appropriate.

Returns
  `1` success, else `0` failure.

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

  ctx | The OSCORE context to add to.
  rid | The recipient ID.
  break_key | `1` 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.

## ◆ 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.

## ◆ 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.

## ◆ 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.

## ◆ 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.

## ◆ oscore_delete_association()

int oscore_delete_association | ( | coap_session_t * | session,
|  | oscore_association_t * | association
| ) |  |

Definition at line 756 of file oscore_context.c.

## ◆ 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.

## ◆ oscore_delete_server_associations()

void oscore_delete_server_associations | ( | coap_session_t * | session | ) |

Definition at line 767 of file oscore_context.c.

## ◆ 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_context | The CoAP context to associate OSCORE context with.
  oscore_conf | The 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.

## ◆ 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_context | The CoAP context to associate OSCORE context with.
  o_osc_ctx | The OSCORE context to duplicate.
  sender_id | The Sender ID to use in the duplication.
  recipient_id | The Recipient ID to use in the duplication.
  id_context | The 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.

## ◆ 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.

## ◆ oscore_find_association()

oscore_association_t * oscore_find_association | ( | coap_session_t * | session,
|  | coap_bin_const_t * | token
| ) |  |

Definition at line 748 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_context | The CoAP COntext to search.
  rcpkey_id | The Recipient kid.
  ctxkey_id | The ID Context to match (or NULL if no check).
  oscore_r2 | Partial id_context to match against or NULL.
  recipient_ctx | The 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.

## ◆ oscore_free_context()

void oscore_free_context | ( | oscore_ctx_t * | osc_ctx | ) |

Definition at line 125 of file oscore_context.c.

## ◆ oscore_free_contexts()

void oscore_free_contexts | ( | coap_context_t * | c_context | ) |

Definition at line 149 of file oscore_context.c.

## ◆ 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_alg | The HKDF algorith to use (e.g. ed25519).
  salt | The optional salt value to use.
  ikm | The Input Keying material.
  info | Optional context / application specific information.
  info_len | Length of info (can be 0).
  okm | Output key material.
  okm_len | Length of output key material (L).

Returns
  `0` if failure, else `1`.

Definition at line 158 of file oscore_crypto.c.

## ◆ 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_alg | The HKDF algorith to use (e.g. ed25519).
  prk | Usually ouptut from HKDF-Extract().
  info | Optional context / application specific information.
  info_len | Length of info (can be 0).
  okm | Output key material.
  okm_len | Length of output key material (L).

Returns
  `0` if failure, else `1`.

Definition at line 101 of file oscore_crypto.c.

## ◆ 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_alg | The HKDF algorith to use (e.g. ed25519).
  salt | The optional salt value to use.
  ikm | The Input Keying material.
  hkdf_extract | The output pseudorandom key (length determined by hkdf_alg).

Returns
  `0` if failure, else `1`.

Definition at line 73 of file oscore_crypto.c.

## ◆ 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_alg | The HMAC algorith to use (e.g. sha256).
  key | The key to use.
  data | The data to hash.
  hmac | The result of the hash.

Returns
  `0` if failure, else `1`.

Definition at line 57 of file oscore_crypto.c.

## ◆ 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.

## ◆ 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.

## ◆ 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 686 of file oscore_context.c.

## ◆ 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.

## ◆ 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.

## ◆ 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.

## ◆ 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_ctx | The OSCORE context to update.
  id_context | The Context ID to use in the duplicate.

Definition at line 387 of file oscore_context.c.

## ◆ 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.