
    Wwg
                     H    d dl mZ d dlmZ d dlmZ d dlmZ  G d d      Zy)    )Optional)x509ValidationPath)ConsListc                       e Zd Zddddee   dee   defdZe	d        Z
e	d	efd
       Zdej                  fdZddZy)ValProcStateNF)ee_name_overrideis_side_validationcert_path_stackr
   r   c                    |j                   t        d      d| _        || _        t	        |xs |j
                        | _        || _        y )NzEmpty path stackr   )head
ValueErrorindexr
   booltailr   r   )selfr   r
   r   s       S/var/www/horilla/myenv/lib/python3.12/site-packages/pyhanko_certvalidator/_state.py__init__zValProcState.__init__
   sP     '/00
 0"&6/"6"6#
  /    c                 n    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   paths      r   path_lenzValProcState.path_len   s2     	>##(($///}}r   returnc                 4    | j                   | j                  k(  S )N)r   r   )r   s    r   
is_ee_certzValProcState.is_ee_cert)   s    zzT]]**r   ee_certc                     ddl m} | j                  D ]2  }|j                         }|s|j                  |j                  k(  s0|c S  y)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   certs        r   check_path_verif_recursionz'ValProcState.check_path_verif_recursion-   sH     	> (( 	D((*Dw~~5	 r   c                     | }| j                   dk  r| j                  d}n<| j                  s||z  }d| j                    }n| j                  | j                  }nd}|rd|z   S |S )zy
        :return:
            A unicode string describing the position of a certificate
            in the chain
           certificatezintermediate certificate zend-entity certificatezthe )r   r
   r   )r   
def_interm	never_defprefixresults        r   describe_certzValProcState.describe_cert=   su     ::>d33;"Fj F0=F"".**F-FF?"Mr   )FF)__name__
__module____qualname__r   r   r   strr   r   propertyr   r   r   Certificater%   r-    r   r   r	   r	   	   s|    
 +/#(/ ".1/ #3-	/
 !/    +D + +$2B2B  r   r	   N)	typingr   
asn1cryptor   r   r   pyhanko_certvalidator.utilr   r	   r4   r   r   <module>r8      s      5 /I Ir   