:right-sidebar: True SecretExchange =================================================================== .. currentmodule:: gi.repository.Gcr .. class:: SecretExchange(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` Allows exchange of secrets between two processes on the same system without exposing those secrets to things like loggers, non-pageable memory etc. This does not protect against active attacks like MITM attacks. Each side creates a secret exchange object, and one of the sides calls :obj:`~gi.repository.SecretExchange.begin`\. This creates a string, which should be passed to the other side. Each side passes the strings it receives into :obj:`~gi.repository.SecretExchange.receive`\. In order to send a reply (either with or without a secret) use :obj:`~gi.repository.SecretExchange.send`\. A side must have successfully called :obj:`~gi.repository.SecretExchange.receive` before it can use :obj:`~gi.repository.SecretExchange.send`\. The secret exchange objects can be used for multiple iterations of the conversation, or for just one request/reply. The only limitation being that the initial request cannot contain a secret. Caveat: Information about the approximate length (rounded up to the nearest 16 bytes) may be leaked. If this is considered inacceptable, do not use :obj:`~gi.repository.Gcr.SecretExchange`\. Constructors ------------ .. rst-class:: interim-class .. class:: SecretExchange :no-index: .. classmethod:: new(protocol: str | None = None) -> ~gi.repository.Gcr.SecretExchange Create a new secret exchange object. Specify a protocol of :const:`None` to allow any protocol. This is especially relevant on the side of the exchange that does not call :obj:`~gi.repository.SecretExchange.begin`\, that is the originator. Currently the only protocol supported is :const:`~gi.repository.Gcr.SECRET_EXCHANGE_PROTOCOL_1`. :param protocol: the exchange protocol to use Methods ------- .. rst-class:: interim-class .. class:: SecretExchange :no-index: .. method:: begin() -> str Begin the secret exchange. The resulting string should be sent to the other side of the exchange. The other side should use :obj:`~gi.repository.SecretExchange.receive` to process the string. .. method:: do_derive_transport_key(self, peer: int, n_peer: int) -> bool :param peer: :param n_peer: .. method:: do_generate_exchange_key(self, scheme: str, public_key: int, n_public_key: int) -> bool :param scheme: :param public_key: :param n_public_key: .. method:: get_protocol() -> str Will return :const:`None` if no protocol was specified, and either :obj:`~gi.repository.SecretExchange.begin` or :obj:`~gi.repository.SecretExchange.receive` have not been called successfully. .. method:: get_secret() -> list[str] Returns the last secret received. If no secret has yet been received this will return :const:`None`. The string is owned by the :obj:`~gi.repository.Gcr.SecretExchange` object and will be valid until the next time that :func:`~gi.repository.Gcr.SecretExchange.receive` is called on this object, or the object is destroyed. Depending on the secret passed into the other side of the secret exchange, the result may be a binary string. It does however have a null terminator, so if you're certain that it is does not contain arbitrary binary data, it can be used as a string. .. method:: receive(exchange: str) -> bool Receive a string from the other side of secret exchange. This string will have been created by :obj:`~gi.repository.SecretExchange.begin` or :obj:`~gi.repository.SecretExchange.send`\. After this call completes successfully the value returned from :func:`~gi.repository.Gcr.SecretExchange.get_secret` will have changed. :param exchange: the string received .. method:: send(secret: str | None, secret_len: int) -> str Send a reply to the other side of the secret exchange, optionally sending a secret. :obj:`~gi.repository.SecretExchange.receive` must have been successfully called at least once on this object. In other words this object must have received data from the other side of the secret exchange, before we can send a secret. :param secret: optionally, a secret to send to the other side :param secret_len: length of ``secret``\, or -1 if null terminated Properties ---------- .. rst-class:: interim-class .. class:: SecretExchange :no-index: .. attribute:: props.protocol :type: str The type of the None singleton. Virtual Methods --------------- .. rst-class:: interim-class .. class:: SecretExchange :no-index: .. method:: do_derive_transport_key(peer: int, n_peer: int) -> bool The type of the None singleton. :param peer: :param n_peer: .. method:: do_generate_exchange_key(scheme: str, public_key: int, n_public_key: int) -> bool The type of the None singleton. :param scheme: :param public_key: :param n_public_key: Fields ------ .. rst-class:: interim-class .. class:: SecretExchange :no-index: .. attribute:: parent .. attribute:: pv