HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberPanel/lib64/python3.10/site-packages/asyncssh/__pycache__/rsa.cpython-310.pyc
o

�h�,�
@sXdZddlmZmZmZmZddlmZmZm	Z	m
Z
ddlmZm
Z
ddlmZddlmZmZmZddlmZmZmZdd	lmZmZdd
lmZddd
dddd
ddd�	ZeeeeeeeeefZeeeeeeeeeef	ZeeefZ da!deddfdd�Z"Gdd�de�Z#ede#d�e#j$D]
Z%ede%e%de#ed�q�e#j&D]Z%ee%d�q�dS)z!RSA public key encryption handler�)�Optional�Tuple�Union�cast�)�ASN1DecodeError�ObjectIdentifier�
der_encode�
der_decode)�
RSAPrivateKey�RSAPublicKey)�all_ints)�MPInt�String�	SSHPacket)�SSHKey�SSHOpenSSHCertificateV01�KeyExportError)�register_public_key_alg�register_certificate_alg)�register_x509_certificate_alg�sha1�sha256�sha512�sha224�sha384)	�ssh-rsa�rsa-sha2-256�rsa-sha2-512�ssh-rsa-sha224@ssh.com�ssh-rsa-sha256@ssh.com�ssh-rsa-sha384@ssh.com�ssh-rsa-sha512@ssh.comsrsa1024-sha1�rsa2048-sha256F�skip_validation�returnNcCs|adS)a\Set whether to disable RSA key validation in OpenSSL

       OpenSSL 3.x does additional validation when loading RSA keys
       as an added security measure. However, the result is that
       loading a key can take significantly longer than it did before.

       If all your RSA keys are coming from a trusted source, you can
       call this function with a value of `True` to default to skipping
       these checks on RSA keys, reducing the cost back down to what it
       was in earlier releases.

       This can also be set on a case by case basis by using the new
       `unsafe_skip_rsa_key_validation` argument on the functions used
       to load keys. This will only affect loading keys of type RSA.

       .. note:: The extra cost only applies to loading existing keys, and
                 not to generating new keys. Also, in cases where a key is
                 used repeatedly, it can be loaded once into an `SSHKey`
                 object and reused without having to pay the cost each time.
                 So, this call should not be needed in most applications.

                 If an application does need this, it is strongly
                 recommended that the `unsafe_skip_rsa_key_validation`
                 argument be used rather than using this function to
                 change the default behavior for all load operations.

    N)� _default_skip_rsa_key_validation)r$�r'�B/usr/local/CyberPanel/lib/python3.10/site-packages/asyncssh/rsa.py�#set_default_skip_rsa_key_validation5s!r)c
