Semtech stack for ELMO - ver. 4.1.0.
Fork of LoRaWAN_Semtech_stack_v4.1 by
mac/LoRaMacCrypto.h@5:cbb921e2a03b, 2016-04-22 (annotated)
- Committer:
- mleksio
- Date:
- Fri Apr 22 07:37:04 2016 +0000
- Revision:
- 5:cbb921e2a03b
- Parent:
- 1:2be292bd43f9
Removed unused files.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mleksio | 1:2be292bd43f9 | 1 | /*! |
mleksio | 1:2be292bd43f9 | 2 | * \file LoRaMacCrypto.h |
mleksio | 1:2be292bd43f9 | 3 | * |
mleksio | 1:2be292bd43f9 | 4 | * \brief LoRa MAC layer cryptography implementation |
mleksio | 1:2be292bd43f9 | 5 | * |
mleksio | 1:2be292bd43f9 | 6 | * \copyright Revised BSD License, see section \ref LICENSE. |
mleksio | 1:2be292bd43f9 | 7 | * |
mleksio | 1:2be292bd43f9 | 8 | * \code |
mleksio | 1:2be292bd43f9 | 9 | * ______ _ |
mleksio | 1:2be292bd43f9 | 10 | * / _____) _ | | |
mleksio | 1:2be292bd43f9 | 11 | * ( (____ _____ ____ _| |_ _____ ____| |__ |
mleksio | 1:2be292bd43f9 | 12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \ |
mleksio | 1:2be292bd43f9 | 13 | * _____) ) ____| | | || |_| ____( (___| | | | |
mleksio | 1:2be292bd43f9 | 14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_| |
mleksio | 1:2be292bd43f9 | 15 | * (C)2013 Semtech |
mleksio | 1:2be292bd43f9 | 16 | * |
mleksio | 1:2be292bd43f9 | 17 | * ___ _____ _ ___ _ _____ ___ ___ ___ ___ |
mleksio | 1:2be292bd43f9 | 18 | * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| |
mleksio | 1:2be292bd43f9 | 19 | * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| |
mleksio | 1:2be292bd43f9 | 20 | * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| |
mleksio | 1:2be292bd43f9 | 21 | * embedded.connectivity.solutions=============== |
mleksio | 1:2be292bd43f9 | 22 | * |
mleksio | 1:2be292bd43f9 | 23 | * \endcode |
mleksio | 1:2be292bd43f9 | 24 | * |
mleksio | 1:2be292bd43f9 | 25 | * \author Miguel Luis ( Semtech ) |
mleksio | 1:2be292bd43f9 | 26 | * |
mleksio | 1:2be292bd43f9 | 27 | * \author Gregory Cristian ( Semtech ) |
mleksio | 1:2be292bd43f9 | 28 | * |
mleksio | 1:2be292bd43f9 | 29 | * \author Daniel Jäckle ( STACKFORCE ) |
mleksio | 1:2be292bd43f9 | 30 | * |
mleksio | 1:2be292bd43f9 | 31 | * \defgroup LORAMAC_CRYPTO LoRa MAC layer cryptography implementation |
mleksio | 1:2be292bd43f9 | 32 | * This module covers the implementation of cryptographic functions |
mleksio | 1:2be292bd43f9 | 33 | * of the LoRaMAC layer. |
mleksio | 1:2be292bd43f9 | 34 | * \{ |
mleksio | 1:2be292bd43f9 | 35 | */ |
mleksio | 0:c58229885f95 | 36 | #ifndef __LORAMAC_CRYPTO_H__ |
mleksio | 0:c58229885f95 | 37 | #define __LORAMAC_CRYPTO_H__ |
mleksio | 0:c58229885f95 | 38 | |
mleksio | 0:c58229885f95 | 39 | /*! |
mleksio | 1:2be292bd43f9 | 40 | * Computes the LoRaMAC frame MIC field |
mleksio | 0:c58229885f95 | 41 | * |
mleksio | 1:2be292bd43f9 | 42 | * \param [IN] buffer - Data buffer |
mleksio | 1:2be292bd43f9 | 43 | * \param [IN] size - Data buffer size |
mleksio | 1:2be292bd43f9 | 44 | * \param [IN] key - AES key to be used |
mleksio | 1:2be292bd43f9 | 45 | * \param [IN] address - Frame address |
mleksio | 1:2be292bd43f9 | 46 | * \param [IN] dir - Frame direction [0: uplink, 1: downlink] |
mleksio | 1:2be292bd43f9 | 47 | * \param [IN] sequenceCounter - Frame sequence counter |
mleksio | 1:2be292bd43f9 | 48 | * \param [OUT] mic - Computed MIC field |
mleksio | 0:c58229885f95 | 49 | */ |
mleksio | 0:c58229885f95 | 50 | 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 | 51 | |
mleksio | 0:c58229885f95 | 52 | /*! |
mleksio | 1:2be292bd43f9 | 53 | * Computes the LoRaMAC payload encryption |
mleksio | 0:c58229885f95 | 54 | * |
mleksio | 1:2be292bd43f9 | 55 | * \param [IN] buffer - Data buffer |
mleksio | 1:2be292bd43f9 | 56 | * \param [IN] size - Data buffer size |
mleksio | 1:2be292bd43f9 | 57 | * \param [IN] key - AES key to be used |
mleksio | 1:2be292bd43f9 | 58 | * \param [IN] address - Frame address |
mleksio | 1:2be292bd43f9 | 59 | * \param [IN] dir - Frame direction [0: uplink, 1: downlink] |
mleksio | 1:2be292bd43f9 | 60 | * \param [IN] sequenceCounter - Frame sequence counter |
mleksio | 1:2be292bd43f9 | 61 | * \param [OUT] encBuffer - Encrypted buffer |
mleksio | 0:c58229885f95 | 62 | */ |
mleksio | 0:c58229885f95 | 63 | 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 | 64 | |
mleksio | 0:c58229885f95 | 65 | /*! |
mleksio | 1:2be292bd43f9 | 66 | * Computes the LoRaMAC payload decryption |
mleksio | 0:c58229885f95 | 67 | * |
mleksio | 1:2be292bd43f9 | 68 | * \param [IN] buffer - Data buffer |
mleksio | 1:2be292bd43f9 | 69 | * \param [IN] size - Data buffer size |
mleksio | 1:2be292bd43f9 | 70 | * \param [IN] key - AES key to be used |
mleksio | 1:2be292bd43f9 | 71 | * \param [IN] address - Frame address |
mleksio | 1:2be292bd43f9 | 72 | * \param [IN] dir - Frame direction [0: uplink, 1: downlink] |
mleksio | 1:2be292bd43f9 | 73 | * \param [IN] sequenceCounter - Frame sequence counter |
mleksio | 1:2be292bd43f9 | 74 | * \param [OUT] decBuffer - Decrypted buffer |
mleksio | 0:c58229885f95 | 75 | */ |
mleksio | 0:c58229885f95 | 76 | 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 | 77 | |
mleksio | 0:c58229885f95 | 78 | /*! |
mleksio | 1:2be292bd43f9 | 79 | * Computes the LoRaMAC Join Request frame MIC field |
mleksio | 0:c58229885f95 | 80 | * |
mleksio | 1:2be292bd43f9 | 81 | * \param [IN] buffer - Data buffer |
mleksio | 1:2be292bd43f9 | 82 | * \param [IN] size - Data buffer size |
mleksio | 1:2be292bd43f9 | 83 | * \param [IN] key - AES key to be used |
mleksio | 1:2be292bd43f9 | 84 | * \param [OUT] mic - Computed MIC field |
mleksio | 0:c58229885f95 | 85 | */ |
mleksio | 0:c58229885f95 | 86 | void LoRaMacJoinComputeMic( const uint8_t *buffer, uint16_t size, const uint8_t *key, uint32_t *mic ); |
mleksio | 0:c58229885f95 | 87 | |
mleksio | 0:c58229885f95 | 88 | /*! |
mleksio | 1:2be292bd43f9 | 89 | * Computes the LoRaMAC join frame decryption |
mleksio | 0:c58229885f95 | 90 | * |
mleksio | 1:2be292bd43f9 | 91 | * \param [IN] buffer - Data buffer |
mleksio | 1:2be292bd43f9 | 92 | * \param [IN] size - Data buffer size |
mleksio | 1:2be292bd43f9 | 93 | * \param [IN] key - AES key to be used |
mleksio | 1:2be292bd43f9 | 94 | * \param [OUT] decBuffer - Decrypted buffer |
mleksio | 0:c58229885f95 | 95 | */ |
mleksio | 0:c58229885f95 | 96 | void LoRaMacJoinDecrypt( const uint8_t *buffer, uint16_t size, const uint8_t *key, uint8_t *decBuffer ); |
mleksio | 0:c58229885f95 | 97 | |
mleksio | 0:c58229885f95 | 98 | /*! |
mleksio | 1:2be292bd43f9 | 99 | * Computes the LoRaMAC join frame decryption |
mleksio | 0:c58229885f95 | 100 | * |
mleksio | 1:2be292bd43f9 | 101 | * \param [IN] key - AES key to be used |
mleksio | 1:2be292bd43f9 | 102 | * \param [IN] appNonce - Application nonce |
mleksio | 1:2be292bd43f9 | 103 | * \param [IN] devNonce - Device nonce |
mleksio | 1:2be292bd43f9 | 104 | * \param [OUT] nwkSKey - Network session key |
mleksio | 1:2be292bd43f9 | 105 | * \param [OUT] appSKey - Application session key |
mleksio | 0:c58229885f95 | 106 | */ |
mleksio | 0:c58229885f95 | 107 | void LoRaMacJoinComputeSKeys( const uint8_t *key, const uint8_t *appNonce, uint16_t devNonce, uint8_t *nwkSKey, uint8_t *appSKey ); |
mleksio | 0:c58229885f95 | 108 | |
mleksio | 1:2be292bd43f9 | 109 | /*! \} defgroup LORAMAC */ |
mleksio | 1:2be292bd43f9 | 110 | |
mleksio | 0:c58229885f95 | 111 | #endif // __LORAMAC_CRYPTO_H__ |