'하드웨어'에 해당되는 글 652건

  1. 2025.03.18 libpcsclite on cpp
  2. 2025.03.17 NDEF 데이터 읽기
  3. 2025.03.17 ntag 213, 215 그리고 13.25MHz CUID 카드
  4. 2025.03.17 SCardListReadersA 함수(winscard.h)
  5. 2025.03.12 NTAG
  6. 2025.03.11 NDEF 읽기
  7. 2025.03.11 mifare desfire 인증 프로세스
  8. 2025.02.28 libnfc, libfreefare
  9. 2025.02.28 ATQA, SAK
  10. 2025.02.28 pcsc pseudo APDU

음.. 흐음...

char *의 포인터를 넘겨줘야 하는데 에러가 난다 머지?

char *mszReaders = NULL;
DWORD dwReaderLen = SCARD_AUTOALLOCATE;
rv = SCardListReaders(hContext, (LPCSTR)NULL, &mszReaders, &dwReaderLen);

 

그래서 강제로 하면 이렇게 에러가 나는데

error: cannot convert ‘char**’ to ‘LPSTR’ {aka ‘char*’}
  103 |     rv = SCardListReaders(hContext, (LPCSTR)NULL, &mszReaders, &dwReaderLen);
      |                                                   ^~~~~~~~~~~
      |                                                   |
      |                                                   char**

 

아래처럼 변수를 미리 선언해서 자동할당 하지 않게 하거나

char mszReaders[255];
DWORD dwReaderLen = sizeof(mszReaders); // SCARD_AUTOALLOCATE;
rv = SCardListReaders(hContext, (LPCSTR)NULL, mszReaders, &dwReaderLen);

 

아래 처럼 강제 형변환을 해주어서 2중 포인터가 아닌 것으로 속여주면 된다.

char *mszReaders = NULL;
DWORD dwReaderLen = SCARD_AUTOALLOCATE;
rv = SCardListReaders(hContext, NULL, (char*)&mszReaders, &dwReaderLen);

 

해결은 되었는데 해결책 같은 느낌이 하나도 안드네..

'하드웨어 > rfid_nfc_smartcard' 카테고리의 다른 글

NDEF 데이터 읽기  (0) 2025.03.17
ntag 213, 215 그리고 13.25MHz CUID 카드  (0) 2025.03.17
SCardListReadersA 함수(winscard.h)  (0) 2025.03.17
NTAG  (0) 2025.03.12
NDEF 읽기  (0) 2025.03.11
Posted by 구차니

claude로 찾아낸 APDU

 

NDEF application을 선택하고 (고정)

파일을 선택하고 (고정)

파일의 길이를 읽고(고정, 리턴 short)

파일을 읽는다(오프셋short + 길이byte)

읽을때는 읽는 길이 + 2 만큼의 버퍼가 필요하다 (끝의 확인 90 00 때문에)

 

BYTE selectNDEF[] = {0x00, 0xA4, 0x04, 0x00, 0x07, 0xD2, 0x76, 0x00, 0x00, 0x85, 0x01, 0x01, 0x00};
BYTE selectFILE[] = {0x00, 0xA4, 0x00, 0x0C, 0x02, 0xE1, 0x04};
BYTE lengthNDEF[] = {0x00, 0xB0, 0x00, 0x00, 0x02};
BYTE readNDEF[] = {0x00, 0xB0, 오프셋HIGH, 오프셋LOW, 길이BYTE}

 

'하드웨어 > rfid_nfc_smartcard' 카테고리의 다른 글

libpcsclite on cpp  (0) 2025.03.18
ntag 213, 215 그리고 13.25MHz CUID 카드  (0) 2025.03.17
SCardListReadersA 함수(winscard.h)  (0) 2025.03.17
NTAG  (0) 2025.03.12
NDEF 읽기  (0) 2025.03.11
Posted by 구차니

NTAG213 / 215는 ATR이 동일하다.

213 쪽은 ic type이 안뜨는 대신 제조사가 뜨네..?

