
    ,hF!                         d dl Z d dlZd dlZd dlZd dlZd dlZd dlmZ d dlmZ 	 d dl	Z	dZ
d Zd Zi i i fdZy# e$ r dZ
Y w xY w)	    N)	unhexlify)FileNotFoundErrorTFc                 :   d}g } G d dt               }d}d}d}		 |dz  }|j                         }
|
s||j                  |       	 |S |
j                         }
|
j	                  d      s|
sd}	T|
j	                  d      r'||j                  |       d}|j                  |
       |	r(|dz  }d	}	||j                  |        |d
||fz  |      }t        j                  d|
      }|s|xj                  |
gz  c_        n|j                  d      j                         }|j                  d      j                         }|j                  |d      }|7t        |      dz  dk7  rd|z   }t        ||t        j                  |             nt        || ||             )zLoad and parse a test vector file

    Return a list of objects, one per group of adjacent
    KV lines or for a single line in the form "[.*]".

    For a group of lines, the object has one attribute per line.
    r   c                       e Zd Zd Zy)_load_tests.<locals>.TestVectorc                 .    || _         || _        g | _        y )N)desccountothers)selfdescriptionr
   s      X/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/Crypto/SelfTest/loader.py__init__z(_load_tests.<locals>.TestVector.__init__=   s    #DIDJDK    N)__name__
__module____qualname__r    r   r   
TestVectorr   <   s    	r   r   NT   #[Fz%s (#%d)z([A-Za-z0-9]+) = ?(.*)   0)objectreadlineappendstrip
startswithrematchr   grouplowergetlensetattrbinasciir   )	dir_compsfile_inr   conversionsline_numberresultsr   test_vectorr
   	new_grouplinerestokendata
conversions                  r   _load_testsr4   0   s    KGV  KEI
q!&{+L NK zz| ??3tI??3&{+KNN4 QJEI&{+$Z;2F%FNKhh/64&(IIaL&&(E99Q<%%'D$5J!t9q=A%:DUH,>,>t,DEUJt,<=S r   c                 2   d}	 t         s<t        t        j                  t	        j
                  t        j                        |      |d|d}t        j                  j                  t        j                        }t        j                  j                  t	        j                  j                  |g|  |      }t        |      5 }t        | |||      }ddd       |S # 1 sw Y   |S xY w# t        $ r# t        j                  d|z   t        d       Y |S w xY w)a  Load and parse a test vector file, formatted using the NIST style.

    Args:
        dir_comps (list of strings):
          The path components under the ``pycryptodome_test_vectors`` package.
          For instance ``("Cipher", "AES")``.
        file_name (string):
          The name of the file with the test vectors.
        description (string):
          A description applicable to the test vectors in the file.
        conversions (dictionary):
          The dictionary contains functions.
          Values in the file that have an entry in this dictionary
          will be converted usign the matching function.
          Otherwise, values will be considered as hexadecimal and
          converted to binary.

    Returns:
        A list of test vector objects.

    The file is formatted in the following way:

    - Lines starting with "#" are comments and will be ignored.
    - Each test vector is a sequence of 1 or more adjacent lines, where
      each lines is an assignement.
    - Test vectors are separated by an empty line, a comment, or
      a line starting with "[".

    A test vector object has the following attributes:

    - desc (string): description
    - counter (int): the order of the test vector in the file (from 1)
    - others (list): zero or more lines of the test vector that were not assignments
    - left-hand side of each assignment (lowercase): the value of the
      assignement, either converted or bytes.
    Nz test ()%Warning: skipping extended tests for r   
stacklevel)test_vectors_availabler   errnoENOENTosstrerrorpathdirnamepycryptodome_test_vectors__file__joinopenr4   warningswarnUserWarning)r(   	file_namer   r*   r,   init_dirfull_file_namer)   s           r   load_test_vectorsrK   u   s    L G$%#ELL$&KK$=$-/ / )4Y?77??#<#E#EFbggll8&Hi&H)T.! 	PW!)Wk;OG	P N	P N  $=K!!"	$ N$s0   C C* CC* C'"C* 'C* *(DDc                    g }	 t         s<t        t        j                  t	        j
                  t        j                        |      t        j                  j                  t        j                        }t        j                  j                  t	        j                  j                  |g|  |      }t        |      5 }	t        j                  |	      }
d d d         G d dt"              }h d}|t%        |j'                               z  }i }|j)                         D ]  \  }} |
      ||<    
d   D ]9  }i }|j)                         D ]  \  }} ||      ||<    |d   D ]  } |       }|j)                         D ]  \  }}t+        |||        |j)                         D ]  \  }}t+        |||        |d	   |_        |d
   |_        |D ]!  }||v s	 t+        ||t1        ||                # ||_        |j)                         D ]  \  }}t+        || ||              |d   dk7  |_        |d   dk(  |_        |j?                  d      |_         ||_        |jC                  |        < |S # 1 sw Y   xY w# t        $ r$ t        j                  d|z   t         d       |cY S w xY w# t2        j4                  $ r  t7        d|d|j,                  d|d      w xY w)Nr7   r   r8   c                       e Zd Zy)0load_test_vectors_wycheproof.<locals>.TestVectorN)r   r   r   r   r   r   r   rN      s    r   r   >   ctivaadikmkeymsgokmsigtaginfosaltlabelpublicshared
testGroupsteststcIdcommentzError decoding attribute 'z' (tcId=z, file r6   resultinvalid
acceptableflags)"r:   r   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   jsonloadrE   rF   rG   r   setkeysitemsr&   idr`   r   r'   Error
ValueErrorfilenamevalidwarningr$   rd   r   )r(   rH   r   root_tag	group_tagunit_tagra   rI   rJ   r)   tv_treer   unit_attr_hexcommon_rootkvr"   common_grouptesttvattrs                        r   load_test_vectors_wycheproofr|      s    F%#ELL$&KK$=$-/ / 77??#<#E#EFbggll8&Hi&H)T.! 	)Wii(G	)V M S))MK  $17A$ & !OO% 	'DAqhLO	' 'N 	DB#))+ "1Aq!"$**, "1Aq!" LBEiBJ% x4<xD)DJ*?@x $BK ( (1Aqw'( H~2BHh<7BJxx(BH#BKMM"7	!F Mw	) 	)  =K!!"	$ 	R $>> x(_cegejejlu)vwwxs6   B8I? <I2I? J/2I<7I? ?*J,+J,/3K"	)r=   r    re   r;   r'   rE   r   Crypto.Util.py3compatr   rA   r:   ImportErrorr4   rK   r|   r   r   r   <module>r      sa   > 
 	      3#$!
BJ:| +-RGM  #"#s   : AA