+
    BÆÚjóJ  ã                   ó  € R t ^ RIHtHt ^ RIHtHtHt ^ RIH	t	H
t
 ^RIHtHtHtHt ^RIHt   ! R R]4      t ! R R	]4      t ! R
 R]4      t ! R R]4      tR t ! R R]4      t ! R R]4      t ! R R]4      tR# )aÍ  libolm Session module.

This module contains the Olm Session part of the Olm library.

It is used to establish a peer-to-peer encrypted communication channel between
two Olm accounts.

Examples:
    >>> alice = Account()
    >>> bob = Account()
    >>> bob.generate_one_time_keys(1)
    >>> id_key = bob.identity_keys['curve25519']
    >>> one_time = list(bob.one_time_keys["curve25519"].values())[0]
    >>> session = OutboundSession(alice, id_key, one_time)

)ÚbytesÚsuper)ÚAnyStrÚOptionalÚType)ÚffiÚlib)ÚURANDOMÚto_bytearrayÚto_bytesÚto_unicode_str)Útrack_for_finalizationc                   ó   € ] tR t^1tRtRtR# )ÚOlmSessionErrorzlibolm Session exception.© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__static_attributes__r   ó    Ú‚/opt/data/installs/351f81cc06284494/environments/aa258815729c481f8402f54f4c368f83/venv/lib/python3.14/site-packages/olm/session.pyr   r   1   s   † Ý#r   r   c                   ó,   a € ] tR t^5t o R tR tRtV tR# )Ú_OlmMessagec                óD   € V'       g   \        R 4      hWn        W n        R# )úCiphertext can't be emptyN)Ú
ValueErrorÚ
ciphertextÚmessage_type)Úselfr   r   s   &&&r   Ú__init__Ú_OlmMessage.__init__6   s   € çÜÐ8Ó9Ð9ð %ŒØ(Ör   c                ó    € \         P                  R \         P                  R/pWP                  ,          pRP	                  W P
                  4      # )ÚPRE_KEYÚMESSAGEz{} {})r   ÚOLM_MESSAGE_TYPE_PRE_KEYÚOLM_MESSAGE_TYPE_MESSAGEr   Úformatr   )r    Útype_to_prefixÚprefixs   &  r   Ú__str__Ú_OlmMessage.__str__@   sD   € ô ×(Ñ(¨)Ü×(Ñ(¨)ð
ˆð
  × 1Ñ 1Õ2ˆØ�~‰~˜f§o¡oÓ6Ð6r   )r   r   N)r   r   r   r   r!   r+   r   Ú__classdictcell__©Ú__classdict__s   @r   r   r   5   s   ø‡ € ò)÷7ð 7r   r   c                   ó0   a € ] tR t^Kt o RtR tR tRtV tR# )ÚOlmPreKeyMessagez™Olm prekey message class

Prekey messages are used to establish an Olm session. After the first
message exchange the session switches to normal messages
c                óN   € \         P                  W\        P                  4       R# )zCreate a new Olm prekey message with the supplied ciphertext

Args:
    ciphertext(str): The ciphertext of the prekey message.
N)r   r!   r   r&   ©r    r   s   &&r   r!   ÚOlmPreKeyMessage.__init__R   ó   € ô 	×Ñ˜T¬s×/KÑ/KÖLr   c                ó8   € R P                  V P                  4      # )zOlmPreKeyMessage({})©r(   r   ©r    s   &r   Ú__repr__ÚOlmPreKeyMessage.__repr__[   s   € à%×,Ñ,¨T¯_©_Ó=Ð=r   r   N©	r   r   r   r   r   r!   r9   r   r-   r.   s   @r   r1   r1   K   s   ø‡ € ñòM÷>ð >r   r1   c                   ó0   a € ] tR t^`t o RtR tR tRtV tR# )Ú
OlmMessagezOlm message classc                óN   € \         P                  W\        P                  4       R# )zqCreate a new Olm message with the supplied ciphertext

Args:
    ciphertext(str): The ciphertext of the message.
