Server : LiteSpeed
System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : nandedex ( 1060)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /opt/cppython/lib/python3.8/site-packages/nacl/bindings/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //opt/cppython/lib/python3.8/site-packages/nacl/bindings/__pycache__/utils.cpython-38.pyc
U

O��g��@s�ddlmZddlmZmZddlmZeeed�dd�Z	ee
ed�dd	�Zee
ed�d
d�Zeed�d
d�Z
eeed�dd�ZdS)�N)�ffi�lib)�ensure)�inp1�inp2�returncCs�tt|t�tjd�tt|t�tjd�tt|�t|��}t�d|�}t�d|�}t�	||t|��t�	||t|��t|�t|�k}t
�|||�dk}|o�|S)zA
    Compare contents of two memory regions in constant time
    �Zraisingzchar []r)r�
isinstance�bytes�exc�	TypeError�max�lenr�new�memmover�
sodium_memcmp)rr�lnZbuf1Zbuf2ZeqLZeqC�r�@/opt/cppython/lib/python3.8/site-packages/nacl/bindings/utils.pyrsr)�s�	blocksizercCs�tt|t�tjd�tt|t�tjd�|dkr6tj�t|�}||}t�	d|�}t�	dd�}t�
|||�t�|||||�}t|dkdtj
d�t�||d�dd�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
    rr�unsigned char []�	size_t []�zPadding failureN)rr	r
rr�int�
ValueErrorrrrrr�
sodium_pad�CryptoError�buffer)rr�s_lenZm_len�bufZp_len�rcrrrr)srcCsntt|t�tjd�tt|t�tjd�t|�}t�dd�}t	�
||||�}|dkr^t�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
    rrrrzUnpadding failureN)rr	r
rrrrrrr�sodium_unpadr)rrrZu_lenr!rrrr"Cs
r")�inprcCsVtt|t�tjd�t|�}t�d|�}t�|||�t	�
||�t�||�dd�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

    rrN)rr	r
rrrrrrr�sodium_incrementr)r#rr rrrr$Xs
r$)�a�brcCs�tt|t�tjd�tt|t�tjd�t|�}tt|�|ktjd�t�d|�}t�d|�}t�|||�t�|||�t	�
|||�t�||�dd�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
    rrN)rr	r
rrrrrrr�
sodium_addr)r%r&rZbuf_aZbuf_brrrr'qsr')Znacl.exceptions�
exceptionsrZnacl._sodiumrrrr
�boolrrrr"r$r'rrrr�<module>s

F1le Man4ger