Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / transport / SecureMessageCodec.h
1 /*
2  *
3  *    Copyright (c) 2021 Project CHIP Authors
4  *    All rights reserved.
5  *
6  *    Licensed under the Apache License, Version 2.0 (the "License");
7  *    you may not use this file except in compliance with the License.
8  *    You may obtain a copy of the License at
9  *
10  *        http://www.apache.org/licenses/LICENSE-2.0
11  *
12  *    Unless required by applicable law or agreed to in writing, software
13  *    distributed under the License is distributed on an "AS IS" BASIS,
14  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *    See the License for the specific language governing permissions and
16  *    limitations under the License.
17  */
18
19 /**
20  *    @file
21  *      This file defines functions for encoding and decoding CHIP messages.
22  *      The encoded messages contain CHIP packet header, encrypted payload
23  *      header, encrypted payload and message authentication code, as per
24  *      CHIP specifications.
25  *
26  */
27
28 #pragma once
29
30 #include <transport/PeerConnectionState.h>
31
32 namespace chip {
33
34 namespace SecureMessageCodec {
35
36 /**
37  * @brief
38  *  Attach payload header to the message and encrypt the message buffer using
39  *  key from the connection state.
40  *
41  * @param localNodeId   Node Id of local node
42  * @param state         The connection state with peer node
43  * @param payloadHeader Reference to the payload header that should be inserted in
44  *                      the message
45  * @param packetHeader  Reference to the packet header that contains unencrypted
46  *                      portion of the message header
47  * @param msgBuf        The message buffer that contains the unencrypted message. If
48  *                      the operation is successuful, this buffer will contain the
49  *                      encrypted message.
50  * @ return CHIP_ERROR  The result of the encode operation
51  */
52 CHIP_ERROR Encode(NodeId localNodeId, Transport::PeerConnectionState * state, PayloadHeader & payloadHeader,
53                   PacketHeader & packetHeader, System::PacketBufferHandle & msgBuf);
54
55 /**
56  * @brief
57  *  Decrypt the message, perform message integrity check, and decode the payload header.
58  *
59  * @param state         The connection state with peer node
60  * @param payloadHeader Reference to the payload header that should be inserted in
61  *                      the message
62  * @param packetHeader  Reference to the packet header that contains unencrypted
63  *                      portion of the message header
64  * @param msgBuf        The message buffer that contains the encrypted message. If
65  *                      the operation is successuful, this buffer will contain the
66  *                      unencrypted message.
67  * @ return CHIP_ERROR  The result of the decode operation
68  */
69 CHIP_ERROR Decode(Transport::PeerConnectionState * state, PayloadHeader & payloadHeader, const PacketHeader & packetHeader,
70                   System::PacketBufferHandle & msgBuf);
71 } // namespace SecureMessageCodec
72
73 } // namespace chip