N)r   r!   r   r'   r3   s   &&r   r!   ÚOlmMessage.__init__c   r5   r   c                ó8   € R P                  V P                  4      # )zOlmMessage({})r7   r8   s   &r   r9   ÚOlmMessage.__repr__l   s   € à×&Ñ& t§¡Ó7Ð7r   r   Nr;   r.   s   @r   r=   r=   `   s   ø‡ € ÙòM÷8ð 8r   r=   c                 ó2   € \         P                  ! V 4       R # ©N)r   Úolm_clear_session)Úsessions   &r   Ú_clear_sessionrF   q   s   € ä×Ò˜'Ö"r   c                   ó”   a a€ ] tR t^vt oRtV 3R ltR tR tRR lt]	RR l4       t
R tRR lt]R	 4       tRR
 ltRR ltRtVtV ;t# )ÚSessionz²libolm Session class.
This is an abstract class that can't be instantiated except when unpickling
a previously pickled InboundSession or OutboundSession object with
from_pickle.
c                ó  <€ \        4       P                  V 4      p\        P                  ! R \        P
                  ! 4       4      Vn        \        P                  ! VP                  4      Vn        \        WP                  \        4       V# )úchar[])r   Ú__new__r   Únewr   Úolm_session_sizeÚ_bufÚolm_sessionÚ_sessionr   rF   )ÚclsÚobjÚ	__class__s   & €r   rK   ÚSession.__new__}   sW   ø€ ô ‹g�o‰o˜cÓ"ˆÜ—7’7˜8¤S×%9Ò%9Ó%;Ó<ˆŒÜ—’ s§x¡xÓ0ˆŒÜ˜s§L¡L´.ÔAØˆ
r   c                óB   € \        V 4      \        J d   \        R 4      hR# )z&Session class may not be instantiated.N)ÚtyperH   Ú	TypeErrorrP   r8   s   &r   r!   ÚSession.__init__†   s   € ä�‹:œÓ ÜÐDÓEÐEár   c                óÔ   € V\         P                  ! 4       8w  d   R # \        P                  ! \         P                  ! V P
                  4      4      P                  4       p\        V4      hrC   )r   Ú	olm_errorr   ÚstringÚolm_session_last_errorrP   Údecoder   )r    ÚretÚ
last_errors   && r   Ú_check_errorÚSession._check_errorŽ   sD   € à”#—-’-“/Ô!Ùä—Z’Z¤× :Ò :¸4¿=¹=Ó IÓJ×QÑQÓSˆ
ä˜jÓ)Ð)r   c           	     óò  € V'       d   \        VR4      MRp\        P                  ! V P                  4      p\        P
                  ! RV4      p V P                  \        P                  ! V P                  \        P                  ! V4      \        V4      WC4      4       \        ^ \        V4      4       F  p^ W%&   K	  	  \        P                  ! WC4      #   \        ^ \        T4      4       F  p^ Y%&   K	  	  i ; i)aF  Store an Olm session.

Stores a session as a base64 string. Encrypts the session using the
supplied passphrase. Returns a byte object containing the base64
encoded string of the pickled session. Raises OlmSessionError on
failure.

Args:
    passphrase(str, optional): The passphrase to be used to encrypt
        the session.
