|
EnigmaIOT
0.9.8
Secure sensor and gateway platform based on ESP8266 and ESP32
|
Go to the documentation of this file.
11 #ifndef _CRYPTMODULE_h
12 #define _CRYPTMODULE_h
14 #if defined(ARDUINO) && ARDUINO >= 100
21 #define CRYPTMODULE_DEBUG_TAG "CryptModule"
24 #define RANDOM_32 0x3FF20E44
43 static uint32_t
random (uint32_t max, uint32_t min = 0) {
54 return _min + (
random () % (_max - _min));
66 static uint8_t*
random (
const uint8_t* buf,
size_t len);
83 const uint8_t* iv, uint8_t ivlen,
const uint8_t* key, uint8_t keylen,
84 const uint8_t* aad, uint8_t aadLen,
const uint8_t* tag, uint8_t tagLen);
92 static uint8_t*
getSHA256 (uint8_t* buffer, uint8_t length);
109 const uint8_t* iv, uint8_t ivlen,
const uint8_t* key, uint8_t keylen,
110 const uint8_t* aad, uint8_t aadLen,
const uint8_t* tag, uint8_t tagLen);
122 bool getDH2 (
const uint8_t* remotePubKey);
static bool decryptBuffer(const uint8_t *data, size_t length, const uint8_t *iv, uint8_t ivlen, const uint8_t *key, uint8_t keylen, const uint8_t *aad, uint8_t aadLen, const uint8_t *tag, uint8_t tagLen)
Decrypts a buffer using a shared key.
uint8_t * getPubDHKey()
Gets own public key used on Diffie Hellman algorithm.
void getDH1()
Starts first stage of Diffie Hellman key agreement algorithm.
uint8_t privateDHKey[KEY_LENGTH]
Temporary private key store used during key agreement.
static bool encryptBuffer(const uint8_t *data, size_t length, const uint8_t *iv, uint8_t ivlen, const uint8_t *key, uint8_t keylen, const uint8_t *aad, uint8_t aadLen, const uint8_t *tag, uint8_t tagLen)
Decrypts a buffer using a shared key.
EnigmaIoT Crypto module. Wraps Arduino CryptoLib classes and methods.
CryptModule Crypto
Singleton Crypto class instance.
static uint8_t * getSHA256(uint8_t *buffer, uint8_t length)
Generates a SHA256 hash from input.
static uint32_t random(uint32_t max, uint32_t min=0)
uint8_t * getPrivDHKey()
Gets own private key used on Diffie Hellman algorithm.
static uint32_t random()
Gets a random number.
const uint8_t RANDOM_LENGTH
Length of random number generator values.
const uint8_t KEY_LENGTH
Key length used by selected crypto algorythm. The only tested value is 32. Change it only if you know...
bool getDH2(const uint8_t *remotePubKey)
Starts second stage of Diffie Hellman key agreement algorithm and calculate shares key.
const uint8_t CRC_LENGTH
Length of CRC.
uint8_t publicDHKey[KEY_LENGTH]
Temporary public key store used during key agreement.