fix enc key initialization after boot

This commit is contained in:
Nunu 2024-01-31 18:11:44 +01:00
parent fd03292669
commit 229806da0f
5 changed files with 19 additions and 5 deletions

View File

@ -65,6 +65,9 @@
#ifdef ENABLE_MESSENGER
#include "app/messenger.h"
#endif
#ifdef ENABLE_ENCRYPTION
#include "helper/crypto.h"
#endif
#ifdef ENABLE_MESSENGER_NOTIFICATION
bool gPlayMSGRing = false;
@ -1309,6 +1312,13 @@ void APP_TimeSlice500ms(void)
} else if (hasNewMessage == 2) {
hasNewMessage = 1;
}
}
#endif
#ifdef ENABLE_ENCRYPTION
if(gRecalculateEncKey){
CRYPTO_Generate256BitKey(gEeprom.ENC_KEY, gEncryptionKey, sizeof(gEeprom.ENC_KEY));
gRecalculateEncKey = false;
}
#endif

View File

@ -682,6 +682,9 @@ void MSG_Init() {
prevKey = 0;
prevLetter = 0;
cIndex = 0;
#ifdef ENABLE_ENCRYPTION
gRecalculateEncKey = true;
#endif
}
void MSG_SendAck() {

View File

@ -19,6 +19,8 @@
#include "driver/bk4819.h"
#include "driver/systick.h"
bool gRecalculateEncKey;
u_int8_t gEncryptionKey[32];
// salt used for hashing encryption key from eeprom used for sending packets

View File

@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdbool.h>
#include <stdint.h>
extern uint8_t gEncryptionKey[32];
extern bool gRecalculateEncKey;
extern uint8_t gEncryptionKey[32];
static const uint8_t encryptionSalt[4][8];
static const uint8_t displaySalt[32];

View File

@ -277,8 +277,7 @@ void SETTINGS_SaveEncryptionKey()
{
EEPROM_WriteBuffer(0x0F30, gEeprom.ENC_KEY, true);
EEPROM_WriteBuffer(0x0F38, gEeprom.ENC_KEY + 8, true);
CRYPTO_Generate256BitKey(gEeprom.ENC_KEY, gEncryptionKey, sizeof(gEeprom.ENC_KEY));
gRecalculateEncKey = true;
}
#endif