Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
onlykey committed May 6, 2021
1 parent 0e1258a commit 0dc7cf0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 29 deletions.
11 changes: 7 additions & 4 deletions fido2/crypto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* defining EXTERNAL_SOLO_CRYPTO
*
* */
#ifndef EXTERNAL_SOLO_CRYPTO
//#ifndef EXTERNAL_SOLO_CRYPTO

#include <stdio.h>
#include <stdlib.h>
Expand All @@ -33,6 +33,7 @@
#include "log.h"
#include "ctap.h"
#include "okcrypto.h"
#ifdef STD_VERSION
// OnlyKey required change end


Expand Down Expand Up @@ -520,7 +521,9 @@ uint8_t attestation_key[33] = "\x11\xc5\xd7\xe3\x2b\xd5\x64\x2d\xf8\x1c\xea\x3b\

uint16_t attestation_key_size = sizeof(attestation_key)-1;

#else
#error "No crypto implementation defined"
//#else
//#error "No crypto implementation defined"
// OnlyKey required change end
#endif
//#endif

#endif
26 changes: 3 additions & 23 deletions onlykey/okcore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1737,7 +1737,6 @@ void set_slot(uint8_t *buffer)
} else if (slot > 0 && slot < 25) {
okcore_aes_gcm_encrypt((buffer + 7), slot, value, profilekey, (16+EElen_private+EElen_aeskey));
okcore_flashset_2fa_key(buffer + 7, (16+EElen_private+EElen_aeskey), slot);
Serial.print("Setting okeeprom_eeset_2FAtype");
uint8_t type = 'Y'; //89
okeeprom_eeset_2FAtype(&type, slot);
}
Expand Down Expand Up @@ -5201,21 +5200,13 @@ int yubikeysim(char *ptr, uint8_t slot)
#ifdef STD_VERSION
uint8_t ctr[2];
yubikeyinit(slot);
Serial.println("Yubikey counter before");
Serial.println(ctx.counter);
Serial.println("Yubikey usage before");
Serial.println(ctx.usage);
yubikey_incr_counter(&ctx, slot);
ctr[0] = ctx.counter >> 8 & 0xFF;
ctr[1] = ctx.counter & 0xFF;
yubikey_eeset_counter(ctr, slot);
yubikey_simulate1(ptr, &ctx);
Serial.println("Yubikey counter after");
Serial.println(ctx.counter);
Serial.println("Yubikey usage after");
Serial.println(ctx.usage);
#endif
return ctx.publen;
#endif
}
/*************************************/
//Increment Yubico timestamp
Expand Down Expand Up @@ -6896,8 +6887,6 @@ void process_setreport()
temp[5] = recv_buffer[5];
okeeprom_eeset_hmac_challengemode(0); // Reset to default both slots require button press
wipe_private(temp);
Serial.println("wiping");
Serial.println(recv_buffer[5]);
}
else {
uint8_t mode = 0;
Expand All @@ -6906,8 +6895,6 @@ void process_setreport()
// Get current mode
okeeprom_eeget_hmac_challengemode(&mode);
delay(100);
Serial.println("MODE");
Serial.println(mode);
if (mode==1) { // Both CR slots already require no button press
} else if (mode==recv_buffer[5]) { // Only current CR slot already require no button press
} else if (mode) { // Only NOT current CR slot already require no button press
Expand All @@ -6925,8 +6912,6 @@ void process_setreport()
else {
okeeprom_eeget_ecckey(&KEYtype, RESERVED_KEY_HMACSHA1_2); //Key Type (1-4) and slot (101-132)
}
Serial.println("TYPE");
Serial.println(KEYtype);
// If private set, write challenge mode
if (KEYtype == 9) {
okeeprom_eeset_hmac_challengemode(&mode);
Expand All @@ -6939,12 +6924,11 @@ void process_setreport()
recv_buffer[4] = OKSETSLOT;
// Pacing
if (keyboard_buffer[47] == CFGFLAG_PACING_10MS) {
Serial.println("CFGFLAG_PACING_10MS");

// set speed to medium
TYPESPEED[0] = 2;
okeeprom_eeset_typespeed((uint8_t*)TYPESPEED);
} else if (keyboard_buffer[47] == CFGFLAG_PACING_20MS) {
Serial.println("CFGFLAG_PACING_20MS");
// set speed to slow
TYPESPEED[0] = 4;
okeeprom_eeset_typespeed((uint8_t*)TYPESPEED);
Expand All @@ -6961,22 +6945,19 @@ void process_setreport()
if (profilemode)
addcharslot = addcharslot + 12;
if (keyboard_buffer[46] == 0x04) {
Serial.println("TAB");
okeeprom_eeget_addchar(&temp, addcharslot);
mask = 0b11000000;
temp2 = 1 << 7;
temp2 = (temp & ~mask) | (temp2 & mask);
okeeprom_eeset_addchar(&temp2, addcharslot);
} else if (keyboard_buffer[46] == 0x20) {
Serial.println("ENTER");
okeeprom_eeget_addchar(&temp, addcharslot);
mask = 0b11000000;
temp2 = 1 << 6;
temp2 = (temp & ~mask) | (temp2 & mask);
okeeprom_eeset_addchar(&temp2, addcharslot);
} else {
//No after otp
Serial.println("NONE");
okeeprom_eeget_addchar(&temp, addcharslot);
mask = 0b11000000;
temp2 = 0;
Expand Down Expand Up @@ -7004,7 +6985,6 @@ void process_setreport()
getBuffer[4] = sess_counter;
getBuffer[5] = 3;
getBuffer[7] = 0;
Serial.println("After getBuffer");
byteprint(getBuffer, 8);
memset(keyboard_buffer, 0, KEYBOARD_BUFFER_SIZE);
memset(recv_buffer, 0, sizeof(recv_buffer));
Expand Down Expand Up @@ -7062,7 +7042,7 @@ void process_setreport()
}
#endif
}
} else if (keyboard_buffer[64] == 0x20 || keyboard_buffer[64] == 0x28 && initialized && unlocked)
} else if ((keyboard_buffer[64] == 0x20 || keyboard_buffer[64] == 0x28) && initialized && unlocked)
{ //Yubi OTP}
if (profilemode != NONENCRYPTEDPROFILE)
{
Expand Down
4 changes: 2 additions & 2 deletions onlykey/onlykey.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@
#ifndef ONLYKEY_H
#define ONLYKEY_H

#define DEBUG //Enable Serial Monitor
#define STD_VERSION //Define for STD edition firmare, undefine for IN TRVL edition firmware
//#define DEBUG //Enable Serial Monitor
//#define STD_VERSION //Define for STD edition firmare, undefine for IN TRVL edition firmware
#define OK_Color //Define for hardware with color LED
#define OKversionmain "v2.1"

Expand Down

0 comments on commit 0dc7cf0

Please sign in to comment.