mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
chg: 'hf mf sim' @piwi's changes part 1
This commit is contained in:
parent
92f37c4c22
commit
f906cb7f89
2 changed files with 23 additions and 9 deletions
|
@ -13,23 +13,27 @@
|
|||
int MF_DBGLEVEL = MF_DBG_ALL;
|
||||
|
||||
// crypto1 helpers
|
||||
void mf_crypto1_decrypt(struct Crypto1State *pcs, uint8_t *data, int len){
|
||||
void mf_crypto1_decryptEx(struct Crypto1State *pcs, uint8_t *data_in, int len, uint8_t *data_out){
|
||||
uint8_t bt = 0;
|
||||
int i;
|
||||
|
||||
if (len != 1) {
|
||||
for (i = 0; i < len; i++)
|
||||
data[i] = crypto1_byte(pcs, 0x00, 0) ^ data[i];
|
||||
data_out[i] = crypto1_byte(pcs, 0x00, 0) ^ data_in[i];
|
||||
} else {
|
||||
bt |= (crypto1_bit(pcs, 0, 0) ^ BIT(data[0], 0)) << 0;
|
||||
bt |= (crypto1_bit(pcs, 0, 0) ^ BIT(data[0], 1)) << 1;
|
||||
bt |= (crypto1_bit(pcs, 0, 0) ^ BIT(data[0], 2)) << 2;
|
||||
bt |= (crypto1_bit(pcs, 0, 0) ^ BIT(data[0], 3)) << 3;
|
||||
data[0] = bt;
|
||||
bt |= (crypto1_bit(pcs, 0, 0) ^ BIT(data_in[0], 0)) << 0;
|
||||
bt |= (crypto1_bit(pcs, 0, 0) ^ BIT(data_in[0], 1)) << 1;
|
||||
bt |= (crypto1_bit(pcs, 0, 0) ^ BIT(data_in[0], 2)) << 2;
|
||||
bt |= (crypto1_bit(pcs, 0, 0) ^ BIT(data_in[0], 3)) << 3;
|
||||
data_out[0] = bt;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void mf_crypto1_decrypt(struct Crypto1State *pcs, uint8_t *data, int len){
|
||||
mf_crypto1_decryptEx(pcs, data, len, data);
|
||||
}
|
||||
|
||||
void mf_crypto1_encrypt(struct Crypto1State *pcs, uint8_t *data, uint16_t len, uint8_t *par) {
|
||||
uint8_t bt = 0;
|
||||
int i;
|
||||
|
@ -62,8 +66,7 @@ int mifare_sendcmd(uint8_t cmd, uint8_t* data, uint8_t data_size, uint8_t* answe
|
|||
ReaderTransmit(dcmd, sizeof(dcmd), timing);
|
||||
int len = ReaderReceive(answer, answer_parity);
|
||||
if(!len) {
|
||||
if (MF_DBGLEVEL >= MF_DBG_ERROR)
|
||||
Dbprintf("%02X Cmd failed. Card timeout.", cmd);
|
||||
if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("%02X Cmd failed. Card timeout.", cmd);
|
||||
len = ReaderReceive(answer,answer_parity);
|
||||
}
|
||||
return len;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue