mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-16 10:02:05 +00:00
Key Verification confirm banner
This commit is contained in:
parent
c676867eaf
commit
8590b7a8ce
@ -183,7 +183,7 @@ void NotificationRenderer::drawAlertBannerOverlay(OLEDDisplay *display, OLEDDisp
|
|||||||
for (int i = 0; i < lineCount; i++) {
|
for (int i = 0; i < lineCount; i++) {
|
||||||
// is this line selected?
|
// is this line selected?
|
||||||
// if so, start the buffer with -> and strncpy to the 4th location
|
// if so, start the buffer with -> and strncpy to the 4th location
|
||||||
if (i == 0 || alertBannerOptions == 0) {
|
if (i < lineCount - alertBannerOptions || alertBannerOptions == 0) {
|
||||||
strncpy(lineBuffer, lineStarts[i], 40);
|
strncpy(lineBuffer, lineStarts[i], 40);
|
||||||
if (lineLengths[i] > 39)
|
if (lineLengths[i] > 39)
|
||||||
lineBuffer[39] = '\0';
|
lineBuffer[39] = '\0';
|
||||||
|
@ -59,7 +59,7 @@ bool KeyVerificationModule::handleReceivedProtobuf(const meshtastic_MeshPacket &
|
|||||||
r->hash1.size == 0) {
|
r->hash1.size == 0) {
|
||||||
memcpy(hash2, r->hash2.bytes, 32);
|
memcpy(hash2, r->hash2.bytes, 32);
|
||||||
if (screen)
|
if (screen)
|
||||||
screen->showOverlayBanner("Enter Security Number", 15000);
|
screen->showOverlayBanner("Enter Security Number", 30000);
|
||||||
|
|
||||||
meshtastic_ClientNotification *cn = clientNotificationPool.allocZeroed();
|
meshtastic_ClientNotification *cn = clientNotificationPool.allocZeroed();
|
||||||
cn->level = meshtastic_LogRecord_Level_WARNING;
|
cn->level = meshtastic_LogRecord_Level_WARNING;
|
||||||
@ -79,9 +79,15 @@ bool KeyVerificationModule::handleReceivedProtobuf(const meshtastic_MeshPacket &
|
|||||||
memset(message, 0, sizeof(message));
|
memset(message, 0, sizeof(message));
|
||||||
sprintf(message, "Verification: \n");
|
sprintf(message, "Verification: \n");
|
||||||
generateVerificationCode(message + 15);
|
generateVerificationCode(message + 15);
|
||||||
|
sprintf(message + 24, "\nACCEPT\nREJECT");
|
||||||
LOG_INFO("Hash1 matches!");
|
LOG_INFO("Hash1 matches!");
|
||||||
if (screen) {
|
if (screen) {
|
||||||
screen->showOverlayBanner(message, 15000);
|
screen->showOverlayBanner(message, 30000, 2, [=](int selected) {
|
||||||
|
if (selected == 0) {
|
||||||
|
auto remoteNodePtr = nodeDB->getMeshNode(currentRemoteNode);
|
||||||
|
remoteNodePtr->bitfield |= NODEINFO_BITFIELD_IS_KEY_MANUALLY_VERIFIED_MASK;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
meshtastic_ClientNotification *cn = clientNotificationPool.allocZeroed();
|
meshtastic_ClientNotification *cn = clientNotificationPool.allocZeroed();
|
||||||
cn->level = meshtastic_LogRecord_Level_WARNING;
|
cn->level = meshtastic_LogRecord_Level_WARNING;
|
||||||
@ -179,7 +185,7 @@ meshtastic_MeshPacket *KeyVerificationModule::allocReply()
|
|||||||
responsePacket->pki_encrypted = true;
|
responsePacket->pki_encrypted = true;
|
||||||
if (screen) {
|
if (screen) {
|
||||||
snprintf(message, 25, "Security Number \n%03u %03u", currentSecurityNumber / 1000, currentSecurityNumber % 1000);
|
snprintf(message, 25, "Security Number \n%03u %03u", currentSecurityNumber / 1000, currentSecurityNumber % 1000);
|
||||||
screen->showOverlayBanner(message, 15000);
|
screen->showOverlayBanner(message, 30000);
|
||||||
LOG_WARN("%s", message);
|
LOG_WARN("%s", message);
|
||||||
}
|
}
|
||||||
meshtastic_ClientNotification *cn = clientNotificationPool.allocZeroed();
|
meshtastic_ClientNotification *cn = clientNotificationPool.allocZeroed();
|
||||||
@ -193,7 +199,7 @@ meshtastic_MeshPacket *KeyVerificationModule::allocReply()
|
|||||||
sizeof(cn->payload_variant.key_verification_number_inform.remote_longname));
|
sizeof(cn->payload_variant.key_verification_number_inform.remote_longname));
|
||||||
cn->payload_variant.key_verification_number_inform.security_number = currentSecurityNumber;
|
cn->payload_variant.key_verification_number_inform.security_number = currentSecurityNumber;
|
||||||
service->sendClientNotification(cn);
|
service->sendClientNotification(cn);
|
||||||
LOG_WARN("Security Number %04u", currentSecurityNumber);
|
LOG_WARN("Security Number %04u, nonce %llu", currentSecurityNumber, currentNonce);
|
||||||
return responsePacket;
|
return responsePacket;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,7 +255,7 @@ void KeyVerificationModule::processSecurityNumber(uint32_t incomingNumber)
|
|||||||
sprintf(message, "Verification: \n");
|
sprintf(message, "Verification: \n");
|
||||||
generateVerificationCode(message + 15); // send the toPhone packet
|
generateVerificationCode(message + 15); // send the toPhone packet
|
||||||
if (screen) {
|
if (screen) {
|
||||||
screen->showOverlayBanner(message, 15000);
|
screen->showOverlayBanner(message, 30000);
|
||||||
}
|
}
|
||||||
meshtastic_ClientNotification *cn = clientNotificationPool.allocZeroed();
|
meshtastic_ClientNotification *cn = clientNotificationPool.allocZeroed();
|
||||||
cn->level = meshtastic_LogRecord_Level_WARNING;
|
cn->level = meshtastic_LogRecord_Level_WARNING;
|
||||||
@ -270,8 +276,10 @@ void KeyVerificationModule::updateState()
|
|||||||
{
|
{
|
||||||
if (currentState != KEY_VERIFICATION_IDLE) {
|
if (currentState != KEY_VERIFICATION_IDLE) {
|
||||||
// check for the 30 second timeout
|
// check for the 30 second timeout
|
||||||
if (currentNonceTimestamp < getTime() - 30) {
|
if (currentNonceTimestamp < getTime() - 60) {
|
||||||
resetToIdle();
|
resetToIdle();
|
||||||
|
} else {
|
||||||
|
currentNonceTimestamp = getTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ class KeyVerificationModule : public ProtobufModule<meshtastic_KeyVerification>
|
|||||||
KeyVerificationState currentState = KEY_VERIFICATION_IDLE;
|
KeyVerificationState currentState = KEY_VERIFICATION_IDLE;
|
||||||
uint8_t hash1[32] = {0}; //
|
uint8_t hash1[32] = {0}; //
|
||||||
uint8_t hash2[32] = {0}; //
|
uint8_t hash2[32] = {0}; //
|
||||||
char message[26] = {0};
|
char message[40] = {0};
|
||||||
|
|
||||||
void processSecurityNumber(uint32_t);
|
void processSecurityNumber(uint32_t);
|
||||||
void updateState(); // check the timeouts and maybe reset the state to idle
|
void updateState(); // check the timeouts and maybe reset the state to idle
|
||||||
|
Loading…
Reference in New Issue
Block a user