diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2016-03-05 08:55:05 -0500 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2016-03-05 08:55:05 -0500 |
commit | d7f37267f4d70b60f9dc5dc316a10a1501337bd3 (patch) | |
tree | 40f72b8c3242b4a855662ab71a530f42e568d8d0 /tests/hazmat/primitives/test_rsa.py | |
parent | 6960600f111de1710b01cc4f4ffc6c023d742cd7 (diff) | |
download | cryptography-d7f37267f4d70b60f9dc5dc316a10a1501337bd3.tar.gz cryptography-d7f37267f4d70b60f9dc5dc316a10a1501337bd3.tar.bz2 cryptography-d7f37267f4d70b60f9dc5dc316a10a1501337bd3.zip |
Added a failing test case for #2760
Diffstat (limited to 'tests/hazmat/primitives/test_rsa.py')
-rw-r--r-- | tests/hazmat/primitives/test_rsa.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/hazmat/primitives/test_rsa.py b/tests/hazmat/primitives/test_rsa.py index c0b8923f..6c4265bd 100644 --- a/tests/hazmat/primitives/test_rsa.py +++ b/tests/hazmat/primitives/test_rsa.py @@ -1257,6 +1257,42 @@ class TestRSADecryption(object): ) ) + @pytest.mark.supported( + only_if=lambda backend: backend.rsa_padding_supported( + padding.OAEP( + mgf=padding.MGF1(algorithm=hashes.SHA1()), + algorithm=hashes.SHA1(), + label=None + ) + ), + skip_message="Does not support OAEP." + ) + def test_invalid_oaep_decryption_modulus_too_large(self, backend): + key = RSAPrivateNumbers( + d=7522768467449591813737881904131688860626637897199391200040629864101874645050262848439547140898692921835389468376945746692330793695514230944510136695957295685934620097463421483677974955529909313614750246672441810743580455199636293179539903480635309128671611293197689633441128717521312450413418112101148855052900544439791989985647496408006333689573840587007410739977038877364695937023906368630297588990131009278072614118207348356464024413418928507020253448851737157735951023683346469818907551606930852978160632858140395181782496281129084666492455457325791532385553960363601827996980725025898649392004494256400884092073L, + dmp1=58478726141129357477396440553174294059739423362064600174933949737607778799766591021036792892472774720417920838206576785118888962405896293970295017580707334365938615623229419730049164710295084140505919593448123474244764980765326827985983252300690925827594762920534235575029199380552228825468180187156871965973L, + dmq1=29495362591612393020811558750684052388578010010540834077048798210876832264504685327766351157044892283801611558399025326793413163800193445448986443756565173983251170215146125726716969166119923984590062007086268151533045913908558077497697689781529854112656599931724820610358669306523835327459478374630794532167L, + iqmp=73311809898189315354589160535402528304848567032089826755352844613815808798190559315018094080936347757336989616401164752221810115652989806704492349938646016705540599864636601183801844136789476942581901723777161540093050820913412158663260617211803836418654472188816187630316821692982783286322262994892003058782L, + p=146000772385188369561757353315557474658786384338271531491986524341089561874297260028407173173104313784839210589468358962527109559207437158778332364464259678946305487699031865937075508861661292545384245805554654024060158573120656164789233691658300236417641065810401988452597662468695292210846023806693330210819L, + q=143389776586788917840288341061017783650340259777525008746201846179529334331195279454478403366163571367369350693776197822272822380830300262175671282877680573202309319960687756231128996976485532095399369019984626945109504492235380960237861693881175139009062798733435914868413033924905615003019941713387610804439L, + public_numbers=RSAPublicNumbers( + e=65537, + n=20935018133810781261016542095587197148997365939225329132783981291025246650219069057247668831128562123920421213971120738894916485198425314369866701853203961247095422391824214597698660070512257608763052522979695072216646806472125849091613870675600690206613647104980763715789012856059203994171727507973375478284872956619063172518373594403145623708992812017818755252164948324059900324007435286018928595207897012755480107417637549958370325484930999313293126801371507050727851420786491494462121457416211678637799045637596481777173037111061210024726290855040978545615750569441900451152778245269283276012328748538414051025541 + ) + ).private_key(backend) + + ciphertext = b'\xb1ph\xc0\x0b\x1a|\xe6\xda\xea\xb5\xd7%\x94\x07\xf96\xfb\x96\x11\x9b\xdc4\xea.-\x91\x80\x13S\x94\x04m\xe9\xc5/F\x1b\x9b:\\\x1d\x04\x16ML\xae\xb32J\x01yuA\xbb\x83\x1c\x8f\xf6\xa5\xdbp\xcd\nx\xc7\xf6\x15\xb2/\xdcH\xae\xe7\x13\x13by\r4t\x99\x0fc\x1f\xc1\x1c\xb1\xdd\xc5\x08\xd1\xee\xa1XQ\xb8H@L5v\xc3\xaf\xf2\r\x97\xed\xaa\xe7\xf1\xd4xai\xd3\x83\xd9\xaa9\xbfx\xe1\x87F \x01\xffL\xccv}ae\xb3\xfa\xf2B\xb8\xf9\x04H\x94\x85\xcb\x86\xbb\\ghx!W31\xc7;t\na_E\xc2\x16\xb0;\xa1\x18\t\x1b\xe1\xdb\x80>)\x15\xc6\x12\xcb\xeeg`\x8b\x9b\x1b\x05y4\xb0\x84M6\xcd\xa1\x827o\xfd\x96\xbaZ#\x8d\xae\x01\xc9\xf2\xb6\xde\x89{8&eQ\x1e8\x03\x01#?\xb66\\\xad.\xe9\xfa!\x95 c{\xcaz\xe0*\tP\r\x91\x9a)B\xb5\xadN\xf4$\x83\t\xb5u\xab\x19\x99' + + with pytest.raises(ValueError): + key.decrypt( + ciphertext, + padding.OAEP( + algorithm=hashes.SHA1(), + mgf=padding.MGF1(hashes.SHA1()), + label=None + ) + ) + def test_unsupported_oaep_mgf(self, backend): private_key = RSA_KEY_512.private_key(backend) with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_MGF): |