EXTRA에서 213은 Version information이 안뜨다니..

 


NTAG 213

Mon Mar 17 13:59:48 2025
 Reader 0: ACS ACR1252 Dual Reader [ACR1252 Dual Reader PICC] 00 00
  Event number: 5
  Card state: Card inserted, 
  ATR: 3B 8F 80 01 80 4F 0C A0 00 00 03 06 03 00 03 00 00 00 00 68

ATR: 3B 8F 80 01 80 4F 0C A0 00 00 03 06 03 00 03 00 00 00 00 68
+ TS = 3B --> Direct Convention
+ T0 = 8F, Y(1): 1000, K: 15 (historical bytes)
  TD(1) = 80 --> Y(i+1) = 1000, Protocol T = 0 
-----
  TD(2) = 01 --> Y(i+1) = 0000, Protocol T = 1 
-----
+ Historical bytes: 80 4F 0C A0 00 00 03 06 03 00 03 00 00 00 00
  Category indicator byte: 80 (compact TLV data object)
    Tag: 4, len: F (initial access data)
      Initial access data: 0C A0 00 00 03 06 03 00 03 00 00 00 00
+ TCK = 68 (correct checksum)

Possibly identified card (using /usr/share/pcsc/smartcard_list.txt):
3B 8F 80 01 80 4F 0C A0 00 00 03 06 03 00 03 00 00 00 00 68
3B 8F 80 01 80 4F 0C A0 00 00 03 06 .. 00 03 00 00 00 00 ..
MIFARE Ultralight (as per PCSC std part3)
3B 8F 80 01 80 4F 0C A0 00 00 03 06 03 00 03 00 00 00 00 68
3B 8F 80 01 80 4F 0C A0 00 00 03 06 03 .. .. 00 00 00 00 ..
RFID - ISO 14443 Type A Part 3 (as per PCSC std part3)
3B 8F 80 01 80 4F 0C A0 00 00 03 06 03 00 03 00 00 00 00 68
RFID - ISO 14443 Type A - NXP Mifare Ultralight or UltralightC
   
Mon Mar 17 13:59:49 2025
 Reader 0: ACS ACR1252 Dual Reader [ACR1252 Dual Reader PICC] 00 00
  Event number: 6
  Card state: Card removed, 

 

NTAG 215

Mon Mar 17 14:00:34 2025
 Reader 0: ACS ACR1252 Dual Reader [ACR1252 Dual Reader PICC] 00 00
  Event number: 7
  Card state: Card inserted, 
  ATR: 3B 8F 80 01 80 4F 0C A0 00 00 03 06 03 00 03 00 00 00 00 68

ATR: 3B 8F 80 01 80 4F 0C A0 00 00 03 06 03 00 03 00 00 00 00 68
+ TS = 3B --> Direct Convention
+ T0 = 8F, Y(1): 1000, K: 15 (historical bytes)
  TD(1) = 80 --> Y(i+1) = 1000, Protocol T = 0 
-----
  TD(2) = 01 --> Y(i+1) = 0000, Protocol T = 1 
-----
+ Historical bytes: 80 4F 0C A0 00 00 03 06 03 00 03 00 00 00 00
  Category indicator byte: 80 (compact TLV data object)
    Tag: 4, len: F (initial access data)
      Initial access data: 0C A0 00 00 03 06 03 00 03 00 00 00 00
+ TCK = 68 (correct checksum)

Possibly identified card (using /usr/share/pcsc/smartcard_list.txt):
3B 8F 80 01 80 4F 0C A0 00 00 03 06 03 00 03 00 00 00 00 68
3B 8F 80 01 80 4F 0C A0 00 00 03 06 .. 00 03 00 00 00 00 ..
MIFARE Ultralight (as per PCSC std part3)
3B 8F 80 01 80 4F 0C A0 00 00 03 06 03 00 03 00 00 00 00 68
3B 8F 80 01 80 4F 0C A0 00 00 03 06 03 .. .. 00 00 00 00 ..
RFID - ISO 14443 Type A Part 3 (as per PCSC std part3)
3B 8F 80 01 80 4F 0C A0 00 00 03 06 03 00 03 00 00 00 00 68
RFID - ISO 14443 Type A - NXP Mifare Ultralight or UltralightC
   
