+
     hE#  c                  s    ^ RI Ht ^ RIt^ RIt^ RIHt ^ RIHtHt ^ RI	H
t
 ^ RIHt ^ RIHt ^RIHtHtHt ^R	IHtHt ^R
IHt RtRtRt^at]P8                  ! ]4      t ! R R]4      tR t R# )    )annotationsN)Event)CallableIterator)System)CardConnection)ListReadersException)STATUS
CtapDevice	CtapError)
CAPABILITYCTAPHID)LOG_LEVEL_TRAFFICs     G/ c                  s0   ] tR t^5tRtR R ltR tR t]R R l4       t	]R R	 l4       t
]R
 R l4       t]R R l4       tR R ltR&R R lltR'R R lltR R ltR'R R lltR R ltR R ltR(R R lltR(R R  lltR! R" lt]R)R# R$ ll4       tR%tR# )*CtapPcscDevicezc
CtapDevice implementation using pyscard (PCSC).

This class is intended for use with NFC readers.
c                    V ^8  d   QhRRRR/# )   
connectionr   namestr Zformat   "//usr/lib/python3.14/site-packages/fido2/pcsc.py__annotate__CtapPcscDevice.__annotate__<   s     7 7> 7 7    c                	sZ   W n         \        ^ 4      V n        RV n        Wn        V P                  4         V P                  \        P                  R4       V ;P                  \        P                  ,          un        R#   \         d"    T P                  '       g   \        R4      h R# i ; i)r    Fs   zUnsupported deviceN)_namer   _capabilitiesuse_ext_apdu_connconnectcallr   CBORr
   
ValueError)selfr   r   s   &&&r   __init__ZCtapPcscDevice.__init__<   s    
']!
	7IIgllG,*//1 	7%%% !566 &	7s   AA> >B*B*)B*c                	sZ    V P                   P                  4        V P                  4        R # N)r   r   _selectr#      &r   r   ZCtapPcscDevice.connectJ   s    

r   c                	s"    R V P                    R2# )zCtapPcscDevice(Z))r   r'   r(   r   __repr__ZCtapPcscDevice.__repr__N   s     A..r   c                   V ^8  d   QhRR/# )r   returnintr   r   r   r   r   r   R   s     A A Ar   c                sH    \         P                  V P                  9   d   ^# ^# )zCTAPHID protocol version.)r   r!   r   r'   r(   r   versionZCtapPcscDevice.versionQ   s      OOt'9'99q@q@r   c               r*   )r   r+   r   r   r   r   r   r   r   W   s     " "j "r   c                s    V P                   # )z%Capabilities supported by the device.)r   r'   r(   r   capabilitiesZCtapPcscDevice.capabilitiesV   s     !!!r   c               r*   )r   r+   z
str | Noner   r   r   r   r   r   \   s      j r   c                    R# )zProduct name of device.Nr   r'   r(   r   product_nameZCtapPcscDevice.product_name[        r   c               r*   )r   r+   
int | Noner   r   r   r   r   r   a   s      z r   c                r/   )zSerial number of device.Nr   r'   r(   r   serial_numberZCtapPcscDevice.serial_number`   r1   r   c               r*   )r   r+   bytesr   r   r   r   r   r   e   s     * * *r   c                sH    \        V P                  P                  4       4      # )z&Get the ATR/ATS of the connected card.)r4   r   ZgetATRr'   r(   r   get_atrZCtapPcscDevice.get_atre   s    TZZ&&())r   Nc               s$    V ^8  d   QhRRRRRR/# )r   apdur4   protocolr2   r+   tuple[bytes, int, int]r   r   r   r   r   r   i   s$     " ""%/"	"r   c                s   \         P                  \        RVP                  4       4       V P                  P                  \        V4      V4      w  r4p\        V4      p\         P                  \        RVP                  4       WE4       WdV3# )z~Exchange data with smart card.

:param apdu: byte string. data to exchange with card
:return: byte string. response from card
zSEND: %szRECV: %s SW=%02X%02X)loggerlogr   hexr   Ztransmitlistr4   )r#   r6   r7   respsw1sw2responses   &&&    r   apdu_exchangeZCtapPcscDevice.apdu_exchangei   sg     	

