HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/nacl/bindings/__pycache__/utils.cpython-38.pyc
U

�֫[D�@stddlmZmZmZddlmZddlmZddl	m
Z
mZddlmZdd�Z
dd	�Zd
d�Zdd
�Zdd�ZdS)�)�absolute_import�division�print_function)�
integer_typesN)�ffi�lib)�ensurecCs�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)Zinp1Zinp2�lnZbuf1Zbuf2ZeqLZeqC�r�5/usr/lib/python3/dist-packages/nacl/bindings/utils.pyrs
�
�rcCs�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
    r	r�unsigned char []�	size_t []�zPadding failureN)rr
rrr
r�
ValueErrorrrrrr�
sodium_pad�CryptoError�buffer)�s�	blocksize�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
    r	rrrzUnpadding failureN)rr
rrr
rrrrr�sodium_unpadr)rrrZu_lenr!rrrr"Js
�
�
r"cCsVtt|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

    r	rN)rr
rrr
rrrrr�sodium_incrementr)Zinprr rrrr#as
�r#cCs�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
    r	rN)rr
rrr
rrrrr�
sodium_addr)�a�brZbuf_aZbuf_brrrr${s 
�
��r$)Z
__future__rrrZsixrZnacl.exceptions�
exceptionsrZnacl._sodiumrrrrrr"r#r$rrrr�<module>s