mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-07-22 01:08:11 -07:00
Merge branch 'flipperdevices:dev' into dev
This commit is contained in:
@@ -304,7 +304,7 @@ void hash0(uint64_t c, uint8_t k[8]) {
|
||||
* @param key
|
||||
* @param div_key
|
||||
*/
|
||||
void diversifyKey(uint8_t *csn, uint8_t *key, uint8_t *div_key) {
|
||||
void diversifyKey(uint8_t *csn, const uint8_t *key, uint8_t *div_key) {
|
||||
// Prepare the DES key
|
||||
mbedtls_des_setkey_enc(&ctx_enc, key);
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ void hash0(uint64_t c, uint8_t k[8]);
|
||||
* @param div_key
|
||||
*/
|
||||
|
||||
void diversifyKey(uint8_t *csn, uint8_t *key, uint8_t *div_key);
|
||||
void diversifyKey(uint8_t *csn, const uint8_t *key, uint8_t *div_key);
|
||||
/**
|
||||
* @brief Permutes a key from standard NIST format to Iclass specific format
|
||||
* @param key
|
||||
|
||||
@@ -198,7 +198,7 @@ static bool mf_classic_is_allowed_access(
|
||||
|
||||
bool mf_classic_check_card_type(uint8_t ATQA0, uint8_t ATQA1, uint8_t SAK) {
|
||||
UNUSED(ATQA1);
|
||||
if((ATQA0 == 0x44 || ATQA0 == 0x04) && (SAK == 0x08 || SAK == 0x88)) {
|
||||
if((ATQA0 == 0x44 || ATQA0 == 0x04) && (SAK == 0x08 || SAK == 0x88 || SAK == 0x09)) {
|
||||
return true;
|
||||
} else if((ATQA0 == 0x42 || ATQA0 == 0x02) && (SAK == 0x18)) {
|
||||
return true;
|
||||
@@ -219,7 +219,7 @@ bool mf_classic_get_type(
|
||||
furi_assert(reader);
|
||||
memset(reader, 0, sizeof(MfClassicReader));
|
||||
|
||||
if((ATQA0 == 0x44 || ATQA0 == 0x04) && (SAK == 0x08 || SAK == 0x88)) {
|
||||
if((ATQA0 == 0x44 || ATQA0 == 0x04) && (SAK == 0x08 || SAK == 0x88 || SAK == 0x09)) {
|
||||
reader->type = MfClassicType1k;
|
||||
} else if((ATQA0 == 0x42 || ATQA0 == 0x02) && (SAK == 0x18)) {
|
||||
reader->type = MfClassicType4k;
|
||||
@@ -386,11 +386,25 @@ bool mf_classic_read_block(
|
||||
tx_rx->tx_rx_type = FuriHalNfcTxRxTypeRaw;
|
||||
|
||||
if(furi_hal_nfc_tx_rx(tx_rx, 50)) {
|
||||
if(tx_rx->rx_bits == 8 * 18) {
|
||||
for(uint8_t i = 0; i < 18; i++) {
|
||||
block->value[i] = crypto1_byte(crypto, 0, 0) ^ tx_rx->rx_data[i];
|
||||
if(tx_rx->rx_bits == 8 * (MF_CLASSIC_BLOCK_SIZE + 2)) {
|
||||
uint8_t block_received[MF_CLASSIC_BLOCK_SIZE + 2];
|
||||
for(uint8_t i = 0; i < MF_CLASSIC_BLOCK_SIZE + 2; i++) {
|
||||
block_received[i] = crypto1_byte(crypto, 0, 0) ^ tx_rx->rx_data[i];
|
||||
}
|
||||
uint16_t crc_calc = nfca_get_crc16(block_received, MF_CLASSIC_BLOCK_SIZE);
|
||||
uint16_t crc_received = (block_received[MF_CLASSIC_BLOCK_SIZE + 1] << 8) |
|
||||
block_received[MF_CLASSIC_BLOCK_SIZE];
|
||||
if(crc_received != crc_calc) {
|
||||
FURI_LOG_E(
|
||||
TAG,
|
||||
"Incorrect CRC while reading block %d. Expected %04X, Received %04X",
|
||||
block_num,
|
||||
crc_received,
|
||||
crc_calc);
|
||||
} else {
|
||||
memcpy(block->value, block_received, MF_CLASSIC_BLOCK_SIZE);
|
||||
read_block_success = true;
|
||||
}
|
||||
read_block_success = true;
|
||||
}
|
||||
}
|
||||
return read_block_success;
|
||||
|
||||
@@ -6,7 +6,7 @@ MifareType mifare_common_get_type(uint8_t ATQA0, uint8_t ATQA1, uint8_t SAK) {
|
||||
if((ATQA0 == 0x44) && (ATQA1 == 0x00) && (SAK == 0x00)) {
|
||||
type = MifareTypeUltralight;
|
||||
} else if(
|
||||
((ATQA0 == 0x44 || ATQA0 == 0x04) && (SAK == 0x08 || SAK == 0x88)) ||
|
||||
((ATQA0 == 0x44 || ATQA0 == 0x04) && (SAK == 0x08 || SAK == 0x88 || SAK == 0x09)) ||
|
||||
((ATQA0 == 0x42 || ATQA0 == 0x02) && (SAK == 0x18))) {
|
||||
type = MifareTypeClassic;
|
||||
} else if(ATQA0 == 0x44 && ATQA1 == 0x03 && SAK == 0x20) {
|
||||
|
||||
Reference in New Issue
Block a user