libcoap 4.3.5-develop-379c7f4
Loading...
Searching...
No Matches
coap_oscore_internal.h
Go to the documentation of this file.
1/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
3/*
4 * coap_oscore_internal.h - Object Security for Constrained RESTful Environments
5 * (OSCORE) support for libcoap
6 *
7 * Copyright (C) 2019-2026 Olaf Bergmann <bergmann@tzi.org>
8 * Copyright (C) 2021-2026 Jon Shallow <supjps-libcoap:jpshallow.com>
9 *
10 * SPDX-License-Identifier: BSD-2-Clause
11 *
12 * This file is part of the CoAP library libcoap. Please see README for terms
13 * of use.
14 */
15
20
21#ifndef COAP_OSCORE_INTERNAL_H_
22#define COAP_OSCORE_INTERNAL_H_
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
34
40#if COAP_OSCORE_GROUP_SUPPORT
41 /* Group */
42 int group_mode;
43 /* Pair Wise */
44 int pairwise_mode;
45 coap_crypto_cred_t *gs_public_cred;
47 coap_crypto_pri_key_t *gs_private_key;
49#endif /* COAP_OSCORE_GROUP_SUPPORT */
50};
51
59 /* Silent Server */
61
62 /* SSN handling for rfc8613 B.1.2 */
65 uint64_t last_seq;
66 uint64_t sliding_window;
67#if COAP_OSCORE_GROUP_SUPPORT
68 coap_crypto_cred_t *gr_public_cred;
70 cose_curve_t sign_curve;
71 /* Group */
72 int group_mode;
73 /* Pair Wise */
74 int pairwise_mode;
75#endif /* COAP_OSCORE_GROUP_SUPPORT */
76};
77
87 uint32_t replay_window;
89 uint32_t ssn_freq;
92 uint32_t rfc8613_b_1_2;
93 uint32_t rfc8613_b_2;
94
95#if COAP_OSCORE_GROUP_SUPPORT
96 oscore_auth_cred_t cred_type;
97 coap_crypto_cred_t *gm_cred;
98 cose_curve_t ecdh_alg;
99 int cred_fmt;
100 cose_alg_t alg_group_enc;
101 cose_alg_t alg_signature;
102 cose_curve_t sign_curve;
103 coap_bin_const_t *sign_enc_key;
104 cose_alg_t alg_pairwise_key_agreement;
105#endif /* COAP_OSCORE_GROUP_SUPPORT */
106
107 /* General Testing */
110
111 /* SSN handling (not in oscore_config[]) */
115 uint64_t start_seq_num;
116};
117
122
139 coap_pdu_t *pdu,
140 coap_bin_const_t *kid_context,
141 oscore_partial_iv_t send_partial_iv);
142
161 coap_pdu_t *pdu,
162 coap_bin_const_t *kid_context,
163 oscore_partial_iv_t send_partial_iv);
164
176 coap_pdu_t *pdu);
177
181#define COAP_OSCORE_DECRYPT_NO_REPLAY 0x01
182
196 coap_pdu_t *pdu,
197 uint32_t flags);
198
205
213 oscore_recipient_ctx_t *recipient_ctx);
214
222 oscore_recipient_ctx_t *recipient_ctx);
223
232
239
249
258
268 coap_oscore_conf_t *oscore_conf);
281 coap_oscore_conf_t *oscore_conf);
282
297 coap_bin_const_t *recipient_id);
298
309
320
355 const coap_address_t *local_if,
356 const coap_address_t *server,
357 coap_proto_t proto,
358 coap_oscore_conf_t *oscore_conf,
359 void *app_data,
361 coap_str_const_t *ws_host);
362
373
409 const coap_address_t *local_if,
410 const coap_address_t *server,
411 coap_proto_t proto,
412 coap_dtls_pki_t *pki_data,
413 coap_oscore_conf_t *oscore_conf,
414 void *app_data,
416 coap_str_const_t *ws_host);
417
453 const coap_address_t *local_if,
454 const coap_address_t *server,
455 coap_proto_t proto,
456 coap_dtls_cpsk_t *psk_data,
457 coap_oscore_conf_t *oscore_conf,
458 void *app_data,
460 coap_str_const_t *ws_host);
461
475 coap_bin_const_t *recipient_id);
476
491 const coap_bin_const_t *recipient_id,
492 uint64_t last_seq, uint64_t seq_window);
493
495
496#ifdef __cplusplus
497}
498#endif
499
500#endif /* COAP_OSCORE_INTERNAL_H */
#define COAP_API
cose_hkdf_alg_t
cose_curve_t
Definition oscore_cose.h:62
cose_alg_t
void coap_oscore_association_set_recipient_ctx(oscore_association_t *association, oscore_recipient_ctx_t *recipient_ctx)
Set the recipient context of an association.
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 ...
coap_session_t * coap_new_client_session_oscore3_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, void *app_data, coap_app_data_free_callback_t callback, coap_str_const_t *ws_host)
Creates a new client session to the designated server, protecting the data using OSCORE,...
oscore_ctx_t * coap_init_oscore_context_from_conf(coap_oscore_conf_t *oscore_conf)
Initializes an OSCORE context from the given configuration.
void coap_oscore_session_set_recipient_ctx(coap_session_t *session, oscore_recipient_ctx_t *recipient_ctx)
Attach the OSCORE recipient context information to the session.
int coap_delete_oscore_snd_conf(coap_oscore_snd_conf_t *oscore_snd_conf)
Release all the information associated with the OSCORE complex Sender configuration.
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.
coap_session_t * coap_new_client_session_oscore_psk3_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, void *app_data, coap_app_data_free_callback_t callback, coap_str_const_t *ws_host)
Creates a new client session to the designated server, with PSK credentials protecting the data using...
struct coap_pdu_t * coap_oscore_decrypt_pdu_ext(coap_session_t *session, coap_pdu_t *pdu, uint32_t flags)
As coap_oscore_decrypt_pdu(), with flags (COAP_OSCORE_DECRYPT_*).
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.
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.
int coap_oscore_recipient_set_latest_seq_lkd(coap_oscore_conf_t *oscore_conf, const coap_bin_const_t *recipient_id, uint64_t last_seq, uint64_t seq_window)
Set the latest sequence number and sliding window for the specified recipient id in the compiled conf...
int coap_rebuild_pdu_for_proxy(coap_pdu_t *pdu)
Convert PDU to use Proxy-Scheme option if Proxy-Uri option is present.
void coap_delete_oscore_associations(coap_session_t *session)
Cleanup all allocated OSCORE association information.
int coap_oscore_initiate(coap_session_t *session, coap_oscore_conf_t *oscore_conf)
Initiate an OSCORE session.
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).
oscore_partial_iv_t
void coap_delete_all_oscore(coap_context_t *context)
Cleanup all allocated OSCORE information.
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.
int coap_delete_oscore_rcp_conf(coap_oscore_rcp_conf_t *oscore_rcp_conf)
Release all the information associated with the OSCORE complex Recipient configuration.
int coap_oscore_is_attached(coap_context_t *c_context, oscore_ctx_t *oscore_ctx)
Verify if the OSCORE context is attached to the c_context .
coap_session_t * coap_new_client_session_oscore_pki3_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, void *app_data, coap_app_data_free_callback_t callback, coap_str_const_t *ws_host)
Creates a new client session to the designated server, with PKI credentials protecting the data using...
size_t coap_oscore_overhead(coap_session_t *session, coap_pdu_t *pdu)
Determine the additional data size requirements for adding in OSCORE.
@ OSCORE_SEND_PARTIAL_IV
Send partial IV with encrypted PDU.
@ OSCORE_SEND_NO_IV
Do not send partial IV unless added by a response.
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_proto_t
CoAP protocol types Note: coap_layers_coap[] needs updating if extended.
Definition coap_pdu.h:245
void(* coap_app_data_free_callback_t)(void *data)
Callback to free off the app data when the entry is being deleted / freed off.
Multi-purpose address abstraction.
CoAP binary data definition with const data.
Definition coap_str.h:65
The CoAP stack's global state is stored in a coap_context_t object.
Holds credential definitions.
Holds private key definitions.
The structure used for defining the Client PSK setup data to be used.
Definition coap_dtls.h:418
The structure used for defining the PKI setup data to be used.
Definition coap_dtls.h:317
The structure used to hold the OSCORE configuration information.
void * save_seq_num_func_param
Passed to save_seq_num_func().
uint32_t rfc8613_b_2
1 if rfc8613 B.2 protocol else 0
cose_hkdf_alg_t hkdf_alg
Set to one of COSE_HKDF_ALG_*.
uint32_t break_sender_key
1 if sender key to be broken, else 0
coap_oscore_snd_conf_t * sender
The sender - i.e.
coap_oscore_rcp_conf_t * recipient_chain
The recipients as a chain.
uint32_t ssn_freq
Sender Seq Num update frequency.
coap_oscore_save_seq_num_t save_seq_num_func
Called every seq num change.
uint32_t rfc8613_b_1_2
1 if rfc8613 B.1.2 enabled else 0
uint64_t start_seq_num
Used for ssn_freq updating.
uint32_t break_recipient_key
1 if recipient key to be broken, else 0
coap_bin_const_t * master_secret
Common Master Secret.
cose_alg_t aead_alg
Set to one of COSE_ALGORITHM_AES*.
coap_bin_const_t * master_salt
Common Master Salt.
uint32_t replay_window
Replay window size Use COAP_OSCORE_DEFAULT_REPLAY_WINDOW.
coap_bin_const_t * id_context
Common ID context.
The structure used to hold the OSCORE Recipient configuration.
int silent_server
1 if server is likely to be silent else 0
coap_bin_const_t * recipient_id
Recipient ID (i.e.
uint64_t last_seq
Highest sequence number used for this recipient.
uint8_t window_initialized
Contains if the sliding window is initialized 1 if initialized, 0 otherwise.
struct coap_oscore_rcp_conf_t * next_recipient
Used to maintain the chain.
uint64_t sliding_window
bitfield sequence counter window
The structure used to hold the OSCORE Sender configuration information.
coap_bin_const_t * sender_id
Sender ID (i.e.
structure for CoAP PDUs
coap_session_t * session
Session responsible for PDU or NULL.
Abstraction of virtual session that can be attached to coap_context_t (client) or coap_endpoint_t (se...
CoAP string data definition with const data.
Definition coap_str.h:47