@sVeZdZUdZeeefed<dZdZ	dZ
ed�ZdZ
dZed	d
�eD��ZdZedd
�eD��Zeee
�Zd
edefdd�Zdefdd�Zeddd�dedededdfdd��Zededefdd��Zededefdd��Zed ede e!fd!d"��Z"ed ede e#fd#d$��Z$ed%ed&ede e!fd'd(��Z%ed%ed&ede e#fd)d*��Z&ed+e'de!fd,d-��Z(ed+e'de#fd.d/��Z)defd0d1�Z*defd2d3�Z+de,eeffd4d5�Z-de,eeffd6d7�Z.defd8d9�Z/defd:d;�Z0defd<d=�Z1d&ed>edefd?d@�Z2d&ed>ed+e'defdAdB�Z3d&edede efdCdD�Z4d&edede efdEdF�Z5dGS)H�RSAKeyz%Handler for RSA public key encryption�_keyrrsRSAz1.2.840.113549.1.1.1)rrrr r!r"r)rrrccs�|]}|dVqdS)�-cert-v01@openssh.comNr'��.0�algr'r'r(�	<genexpr>gs��zRSAKey.<genexpr>)r#rccs�|]}d|VqdS)sx509v3-Nr'r-r'r'r(r0js��otherr%cCs>t|t�stS|jj|jjko|jj|jjko|jj|jjkS�N)�
isinstancer*�NotImplementedr+�n�e�d)�selfr1r'r'r(�__eq__ms
��z
RSAKey.__eq__cCs&t|jj|jj|jj|jj|jjf�Sr2)�hashr+r5r6r7�p�q�r8r'r'r(�__hash__xs�zRSAKey.__hash__ii)�key_size�exponent�	algorithmr?r@cCs|t�||��S)zGenerate a new RSA private key)r�generate)�clsrAr?r@r'r'r(rB|szRSAKey.generate�
key_paramscCsFtt|�\	}}}}}}}}	}
|
durt}
|t�||||||||	|
�	�S)zConstruct an RSA private keyN)r�_PrivateKeyConstructArgsr&r�	construct)rCrDr5r6r7r;r<�dmp1�dmq1�iqmp�unsafe_skip_rsa_key_validationr'r'r(�make_private�s��zRSAKey.make_privatecCstt|�\}}|t�||��S)zConstruct an RSA public key)r�_PublicKeyArgsrrF)rCrDr5r6r'r'r(�make_public�szRSAKey.make_public�key_datacCs4t|t�rt|�rt|�dkrtt|dd��SdS)z&Decode a PKCS#1 format RSA private key�	rN)r3�tupler
�lenr�_PrivateKeyArgs�rCrNr'r'r(�decode_pkcs1_private�szRSAKey.decode_pkcs1_privatecCs,t|t�rt|�rt|�dkrtt|�SdS)z%Decode a PKCS#1 format RSA public key�N)r3rPr
rQrrLrSr'r'r(�decode_pkcs1_public�s
zRSAKey.decode_pkcs1_public�
alg_params�datacC�8|durdSzt|�}Wn
tyYdSw|�|�S)z&Decode a PKCS#8 format RSA private keyN)r
rrT�rCrWrXrNr'r'r(�decode_pkcs8_private���
zRSAKey.decode_pkcs8_privatecCrY)z%Decode a PKCS#8 format RSA public keyN)r
rrVrZr'r'r(�decode_pkcs8_public�r\zRSAKey.decode_pkcs8_public�packetc	CsT|��}|��}|��}|��}|��}|��}|||||||d||d|fS)z$Decode an SSH format RSA private keyr��	get_mpint)rCr^r5r6r7rIr;r<r'r'r(�decode_ssh_private�s$zRSAKey.decode_ssh_privatecCs|��}|��}||fS)z#Decode an SSH format RSA public keyr_)rCr^r6r5r'r'r(�decode_ssh_public�szRSAKey.decode_ssh_publicc	CsF|jjstd��d|jj|jj|jj|jj|jj|jj|jj|jj	f	S)z&Encode a PKCS#1 format RSA private key�Key is not privater)
r+r7rr5r6r;r<rGrHrIr=r'r'r(�encode_pkcs1_private�s
�zRSAKey.encode_pkcs1_privatecCs|jj|jjfS)z%Encode a PKCS#1 format RSA public key)r+r5r6r=r'r'r(�encode_pkcs1_public��zRSAKey.encode_pkcs1_publiccC�dt|���fS)z&Encode a PKCS#8 format RSA private keyN)r	rdr=r'r'r(�encode_pkcs8_private�rfzRSAKey.encode_pkcs8_privatecCrg)z%Encode a PKCS#8 format RSA public keyN)r	rer=r'r'r(�encode_pkcs8_public�rfzRSAKey.encode_pkcs8_publicc	Cs�|jjstd��|jjdusJ�|jjdusJ�|jjdus J�d�t|jj�t|jj	�t|jj�t|jj�t|jj�t|jj�f�S)z$Encode an SSH format RSA private keyrcN�)
r+r7rrIr;r<�joinrr5r6r=r'r'r(�encode_ssh_private�s�zRSAKey.encode_ssh_privatecCsd�t|jj�t|jj�f�S)z#Encode an SSH format RSA public keyrj)rkrr+r6r5r=r'r'r(�encode_ssh_public
szRSAKey.encode_ssh_publiccCsr|jjstd��|jjdusJ�|jjdusJ�|jjdus J�d�t|jj�t|jj�t|jj�t|jj�f�S)z1Encode RSA certificate private key data for agentrcNrj)r+r7rrIr;r<rkrr=r'r'r(�encode_agent_cert_privates�z RSAKey.encode_agent_cert_private�
sig_algorithmcCs&|jjstd��t|j�|t|��S)z6Compute an SSH-encoded signature of the specified datazPrivate key needed for signing)r+r7�
ValueErrorr�sign�
_hash_algs)r8rXror'r'r(�sign_sshszRSAKey.sign_sshcCs$|��}|��|j�||t|�S)z5Verify an SSH-encoded signature of the specified data)�
get_string�	check_endr+�verifyrr)r8rXror^�sigr'r'r(�
verify_ssh$szRSAKey.verify_sshcC�tt|j�}|�|t|�S)z%Encrypt a block of data with this key)rrr+�encryptrr)r8rXrA�pub_keyr'r'r(rz-�zRSAKey.encryptcCry)z%Decrypt a block of data with this key)rrr+�decryptrr)r8rXrA�priv_keyr'r'r(r}3r|zRSAKey.decryptN)6�__name__�
__module__�__qualname__�__doc__rrr�__annotations__rA�default_x509_hash�pem_namer�	pkcs8_oid�sig_algorithms�cert_sig_algorithmsrP�cert_algorithms�x509_sig_algorithms�x509_algorithms�set�all_sig_algorithms�object�boolr9�intr>�classmethod�bytesrBrrKrMrrRrTrLrVr[r]rrarbrdrerrhrirlrmrnrsrxrzr}r'r'r'r(r*Ys�
�
�����
�
����	
�
�	r*rTr,)'r��typingrrrr�asn1rrr	r
�cryptorr�miscr
r^rrr�
public_keyrrrrrrrrr�rRr�rErLr&r)r*r��_algr�r'r'r'r(�<module>sD�$b
�
