Skip to content

Commit bbb910a

Browse files
committed
support for downgrade prevention
1 parent 3eee1c1 commit bbb910a

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

OnlyKey/OnlyKey.ino

+4-8
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@
7979
/*************************************/
8080
//Firmware Build Options
8181
/*************************************/
82-
#define DEBUG //Enable Serial Monitor, debug firmware
83-
#define STD_VERSION //Define for STD edition firmare, undefine for IN TRVL edition firmware
82+
//#define DEBUG //Enable Serial Monitor, debug firmware
83+
//#define STD_VERSION //Define for STD edition firmare, undefine for IN TRVL edition firmware
8484
#define OK_Color //Define for hardware with color LED
8585
//#define FACTORYKEYS // Attestation key and other keys encrypted using CHIP ID and RNG for unique per device
8686
/*************************************/
@@ -341,8 +341,6 @@ void setup() {
341341
eeprom_write_byte((unsigned char*)(2+i), ctap_buffer[i]); // 2-65 used for fw integrity hash
342342
}
343343
memset(ctap_buffer, 0, 2048);
344-
//write fwvermaj, prevents downgrade to previous majver
345-
eeprom_write_byte((unsigned char *)1984, OKversionmaj[0]);
346344
#endif
347345
// 3) Enable flash security after writing
348346
int nn = 0;
@@ -351,12 +349,11 @@ void setup() {
351349
Serial.print("Flash security bits ");
352350
if(nn) Serial.print("not ");
353351
Serial.println("written successfully");
354-
Serial.println("FW VER MAJ ");
355-
Serial.print(eeprom_read_byte((unsigned char *)1984));
356352
#endif
357353
}
358354
if(!initcheck) {
359355
wipeEEPROM();
356+
eeprom_write_byte((unsigned char *)1984, (OKversionmaj[0] - '0')); //write fwvermaj, prevents downgrade to previous majver
360357
okeeprom_eeset_timeout((uint8_t*)TIMEOUT); //Default lockout 30 min
361358
unlocked = true; //Flash is not protected, First time use
362359
initialized = false;
@@ -1222,8 +1219,6 @@ void process_slot(int s) {
12221219
index++;
12231220
}
12241221
otplength = okeeprom_eeget_2FAtype(ptr, slot);
1225-
Serial.println("OTP TYPE from Flash");
1226-
Serial.println(temp[0]);
12271222
if(temp[0] > 0)
12281223
{
12291224
if(temp[0] == MFAGOOGLEAUTH) { //Google Auth
@@ -1481,3 +1476,4 @@ void exceeded_login_attempts() {
14811476
}
14821477

14831478

1479+

0 commit comments

Comments
 (0)