File: //usr/local/CyberPanel/lib64/python3.10/site-packages/asyncssh/__pycache__/saslprep.cpython-310.pyc
o
�hX � @ s� d Z ddlZddlZddlmZmZmZ ddlmZ G dd� de �Z
deddfd d
�Zdede
deeegef d
ed deeege
f de
defdd�Zdedefdd�Zdedefdd�ZdS )z�SASLprep implementation
This module implements the stringprep algorithm defined in RFC 3454
and the SASLprep profile of stringprep defined in RFC 4013. This
profile is used to normalize usernames and passwords sent in the
SSH protocol.
� N)�Callable�Optional�Sequence)�Literalc @ s e Zd ZdZdS )�
SASLPrepErrorz!Invalid data provided to saslprepN)�__name__�
__module__�__qualname__�__doc__� r r �G/usr/local/CyberPanel/lib/python3.10/site-packages/asyncssh/saslprep.pyr ( s r �s�returnc C sv d}d}| D ]}|st �|�rd}|st �|�rd}q|r#|r#td��|r7t �| d �r3t �| d �s9td��dS dS )z@Enforce bidirectional character check from RFC 3454 (stringprep)FTz*Both RandALCat and LCat characters presentr ���z-RandALCat character not at both start and endN)�
stringprep�in_table_d1�in_table_d2r )r
�r_and_al_cat�l_cat�cr r r �_check_bidi, s ���r �check_unassigned�mapping�
normalization)�NFC�NFD�NFKC�NFKD�
prohibited�bidic C s� |r| D ]}t �|�rtd|����q|r|| �} |r!t�|| �} |r8| D ]}|D ]
}||�r6td|����q)q%|r>t| � | S )z5Implement a stringprep profile as defined in RFC 3454zUnassigned character: zProhibited character: )r �in_table_a1r �unicodedata� normalizer )r
r r r r r r �lookupr r r �_stringprepA s&