Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
LoRaMacCrypto.h
00001 /** 00002 / _____) _ | | 00003 ( (____ _____ ____ _| |_ _____ ____| |__ 00004 \____ \| ___ | (_ _) ___ |/ ___) _ \ 00005 _____) ) ____| | | || |_| ____( (___| | | | 00006 (______/|_____)_|_|_| \__)_____)\____)_| |_| 00007 (C)2013 Semtech 00008 ___ _____ _ ___ _ _____ ___ ___ ___ ___ 00009 / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| 00010 \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| 00011 |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| 00012 embedded.connectivity.solutions=============== 00013 00014 Description: LoRa MAC Crypto implementation 00015 00016 License: Revised BSD License, see LICENSE.TXT file include in the project 00017 00018 Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jaeckle ( STACKFORCE ) 00019 00020 00021 Copyright (c) 2017, Arm Limited and affiliates. 00022 00023 SPDX-License-Identifier: BSD-3-Clause 00024 */ 00025 00026 #ifndef MBED_LORAWAN_MAC_LORAMAC_CRYPTO_H__ 00027 #define MBED_LORAWAN_MAC_LORAMAC_CRYPTO_H__ 00028 00029 /** 00030 * Computes the LoRaMAC frame MIC field 00031 * 00032 * @param [in] buffer - Data buffer 00033 * @param [in] size - Data buffer size 00034 * @param [in] key - AES key to be used 00035 * @param [in] address - Frame address 00036 * @param [in] dir - Frame direction [0: uplink, 1: downlink] 00037 * @param [in] seq_counter - Frame sequence counter 00038 * @param [out] mic - Computed MIC field 00039 * 00040 * @return 0 if successful, or a cipher specific error code 00041 */ 00042 int compute_mic(const uint8_t *buffer, uint16_t size, const uint8_t *key, 00043 uint32_t address, uint8_t dir, uint32_t seq_counter, 00044 uint32_t *mic); 00045 00046 /** 00047 * Performs payload encryption 00048 * 00049 * @param [in] buffer - Data buffer 00050 * @param [in] size - Data buffer size 00051 * @param [in] key - AES key to be used 00052 * @param [in] address - Frame address 00053 * @param [in] dir - Frame direction [0: uplink, 1: downlink] 00054 * @param [in] seq_counter - Frame sequence counter 00055 * @param [out] enc_buffer - Encrypted buffer 00056 * 00057 * @return 0 if successful, or a cipher specific error code 00058 */ 00059 int encrypt_payload(const uint8_t *buffer, uint16_t size, const uint8_t *key, 00060 uint32_t address, uint8_t dir, uint32_t seq_counter, 00061 uint8_t *enc_buffer); 00062 00063 /** 00064 * Performs payload decryption 00065 * 00066 * @param [in] buffer - Data buffer 00067 * @param [in] size - Data buffer size 00068 * @param [in] key - AES key to be used 00069 * @param [in] address - Frame address 00070 * @param [in] dir - Frame direction [0: uplink, 1: downlink] 00071 * @param [in] seq_counter - Frame sequence counter 00072 * @param [out] dec_buffer - Decrypted buffer 00073 * 00074 * @return 0 if successful, or a cipher specific error code 00075 */ 00076 int decrypt_payload(const uint8_t *buffer, uint16_t size, const uint8_t *key, 00077 uint32_t address, uint8_t dir, uint32_t seq_counter, 00078 uint8_t *dec_buffer); 00079 00080 /** 00081 * Computes the LoRaMAC Join Request frame MIC field 00082 * 00083 * @param [in] buffer - Data buffer 00084 * @param [in] size - Data buffer size 00085 * @param [in] key - AES key to be used 00086 * @param [out] mic - Computed MIC field 00087 * 00088 * @return 0 if successful, or a cipher specific error code 00089 * 00090 */ 00091 int compute_join_frame_mic(const uint8_t *buffer, uint16_t size, 00092 const uint8_t *key, uint32_t *mic); 00093 00094 /** 00095 * Computes the LoRaMAC join frame decryption 00096 * 00097 * @param [in] buffer - Data buffer 00098 * @param [in] size - Data buffer size 00099 * @param [in] key - AES key to be used 00100 * @param [out] dec_buffer - Decrypted buffer 00101 * 00102 * @return 0 if successful, or a cipher specific error code 00103 */ 00104 int decrypt_join_frame(const uint8_t *buffer, uint16_t size, 00105 const uint8_t *key, uint8_t *dec_buffer); 00106 00107 /** 00108 * Computes the LoRaMAC join frame decryption 00109 * 00110 * @param [in] key - AES key to be used 00111 * @param [in] app_nonce - Application nonce 00112 * @param [in] dev_nonce - Device nonce 00113 * @param [out] nwk_skey - Network session key 00114 * @param [out] app_skey - Application session key 00115 * 00116 * @return 0 if successful, or a cipher specific error code 00117 */ 00118 int compute_skeys_for_join_frame(const uint8_t *key, const uint8_t *app_nonce, 00119 uint16_t dev_nonce, uint8_t *nwk_skey, 00120 uint8_t *app_skey ); 00121 00122 #endif // MBED_LORAWAN_MAC_LORAMAC_CRYPTO_H__
Generated on Tue Jul 12 2022 14:23:51 by
