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__/sk.cpython-310.pyc
o

�hC.�@s<dZddlmZddlZddlmZddlZddlZddlm	Z	m
Z
mZmZm
Z
ddlmZmZmZmZed�ZeeeeefZdZd	Zd
ZdZdZd
edeeefdefdd�Zdedefdd�Zdede	defdedefdd�Z ddd
ededeeeffdd �Z!ddd
eded!ed"e
ed#e"deeeffd$d%�Z#d
eded!edeeeffd&d'�Z$ddd(eded)edeeeeff
d*d+�Z%ddd(eded)ed,e"deeeeffd-d.�Z&d/eded)edeeeeeffd0d1�Z'd/ededefd2d3�Z(d
eded!ed"e
ed#e"deeeffd4d5�Z)	6dHd/eded)ed7ed8e"deeeeeffd9d:�Z*ded!e
ed"edeefd;d<�Z+zCdd=l,m-Z-dd>l.m/Z/dd?l0m1Z1m2Z2m3Z3dd@l4m5Z5m6Z6m7Z7ddAl4m8Z8ddBl9m:Z:dCZ;e-�<��owe=edD��owej>j?�@�ZAWdSeBeCeDf�y�d6Z;d6ZAdedEedefdFdG�ZEeEZ)eEZ*eEZ+YdSw)IzU2F security key handler�)�urlsafe_b64encodeN)�sha256)�Callable�List�Mapping�NoReturn�Optional)�Sequence�Tuple�TypeVar�cast�_PollResultg�������?s �i����i�����alg�
public_key�returncCs0tt|d�}|tkr
|Sd|tt|d�S)z8Decode algorithm and public value from a CTAP public key�������)r�bytes�SSH_SK_ED25519)rr�result�r�A/usr/local/CyberPanel/lib/python3.10/site-packages/asyncssh/sk.py�_decode_public_key0sr�_rp_id�_origincCsdS)z@Allow any relying party name -- SSH encodes the application hereTr)rrrrr�
_verify_rp_id;sr�
poll_interval�func.�argsc
GsL	z||�WSty$}z|jtjkr�t�|�WYd}~nd}~wwq)z'Poll until a CTAP1 response is receivedTN)�	ApduError�code�APDU�USE_NOT_SATISFIED�time�sleep)rrr �excrrr�_ctap1_pollAs
���r(�dev�
CtapHidDevice�applicationcCsFt|�}|tkrtd��t|�d����}tt|jt	|�}|j
|jfS)z.Enroll a new security key using CTAP version 1zUnsupported algorithm�utf-8)�Ctap1�SSH_SK_ECDSA�
ValueErrorr�encode�digestr(�_CTAP1_POLL_INTERVAL�register�_dummy_hashr�
key_handle)r)rr+�ctap1�app_hash�registrationrrr�
_ctap1_enrollOs�r9�user�pin�residentc	Cs�t|�}||d�}|�d�|d�}d|d�g}	d|i}
|r6t�}t||��|�}t�|tt��	�dd�}
nd}d}
|r?|j
nd}|jt|||	|
|
|d�}|jj
}t||j�|jfS)	z.Enroll a new security key using CTAP version 2��id�namer,�
public-key��typer�rkN�)�options�pin_uv_param�pin_uv_protocol)�Ctap2r0�
PinProtocolV1�	ClientPin�
get_pin_token�hmac�newr4rr1�VERSION�make_credential�	auth_data�credential_datarr�
credential_id)r)rr+r:r;r<�ctap2�rp�	user_cred�
key_paramsrE�pin_protocol�	pin_token�pin_auth�pin_version�cred�cdatarrr�
_ctap2_enroll_s$
�r]c
Csft|td�}||d�}|�d�|d�}d|d�g}||d|d�}|�|�}|jjj}	t||	j�|	j	fS)z4Enroll a new security key using Windows WebAuthn API��verifyr=r,r@rA�)rTr:�	challenge�pubKeyCredParams)
�
WindowsClientrr0rO�attestation_objectrPrQrrrR)
rr+r:�clientrTrUrVrErr\rrr�_win_enroll�s
�

