1 /*
2  * Copyright (c) 2017 Intel Corporation.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 /**
8  * @file
9  * @brief 802.15.4 6LoWPAN authentication and encryption
10  *
11  * This is not to be included by the application.
12  */
13 
14 #ifdef CONFIG_NET_L2_IEEE802154_SECURITY
15 
16 #include <zephyr/net/ieee802154.h>
17 
18 int ieee802154_security_setup_session(struct ieee802154_security_ctx *sec_ctx, uint8_t level,
19 				      uint8_t key_mode, uint8_t *key, uint8_t key_len);
20 
21 void ieee802154_security_teardown_session(struct ieee802154_security_ctx *sec_ctx);
22 
23 /**
24  * @brief Decrypt an authenticated payload.
25  *
26  * @param sec_ctx Pointer to an IEEE 802.15.4 security context.
27  * @param frame Pointer to the frame data in original (little endian) byte order.
28  * @param ll_hdr_len Length of the MHR.
29  * @param payload_len Length of the MAC payload.
30  * @param authtag_len Length of the authentication tag.
31  * @param src_ext_addr Pointer to the extended source address of the frame (in little endian byte
32  *                     order).
33  * @param frame_counter Frame counter in CPU byte order.
34  */
35 bool ieee802154_decrypt_auth(struct ieee802154_security_ctx *sec_ctx, uint8_t *frame,
36 			     uint8_t ll_hdr_len, uint8_t payload_len, uint8_t authtag_len,
37 			     uint8_t *src_ext_addr, uint32_t frame_counter);
38 
39 /**
40  * @brief Encrypt an authenticated payload.
41  *
42  * @param sec_ctx Pointer to an IEEE 802.15.4 security context.
43  * @param frame Pointer to the frame data in original (little endian) byte order.
44  * @param ll_hdr_len Length of the MHR.
45  * @param payload_len Length of the MAC payload.
46  * @param authtag_len Length of the authentication tag.
47  * @param src_ext_addr Pointer to the extended source address of the frame (in little endian byte
48  *                     order).
49  */
50 bool ieee802154_encrypt_auth(struct ieee802154_security_ctx *sec_ctx, uint8_t *frame,
51 			     uint8_t ll_hdr_len, uint8_t payload_len,
52 			     uint8_t authtag_len, uint8_t *src_ext_addr);
53 
54 int ieee802154_security_init(struct ieee802154_security_ctx *sec_ctx);
55 
56 #else
57 
58 #define ieee802154_decrypt_auth(...)  true
59 #define ieee802154_encrypt_auth(...)  true
60 #define ieee802154_security_init(...) 0
61 
62 #endif /* CONFIG_NET_L2_IEEE802154_SECURITY */
63