Export ISO14443A CRC function. Thanks to Romain Tartière.
This commit is contained in:
parent
667ba72dbd
commit
a78cae1c15
2 changed files with 9 additions and 3 deletions
|
@ -75,6 +75,7 @@ NFC_EXPORT bool nfc_target_send_dep_bytes(const nfc_device_t* pnd, const byte_t*
|
||||||
NFC_EXPORT const char* nfc_device_name(nfc_device_t* pnd);
|
NFC_EXPORT const char* nfc_device_name(nfc_device_t* pnd);
|
||||||
|
|
||||||
/* Misc. functions */
|
/* Misc. functions */
|
||||||
|
NFC_EXPORT void iso14443a_crc(byte_t* pbtData, size_t szLen, byte_t* pbtCrc);
|
||||||
NFC_EXPORT const char* nfc_version(void);
|
NFC_EXPORT const char* nfc_version(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -128,7 +128,7 @@ uint64_t swap_endian64(const void* pui64)
|
||||||
return (((ui64N&0xFF)<<56)+((ui64N&0xFF00)<<40)+((ui64N&0xFF0000)<<24)+((ui64N&0xFF000000)<<8)+((ui64N&0xFF00000000ull)>>8)+((ui64N&0xFF0000000000ull)>>24)+((ui64N&0xFF000000000000ull)>>40)+((ui64N&0xFF00000000000000ull)>>56));
|
return (((ui64N&0xFF)<<56)+((ui64N&0xFF00)<<40)+((ui64N&0xFF0000)<<24)+((ui64N&0xFF000000)<<8)+((ui64N&0xFF00000000ull)>>8)+((ui64N&0xFF0000000000ull)>>24)+((ui64N&0xFF000000000000ull)>>40)+((ui64N&0xFF00000000000000ull)>>56));
|
||||||
}
|
}
|
||||||
|
|
||||||
void append_iso14443a_crc(byte_t* pbtData, size_t szLen)
|
void iso14443a_crc(byte_t* pbtData, size_t szLen, byte_t* pbtCrc)
|
||||||
{
|
{
|
||||||
byte_t bt;
|
byte_t bt;
|
||||||
uint32_t wCrc = 0x6363;
|
uint32_t wCrc = 0x6363;
|
||||||
|
@ -140,8 +140,13 @@ void append_iso14443a_crc(byte_t* pbtData, size_t szLen)
|
||||||
wCrc = (wCrc >> 8)^((uint32_t)bt << 8)^((uint32_t)bt<<3)^((uint32_t)bt>>4);
|
wCrc = (wCrc >> 8)^((uint32_t)bt << 8)^((uint32_t)bt<<3)^((uint32_t)bt>>4);
|
||||||
} while (--szLen);
|
} while (--szLen);
|
||||||
|
|
||||||
*pbtData++ = (byte_t) (wCrc & 0xFF);
|
*pbtCrc++ = (byte_t) (wCrc & 0xFF);
|
||||||
*pbtData = (byte_t) ((wCrc >> 8) & 0xFF);
|
*pbtCrc = (byte_t) ((wCrc >> 8) & 0xFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
void append_iso14443a_crc(byte_t* pbtData, size_t szLen)
|
||||||
|
{
|
||||||
|
iso14443a_crc(pbtData, szLen, pbtData + szLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_hex(const byte_t* pbtData, const size_t szBytes)
|
void print_hex(const byte_t* pbtData, const size_t szBytes)
|
||||||
|
|
Loading…
Add table
Reference in a new issue