mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-02 08:00:38 +00:00
begin work on crypto
This commit is contained in:
16
src/mesh/CryptoEngine.cpp
Normal file
16
src/mesh/CryptoEngine.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include "CryptoEngine.h"
|
||||
#include "configuration.h"
|
||||
|
||||
void CryptoEngine::setKey(size_t numBytes, const uint8_t *bytes)
|
||||
{
|
||||
DEBUG_MSG("WARNING: Using stub crypto - all crypto is sent in plaintext!\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypt a packet
|
||||
*
|
||||
* @param bytes is updated in place
|
||||
*/
|
||||
void CryptoEngine::encrypt(uint32_t fromNode, uint64_t packetNum, size_t numBytes, uint8_t *bytes) {}
|
||||
|
||||
void CryptoEngine::decrypt(uint32_t fromNode, uint64_t packetNum, size_t numBytes, uint8_t *bytes) {}
|
||||
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