Semtech stack for ELMO - ver. 4.1.0.

Dependencies:   SX1272lib mbed

Fork of LoRaWAN_Semtech_stack_v4.1 by Michal Leksinski

Committer:
mleksio
Date:
Wed Dec 16 14:25:16 2015 +0000
Revision:
0:c58229885f95
Child:
1:2be292bd43f9
first commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mleksio 0:c58229885f95 1 /*
mleksio 0:c58229885f95 2 / _____) _ | |
mleksio 0:c58229885f95 3 ( (____ _____ ____ _| |_ _____ ____| |__
mleksio 0:c58229885f95 4 \____ \| ___ | (_ _) ___ |/ ___) _ \
mleksio 0:c58229885f95 5 _____) ) ____| | | || |_| ____( (___| | | |
mleksio 0:c58229885f95 6 (______/|_____)_|_|_| \__)_____)\____)_| |_|
mleksio 0:c58229885f95 7 (C)2013 Semtech
mleksio 0:c58229885f95 8 Description: LoRa MAC layer implementation
mleksio 0:c58229885f95 9 License: Revised BSD License, see LICENSE.TXT file include in the project
mleksio 0:c58229885f95 10 Maintainer: Miguel Luis and Gregory Cristian
mleksio 0:c58229885f95 11 */
mleksio 0:c58229885f95 12 #ifndef __LORAMAC_CRYPTO_H__
mleksio 0:c58229885f95 13 #define __LORAMAC_CRYPTO_H__
mleksio 0:c58229885f95 14
mleksio 0:c58229885f95 15 /*!
mleksio 0:c58229885f95 16 * Copies size elements of src array to dst array
mleksio 0:c58229885f95 17 *
mleksio 0:c58229885f95 18 * \remark STM32 Standard memcpy function only works on pointers that are aligned
mleksio 0:c58229885f95 19 *
mleksio 0:c58229885f95 20 * \param [IN] src Source array
mleksio 0:c58229885f95 21 * \param [OUT] dst Destination array
mleksio 0:c58229885f95 22 * \param [IN] size Number of bytes to be copied
mleksio 0:c58229885f95 23 */
mleksio 0:c58229885f95 24 #define LoRaMacMemCpy( src, dst, size ) memcpy1( dst, src, size )
mleksio 0:c58229885f95 25
mleksio 0:c58229885f95 26 /*!
mleksio 0:c58229885f95 27 * Computes the LoRaMAC frame MIC field
mleksio 0:c58229885f95 28 *
mleksio 0:c58229885f95 29 * \param [IN] buffer Data buffer
mleksio 0:c58229885f95 30 * \param [IN] size Data buffer size
mleksio 0:c58229885f95 31 * \param [IN] key AES key to be used
mleksio 0:c58229885f95 32 * \param [IN] address Frame address
mleksio 0:c58229885f95 33 * \param [IN] dir Frame direction [0: uplink, 1: downlink]
mleksio 0:c58229885f95 34 * \param [IN] sequenceCounter Frame sequence counter
mleksio 0:c58229885f95 35 * \param [OUT] mic Computed MIC field
mleksio 0:c58229885f95 36 */
mleksio 0:c58229885f95 37 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 );
mleksio 0:c58229885f95 38
mleksio 0:c58229885f95 39 /*!
mleksio 0:c58229885f95 40 * Computes the LoRaMAC payload encryption
mleksio 0:c58229885f95 41 *
mleksio 0:c58229885f95 42 * \param [IN] buffer Data buffer
mleksio 0:c58229885f95 43 * \param [IN] size Data buffer size
mleksio 0:c58229885f95 44 * \param [IN] key AES key to be used
mleksio 0:c58229885f95 45 * \param [IN] address Frame address
mleksio 0:c58229885f95 46 * \param [IN] dir Frame direction [0: uplink, 1: downlink]
mleksio 0:c58229885f95 47 * \param [IN] sequenceCounter Frame sequence counter
mleksio 0:c58229885f95 48 * \param [OUT] encBuffer Encrypted buffer
mleksio 0:c58229885f95 49 */
mleksio 0:c58229885f95 50 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 );
mleksio 0:c58229885f95 51
mleksio 0:c58229885f95 52 /*!
mleksio 0:c58229885f95 53 * Computes the LoRaMAC payload decryption
mleksio 0:c58229885f95 54 *
mleksio 0:c58229885f95 55 * \param [IN] buffer Data buffer
mleksio 0:c58229885f95 56 * \param [IN] size Data buffer size
mleksio 0:c58229885f95 57 * \param [IN] key AES key to be used
mleksio 0:c58229885f95 58 * \param [IN] address Frame address
mleksio 0:c58229885f95 59 * \param [IN] dir Frame direction [0: uplink, 1: downlink]
mleksio 0:c58229885f95 60 * \param [IN] sequenceCounter Frame sequence counter
mleksio 0:c58229885f95 61 * \param [OUT] decBuffer Decrypted buffer
mleksio 0:c58229885f95 62 */
mleksio 0:c58229885f95 63 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 );
mleksio 0:c58229885f95 64
mleksio 0:c58229885f95 65 /*!
mleksio 0:c58229885f95 66 * Computes the LoRaMAC Join Request frame MIC field
mleksio 0:c58229885f95 67 *
mleksio 0:c58229885f95 68 * \param [IN] buffer Data buffer
mleksio 0:c58229885f95 69 * \param [IN] size Data buffer size
mleksio 0:c58229885f95 70 * \param [IN] key AES key to be used
mleksio 0:c58229885f95 71 * \param [OUT] mic Computed MIC field
mleksio 0:c58229885f95 72 */
mleksio 0:c58229885f95 73 void LoRaMacJoinComputeMic( const uint8_t *buffer, uint16_t size, const uint8_t *key, uint32_t *mic );
mleksio 0:c58229885f95 74
mleksio 0:c58229885f95 75 /*!
mleksio 0:c58229885f95 76 * Computes the LoRaMAC join frame decryption
mleksio 0:c58229885f95 77 *
mleksio 0:c58229885f95 78 * \param [IN] buffer Data buffer
mleksio 0:c58229885f95 79 * \param [IN] size Data buffer size
mleksio 0:c58229885f95 80 * \param [IN] key AES key to be used
mleksio 0:c58229885f95 81 * \param [OUT] decBuffer Decrypted buffer
mleksio 0:c58229885f95 82 */
mleksio 0:c58229885f95 83 void LoRaMacJoinDecrypt( const uint8_t *buffer, uint16_t size, const uint8_t *key, uint8_t *decBuffer );
mleksio 0:c58229885f95 84
mleksio 0:c58229885f95 85 /*!
mleksio 0:c58229885f95 86 * Computes the LoRaMAC join frame decryption
mleksio 0:c58229885f95 87 *
mleksio 0:c58229885f95 88 * \param [IN] key AES key to be used
mleksio 0:c58229885f95 89 * \param [IN] appNonce Application nonce
mleksio 0:c58229885f95 90 * \param [IN] devNonce Device nonce
mleksio 0:c58229885f95 91 * \param [OUT] nwkSKey Network session key
mleksio 0:c58229885f95 92 * \param [OUT] appSKey Application session key
mleksio 0:c58229885f95 93 */
mleksio 0:c58229885f95 94 void LoRaMacJoinComputeSKeys( const uint8_t *key, const uint8_t *appNonce, uint16_t devNonce, uint8_t *nwkSKey, uint8_t *appSKey );
mleksio 0:c58229885f95 95
mleksio 0:c58229885f95 96 #endif // __LORAMAC_CRYPTO_H__