EnigmaIoT Crypto module. Wraps Arduino CryptoLib classes and methods.
More...
#include <cryptModule.h>
|
void | getDH1 () |
| Starts first stage of Diffie Hellman key agreement algorithm. More...
|
|
bool | getDH2 (const uint8_t *remotePubKey) |
| Starts second stage of Diffie Hellman key agreement algorithm and calculate shares key. More...
|
|
uint8_t * | getPrivDHKey () |
| Gets own private key used on Diffie Hellman algorithm. More...
|
|
uint8_t * | getPubDHKey () |
| Gets own public key used on Diffie Hellman algorithm. More...
|
|
|
static uint32_t | random () |
| Gets a random number. More...
|
|
static uint32_t | random (uint32_t max, uint32_t min=0) |
|
static uint8_t * | random (const uint8_t *buf, size_t len) |
| Fills a buffer with random values. More...
|
|
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. More...
|
|
static uint8_t * | getSHA256 (uint8_t *buffer, uint8_t length) |
| Generates a SHA256 hash from input. More...
|
|
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. More...
|
|
EnigmaIoT Crypto module. Wraps Arduino CryptoLib classes and methods.
Uses Arduino CryptoLib library
Definition at line 35 of file cryptModule.h.
◆ decryptBuffer()
bool CryptModule::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 |
|
) |
| |
|
static |
Decrypts a buffer using a shared key.
- Parameters
-
data | Buffer to decrypt. It will be used as input and output |
length | Buffer length in number of bytes |
iv | Initialization Vector used to encrypt this data |
ivlen | IV length |
key | Shared key used to encrypt data |
keylen | Key length |
aad | Additional Authentication Data for Poly1305 |
aadLen | Additional Authentication Data length |
tag | Buffer to store authentication tag calculated by Poly1305 |
tagLen | Additional Authentication Tag length |
- Returns
- True if decryption and tag checking was correct
Definition at line 52 of file cryptModule.cpp.
◆ encryptBuffer()
bool CryptModule::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 |
|
) |
| |
|
static |
Decrypts a buffer using a shared key.
- Parameters
-
data | Buffer to decrypt. It will be used as input and output |
length | Buffer length in number of bytes |
iv | Initialization Vector used to encrypt this data |
ivlen | IV length |
key | Shared key used to encrypt data |
keylen | Key length |
aad | Additional Authentication Data for Poly1305 |
aadLen | Additional Authentication Data length |
tag | Buffer to store authentication tag calculated by Poly1305 |
tagLen | Additional Authentication Tag length |
- Returns
- True if encryption and tag generation was correct
Definition at line 86 of file cryptModule.cpp.
◆ getDH1()
void CryptModule::getDH1 |
( |
| ) |
|
Starts first stage of Diffie Hellman key agreement algorithm.
Definition at line 141 of file cryptModule.cpp.
◆ getDH2()
bool CryptModule::getDH2 |
( |
const uint8_t * |
remotePubKey | ) |
|
Starts second stage of Diffie Hellman key agreement algorithm and calculate shares key.
- Parameters
-
remotePubKey | Public key got from the other peer |
- Returns
true
if calculation worked normally, false
otherwise.
Definition at line 148 of file cryptModule.cpp.
◆ getPrivDHKey()
uint8_t* CryptModule::getPrivDHKey |
( |
| ) |
|
|
inline |
Gets own private key used on Diffie Hellman algorithm.
- Returns
- Pointer to private key
Definition at line 128 of file cryptModule.h.
◆ getPubDHKey()
uint8_t* CryptModule::getPubDHKey |
( |
| ) |
|
|
inline |
Gets own public key used on Diffie Hellman algorithm.
- Returns
- Pointer to public key
Definition at line 136 of file cryptModule.h.
◆ getSHA256()
uint8_t * CryptModule::getSHA256 |
( |
uint8_t * |
buffer, |
|
|
uint8_t |
length |
|
) |
| |
|
static |
Generates a SHA256 hash from input.
- Parameters
-
buffer | Buffer with data to hash. Hash will be stored here |
length | Buffer length in number of bytes. It should be 32 at least |
- Returns
- Returns buffer pointer
Definition at line 20 of file cryptModule.cpp.
◆ random() [1/3]
uint32_t CryptModule::random |
( |
| ) |
|
|
static |
Gets a random number.
- Returns
- Returns a random number
Definition at line 119 of file cryptModule.cpp.
◆ random() [2/3]
uint8_t * CryptModule::random |
( |
const uint8_t * |
buf, |
|
|
size_t |
len |
|
) |
| |
|
static |
Fills a buffer with random values.
- Parameters
-
buf | Pointer to the buffer to fill |
len | Buffer length in number of bytes |
- Returns
- Returns the same buffer used as input, filled with random data
Definition at line 127 of file cryptModule.cpp.
◆ random() [3/3]
static uint32_t CryptModule::random |
( |
uint32_t |
max, |
|
|
uint32_t |
min = 0 |
|
) |
| |
|
inlinestatic |
◆ privateDHKey
Temporary private key store used during key agreement.
Definition at line 141 of file cryptModule.h.
◆ publicDHKey
Temporary public key store used during key agreement.
Definition at line 142 of file cryptModule.h.
The documentation for this class was generated from the following files: