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/CyberCP/lib/python3.10/site-packages/asyncssh/crypto/__pycache__/ec.cpython-310.pyc
o

�h��@s�UdZddlmZmZmZmZddlmZddlm	Z	ddl
mZddl
mZddl
mZmZmZe	je	je	je	jd	�Zeeee	jfed
<Gdd�de�ZGd
d�de�ZGdd�de�ZGdd�d�ZdS)z;A shim around PyCA for elliptic curve keys and key exchange�)�Mapping�Optional�Type�cast)�InvalidSignature)�ec)�Encoding)�PublicFormat�)�	CryptoKey�PyCAKey�hashes)s1.3.132.0.10snistp256snistp384snistp521�_curvescs�eZdZdZ	ddededejdedeej	f
�fdd	�
Z
eded
eej
fdd��Zed
efd
d��Zed
efdd��Zed
efdd��Zed
eefdd��Zed
efdd��Zed
eefdd��Z�ZS)�_ECKeyz+Base class for shim around PyCA for EC keysN�pyca_key�curve_id�pub�point�privcs(t��|�||_||_||_||_dS�N)�super�__init__�	_curve_id�_pub�_point�_priv)�selfrrrrr��	__class__��E/usr/local/CyberCP/lib/python3.10/site-packages/asyncssh/crypto/ec.pyr/s

z_ECKey.__init__�returncCs.zt|WStytd|�����d�w)z Look up curve and hash algorithm�Unknown EC curve N)r�KeyError�
ValueError�decode)�clsrrrr �lookup_curve9s

�z_ECKey.lookup_curvecC�|jS)zReturn the EC curve name)r�rrrr rB�z_ECKey.curve_idcC�|jjS)z!Return the EC public x coordinate)r�xr)rrr r,H�z_ECKey.xcCr+)z!Return the EC public y coordinate)r�yr)rrr r.Nr-z_ECKey.ycCs|jr|jjSdS)z)Return the EC private value as an integerN)r�
private_valuer)rrr �dTsz_ECKey.dcCr()z9Return the EC public point value encoded as a byte string)rr)rrr �public_valueZr*z_ECKey.public_valuecCs,|jr|jjjdd}|jj�|d�SdS)z4Return the EC private value encoded as a byte string���bigN)rr�curve�key_sizer/�to_bytes)r�keylenrrr r/`sz_ECKey.private_valuer)�__name__�
__module__�__qualname__�__doc__r�bytesr�EllipticCurvePublicNumbersr�EllipticCurvePrivateNumbersr�classmethodr�
EllipticCurver'�propertyr�intr,r.r0r1r/�
__classcell__rrrr r,s0����
rc	@s\eZdZdZededededdfdd��Zededdfdd	��Zddede	defd
d�Z
dS)�ECDSAPrivateKeyz)A shim around PyCA for ECDSA private keysrr1r/r!cCs6|�|�}t�||��}|��}|j}||||||�S)zConstruct an ECDSA private key)r'r�derive_private_key�private_numbers�public_numbers)r&rr1r/r5�priv_keyrrrrr �	constructns

zECDSAPrivateKey.constructcCsN|�|�}t�|��}|��}|��}|��}|�tjt	j
�}||||||�S)z Generate a new ECDSA private key)r'r�generate_private_keyrG�
public_keyrH�public_bytesr�X962r	�UncompressedPoint)r&rr5rIr�pub_keyrr1rrr �generate{s
�zECDSAPrivateKey.generate��data�	hash_namecCs$td|j�}|�|t�t|���S)zSign a block of datazec.EllipticCurvePrivateKey)rr�signr�ECDSAr
)rrSrTrIrrr rU�szECDSAPrivateKey.signN�rR)r9r:r;r<r@r=rCrJrQ�strrUrrrr rEks
��rEc	@sFeZdZdZedededdfdd��Zdded	ed
edefdd�Z	d
S)�ECDSAPublicKeyz(A shim around PyCA for ECDSA public keysrr1r!cCs0|�|�}tj�|�|�}|��}|||||�S)zConstruct an ECDSA public key)r'r�EllipticCurvePublicKey�from_encoded_pointrH)r&rr1r5rPrrrr rJ�s

�zECDSAPublicKey.constructrRrS�sigrTcCsBztd|j�}|�||t�t|���WdSty YdSw)z'Verify the signature on a block of datazec.EllipticCurvePublicKeyTF)rr�verifyrrVr
r)rrSr\rTrPrrr r]�s�zECDSAPublicKey.verifyNrW)
r9r:r;r<r@r=rJrX�boolr]rrrr rY�s�� rYc@sPeZdZdZdefdd�Zdefdd�Zdedefd	d
�Zdedefdd�Z	d
S)�ECDHz(A shim around PyCA for ECDH key exchangercCsBzt|}Wntytd|�����d�wt�|��|_dS)Nr")rr#r$r%rrK�	_priv_key)rrr5rrr r�s�z
ECDH.__init__r!cCs|j��}|�tjtj�S)z.Return the public key to send in the handshake)r`rLrMrrNr	rO)rrPrrr �
get_public�s
�zECDH.get_public�peer_publiccCs$tj�|jj|�}|j�t��|�S)z9Return the shared key from the peer's public key as bytes)rrZr[r`r5�exchanger_)rrb�peer_keyrrr �get_shared_bytes�s�zECDH.get_shared_bytescCst�|�|�d�S)z0Return the shared key from the peer's public keyr4)rC�
from_bytesre)rrbrrr �
get_shared�szECDH.get_sharedN)
r9r:r;r<r=rrarerCrgrrrr r_�sr_N)r<�typingrrrr�cryptography.exceptionsr�)cryptography.hazmat.primitives.asymmetricr�,cryptography.hazmat.primitives.serializationrr	�miscrrr
�	SECP256K1�	SECP256R1�	SECP384R1�	SECP521R1rr=rA�__annotations__rrErYr_rrrr �<module>s �?*