%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__/crypto_box.cpython-312.pyc

�

�f�'�
�z�UddlmZddlmZddlmZmZddlm	Z	ddgZ
ej�Ze
ed<ej�Ze
ed<ej"�Ze
ed	<ej&�Ze
ed
<ej*�Ze
ed<ej.�Ze
ed<ej2�Ze
ed
<ej6�Ze
ed<deeeffd�Zdedeeeffd�Zdededededef
d�Z dededededef
d�Z!dededefd�Z"dedededefd�Z#dedededefd�Z$dededefd�Z%dedededefd�Z&y )!�)�Tuple)�
exceptions)�ffi�lib)�ensure�crypto_box_keypair�
crypto_box�crypto_box_SECRETKEYBYTES�crypto_box_PUBLICKEYBYTES�crypto_box_SEEDBYTES�crypto_box_NONCEBYTES�crypto_box_ZEROBYTES�crypto_box_BOXZEROBYTES�crypto_box_BEFORENMBYTES�crypto_box_SEALBYTES�returnc�H�tjdt�}tjdt�}t	j
||�}t
|dk(dtj��tj|t�ddtj|t�ddfS)zq
    Returns a randomly generated public and secret key.

    :rtype: (bytes(public_key), bytes(secret_key))
    �unsigned char[]r�Unexpected library error��raisingN)
r�newrr
rrr�exc�RuntimeError�buffer)�pk�sk�rcs   �:/usr/lib/python3/dist-packages/nacl/bindings/crypto_box.pyrr"s���

���"�$=�	>�B�	���"�$=�	>�B�	�	�	��B�	'�B�
�2��7�.��8H�8H�I�	�
�
�2�0�1�!�4��
�
�2�0�1�!�4����seedc���tt|t�dt��t	|�t
k7rt
jd��tjdt�}tjdt�}tj|||�}t|dk(dtj��tj|t�ddtj|t�ddfS)a
    Returns a (public, secret) keypair deterministically generated
    from an input ``seed``.

    .. warning:: The seed **must** be high-entropy; therefore,
        its generator **must** be a cryptographic quality
        random function like, for example, :func:`~nacl.utils.random`.

    .. warning:: The seed **must** be protected and remain secret.
        Anyone who knows the seed is really in possession of
        the corresponding PrivateKey.


    :param seed: bytes
    :rtype: (bytes(public_key), bytes(secret_key))
    zseed must be bytesrzInvalid seedrrrN)r�
isinstance�bytes�	TypeError�lenrr�
ValueErrorrrrr
r�crypto_box_seed_keypairrr)r!rrrs    rr(r(4s���"�:�d�E�"�$8�)�L�
�4�y�(�(��n�n�^�,�,�	���"�$=�	>�B�	���"�$=�	>�B�	�	$�	$�R��T�	2�B�
�2��7�.��8H�8H�I�	�
�
�2�0�1�!�4��
�
�2�0�1�!�4��r �message�noncerrc��t|�tk7rtjd��t|�tk7rtjd��t|�t
k7rtjd��dtz|z}tjdt|��}tj||t|�|||�}t|dk(dtj��tj|t|��td	S)
z�
    Encrypts and returns a message ``message`` using the secret key ``sk``,
    public key ``pk``, and the nonce ``nonce``.

    :param message: bytes
    :param nonce: bytes
    :param pk: bytes
    :param sk: bytes
    :rtype: bytes
    �Invalid nonce size�Invalid public key�Invalid secret key�rrrrN)r&r
rr'rr
rrrrr	rrrr)r)r*rr�padded�
ciphertextrs       rr	r	Vs����5�z�*�*��n�n�1�2�2�
�2�w�+�+��n�n�1�2�2�
�2�w�+�+��n�n�1�2�2��,�,��
7�F����*�C��K�8�J�	���
�F�C��K���B�	G�B�
�2��7�.��8H�8H�I��:�:�j�#�f�+�.�/F�/G�H�Hr r1c��t|�tk7rtjd��t|�tk7rtjd��t|�t
k7rtjd��dtz|z}tjdt|��}tj||t|�|||�}t|dk(dtj��tj|t|��td	S)
a
    Decrypts and returns an encrypted message ``ciphertext``, using the secret
    key ``sk``, public key ``pk``, and the nonce ``nonce``.

    :param ciphertext: bytes
    :param nonce: bytes
    :param pk: bytes
    :param sk: bytes
    :rtype: bytes
    r,r-r.r/rr�/An error occurred trying to decrypt the messagerN)r&r
rr'rr
rrrr�crypto_box_openr�CryptoErrorrr)r1r*rrr0�	plaintext�ress       rr4r4ss����5�z�*�*��n�n�1�2�2�
�2�w�+�+��n�n�1�2�2�
�2�w�+�+��n�n�1�2�2��/�/�:�
=�F����)�3�v�;�7�I�

�
�
�i���V��e�R��
L�C�
��q��9������:�:�i��V��-�.B�.C�D�Dr c�x�t|�tk7rtjd��t|�tk7rtjd��tjdt�}tj|||�}t|dk(dtj��tj|t�ddS)a
    Computes and returns the shared key for the public key ``pk`` and the
    secret key ``sk``. This can be used to speed up operations where the same
    set of keys is going to be used multiple times.

    :param pk: bytes
    :param sk: bytes
    :rtype: bytes
    r-r.rrrrN)
