LMiC adapted to work with SX1272MB2xAS LoRa shield.
Fork of LMiC by
Diff: aes.cpp
- Revision:
- 8:5879e83f632a
- Parent:
- 1:d3b7bde3995c
diff -r 29058a7ccf23 -r 5879e83f632a aes.cpp --- a/aes.cpp Thu Feb 25 21:28:23 2016 +0000 +++ b/aes.cpp Mon Apr 02 12:04:59 2018 +0000 @@ -7,11 +7,23 @@ * * Contributors: * IBM Zurich Research Lab - initial API, implementation and documentation - *******************************************************************************/ + * + * ///////////////////////////////////////////////////////////////////////////// + * + * Used by Giorgos Tsapparellas for Internet of Things (IoT) smart monitoring + * device for agriculture using LoRaWAN technology. + * + * Date of issued copy: 25 January 2018 + * + * Modifications: + * - No external modifications of the existing "AS IT IS" software. + * - Added some external comments for meeting good principles of + * source code re-usability. + ******************************************************************************/ #include "oslmic.h" -#define AES_MICSUB 0x30 // internal use only +#define AES_MICSUB 0x30 // Internal use only. static const u4_t AES_RCON[10] = { 0x01000000, 0x02000000, 0x04000000, 0x08000000, 0x10000000, @@ -199,12 +211,18 @@ a ^= (AES_S[u1(r2>> 8)]<< 8); \ a ^= AES_S[u1(r3) ] -// global area for passing parameters (aux, key) and for storing round keys +// Global area for passing parameters (aux, key) and for storing round keys. u4_t AESAUX[16/sizeof(u4_t)]; u4_t AESKEY[11*16/sizeof(u4_t)]; -// generate 1+10 roundkeys for encryption with 128-bit key -// read 128-bit key from AESKEY in MSBF, generate roundkey words in place +/* +* aesroundkeys function of type static void. +* Generate 1+10 roundkeys for encryption with 128-bit key. +* Read 128-bit key from AESKEY in MSBF, generate roundkey words in place. +* +* Input parameters: None +* +*/ static void aesroundkeys () { int i; u4_t b; @@ -225,8 +243,17 @@ } AESKEY[i] = b ^= AESKEY[i-4]; } -} +} // end of aesroundkeys function. +/* +* os_aes function of type unsigned integer. +* +* Input parameters: unsigned int mode +* unsigned int buf +* unsigned int short len +* +* Return: AESAUX[0] +*/ u4_t os_aes (u1_t mode, xref2u1_t buf, u2_t len) { aesroundkeys(); @@ -363,5 +390,5 @@ mode |= AES_MICNOAUX; } return AESAUX[0]; -} +} // end of os_aes function.