Project restructuring (fixes macOS builds) (#198)

- Create `Include/` folder for all main projects
- Fix some issues here and there (found while moving things)
- All includes are now in `Tactility/` subfolder and must be included with that prefix. This fixes issues with clashing POSIX headers (e.g. `<semaphore.h>` versus Tactility's `Semaphore.h`)
This commit is contained in:
Ken Van Hoeylandt
2025-02-01 18:13:20 +01:00
committed by GitHub
parent 7856827ecf
commit c87200a80d
350 changed files with 967 additions and 870 deletions
+5 -4
View File
@@ -1,8 +1,9 @@
#include "Crypt.h"
#include "Tactility/crypt/Crypt.h"
#include "Check.h"
#include "Log.h"
#include "mbedtls/aes.h"
#include "Tactility/Check.h"
#include "Tactility/Log.h"
#include <mbedtls/aes.h>
#include <cstring>
#include <cstdint>
-63
View File
@@ -1,63 +0,0 @@
/** @file secure.h
*
* @brief Hardware-bound encryption methods.
* @warning Enable secure boot and flash encryption to increase security.
*
* Offers AES 256 CBC encryption with built-in key.
* The key is built from data including:
* - the internal factory MAC address
* - random data stored in NVS
*
* It's important to use flash encryption to avoid an attacker to get
* access to your encrypted data. If flash encryption is disabled,
* someone can fetch the key from the partitions.
*
* See:
* https://docs.espressif.com/projects/esp-idf/en/latest/esp32/security/secure-boot-v2.html
* https://docs.espressif.com/projects/esp-idf/en/latest/esp32/security/flash-encryption.html
*/
#pragma once
#include <cstdio>
#include <cstdint>
#include <string>
namespace tt::crypt {
/**
* @brief Fills the IV with zeros and then creates an IV based on the input data.
* @param[in] data input data
* @param[in] dataLength input data length
* @param[out] iv output IV
*/
void getIv(const void* data, size_t dataLength, uint8_t iv[16]);
/**
* @brief Encrypt data.
*
* Important: Use flash encryption to increase security.
* Important: input and output data must be aligned to 16 bytes.
*
* @param[in] iv the AES IV
* @param[in] inData input data
* @param[out] outData output data
* @param[in] dataLength data length, a multiple of 16 (for both inData and outData)
* @return the result of esp_aes_crypt_cbc() (MBEDTLS_ERR_*)
*/
int encrypt(const uint8_t iv[16], uint8_t* inData, uint8_t* outData, size_t dataLength);
/**
* @brief Decrypt data.
*
* Important: Use flash encryption to increase security.
* Important: input and output data must be aligned to 16 bytes.
*
* @param[in] iv AES IV
* @param[in] inData input data
* @param[out] outData output data
* @param[in] dataLength data length, a multiple of 16 (for both inData and outData)
* @return the result of esp_aes_crypt_cbc() (MBEDTLS_ERR_*)
*/
int decrypt(const uint8_t iv[16], uint8_t* inData, uint8_t* outData, size_t dataLength);
} // namespace
+1 -1
View File
@@ -1,4 +1,4 @@
#include "Hash.h"
#include "Tactility/crypt/Hash.h"
namespace tt::crypt {
-23
View File
@@ -1,23 +0,0 @@
#pragma once
#include <cstddef>
#include <cstdint>
namespace tt::crypt {
/**
* Implementation of DJB2 hashing algorithm.
* @param[in] str the string to calculate the hash for
* @return the hash
*/
uint32_t djb2(const char* str);
/**
* Implementation of DJB2 hashing algorithm.
* @param[in] data the bytes to calculate the hash for
* @param[in] length the size of data
* @return the hash
*/
uint32_t djb2(const void* data, size_t length);
} // namespace