+
     h!  c                  s   R t ^ RIHt ^ RIt^t^t^t^tRCR R lltR R lt	R R lt
R	 R
 lt / R^ bR^bR^bR^bR^bR^bR^bR^bR^bR^	bR^
bR^bR^bR^bR^bR^bR^b/ R^bR^bR^bR^bR ^bR!^bR"^bR#^bR$^bR%^bR&^bR'^bR(^bR)^bR*^ bR+^!bR,^"bCR-^#R.^$R/^@R0^[R1^\R2^]R3^^R4^_R5^`R6^{R7^|R8^}R9^~R:^/CtR; R< ltRDR= R> lltR? R@ ltRA RB lt]t]tR# )Eal  smartcard.util package

__author__ = "https://www.gemalto.com/"

Copyright 2001-2012 gemalto
Author: Jean-Daniel Aussel, mailto:jean-daniel.aussel@gemalto.com

This file is part of pyscard.

pyscard is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

pyscard is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with pyscard; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
)annotationsNc               $    V ^8  d   QhRRRRRR/# )   bytelist	list[int]lengthintpaddingstr format   ">/usr/lib64/python3.14/site-packages/smartcard/util/__init__.py__annotate__r   #   s&     D D9 Dc DC D    c                sX    V \        V^4      .V\        V 4      ,
          ,          ,           # )af  Padds a byte list with a constant byte value (default is x0FF)
@param bytelist: the byte list to padd
@param length: the total length of the resulting byte list;
              no padding if length is smaller than the byte list length
@param padding: padding value (default is 0xff)

@return: the padded bytelist

>>> padd([59, 101, 0, 0, 156, 17, 1, 1, 3], 16)
[59, 101, 0, 0, 156, 17, 1, 1, 3, 255, 255, 255, 255, 255, 255, 255]
>>> padd([59, 101, 0, 0, 156, 17, 1, 1, 3], 12, '80')
[59, 101, 0, 0, 156, 17, 1, 1, 3, 128, 128, 128]
>>> padd([59, 101, 0, 0, 156, 17, 1, 1, 3], 8)
[59, 101, 0, 0, 156, 17, 1, 1, 3]
)r   Zlen)r   r   r   s   &&&r   paddr   #   s'    " s7B'(FS],BCCCr   c                    V ^8  d   QhRRRR/# )r   stringtoconvertr   returnr   r	   r
   r   r   r   r   7   s     1 1# 1) 1r   c                s6    \        V P                  R4      4      # )a:  Convert a string to a list of UTF-8 encoded bytes.

@param stringtoconvert: the string to convert into a byte list

@return: a byte list of the ASCII codes of the string characters

L{toASCIIBytes()} is the reverse of L{toASCIIString()}

>>> toASCIIBytes("Number 101")
[78, 117, 109, 98, 101, 114, 32, 49, 48, 49]
utf-8)listencode)r      &r   toASCIIBytesr   7   s     &&w/00r   c               r   )r   r   r   r   r   r	   r
   r   r   r   r   G   s     H HI H# Hr   c                s2    RP                  R V  4       4      # )a  Convert a list of integers in the range ``[32, 127]`` to a string.

Integer values outside the range ``[32, 127]`` are replaced with a period.

@param bytelist: list of ASCII bytes to convert into a string

@return: a string from the ASCII code list

L{toASCIIString()} is the reverse of L{toASCIIBytes()}