$j$((*=,,T$ZB3;

$&<hllncWc!!r   c               s$    V ^8  d   QhRRRRRR/# )r   control_coder,   control_datar4   r+   r   r   r   r   r   r   y   s"      S  PU r   c                s
   \         P                  \        RVP                  4       4       V P                  P                  V\        V4      4      p\        V4      p\         P                  \        RVP                  4       4       V# )zSends control sequence to reader's driver.

:param control_code: int. code to send to reader driver.
:param control_data: byte string. data to send to driver
:return: byte string. response
zSend control: %szControl response: %s)r9   r:   r   r;   r   Zcontrolr<   r4   )r#   rB   rC   r@   s   &&& r   control_exchangeZCtapPcscDevice.control_exchangey   s`     	

$&8,:J:J:LM::%%lD4FG?

$&<hllnMr   c               r*   r   r+   ZNoner   r   r   r   r   r      s     2 2 2r   c                	s(   R \         P                  ! R\        \        4      4      ,           \        ,           pV P	                  V4      w  r#pW43\
        8w  d   \        R4      hVR8X  d*   V ;P                  \        P                  ,          un        R# R# )s     !BzFIDO applet selection failure.s   U2F_V2N)
structpacklenAID_FIDO_chained_apdu_exchange
SW_SUCCESSr"   r   r   ZNMSGr#   r6   r=   r>   r?   s   &    r   r&   ZCtapPcscDevice._select   sl    "V[[s8}%EEP44T:3:#=>>9*//1 r   c               s0    V ^8  d   QhRRRRRRRRRRRR	/# )
r   clar,   insp1p2datar4   r+   r8   r   r   r   r   r   r      s<     " "" "&)"/2":?"	"r   c                	s   V P                   '       dB   \        P                  ! R WW4^ \        V4      4      pV P	                  We,           4      w  rxp	WxV	3# \        V4      ^8  dh   VR,          VR,          rZ\        P                  ! R^V,          W#V\        V
4      4      pV P	                  Wj,           4      w  rxp	W3\
        8w  g   Ks  WxV	3# \        P                  ! RWW44      pV'       d/   V\        P                  ! R\        V4      4      V,           ,          pV P	                  VR,           4      w  rxp	V\        8X  d=   R\        P                  ! RV	4      ,           pV P	                  V4      w  rp	W|,          pKG  WxV	3# )z!BBBBBH:N   N:rS   NNz!BBBBBz!BBBBrF   s    s      )r   rG   rH   rI   rA   rL   SW1_MORE_DATA)r#   rN   rO   rP   rQ   rR   Zheaderr=   r>   r?   Zto_sendr6   Zlress   &&&&&&       r   _chain_apdusZCtapPcscDevice._chain_apdus   s:    [[CbdCINF!//>NDsc>!d)c/ $T
DJXtcz3BGU!%!3!3F4D!E3:+c>);;w"9DD#d)4t;;!//w?NDs&*V[[s-CC!%!3!3D!93c>!r   c               r   )r   r6   r4   r+   r8   r   r   r   r   r   r      s     9 95 95K 9r   c                	s0   \        V4      ^8  dA   V^,          ^ 8X  d3   \        P                  ! RVR,          4      ^ ,          pV^^V,            pM(\        V4      ^8X  d   RpMV^,          pV^^V,            pVR,          w  rErgV P                  WEWgV4      # )   z!H:i   rV   Nr   :Ni   N)rI   rG   ZunpackrU   )r#   r6   Zdata_lenrR   rN   rO   rP   rQ   s   &&      r   rK   Z%CtapPcscDevice._chained_apdu_exchange   s    t9>d1gl}}T495a8HAL)DY!^D AwHAL)D!"X2  2488r   c               s     V ^8  d   QhRRRR/# )r   r6   r4   r+   r   r   r   r   r   r      s     3 3u 3 3r   c                	sf    V P                  V4      w  r#pV\        P                  ! R W44      ,           # )z!BB)rK   rG   rH   rM   s   &&   r   
_call_apduZCtapPcscDevice._call_apdu   s,    44T:3fkk%222r   c               s(    V ^8  d   QhRRRRRRRR/# )r   rR   r4   eventEvent | Noneon_keepaliveCallable[[STATUS], None] | Noner+   r   r   r   r   r   r      s2     8 88 8 6	8
 
8r   c                	s   T;'       g    \        4       pV P                  ^^^^ V4      w  rEpRpVP                  4       '       g   WV3\        8X  dD   \	        V^ ,          4      pV'       d   Wx8w  d   TpV! V4       V P                  ^^^ ^ 4      w  rEpKO  WV3\
        8w  d$   \        \        P                  P                  4      hV# \        \        P                  P                  4      h)i   N)
r   rU   Zis_set	SW_UPDATEr   rL   r
   ERRZOTHERZKEEPALIVE_CANCEL)	r#   rR   rX   rZ   r=   r>   r?   Zlast_kaZ	ka_statuss	   &&&&     r   
