%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3/dist-packages/secretstorage/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3/dist-packages/secretstorage/__pycache__/util.cpython-312.pyc

�

�bc��v�dZddlZddlmZmZmZddlmZmZm	Z	m
Z
mZmZm
Z
ddlmZddlmZmZmZmZmZmZmZmZmZmZddlmZmZddlmZm Z dd	l!m"Z"m#Z#m$Z$dd
l%m&Z&dZ'edzZ(ed
zZ)Gd�de�Z*dedefd�Z+dede,de-dee-e,e,e-ffd�Z.dede-dee/ee-ffd�Z0dedee-de/fd�Z1deddfd�Z2y)zkThis module provides some utility functions, but these shouldn't
normally be used by external applications.�N)�Any�List�Tuple)�DBusAddress�DBusErrorResponse�	MatchRule�Message�MessageType�new_method_call�
Properties)�DBusConnection)
�DBUS_UNKNOWN_METHOD�DBUS_NO_SUCH_OBJECT�DBUS_SERVICE_UNKNOWN�
DBUS_NO_REPLY�DBUS_NOT_SUPPORTED�DBUS_EXEC_FAILED�SS_PATH�	SS_PREFIX�ALGORITHM_DH�ALGORITHM_PLAIN)�Session�int_to_bytes)�ItemNotFoundException�"SecretServiceNotAvailableException)�Cipher�
algorithms�modes)�default_backendzorg.freedesktop.secrets�Service�Promptc�x�eZdZdZdedededdfd�Zdedefd	�Z	d
edededefd
�Z
dedefd�Zdedededdfd�Zy)�DBusAddressWrapperz�A wrapper class around :class:`jeepney.wrappers.DBusAddress`
    that adds some additional methods for calling and working with
    properties, and converts error responses to SecretStorage
    exceptions.

    .. versionadded:: 3.0
    �path�	interface�
connection�returnNc�J�tj||t|�||_y�N)r�__init__�BUS_NAME�_connection)�selfr$r%r&s    �4/usr/lib/python3/dist-packages/secretstorage/util.pyr*zDBusAddressWrapper.__init__'s�����T�4��9�=�%����msgc��	|jj|�}|jjtj
k(rt
|��|jS#t$rt}|jttfvrtd�|�|jtttfvr-|j}t!|t"�r|d}t%|�|��d}~wwxYw)NzItem does not exist!r)r,�send_and_get_reply�header�message_typer
�errorr�body�namerrrrrr�data�
isinstance�tupler)r-r0�resp_msg�respr8s     r.r2z%DBusAddressWrapper.send_and_get_reply,s���	� $� 0� 0� C� C�C� H�H����+�+�{�/@�/@�@�'��1�1��=�=� �� �		��y�y�0�2E�F�F�+�,B�C��M����3�5E�,�.�.��y�y���d�E�*���7�D�8��>�D�H���		�s�AA�	C�$A/C�C�method�	signaturer6c�@�t||||�}|j|�Sr))rr2)r-r=r>r6r0s     r.�callzDBusAddressWrapper.call=s#���d�F�I�t�<���&�&�s�+�+r/r7c�f�t|�j|�}|j|�\\}}|Sr))r�getr2)r-r7r0r>�values     r.�get_propertyzDBusAddressWrapper.get_propertyAs4�����"�"�4�(��"�5�5�c�:����E��r/rCc�^�t|�j|||�}|j|�yr))r�setr2)r-r7r>rCr0s     r.�set_propertyzDBusAddressWrapper.set_propertyFs)�����"�"�4��E�:������$r/)
�__name__�
__module__�__qualname__�__doc__�strr
r*r	rr2r@rDrG�r/r.r#r#s����&�S�&�S�&�+�&�04�&�
�g��#��",�3�,�3�,�s�,�s�,������
%��%��%�S�%�T�%r/r#r&r'c	��ttt|�}t�}	|j	ddt
dt
|j�f�\}}|\}}|dk(sJ�tj|d�}|j|�||_|S#t$r@}|jtk7r�|j	ddtd�\}}d|_Yd}~�Md}~wwxYw)z%Returns a new Secret Service session.�OpenSession�sv�ay�big)�s�FN)r#r�
SERVICE_IFACErr@rr�
my_public_key�int�
from_bytes�set_server_public_keyrr7rr�	encrypted�object_path)	r&�service�session�output�resultr>rC�keyr<s	         r.�open_sessionraKs��� ��-��D�G��i�G�+� ����4��
�<�� 5� 5�6�7�9����"��	�5��D� � � ��n�n�U�E�*���%�%�c�*� �G���N���"��9�9�*�*�� ����4�������"�����"�s�0B
�
	C�6C�Cr]�secret�content_typec�j�t|t�r|jd�}nt|t�st	d��|j
