o
    vh
                     @   sB   d dl mZ d dlmZ d dlmZ d dlmZ G dd dZdS )    )Optional)x509ValidationPath)ConsListc                   @   sj   e Zd Zddddee dee defddZe	d	d
 Z
e	defddZdejfddZdddZdS )ValProcStateNF)ee_name_overrideis_side_validationcert_path_stackr   r	   c                C   s8   |j d u r	tdd| _|| _t|p|j| _|| _d S )NzEmpty path stackr   )head
ValueErrorindexr   booltailr	   r
   )selfr
   r   r	    r   Z/var/www/html/hyperkenya/venv/lib/python3.10/site-packages/pyhanko_certvalidator/_state.py__init__	   s   

zValProcState.__init__c                 C   s(   ddl m} | jj}t||sJ |jS )z
        Length of the path being validated.

        .. note::
            This is the path length in the sense of RFC 5280, i.e.
            the root doesn't count.
        r   r   )pyhanko_certvalidator.pathr   r
   r   
isinstancepkix_len)r   r   pathr   r   r   path_len   s   	zValProcState.path_lenreturnc                 C   s   | j | jkS )N)r   r   )r   r   r   r   
is_ee_cert(   s   zValProcState.is_ee_certee_certc                 C   s<   ddl m} | jD ]}| }|r|j|jkr|  S q	dS )a  
        Helper method to avoid recursion in indirect CRL validation.
        There are some questionable-but-technically-valid CA setups where
        a CRL issuer is authorised to assert its own revocation status,
        which could cause a naive implementation to recurse.
        r   r   N)r   r   r
   get_ee_cert_safesha256)r   r   r   r   certr   r   r   check_path_verif_recursion,   s   
z'ValProcState.check_path_verif_recursionc                 C   sb   | }| j dk r| jdu rd}n| js||M }d| j  }n| jdur'| j}nd}|r/d| S |S )zy
        :return:
            A unicode string describing the position of a certificate
            in the chain
           Ncertificatezintermediate certificate zend-entity certificatezthe )r   r   r   )r   
def_interm	never_defprefixresultr   r   r   describe_cert<   s   
zValProcState.describe_cert)FF)__name__
__module____qualname__r   r   r   strr   r   propertyr   r   r   Certificater   r&   r   r   r   r   r      s     

r   N)	typingr   
asn1cryptor   r   r   pyhanko_certvalidator.utilr   r   r   r   r   r   <module>   s
    