20171208

Fork of LoRaWAN-lib by Semtech

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LoRaMacCrypto.h Source File

LoRaMacCrypto.h

Go to the documentation of this file.
00001 /*!
00002  * \file      LoRaMacCrypto.h
00003  *
00004  * \brief     LoRa MAC layer cryptography implementation
00005  *
00006  * \copyright Revised BSD License, see section \ref LICENSE.
00007  *
00008  * \code
00009  *                ______                              _
00010  *               / _____)             _              | |
00011  *              ( (____  _____ ____ _| |_ _____  ____| |__
00012  *               \____ \| ___ |    (_   _) ___ |/ ___)  _ \
00013  *               _____) ) ____| | | || |_| ____( (___| | | |
00014  *              (______/|_____)_|_|_| \__)_____)\____)_| |_|
00015  *              (C)2013 Semtech
00016  *
00017  *               ___ _____ _   ___ _  _____ ___  ___  ___ ___
00018  *              / __|_   _/_\ / __| |/ / __/ _ \| _ \/ __| __|
00019  *              \__ \ | |/ _ \ (__| ' <| _| (_) |   / (__| _|
00020  *              |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___|
00021  *              embedded.connectivity.solutions===============
00022  *
00023  * \endcode
00024  *
00025  * \author    Miguel Luis ( Semtech )
00026  *
00027  * \author    Gregory Cristian ( Semtech )
00028  *
00029  * \author    Daniel Jäckle ( STACKFORCE )
00030  *
00031  * \defgroup    LORAMAC_CRYPTO  LoRa MAC layer cryptography implementation
00032  *              This module covers the implementation of cryptographic functions
00033  *              of the LoRaMAC layer.
00034  * \{
00035  */
00036 #ifndef __LORAMAC_CRYPTO_H__
00037 #define __LORAMAC_CRYPTO_H__
00038 
00039 /*!
00040  * Computes the LoRaMAC frame MIC field
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] mic             - Computed MIC field
00049  */
00050 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 );
00051 
00052 /*!
00053  * Computes the LoRaMAC payload encryption
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] encBuffer       - Encrypted buffer
00062  */
00063 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 );
00064 
00065 /*!
00066  * Computes the LoRaMAC payload decryption
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 [IN]  address         - Frame address
00072  * \param [IN]  dir             - Frame direction [0: uplink, 1: downlink]
00073  * \param [IN]  sequenceCounter - Frame sequence counter
00074  * \param [OUT] decBuffer       - Decrypted buffer
00075  */
00076 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 );
00077 
00078 /*!
00079  * Computes the LoRaMAC Join Request frame MIC field
00080  *
00081  * \param [IN]  buffer          - Data buffer
00082  * \param [IN]  size            - Data buffer size
00083  * \param [IN]  key             - AES key to be used
00084  * \param [OUT] mic             - Computed MIC field
00085  */
00086 void LoRaMacJoinComputeMic ( const uint8_t *buffer, uint16_t size, const uint8_t *key, uint32_t *mic );
00087 
00088 /*!
00089  * Computes the LoRaMAC join frame decryption
00090  *
00091  * \param [IN]  buffer          - Data buffer
00092  * \param [IN]  size            - Data buffer size
00093  * \param [IN]  key             - AES key to be used
00094  * \param [OUT] decBuffer       - Decrypted buffer
00095  */
00096 void LoRaMacJoinDecrypt ( const uint8_t *buffer, uint16_t size, const uint8_t *key, uint8_t *decBuffer );
00097 
00098 /*!
00099  * Computes the LoRaMAC join frame decryption
00100  *
00101  * \param [IN]  key             - AES key to be used
00102  * \param [IN]  appNonce        - Application nonce
00103  * \param [IN]  devNonce        - Device nonce
00104  * \param [OUT] nwkSKey         - Network session key
00105  * \param [OUT] appSKey         - Application session key
00106  */
00107 void LoRaMacJoinComputeSKeys ( const uint8_t *key, const uint8_t *appNonce, uint16_t devNonce, uint8_t *nwkSKey, uint8_t *appSKey );
00108 
00109 /*! \} defgroup LORAMAC */
00110 
00111 #endif // __LORAMAC_CRYPTO_H__