úutf-8r   rJ   )Ú	bytearrayr   Úolm_pickle_session_lengthrP   r   rL   r`   Úolm_pickle_sessionÚfrom_bufferÚlenÚrangeÚunpack)r    Ú
passphraseÚbyte_keyÚpickle_lengthÚpickle_bufferÚis   &&    r   ÚpickleÚSession.pickle—   sÇ   € ÷ 6@”9˜Z¨Ô1ÀSˆä×5Ò5°d·m±mÓDˆÜŸš ¨-Ó8ˆð		$Ø×ÑÜ×&Ò& t§}¡}Ü'*§¢°xÓ'@Ü'*¨8£}Ø'4óEôFô ˜1œc (›mÖ,�Ø"#�H“Kñ -ô �zŠz˜-Ó7Ð7øô ˜1œc (›mÖ,�Ø"#�H“Kò -ús   ÁAC Ã"C6c           	     óê  € V'       g   \        R4      hV'       d   \        VR4      MRp\        P                  ! RV4      pV P	                  V 4      p \
        P                  ! VP                  \        P                  ! V4      \        V4      V\        V4      4      pVP                  V4       \        ^ \        V4      4       F  p^ W7&   K	  	  V#   \        ^ \        T4      4       F  p^ Y7&   K	  	  i ; i)aS  Load a previously stored Olm session.

Loads a session from a pickled base64 string and returns a Session
object. Decrypts the session using the supplied passphrase. Raises
OlmSessionError on failure. If the passphrase doesn't match the one
used to encrypt the session then the error message for the
exception will be "BAD_ACCOUNT_KEY". If the base64 couldn't be decoded
then the error message will be "INVALID_BASE64".

Args:
    pickle(bytes): Base64 encoded byte string containing the pickled
        session
    passphrase(str, optional): The passphrase used to encrypt the
        session.
zPickle can't be emptyrc   r   rJ   )r   rd   r   rL   rK   r   Úolm_unpickle_sessionrP   rg   rh   r`   ri   )rQ   rp   rk   rl   rn   rE   r^   ro   s   &&&     r   Úfrom_pickleÚSession.from_pickle¶   sÐ   € ÷$ ÜÐ4Ó5Ð5ç5?”9˜Z¨Ô1ÀSˆäŸš ¨&Ó1ˆà—+‘+˜cÓ"ˆð
	$Ü×*Ò*¨7×+;Ñ+;Ü+.¯?ª?¸8Ó+DÜ+.¨x«=Ø+8Ü+.¨v«;ó	8ˆCð
 × Ñ  Ô%ô ˜1œc (›mÖ,�Ø"#�H“Kñ -ð ˆøô ˜1œc (›mÖ,�Ø"#�H“Kò -ús   ÁAC Ã"C2c                óà  € \        V4      p\        P                  ! V P                  4      p\	        V4      p \        P
                  ! V P                  4      pV P                  V4       \        P                  ! V P                  \        V4      4      p\        P                  ! RV4      pV P                  \        P                  ! V P                  \        P                  ! V4      \        V4      \        P                  ! V4      VWv4      4       W!Jd!   \        ^ \        V4      4       F  p^ W(&   K	  	  T\        P                  8X  d/   \        \        P                   ! TT4      P#                  4       4      # T\        P$                  8X  d/   \'        \        P                   ! TT4      P#                  4       4      # \)        R4      h  Y!Jd"   \        ^ \        T4      4       F  p^ Y(&   K	  	  i i ; i)zÐEncrypts a message using the session. Returns the ciphertext as a
base64 encoded string on success. Raises OlmSessionError on failure.

Args:
    plaintext(str): The plaintext message that will be encrypted.
rJ   zUnknown message type)r
   r   Úolm_encrypt_random_lengthrP   r	   Úolm_encrypt_message_typer`   Úolm_encrypt_message_lengthrh   r   rL   Úolm_encryptrg   ri   r&   r1   rj   r]   r'   r=   r   )	r    Ú	plaintextÚbyte_plaintextÚr_lengthÚrandomr   Úciphertext_lengthÚciphertext_bufferro   s	   &&       r   ÚencryptÚSession.encryptß   s›  € ô & iÓ0ˆä×0Ò0°·±Ó?ˆÜ˜Ó"ˆð	*Ü×7Ò7¸¿¹ÓFˆLà×Ñ˜lÔ+ä #× >Ò >Ø—‘œs >Ó2ó!Ðô !$§¢¨Ð2CÓ DÐà×ÑœcŸošoØ—‘Ü—’ Ó/´°^Ó1DÜ—’ Ó'¨Ø!ó	ô ð Ó.Ü˜q¤# nÓ"5Ö6�AØ()�NÓ%ñ 7ð œ3×7Ñ7Ô7Ü#Ü—
’
Ø%Ø%ó÷ ‘&“(ó	ð ð
 œS×9Ñ9Ô9ÜÜ—
’
Ø%Ø%ó÷ ‘&“(ó	ð ô Ð3Ó4Ð4øð# Ó.Ü˜q¤# nÓ"5Ö6�AØ()�NÓ%ò 7ð /ús   ¸CG Ç(G-c                ó„  € VP                   '       g   \        R4      h\        VP                   4      p\        P                  ! RV4      p\
        P                  ! V P                  VP                  V\        V4      4      pV P                  V4       \        P                  ! RV4      p\        P                  ! RV4      p\
        P                  ! V P                  VP                  V\        V4      We4      pV P                  V4       \        \        P                  ! Wg4      VR7      p\
        P                  ! V^ V4       V# )a5  Decrypts a message using the session. Returns the plaintext string
on success. Raises OlmSessionError on failure. If the base64 couldn't
be decoded then the error message will be "INVALID_BASE64". If the
message is for an unsupported version of the protocol the error message
will be "BAD_MESSAGE_VERSION". If the message couldn't be decoded then
the error message will be "BAD_MESSAGE_FORMAT". If the MAC on the
message was invalid then the error message will be "BAD_MESSAGE_MAC".

Args:
    message(OlmMessage): The Olm message that will be decrypted. It can
        be either an OlmPreKeyMessage or an OlmMessage.
    unicode_errors(str, optional): The error handling scheme to use for
        unicode decoding errors. The default is "replace" meaning that
        the character that was unable to decode will be replaced with
        the unicode replacement character (U+FFFD). Other possible
        values are "strict", "ignore" and "xmlcharrefreplace" as well
        as any other name registered with codecs.register_error that
        can handle UnicodeEncodeErrors.
r   rJ   )Úerrors)r   r   r   r   rL   r   Ú olm_decrypt_max_plaintext_lengthrP   r   rh   r`   Úolm_decryptr   rj   Úmemset)	r    ÚmessageÚunicode_errorsÚbyte_ciphertextr€   Úmax_plaintext_lengthÚplaintext_bufferÚplaintext_lengthr{   s	   &&&      r   ÚdecryptÚSession.decrypt  s  € ð* ×!×!Ð!ÜÐ8Ó9Ð9ä" 7×#5Ñ#5Ó6ˆô  ŸGšG H¨oÓ>Ðä"×CÒCØ�M‰M˜7×/Ñ/Ð1BÜ�Ó ó 
Ðð 	×ÑÐ.Ô/ÜŸ7š7 8Ð-AÓBÐô  ŸGšG H¨oÓ>ÐÜŸ?š?Ø�M‰M˜7×/Ñ/Øœs ?Ó3Øó
Ðð
 	×ÑÐ*Ô+Ü"Ü�JŠJÐ'Ó:Ø!ô
ˆ	ô 	�
Š
Ð# QÐ(<Ô=àÐr   c                ó  € \         P                  ! V P                  4      p\        P                  ! RV4      pV P                  \         P                  ! V P                  W!4      4       \        P                  ! W!4      P                  4       # )zYstr: An identifier for this session. Will be the same for both
ends of the conversation.
rJ   )	r   Úolm_session_id_lengthrP   r   rL   r`   Úolm_session_idrj   r]   )r    Ú	id_lengthÚ	id_buffers   &  r   ÚidÚ
Session.idH  sd   € ô ×-Ò-¨d¯m©mÓ<ˆ	Ü—G’G˜H iÓ0ˆ	à×ÑÜ×Ò˜tŸ}™}¨iÓCô	
ô �zŠz˜)Ó/×6Ñ6Ó8Ð8r   c           	     ó$  € \        V\        4      '       g   \        R4      hVP                  '       g   \	        R4      hRp\        VP                  4      p\        P                  ! RV4      pV'       dW   \        V4      p\        P                  ! V P                  \        P                  ! V4      \        V4      V\        V4      4      pM+\        P                  ! V P                  V\        V4      4      pV P                  V4       \        V4      # )a?  Checks if the PRE_KEY message is for this in-bound session.
This can happen if multiple messages are sent to this session before
this session sends a message in reply. Returns True if the session
matches. Returns False if the session does not match. Raises
OlmSessionError on failure. If the base64 couldn't be decoded then the
error message will be "INVALID_BASE64". If the message was for an
unsupported protocol version then the error message will be
"BAD_MESSAGE_VERSION". If the message couldn't be decoded then then the
error message will be * "BAD_MESSAGE_FORMAT".

Args:
    message(OlmPreKeyMessage): The Olm prekey message that will checked
        if it is intended for this session.
    identity_key(str, optional): The identity key of the sender. To
        check if the message was also sent using this identity key.
z0Matches can only be called with prekey messages.r   NrJ   )Ú
isinstancer1   rW   r   r   r   r   rL   r   Ú olm_matches_inbound_session_fromrP   rg   rh   Úolm_matches_inbound_sessionr`   Úbool)r    rˆ   Úidentity_keyr^   rŠ   Úmessage_bufferÚbyte_id_keys   &&&    r   ÚmatchesÚSession.matchesV  sÛ   € ô$ ˜'Ô#3×4Ò4ÜÐNÓOÐOà×!×!Ð!ÜÐ8Ó9Ð9àˆä" 7×#5Ñ#5Ó6ˆô Ÿš ¨?Ó;ˆçÜ" <Ó0ˆKä×6Ò6Ø—‘Ü—’ Ó,¬c°+Ó.>Ø¤ OÓ 4ó‰Cô ×1Ò1Ø—‘Ø¤ OÓ 4ó6ˆCð 	×Ñ˜#Ôä�C‹yÐr   c                óº   € \         P                  ! RV4      p\        P                  ! V P                  W!4       \         P
                  ! V4      P                  4       # )ag  
