Contiki-NG
Toggle main menu visibility
Loading...
Searching...
No Matches
edhoc-msg-handlers.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2024, RISE Research Institutes of Sweden AB
3
* Copyright (c) 2020, Industrial Systems Institute (ISI), Patras, Greece
4
* All rights reserved.
5
*
6
* Redistribution and use in source and binary forms, with or without
7
* modification, are permitted provided that the following conditions
8
* are met:
9
* 1. Redistributions of source code must retain the above copyright
10
* notice, this list of conditions and the following disclaimer.
11
* 2. Redistributions in binary form must reproduce the above copyright
12
* notice, this list of conditions and the following disclaimer in the
13
* documentation and/or other materials provided with the distribution.
14
* 3. Neither the name of the copyright holder nor the names of its contributors
15
* may be used to endorse or promote products derived from this software
16
* without specific prior written permission.
17
*
18
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
19
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28
* SUCH DAMAGE.
29
*
30
*/
31
32
/**
33
* \file
34
* Declarations for the EDHOC message handlers.
35
* \author
36
* Lidia Pocero <pocero@isi.gr>, Peter A Jonsson, Rikard Höglund, Marco Tiloca
37
* Christos Koulamas <cklm@isi.gr>, Niclas Finne <niclas.finne@ri.se>,
38
* Nicolas Tsiftes <nicolas.tsiftes@ri.se>
39
*/
40
41
/**
42
* \addtogroup edhoc
43
* @{
44
*/
45
46
#ifndef EDHOC_MSG_HANDLERS_H_
47
#define EDHOC_MSG_HANDLERS_H_
48
49
#include "
edhoc.h
"
50
51
/**
52
* \brief Try to deserialize data as an EDHOC error message
53
* \param message expected type of message
54
* \param data input CBOR data to parse
55
* \param data_size input size of CBOR data
56
* \return EDHOC_SUCCESS if data is not an EDHOC error message,
57
* error code otherwise.
58
*/
59
edhoc_error_t
edhoc_check_err_rx_msg
(uint8_t message,
const
uint8_t *data,
size_t
data_size);
60
61
/**
62
* \brief Handle the EDHOC Message 1 received
63
* \param ctx EDHOC Context struct
64
* \param payload A pointer to the buffer containing the EDHOC message received
65
* \param payload_size Size of the EDHOC message received
66
* \param auth_data A pointer to a buffer to copy the Application Data received in Message 1
67
* \retval negative number (EDHOC ERROR CODES) when an EDHOC ERROR is detected
68
* \retval ad_sz The length of the Application Data received in Message 1, when EDHOC success
69
*
70
* Used by Responder EDHOC role to process the Message 1 received
71
* - Decode the message 1
72
* - Verify that cipher suite
73
* - Pass Application data AD_1
74
* - If any verification step fails to return an EDHOC ERROR code and, if all the steps success
75
* - the length of the Application Data receive on the Message 1 is returned.
76
*/
77
int
edhoc_handler_msg_1
(edhoc_context_t *ctx, uint8_t *payload,
78
size_t
payload_size, uint8_t *auth_data);
79
80
/**
81
* \brief Handle the EDHOC Message 2 received
82
* \param msg2 A pointer to the buffer containing the received EDHOC message 2
83
* \param ctx EDHOC Context struct
84
* \param payload A pointer to the buffer containing the EDHOC message received
85
* \param payload_size Size of the EDHOC message received
86
* \retval negative error code when an EDHOC ERROR is detected
87
* \retval 1 when EDHOC decode and verify success
88
*
89
* Used by Initiator EDHOC role to process the Message 2 received
90
* - Decode the message 2
91
* - Verify the other peer through 5-tuple and/or connection identifier C_I
92
*
93
* If any verification step fails to return an EDHOC ERROR code and, if all the steps success return 1.
94
*/
95
int
edhoc_handler_msg_2
(edhoc_msg_2_t *msg2, edhoc_context_t *ctx,
96
uint8_t *payload,
size_t
payload_size);
97
98
/**
99
* \brief Handle the EDHOC Message 3 received
100
* \param msg3 A pointer to the buffer containing the received EDHOC message 3
101
* \param ctx EDHOC Context struct
102
* \param payload A pointer to the buffer containing the EDHOC message received
103
* \param payload_size Size of the EDHOC message received
104
* \retval negative number (EDHOC ERROR CODE) when an EDHOC ERROR is detected
105
* \retval 1 when EDHOC decode and verify success
106
*
107
* Used by Responder EDHOC role to process the Message 3 receive
108
* - Decode the message 3
109
* - Verify the other peer through 5-tuple and/or connection identifier C_R
110
*
111
* If any verification step fails to return an EDHOC ERROR code and,if all the steps success return 1.
112
*/
113
int
edhoc_handler_msg_3
(edhoc_msg_3_t *msg3, edhoc_context_t *ctx,
114
uint8_t *payload,
size_t
payload_size);
115
116
#endif
/* EDHOC_MSG_HANDLERS_H_ */
117
/** @} */
edhoc_error_t
edhoc_error_t
Unified error type for EDHOC operations.
Definition
edhoc-error.h:60
edhoc.h
An implementation of Ephemeral Diffie-Hellman Over COSE (EDHOC) (RFC9528).
edhoc_handler_msg_3
int edhoc_handler_msg_3(edhoc_msg_3_t *msg3, edhoc_context_t *ctx, uint8_t *payload, size_t payload_size)
Handle the EDHOC Message 3 received.
Definition
edhoc-msg-handlers.c:385
edhoc_handler_msg_1
int edhoc_handler_msg_1(edhoc_context_t *ctx, uint8_t *payload, size_t payload_size, uint8_t *auth_data)
Handle the EDHOC Message 1 received.
Definition
edhoc-msg-handlers.c:228
edhoc_handler_msg_2
int edhoc_handler_msg_2(edhoc_msg_2_t *msg2, edhoc_context_t *ctx, uint8_t *payload, size_t payload_size)
Handle the EDHOC Message 2 received.
Definition
edhoc-msg-handlers.c:311
edhoc_check_err_rx_msg
edhoc_error_t edhoc_check_err_rx_msg(uint8_t message, const uint8_t *data, size_t data_size)
Try to deserialize data as an EDHOC error message.
Definition
edhoc-msg-handlers.c:192
os
net
security
edhoc
edhoc-msg-handlers.h
Generated on
for Contiki-NG by
1.17.0