>>> toASCIIString([0x4E,0x75,0x6D,0x62,0x65,0x72,0x20,0x31,0x30,0x31])
'Number 101'
>>> toASCIIString([0x01, 0x20, 0x80, 0x7E, 0xF0])
". .~."
 c              3  s`   "   T F$  p^ Tu;8:  d   ^8:  d   M M\        V4      MRx  K&  	  R# 5i)i    Z.N)Zchr).0Zcs   & r   	<genexpr>Z toASCIIString.<locals>.<genexpr>X   s#     GhR1^^3q64hs   ,.)join)r   r   r   toASCIIStringr   G   s    " 77GhGGGr   c               r   )r   
bytestringr   r   r   r	   r
   r   r   r   r   [   s     E E E	 Er   c                st     \        \        P                  V 4      4      #   \         d    \	        R4      hi ; i)a>  Convert a string of hexadecimal characters to a list of integers.

@param bytestring: a byte string

>>> toBytes("3B 65 00 00 9C 11 01 01 03")
[59, 101, 0, 0, 156, 17, 1, 1, 3]
>>> toBytes("3B6500009C11010103")
[59, 101, 0, 0, 156, 17, 1, 1, 3]
>>> toBytes("3B6500   009C1101  0103")
[59, 101, 0, 0, 156, 17, 1, 1, 3]
z)not a string representing a list of bytes)r   bytesZfromhexZ
ValueError	TypeError)r   r   r   toBytesr!   [   s9    EEMM*-.. ECDDEs     7Z@t   £Z$t   ¥t   èt   ét   ùt   ìt   òt   ÇZ
t   Øt   øZt   Åt   åu   ΔZ_u   Φu   Γu   Λu   Ωu   Πu   Ψu   Σu   Θu   Ξt   Æt   æt   ßt   É Z!Z"Z#t   ¤t   ¡t   Ät   Öt   Ñt   Üt   §t   ¿t   ät   öt   ñt   üt   àc               r   )r   r   zstr | bytesr   r   r	   r
   r   r   r   r      s      K I r   c                sB   \        V \        4      '       d   V P                  R4      p . pV  Fo  pRTu;8:  d   R8:  g&   M RTu;8:  d   R8:  g   M RTu;8:  d   R8:  d    M MVP                  \	        V4      4       KS  VP                  \
        V,          4       Kq  	  V# )u   Returns a list of bytes from a string using GSM 3.38 conversion table.

@param stringtoconvert:     string to convert

@return: a list of bytes

>>> toGSM3_38Bytes("@ùPascal")
[0, 6, 80, 97, 115, 99, 97, 108]
z	iso8859-1Z%Z?ZAZZaZz)
isinstancer   decodeZappendZord__dic_GSM_3_38__)r   ZresultZchars   &  r   toGSM3_38Bytesr'      s~     /5)))00=F43C4$63$6C4<N3<NMM#d)$MM*401	  
 Mr   c               r   )r   datazlist[int] | Noner   r   r   r   r	   r
   r   r   r   r      s'     /G /G& /Gs /G3 /Gr   c                s  a V e"   \        V \        4      '       g   \        R4      hV '       g   R# RoRp\        V,          '       d   Rp\        V,          '       g
   VR,          p\
        V,          '       d'   \        V,          '       d   RS,           oM	RS,           oVP                  V3R lV  4       4      P                  4       # )	a  Convert a list of integers to a formatted string of hexadecimal.

Integers larger than 255 will be truncated to two-byte hexadecimal pairs.

@param data:   a list of bytes to stringify,
            e.g. [59, 22, 148, 32, 2, 1, 0, 0, 13]
@param format: a logical OR of
  - COMMA: add a comma between bytes
  - HEX: add the 0x chars before bytes
  - UPPERCASE: use 0X before bytes (need HEX)
  - PACK: remove blanks

>>> vals = [0x3B, 0x65, 0x00, 0x00, 0x9C, 0x11, 0x01, 0x01, 0x03]
>>> toHexString(vals)
'3B 65 00 00 9C 11 01 01 03'
>>> toHexString(vals, COMMA)
'3B, 65, 00, 00, 9C, 11, 01, 01, 03'
>>> toHexString(vals, HEX)
'0x3B 0x65 0x00 0x00 0x9C 0x11 0x01 0x01 0x03'
>>> toHexString(vals, HEX | COMMA)
'0x3B, 0x65, 0x00, 0x00, 0x9C, 0x11, 0x01, 0x01, 0x03'
>>> toHexString(vals, PACK)
'3B6500009C11010103'
>>> toHexString(vals, HEX | UPPERCASE)
'0X3B 0X65 0X00 0X00 0X9C 0X11 0X01 0X01 0X03'
>>> toHexString(vals, HEX | UPPERCASE | COMMA)
'0X3B, 0X65, 0X00, 0X00, 0X9C, 0X11, 0X01, 0X01, 0X03'
znot a list of bytesr   z%-0.2XZ,r"   Z0XZ0xc              3  sD   <"   T F  pSV^,          ,          x  K  	  R# 5i)i   Nr	   )r   r#   pformats   & r   r   ZtoHexString.<locals>.<genexpr>   s     =1'QX..s    )	r$   r   r    COMMAPACKHEX	UPPERCASEr   Zrstrip)r(   r   Z	separatorr)   s   && @r   toHexStringr.      s    < LJtT22-..GIv~~	&==S	
V||vWnGWnG>>===DDFFr   c               r   )r   hexlistr   r   r   r	   r
   r   r   r   r      s     * *	 *c *r   c                sl    \         P                  ! R\        4       \        V 4      P	                  R4      # )zDeprecated. Use `bytes(hexlist).decode("utf-8")` or similar.

>>> HexListToBinString([78, 117, 109, 98, 101, 114, 32, 49, 48, 49])
'Number 101'
z0Use `bytes(hexlist).decode("utf-8")` or similar.r   )warningswarnDeprecationWarningr   r%   )r/   r   r   HexListToBinStringr3      s-     MM: >  ))r   c               r   )r   	binstringr   r   r   r	   r
   r   r   r   r     s     + +# +) +r   c                sl    \         P                  ! R\        4       \        V P	                  R4      4      # )zDeprecated. Use `list(binstring.encode("utf-8"))` or similar.

>>> BinStringToHexList("Number 101")
[78, 117, 109, 98, 101, 114, 32, 49, 48, 49]
z1Use `list(binstring.encode("utf-8"))` or similar.r   )r0   r1   r2   r   r   )r4   r   r   BinStringToHexListr5     s.     MM; 	  )**r   )ZFF)Ni    )Z__doc__Z
__future__r    r0   r+   r,   r-   r*   r   r   r   r!   r&   r'   r.   r3   r5   Zhl2bsZbs2hlr	   r   r   <module>r6      s^  0 # 		D(1 H(E& *;;$; ; 	$	;
 	$; 	$; 	$; 	$; 	$; 	$; 	$; 	$; 	$; 	$; 	$;  	$!;" 	$#;$ %;& 	$';( 	$);* 	$+;, 	$-;. 	$/;0 	$1;2 	$3;4 	$5;6 	$7;: 	$;;< 	$=;> 	$?;@ 	$A;B C;D E;F G;H $ 	$ 	$$$$$$ 	$$$$$u; |,/Gd*+ 	r   