libcoap 4.3.5-develop-19cef11
|
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_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 . More... | |
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 . 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... | |
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_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. More... | |
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. More... | |
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. 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_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... | |
Internal API for interfacing with OSCORE (RFC8613)
#define AEAD_PLAINTEXT_MAXLEN COAP_MAX_CHUNK_SIZE |
Definition at line 64 of file oscore_crypto.h.
#define AEAD_TAG_MAXLEN COAP_MAX_CHUNK_SIZE |
Definition at line 65 of file oscore_crypto.h.
#define AES_CCM_TAG 8 |
Definition at line 61 of file oscore_crypto.h.
#define CONTEXT_INIT_VECT_LEN 13 |
Definition at line 64 of file oscore_context.h.
#define CONTEXT_KEY_LEN 16 |
Definition at line 61 of file oscore_context.h.
#define CONTEXT_SEQ_LEN sizeof(uint64_t) |
Definition at line 65 of file oscore_context.h.
#define ED25519_PRIVATE_KEY_LEN 32 |
Definition at line 67 of file oscore_context.h.
#define ED25519_PUBLIC_KEY_LEN 32 |
Definition at line 68 of file oscore_context.h.
#define ED25519_SEED_LEN 32 |
Definition at line 69 of file oscore_context.h.
#define ED25519_SIGNATURE_LEN 64 |
Definition at line 70 of file oscore_context.h.
#define EP_CTX_NUM 10 /* to be set by application */ |
Definition at line 63 of file oscore_context.h.
#define HKDF_INFO_MAXLEN 25 |
Definition at line 59 of file oscore_crypto.h.
#define HKDF_OUTPUT_MAXLEN 25 |
Definition at line 60 of file oscore_crypto.h.
#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.
#define OSCORE_ASSOCIATIONS_DELETE | ( | r, | |
obj | |||
) | HASH_DELETE(hh, (r), (obj)) |
Definition at line 130 of file oscore_context.h.
#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.
#define OSCORE_ASSOCIATIONS_ITER | ( | r, | |
tmp | |||
) |
Definition at line 132 of file oscore_context.h.
#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.
#define OSCORE_SEQ_MAX (((uint64_t)1 << 40) - 1) |
Definition at line 72 of file oscore_context.h.
#define TOKEN_SEQ_NUM 2 /* to be set by application */ |
Definition at line 62 of file oscore_context.h.
typedef struct oscore_association_t oscore_association_t |
Definition at line 82 of file oscore_context.h.
typedef enum oscore_partial_iv_t oscore_partial_iv_t |
typedef struct oscore_recipient_ctx_t oscore_recipient_ctx_t |
Definition at line 81 of file oscore_context.h.
typedef struct oscore_sender_ctx_t oscore_sender_ctx_t |
Definition at line 80 of file oscore_context.h.
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.
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.
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.
context | The current coap_context_t object. |
oscore_conf | OSCORE configuration information. This structure is freed off by this call. |
1
if successful, else 0
. void coap_delete_all_oscore | ( | coap_context_t * | context | ) |
Cleanup all allocated OSCORE information.
context | The context that the OSCORE information is associated with. |
void coap_delete_oscore_associations | ( | coap_session_t * | session | ) |
Cleanup all allocated OSCORE association information.
session | The session that the OSCORE associations are associated with. |
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.
context | The CoAP context holding the OSCORE recipient_id to. |
recipient_id | The Recipient ID to remove. |
1
Successfully removed, else 0
not found. 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.
ctx | The CoAP context. |
local_if | Address 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. |
server | The server's address. If the port number is zero, the default port for the protocol will be used. |
proto | CoAP Protocol. |
oscore_conf | OSCORE configuration information. This structure is freed off by this call. |
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.
ctx | The CoAP context. |
local_if | Address 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. |
server | The server's address. If the port number is zero, the default port for the protocol will be used. |
proto | CoAP Protocol. |
pki_data | PKI parameters. |
oscore_conf | OSCORE configuration information. This structure is freed off by this call. |
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.
ctx | The CoAP context. |
local_if | Address 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. |
server | The server's address. If the port number is zero, the default port for the protocol will be used. |
proto | CoAP Protocol. |
psk_data | PSK parameters. |
oscore_conf | OSCORE configuration information. This structure is freed off by this call. |
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.
context | The CoAP context to add the OSCORE recipient_id to. |
recipient_id | The Recipient ID to add. |
1
Successfully added, else 0
there is an issue. 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.
session | The session that will handle the transport of the specified pdu . |
pdu | The PDU to decrypt if necessary. |
pdu
, or NULL
on error. int coap_oscore_initiate | ( | coap_session_t * | session, |
coap_oscore_conf_t * | oscore_conf | ||
) |
Initiate an OSCORE session.
session | The session that the OSCORE associations are associated with. |
oscore_conf | The OSCORE configuration. |
1
success, else 0
failure. 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.
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. |
pdu
, or NULL
on error. 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.
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. |
pdu
, or NULL
on error. size_t coap_oscore_overhead | ( | coap_session_t * | session, |
coap_pdu_t * | pdu | ||
) |
Determine the additional data size requirements for adding in OSCORE.
session | The session that the OSCORE associations are associated with. |
pdu | The non OSCORE protected PDU that is going to be used. |
int coap_rebuild_pdu_for_proxy | ( | coap_pdu_t * | pdu | ) |
Convert PDU to use Proxy-Scheme option if Proxy-Uri option is present.
pdu | The PDU to check and update if appropriate. |
1
success, else 0
failure. 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
ctx | The OSCORE context to add to. |
rid | The recipient ID. |
break_key | 1 if testing for broken keys, else 0 . |
ctx
chain. Definition at line 600 of file oscore_context.c.
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.
void oscore_convert_to_hex | ( | const uint8_t * | src, |
size_t | src_len, | ||
char * | dest, | ||
size_t | dst_len | ||
) |
uint8_t * oscore_cs_key_params | ( | cose_curve_t | param, |
int8_t | param_type, | ||
size_t * | len | ||
) |
uint8_t * oscore_cs_params | ( | int8_t | param, |
int8_t | param_type, | ||
size_t * | len | ||
) |
int oscore_decode_option_value | ( | const uint8_t * | option_value, |
size_t | option_len, | ||
cose_encrypt0_t * | cose | ||
) |
int oscore_delete_association | ( | coap_session_t * | session, |
oscore_association_t * | association | ||
) |
int oscore_delete_recipient | ( | oscore_ctx_t * | osc_ctx, |
coap_bin_const_t * | rid | ||
) |
void oscore_delete_server_associations | ( | coap_session_t * | session | ) |
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
c_context | The CoAP context to associate OSCORE context with. |
oscore_conf | The OSCORE configuration to use. |
c_context
chain. Definition at line 513 of file oscore_context.c.
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_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
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. |
c_context
chain. Definition at line 429 of file oscore_context.c.
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 | ||
) |
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_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)
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.
void oscore_free_association | ( | oscore_association_t * | association | ) |
Definition at line 674 of file oscore_context.c.
void oscore_free_context | ( | oscore_ctx_t * | osc_ctx | ) |
Definition at line 125 of file oscore_context.c.
void oscore_free_contexts | ( | coap_context_t * | c_context | ) |
void oscore_generate_nonce | ( | cose_encrypt0_t * | ptr, |
oscore_ctx_t * | ctx, | ||
uint8_t * | buffer, | ||
uint8_t | size | ||
) |
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.
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). |
0
if failure, else 1
. Definition at line 158 of file oscore_crypto.c.
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.
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). |
0
if failure, else 1
. Definition at line 101 of file oscore_crypto.c.
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.
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). |
0
if failure, else 1
. Definition at line 73 of file oscore_crypto.c.
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.
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. |
0
if failure, else 1
. Definition at line 57 of file oscore_crypto.c.
uint8_t oscore_increment_sender_seq | ( | oscore_ctx_t * | ctx | ) |
void oscore_log_char_value | ( | coap_log_t | level, |
const char * | name, | ||
const char * | 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.
void oscore_log_int_value | ( | coap_log_t | level, |
const char * | name, | ||
int | value | ||
) |
Definition at line 263 of file oscore_context.c.
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 | ||
) |
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 | ||
) |
int oscore_remove_context | ( | coap_context_t * | c_context, |
oscore_ctx_t * | osc_ctx | ||
) |
void oscore_roll_back_seq | ( | oscore_recipient_ctx_t * | 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
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.
uint8_t oscore_validate_sender_seq | ( | oscore_recipient_ctx_t * | ctx, |
cose_encrypt0_t * | cose | ||
) |