Mon Mar 17 14:00:35 2025
 Reader 0: ACS ACR1252 Dual Reader [ACR1252 Dual Reader PICC] 00 00
  Event number: 8
  Card state: Card removed, 

 

13.56MHz CUID 카드

Mon Mar 17 14:01:11 2025
 Reader 0: ACS ACR1252 Dual Reader [ACR1252 Dual Reader PICC] 00 00
  Event number: 9
  Card state: Card inserted, 
  ATR: 3B 8F 80 01 80 4F 0C A0 00 00 03 06 03 00 01 00 00 00 00 6A

ATR: 3B 8F 80 01 80 4F 0C A0 00 00 03 06 03 00 01 00 00 00 00 6A
+ TS = 3B --> Direct Convention
+ T0 = 8F, Y(1): 1000, K: 15 (historical bytes)
  TD(1) = 80 --> Y(i+1) = 1000, Protocol T = 0 
-----
  TD(2) = 01 --> Y(i+1) = 0000, Protocol T = 1 
-----
+ Historical bytes: 80 4F 0C A0 00 00 03 06 03 00 01 00 00 00 00
  Category indicator byte: 80 (compact TLV data object)
    Tag: 4, len: F (initial access data)
      Initial access data: 0C A0 00 00 03 06 03 00 01 00 00 00 00
+ TCK = 6A (correct checksum)

Possibly identified card (using /usr/share/pcsc/smartcard_list.txt):
3B 8F 80 01 80 4F 0C A0 00 00 03 06 03 00 01 00 00 00 00 6A
3B 8F 80 01 80 4F 0C A0 00 00 03 06 .. 00 01 00 00 00 00 ..
MIFARE Classic 1K (as per PCSC std part3)
3B 8F 80 01 80 4F 0C A0 00 00 03 06 03 00 01 00 00 00 00 6A
3B 8F 80 01 80 4F 0C A0 00 00 03 06 03 .. .. 00 00 00 00 ..
RFID - ISO 14443 Type A Part 3 (as per PCSC std part3)
3B 8F 80 01 80 4F 0C A0 00 00 03 06 03 00 01 00 00 00 00 6A
NXP/Philips MIFARE Classic 1K (as per PCSC std part3)
http://www.nxp.com/#/pip/pip=[pfp=41863]|pp=[t=pfp,i=41863]
Oyster card - Transport for London (first-gen)
https://en.wikipedia.org/wiki/Oyster_card
ACOS5/1k Mirfare
vivotech ViVOcard Contactless Test Card
Bangkok BTS Sky SmartPass
Mifare Classic 1K (block 0 re-writeable)
Electic vehicle charging card of the German Telekom, acting as EMSP GetCharge
Electic vehicle charging card of the EMSP Stadtwerke Muenchen (SWM), ladenetz.de, Germany
Electic vehicle charging card of the EMSP EinfachStromLaden of Maingau-Energie, Germany
Scouter carsharing customer card in Germany
https://scouter.de/
   
Mon Mar 17 14:01:11 2025
 Reader 0: ACS ACR1252 Dual Reader [ACR1252 Dual Reader PICC] 00 00
  Event number: 10
  Card state: Card removed,

'하드웨어 > rfid_nfc_smartcard' 카테고리의 다른 글

libpcsclite on cpp  (0) 2025.03.18
NDEF 데이터 읽기  (0) 2025.03.17
SCardListReadersA 함수(winscard.h)  (0) 2025.03.17
NTAG  (0) 2025.03.12
NDEF 읽기  (0) 2025.03.11
Posted by 구차니

특이하다면 특이한 함수인데

mszReaders 변수의 길이를 포인터인 pcchReaders에 넘겨주어야지 정상적으로 작동한다.