Generate a string describing the internal state of an olm session
for debugging and logging purposes.

Args:
    buffer_length(int): The size of buffer for the string.
        If the buffer is not large enough to hold the entire string, it
        will be truncated and will end with "...".  A buffer length of
        600 will be enough to hold any output.
rJ   )r   rL   r   Úolm_session_describerP   r[   r]   )r    Úbuffer_lengthÚdescribe_buffers   && r   ÚdescribeÚSession.describe‡  sE   € ô Ÿ'š' (¨MÓ:ˆÜ× Ò Ø�M‰M˜?ô	
ô �zŠz˜/Ó*×1Ñ1Ó3Ð3r   )rP   )Ú )ÚreplacerC   )iX  )r   r   r   r   r   rK   r!   r`   rp   Úclassmethodrt   r�   rŽ   Úpropertyr•   rŸ   r¥   r   r-   Ú__classcell__©rS   r/   s   @@r   rH   rH   v   sc   ù‡ € ñõò*ò*ô8ð> ó&ó ð&òP05ôd5ðn ñ9ó ð9ô/÷b4ô 4r   rH   c                   óJ   a a€ ] tR tRt oRtRV 3R lltRV 3R lltRtVtV ;t	# )ÚInboundSessioniš  z9Inbound Olm session for p2p encrypted communication.
    c                ó6   <€ \        4       P                  V 4      # rC   ©r   rK   )rQ   Úaccountrˆ   rœ   rS   s   &&&&€r   rK   ÚInboundSession.__new__ž  ó   ø€ ä‹w�‰˜sÓ#Ð#r   c                óL  <€ VP                   '       g   \        R4      h\        4       P                  4        \	        VP                   4      p\
        P                  ! RV4      pV'       du   \	        V4      p\
        P                  ! RV4      pV P                  \        P                  ! V P                  VP                  V\        V4      V\        V4      4      4       R# V P                  \        P                  ! V P                  VP                  V\        V4      4      4       R# )a…  Create a new inbound Olm session.

Create a new in-bound session for sending/receiving messages from an
incoming prekey message. Raises OlmSessionError on failure. If the
base64 couldn't be decoded then error message will be "INVALID_BASE64".
If the message was for an unsupported protocol version then
the errror message will be "BAD_MESSAGE_VERSION". If the message
couldn't be decoded then then the error message will be
"BAD_MESSAGE_FORMAT". If the message refers to an unknown one-time
key then the error message will be "BAD_MESSAGE_KEY_ID".

Args:
    account(Account): The Olm Account that will be used to create this
        session.
    message(OlmPreKeyMessage): The Olm prekey message that will checked
        that will be used to create this session.
    identity_key(str, optional): The identity key of the sender. To
        check if the message was also sent using this identity key.
r   rJ   N)r   r   r   r!   r   r   rL   r`   r   Úolm_create_inbound_session_fromrP   Ú_accountrh   Úolm_create_inbound_session)	r    r±   rˆ   rœ   rŠ   r�   rž   Úidentity_key_bufferrS   s	   &&&&    €r   r!   ÚInboundSession.__init__¢  sß   ø€ ð* ×!×!Ð!ÜÐ8Ó9Ð9ä‹×ÑÔÜ" 7×#5Ñ#5Ó6ˆÜŸš ¨?Ó;ˆçÜ" <Ó0ˆKÜ"%§'¢'¨(°KÓ"@ÐØ×Ñœc×AÒAØ—‘Ø× Ñ Ø#¤S¨Ó%5Ø¤ OÓ 4ó	ö ð ×Ñœc×<Ò<Ø—‘Ø× Ñ Ø¤ OÓ 4óö r   r   rC   ©
r   r   r   r   r   rK   r!   r   r-   r«   r¬   s   @@r   r®   r®   š  s   ù‡ € ñ÷$÷*÷ *r   r®   c                   óB   a a€ ] tR tRt oRtV 3R ltV 3R ltRtVtV ;t	# )ÚOutboundSessioniÏ  z5Outbound Olm session for p2p encrypted communication.c                ó6   <€ \        4       P                  V 4      # rC   r°   )rQ   r±   rœ   Úone_time_keyrS   s   &&&&€r   rK   ÚOutboundSession.__new__Ò  r³   r   c                ó"  <€ V'       g   \        R4      hV'       g   \        R4      h\        4       P                  4        \        V4      p\        V4      p\        P
                  ! V P                  4      p\        V4      pV P                  \        P                  ! V P                  VP                  \        P                  ! V4      \        V4      \        P                  ! V4      \        V4      \        P                  ! V4      V4      4       R# )a,  Create a new outbound Olm session.

