%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/nacl/bindings/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/nacl/bindings/__pycache__/utils.cpython-312.pyc

�

�f����ddlmZddlmZmZddlmZdededefd�Z	ded	e
defd
�Zded	e
defd�Zdedefd
�Z
dededefd�Zy)�N)�ffi�lib)�ensure�inp1�inp2�returnc�(�tt|t�tj��tt|t�tj��tt
|�t
|��}tjd|�}tjd|�}tj||t
|��tj||t
|��t
|�t
|�k(}tj|||�dk(}|xr|S)zA
    Compare contents of two memory regions in constant time
    ��raisingzchar []r)r�
isinstance�bytes�exc�	TypeError�max�lenr�new�memmover�
sodium_memcmp)rr�ln�buf1�buf2�eqL�eqCs       �5/usr/lib/python3/dist-packages/nacl/bindings/utils.pyrrs����:�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��d�C��I�&��K�K��d�C��I�&�

�d�)�s�4�y�
 �C�

�
�
�D�$��
+�q�
0�C��;�3���s�	blocksizec��tt|t�tj��tt|t
�tj��|dkrtj�t|�}||z}tjd|�}tjdd�}tj|||�tj|||||�}t|dk(dtj��tj||d�ddS)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 []�zPadding failureN)rrr
rr�int�
ValueErrorrrrrr�
sodium_pad�CryptoError�buffer)rr�s_len�m_len�buf�p_len�rcs       rr$r$)s����:�a������7�
�:�i��%�s�}�}�=��A�~��n�n����F�E��I��E�

�'�'�$�e�
,�C��G�G�K��#�E��K�K��Q���	����s�E�9�e�	<�B�
�2��7�%�s���?��:�:�c�5��8�$�Q�'�'rc�\�tt|t�tj��tt|t
�tj��t
|�}tjdd�}tj||||�}|dk7rtjd��|d|dS)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!rzUnpadding failureN)rrr
rrr"rrrr�sodium_unpadr%)rrr'�u_lenr+s     rr-r-Cs����:�a������7�
�:�i��%�s�}�}�=���F�E��G�G�K��#�E�	�	�	�%��E�9�	5�B�	�Q�w��o�o�1�2�2��Z�u�Q�x�=�r�inpc�"�tt|t�tj��t|�}t
jd|�}t
j|||�tj||�t
j||�ddS)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
rN)rrr
rrrrrrr�sodium_incrementr&)r/rr)s   rr1r1Xsi���:�c�5�!�3�=�=�9�	�S��B�

�'�'�$�b�
)�C��K�K��S�"������b�!��:�:�c�2��q�!�!r�a�bc��tt|t�tj��tt|t�tj��t|�}tt|�|k(tj��t
jd|�}t
jd|�}t
j|||�t
j|||�tj|||�t
j||�ddS)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
rN)rrr
rrrrrrr�
sodium_addr&)r2r3r�buf_a�buf_bs     rr5r5qs����:�a������7�
�:�a������7�	�Q��B�
�3�q�6�R�<����/��G�G�&��+�E��G�G�&��+�E��K�K��q�"���K�K��q�"���N�N�5�%��$��:�:�e�R� ��#�#r)�nacl.exceptions�
exceptionsr�nacl._sodiumrrrr
�boolrr"r$r-r1r5�rr�<module>r=s����!�"����U��t��*(�%�(�C�(�E�(�4�E��c��e��*"�%�"�E�"�2$�%�$�E�$�e�$r

Zerion Mini Shell 1.0