wec@sddlZddlmZmZddlmZddlmZmZdej fdYZ dej fdYZ id Z e d krd Zejd d ndS(iN(t unhexlifythexlify(tlist_test_cases(tstrxortstrxor_ct StrxorTestscBs}eZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d ZRS( cCsZtd}td}td}|jt||||jt|||dS(Ntff339a83e5cd4cdf5649t383d4ba020573314395btc70ed123c59a7fcb6f12(Rt assertEqualR(tselftterm1tterm2tresult((sF/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Util/test_strxor.pyttest1+s    cCs#d}|jt|||dS(Nt(R R(R tes((sF/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Util/test_strxor.pyttest22scCs9td}dt|}|jt|||dS(NRt(RtlenR R(R R t all_zeros((sF/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Util/test_strxor.pyttest36s cCs2td}td}|jtt||dS(NRtff339a83e5cd4cdf564990(Rt assertRaisest ValueErrorR(R R R ((sF/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Util/test_strxor.pyttest_wrong_length;s  cCsMtd}t|}td}td}|jt|||dS(NRRR(Rt bytearrayR R(R R tterm1_baR R ((sF/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Util/test_strxor.pyttest_bytearray@s     cCsMtd}t|}td}td}|jt|||dS(NRRR(Rt memoryviewR R(R R tterm1_mvR R ((sF/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Util/test_strxor.pyttest_memoryviewHs     cCstd}td}|}|}td}tt|}t||d|}|j|d|j|||j|||j||dS(s3Verify result can be stored in pre-allocated memoryRRRtoutputN(RRRRR tNone(R R R toriginal_term1toriginal_term2t expected_xorR R ((sF/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Util/test_strxor.pyttest_output_bytearrayPs   cCstd}td}|}|}td}ttt|}t||d|}|j|d|j|||j|||j||dS(s3Verify result can be stored in pre-allocated memoryRRRR N(RRRRRR R!(R R R R"R#R$R R ((sF/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Util/test_strxor.pyttest_output_memoryviewas   cCszttd}td}|}td}t||d|}|j|d|j|||j||dS(s1Verify result can be stored in overlapping memoryRRRR N(RRRR R!(R R R R#R$R ((sF/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Util/test_strxor.pyt!test_output_overlapping_bytearrayrs  cCstttd}td}|}td}t||d|}|j|d|j|||j||dS(s1Verify result can be stored in overlapping memoryRRRR N(RRRRR R!(R R R R#R$R ((sF/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Util/test_strxor.pyt"test_output_overlapping_memoryviews  cCs8td}td}|jtt||d|dS(s2Verify result cannot be stored in read-only memoryRRR N(RRt TypeErrorR(R R R ((sF/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Util/test_strxor.pyttest_output_ro_bytess  cCs>ttd}td}|jtt||d|dS(s2Verify result cannot be stored in read-only memoryRRR N(RRRR)R(R R R ((sF/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Util/test_strxor.pyttest_output_ro_memoryviews cCsNtd}td}tt|d}|jtt||d|dS(s<Verify result cannot be stored in memory of incorrect lengthRRiR N(RRRRRR(R R R R ((sF/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Util/test_strxor.pyttest_output_incorrect_lengths  (t__name__t __module__RRRRRRR%R&R'R(R*R+R,(((sF/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Util/test_strxor.pyR)s            t Strxor_cTestscBs}eZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d ZRS( cCs5td}td}|jt|d|dS(NRtbe72dbc2a48c0d9e1708iA(RR R(R R R ((sF/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Util/test_strxor.pyRs  cCs)td}|jt|d|dS(NRi(RR R(R R ((sF/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Util/test_strxor.pyRs cCs|jtddddS(NRiZ(R R(R ((sF/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Util/test_strxor.pyRscCs<td}|jtt|d|jtt|ddS(NRii(RRRR(R R ((sF/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Util/test_strxor.pyttest_wrong_ranges cCsAtd}t|}td}|jt|d|dS(NRR0iA(RRR R(R R RR ((sF/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Util/test_strxor.pyRs   cCsAtd}t|}td}|jt|d|dS(NRR0iA(RRR R(R R RR ((sF/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Util/test_strxor.pyRs   cCsztd}|}td}tt|}t|dd|}|j|d|j|||j||dS(NRR0iAR (RRRRR R!(R R R"texpected_resultR R ((sF/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Util/test_strxor.pyR%s  cCstd}|}td}ttt|}t|dd|}|j|d|j|||j||dS(NRR0iAR (RRRRRR R!(R R R"R2R R ((sF/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Util/test_strxor.pyR&s  cCsWttd}td}t|dd|}|j|d|j||dS(s1Verify result can be stored in overlapping memoryRR0iAR N(RRRR R!(R R R$R ((sF/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Util/test_strxor.pyR's  cCs]tttd}td}t|dd|}|j|d|j||dS(s1Verify result can be stored in overlapping memoryRR0iAR N(RRRRR R!(R R R$R ((sF/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Util/test_strxor.pyR(s  cCs,td}|jtt|dd|dS(s2Verify result cannot be stored in read-only memoryRiAR N(RRR)R(R R ((sF/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Util/test_strxor.pyR*s cCs>ttd}td}|jtt|dd|dS(s2Verify result cannot be stored in read-only memoryRRiAR N(RRRR)R(R R R ((sF/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Util/test_strxor.pyR+s cCsBtd}tt|d}|jtt|dd|dS(s<Verify result cannot be stored in memory of incorrect lengthRiiAR N(RRRRRR(R R R ((sF/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Util/test_strxor.pyR,s (R-R.RRRR1RRR%R&R'R(R*R+R,(((sF/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Util/test_strxor.pyR/s        cCs*g}|tt7}|tt7}|S(N(RRR/(tconfigttests((sF/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Util/test_strxor.pyt get_testsst__main__cCstjtS(N(tunittestt TestSuiteR5(((sF/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Util/test_strxor.pytst defaultTesttsuite(R7tbinasciiRRtCrypto.SelfTest.st_commonRtCrypto.Util.strxorRRtTestCaseRR/R5R-R;tmain(((sF/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Util/test_strxor.pyt"s g