MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / decryptKey

Function decryptKey

Tactility/Source/app/chat/ChatSettings.cpp:80–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78}
79
80static bool decryptKey(const std::string& hexInput, uint8_t key[ESP_NOW_KEY_LEN]) {
81 if (hexInput.size() != ESP_NOW_KEY_LEN * 2) {
82 return false;
83 }
84
85 uint8_t encrypted[ESP_NOW_KEY_LEN];
86 if (!readHex(hexInput, encrypted, ESP_NOW_KEY_LEN)) {
87 return false;
88 }
89
90 uint8_t iv[16];
91 crypt::getIv(IV_SEED, std::strlen(IV_SEED), iv);
92
93 if (crypt::decrypt(iv, encrypted, key, ESP_NOW_KEY_LEN) != 0) {
94 LOGGER.error("Failed to decrypt key");
95 return false;
96 }
97 return true;
98}
99
100/** Generate a non-zero random sender ID using hardware RNG. */
101static uint32_t generateSenderId() {

Callers 1

loadSettingsFunction · 0.85

Calls 4

getIvFunction · 0.85
errorMethod · 0.80
readHexFunction · 0.70
decryptFunction · 0.50

Tested by

no test coverage detected