之前也做过不少RSA加密的题型,所以我根据集合的划分,将RSA加密题型进行分类,尽我所能的将题型分类成如下图所示,我会根据我的分类进行学习。目前还没分类完成,只能说边学边分类吧(此图会不定期跟新与完善)。这个分类的构建有参考这本国外书籍:《Cryptanalysis of RSA and Its Variants (M. Jason Hinek)》
from Crypto.Util.number import * from Crypto.Util.Padding import * from Crypto.Cipher import AES from hashlib import sha256 from random import * from secret import flag
p,q,r = getPrime(256),getPrime(256),getPrime(256) n = p*q*r phi = (p-1)*(q-1)*(r-1)
key = sha256(str(p+q+r).encode()).digest() enc = AES.new(key, AES.MODE_ECB) c = enc.encrypt(pad(flag,16))
''' n = 343127312894441264623060100705188723106648253383902349620699412384677995734576572885137280031507308915752070128528949423639735964709160841591038148069185325450544546735392923674211031016035209702254447128968565740534765322198664691 hint = 3802744632475774666777934738986183209966233570124815804333822490240409933768208822899072601181527365734196352249978937639454658680559993507805820991037544059215540360338084909833242583087617315128513337647913472696515770688338805196215328080662137260951972365100322795737835152857750114216709340410268143017180826135339564387228460663261697814425298725805568817218360964967025967384766127098203664964210047103829182895016532403825215903779806760754721373523135367007867453212189953817229696304611549977864533229540971457717668560698088917340909962348110683581294453903261530189579223087858081200349343639420534779115290433982968345085704202494045885911950427043282588446343291558819683037970053828479057449781943479407877748772895179095205885377333120540311815022381056 c = b';#\x1b\xa6R\xe2\x1d\x9dpf\x8e\xda\xe4\x14\x9a\xfb\tr\x99\x8a\xc9r\x03C\xb58Zb\x97\x0b\xc7S\x0fa\x88\xb4\xe4\x16.M\x92\x94\x94\x8b\xa9Ki\x9b\xe4\xe9d5\xa3~\x1a\x9cx\x03\xdc\x1f\x87\x14E\x90' '''
from Cryptodome.Util.number import long_to_bytes, getPrime, bytes_to_long
m = b"Blitz{REDACTED}"
p = getPrime(150) q = getPrime(150) e = getPrime(128) n = p*q mod_phi = (p-1)*(q-1)*(e-1) d = pow(e, -1, mod_phi) print(mod_phi) print(n) c = pow(bytes_to_long(m), e, n) print(c) print(p) """ mod_phi = 381679521901481226602014060495892168161810654344421566396411258375972593287031851626446898065545609421743932153327689119440405912 n = 1236102848705753437579242450812782858653671889829265508760569425093229541662967763302228061 c = 337624956533508120294617117960499986227311117648449203609049153277315646351029821010820258 """