Loading...
Searching...
No Matches
coap_oscore_internal.h
Go to the documentation of this file.
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* coap_oscore_internal.h - Object Security for Constrained RESTful Environments
* (OSCORE) support for libcoap
*
* Copyright (C) 2019-2023 Olaf Bergmann <bergmann@tzi.org>
* Copyright (C) 2021-2023 Jon Shallow <supjps-libcoap:jpshallow.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*
* This file is part of the CoAP library libcoap. Please see README for terms
* of use.
*/
#ifndef COAP_OSCORE_INTERNAL_H_
#define COAP_OSCORE_INTERNAL_H_
#include "oscore/oscore_context.h"
struct coap_oscore_conf_t {
coap_bin_const_t *master_secret;
coap_bin_const_t *master_salt;
coap_bin_const_t *sender_id;
coap_bin_const_t *id_context;
coap_bin_const_t **recipient_id;
uint32_t recipient_id_count;
uint32_t replay_window;
uint32_t ssn_freq;
cose_alg_t aead_alg;
cose_hkdf_alg_t hkdf_alg;
uint32_t rfc8613_b_1_2;
uint32_t rfc8613_b_2;
/* General Testing */
uint32_t break_sender_key;
uint32_t break_recipient_key;
/* SSN handling (not in oscore_config[]) */
coap_oscore_save_seq_num_t save_seq_num_func;
void *save_seq_num_func_param;
uint64_t start_seq_num;
};
typedef enum oscore_partial_iv_t {
OSCORE_SEND_NO_IV,
OSCORE_SEND_PARTIAL_IV
} oscore_partial_iv_t;
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);
struct coap_pdu_t *coap_oscore_decrypt_pdu(coap_session_t *session,
coap_pdu_t *pdu);
void coap_delete_all_oscore(coap_context_t *context);
void coap_delete_oscore_associations(coap_session_t *session);
size_t coap_oscore_overhead(coap_session_t *session, coap_pdu_t *pdu);
int coap_rebuild_pdu_for_proxy(coap_pdu_t *pdu);
int coap_oscore_initiate(coap_session_t *session,
coap_oscore_conf_t *oscore_conf);
#endif /* COAP_OSCORE_INTERNAL_H */
cose_hkdf_alg_t
cose_hkdf_alg_t
Definition oscore_cose.h:165
cose_alg_t
cose_alg_t
Definition oscore_cose.h:126
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.
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.
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.
coap_delete_oscore_associations
void coap_delete_oscore_associations(coap_session_t *session)
Cleanup all allocated OSCORE association information.
coap_oscore_initiate
int coap_oscore_initiate(coap_session_t *session, coap_oscore_conf_t *oscore_conf)
Initiate an OSCORE session.
oscore_partial_iv_t
oscore_partial_iv_t
Definition coap_oscore_internal.h:63
coap_delete_all_oscore
void coap_delete_all_oscore(coap_context_t *context)
Cleanup all allocated OSCORE information.
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.
OSCORE_SEND_PARTIAL_IV
@ OSCORE_SEND_PARTIAL_IV
Send partial IV with encrypted PDU.
Definition coap_oscore_internal.h:65
OSCORE_SEND_NO_IV
@ OSCORE_SEND_NO_IV
Do not send partial IV unless added by a response.
Definition coap_oscore_internal.h:64
coap_oscore_save_seq_num_t
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:137
oscore_context.h
An implementation of the Object Security for Constrained RESTful Enviornments (RFC 8613).
coap_bin_const_t
CoAP binary data definition with const data.
Definition coap_str.h:64
coap_context_t
The CoAP stack's global state is stored in a coap_context_t object.
Definition coap_net_internal.h:49
coap_oscore_conf_t
The structure used to hold the OSCORE configuration information.
Definition coap_oscore_internal.h:36
coap_oscore_conf_t::save_seq_num_func_param
void * save_seq_num_func_param
Passed to save_seq_num_func()
Definition coap_oscore_internal.h:59
coap_oscore_conf_t::rfc8613_b_2
uint32_t rfc8613_b_2
1 if rfc8613 B.2 protocol else 0
Definition coap_oscore_internal.h:50
coap_oscore_conf_t::hkdf_alg
cose_hkdf_alg_t hkdf_alg
Set to one of COSE_HKDF_ALG_*.
Definition coap_oscore_internal.h:48
coap_oscore_conf_t::break_sender_key
uint32_t break_sender_key
1 if sender key to be broken, else 0
Definition coap_oscore_internal.h:53
coap_oscore_conf_t::ssn_freq
uint32_t ssn_freq
Sender Seq Num update frequency.
Definition coap_oscore_internal.h:46
coap_oscore_conf_t::save_seq_num_func
coap_oscore_save_seq_num_t save_seq_num_func
Called every seq num change.
Definition coap_oscore_internal.h:57
coap_oscore_conf_t::rfc8613_b_1_2
uint32_t rfc8613_b_1_2
1 if rfc8613 B.1.2 enabled else 0
Definition coap_oscore_internal.h:49
coap_oscore_conf_t::start_seq_num
uint64_t start_seq_num
Used for ssn_freq updating.
Definition coap_oscore_internal.h:60
coap_oscore_conf_t::sender_id
coap_bin_const_t * sender_id
Sender ID (i.e.
Definition coap_oscore_internal.h:39
coap_oscore_conf_t::recipient_id
coap_bin_const_t ** recipient_id
Recipient ID (i.e.
Definition coap_oscore_internal.h:41
coap_oscore_conf_t::break_recipient_key
uint32_t break_recipient_key
1 if recipient key to be broken, else 0
Definition coap_oscore_internal.h:54
coap_oscore_conf_t::master_secret
coap_bin_const_t * master_secret
Common Master Secret.
Definition coap_oscore_internal.h:37
coap_oscore_conf_t::aead_alg
cose_alg_t aead_alg
Set to one of COSE_ALGORITHM_AES*.
Definition coap_oscore_internal.h:47
coap_oscore_conf_t::master_salt
coap_bin_const_t * master_salt
Common Master Salt.
Definition coap_oscore_internal.h:38
coap_oscore_conf_t::replay_window
uint32_t replay_window
Replay window size Use COAP_OSCORE_DEFAULT_REPLAY_WINDOW.
Definition coap_oscore_internal.h:44
coap_oscore_conf_t::id_context
coap_bin_const_t * id_context
Common ID context.
Definition coap_oscore_internal.h:40
coap_oscore_conf_t::recipient_id_count
uint32_t recipient_id_count
Number of recipient_id entries.
Definition coap_oscore_internal.h:43
coap_pdu_t
structure for CoAP PDUs
Definition coap_pdu_internal.h:119
coap_pdu_t::session
coap_session_t * session
Session responsible for PDU or NULL.
Definition coap_pdu_internal.h:158
coap_session_t
Abstraction of virtual session that can be attached to coap_context_t (client) or coap_endpoint_t (se...
Definition coap_session_internal.h:68