ó
    &ÝNjÆ•  ã                   ó€  • S r SSKrSSKrSSKrSSKrSSKJrJr  SSKJr  SSK	J
r
Jr  SSKJr  SSKJr  SSKJrJrJr  SSKrSS	KJr  SS
KJrJrJr  SSKJr  SSKJr  SSKJ r   SSK!J"r"J#r#J$r$  SSK%J&r&  SSK'J(r(  SSK)J*r*  SSK+J,r,J-r-  SSK.J/r/J0r0   SSK1J2r2  Sr5S r6 " S S\75      r8 " S S\5      r9\\ \\4   r:\9" \Rv                  Rx                  \Rz                  R|                  S9r>\9" \Rv                  R~                  \Rz                  R|                  S9r@ " S S5      rA " S S5      rBg! \3 a	    SSK4J2r2   N¤f = f) z!
Common API for all public keys.
é    N)ÚdecodebytesÚencodebytes)Ú	unhexlify)Úmd5Úsha256)Ú	RawIOBase)ÚPath)Ú
NamedTupleÚOptionalÚUnion)Údefault_backend)Ú
asymmetricÚpaddingÚserialization)ÚEllipticCurvePrivateKey)ÚEd25519PrivateKey)ÚRSAPrivateKey)ÚCipherÚ
algorithmsÚmodes)Úutil)Úo600)ÚMessage)ÚPasswordRequiredExceptionÚSSHException)ÚbÚu)Ú	TripleDESs   openssh-key-v1 c                 ó²   • U S   nSUs=::  a  S:  a   U $   US:”  a  [        S5      e[        U5       H  nXU-
     US-   :w  d  M  [        S5      e   U S U*  $ )Néÿÿÿÿé    é   é   zInvalid keyé   )r   Úrange)ÚdataÚpadding_lengthÚis      ÚJ/home/mande/repo/quber/.venv/lib/python3.13/site-packages/paramiko/pkey.pyÚ_unpad_opensshr*   C   sw   € ð ˜"‘X€NØˆ~Õ$ Ô$Øˆð %à˜ÓÜ˜=Ó)Ð)Ü�>Ö"ˆØ�NÑ"Ñ# q¨1¡uÕ,Ü˜}Ó-Ð-ñ #ð Ð �.�Ð!Ð!ó    c                   ó(   • \ rS rSrSrSS jrS rSrg)ÚUnknownKeyTypeéR   zC
An unknown public/private key algorithm was attempted to be read.
Nc                 ó   • Xl         X l        g ©N©Úkey_typeÚ	key_bytes)Úselfr2   r3   s      r)   Ú__init__ÚUnknownKeyType.__init__W   s   € Ø ŒØ"�r+   c                 óP   • SU R                   < S[        U R                  5       S3$ )NzUnknownKeyType(type=z	, bytes=<z>))r2   Úlenr3   ©r4   s    r)   Ú__str__ÚUnknownKeyType.__str__[   s'   € Ø% d§m¡mÑ%6°iÄÀDÇNÁNÓ@SÐ?TÐTVÐWÐWr+   ©r3   r2   ©NN)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r5   r:   Ú__static_attributes__© r+   r)   r-   r-   R   s   † ñô#õXr+   r-   c                   óR   • \ rS rSr% \R
                  \S'   \R                  \S'   Srg)Ú
FileFormaté_   ÚformatÚencodingrD   N)	r>   r?   r@   rA   r   ÚPrivateFormatÚ__annotations__ÚEncodingrC   rD   r+   r)   rF   rF   _   s   ‡ Ø×'Ñ'Ó'Ø×$Ñ$Ö$r+   rF   )rH   rI   c            
       óÎ  • \ rS rSrSr\R                  SS\R                  S.\R                  SS\R                  S.\	SS\R                  S.S.r