_call_cborZCtapPcscDevice._call_cbor   s       **4tT4H3,,..*	)"47O	G$8'G + "&!2!24tT!J3zZ'	 3 344K	6677r   c          
     s,    V ^8  d   QhRRRRRRRRR	R/# )
r   cmdr,   rR   r4   rX   rY   rZ   r[   r+   r   r   r   r   r   r      s<     ; ;; ; 	;
 6; 
;r   c                	s    V\         P                  8X  d   V P                  W#V4      # V\         P                  8X  d   V P	                  V4      # \        \
        P                  P                  4      hr%   )r   r!   r^   ZMSGrW   r
   r]   ZINVALID_COMMAND)r#   r_   rR   rX   rZ   s   &&&&&r   r    ZCtapPcscDevice.call   sQ     ',,??4==GKK??4((IMM99::r   c               r*   rE   r   r   r   r   r   r      s        t  r   c                	s:    V P                   P                  4        R # r%   )r   Z
disconnectr'   r(   r   closeZCtapPcscDevice.close   s    

r   c               r   )r   r   r   r+   zIterator[CtapPcscDevice]r   r   r   r   r   r      s     0 0 0-E 0r   c              #  	s   "   \        4        F9  pWP                  9   g   K   V ! VP                  4       VP                  4      x  K;  	  R#   \         d"   p\        P                  R T4        Rp?Kf  Rp?ii ; i5i)zError %rN)_list_readersr   ZcreateConnectionZ	Exceptionr9   Zdebug)Zclsr   Zreaderes   &&  r   list_devicesZCtapPcscDevice.list_devices   s\     #oF{{"0f557EE & ! 0LLQ//0s.   A;#AA;A8A3-A;3A88A;)r   r   r   r   r%   )r   )r   NN)Z )__name__Z
__module__Z__qualname__Z__firstlineno__Z__doc__r$   r   r)   Zpropertyr-   r.   r0   r3   r5   rA   rD   r&   rU   rK   rW   r^   r    r`   Zclassmethodrc   Z__static_attributes__r   r   r   r   r   5   s    7/ A A " "    *" 2"09388;  0 0r   r   c                 s     \         P                  ! 4       #   \         d?   p  ^ RIHp RTn        \         P                  ! 4       u Rp ? #   \         d    T hi ; iRp ? ii ; i)r    )PCSCContextN)r   Zreadersr   Zsmartcard.pcsc.PCSCContextre   ZinstanceZImportError)rb   re   s     r   ra   ra      sT    ~~ 	>#'K >>## 	G	s&    A !A
A 
AAA )i   r    )i   r    )!Z
__future__r   ZloggingrG   Z	threadingr   Ztypingr   r   Z	smartcardr   Zsmartcard.CardConnectionr   Zsmartcard.pcsc.PCSCExceptionsr   Zctapr   r	   r
   Zhidr   r   Zutilsr   rJ   rL   r\   rT   Z	getLoggerrd   r9   r   ra   r   r   r   <module>rf      se   : #    %  3 > / / $ $.
	 
		8	$z0Z z0zr   