Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyc

ó
T:´Nc@sdZdZddlZddlZejddkoGejddkrWddlTnddlTddlZddlm	Z	m
Z
mZd	ejfd
„ƒYZ
de
fd„ƒYZd
e
fd„ƒYZid„Zedkrd„ZejddƒndS(s(Self-test suite for Crypto.PublicKey.RSAs$Id$iÿÿÿÿNiii(t*(tlist_test_casesta2b_hextb2a_hextRSATestcBs¶eZdZdZdZdZdZd„Zd„Zd„Z	d„Z
d	„Zd
„Zd„Z
d„Zd
„Zd„Zd„Zd„Zd„Zd„Zd„Zd„ZRS(sÅ
           eb 7a 19 ac e9 e3 00 63 50 e3 29 50 4b 45 e2
        ca 82 31 0b 26 dc d8 7d 5c 68 f1 ee a8 f5 52 67
        c3 1b 2e 8b b4 25 1f 84 d7 e0 b2 c0 46 26 f5 af
        f9 3e dc fb 25 c9 c2 b3 ff 8a e1 0e 83 9a 2d db
        4c dc fe 4f f4 77 28 b4 a1 b7 c1 36 2b aa d2 9a
        b4 8d 28 69 d5 02 41 21 43 58 11 59 1b e3 92 f9
        82 fb 3e 87 d0 95 ae b4 04 48 db 97 2f 3a c1 4f
        7b c2 75 19 52 81 ce 32 d2 f1 b7 6d 4d 35 3e 2d
    sÅ
        12 53 e0 4d c0 a5 39 7b b4 4a 7a b8 7e 9b f2 a0
        39 a3 3d 1e 99 6f c8 2a 94 cc d3 00 74 c9 5d f7
        63 72 20 17 06 9e 52 68 da 5d 1c 0b 4f 87 2c f6
        53 c1 1d f8 23 14 a6 79 68 df ea e2 8d ef 04 bb
        6d 84 b1 c3 1d 65 4a 19 70 e5 78 3b d6 eb 96 a0
        24 c2 ca 2f 4a 90 fe 9f 2e f5 c9 c1 40 e5 bb 48
        da 95 36 ad 87 00 c8 4f c9 13 0a de a7 4e 55 8d
        51 a7 4d df 85 d8 b5 0d e9 68 38 d6 06 3e 09 55
    sÅ
        bb f8 2f 09 06 82 ce 9c 23 38 ac 2b 9d a8 71 f7
        36 8d 07 ee d4 10 43 a4 40 d6 b6 f0 74 54 f5 1f
        b8 df ba af 03 5c 02 ab 61 ea 48 ce eb 6f cd 48
        76 ed 52 0d 60 e1 ec 46 19 71 9d 8a 5b 8b 80 7f
        af b8 e0 a3 df c7 37 72 3e e6 b4 b7 d9 3a 25 84
        ee 6a 64 9d 06 09 53 74 88 34 b2 45 45 98 39 4e
        e0 aa b1 2d 7b 61 a5 1f 52 7a 9a 41 f6 c1 68 7f
        e2 53 72 98 ca 2a 8f 59 46 f8 e5 fd 09 1d bd cb
    lså
        c9 7f b1 f0 27 f4 53 f6 34 12 33 ea aa d1 d9 35
        3f 6c 42 d0 88 66 b1 d0 5a 0f 20 35 02 8b 9d 86
        98 40 b4 16 66 b4 2e 92 ea 0d a3 b4 32 04 b5 cf
        ce 33 52 52 4d 04 16 a5 a4 41 e7 00 af 46 15 03
    cCsÎddlmaddlmaddlmam}tt|jƒƒ|_	tt|j
ƒƒ|_t|j	|jƒd|_
||j|jd|j
dƒ|_||j|j
ƒ|_t|_dS(Niÿÿÿÿ(tRSA(tRandom(t
bytes_to_longtinverseii(tCrypto.PublicKeyRtCryptoRtCrypto.Util.numberRRRtmodulustntprime_factortptdivmodtqtetdtutrsa(tselfR((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pytsetUpZs'cCsV|jjdƒ}|j|ƒ|j|ƒ|jƒ}|j|ƒ|j|ƒdS(s7RSA (default implementation) generated key (1 argument)iN(Rtgeneratet_check_private_keyt_exercise_primitivet	publickeyt_check_public_keyt_exercise_public_primitive(RtrsaObjtpub((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyttest_generate_1argis


cCsb|jjdtjƒjƒ}|j|ƒ|j|ƒ|jƒ}|j|ƒ|j	|ƒdS(s8RSA (default implementation) generated key (2 arguments)iN(
RRRtnewtreadRRRRR(RRR((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyttest_generate_2argrs


cCsI|jj|j|jfƒ}|j|ƒ|j|ƒ|j|ƒdS(s6RSA (default implementation) constructed key (2-tuple)N(Rt	constructR
RRt_check_encryptiont_check_verification(RR((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyttest_construct_2tuple{s

cCs\|jj|j|j|jfƒ}|j|ƒ|j|ƒ|j|ƒ|j|ƒdS(s6RSA (default implementation) constructed key (3-tuple)N(	RR$R
RRR%t_check_decryptiont_check_signingR&(RR((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyttest_construct_3tuple‚s
$


cCsb|jj|j|j|j|jfƒ}|j|ƒ|j|ƒ|j|ƒ|j	|ƒdS(s6RSA (default implementation) constructed key (4-tuple)N(
RR$R
RRRR%R(R)R&(RR((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyttest_construct_4tupleŠs
*


cCsu|jj|j|j|j|j|jfƒ}|j|ƒ|j|ƒ|j	|ƒ|j
|ƒ|j|ƒdS(s6RSA (default implementation) constructed key (5-tuple)N(RR$R
RRRRRR%R(R)R&(RR((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyttest_construct_5tuple’s0



cCs{|jj|j|j|j|j|j|jfƒ}|j|ƒ|j	|ƒ|j
|ƒ|j|ƒ|j|ƒdS(s6RSA (default implementation) constructed key (6-tuple)N(
RR$R
RRRRRRR%R(R)R&(RR((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyttest_construct_6tuple›s6



cCsà|jd|jƒƒ|jd|jƒƒ|jd|jƒƒ|jd|jƒƒ|j|j|jjƒ|j|j|jjƒ|j|j|jjƒ|j|j	|jj	ƒ|j|j
|jj
ƒ|j|j|jjƒ|jd|j	|j
kƒ|j|j|j	|j
ƒ|jd|j|j|j	d|j
dƒ|jd|j	|j|j
ƒ|jd|j	dkƒ|jd|j
dkƒ|jd|jdkƒ|jd|jdkƒdS(Ni(tassertEqualthas_privatetcan_signtcan_encryptt	can_blindR
tkeyRRRRR(RR((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyR¤s$0!cCst|jƒ}|jd|jƒƒ|jd|jƒƒ|jd|jƒƒ|jd|jƒƒ|j|j|jjƒ|j|j	|jj	ƒ|jdt
|dƒƒ|jdt
|dƒƒ|jdt
|dƒƒ|jdt
|dƒƒ|jdt
|jdƒƒ|jdt
|jdƒƒ|jdt
|jdƒƒ|jdt
|jdƒƒ|jd|j	dkƒ|jt|j
|tdƒƒ|jt|j|ƒ|j|jƒ|jƒktƒ|j|jƒ|jƒktƒdS(NiiRRRRt(Rt
ciphertextR.R/R0R1R2R
R3RthasattrtassertRaisest	TypeErrortsigntbtdecryptRtTruetFalse(RRR5((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyR½s("c
Cs#t|jƒ}|j|fƒ}|j|tdƒƒ\}|jt|ƒt|ƒƒtjƒj	t
|ƒdƒ}|j||ƒ}|j|fƒ}|j||ƒ}|jt|ƒt|ƒƒ|j
|tdƒƒ}	|jt|ƒf|	ƒ|jd|j|t|ƒfƒƒdS(NR4i(RR5R;tencryptR:R.RRR!R"tlentblindtunblindR9Rtverify(
RRR5t	plaintexttnew_ciphertext2tblinding_factort
blinded_ctextt
blinded_ptexttunblinded_plaintextt
signature2((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyRßscCsGt|jƒ}|j|tdƒƒ\}|j|t|ƒfƒdS(NR4(RRCR>R:RBR(RRRCRD((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyRúscCsYt|jƒ}t|jƒ}|j|tdƒƒ\}|jt|ƒt|ƒƒdS(NR4(RRCR5R>R:R.R(RRRCR5RD((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyR%sc	CsÁt|jƒ}t|jƒ}|j|fƒ}|jt|ƒt|ƒƒtjƒjt	|ƒdƒ}|j
||ƒ}|j|fƒ}|j||ƒ}|jt|ƒt|ƒƒdS(Ni(RRCR5R;R.RRR!R"R?R@RA(	RRRCR5t
new_plaintextRERFRGRH((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyR(scCsutt|jƒƒ}t|jƒ}|f}|jd|j||ƒƒ|df}|jd|j||ƒƒdS(NiR4(RRRCR5R.RB(RRt	signaturetmessagetttt2((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyR&s	cCsMtt|jƒƒ}t|jƒ}|j|f|j|tdƒƒƒdS(NR4(RRRCR5R.R9R:(RRRKRL((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyR)(s(t__name__t
__module__RCR5RRRRR R#R'R*R+R,R-RRRRR%R(R&R)(((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyR&s*														"						tRSAFastMathTestcBsPeZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z	RS(cCs&tj|ƒtjdtƒ|_dS(Nt
use_fast_math(RRRtRSAImplementationR<R(R((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyR0s
cCstj|ƒdS(s9RSA (_fastmath implementation) generated key (1 argument)N(RR (R((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyR 4scCstj|ƒdS(s:RSA (_fastmath implementation) generated key (2 arguments)N(RR#(R((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyR#8scCstj|ƒdS(s8RSA (_fastmath implementation) constructed key (2-tuple)N(RR'(R((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyR'<scCstj|ƒdS(s8RSA (_fastmath implementation) constructed key (3-tuple)N(RR*(R((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyR*@scCstj|ƒdS(s8RSA (_fastmath implementation) constructed key (4-tuple)N(RR+(R((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyR+DscCstj|ƒdS(s8RSA (_fastmath implementation) constructed key (5-tuple)N(RR,(R((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyR,HscCstj|ƒdS(s8RSA (_fastmath implementation) constructed key (6-tuple)N(RR-(R((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyR-Ls(
RORPRR R#R'R*R+R,R-(((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyRQ/s							tRSASlowMathTestcBsPeZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z	RS(cCs&tj|ƒtjdtƒ|_dS(NRR(RRRRSR=R(R((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyRQs
cCstj|ƒdS(s9RSA (_slowmath implementation) generated key (1 argument)N(RR (R((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyR UscCstj|ƒdS(s:RSA (_slowmath implementation) generated key (2 arguments)N(RR#(R((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyR#YscCstj|ƒdS(s8RSA (_slowmath implementation) constructed key (2-tuple)N(RR'(R((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyR']scCstj|ƒdS(s8RSA (_slowmath implementation) constructed key (3-tuple)N(RR*(R((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyR*ascCstj|ƒdS(s8RSA (_slowmath implementation) constructed key (4-tuple)N(RR+(R((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyR+escCstj|ƒdS(s8RSA (_slowmath implementation) constructed key (5-tuple)N(RR,(R((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyR,iscCstj|ƒdS(s8RSA (_slowmath implementation) constructed key (6-tuple)N(RR-(R((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyR-ms(
RORPRR R#R'R*R+R,R-(((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyRTPs							cCsòg}|ttƒ7}y$ddlm}|ttƒ7}Wn¡tk
rÝddlm}ddl}t	j
jt	j
jt	j
j
|j|jƒƒƒƒd|dƒƒ}t	j
j|ƒrÞtddd|ƒ‚qÞnX|ttƒ7}|S(	Niÿÿÿÿ(t	_fastmath(tget_config_vars/../../PublicKey/_fastmathtSOs-While the _fastmath module exists, importing s<it failed. This may point to the gmp or mpir shared library s.not being in the path. _fastmath was found at (RRR	RURQtImportErrortdistutils.sysconfigRVtinspecttostpathtnormpathtdirnametabspathtgetfiletcurrentframetexistsRT(tconfigttestsRURVRZt_fm_path((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyt	get_testsrs
	>t__main__cCstjtƒƒS(N(tunittestt	TestSuiteRf(((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyt<lambda>†stdefaultTesttsuite(t__doc__t__revision__tsysR[tversion_infotCrypto.Util.py21compattCrypto.Util.py3compatRhtCrypto.SelfTest.st_commonRRRtTestCaseRRQRTRfRORltmain(((sF/usr/lib/python2.7/dist-packages/Crypto/SelfTest/PublicKey/test_RSA.pyt<module>s &

ÿ
!"