§
    &xÅjW  ã                   óŽ   — d dl mZ d dlmZmZ d dl mZ dededefd„Z	ded	e
defd
„Zded	e
defd„Zdedefd„Zdededefd„ZdS )é    N)ÚffiÚlib)ÚensureÚinp1Úinp2Úreturnc                 ój  — t          t          | t          ¦  «        t          j        ¬¦  «         t          t          |t          ¦  «        t          j        ¬¦  «         t          t          | ¦  «        t          |¦  «        ¦  «        }t          j        d|¦  «        }t          j        d|¦  «        }t          j	        || t          | ¦  «        ¦  «         t          j	        ||t          |¦  «        ¦  «         t          | ¦  «        t          |¦  «        k    }t          j        |||¦  «        dk    }|o|S )zA
    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          úDC:\Projects\Historical\venv\Lib\site-packages\nacl/bindings/utils.pyr   r      sì   € õ �:�d�EÑ"Ô"­C¬MÐ:Ñ:Ô:Ð:Ý
�:�d�EÑ"Ô"­C¬MÐ:Ñ:Ô:Ð:å	�S�‰YŒY�˜D™	œ	Ñ	"Ô	"€BåŒ7�9˜bÑ!Ô!€DÝŒ7�9˜bÑ!Ô!€Då„K��d�C ™IœIÑ&Ô&Ð&Ý„K��d�C ™IœIÑ&Ô&Ð&å
ˆd‰)Œ)•s˜4‘y”yÒ
 €CÝ
Ô
˜D $¨Ñ
+Ô
+¨qÒ
0€Càˆ;�3Ðó    ÚsÚ	blocksizec                 ó<  — t          t          | t          ¦  «        t          j        ¬¦  «         t          t          |t
          ¦  «        t          j        ¬¦  «         |dk    rt          j        ‚t          | ¦  «        }||z   }t          j	        d|¦  «        }t          j	        dd¦  «        }t          j
        || |¦  «         t          j        |||||¦  «        }t          |dk    dt          j        ¬¦  «         t          j        ||d         ¦  «        dd…         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Ñ7Ô7Ð7Ý
�:�i¥Ñ%Ô%­s¬}Ð=Ñ=Ô=Ð=Ø�A‚~€~ÝŒnÐÝ�‰FŒF€EØ�IÑ€EÝ
Œ'Ð$ eÑ
,Ô
,€CÝŒG�K Ñ#Ô#€EÝ„K��Q˜ÑÔÐÝ	Œ˜˜s E¨9°eÑ	<Ô	<€BÝ
ˆ2�Š7Ð%­s¬Ð?Ñ?Ô?Ð?ÝŒ:�c˜5 œ8Ñ$Ô$ Q Q QÔ'Ð'r   c                 ó„  — t          t          | t          ¦  «        t          j        ¬¦  «         t          t          |t
          ¦  «        t          j        ¬¦  «         t          | ¦  «        }t          j        dd¦  «        }t          j
        || ||¦  «        }|dk    rt          j        d¦  «        ‚| d|d         …         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Ñ7Ô7Ð7Ý
�:�i¥Ñ%Ô%­s¬}Ð=Ñ=Ô=Ð=Ý�‰FŒF€EÝŒG�K Ñ#Ô#€EÝ	Ô	˜%  E¨9Ñ	5Ô	5€BØ	ˆQ‚w€wÝŒoÐ1Ñ2Ô2Ð2ØˆZˆu�QŒxˆZŒ=Ðr   Úinpc                 ó6  — t          t          | t          ¦  «        t          j        ¬¦  «         t          | ¦  «        }t          j        d|¦  «        }t          j        || |¦  «         t          j
        ||¦  «         t          j        ||¦  «        dd…         S )ag  
    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   s‚   € õ �:�c�5Ñ!Ô!­3¬=Ð9Ñ9Ô9Ð9å	ˆS‰Œ€BÝ
Œ'Ð$ bÑ
)Ô
)€Cå„K��S˜"ÑÔÐåÔ˜˜bÑ!Ô!Ð!åŒ:�c˜2ÑÔ˜q˜q˜qÔ!Ð!r   ÚaÚbc                 óB  — t          t          | t          ¦  «        t          j        ¬¦  «         t          t          |t          ¦  «        t          j        ¬¦  «         t          | ¦  «        }t          t          |¦  «        |k    t          j        ¬¦  «         t          j        d|¦  «        }t          j        d|¦  «        }t          j        || |¦  «         t          j        |||¦  «         t          j
        |||¦  «         t          j        ||¦  «        dd…         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Ñ7Ô7Ð7Ý
�:�a�ÑÔ­¬Ð7Ñ7Ô7Ð7Ý	ˆQ‰Œ€BÝ
�3ˆq‰6Œ6�RŠ<¥¤Ð/Ñ/Ô/Ð/åŒGÐ&¨Ñ+Ô+€EÝŒGÐ&¨Ñ+Ô+€Eå„K��q˜"ÑÔÐÝ„K��q˜"ÑÔÐå„N�5˜% Ñ$Ô$Ð$åŒ:�e˜RÑ Ô    Ô#Ð#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   