하드웨어/rfid_nfc_smartcard

libpcsclite 라이브러리

구차니 2025. 2. 14. 11:47

pcsc_scan 프로그램에서 정체를(?) 알 수 없는 함수들이 있어서 찾아보는데

libpcsclite 쪽 거였다. 별다르게 include 하는 것도 없어 보였는데 wincard.h 가 그거였던 듯..

그나저나 이름이나 변수타입 등등 윈도우 버전을 거의 그대로 옮긴 느낌이 강하네..

 

API 목록

$ readelf -a libpcsclite.so.1.0.0
The decoding of unwind sections for machine type AArch64 is not currently supported.

Symbol table '.dynsym' contains 77 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND 
     1: 0000000000001638     0 SECTION LOCAL  DEFAULT   10 .init
     2: 000000000001b000     0 SECTION LOCAL  DEFAULT   22 .data
     3: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memcpy@GLIBC_2.17 (2)
     4: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strlen@GLIBC_2.17 (2)
     5: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND _ITM_deregisterT[...]
     6: 0000000000000000     0 FUNC    WEAK   DEFAULT  UND _[...]@GLIBC_2.17 (2)
     7: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND p[...]@GLIBC_2.17 (2)
     8: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  UND stderr@GLIBC_2.17 (2)
     9: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND kill@GLIBC_2.17 (2)
    10: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fileno@GLIBC_2.17 (2)
    11: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND _[...]@GLIBC_2.17 (2)
    12: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND _[...]@GLIBC_2.17 (2)
    13: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND _[...]@GLIBC_2.17 (2)
    14: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND time@GLIBC_2.17 (2)
    15: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND malloc@GLIBC_2.17 (2)
    16: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND open@GLIBC_2.17 (2)
    17: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND poll@GLIBC_2.17 (2)
    18: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND p[...]@GLIBC_2.17 (2)
    19: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memset@GLIBC_2.17 (2)
    20: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND g[...]@GLIBC_2.17 (2)
    21: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND p[...]@GLIBC_2.17 (2)
    22: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND s[...]@GLIBC_2.17 (2)
    23: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND rand@GLIBC_2.17 (2)
    24: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strdup@GLIBC_2.17 (2)
    25: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND s[...]@GLIBC_2.17 (2)
    26: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND _[...]@GLIBC_2.17 (2)
    27: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND p[...]@GLIBC_2.17 (2)
    28: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND close@GLIBC_2.17 (2)
    29: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND __gmon_start__
    30: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND stat@GLIBC_2.33 (3)
    31: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  UND _[...]@GLIBC_2.17 (4)
    32: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND _[...]@GLIBC_2.17 (2)
    33: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strcmp@GLIBC_2.17 (2)
    34: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strtol@GLIBC_2.17 (2)
    35: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND free@GLIBC_2.17 (2)
    36: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND n[...]@GLIBC_2.17 (2)
    37: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND send@GLIBC_2.17 (2)
    38: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND c[...]@GLIBC_2.17 (2)
    39: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND p[...]@GLIBC_2.34 (5)
    40: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fcntl@GLIBC_2.17 (2)
    41: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND socket@GLIBC_2.17 (2)
    42: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND p[...]@GLIBC_2.17 (2)
    43: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strcpy@GLIBC_2.17 (2)
    44: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND read@GLIBC_2.17 (2)
    45: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND isatty@GLIBC_2.17 (2)
    46: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND srand@GLIBC_2.17 (2)
    47: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND s[...]@GLIBC_2.17 (2)
    48: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND _ITM_registerTMC[...]
    49: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND _[...]@GLIBC_2.17 (2)
    50: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND getenv@GLIBC_2.17 (2)
    51: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND p[...]@GLIBC_2.17 (2)
    52: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND p[...]@GLIBC_2.17 (2)
    53: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND p[...]@GLIBC_2.34 (5)
    54: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND p[...]@GLIBC_2.34 (5)
    55: 0000000000004170   196 FUNC    GLOBAL DEFAULT   12 SCardGetAttrib
    56: 0000000000004990   324 FUNC    GLOBAL DEFAULT   12 SCardCancel
    57: 0000000000004ad4   160 FUNC    GLOBAL DEFAULT   12 SCardIsValidContext
    58: 00000000000027a0   608 FUNC    GLOBAL DEFAULT   12 SCardConnect
    59: 0000000000003f90   472 FUNC    GLOBAL DEFAULT   12 SCardControl
    60: 0000000000004234    80 FUNC    GLOBAL DEFAULT   12 SCardSetAttrib
    61: 0000000000002db0   416 FUNC    GLOBAL DEFAULT   12 SCardBeginTransaction
    62: 0000000000003094  1168 FUNC    GLOBAL DEFAULT   12 SCardStatus
    63: 0000000000008478    16 OBJECT  GLOBAL DEFAULT   14 g_rgSCardT0Pci
    64: 0000000000002a00   488 FUNC    GLOBAL DEFAULT   12 SCardReconnect
    65: 0000000000004560   548 FUNC    GLOBAL DEFAULT   12 SCardListReaders
    66: 0000000000008458    16 OBJECT  GLOBAL DEFAULT   14 g_rgSCardRawPci
    67: 0000000000004834   348 FUNC    GLOBAL DEFAULT   12 SCardListReaderGroups
    68: 0000000000002bf0   448 FUNC    GLOBAL DEFAULT   12 SCardDisconnect
    69: 0000000000003524  2668 FUNC    GLOBAL DEFAULT   12 SCardGetStatusChange
    70: 0000000000004784   176 FUNC    GLOBAL DEFAULT   12 SCardFreeMemory
    71: 0000000000002540   600 FUNC    GLOBAL DEFAULT   12 SCardReleaseContext
    72: 0000000000008468    16 OBJECT  GLOBAL DEFAULT   14 g_rgSCardT1Pci
    73: 0000000000004284   724 FUNC    GLOBAL DEFAULT   12 SCardTransmit
    74: 0000000000001d40   832 FUNC    GLOBAL DEFAULT   12 pcsc_stringify_error
    75: 0000000000004c30  1120 FUNC    GLOBAL DEFAULT   12 SCardEstablishContext
    76: 0000000000002f50   324 FUNC    GLOBAL DEFAULT   12 SCardEndTransaction

[링크 : https://pcsclite.apdu.fr/api/group__API.html]

 

+

리더기에 다이렉트로 붙이려면 SCARD_SHARE_DIRECT로 해서 명령을 보내라는데...

(난 카드의 시리얼을 받고 싶었고, 이 글은 리더기의 시리얼을 받고 싶어하고)

You should be using:

lReturn = SCardConnect(hResManager,szAvailRdr,SCARD_SHARE_SHARED,
                            SCARD_PROTOCOL_T1,
                            &hCardHandle,
                            &dwActProtocol);
Instead, try using:

lReturn = SCardConnect(hResManager,szAvailRdr,SCARD_SHARE_DIRECT,
                      NULL,
                      &hCardHandle,
                      NULL);
where szAvailRdr refers to the reader name (smartcard readername) and hCardHandle is a handle obtained before using scardconnect.

This should keep you going!

[링크 : https://stackoverflow.com/questions/6940824/getting-pcsc-reader-serial-number-with-winscard]

 

sector / block 개념으로 1k 데이터를 쓸수 있다고.

그러면 serial은 어디서 빼내지?

[링크 : https://you-rang.tistory.com/243]

[링크 : https://blog.naver.com/intopion/221613937290]