| 64 | } |
| 65 | |
| 66 | static bool encryptKey(const uint8_t key[ESP_NOW_KEY_LEN], std::string& hexOutput) { |
| 67 | uint8_t iv[16]; |
| 68 | crypt::getIv(IV_SEED, std::strlen(IV_SEED), iv); |
| 69 | |
| 70 | uint8_t encrypted[ESP_NOW_KEY_LEN]; |
| 71 | if (crypt::encrypt(iv, key, encrypted, ESP_NOW_KEY_LEN) != 0) { |
| 72 | LOGGER.error("Failed to encrypt key"); |
| 73 | return false; |
| 74 | } |
| 75 | |
| 76 | hexOutput = toHexString(encrypted, ESP_NOW_KEY_LEN); |
| 77 | return true; |
| 78 | } |
| 79 | |
| 80 | static bool decryptKey(const std::string& hexInput, uint8_t key[ESP_NOW_KEY_LEN]) { |
| 81 | if (hexInput.size() != ESP_NOW_KEY_LEN * 2) { |
no test coverage detected