chg: 'lf keri sim' - is kind of up, *untested*

This commit is contained in:
iceman1001 2019-02-24 11:14:51 +01:00
commit 730b4940f8

View file

@ -16,7 +16,7 @@ int usage_lf_keri_clone(void){
PrintAndLogEx(NORMAL, "Usage: lf keri clone [h] <id> <Q5>"); PrintAndLogEx(NORMAL, "Usage: lf keri clone [h] <id> <Q5>");
PrintAndLogEx(NORMAL, "Options:"); PrintAndLogEx(NORMAL, "Options:");
PrintAndLogEx(NORMAL, " h : This help"); PrintAndLogEx(NORMAL, " h : This help");
PrintAndLogEx(NORMAL, " <id> : KERI Internal ID"); PrintAndLogEx(NORMAL, " <id> : Keri Internal ID");
PrintAndLogEx(NORMAL, " <Q5> : specify write to Q5 (t5555 instead of t55x7)"); PrintAndLogEx(NORMAL, " <Q5> : specify write to Q5 (t5555 instead of t55x7)");
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:"); PrintAndLogEx(NORMAL, "Examples:");
@ -128,8 +128,6 @@ int CmdKeriRead(const char *Cmd) {
} }
int CmdKeriClone(const char *Cmd) { int CmdKeriClone(const char *Cmd) {
uint32_t internalid = 0; uint32_t internalid = 0;
uint32_t blocks[3] = { uint32_t blocks[3] = {
@ -196,19 +194,17 @@ int CmdKeriSim(const char *Cmd) {
char cmdp = tolower(param_getchar(Cmd, 0)); char cmdp = tolower(param_getchar(Cmd, 0));
if (strlen(Cmd) == 0 || cmdp == 'h') return usage_lf_keri_sim(); if (strlen(Cmd) == 0 || cmdp == 'h') return usage_lf_keri_sim();
uint8_t bits[64]; uint64_t internalid = param_get32ex(Cmd, 0, 0, 10);
uint8_t *bs = bits;
memset(bs, 0, sizeof(bits));
uint32_t internalid = param_get32ex(Cmd, 0, 0, 10);
// loop to bits.
internalid |= 0x80000000; internalid |= 0x80000000;
internalid <<= 3;
internalid += 7;
// 3 LSB is ONE uint8_t bits[64] = {0x00};
uint64_t data = ((uint64_t)internalid << 3 ) + 7; // loop to bits
uint8_t j = 0;
for ( int8_t i = 63; i >= 0; --i) {
bits[j++] = ((internalid >> i) & 1 );
}
uint8_t clk = 32, carrier = 2, invert = 0; uint8_t clk = 32, carrier = 2, invert = 0;
uint16_t arg1, arg2; uint16_t arg1, arg2;
@ -216,14 +212,13 @@ int CmdKeriSim(const char *Cmd) {
arg1 = clk << 8 | carrier; arg1 = clk << 8 | carrier;
arg2 = invert; arg2 = invert;
PrintAndLogEx(NORMAL, "Simulating KERI - Internal Id: %u", internalid); PrintAndLogEx(NORMAL, "Simulating KERI - Internal Id: %u", internalid);
UsbCommand c = {CMD_PSK_SIM_TAG, {arg1, arg2, size}}; UsbCommand c = {CMD_PSK_SIM_TAG, {arg1, arg2, size}};
memcpy(c.d.asBytes, bs, size); memcpy(c.d.asBytes, bs, size);
clearCommandBuffer(); clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
return 0; return 0;
} }