
    Eh                        d Z dZddlZddlZddlZddl ej                  dk  rd ZneZ G d dej                        Z	 G d	 d
ej                        Z
 G d dej                        Z G d dej                        ZddZd Zy)z&Self-testing for PyCrypto hash modulesz$Id$    N)*i  c                  "    | j                         S N)copy)kwargss    \/var/www/html/bid_assistant/venv/lib/python3.12/site-packages/Crypto/SelfTest/Hash/common.pydictr	   &   s    {{}    c                       e Zd Zd Zd Zd Zy)HashDigestSizeSelfTestc                 l    t         j                  j                  |        || _        || _        || _        y r   )unittestTestCase__init__hashmodexpecteddescription)selfr   r   r   s       r   r   zHashDigestSizeSelfTest.__init__.   s,    ""4( &r
   c                     | j                   S r   r   r   s    r   shortDescriptionz'HashDigestSizeSelfTest.shortDescription4       r
   c                 d   | j                  t        | j                  d             | j                  | j                  j                  | j
                         | j                  j                         }| j                  t        |d             | j                  |j                  | j
                         y )Ndigest_size)
failUnlesshasattrr   assertEqualsr   r   new)r   hs     r   runTestzHashDigestSizeSelfTest.runTest7   st    m<=$,,22DMMBLL=12!--7r
   N__name__
__module____qualname__r   r   r!    r
   r   r   r   ,   s    ' 8r
   r   c                       e Zd Zd Zd Zd Zy)HashSelfTestc                 z    t         j                  j                  |        || _        || _        || _        || _        y r   )r   r   r   r   r   inputr   )r   r   r   r   r*   s        r   r   zHashSelfTest.__init__A   s3    ""4( 
&r
   c                     | j                   S r   r   r   s    r   r   zHashSelfTest.shortDescriptionH   r   r
   c                    | j                   j                         }|j                  | j                         t	        j
                  |j                               }|j                         }| j                   j                  | j                        }|j                         }t	        j
                  |j                               }| j                  | j                  |       t        j                  d   dk(  r9| j                  | j                  |       | j                  | j                  |       nT| j                  | j                  j                         |       | j                  | j                  j                         |       | j                  | j                  |       |j                         }|j                  | j                         t	        j
                  |j                               }| j                  | j                  |       y )Nr      )r   r   updater*   binasciib2a_hexdigest	hexdigestassertEqualr   sysversion_infodecode)r   r    out1out2out3out4h2out5s           r   r!   zHashSelfTest.runTestK   sd   LL	
+{{}LLTZZ({{}
+ 	-A!#T]]D1T]]D1T]]113T:T]]113T:- UUW
		$**		,-r
   Nr"   r&   r
   r   r(   r(   ?   s    ' .r
   r(   c                       e Zd Zd Zd Zy)HashTestOIDc                 ^    t         j                  j                  |        || _        || _        y r   )r   r   r   r   oid)r   r   r@   s      r   r   zHashTestOID.__init__h   s$    ""4(r
   c                    | j                   j                         }| j                  d k(  r"	 d}|j                  }| j	                  |d       y | j	                  |j                  | j                         y # t        $ r d}Y Gw xY w)Nr      )r   r   r@   AttributeErrorr3   )r   r    raisedas       r   r!   zHashTestOID.runTestm   sr    LL88T>EE VA&QUUDHH-	 " s   A3 3B BN)r#   r$   r%   r   r!   r&   r
   r   r>   r>   g   s    

.r
   r>   c                       e Zd Zd Zd Zd Zy)MACSelfTestc                     t         j                  j                  |        || _        || _        || _        || _        || _        || _        y r   )	r   r   r   r   expected_dictr*   keyhashmodsr   )r   r   r   rI   r*   rJ   rK   s          r   r   zMACSelfTest.__init__{   sB    ""4(*
 &r
   c                     | j                   S r   r   r   s    r   r   zMACSelfTest.shortDescription   r   r
   c                    | j                   j                         D ]F  }| j                  |   }t        j                  t        | j                              }t        j                  t        | j                              }t        dj                  | j                   |   j                                     }| j                  j                  ||      }|j                  |       t        j                  |j                               }|j                         }| j                  j                  |||      }|j                         }	t        j                  |j                               }
|j!                         }|j                  t        d             t        j                  |j                               }| j#                  ||       t$        j&                  d   dk(  r%| j#                  ||       | j#                  ||	       n@| j#                  |j)                         |       | j#                  |j)                         |	       | j#                  ||
       | j#                  ||       I y )N )	digestmodzblah blah blahr   r-   )rI   keysrK   r/   a2b_hexbrJ   r*   joinsplitr   r   r.   r0   r1   r2   r   r3   r4   r5   r6   )r   hashnamer   rJ   datar   r    r7   r8   r9   r:   r;   r<   s                r   r!   zMACSelfTest.runTest   s   **//1  	-HmmH-G""1TXX;/C##AdjjM2D !3!3H!=!C!C!EFGH   8AHHTN##AHHJ/D;;=D  dG4A;;=D##AHHJ/D BHHQ'()##BIIK0D Xt,"a'  40  40  !2D9  !2D9Xt,Xt,A 	-r
   Nr"   r&   r
   r   rG   rG   y   s    ' !-r
   rG   c           	         g }t        t        |            D ]s  }||   }t        t        |dd       \  }}	t        |      dk  rt	        |	      }
n|d   j                  d      }
d||dz   |
fz  }|j                  t        | |||	             u |t        |      }d|dz   fz  }|j                  t        | ||             |j                  t        | |             |S )Nr   r-      zlatin-1
%s #%d: %srB   z%s #%d: digest_size)
rangelenmaprR   reprencodeappendr(   r   r>   )modulemodule_name	test_datar   r@   testsirowr   r*   r   names               r   make_hash_testsrg      s    E3y>" Bl#a(O5s8a<u+Ka&--	2K{AaC==\&$%@AB f K1#55D	LL'kBC	LLVS)*Lr
   c                     g }t        t        |            D ]8  }||   }|\  }}}	}
d||dz   |
fz  }|j                  t        | ||	|||             : |S )NrY   rB   )rZ   r[   r_   rG   )r`   ra   rb   rK   rc   rd   re   rJ   rV   resultsr   rf   s               r   make_mac_testsrj      so    E3y>" Nl,/)dG[{AaC==[wc8LM	N
 Lr
   r   )__doc____revision__r4   r   r/   Crypto.Util.py3compat
hexversionr	   r   r   r(   r>   rG   rg   rj   r&   r
   r   <module>ro      s   2 - 
   # >>J D8X.. 8&&.8$$ &.P.(## .$/-(## /-b$r
   