asif-test

Fork of LoRaWAN-lib by Semtech

Committer:
billvs
Date:
Wed Nov 01 20:44:06 2017 +0000
Revision:
8:8c9f22063c8d
Parent:
2:14a5d6ad92d5
asif test

Who changed what in which revision?

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