�J�|js|j
d||fS|j�J�dt|�dzz
}|t|f|z�z
}tjd�}tj|j�}t|tj|�t!��j#�}|j%|�|j'�z}|j
|||fS)zKFormats `secret` to make possible to pass it to the
    Secret Service API.zutf-8zsecret must be bytesr/��)r9rL�encode�bytes�	TypeErrorr[rZ�aes_key�len�os�urandomr�AESrr�CBCr�	encryptor�update�finalize)r]rbrc�padding�aes_iv�aesrp�encrypted_secrets        r.�
format_secretrwes���&�#�����w�'��
���
&��.�/�/����*�*�*�����#�#�S�&�,�?�?��?�?�&�&�&��c�&�k�C�'�(�G�
�e�W�J��(�)�)�F�
�Z�Z��
�F�
�.�.����
)�C��s�E�I�I�f�-��/@�A�K�K�M�I� �'�'��/�)�2D�2D�2F�F��������	�r/�prompt_pathc�,�t|t|�}t|tdtj��}|j|�5}|j
ddd�|j|�j\}}ddd��J��J�||fS#1swY�xYw)z�Executes the prompt in a blocking mode.

    :returns: a tuple; the first element is a boolean value showing
              whether the operation was dismissed, the second element
              is a list of unlocked object paths
    �	Completed)r$r%�member�typer!rSrTN)	r#�PROMPT_IFACErr
�signal�filterr@�recv_until_filteredr6)r&rx�prompt�rule�signals�	dismissedr_s       r.�exec_promptr��s��� ��\�:�
F�F��
���
�
�
�	�D�
�	�	�4�	 �I�G����H�c�2�&�&�:�:�7�C�H�H��	�6�I�� � � ������f���I�I�s�2B
�
B�pathsc��ttt|�}|jdd|�\}}t	|�dkDrt||�\}\}}|dk(sJ�|Sy)z�Requests unlocking objects specified in `paths`.
    Returns a boolean representing whether the operation was dismissed.

    .. versionadded:: 2.1.2�Unlock�ao�F)r#rrUr@rkr�)r&r�r\�unlocked_pathsr�r�r>�unlockeds        r.�unlock_objectsr��sa��
!��-��D�G�$�\�\�(�D�%�@��N�F�
�6�{�Q��+6�z�6�+J�(�	�(�I�x��D� � � ���r/c��ttt��}tdd|��}d|_|jdd|j
��y)z�Adds match rules for the given connection.

    Currently it matches all messages from the Prompt interface, as the
    mock service (unlike GNOME Keyring) does not specify the signal
    destination.

    .. versionadded:: 3.1
    )�senderr%z/org/freedesktop/DBuszorg.freedesktop.DBus)r$r%r&�AddMatchrSN)rr+r}r#�bus_namer@�	serialise)r&r��dbuss   r.�add_match_rulesr��sC���H��=�D��#:�(>�)3�5�D�+�D�M��I�I�j�#�t�~�~�/�0r/)3rKrl�typingrrr�jeepneyrrrr	r
rr�jeepney.io.blockingr
�secretstorage.definesrrrrrrrrrr�secretstorage.dhcryptorr�secretstorage.exceptionsrr�&cryptography.hazmat.primitives.ciphersrrr�cryptography.hazmat.backendsrr+rUr}r#rarhrLrw�boolr�r�r�rMr/r.�<module>r�s��.�
�#�#����/�3�3�3�9�$�L�L�8�$���I�%�
��8�#��)%��)%�X�^����4�7��E�� #��(-�c�5�%��.D�(E��6�N�� ��%*�4��c��?�%;��.�~��d�3�i��D��1��1�4�1r/

Zerion Mini Shell 1.0