ó
    &ÝNjÊ  ã                   ó–   • S SK Jr  S SKJrJr  S SK Jr  S\S\S\4S jr	S\S	\
S\4S
 jrS\S	\
S\4S jrS\S\4S jrS\S\S\4S jrg)é    N)ÚffiÚlib)ÚensureÚinp1Úinp2Úreturnc                 ó*  • [        [        U [        5      [        R                  S9  [        [        U[        5      [        R                  S9  [        [        U 5      [        U5      5      n[        R                  " SU5      n[        R                  " SU5      n[        R                  " X0[        U 5      5        [        R                  " XA[        U5      5        [        U 5      [        U5      :H  n[        R                  " X4U5      S:H  nU=(       a    U$ )z9
Compare contents of two memory regions in constant time
©Úraisingzchar []r   )r   Ú
isinstanceÚbytesÚexcÚ	TypeErrorÚmaxÚlenr   ÚnewÚmemmover   Úsodium_memcmp)r   r   ÚlnÚbuf1Úbuf2ÚeqLÚeqCs          ÚP/home/mande/repo/quber/.venv/lib/python3.13/site-packages/nacl/bindings/utils.pyr   r      s¹   € ô Œ:�dœEÓ"¬C¯M©MÒ:Ü
Œ:�dœEÓ"¬C¯M©MÒ:ä	ŒS�‹Yœ˜D›	Ó	"€Bä�7Š7�9˜bÓ!€DÜ�7Š7�9˜bÓ!€Dä‡K‚K�œC ›IÔ&Ü‡K‚K�œC ›IÔ&ä
ˆd‹)”s˜4“yÑ
 €CÜ
×
Ò
˜D¨Ó
+¨qÑ
0€Cà�;�3Ðó    ÚsÚ	blocksizec                 ó  • [        [        U [        5      [        R                  S9  [        [        U[
        5      [        R                  S9  US::  a  [        R                  e[        U 5      nX!-   n[        R                  " SU5      n[        R                  " SS5      n[        R                  " X@U5        [        R                  " XTX!U5      n[        US:H  S[        R                  S9  [        R                  " XES   5      SS $ )zÚ
Pad the input bytearray ``s`` to a multiple of ``blocksize``
using the ISO/IEC 7816-4 algorithm

:param s: input bytes string
:type s: bytes
:param blocksize:
:type blocksize: int
:return: padded string
:rtype: bytes
r
   r   úunsigned char []ú	size_t []é   zPadding failureN)r   r   r   r   r   ÚintÚ
ValueErrorr   r   r   r   r   Ú
sodium_padÚCryptoErrorÚbuffer)r   r   Ús_lenÚm_lenÚbufÚp_lenÚrcs          r   r$   r$   )   s¾   € ô Œ:�aœÓ¬¯©Ò7Ü
Œ:�i¤Ó%¬s¯}©}Ò=Ø�Aƒ~Ü�n‰nÐÜ�‹F€EØÑ€EÜ
�'Š'Ð$ eÓ
,€CÜ�GŠG�K Ó#€EÜ‡K‚K�˜ÔÜ	�Š˜ E°eÓ	<€BÜ
ˆ2�‰7Ð%¬s¯©Ò?Ü�:Š:�c ™8Ó$¡QÐ'Ð'r   c                 óT  • [        [        U [        5      [        R                  S9  [        [        U[
        5      [        R                  S9  [        U 5      n[        R                  " SS5      n[        R                  " X0X!5      nUS:w  a  [        R                  " S5      eU SUS    $ )zº
Remove ISO/IEC 7816-4 padding from the input byte array ``s``

:param s: input bytes string
:type s: bytes
:param blocksize:
:type blocksize: int
:return: unpadded string
:rtype: bytes
r
   r    r!   r   zUnpadding failureN)r   r   r   r   r   r"   r   r   r   r   Úsodium_unpadr%   )r   r   r'   Úu_lenr+   s        r   r-   r-   C   s€   € ô Œ:�aœÓ¬¯©Ò7Ü
Œ:�i¤Ó%¬s¯}©}Ò=Ü�‹F€EÜ�GŠG�K Ó#€EÜ	×	Ò	˜% EÓ	5€BØ	ˆQƒwÜ�oŠoÐ1Ó2Ð2ØˆZˆu�Q‰xˆ=Ðr   Úinpc                 ó  • [        [        U [        5      [        R                  S9  [        U 5      n[        R                  " SU5      n[        R                  " X U5        [        R                  " X!5        [        R                  " X!5      SS $ )aC  
Increment the value of a byte-sequence interpreted
as the little-endian representation of a unsigned big integer.

:param inp: input bytes buffer
:type inp: bytes
:return: a byte-sequence representing, as a little-endian
         unsigned big integer, the value ``to_int(inp)``
         incremented by one.
:rtype: bytes

r
   r   N)r   r   r   r   r   r   r   r   r   r   Úsodium_incrementr&   )r/   r   r)   s      r   r1   r1   X   sc   € ô Œ:�cœ5Ó!¬3¯=©=Ò9ä	ˆS‹€BÜ
�'Š'Ð$ bÓ
)€Cä‡K‚K�˜"Ôä×Ò˜Ô!ä�:Š:�cÓ™qÐ!Ð!r   ÚaÚbc                 ó  • [        [        U [        5      [        R                  S9  [        [        U[        5      [        R                  S9  [        U 5      n[        [        U5      U:H  [        R                  S9  [        R                  " SU5      n[        R                  " SU5      n[        R                  " X0U5        [        R                  " XAU5        [        R                  " X4U5        [        R                  " X25      SS $ )aí  
Given a couple of *same-sized* byte sequences, interpreted as the
little-endian representation of two unsigned integers, compute
the modular addition of the represented values, in constant time for
a given common length of the byte sequences.

:param a: input bytes buffer
:type a: bytes
:param b: input bytes buffer
:type b: bytes
:return: a byte-sequence representing, as a little-endian big integer,
         the integer value of ``(to_int(a) + to_int(b)) mod 2^(8*len(a))``
:rtype: bytes
r
   r   N)r   r   r   r   r   r   r   r   r   r   Ú
sodium_addr&   )r2   r3   r   Úbuf_aÚbuf_bs        r   r5   r5   q   s­   € ô Œ:�aœÓ¬¯©Ò7Ü
Œ:�aœÓ¬¯©Ò7Ü	ˆQ‹€BÜ
Œ3ˆq‹6�R‰<¤§¡Ò/ä�GŠGÐ&¨Ó+€EÜ�GŠGÐ&¨Ó+€Eä‡K‚K�˜"ÔÜ‡K‚K�˜"Ôä‡N‚N�5 Ô$ä�:Š:�eÓ ¡Ð#Ð#r   )Únacl.exceptionsÚ
exceptionsr   Únacl._sodiumr   r   r   r   Úboolr   r"   r$   r-   r1   r5   © r   r   Ú<module>r=      s‹   ðõ ß !Ý "ð˜ð  Uð ¨tô ð*(�%ð ( Cð (¨Eô (ð4�Eð  cð ¨eô ð*"˜%ð " Eô "ð2$�%ð $˜Eð $ eõ $r   