r&rrr'r
rrrr�crypto_box_beforenmrrr)rr�krs    rr9r9�s����2�w�+�+��n�n�1�2�2�
�2�w�+�+��n�n�1�2�2����!�#;�<�A�	�	 �	 ��B��	+�B�
�2��7�.��8H�8H�I��:�:�a�1�2�1�5�5r r:c���t|�tk7rtjd��t|�tk7rtjd��dt
z|z}t
jdt|��}tj||t|�||�}t|dk(dtj��t
j|t|��tdS)	z�
    Encrypts and returns the message ``message`` using the shared key ``k`` and
    the nonce ``nonce``.

    :param message: bytes
    :param nonce: bytes
    :param k: bytes
    :rtype: bytes
    �
Invalid nonce�Invalid shared keyr/rrrrN)r&r
rr'rrrrr�crypto_box_afternmrrrr)r)r*r:r0r1rs      rr>r>�s����5�z�*�*��n�n�_�-�-�
�1�v�)�)��n�n�1�2�2�
�+�
+�g�
5�F����*�C��K�8�J�	�	�	�
�F�C��K���	J�B�
�2��7�.��8H�8H�I��:�:�j�#�f�+�.�/F�/G�H�Hr c���t|�tk7rtjd��t|�tk7rtjd��dt
z|z}t
jdt|��}tj||t|�||�}t|dk(dtj��t
j|t|��tdS)	z�
    Decrypts and returns the encrypted message ``ciphertext``, using the shared
    key ``k`` and the nonce ``nonce``.

    :param ciphertext: bytes
    :param nonce: bytes
    :param k: bytes
    :rtype: bytes
    r<r=r/rrr3rN)r&r
rr'rrrrr�crypto_box_open_afternmrr5rr)r1r*r:r0r6r7s      rr@r@�s����5�z�*�*��n�n�_�-�-�
�1�v�)�)��n�n�1�2�2��/�/�:�
=�F����)�3�v�;�7�I�

�
%�
%�i���V��e�Q�
O�C�
��q��9������:�:�i��V��-�.B�.C�D�Dr c���tt|t�dt��tt|t�dt��t	|�t
k7rt
jd��t	|�}t|z}tjd|�}tj||||�}t|dk(dtj��tj||�ddS)	a�
    Encrypts and returns a message ``message`` using an ephemeral secret key
    and the public key ``pk``.
    The ephemeral public key, which is embedded in the sealed box, is also
    used, in combination with ``pk``, to derive the nonce needed for the
    underlying box construct.

    :param message: bytes
    :param pk: bytes
    :rtype: bytes

    .. versionadded:: 1.2
    zinput message must be bytesr�public key must be bytesr-rrrN)rr#r$r%r&rrr'rrrr�crypto_box_sealrr)r)r�_mlen�_clenr1rs      rrCrC�s�����7�E�"�%�����2�u��9�9���2�w�+�+��n�n�1�2�2���L�E� �5�(�E����*�E�2�J�	�	�	�Z��%��	<�B�
�2��7�.��8H�8H�I��:�:�j�%�(��+�+r c���tt|t�dt��tt|t�dt��tt|t�dt��t	|�t
k7rt
jd��t	|�tk7rt
jd��t	|�}t|tk\djt�tj��|tz
}tjdtd	|��}tj|||||�}t|d
k(dtj ��tj"||�ddS)
a�
    Decrypts and returns an encrypted message ``ciphertext``, using the
    recipent's secret key ``sk`` and the sender's ephemeral public key
    embedded in the sealed box. The box contruct nonce is derived from
    the recipient's public key ``pk`` and the sender's public key.

    :param ciphertext: bytes
    :param pk: bytes
    :param sk: bytes
    :rtype: bytes

    .. versionadded:: 1.2
    zinput ciphertext must be bytesrrBzsecret key must be bytesr-r.z)Input cyphertext must be at least {} longr�rr3N)rr#r$r%r&rrr'r
r�formatrr�maxr�crypto_box_seal_openr5r)r1rrrErDr6r7s       rrJrJs-����:�u�%�(�����2�u��9�9����2�u��9�9���2�w�+�+��n�n�1�2�2�
�2�w�+�+��n�n�1�2�2��
�O�E�
�
�%�%�	4�<�<� �	
��
�
��
�(�(�E����)�3�q�%�=�9�I�

�
"�
"�9�j�%��R�
H�C�
��q��9������:�:�i��'��*�*r N)'�typingr�naclrr�nacl._sodiumrr�nacl.exceptionsr�__all__�crypto_box_secretkeybytesr
�int�__annotations__�crypto_box_publickeybytesr�crypto_box_seedbytesr�crypto_box_noncebytesr
�crypto_box_zerobytesr�crypto_box_boxzerobytesr�crypto_box_beforenmbytesr�crypto_box_sealbytesrr$rr(r	r4r9r>r@rCrJ�r r�<module>r[s���"�!�"� ��
.��"?��!>�!>�!@��3�@�!>��!>�!>�!@��3�@�4�C�4�4�6��c�6�6�S�6�6�8��s�8�4�C�4�4�6��c�6�:�s�:�:�<���<� <�� <� <� >��#�>�4�C�4�4�6��c�6��E�%��,�/��$�%��E�%��,�,?��DI��I�e�I��I�E�I�e�I�: E�� E�#� E�).� E�49� E�
� E�F6�E�6�u�6��6�0I��I�e�I��I�%�I�2E��E�#�E�(-�E�
�E�>#,�U�#,��#,�%�#,�L8+�U�8+��8+�5�8+�U�8+r 

Zerion Mini Shell 1.0