Creates a new outbound session for sending messages to a given
identity key and one-time key.

Raises OlmSessionError on failure. If the keys couldn't be decoded as
base64 then the error message will be "INVALID_BASE64".

Args:
    account(Account): The Olm Account that will be used to create this
        session.
    identity_key(str): The identity key of the person with whom we want
        to start the session.
    one_time_key(str): A one-time key from the person with whom we want
        to start the session.
zIdentity key can't be emptyzOne-time key can't be emptyN)r   r   r!   r   r   Ú)olm_create_outbound_session_random_lengthrP   r	   r`   Úolm_create_outbound_sessionr¶   r   rg   rh   )	r    r±   rœ   r¾   rž   Úbyte_one_timeÚsession_random_lengthr~   rS   s	   &&&&    €r   r!   ÚOutboundSession.__init__Ö  sÊ   ø€ ÷$ ÜÐ:Ó;Ð;çÜÐ:Ó;Ð;ä‹×ÑÔä˜|Ó,ˆÜ  Ó.ˆä #× MÒ MØ�M‰Mó!Ðô Ð.Ó/ˆà×Ñœ#×9Ò9Ø�M‰MØ×ÑÜ�OŠO˜KÓ(¬#¨kÓ*:Ü�OŠO˜MÓ*¬C°Ó,>Ü�OŠO˜FÓ#Ð%:ó
ö 	r   r   rº   r¬   s   @@r   r¼   r¼   Ï  s   ù‡ € Ù?õ$÷(õ (r   r¼   N)r   Úbuiltinsr   r   Útypingr   r   r   Ú_libolmr   r   Ú_compatr	   r
   r   r   Ú	_finalizer   r±   ÚAccountÚ	Exceptionr   Úobjectr   r1   r=   rF   rH   r®   r¼   r   r   r   Ú<module>rÎ      s…   ðñ"÷$ "ß )Ñ )÷ ç DÓ DÝ -ð 	ô$�iô $ô7�&ô 7ô,>�{ô >ô*8�ô 8ò"#ô
a4ˆfô a4ôH	2�Wô 2ôj/�gö /r   