LONG SCardListReadersA(
  [in]           SCARDCONTEXT hContext,
  [in, optional] LPCSTR       mszGroups,
  [out]          LPSTR        mszReaders,
  [in, out]      LPDWORD      pcchReaders
);

 

그래서 조금 편하게 쓰라고 SCARD_AUTOALLOCATE (-1)을 해주면 알아서 할당해서 던져주는 듯.

LPTSTR          pmszReaders = NULL;
LPTSTR          pReader;
LONG            lReturn, lReturn2;
DWORD           cch = SCARD_AUTOALLOCATE;

// Retrieve the list the readers.
// hSC was set by a previous call to SCardEstablishContext.
lReturn = SCardListReaders(hSC,
                           NULL,
                           (LPTSTR)&pmszReaders,
                           &cch );

[링크 : https://learn.microsoft.com/ko-kr/windows/win32/api/winscard/nf-winscard-scardlistreadersa]

'하드웨어 > rfid_nfc_smartcard' 카테고리의 다른 글

NDEF 데이터 읽기  (0) 2025.03.17
ntag 213, 215 그리고 13.25MHz CUID 카드  (0) 2025.03.17
NTAG  (0) 2025.03.12
NDEF 읽기  (0) 2025.03.11
mifare desfire 인증 프로세스  (0) 2025.03.11
Posted by 구차니

옥션에서 먼가 구매하려고 보다 보니

NTAG 213 / 215를 따로 팔고 있길래 먼가 해서 검색

얘는.. RFID 리더는 못 읽고 NFC 리더에서만 읽을수 있으려나?

 

NTAG203 : 보급형,  137 bytes , 다양한 형태로 사용이 가능하다.
NTAG212 : 메모리사이즈가 128 bytes. NTAG203를 개선하여 속도나 거리에서 개선된 제품.
NTAG213 : 읽기 속도 개선, 메모리 사이즈가 144 bytes. 암호 보호, 가격도 싸고 성능도 좋다.
NTAG215 : 메모리 사이즈가 504 bytes, 암호 보호 기능 강화.
NTAG216 : 메모리 사이즈가 888 bytes. 속도는 빠르나 가격이 비싸다.

[링크 : https://blog.naver.com/iamsmartin/220727540584]

 

14443 Type A 를 충족한다고 하면 acr1252u 로도 읽힐 것 같네?

NTAG® 213/215/216: NFC Forum Type 2 Tag Compliant IC with 144/504/888 Bytes User Memory

NTAG 213, NTAG 215, and NTAG 216 have been developed by NXP® Semiconductors as standard NFC tag ICs to be used in mass-market applications such as retail, gaming, and consumer electronics, in combination with NFC devices or NFC-compliant Proximity Coupling Devices. NTAG 213, NTAG 215, and NTAG 216 (from now on, generally called NTAG 21x) are designed to fully comply to NFC Forum Type 2 Tag and ISO/IEC14443 Type A specifications.

[링크 : https://www.nxp.com/products/NTAG213_215_216]

'하드웨어 > rfid_nfc_smartcard' 카테고리의 다른 글

ntag 213, 215 그리고 13.25MHz CUID 카드  (0) 2025.03.17
SCardListReadersA 함수(winscard.h)  (0) 2025.03.17
NDEF 읽기  (0) 2025.03.11
mifare desfire 인증 프로세스  (0) 2025.03.11
libnfc, libfreefare  (0) 2025.02.28
Posted by 구차니

아니.. chatGPT로는 못했는데 claude 만세 -_ㅠ

 

What are these commands?
The first command (90 60 00 00 00) is a MIFARE DESFire GetVersion command (wrapped command set). This seems to be specific to the NXP-based Android NFC stack and is not part of a typical NFC tag detection procedure.
The second command (00 A4 04 00 07 D2 76 00 00 85 01 01 00) is a SELECT APDU that tries to select the NFC Forum Type 4 tag application (version 2.0) by its AID. This is part of the typical tag detection procedure for ISO 14443-4 (ISO-DEP) based tags/smartcards.
Why are these commands sent before apps are notified about the presence of a tag and even if no app is active at all?
A typical NFC device will automatically discover the presence of NFC tags that contain NDEF messages. Usually such NDEF messages then trigger actions on the device (e.g. start an app). As your tag seems to be an ISO 14443-4 (ISO-DEP) compliant tag/smartcard, the NDEF discovery procedure for an NFC Forum Type 4 tag is started. This procedure normally contains of the following steps:
  1. Select the NFC Forum Type 4 tag application (version 2.0)
  2. If application selection is successful, continue with reading the capability container file and the NDEF data file.
  3. If application selection fails, continue with selecting the NFC Forum Type 4 tag application (version 1.0)
  4. If application selection is successful, continue with reading the capability container file and the NDEF data file.
  5. If application selection fails, tag is not an NFC Forum Type 4 tag.
  6. Typically the connection to the tag is reset at this point so that any communication that an app performs with a tag is started right after a fresh activation of the tag.
The additional command before step 1 indicates that the NXP's NFC stack additionally tries to find out if the Type 4 tag is an NXP product (NXP's MIFARE DESFire or DESFIRE EV1). It is not related to peer-to-peer mode protocols.
Remark on the Broadcom NFC stack: There is a known issue that seems to still exist on Android 4.4: Even after the tag is passed to an app and the app started IsoDep communication the NFC stack arbitrarily sends READ BINARY commands interleaved with the app's communication. This frequently results into protocol errors due to invalid command sequences. This does not happen with NXP's NFC stack.
Can I prevent this initial processing of a tag?
Yes, but only since Android 4.4. On that platform you can use the NfcAdapter's enableReaderMode method to bring the device into a reader mode without NDEF discovery.

[링크 : https://stackoverflow.com/questions/21121149/bytes-automatically-send-by-android-nfc-to-an-emulated-card]

 

8. MIFARE DESFire EV1 GetVersion command 1
Command: 90 60 00 00 00h
Expected Response: XX XX XX XX XX XX XX 91 AFh

9. MIFARE DESFire EV1 GetVersion command 2. The Storage Size code (SS) value indicates the storage size, in particular: 1Ah indicates 8192 bytes, 18h indicates 4096 bytes and 16h indicates 2048 bytes
Command: 90 AF 00 00 00h
Expected Response: XX XX XX SW XX SS XX 91 AFh

10. MIFARE DESFire EV1 GetVersion command 3
Command: 90 AF 00 00 00h
11. Expected Response: XX XX XX XX XX XX XX XX XX XX XX XX XX 91 00

[링크 : https://www.nxp.com/docs/en/application-note/AN11004.pdf]

'하드웨어 > rfid_nfc_smartcard' 카테고리의 다른 글

SCardListReadersA 함수(winscard.h)  (0) 2025.03.17
NTAG  (0) 2025.03.12
mifare desfire 인증 프로세스  (0) 2025.03.11
libnfc, libfreefare  (0) 2025.02.28
ATQA, SAK  (0) 2025.02.28
Posted by 구차니

검색하다 보니 먼가.. DES가 들어갔듯

무언가 인증 절차가 있는 것 같은데 NDEF도 이 영향을 받는건가?

 

MIFARE DESFire 인증 프로세스:
  1. 카드 리더는 통신을 시작하기 위해 MIFARE DESFire 카드에 요청을 보냅니다.
  2. 카드는 고유 식별자(UID)와 지원되는 명령 목록으로 응답합니다.
  3. 리더는 마스터 키 또는 애플리케이션 키와 같은 특정 키를 사용하여 카드 인증 요청을 보냅니다.
  4. 카드는 지정된 키를 사용하여 암호화된 난수(챌린지)로 응답합니다.
  5. 판독기는 동일한 키를 사용하여 챌린지를 해독하고 결과를 다시 카드로 보냅니다.
  6. 카드는 응답을 확인하고 성공하면 인증 상태를 판독기로 다시 보냅니다.
  7. 판독기는 이제 카드에 명령을 보내 데이터 읽기 또는 쓰기와 같은 특정 작업을 수행할 수 있습니다.
인증 프로세스는 MIFARE 기술의 특정 구현 및 애플리케이션의 보안 요구 사항에 따라 다를 수 있습니다. 또한 최신 MIFARE 카드는 고급 암호화 알고리즘과 인증 방법을 사용하여 보안을 강화할 수 있습니다.

[링크 : http://ko.as-rfid.com/info/what-is-the-authentication-process-of-mifare-81733128.html]

'하드웨어 > rfid_nfc_smartcard' 카테고리의 다른 글

NTAG  (0) 2025.03.12
NDEF 읽기  (0) 2025.03.11
libnfc, libfreefare  (0) 2025.02.28
ATQA, SAK  (0) 2025.02.28
pcsc pseudo APDU  (0) 2025.02.28
Posted by 구차니

mifare 쪽 라이브러리인데

내가 사용중인 USB ACR1252U는 nfc-list 유틸에서 검색되지 않는다.

$ nfc-scan-device 
nfc-scan-device uses libnfc 1.8.0
No NFC device found.

$ nfc-list 
nfc-list uses libnfc 1.8.0
No NFC device found.

 

libpcsclite 로는 되는데 어떻게 해야하나 찾아보는데..

aarch64 쪽으로만 등록이 되어있는지 해당 패키지가 x64 ubuntu에서는 검색이 안된다.

HamadiSan on Jan 12, 2023
So, nfc-list now detects ACR1252u after "sudo apt-get install libacr38u" on raspberry-pi.

[링크 : https://github.com/nfc-tools/libnfc/issues/658]

[링크 : https://github.com/nfc-tools/libfreefare]

 

걍 속편하게 포기(!)

'하드웨어 > rfid_nfc_smartcard' 카테고리의 다른 글

NDEF 읽기  (0) 2025.03.11
mifare desfire 인증 프로세스  (0) 2025.03.11
ATQA, SAK  (0) 2025.02.28
pcsc pseudo APDU  (0) 2025.02.28
Mirafe DESFire EV3 record  (0) 2025.02.27
Posted by 구차니

ATQA - Answer To reQuest code A

ATQA(Answer To reQuest code A)는 NFC(Near Field Communication) 기술의 2바이트 코드로 NFC 리더와 통신하는 RFID 태그 또는 장치의 유형을 식별하는 데 사용됩니다. NFC 리더가 근처의 태그 또는 장치와 통신하기 위해 신호를 보내면 태그 또는 장치는 ATQA 코드로 응답하여 자신의 존재와 기능을 나타냅니다.

[링크 : http://ko.as-rfid.com/info/what-is-the-atqa-in-nfc-81733101.html]

 

SAK - Select ACK

SAK는 Select Acknowledge이 약어이며 카드를 구분하기 위해서 사용합니다. SAK = 0x80이면 Mifare 1KB 카드를 의미합니다. 

[링크 : https://m.blog.naver.com/ssshin22/220936072357]

'하드웨어 > rfid_nfc_smartcard' 카테고리의 다른 글

mifare desfire 인증 프로세스  (0) 2025.03.11
libnfc, libfreefare  (0) 2025.02.28
pcsc pseudo APDU  (0) 2025.02.28
Mirafe DESFire EV3 record  (0) 2025.02.27
ATS  (0) 2025.02.27
Posted by 구차니

Class가 FF 면 벤더 지정 명령 혹은 유사 APDU 라고 하는 듯.

그러니까 제조사에서 APDU 형태로 만든 APDU가 아닌 명령

 

'하드웨어 > rfid_nfc_smartcard' 카테고리의 다른 글

libnfc, libfreefare  (0) 2025.02.28
ATQA, SAK  (0) 2025.02.28
Mirafe DESFire EV3 record  (0) 2025.02.27
ATS  (0) 2025.02.27
rfid 태그 UID(시리얼 넘버) 읽기  (0) 2025.02.26
Posted by 구차니