libcoap 4.3.5-develop-19cef11
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-2024 Olaf Bergmann <bergmann@tzi.org>
8 * Copyright (C) 2021-2024 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
21#ifndef COAP_OSCORE_INTERNAL_H_
22#define COAP_OSCORE_INTERNAL_H_
23
25
44 uint32_t replay_window;
46 uint32_t ssn_freq;
49 uint32_t rfc8613_b_1_2;
50 uint32_t rfc8613_b_2;
52 /* General Testing */
56 /* SSN handling (not in oscore_config[]) */
60 uint64_t start_seq_num;
61};
62
63typedef enum oscore_partial_iv_t {
67
84 coap_pdu_t *pdu,
85 coap_bin_const_t *kid_context,
86 oscore_partial_iv_t send_partial_iv);
87
106 coap_pdu_t *pdu,
107 coap_bin_const_t *kid_context,
108 oscore_partial_iv_t send_partial_iv);
109
121 coap_pdu_t *pdu);
122
129
136
146
155
165 coap_oscore_conf_t *oscore_conf);
178 coap_oscore_conf_t *oscore_conf);
179
194 coap_bin_const_t *recipient_id);
195
218 const coap_address_t *local_if,
219 const coap_address_t *server,
220 coap_proto_t proto,
221 coap_oscore_conf_t *oscore_conf);
222
245 const coap_address_t *local_if,
246 const coap_address_t *server,
247 coap_proto_t proto,
248 coap_dtls_pki_t *pki_data,
249 coap_oscore_conf_t *oscore_conf);
250
273 const coap_address_t *local_if,
274 const coap_address_t *server,
275 coap_proto_t proto,
276 coap_dtls_cpsk_t *psk_data,
277 coap_oscore_conf_t *oscore_conf);
278
292 coap_bin_const_t *recipient_id);
293
296#endif /* COAP_OSCORE_INTERNAL_H */
#define COAP_API
cose_hkdf_alg_t
Definition: oscore_cose.h:165
cose_alg_t
Definition: oscore_cose.h:126
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 ...
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_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_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.
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_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.
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 ...
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.
Definition: coap_oscore.h:130
coap_proto_t
CoAP protocol types.
Definition: coap_pdu.h:312
An implementation of the Object Security for Constrained RESTful Enviornments (RFC 8613).
Multi-purpose address abstraction.
Definition: coap_address.h:148
CoAP binary data definition with const data.
Definition: coap_str.h:64
The CoAP stack's global state is stored in a coap_context_t object.
The structure used for defining the Client PSK setup data to be used.
Definition: coap_dtls.h:410
The structure used for defining the PKI setup data to be used.
Definition: coap_dtls.h:312
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
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.
coap_bin_const_t * sender_id
Sender ID (i.e.
coap_bin_const_t ** recipient_id
Recipient ID (i.e.
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.
uint32_t recipient_id_count
Number of recipient_id entries.
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...