rf�message_hashr5c
Cs^t|�}t|�d����}tt|j|||�}|d}t�|dd�d�}|dd�}	|||	fS)z7Sign a message with a security key using CTAP version 1r,rr��bigN)	r-rr0r1r(r2�authenticate�int�
from_bytes)
r)rgr+r5r6r7�
auth_response�flags�counter�sigrrr�_ctap1_sign�s�
rq�touch_requiredc
Csbt|�}d|d�g}d|i}|r|j|||ddid�|j||||d�d}|j}	|	j|	j|jfS)z7Sign a message with a security key using CTAP version 2r@�rBr>�upF)rEr)rH�get_assertionsrPrnro�	signature)
r)rgr+r5rrrS�allow_credsrE�	assertionrPrrr�_ctap2_sign�s
�
��ry�datacCsRt|td�}d|d�g}|||d�}|�|��d�}|j}|j|j|jt|j	�fS)z=Sign a message with a security key using Windows WebAuthn APIr^r@rs)ra�rpId�allowCredentialsr)
rcr�
get_assertion�get_response�authenticator_datarnrorvr�client_data)rzr+r5re�credsrErrPrrr�	_win_sign�s��r�cCs$dt|��d�d|�d�dS)z#Calculate a WebAuthn request prefixs${"type":"webauthn.get","challenge":"�=s","origin":"r,�")r�rstripr0)rzr+rrr�sk_webauthn_prefix�s����r�c
Cstrt|||�Sztt���}Wntytd�d�wzczt||||||�WW|��St	yX}z|j
t	jjkrAtd�d�|j
t	jj
krMtd�d�tt|��d�d}~wty�zt|||�WYW|��Sty}ztt|��d�d}~www|��w)zEnroll a new security keyzNo security key foundNzPIN required�Invalid PIN)�sk_use_webauthnrf�nextr*�list_devices�
StopIterationr/r]�close�	CtapErrorr"�ERR�
PUAT_REQUIRED�PIN_INVALID�strr9r!)rr+r:r;r<r)r'rrr�	sk_enroll�s6
�
�

�
����
r�Frn�is_webauthncCsbt|t@�}|rtrt|||�S|rt||�d}t|���}t��D]�}z�zt	|||||�\}}}	|||	|fWW|�
�Sty_}
z|
jtj
jkrUtt|
��d�WYd}
~
nGd}
~
wty�zt||||�\}}}	|||	|fWYW|�
�Sty�}
z|
jtjkr�tt|
��d�WYd}
~
nd}
~
wwYnwW|�
�q#|�
�wtd��)z"Sign a message with a security key�}Nz!Security key credential not found)�bool�SSH_SK_USER_PRESENCE_REQDr�r�r�rr1r*r�ryr�r�r"r��NO_CREDENTIALSr/r�rqr!r#�
WRONG_DATA)rzr+r5rnr�rrrgr)rorpr'rrr�sk_sign�sH
����
�������
r�cCs�t|�d����}g}t��D]�}z�zpt|�}t�}t||��|�}t	|||�}	|	�
|�D]S}
ttt
tf|
t	jj�}tt
|d�}|rJ||krJq-ttt
tf|
t	jj�}
tt|
d�}ttttf|
t	jj�}tt|d�}t||�}|�||||f�q-Wn=ty�}z1|jtjjkr�WYd}~W|��q|jtjjkr�td�d�|jtjjkr�td�d�tt
|��d�d}~wwW|��q|��w|S)z#Get keys resident on a security keyr,r?r>�Nr�zPIN not set)rr0r1r*r�rHrIrJrK�CredentialManagement�enumerate_credsrrr��object�RESULT�USER�
CREDENTIAL_IDrrk�
PUBLIC_KEYr�appendr�r"r�r�r�r�r/�PIN_NOT_SET)r+r:r;r7rr)rSrWrX�	cred_mgmtr[�	user_infor?�cred_idr5rr�public_valuer'rrr�sk_get_residentsP
�
�
�
�
�

���r�)rc)r�)r-r#r!)rHrJrI)r�)r*T�windll�kwargscOstd��)z/Report that security key support is unavailablez"Security key support not available)r/)r r�rrr�_sk_not_availableZsr�)F)F�__doc__�base64r�ctypes�hashlibrrLr%�typingrrrrrr	r
rrr
rkr�r�_SKResidentKeyr2r4r�r.rr�rr�floatr(r9r�r]rfrqryr�r�r�r�r��fido2.clientrc�
fido2.ctapr��fido2.ctap1r-r#r!�fido2.ctap2rHrJrIr��	fido2.hidr*�sk_available�is_available�hasattrr��shell32�
IsUserAnAdminr��ImportError�OSError�AttributeErrorr�rrrr�<module>s��
�
�

����

�"!�
�
���
�
�
��

���
�&�
�1
��
