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 Description: LoRa MAC layer implementation 00009 License: Revised BSD License, see LICENSE.TXT file include in the project 00010 Maintainer: Miguel Luis and Gregory Cristian 00011 */ 00012 #ifndef __LORAMAC_CRYPTO_H__ 00013 #define __LORAMAC_CRYPTO_H__ 00014 00015 /*! 00016 * Copies size elements of src array to dst array 00017 * 00018 * \remark STM32 Standard memcpy function only works on pointers that are aligned 00019 * 00020 * \param [IN] src Source array 00021 * \param [OUT] dst Destination array 00022 * \param [IN] size Number of bytes to be copied 00023 */ 00024 #define LoRaMacMemCpy( src, dst, size ) memcpy1( dst, src, size ) 00025 00026 /*! 00027 * Computes the LoRaMAC frame MIC field 00028 * 00029 * \param [IN] buffer Data buffer 00030 * \param [IN] size Data buffer size 00031 * \param [IN] key AES key to be used 00032 * \param [IN] address Frame address 00033 * \param [IN] dir Frame direction [0: uplink, 1: downlink] 00034 * \param [IN] sequenceCounter Frame sequence counter 00035 * \param [OUT] mic Computed MIC field 00036 */ 00037 void LoRaMacComputeMic( const uint8_t *buffer, uint16_t size, const uint8_t *key, uint32_t address, uint8_t dir, uint32_t sequenceCounter, uint32_t *mic ); 00038 00039 /*! 00040 * Computes the LoRaMAC payload encryption 00041 * 00042 * \param [IN] buffer Data buffer 00043 * \param [IN] size Data buffer size 00044 * \param [IN] key AES key to be used 00045 * \param [IN] address Frame address 00046 * \param [IN] dir Frame direction [0: uplink, 1: downlink] 00047 * \param [IN] sequenceCounter Frame sequence counter 00048 * \param [OUT] encBuffer Encrypted buffer 00049 */ 00050 void LoRaMacPayloadEncrypt( const uint8_t *buffer, uint16_t size, const uint8_t *key, uint32_t address, uint8_t dir, uint32_t sequenceCounter, uint8_t *encBuffer ); 00051 00052 /*! 00053 * Computes the LoRaMAC payload decryption 00054 * 00055 * \param [IN] buffer Data buffer 00056 * \param [IN] size Data buffer size 00057 * \param [IN] key AES key to be used 00058 * \param [IN] address Frame address 00059 * \param [IN] dir Frame direction [0: uplink, 1: downlink] 00060 * \param [IN] sequenceCounter Frame sequence counter 00061 * \param [OUT] decBuffer Decrypted buffer 00062 */ 00063 void LoRaMacPayloadDecrypt( const uint8_t *buffer, uint16_t size, const uint8_t *key, uint32_t address, uint8_t dir, uint32_t sequenceCounter, uint8_t *decBuffer ); 00064 00065 /*! 00066 * Computes the LoRaMAC Join Request frame MIC field 00067 * 00068 * \param [IN] buffer Data buffer 00069 * \param [IN] size Data buffer size 00070 * \param [IN] key AES key to be used 00071 * \param [OUT] mic Computed MIC field 00072 */ 00073 void LoRaMacJoinComputeMic( const uint8_t *buffer, uint16_t size, const uint8_t *key, uint32_t *mic ); 00074 00075 /*! 00076 * Computes the LoRaMAC join frame decryption 00077 * 00078 * \param [IN] buffer Data buffer 00079 * \param [IN] size Data buffer size 00080 * \param [IN] key AES key to be used 00081 * \param [OUT] decBuffer Decrypted buffer 00082 */ 00083 void LoRaMacJoinDecrypt( const uint8_t *buffer, uint16_t size, const uint8_t *key, uint8_t *decBuffer ); 00084 00085 /*! 00086 * Computes the LoRaMAC join frame decryption 00087 * 00088 * \param [IN] key AES key to be used 00089 * \param [IN] appNonce Application nonce 00090 * \param [IN] devNonce Device nonce 00091 * \param [OUT] nwkSKey Network session key 00092 * \param [OUT] appSKey Application session key 00093 */ 00094 void LoRaMacJoinComputeSKeys( const uint8_t *key, const uint8_t *appNonce, uint16_t devNonce, uint8_t *nwkSKey, uint8_t *appSKey ); 00095 00096 #endif // __LORAMAC_CRYPTO_H__
Generated on Wed Jul 13 2022 23:48:00 by
