struct {
int (*setkey)(struct rfid_asic_handle *h,
const unsigned char *key);
+ int (*setkey_ee)(struct rfid_asic_handle *h,
+ const unsigned int addr);
int (*auth)(struct rfid_asic_handle *h, u_int8_t cmd,
u_int32_t serno, u_int8_t block);
} mifare_classic;
} iso15693;
struct rfid_mifare_classic_reader {
int (*setkey)(struct rfid_reader_handle *h, const unsigned char *key);
+ int (*setkey_ee)(struct rfid_reader_handle *h, const unsigned int addr);
int (*auth)(struct rfid_reader_handle *h, u_int8_t cmd,
u_int32_t serno, u_int8_t block);
} mifare_classic;
return 0;
}
+static int
+rc632_mifare_set_key_ee(struct rfid_asic_handle *h, unsigned int addr)
+{
+ int ret;
+ u_int8_t cmd_addr[2];
+ u_int8_t reg;
+
+ if (addr > 0xffff - RFID_MIFARE_KEY_CODED_LEN)
+ return -EINVAL;
+
+ cmd_addr[0] = addr & 0xff; /* LSB */
+ cmd_addr[1] = (addr >> 8) & 0xff; /* MSB */
+
+ /* Terminate probably running command */
+ ret = rc632_reg_write(h, RC632_REG_COMMAND, RC632_CMD_IDLE);
+ if (ret < 0)
+ return ret;
+
+ /* Write the key address to the FIFO */
+ ret = rc632_fifo_write(h, 2, cmd_addr, 0x03);
+ if (ret < 0)
+ return ret;
+
+ ret = rc632_reg_write(h, RC632_REG_COMMAND, RC632_CMD_LOAD_KEY_E2);
+ if (ret < 0)
+ return ret;
+
+ ret = rc632_timer_set(h, RC632_TMO_AUTH1);
+ if (ret < 0)
+ return ret;
+
+ //ret = rc632_wait_idle(h, RC632_TMO_AUTH1);
+ ret = rc632_wait_idle_timer(h);
+ if (ret < 0)
+ return ret;
+
+ ret = rc632_reg_read(h, RC632_REG_ERROR_FLAG, ®);
+ if (ret < 0)
+ return ret;
+
+ if (reg & RC632_ERR_FLAG_KEY_ERR)
+ return -EINVAL;
+
+ return 0;
+}
+
static int
rc632_mifare_auth(struct rfid_asic_handle *h, u_int8_t cmd, u_int32_t serno,
u_int8_t block)
},
.mifare_classic = {
.setkey = &rc632_mifare_set_key,
+ .setkey_ee = &rc632_mifare_set_key_ee,
.auth = &rc632_mifare_auth,
},
},
return ph->l2h->rh->reader->mifare_classic.setkey(ph->l2h->rh, key);
}
+int mfcl_set_key_ee(struct rfid_protocol_handle *ph, unsigned int addr)
+{
+ if (!ph->l2h->rh->reader->mifare_classic.setkey_ee)
+ return -ENODEV;
+
+ return ph->l2h->rh->reader->mifare_classic.setkey_ee(ph->l2h->rh, addr);
+}
+
int mfcl_auth(struct rfid_protocol_handle *ph, u_int8_t cmd, u_int8_t block)
{
u_int32_t serno = *((u_int32_t *)ph->l2h->uid);
},
.mifare_classic = {
.setkey = &_rdr_rc632_mifare_setkey,
+ .setkey_ee = &_rdr_rc632_mifare_setkey_ee,
.auth = &_rdr_rc632_mifare_auth,
},
};
},
.mifare_classic = {
.setkey = &_rdr_rc632_mifare_setkey,
+ .setkey_ee = &_rdr_rc632_mifare_setkey_ee,
.auth = &_rdr_rc632_mifare_auth,
},
};
return rh->ah->asic->priv.rc632.fn.mifare_classic.setkey(rh->ah, key);
}
+int
+_rdr_rc632_mifare_setkey_ee(struct rfid_reader_handle *rh, unsigned int addr)
+{
+ return rh->ah->asic->priv.rc632.fn.mifare_classic.setkey_ee(rh->ah, addr);
+}
+
int
_rdr_rc632_mifare_auth(struct rfid_reader_handle *rh, u_int8_t cmd,
u_int32_t serno, u_int8_t block)
unsigned int speed);
int _rdr_rc632_l2_init(struct rfid_reader_handle *rh, enum rfid_layer2_id l2);
int _rdr_rc632_mifare_setkey(struct rfid_reader_handle *rh, const u_int8_t *key);
+int _rdr_rc632_mifare_setkey_ee(struct rfid_reader_handle *rh, const unsigned int addr);
int _rdr_rc632_mifare_auth(struct rfid_reader_handle *rh, u_int8_t cmd,
u_int32_t serno, u_int8_t block);
int _rdr_rc632_getopt(struct rfid_reader_handle *rh, int optname,
},
.mifare_classic = {
.setkey = &_rdr_rc632_mifare_setkey,
+ .setkey_ee = &_rdr_rc632_mifare_setkey_ee,
.auth = &_rdr_rc632_mifare_auth,
},
};