S	rS
r\R                  " S5      r\R                  " S5      r\S8S\\   4S jj5       r\ S8S\S\S\\   4S jj5       r\S 5       rS9S jrS rS rS rS rS r\S 5       r S r!\S 5       r"S r#S r$S r%\S  5       r&S! r'S8S" jr(S# r)\S8S$ j5       r*\S8S% j5       r+S\,4S&\S\\   S'\-4S( jjr.S\,4S)\/S\\   S'\-4S* jjr0S8S+ jr1S8S, jr2S- r3S. r4S/ r5S0 r6 S8S&\S1\7S'\-S\\   4S2 jjr8 S8S3\/S1\7S'\-S\\   4S4 jjr9S5 r:S6 r;S7r<g):ÚPKeyév   zt
Base class for public keys.

Also includes some "meta" level convenience constructors such as
`.from_type_string`.
é   )ÚcipherÚkeysizeÚ	blocksizeÚmoder!   é   é   )zAES-128-CBCzAES-256-CBCzDES-EDE3-CBCr$   é   z/^-{5}BEGIN (RSA|EC|OPENSSH) PRIVATE KEY-{5}\s*$z-^-{5}END (RSA|EC|OPENSSH) PRIVATE KEY-{5}\s*$NÚpasswordc                 óœ  • SSK JnJnJn  [	        U 5      n Sn[	        U 5      R                  U5      (       a  U S[        U5      *  nU nOU nX-   n[        U5      R                  5       n[        U5      R                  5       nUR                  5       n [        R                  " X�S9n	Sn
[        U	[        R                   R"                  5      (       a  Un
Ok[        U	[        R$                  R&                  5      (       a  Un
O?[        U	[        R(                  R*                  5      (       a  Un
O[-        X‰R.                  S9eUR1                  5        nU
R3                  X±S9nSSS5        UR5                  5       (       a  WR7                  [	        U5      5        W$ ! [         a    [        R                  " X�S9n	 GNf = f! , (       d  f       Nd= f)aÅ  
Attempt to instantiate appropriate key subclass from given file path.

:param pathlib.Path path: The path to load (may also be a `str`).
:param str password: Optional decryption password.

:returns:
    A `PKey` subclass instance.

:raises:
    `UnknownKeyType`, if our crypto backend doesn't know this key type.

.. versionadded:: 3.2
.. versionchanged:: 5.0
    Renamed ``passphrase`` argument to ``password`` for consistency
    with older methods.
r   )ÚECDSAKeyÚ
Ed25519KeyÚRSAKeyz	-cert.pubN©r&   rX   r<   ©rX   )ÚparamikorZ   r[   r\   ÚstrÚendswithr8   r	   Ú
expanduserÚ
read_bytesr   Úload_ssh_private_keyÚ
ValueErrorÚload_pem_private_keyÚ
isinstancer   Úrsar   Úed25519r   Úecr   r-   Ú	__class__ÚopenÚfrom_private_keyÚexistsÚload_certificate)ÚpathrX   rZ   r[   r\   Úcert_suffixÚkey_pathÚ	cert_pathr&   ÚloadedÚ	key_classÚfdÚkeys                r)   Ú	from_pathÚPKey.from_path˜   s…  € ÷* 	:Ñ9ô �4‹yˆð "ˆÜˆt‹9×Ñ˜k×*Ñ*ØÐ/œs ;Ó/Ð/Ð0ˆHØ‰IàˆHØÑ*ˆIä˜“>×,Ñ,Ó.ˆÜ˜“O×.Ñ.Ó0ˆ	à×"Ñ"Ó$ˆð	Ü"×7Ò7ØñˆFð  ˆ	Ü�fœjŸn™n×:Ñ:×;Ñ;Ø‰IÜ˜¤
× 2Ñ 2× DÑ D×EÑEØ"‰IÜ˜¤
§¡× EÑ E×FÑFØ ‰Iä ¨4×:JÑ:JÑKÐKØ�]‰]Œ_ Ø×,Ñ,¨RÐ,ÐCˆC÷ à×Ñ×Ñà× Ñ ¤ Y£Ô0Øˆ
øô5 ó 	Ü"×7Ò7Øñ‹Fð	ú÷* �_ús   ÂF ÅF=ÆF:Æ9F:Æ=
Gr2   r3   c                 óh   • SSK Jn  U H  nXR                  5       ;   d  M  U" XS9s  $    [        XS9e)aŠ  
Given type `str` & raw `bytes`, return a `PKey` subclass instance.

For example, ``PKey.from_type_string("ssh-ed25519", <public bytes>)``
will (if successful) return a new `.Ed25519Key`.

:param str key_type:
    The key type, eg ``"ssh-ed25519"``.
:param bytes key_bytes:
    The raw byte data forming the key material, as expected by
    subclasses' ``data`` parameter.
:param str password:
    Optional password used to decrypt ``key_bytes``.

:returns:
    A `PKey` subclass instance.

:raises:
    `UnknownKeyType`, if no registered classes knew about this type.

.. versionadded:: 3.2
.. versionchanged:: 5.0
    Added the ``password`` kwarg.
r   )Úkey_classesr]   r1   )r_   r{   Úidentifiersr-   )r2   r3   rX   r{   ru   s        r)   Úfrom_type_stringÚPKey.from_type_stringã   s8   € õ8 	)ã$ˆIØ×0Ñ0Ó2Õ2Ù  iÑCÒCñ %ô  hÑDÐDr+   c                 ó   • U R                   /$ )zÓ
returns an iterable of key format/name strings this class can handle.

Most classes only have a single identifier, and thus this default
implementation suffices; see `.ECDSAKey` for one example of an
override.
)Úname)Úclss    r)   r|   ÚPKey.identifiers  s   € ð —‘ˆzÐr+   c                 ó   • g)aö  
Create a new instance of this public key type.  If ``msg`` is given,
the key's public part(s) will be filled in from the message.  If
``data`` is given, the key's public part(s) will be filled in from
the string.

:param .Message msg:
    an optional SSH `.Message` containing a public key of this type.
:param bytes data:
    optional, the bytes of a public key of this type

:raises: `.SSHException` --
    if a key cannot be created from the ``data`` or ``msg`` given, or
    no key was passed in.
NrD   )r4   Úmsgr&   s      r)   r5   ÚPKey.__init__  s   € ð  	r+   c                 óÊ   • Sn[        U S5      (       a!  U R                  (       a  SU R                  < 3nSU R                   SU R                  5        SU R                   U S3$ )NÚ Úcommentz
, comment=z	PKey(alg=z, bits=z, fp=Ú))Úhasattrrˆ   Úalgorithm_nameÚget_bitsÚfingerprint)r4   rˆ   s     r)   Ú__repr__ÚPKey.__repr__/  sb   € Øˆä�4˜×#Ñ#¨¯¯Ø" 4§<¡<Ñ"2Ð3ˆGØ˜4×.Ñ.Ð/¨w°t·}±}³Ð6GÀuÈT×M]ÑM]ÐL^Ð_fÐ^gÐghÐiÐir+   c                 ó   • [        5       $ )z§
Return a string of an SSH `.Message` made up of the public part(s) of
this key.  This string is suitable for passing to `__init__` to
re-create the key object later.
©Úbytesr9   s    r)   ÚasbytesÚPKey.asbytes7  s   € ô ‹wˆr+   c                 ó"   • U R                  5       $ r0   )r“   r9   s    r)   Ú	__bytes__ÚPKey.__bytes__?  s   € Ø�|‰|‹~Ðr+   c                 ób   • [        U[        5      =(       a    U R                  UR                  :H  $ r0   )rg   rN   Ú_fields©r4   Úothers     r)   Ú__eq__ÚPKey.__eq__B  s!   € Ü˜%¤Ó&×H¨4¯<©<¸5¿=¹=Ñ+HÐHr+   c                 ó,   • [        U R                  5      $ r0   )Úhashr™   r9   s    r)   Ú__hash__ÚPKey.__hash__E  s   € Ü�D—L‘LÓ!Ð!r+   c                 ó   • [         er0   )ÚNotImplementedErrorr9   s    r)   r™   ÚPKey._fieldsH  s   € ä!Ð!r+   c                 ó   • g)z£
Return the name of this private key implementation.

:return:
    name of this private key type, in SSH terminology, as a `str` (for
    example, ``"ssh-rsa"``).
r‡   rD   r9   s    r)   Úget_nameÚPKey.get_nameL  s   € ð r+   c                 óÜ   • U R                  5       R                  SS5      nSnX!;   a"  UR                  US5      nUR                  5       $ UR                  S5      S   nUR                  5       $ )z‘
Return the key algorithm identifier for this key.

Similar to `get_name`, but aimed at pure algorithm name instead of SSH
protocol field value.
zssh-r‡   z-cert-v01@openssh.comz-certÚ-r   )r¦   ÚreplaceÚsplitÚupper)r4   r€   Ú	cert_tails      r)   r‹   ÚPKey.algorithm_nameV  se   € ð �}‰}‹×&Ñ& v¨rÓ2ˆà+ˆ	ØÓØ—<‘< 	¨7Ó3ˆDð �z‰z‹|Ðð —:‘:˜c“? 1Ñ%ˆDØ�z‰z‹|Ðr+   c                 ó   • g)z˜
Return the number of significant bits in this key.  This is useful
for judging the relative security of a key.

