ffdZddlZddlmZddlmZmZddlTddlm Z m Z m Z m Z m Z ddlmZddlmZdd lmZdd lmZd ZGd d eZdZdZdZGddejZifdZedkrdZ ej!ddSdS)z.Self-test for the custom module exponentiationN)list_test_cases) long_to_bytes bytes_to_long)*)load_pycryptodome_raw_libcreate_string_bufferget_raw_bufferc_size_t c_ulonglong)SHAKE128)Integer)_raw_montgomery) StrongRandomcJttj|}|S)N)data)rr new)tagrngs /builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib64/python3.11/site-packages/Crypto/SelfTest/Math/test_modexp.py create_rngr9s! x|--- . .C JceZdZdS)ExceptionModulusN)__name__ __module__ __qualname__rrrr=sDrrc  ttt||| fd|||fD\}}}t }t j||||t td}|dkrt|rtd|ztt|}|S)Nc0g|]}t|Sr)r).0xmax_lens r zmonty_pow..Cs/ 8 8 8qq'!:!: 8 8 8r zmonty_pow failed with error: %d) lenrmaxrr monty_powr r r ValueErrorrr ) baseexpmodulusbase_bexp_b modulus_bouterrorresultr"s @rr(r(@s-D#w 7 78899G 8 8 8 8"&W!5 8 8 8FE9 w ' 'C  %!!B   E {{    D:UBCCC >#.. / /F MrlMAUjb*a\}8z09c_(LmJC0:8yeZIf7j3D N`&E[@z^: g8*7cH o)Ra>)< emacCP:I'; d=tOjEGKaR44rr6)r(rAr:)r;r*r2s r test_zero_expzTestModExp.test_zero_expgs4D4H-- #####rchtdtt}||ddS)Nr)r(r@rAr:)r;r2s rtest_zero_basezTestModExp.test_zero_basels/1i22 #####rcd}|tt|td|ttddddS)Nlr) assertRaisesrr(r@r;r*s rtest_zero_moduluszTestModExp.test_zero_moduluspsGB *ItYJJJ *Iq!Q?????rctdz }t|tdzt}t|tdzt}|||dS)Ni@)rAr?r(r:rBs rtest_larger_exponentzTestModExp.test_larger_exponentusR)#tXr\84442x88 *****rcztdz }|tt|ttdz dS)Nr6)rArJrr(r@rKs rtest_even_moduluszTestModExp.test_even_modulus{s31} *ItYQR SSSSSrctjtd}t ddD]}t j||dz}t j|||z}t j||}t|||}t|||}| ||dS)NTestr6d) r rupdatebranger from_bytesreadr?r(r:)r;prnglengthmodulus2r* exponent2rCr2s rtest_several_lengthszTestModExp.test_several_lengthss|~~$$QvYY//Asmm / /F)$))F*;*;<rsH&y{{33rsuite) defaultTest)"__doc__r~Crypto.SelfTest.st_commonrCrypto.Util.numberrrCrypto.Util.py3compatCrypto.Util._raw_apirrr r r Crypto.Hashr Crypto.Math.Numbersr Crypto.Math._IntegerCustomrCrypto.Random.randomrrr)rr(r@rATestCaser4r{rrmainrrrrsD54555555;;;;;;;;####////////////// ! ''''''666666------     z   0 O  Nb/b/b/b/b/"b/b/b/J  z 3 3EHMg&&&&&&r