�
Ϫ�f�M � � � d Z ddlZddlZddlmZmZmZ ddlm Z ddl
mZ ddlm
Z
ddlmZmZmZ ddlmZ dd lmZmZmZ dd
lmZ ddlmZ ddlmZ dd
lmZ ddl m!Z! e� Z"d� Z#d� Z$ G d� d� Z% e
e� G d� de%� � Z& e
e� G d� d� � Z'd� Z( e
e� G d� de%e!� � Z) G d� d� Z* G d� d� Z+y)zE
An implementation of the OpenSSH known_hosts database.
@since: 8.2
� N)�Error�
a2b_base64�
b2a_base64)�closing)�sha1)�implementer)�HostKeyChanged�InvalidEntry�UserRejectedKey)�IKnownHostEntry)�BadKeyError�FingerprintFormats�Key)�defer)�Logger)�nativeString)�secureRandom)�FancyEqMixinc �4 � t | � j � S )z�
Encode a binary string as base64 with no trailing newline.
@param s: The string to encode.
@type s: L{bytes}
@return: The base64-encoded string.
@rtype: L{bytes}
)r �strip)�ss �A/usr/lib/python3/dist-packages/twisted/conch/client/knownhosts.py�
_b64encoder s � � �a�=��� � � c �& � | j dd� }t |� dk7 r
t � �|\ }}}|j dd� }t |� dk( r|\ }}|j d� }n|d }d}t j
t
|� � }||||fS )a�
Extract common elements of base64 keys from an entry in a hosts file.
@param string: A known hosts file entry (a single line).
@type string: L{bytes}
@return: a 4-tuple of hostname data (L{bytes}), ssh key type (L{bytes}), key
(L{Key}), and comment (L{bytes} or L{None}). The hostname data is
simply the beginning of the line up to the first occurrence of
whitespace.
@rtype: L{tuple}
N� � � �
r )�split�lenr
�rstripr �
fromStringr ) �string�elements� hostnames�keyType�
keyAndComment�splitkey� keyString�comment�keys r �_extractCommonr- - s� � � �|�|�D�!�$�H�
�8�}����n��(0�%�I�w�
��"�"�4��+�H�
�8�}���%�� �7��.�.��'���Q�K� ���
�.�.��I�.�
/�C��g�s�G�+�+r c � � e Zd ZdZd� Zd� Zy)�
_BaseEntrya�
Abstract base of both hashed and non-hashed entry objects, since they
represent keys and key types the same way.
@ivar keyType: The type of the key; either ssh-dss or ssh-rsa.
@type keyType: L{bytes}
@ivar publicKey: The server public key indicated by this line.
@type publicKey: L{twisted.conch.ssh.keys.Key}
@ivar comment: Trailing garbage after the key line.
@type comment: L{bytes}
c �. � || _ || _ || _ y �N)r' |