* Combines a stored key and a hardware key into a single reliable key value. * @param[out] key the key output */
| 109 | * @param[out] key the key output |
| 110 | */ |
| 111 | static void getKey(uint8_t key[32]) { |
| 112 | #if !defined(CONFIG_SECURE_BOOT) || !defined(CONFIG_SECURE_FLASH_ENC_ENABLED) |
| 113 | LOGGER.warn("Using tt_secure_* code with secure boot and/or flash encryption disabled."); |
| 114 | LOGGER.warn("An attacker with physical access to your ESP32 can decrypt your secure data."); |
| 115 | #endif |
| 116 | |
| 117 | #ifdef ESP_PLATFORM |
| 118 | uint8_t hardware_key[32]; |
| 119 | uint8_t nvs_key[32]; |
| 120 | |
| 121 | get_hardware_key(hardware_key); |
| 122 | get_nvs_key(nvs_key); |
| 123 | xorKey(hardware_key, nvs_key, key, 32); |
| 124 | #else |
| 125 | LOGGER.warn("Using unsafe key for debugging purposes."); |
| 126 | memset(key, 0, 32); |
| 127 | #endif |
| 128 | } |
| 129 | |
| 130 | void getIv(const void* data, size_t dataLength, uint8_t iv[16]) { |
| 131 | memset(iv, 0, 16); |
no test coverage detected