mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-22 10:42:49 +00:00
begin work on crypto
This commit is contained in:
31
src/mesh/CryptoEngine.h
Normal file
31
src/mesh/CryptoEngine.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
/**
|
||||
* see docs/software/crypto.md for details.
|
||||
*
|
||||
* The NONCE is constructed by concatenating:
|
||||
* a 32 bit sending node number + a 64 bit packet number + a 32 bit block counter (starts at zero)
|
||||
*/
|
||||
|
||||
class CryptoEngine
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Set the key used for encrypt, decrypt.
|
||||
*
|
||||
* As a special case: If all bytes are zero, we assume _no encryption_ and send all data in cleartext.
|
||||
*
|
||||
* @param numBytes must be 32 for now (AES256)
|
||||
*/
|
||||
void setKey(size_t numBytes, const uint8_t *bytes);
|
||||
|
||||
/**
|
||||
* Encrypt a packet
|
||||
*
|
||||
* @param bytes is updated in place
|
||||
*/
|
||||
void encrypt(uint32_t fromNode, uint64_t packetNum, size_t numBytes, uint8_t *bytes);
|
||||
void decrypt(uint32_t fromNode, uint64_t packetNum, size_t numBytes, uint8_t *bytes);
|
||||
};
|
||||
Reference in New Issue
Block a user