:return: bits in the key (as an `int`)
r   rD   r9   s    r)   rŒ   ÚPKey.get_bitsj  s   € ð r+   c                 ó   • g)zN
Return ``True`` if this key has the private part necessary for signing
data.
FrD   r9   s    r)   Úcan_signÚPKey.can_signv  s   € ð
 r+   c                 óP   • [        U R                  5       5      R                  5       $ )z³
Return an MD5 fingerprint of the public part of this key.  Nothing
secret is revealed.

:return:
    a 16-byte `string <str>` (binary) of the MD5 fingerprint, in SSH
    format.
)r   r“   Údigestr9   s    r)   Úget_fingerprintÚPKey.get_fingerprint}  s   € ô �4—<‘<“>Ó"×)Ñ)Ó+Ð+r+   c                 óî   • [        [        U 5      5      nUR                  R                  5       n[	        UR                  5       5      n[        U5      R                  5       R                  S5      nU SU 3$ )z�
Modern fingerprint property designed to be comparable to OpenSSH.

Currently only does SHA256 (the OpenSSH default).

.. versionadded:: 3.2
Ú=Ú:)	r   r’   r€   r¬   r   rµ   r   ÚstripÚrstrip)r4   ÚhashyÚ	hash_nameÚb64edÚcleaneds        r)   r�   ÚPKey.fingerprintˆ  s`   € ô ”u˜T“{Ó#ˆØ—J‘J×$Ñ$Ó&ˆ	Ü˜EŸL™L›NÓ+ˆÜ�E“(—.‘.Ó"×)Ñ)¨#Ó.ˆØ�˜A˜g˜YÐ'Ð'r+   c                 óf   • [        [        U R                  5       5      5      R                  SS5      $ )a  
Return a base64 string containing the public part of this key.  Nothing
secret is revealed.  This format is compatible with that used to store
public key files or recognized host keys.

:return: a base64 `string <str>` containing the public part of the key.
Ú
r‡   )r   r   r“   rª   r9   s    r)   Ú
get_base64ÚPKey.get_base64—  s'   € ô ”˜TŸ\™\›^Ó,Ó-×5Ñ5°d¸BÓ?Ð?r+   c                 ó   • [        5       $ )a}  
Sign a blob of data with this private key, and return a `.Message`
representing an SSH signature message.

:param bytes data:
    the data to sign.
:param str algorithm:
    the signature algorithm to use, if different from the key's
    internal name. Default: ``None``.
:return: an SSH signature `message <.Message>`.

.. versionchanged:: 2.9
    Added the ``algorithm`` kwarg.
r‘   )r4   r&   Ú	algorithms      r)   Úsign_ssh_dataÚPKey.sign_ssh_data¡  s   € ô ‹wˆr+   c                 ó   • g)a&  
Given a blob of data, and an SSH message representing a signature of
that data, verify that it was signed with this key.

:param bytes data: the data that was signed.
:param .Message msg: an SSH signature message
:return:
    ``True`` if the signature verifies correctly; ``False`` otherwise.
FrD   )r4   r&   r„   s      r)   Úverify_ssh_sigÚPKey.verify_ssh_sig²  s   € ð r+   c                 ó   • U " XS9nU$ )a%  
Create a key object by reading a private key file.  If the private
key is encrypted and ``password`` is not ``None``, the given password
will be used to decrypt the key (otherwise `.PasswordRequiredException`
is thrown).  Through the magic of Python, this factory method will
exist in all subclasses of PKey (such as `.RSAKey`), but
is useless on the abstract PKey class.

:param str filename: name of the file to read
:param str password:
    an optional password to use to decrypt the key file, if it's
    encrypted
:return: a new `.PKey` based on the given private key

:raises: ``IOError`` -- if there was an error reading the file
:raises: `.PasswordRequiredException` -- if the private key file is
    encrypted, and ``password`` is ``None``
:raises: `.SSHException` -- if the key file is invalid
)ÚfilenamerX   rD   )r�   rÎ   rX   rw   s       r)   Úfrom_private_key_fileÚPKey.from_private_key_file¾  s   € ñ* ˜8Ñ7ˆØˆ
r+   c                 ó   • U " XS9nU$ )a¦  
Create a key object by reading a private key from a file (or file-like)
object.  If the private key is encrypted and ``password`` is not
``None``, the given password will be used to decrypt the key (otherwise
`.PasswordRequiredException` is thrown).

:param file_obj: the file-like object to read from
:param str password:
    an optional password to use to decrypt the key, if it's encrypted
:return: a new `.PKey` based on the given private key

:raises: ``IOError`` -- if there was an error reading the key
:raises: `.PasswordRequiredException` --
    if the private key file is encrypted, and ``password`` is ``None``
:raises: `.SSHException` -- if the key file is invalid
)Úfile_objrX   rD   )r�   rÒ   rX   rw   s       r)   rm   ÚPKey.from_private_keyÖ  s   € ñ$ ˜8Ñ7ˆØˆ
r+   rÎ   Úfile_formatc                 ó<   • U R                  UU R                  UUS9  g)a×  
Write private key contents into a file.  If the password is not
``None``, the key is encrypted before writing.

:param str filename: name of the file to write
:param str password:
    an optional password to use to encrypt the key file
:param FileFormat file_format:
    what format+encoding pair to use; defaults to the original
    behavior, namely PEM.

:raises: ``IOError`` -- if there was an error writing the file
:raises: `.SSHException` -- if the key is invalid
©rÔ   rX   N)Ú_write_private_key_fileÚprivate_key)r4   rÎ   rX   rÔ   s       r)   Úwrite_private_key_fileÚPKey.write_private_key_fileë  s)   € ð( 	×$Ñ$ØØ×ÑØ#Øð	 	%ò 	
r+   rÒ   c                 ó<   • U R                  UU R                  UUS9  g)aì  
Write private key contents into a file (or file-like) object.  If the
password is not ``None``, the key is encrypted before writing.

:param file_obj: the file-like object to write into
:param str password: an optional password to use to encrypt the key
:param FileFormat file_format:
    what format+encoding pair to use; defaults to the original
    behavior, namely PEM.

:raises: ``IOError`` -- if there was an error writing to the file
:raises: `.SSHException` -- if the key is invalid
rÖ   N)Ú_write_private_keyrØ   )r4   rÒ   rX   rÔ   s       r)   Úwrite_private_keyÚPKey.write_private_key  s)   € ð& 	×ÑØØ×ÑØ#Øð	 	 ò 	
r+   c                 óx   • [        US5       nU R                  XU5      nSSS5        U$ ! , (       d  f       W$ = f)ab  
Read an SSH2-format private key file, looking for a string of the type
``"BEGIN xxx PRIVATE KEY"`` for some ``xxx``, base64-decode the text we
find, and return it as a string.  If the private key is encrypted and
``password`` is not ``None``, the given password will be used to
decrypt the key (otherwise `.PasswordRequiredException` is thrown).

:param str tag:
    ``"RSA"`` (or etc), the tag used to mark the data block.
:param str filename:
    name of the file to read.
:param str password:
    an optional password to use to decrypt the key file, if it's
    encrypted.
:return:
    the `bytes` that make up the private key.

:raises: ``IOError`` -- if there was an error reading the file.
:raises: `.PasswordRequiredException` -- if the private key file is
    encrypted, and ``password`` is ``None``.
:raises: `.SSHException` -- if the key file is invalid.
ÚrN)rl   Ú_read_private_key)r4   ÚtagrÎ   rX   Úfr&   s         r)   Ú_read_private_key_fileÚPKey._read_private_key_file   s:   € ô. �(˜CÔ  AØ×)Ñ)¨#°(Ó;ˆD÷ !àˆ÷ !Ô àˆús   �*ª
9c                 óT  • UR                  5       nU(       d  [        SR                  U5      5      eSnU R                  R	                  XE   5      n[        U5      S-
  nXW:  a7  U(       d0  US-  nU R                  R	                  XE   5      nXW:  a	  U(       d  M0  US-  nU(       a  UR                  S5      OS nU[        U5      :¼  d  Uc  [        SR                  U5      5      eUn	U R                  R	                  XI   5      nX—:  a7  U(       d0  U	S-  n	U R                  R	                  XI   5      nX—:  a	  U(       d  M0  X�:X  a!  U R                  XIU5      n
U R                  nXº4$ US:X  a#  U R                  XEU	 U5      n
U R                  nXº4$ [        SR                  X�5      5      e)Nzno lines in {} private key filer   r$   znot a valid {} private key fileÚOPENSSHz#encountered {} key, expected {} key)Ú	readlinesr   rH   Ú	BEGIN_TAGÚmatchr8   ÚgroupÚEND_TAGÚ_read_private_key_pemÚ_PRIVATE_KEY_FORMAT_ORIGINALÚ_read_private_key_opensshÚ_PRIVATE_KEY_FORMAT_OPENSSH)r4   râ   rã   rX   ÚlinesÚstartÚmÚ
line_rangeÚkeytypeÚendr&   Úpkformats               r)   rá   ÚPKey._read_private_key;  s˜  € Ø—‘“ˆÞÜÐ@×GÑGÈÓLÓMÐMð ˆØ�N‰N× Ñ  ¡Ó.ˆÜ˜“Z !‘^ˆ
ØÓ ®Ø�Q‰JˆEØ—‘×$Ñ$ U¡\Ó2ˆAð Ó ¯¨ð 	�‰
ˆÞ !�!—'‘'˜!”* tˆØ”C˜“JÓ '¡/ÜÐ@×GÑGÈÓLÓMÐMð ˆØ�L‰L×Ñ˜u™zÓ*ˆØÓ¦qØ�1‰HˆCØ—‘×"Ñ" 5¡:Ó.ˆAð Ó§q qð ‹>Ø×-Ñ-¨e¸(ÓCˆDØ×8Ñ8ˆHð ˆ~Ðð ˜	Ó!Ø×1Ñ1°%¸cÐ2BÀHÓMˆDØ×7Ñ7ˆHð ˆ~Ðô	 Ø5×<Ñ<¸WÓJóð r+   c                 ód   • Sn[        UR                  U R                  R                  U5      5      e)Nz={}._read_private_key() spat out an unknown key format id '{}')r   rH   rk   r>   )r4   Úid_Úerrs      r)   Ú_got_bad_key_format_idÚPKey._got_bad_key_format_id`  s'   € ØMˆÜ˜3Ÿ:™: d§n¡n×&=Ñ&=¸sÓCÓDÐDr+   c           	      ó  • Sn0 nUS-  nU[        U5      :  a_  X   R                  S5      n[        U5      S:X  a  O<US   R                  5       XVS   R                  5       '   US-  nU[        U5      :  a  M_   [	        [        SR                  XU 5      5      5      nSU;  a  U$ US   n	U	S:w  a  [        SR                  U	5      5      e US	   R                  S
5      u  p«X R                  ;  a  [        SR                  U
5      5      eUc  [        S5      eU R                  U
   S   nU R                  U
   S   nU R                  U
   S   n[        [        U5      5      n[        R                   " ["        XóU5      n[%        U" U5      U" U5      ['        5       S9R)                  5       nUR+                  U5      UR-                  5       -   n[.        R0                  " UR2                  5      R5                  5       n UR+                  U5      UR-                  5       -   $ ! [        R                  R                   a  n[        SR                  U5      5      eS nAff = f!   [        S5      e= f! [6         a    [        S5      ef = f)Nr   r$   z: r‡   úbase64 decoding error: {}z	proc-typez4,ENCRYPTEDz"Unknown private key structure "{}"zdek-infoÚ,z(Can't parse DEK-info in private key filezUnknown private key cipher "{}"zPrivate key file is encryptedrQ   rR   rT   )Úbackendz(Bad password or corrupt private key file)r8   r«   r»   Úlowerr   r   ÚjoinÚbase64ÚbinasciiÚErrorr   rH   Ú_CIPHER_TABLEr   r   r   Úgenerate_key_bytesr   r   r   Ú	decryptorÚupdateÚfinalizer   ÚPKCS7Ú
block_sizeÚunpadderre   )r4   rñ   rö   rX   rò   ÚheadersÚliner&   ÚeÚ	proc_typeÚencryption_typeÚsaltstrrQ   rR   rT   Úsaltrw   r	  Údecrypted_datar  s                       r)   rí   ÚPKey._read_private_key_pemd  s|  € ØˆàˆØ�‰
ˆØ”c˜%“jÓ Ø‘<×%Ñ% dÓ+ˆDÜ�4‹y˜A‹~ØØ'+¨A¡w§}¡}£ˆG˜‘G—M‘M“OÑ$Ø�Q‰JˆEð ”c˜%“jÕ ð	FÜœq §¡¨°SÐ)9Ó!:Ó;Ó<ˆDð ˜gÓ%àˆKà˜KÑ(ˆ	Ø˜Ó%ÜØ4×;Ñ;¸IÓFóð ð	KØ'.¨zÑ':×'@Ñ'@ÀÓ'EÑ$ˆOð ×"4Ñ"4Ó4ÜØ1×8Ñ8¸ÓIóð ð
 ÑÜ+Ð,KÓLÐLØ×#Ñ# OÑ4°XÑ>ˆØ×$Ñ$ _Ñ5°iÑ@ˆØ×!Ñ! /Ñ2°6Ñ:ˆÜœ˜7›Ó$ˆÜ×%Ò%¤c¨4¸7ÓCˆÜÙ�3‹K™˜d›¬_Ó->ñ
ç
‰)‹+ð 	ð #×)Ñ)¨$Ó/°)×2DÑ2DÓ2FÑFˆÜ—=’= ×!2Ñ!2Ó3×<Ñ<Ó>ˆð	KØ—?‘? >Ó2°X×5FÑ5FÓ5HÑHÐHøôE �‰×$Ñ$ó 	FÜÐ:×AÑAÀ!ÓDÓEÐEûð	Fûð	KÜÐIÓJÐJûô* ó 	KÜÐIÓJÐJð	Kús0   Á9%H ÃI Ç=!I/ ÈIÈ=IÉIÉI,É/Jc                 ó¤  •  [        [        SR                  U5      5      5      nUSS nU[        :w  a  [        S5      eU R                  USS S5      nUu  pxpšnU
S:”  a  [        S5      eU R                  US	5      u  pÍU[        S
5      :X  Ga"  U[        S5      :X  a  [        R                  nOIU[        S5      :X  a  [        R                  nO)[        SR                  UR                  S5      5      5      eUc  [        S5      eU R                  U	S5      u  nn[        R                   " [        U5      [        U5      SUSS9nUSS nUSS n[#        [$        R&                  " U5      U" U5      [)        5       5      R+                  5       nUR-                  U5      nUUR/                  5       -  nO,U[        S5      :X  a  U[        S5      :X  a  UnO[        S5      eU R                  US5      nUu  nnnnUU:w  a  [        S5      e[1        U5      $ ! [        R                  R
                   a  n[        SR                  U5      5      eSnAff = f)z¢
Read the new OpenSSH SSH2 private key format available
since OpenSSH version 6.5
Reference:
https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key
r‡   rÿ   Nr#   z)unexpected OpenSSH key header encounteredÚsssurr$   z.unsupported: private keyfile has multiple keysÚssÚbcryptz
aes256-cbcz
aes256-ctrz,unknown cipher `{}` used in private key filezutf-8zprivate key file is encryptedÚsué0   T)Úignore_few_roundsr!   Únonez.unknown cipher or kdf used in private key fileÚuusrz/OpenSSH private key file checkints do not match)r   r   r  r  r  r  r   rH   ÚOPENSSH_AUTH_MAGICÚ_uint32_cstruct_unpackr   ÚCBCÚCTRÚdecoder   r  Úkdfr   r   ÚAESr   r	  r
  r  r*   )r4   rñ   rX   r&   r  Ú
auth_magicÚcstructrQ   ÚkdfnameÚkdf_optionsÚnum_pubkeysÚ	remainderÚpubkeyÚprivkey_blobrT   r  ÚroundsÚkey_ivrw   Úivr	  Údecrypted_privkeyÚ	checkint1Ú	checkint2rõ   Úkeydatas                             r)   rï   ÚPKey._read_private_key_openssh˜  s`  € ð	FÜœq §¡¨£Ó0Ó1ˆDð
 ˜#˜2�Yˆ
ØÔ+Ó+ÜÐJÓKÐKà×-Ñ-¨d°2°3¨i¸ÓAˆØ?FÑ<ˆ˜°9à˜‹?ÜØ@óð ð  $×:Ñ:¸9ÀdÓKÑˆà”a˜“kÔ!Øœ˜<›Ó(Ü—y‘y‘Øœ1˜\›?Ó*Ü—y‘y‘ä"ØB×IÑIØŸ™ gÓ.óóð ð ÑÜ/Ø3óð ð
  ×6Ñ6°{ÀDÓI‰LˆD�&ô —Z’ZÜ�(“Ü�$“ØØð #'ñˆFð ˜˜"�+ˆCØ˜˜�ˆBô Ü—’˜sÓ#¡T¨"£X¬Ó/@óç‰i‹kð ð !*× 0Ñ 0°Ó >ÐØ ×!3Ñ!3Ó!5Ñ5ÑØ”q˜“yÓ  W´°&³	Ó%9à ,ÑäØ@óð ð
 ×-Ñ-Ð.?ÀÓHˆØ18Ñ.ˆ	�9˜g wà˜	Ó!ÜØAóð ô ˜gÓ&Ð&øôW �‰×$Ñ$ó 	FÜÐ:×AÑAÀ!ÓDÓEÐEûð	Fús   ‚#H ÈIÈ0I
É
Ic                 ó~  • / nSn U GH   nUS:X  a?  [         R                  " SXUS-    5      S   nUS-  nXXF-    nXF-  nUR                  U5        US:X  aX  [         R                  " SXUS-    5      S   nUS-  nXXF-    nXF-  n[        R                  " US5      nUR                  U5        M§  US:X  a7  [         R                  " SXUS-    5      S   n	US-  nUR                  U	5        Mä  US:X  d  Mì  XS	 nUR                  U5          O    [        U5      $ ! [
         a  n
[        [        U
5      5      eS	n
A
ff = f)
a·  
Used to read new OpenSSH private key format.
Unpacks a c data structure containing a mix of 32-bit uints and
variable length strings prefixed by 32-bit uint size field,
according to the specified format. Returns the unpacked vars
in a tuple.
Format strings:
  s - denotes a string
  i - denotes a long integer, encoded as a byte string
  u - denotes a 32-bit unsigned integer
  r - the remainder of the input string, returned as a string
r   Úsz>Lé   r(   Tr   rà   N)	ÚstructÚunpackÚappendr   Úinflate_longÚ	Exceptionr   r`   Útuple)r4   r&   Ú	strformatÚarrÚidxrã   Ús_sizer9  r(   r   r  s              r)   r"  ÚPKey._uint32_cstruct_unpackî  sM  € ð ˆØˆð	'Ü�Ø˜“8ä#Ÿ]š]¨4°¸CÀ!¹GÐ1DÓEÀaÑH�FØ˜1‘H�CØ 3¡<Ð0�AØ‘M�CØ—J‘J˜q”MØ˜“8ä#Ÿ]š]¨4°¸CÀ!¹GÐ1DÓEÀaÑH�FØ˜1‘H�CØ 3¡<Ð0�AØ‘M�CÜ×)Ò)¨!¨TÓ2�AØ—J‘J˜q–MØ˜#“XäŸš d¨D°s¸Q±wÐ,?Ó@ÀÑC�AØ˜1‘H�CØ—J‘J˜q–MØ˜#•Xà˜T˜
�AØ—J‘J˜q”MÙò3 ô> �S‹zÐøô ó 	'ô œs 1›vÓ&Ð&ûð		'ús$   †C*D Ã4D ÄD Ä
D<Ä#D7Ä7D<rw   c                 ó  • [         R                  " [         R                  " U[         R                  [         R                  -  [         R
                  -  [        S9S5       nU R                  XRX4S9  S S S 5        g ! , (       d  f       g = f)N)ÚflagsrT   Úwr^   )ÚosÚfdopenrl   ÚO_WRONLYÚO_TRUNCÚO_CREATr   rÜ   )r4   rÎ   rw   rÔ   rX   rã   s         r)   r×   ÚPKey._write_private_key_file  sl   € ô �YŠYÜ�GŠGØô —k‘k¤B§J¡JÑ.´·±Ñ;ô ñ	ð ô
ð Ø×#Ñ# A¨KÐ#ÑK÷
÷ 
ö 
ús   Á A:Á:
Brã   c                 óü   • Uc  [         R                  " 5       nO[         R                  " [        U5      5      nUR	                  UR                  UR                  UR                  U5      R                  5       5        g r0   )	r   ÚNoEncryptionÚBestAvailableEncryptionr   ÚwriteÚprivate_bytesrI   rH   r%  )r4   rã   rw   rÔ   rX   Ú
encryptions         r)   rÜ   ÚPKey._write_private_key9  s`   € ð ÑÜ&×3Ò3Ó5‰Jä&×>Ò>¼qÀ»{ÓKˆJà	�‰Ø×ÑØ×$Ñ$ k×&8Ñ&8¸*óç‰f‹hõ	
r+   c                 ó°  • UnUn[        U[        5      (       a  U/n[        U[        5      (       a  U/nUc  [        S5      eUR                  5         UR	                  5       nXd;   a  gXe;   a9  U R                  [        UR                  5       5      5        UR                  5         gSn[        UR                  U R                  R                  U5      5      e)ai  
Perform message type-checking & optional certificate loading.

This includes fast-forwarding cert ``msg`` objects past the nonce, so
that the subsequent fields are the key numbers; thus the caller may
expect to treat the message as key material afterwards either way.

The obtained key type is returned for classes which need to know what
it was (e.g. ECDSA.)
NzKey object may not be emptyz%Invalid key (class: {}, data type: {})rg   r`   r   ÚrewindÚget_textro   r   r“   Ú
get_stringrH   rk   r>   )r4   r„   r2   Ú	cert_typeÚ	key_typesÚ
cert_typesÚtype_rû   s           r)   Ú_check_type_and_load_certÚPKey._check_type_and_load_certK  s¼   € ð ˆ	Øˆ
Ü�h¤×$Ñ$Ø"˜ˆIÜ�j¤#×&Ñ&Ø$˜ˆJà‰;ÜÐ<Ó=Ð=ð 	�
‰
ŒØ—‘“ˆð ÓØð Ó ð ×!Ñ!¤'¨#¯+©+«-Ó"8Ô9ð �N‰NÕà9ˆCÜ˜sŸz™z¨$¯.©.×*AÑ*AÀ5ÓIÓJÐJr+   c                 ó„  • [        U[        5      (       a  SnO)[        R                  R	                  U5      (       a  SnOSn[        [        U5      " U5      nUR                  R                  U R                  5       5      (       d5  Sn[        UR                  UR                  U R                  5       5      5      eX0l        g)aÅ  
Supplement the private key contents with data loaded from an OpenSSH
public key (``.pub``) or certificate (``-cert.pub``) file, a string
containing such a file, or a `.Message` object.

The .pub contents adds no real value, since the private key
file includes sufficient information to derive the public
key info. For certificates, however, this can be used on
the client side to offer authentication requests to the server
based on certificate instead of raw public key.

See:
https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.certkeys

Note: very little effort is made to validate the certificate contents,
that is for the server to decide if it is good enough to authenticate
successfully.
Úfrom_messageÚ	from_fileÚfrom_stringz0PublicBlob type {} incompatible with key type {}N)rg   r   rI  rp   ÚisfileÚgetattrÚ
PublicBlobr2   Ú
startswithr¦   re   rH   Úpublic_blob)r4   ÚvalueÚconstructorÚblobrû   s        r)   ro   ÚPKey.load_certificate|  sŠ   € ô& �eœW×%Ñ%Ø(‰KÜ�W‰W�^‰^˜E×"Ñ"Ø%‰Kà'ˆKÜ”z ;Ô/°Ó6ˆØ�}‰}×'Ñ'¨¯©«×8Ñ8ØDˆCÜ˜SŸZ™Z¨¯©°t·}±}³ÓGÓHÐHØÕr+   )rh  r0   r=   )=r>   r?   r@   rA   rB   r   r'  r   r#  r   r  rî   rð   ÚreÚcompileré   rì   Ústaticmethodr   r`   rx   r’   r}   Úclassmethodr|   r5   rŽ   r“   r–   rœ   r    Úpropertyr™   r¦   r‹   rŒ   r²   r¶   r�   rÄ   rÈ   rË   rÏ   rm   ÚPEMrF   rÙ   r   rÝ   rä   rá   rü   rí   rï   r"  Ú
PrivateKeyr×   rÜ   r^  ro   rC   rD   r+   r)   rN   rN   v   s•  † ñð !—n‘nØØØ—I‘Iñ	
ð !—n‘nØØØ—I‘Iñ	
ð  ØØØ—I‘Iñ	
ñ€Mð( $%Ð Ø"#ÐØ—
’
ÐMÓN€IØ�jŠjÐIÓJ€GàñH (¨3¡-ô Hó ðHðT àCGñ EØð EØ"'ð EØ3;¸C±=ô Eó ð EðD ñó ðô ò0jòòòIò"ð ñ"ó ð"òð ñó ðò&
òò	,ð ñ(ó ð(ò@ôò"
ð óó ðð. óó ðð. #'Ø"%ñ	
àð
ð ˜3‘-ð
ð  õ	
ð< #'Ø"%ñ	
àð
ð ˜3‘-ð
ð  õ	
ô4ô6#òJEò2KòhT'òl/ðl #'ñLàðLð ðLð  ð	Lð
 ˜3‘-õLð> #'ñ
àð
ð ð
ð  ð	
ð
 ˜3‘-õ
ò$/Kõb r+   rN   c                   ód   • \ rS rSrSrSS jr\S 5       r\S 5       r\S 5       r	S r
S	 rS
 rSrg)rf  i¢  ah  
OpenSSH plain public key or OpenSSH signed public key (certificate).

Tries to be as dumb as possible and barely cares about specific
per-key-type data.

.. note::

    Most of the time you'll want to call `from_file`, `from_string` or
    `from_message` for useful instantiation, the main constructor is
    basically "I should be using ``attrs`` for this."
Nc                 ó(   • Xl         X l        X0l        g)zÚ
Create a new public blob of given type and contents.

:param str type_: Type indicator, eg ``ssh-rsa``.
:param bytes blob: The blob bytes themselves.
:param str comment: A comment, if one was given (e.g. file-based.)
N)r2   Úkey_blobrˆ   )r4   r]  rk  rˆ   s       r)   r5   ÚPublicBlob.__init__°  s   € ð ŒØŒØ�r+   c                 óŽ   • [        U5       nUR                  5       nSSS5        U R                  W5      $ ! , (       d  f       N= f)z?
Create a public blob from a ``-cert.pub``-style file on disk.
N)rl   Úreadrc  )r�   rÎ   rã   Ústrings       r)   rb  ÚPublicBlob.from_file¼  s4   € ô
 �(Œ^˜qØ—V‘V“XˆF÷ à�‰˜vÓ&Ð&÷ �^ús	   Œ6¶
Ac                 ó¤  • UR                  SS5      n[        U5      S:  a  Sn[        UR                  U5      5      eUS   n[	        [        US   5      5      n US   R                  5       n[        U5      nUR                  5       nX„:w  a+  SR                  XH5      n	[        SR                  U	5      5      eU " XEUS9$ ! [         a    Sn N`f = f)	z9
Create a public blob from a ``-cert.pub``-style string.
NrW   z%Not enough fields for public blob: {}r   r$   z!key type={!r}, but blob type={!r}zInvalid PublicBlob contents: {})r]  rk  rˆ   )
r«   r8   re   rH   r   r   r»   Ú
IndexErrorr   rX  )
r�   rz  Úfieldsr„   r2   rv  rˆ   ró   Ú	blob_typeÚdeetss
             r)   rc  ÚPublicBlob.from_stringÅ  sÔ   € ð
 —‘˜d AÓ&ˆÜˆv‹;˜‹?Ø9ˆCÜ˜SŸZ™Z¨Ó/Ó0Ð0Ø˜!‘9ˆÜœq ¨¡›|Ó,ˆð	Ø˜Q‘i—o‘oÓ'ˆGô
 �HÓˆØ—J‘J“Lˆ	ØÓ Ø7×>Ñ>ØóˆEô Ð>×EÑEÀeÓLÓMÐMá˜¸'ÑBÐBøô ó 	ØŠGð	ús   ÁC  Ã CÃCc                 óJ   • UR                  5       nU " X!R                  5       S9$ )z½
Create a public blob from a network `.Message`.

Specifically, a cert-bearing pubkey auth packet, because by definition
OpenSSH-style certificates 'are' their own network representation."
)r]  rk  )rX  r“   )r�   Úmessager]  s      r)   ra  ÚPublicBlob.from_messageà  s$   € ð × Ñ Ó"ˆÙ˜§_¡_Ó%6Ñ7Ð7r+   c                 óš   • SR                  U R                  5      nU R                  (       a  USR                  U R                  5      -  nU$ )Nz{} public key/certificatez- {})rH   r2   rˆ   )r4   Úrets     r)   r:   ÚPublicBlob.__str__ë  s9   € Ø)×0Ñ0°·±Ó?ˆØ�<�<Ø�6—=‘= §¡Ó.Ñ.ˆCØˆ
r+   c                 óX   • U =(       a"    U=(       a    U R                   UR                   :H  $ r0   )rv  rš   s     r)   rœ   ÚPublicBlob.__eq__ñ  s   € à×A˜×A $§-¡-°5·>±>Ñ"AÐAr+   c                 ó   • X:X  + $ r0   rD   rš   s     r)   Ú__ne__ÚPublicBlob.__ne__õ  s   € ØÒ Ð r+   )rˆ   rv  r2   r0   )r>   r?   r@   rA   rB   r5   rp  rb  rc  ra  r:   rœ   r‹  rC   rD   r+   r)   rf  rf  ¢  sZ   † ñô
ð ñ'ó ð'ð ñCó ðCð4 ñ8ó ð8òòBõ!r+   rf  )CrB   r  rI  rm  r;  r   r   r  r   Úhashlibr   r   Úior   Úpathlibr	   Útypingr
   r   r   r  Úcryptography.hazmat.backendsr   Úcryptography.hazmat.primitivesr   r   r   Ú,cryptography.hazmat.primitives.asymmetric.ecr   Ú1cryptography.hazmat.primitives.asymmetric.ed25519r   Ú-cryptography.hazmat.primitives.asymmetric.rsar   Ú&cryptography.hazmat.primitives.ciphersr   r   r   r_   r   Úparamiko.commonr   Úparamiko.messager   Úparamiko.ssh_exceptionr   r   Úparamiko.utilr   r   Ú/cryptography.hazmat.decrepit.ciphers.algorithmsr   ÚImportErrorÚ1cryptography.hazmat.primitives.ciphers.algorithmsr!  r*   r?  r-   rF   rs  rJ   ÚTraditionalOpenSSLrL   rr  ÚOpenSSHrç   rN   rf  rD   r+   r)   Ú<module>r      s%  ðñ&ó Û 	Û 	Û ß +Ý ß Ý Ý ß .Ñ .ã Ý 8ß MÑ Mõõ PÝ Gß LÑ Lå Ý  Ý $ß Jß ðLÝIð
 +Ð ò"ô
X�Yô 
Xô%�ô %ð �=Ð"9Ð;LÐLÑM€
ñ Ø×&Ñ&×9Ñ9Ø×#Ñ#×'Ñ'ñ€ñ Ø×&Ñ&×.Ñ.Ø×#Ñ#×'Ñ'ñ€÷c ñ c ÷XT!ò T!øðM ó LßKðLús   ÂD. Ä.D=Ä<D=