Adding iso14443b_crc_append()
This commit is contained in:
parent
bb5b712a74
commit
c3a5fba028
2 changed files with 35 additions and 2 deletions
|
@ -135,6 +135,8 @@ NFC_EXPORT int nfc_device_set_property_bool(nfc_device *pnd, const nfc_property
|
|||
/* Misc. functions */
|
||||
NFC_EXPORT void iso14443a_crc(uint8_t *pbtData, size_t szLen, uint8_t *pbtCrc);
|
||||
NFC_EXPORT void iso14443a_crc_append(uint8_t *pbtData, size_t szLen);
|
||||
NFC_EXPORT void iso14443b_crc(uint8_t *pbtData, size_t szLen, uint8_t *pbtCrc);
|
||||
NFC_EXPORT void iso14443b_crc_append(uint8_t *pbtData, size_t szLen);
|
||||
NFC_EXPORT uint8_t *iso14443a_locate_historical_bytes(uint8_t *pbtAts, size_t szAts, size_t *pszTk);
|
||||
|
||||
NFC_EXPORT void nfc_free(void *p);
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
|
||||
|
||||
/**
|
||||
* @brief CRC
|
||||
* @brief CRC_A
|
||||
*
|
||||
*/
|
||||
void
|
||||
|
@ -62,7 +62,7 @@ iso14443a_crc(uint8_t *pbtData, size_t szLen, uint8_t *pbtCrc)
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief Append CRC
|
||||
* @brief Append CRC_A
|
||||
*
|
||||
*/
|
||||
void
|
||||
|
@ -71,6 +71,37 @@ iso14443a_crc_append(uint8_t *pbtData, size_t szLen)
|
|||
iso14443a_crc(pbtData, szLen, pbtData + szLen);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CRC_B
|
||||
*
|
||||
*/
|
||||
void
|
||||
iso14443b_crc(uint8_t *pbtData, size_t szLen, uint8_t *pbtCrc)
|
||||
{
|
||||
uint8_t bt;
|
||||
uint32_t wCrc = 0xFFFF;
|
||||
|
||||
do {
|
||||
bt = *pbtData++;
|
||||
bt = (bt ^ (uint8_t)(wCrc & 0x00FF));
|
||||
bt = (bt ^ (bt << 4));
|
||||
wCrc = (wCrc >> 8) ^ ((uint32_t) bt << 8) ^ ((uint32_t) bt << 3) ^ ((uint32_t) bt >> 4);
|
||||
} while (--szLen);
|
||||
wCrc = ~wCrc;
|
||||
*pbtCrc++ = (uint8_t)(wCrc & 0xFF);
|
||||
*pbtCrc = (uint8_t)((wCrc >> 8) & 0xFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Append CRC_B
|
||||
*
|
||||
*/
|
||||
void
|
||||
iso14443b_crc_append(uint8_t *pbtData, size_t szLen)
|
||||
{
|
||||
iso14443b_crc(pbtData, szLen, pbtData + szLen);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Locate historical bytes
|
||||
* @see ISO/IEC 14443-4 (5.2.7 Historical bytes)
|
||||
|
|
Loading…
Reference in a new issue