5Xc@sdZddlZejeZddlZddlmZddlm Z m Z ddl m Z m Z dZdZeeddd d d d d eeddd d d ddeeddd d d ddeeddd d d ddeedddd d ddeed dd d d ddeeddd d d ddeeddd dd dd eeddd d d!d"d#g Zd$Zejeeddd d d d%d&eeddd d d d'd(eeddd d d d)d*eeddd d d d+d,eedddd d d-d.eed dd d d d/d0eeddd d d d1d2eeddd dd d3d4eeddd d d!d5d6g d7e fd8YZd9ejd:fd;YZd<ejd=fd>YZdS(?sFpasslib.tests.test_handlers_argon2 - tests for passlib hash algorithmsiN(thash(t HandlerCaset TEST_MODE(t UPASS_TABLEtPASS_TABLE_UTF8cCsAtd|d|d|dd|>d|d|d|d |d | S( NtversiontroundstlogMt memory_costit parallelismtsecrettsaltt hex_digestR(tdict(RttRtpR R R R((sF/usr/lib/python2.7/site-packages/passlib/tests/test_handlers_argon2.pythashtests(iiitpasswordtsomesaltt@f6c4db4a54e2a370627aff3db6176b94a2a209a62c8e36152711802f7b30c694sP$argon2i$m=65536,t=2,p=1$c29tZXNhbHQ$9sTbSlTio3Biev89thdrlKKiCaYsjjYVJxGAL3swxpQit@9690ec55d28d3ed32562f2e73ea62b02b018757643a2ae6e79528459de8106e9sR$argon2i$m=1048576,t=2,p=1$c29tZXNhbHQ$lpDsVdKNPtMlYvLnPqYrArAYdXZDoq5ueVKEWd6BBukit@3e689aaa3d28a77cf2bc72a51ac53166761751182f1ee292e3f677a7da4c2467sQ$argon2i$m=262144,t=2,p=1$c29tZXNhbHQ$Pmiaqj0op3zyvHKlGsUxZnYXURgvHuKS4/Z3p9pMJGcit@fd4dd83d762c49bdeaf57c47bdcd0c2f1babf863fdeb490df63ede9975fccf06sN$argon2i$m=256,t=2,p=1$c29tZXNhbHQ$/U3YPXYsSb3q9XxHvc0MLxur+GP960kN9j7emXX8zwYt@b6c11560a6a9d61eac706b79a2f97d68b4463aa3ad87e00c07e2b01e90c564fbsN$argon2i$m=256,t=2,p=2$c29tZXNhbHQ$tsEVYKap1h6scGt5ovl9aLRGOqOth+AMB+KwHpDFZPst@81630552b8f3b1f48cdb1992c4c678643d490b2b5eb4ff6c4b3438b5621724b2sP$argon2i$m=65536,t=1,p=1$c29tZXNhbHQ$gWMFUrjzsfSM2xmSxMZ4ZD1JCytetP9sSzQ4tWIXJLIit@f212f01615e6eb5d74734dc3ef40ade2d51d052468d8c69440a3a1f2c1c2847bsP$argon2i$m=65536,t=4,p=1$c29tZXNhbHQ$8hLwFhXm6110c03D70Ct4tUdBSRo2MaUQKOh8sHChHstdifferentpasswordt@e9c902074b6754531a3a0be519e5baf404b30ce69b3f01ac3bf21229960109a3sP$argon2i$m=65536,t=2,p=1$c29tZXNhbHQ$6ckCB0tnVFMaOgvlGeW69ASzDOabPwGsO/ISKZYBCaMtdiffsaltt@79a103b90fe8aef8570cb31fc8b22259778916f8336b7bdac3892569d4f1c497sP$argon2i$m=65536,t=2,p=1$ZGlmZnNhbHQ$eaEDuQ/orvhXDLMfyLIiWXeJFvgza3vaw4kladTxxJcit@c1628832147d9720c5bd1cfd61367078729f6dfb6f8fea9ff98158e0d7816ed0sU$argon2i$v=19$m=65536,t=2,p=1$c29tZXNhbHQ$wWKIMhR9lyDFvRz9YTZweHKfbftvj+qf+YFY4NeBbtAt@d1587aca0922c3b5d6a83edab31bee3c4ebaef342ed6127a55d19b2351ad1f41sW$argon2i$v=19$m=1048576,t=2,p=1$c29tZXNhbHQ$0Vh6ygkiw7XWqD7asxvuPE667zQu1hJ6VdGbI1GtH0Et@296dbae80b807cdceaad44ae741b506f14db0959267b183b118f9b24229bc7cbsV$argon2i$v=19$m=262144,t=2,p=1$c29tZXNhbHQ$KW266AuAfNzqrUSudBtQbxTbCVkmexg7EY+bJCKbx8st@89e9029f4637b295beb027056a7336c414fadd43f6b208645281cb214a56452fsS$argon2i$v=19$m=256,t=2,p=1$c29tZXNhbHQ$iekCn0Y3spW+sCcFanM2xBT63UP2sghkUoHLIUpWRS8t@4ff5ce2769a1d7f4c8a491df09d41a9fbe90e5eb02155a13e4c01e20cd4eab61sS$argon2i$v=19$m=256,t=2,p=2$c29tZXNhbHQ$T/XOJ2mh1/TIpJHfCdQan76Q5esCFVoT5MAeIM1Oq2Et@d168075c4d985e13ebeae560cf8b94c3b5d8a16c51916b6f4ac2da3ac11bbecfsU$argon2i$v=19$m=65536,t=1,p=1$c29tZXNhbHQ$0WgHXE2YXhPr6uVgz4uUw7XYoWxRkWtvSsLaOsEbvs8t@aaa953d58af3706ce3df1aefd4a64a84e31d7f54175231f1285259f88174ce5bsU$argon2i$v=19$m=65536,t=4,p=1$c29tZXNhbHQ$qqlT1YrzcGzj3xrv1KZKhOMdf1QXUjHxKFJZ+IF0zlst@14ae8da01afea8700c2358dcef7c5358d9021282bd88663a4562f59fb74d22eesU$argon2i$v=19$m=65536,t=2,p=1$c29tZXNhbHQ$FK6NoBr+qHAMI1jc73xTWNkCEoK9iGY6RWL1n7dNIu4t@b0357cccfbef91f3860b0dba447b2348cbefecadaf990abfe9cc40726c521271sU$argon2i$v=19$m=65536,t=2,p=1$ZGlmZnNhbHQ$sDV8zPvvkfOGCw26RHsjSMvv7K2vmQq/6cxAcmxSEnEt_base_argon2_testcBseZejZddedfedfdgZdddd d gZd Z dd Z d Z dZ dZdZdZdZdZdejfdYZRS(Rs>$argon2i$v=19$m=256,t=1,p=1$c29tZXNhbHQ$AJFIsNZTMKTAewB4+ETN1As>$argon2i$v=19$m=380,t=2,p=2$c29tZXNhbHQ$SrssP8n7m/12VWPM8dvNrwsI$argon2i$v=19$m=512,t=2,p=2$1sV0O4PWLtc12Ypv1f7oGw$z+yqzlKtrq3SaNfXDfIDnQt passwords>$argon2i$v=19$m=512,t=2,p=2$c29tZXNhbHQ$Fb5+nPuLzZvtqKRwqUEtUQsX$argon2i$v=19$t=2,p=4$c29tZXNhbHQAAAAAAAAAAA$QWLzI4TY9HkL2ZTLc8g6SinwdhZewYrzz9zxCo0bkGYsi$argon2i$v=19$m=65536,t=8589934592,p=4$c29tZXNhbHQAAAAAAAAAAA$QWLzI4TY9HkL2ZTLc8g6SinwdhZewYrzz9zxCo0bkGYsd$argon2i$v=19$m=65536,t=2,p=4,q=5$c29tZXNhbHQAAAAAAAAAAA$QWLzI4TY9HkL2ZTLc8g6SinwdhZewYrzz9zxCo0bkGYsd$argon2i$v=19$t=2,m=65536,p=4,q=5$c29tZXNhbHQAAAAAAAAAAA$QWLzI4TY9HkL2ZTLc8g6SinwdhZewYrzz9zxCo0bkGYsT$argon2i$v=19$m=127,t=2,p=16$c29tZXNhbHQ$IMit9qkFULCMA/ViizL57cnTLOa5DiVM9eMwpAvPwr4cCs'tt|jtjdddS(Ntignores.*Using argon2pure backend.*(tsuperR't setUpWarningstwarningstfilterwarnings(tself((sF/usr/lib/python2.7/site-packages/passlib/tests/test_handlers_argon2.pyR+scKsi|jdkrL|p|jj|}|dt}|j|_|jStt|j ||SdS(Nt argon2_cffit use_defaults( tbackendthandlertusingtTruet_stub_checksumtchecksumt to_stringR*R'tdo_stub_encrypt(R.R2tsettings((sF/usr/lib/python2.7/site-packages/passlib/tests/test_handlers_argon2.pyR8s   cCs|jddS(Ns!legacy 1.6 workflow not supported(tskipTest(R.((sF/usr/lib/python2.7/site-packages/passlib/tests/test_handlers_argon2.pyttest_03_legacy_hash_workflowscCs |jt|jjdddS(NRs`$argon2i$v=19$m=65536,t=2,p=4,keyid=ABCD$c29tZXNhbHQ$IMit9qkFULCMA/ViizL57cnTLOa5DiVM9eMwpAvPwr4(t assertRaisestNotImplementedErrorR2tverify(R.((sF/usr/lib/python2.7/site-packages/passlib/tests/test_handlers_argon2.pyttest_keyid_parameterscCs|j}d}d}d}|jdkrb|jt|jd||j|jd||n5|j|jd||j|jd|||jdkr|jt|jd||j|jd||n8|j|jjd||j|jd||dS(NsO$argon2i$v=19$m=512,t=2,p=2,data=c29tZWRhdGE$c29tZXNhbHQ$KgHyCesFyyjkVkihZ5VNFwsO$argon2i$v=19$m=512,t=2,p=2,data=c29tZWRhdGE$c29tZXNhbHQ$uEeXt1dxN1iFKGhklseW4ws>$argon2i$v=19$m=512,t=2,p=2$c29tZXNhbHQ$uEeXt1dxN1iFKGhklseW4wR/R( R2R1R<R=R>t assertEqualtgenhasht assertTruet assertFalse(R.R2tsample1tsample2tsample3((sF/usr/lib/python2.7/site-packages/passlib/tests/test_handlers_argon2.pyttest_data_parameters cCs |jt|jjdddS(Ntstubsj$argon2i$v=19$m=65536,t=2,p=4,keyid=ABCD,data=EFGH$c29tZXNhbHQ$IMit9qkFULCMA/ViizL57cnTLOa5DiVM9eMwpAvPwr4(R<R=R2R>(R.((sF/usr/lib/python2.7/site-packages/passlib/tests/test_handlers_argon2.pyttest_keyid_and_data_parametersscCsZ|j}|jd}|j|j||jdd}|j|j|dS(NRHs $argon2i$s $argon2d$(R2RRCt needs_updatetreplaceRB(R.R2Rthash2((sF/usr/lib/python2.7/site-packages/passlib/tests/test_handlers_argon2.pyttest_needs_update_w_types  c Cso|jjdddddddd}d }|jd krU|j|j|n|j|j|dS( NRit time_costiR it digest_sizei s[$argon2i$m=65536,t=2,p=4$c29tZXNhbHQAAAAAAAAAAA$QWLzI4TY9HkL2ZTLc8g6SinwdhZewYrzz9zxCo0bkGYi(R2R3t max_versionRCRJRB(R.R2R((sF/usr/lib/python2.7/site-packages/passlib/tests/test_handlers_argon2.pyttest_needs_update_w_versions  c Cs|j}|jdkr*|jdnd}|jddddddd |d d }|jd }|j|d d}|jddddddd |d d }|jd }|j|ddS(s3verify we're using right base64 encoding for argon2is,handler uses wrong version for sample hashesRRiRNiR R t checksum_sizei RsS$argon2i$v=19$m=256,t=2,p=2$c29tZXNhbHQ$T/XOJ2mh1/TIpJHfCdQan76Q5esCFVoT5MAeIM1Oq2Etsomesalts^$argon2i$v=19$m=256,t=2,p=2$c29tZXNhbHQAAAAAAAAAAA$rqnbEp1/jFDUEKZZmw+z14amDsFqMDC53dIe57ZHD38N(R2RR:R3RR@(R.R2R ttempR((sF/usr/lib/python2.7/site-packages/passlib/tests/test_handlers_argon2.pyttest_argon_byte_encodings ! ! tFuzzHashGeneratorcBs3eZejjjZejdddZRS(Rtrandom_memory_costcCsB|jjdkr(|jddddS|jddddSdS(Nt argon2pureiiiii@i(ttestR1t randintgauss(R.((sF/usr/lib/python2.7/site-packages/passlib/tests/test_handlers_argon2.pyRW#s(t__name__t __module__RRVt settings_maptcopytupdateRW(((sF/usr/lib/python2.7/site-packages/passlib/tests/test_handlers_argon2.pyRVs(spasswords>$argon2i$v=19$m=256,t=1,p=1$c29tZXNhbHQ$AJFIsNZTMKTAewB4+ETN1A(spasswords>$argon2i$v=19$m=380,t=2,p=2$c29tZXNhbHQ$SrssP8n7m/12VWPM8dvNrw(R(s>$argon2i$v=19$m=512,t=2,p=2$c29tZXNhbHQ$Fb5+nPuLzZvtqKRwqUEtUQN(R[R\Rtargon2R2RRtknown_correct_hashestknown_malformed_hashesR+tNoneR8R;R?RGRIRMRQRURRV(((sF/usr/lib/python2.7/site-packages/passlib/tests/test_handlers_argon2.pyR'ks*        :  targon2_argon2_cffi_testR/cBs8eZejddd d gZejdeDRS( Rs[$argon2i$m=65536,t=2,p=4$c29tZXNhbHQAAAAAAAAAAA$QWLzI4TY9HkL2ZTLc8g6SinwdhZewYrzz9zxCo0bkGYsU$argon2i$v=19$m=65536,t=2,p=4$c29tZXNhbHQ$IMit9qkFULCMA/ViizL57cnTLOa5DiVM9eMwpAvPwr4sU$argon2d$v=19$m=65536,t=2,p=4$c29tZXNhbHQ$cZn5d+rFh+ZfuRhm2iGUGgcrW5YLeM6q7L3vBsdmFA0R(sU$argon2i$v=19$m=65536,t=2,p=4$c29tZXNhbHQ$Vpzuc0v0SrP88LcVvmg+z5RoOYpMDKH/lt6O+CZabIQccsE|];}|dtdr"dndkr|d|dfVqdS(RtfulliiR RN(R(t.0tinfo((sF/usr/lib/python2.7/site-packages/passlib/tests/test_handlers_argon2.pys Ps(spasswords[$argon2i$m=65536,t=2,p=4$c29tZXNhbHQAAAAAAAAAAA$QWLzI4TY9HkL2ZTLc8g6SinwdhZewYrzz9zxCo0bkGY(spasswordsU$argon2i$v=19$m=65536,t=2,p=4$c29tZXNhbHQ$IMit9qkFULCMA/ViizL57cnTLOa5DiVM9eMwpAvPwr4(spasswordsU$argon2d$v=19$m=65536,t=2,p=4$c29tZXNhbHQ$cZn5d+rFh+ZfuRhm2iGUGgcrW5YLeM6q7L3vBsdmFA0(s passwordsU$argon2i$v=19$m=65536,t=2,p=4$c29tZXNhbHQ$Vpzuc0v0SrP88LcVvmg+z5RoOYpMDKH/lt6O+CZabIQ(R[R\R'Ratextendtreference_data(((sF/usr/lib/python2.7/site-packages/passlib/tests/test_handlers_argon2.pyRd/s targon2_argon2pure_testRXcBsfeZejjddddZee_ej Z e j de Ddej fdYZ RS(Ri R iccs3|])}|ddkr|d|dfVqdS(RiR RN((RfRg((sF/usr/lib/python2.7/site-packages/passlib/tests/test_handlers_argon2.pys bsRVcBseZdZRS(cCs|jddddS(Niii(RZ(R.((sF/usr/lib/python2.7/site-packages/passlib/tests/test_handlers_argon2.pyt random_roundshs(R[R\Rk(((sF/usr/lib/python2.7/site-packages/passlib/tests/test_handlers_argon2.pyRVfs( R[R\RR`R3R2R4tpure_use_threadsR'RaRhRiRV(((sF/usr/lib/python2.7/site-packages/passlib/tests/test_handlers_argon2.pyRjTs   (t__doc__tloggingt getLoggerR[tlogR,tpasslibRtpasslib.tests.utilsRRtpasslib.tests.test_handlersRRRRRiRhR'tcreate_backend_caseRdRj(((sF/usr/lib/python2.7/site-packages/passlib/tests/test_handlers_argon2.pyts     %