Abstract: The security of many public key encryption schemes relied on the intractability of finding the integer factoring

problem such as the RSA scheme. However, there is a great deal of research concerning factoring the RSA modulus. Factoring the modulus is very hard and therefore an efficient and fast algorithm is required to solve this problem. The suggested algorithm aims to obtain the private key by factoring the modulus based the public key of the RSA scheme. This new idea is claimed to be more efficient than the existing algorithms especially when the public key is small, since most public key encryption system use small keys to improve the efficiency of encryption. We have developed a program, with a GUI made in C++ using wxWidgets, to implement the proposed algorithm for cracking the RSA scheme. Existing RSA algorithm: RSA involves a public key and a private key. The public key can be known to everyone and is used for encrypting messages. Messages encrypted with the public key can only be decrypted using the private key. The keys for the RSA algorithm are generated the following way: 1. Choose two distinct prime numbers p and q. o For security purposes, the integers p and q should be chosen at random, and should be of similar bit-length. Prime integers can be efficiently found using a primality test. 2. Compute n = pq. o n is used as the modulus for both the public and private keys 3. Compute φ(n) = (p – 1)(q – 1), where φ is Euler's totient function. 4. Choose an integer e such that 1 < e < φ(n) and gcd(e,φ(n)) = 1, i.e. e and φ(n) are coprime. o e is released as the public key exponent. 5. Determine d = e–1 mod φ(n); i.e. d is the multiplicative inverse of e mod φ(n). o This is often computed using the extended Euclidean algorithm. o d is kept as the private key exponent. The public key consists of the modulus n and the public (or encryption) exponent e. The private key consists of the private (or decryption) exponent d which must be kept secret. Example 1. Choose two distinct prime numbers, such as p = 61 and q = 53. 2. Compute n = pq giving n = 61 · 53 = 3233. 3. Compute the totient of the product as φ(n) = (p − 1)(q − 1) giving φ(3233) = (61 − 1)(53 − 1) = 3120. 4. Choose any number 1 < e < 3120 that is coprime to 3120. Choosing a prime number for e leaves us only to check that e is not a divisor of 3120. Let e = 17. 5. Compute d, the modular multiplicative inverse of d = 2753. yielding

ii. in order to encrypt m = 65. e = 17).q2. Compute k/(d*g) as follows: a.. qi=[1/ri-1] ri=(1/ri-1)-qi if(qi=qi-1) c.q1. m=0 c. m=m+1 c. If i is even c.qi-1. we can break the message.q1. for =1. Using this.2… c. c. Reconstruct f using the expansion q0. 2.qi+1 d. r0=f-q0.iii. we calculate m = 27902753 (mod 3233) = 65. the encryption function is m17 (mod 3233). The private key is (n = 3233. For i=1. we calculate c = 6517 (mod 3233) = 2790. For instance. q0 = [f].n) Compute qi and ri as follows: a. f = (e/n) b. If i is odd e..iv.q1.i.3…m (m is obtained from the above step) b. To decrypt c = 2790. c. Obtain entity A public key (e.iv. Reconstruct f using algorithm 1 using the expansion q0. Compute d=(d*g)/g.The public key is (n = 3233. Proposed attack algorithm 1.…) break 3.2. . For a padded plaintext message m. d = 2753).…qi) So k/(d*g)=(nm/dm) is each iteration 4. For an encrypted ciphertext c. the decryption function is c2753 (mod 3233).1. f=(q0.

Code Gui. const wxPoint &pos. }.cpp" #define DECODE 101 #define ENCODE 102 using namespace std. IMPLEMENT_APP(RSAKiller) class dialog:public wxDialog { public: dialog(const wxString &title. }. .h> #include<iostream> #include<cstring> #include "rsacrack. const wxSize &size). class RSAKiller:public wxApp { public: virtual bool OnInit().cpp: #include<wx/wx.

100)). wxBoxSizer *encodeSizer = new wxBoxSizer(wxVERTICAL).-1. this->Layout().0.pos. void OnQuit(wxCommandEvent &Event). . wxTextCtrl *codeword. const wxSize &size).dialog::dialog(const wxString &title. } class InfoFrame:public wxFrame { public: InfoFrame(const wxString &title. wxStaticText *label_encode=new wxStaticText(this.wxALL.size) { this->SetSizeHints(wxDefaultSize. wxTextCtrl *publickeyfields. void OnAbout(wxCommandEvent &Event).5). wxStaticText *introText. wxPoint(100. -1. const wxSize &size) :wxDialog(NULL. this->SetSizer(encodeSizer). const wxPoint &pos.title. encodeSizer->Add(label_encode.wxDefaultSize). const wxPoint &pos. wxT("Enter ciphertext").

utf8_str()<<endl. sprintf(output.i++) outputstring[i]=output[i].n. ._T("Error")).&cw).%d)"._T("Error")). return.&n)) { wxMessageBox(_T("You must enter public key")."The original plaintext was %d".k).utf8_str().e."Enter Number")==0) { wxMessageBox(_T("You must enter a number"). if(strcmp(codeword->GetValue()."(%d.&e. sscanf(codeword->GetValue().void OnDecode(wxCommandEvent &Event) { //cout<<"Decode pressed"<<endl. /*char *output.cw). return. cout<<codeword->GetValue().utf8_str()<<endl. int k=attack(n.int e.utf8_str(). if(!sscanf(publickeyfields>GetValue().string outputstring. for(int i=0.char_str(). } int cw=0."%d". } cout<<publickeyfields->GetValue().i<strlen(output).

100)._T("Decoded")). wxMessageBox(mystring. InfoFrame::OnDecode) END_EVENT_TABLE() enum { ID_QUIT=1.wxPoint(100.wxFrame) EVT_BUTTON (DECODE._T("Decoded")). //dialog *encode=new dialog(_("Encode"). } DECLARE_EVENT_TABLE() }. */ wxString mystring = wxString::Format(wxT("Plaintext was %i").k). cout<<"("<<e<<".outputstring[i]='\0'. //cout<<"Decoded -> "<<output<<endl. bool RSAKiller::OnInit() { .wxDefaultSize). BEGIN_EVENT_TABLE(InfoFrame. //wxMessageBox(codeword->GetValue()."<<n<<")"<<endl. ID_ABOUT }.

wxEVT_COMMAND_MENU_SELECTED. SetMenuBar(menuBar).InfoFrame *encodeFrame = new InfoFrame(_("RSA Killer v1. SetTopWindow(encodeFrame).0"). CreateStatusBar(). fileMenu->AppendSeparator(). (wxObjectEventFunction) &InfoFrame::OnQuit).0")).-1.. encodeFrame->Connect( ID_QUIT. encodeFrame->Connect(ID_ABOUT.//new wxTextDataObject(this. .wxPoint(10. wxBoxSizer *topsizer = new wxBoxSizer(wxVERTICAL). return true. wxPoint(100.350)). wxEVT_COMMAND_MENU_SELECTED. size) { wxMenuBar *menuBar= new wxMenuBar.20)). //wxTextDataObject *introText= new wxTextDataObject(_("Hi")). } InfoFrame::InfoFrame(const wxString &title. SetStatusText(_("Welcome to RSA Killer v1. wxMenu *fileMenu = new wxMenu. const wxPoint &pos.100). encodeFrame->Show(true). menuBar->Append(fileMenu. fileMenu->Append(ID_QUIT. const wxSize &size) :wxFrame(NULL. (wxObjectEventFunction) &InfoFrame::OnAbout). fileMenu->Append(ID_ABOUT.10). _("&File")).wxSize(20.1."))._("&About._("&Exit")). pos.. title. wxSize(450.wxT("Hi!").

wxID_ANY.wxDefaultPosition. level2Text->Add(new wxStaticText(this. encodeFields->Add(new wxStaticText(this.25)). 1).-1.wxHORIZONTAL).Expand().90). ._T("Enter public key")). wxID_ANY. wxTE_READONLY )._T("Enter number").wxSizerFlags(1). _T("Hi! Welcome to RSA Killer application \ndesigned by Shikhar Kohli and Salil Saxena"))).//. publickeyfields = new wxTextCtrl(this. _T("Encode")).\ wxPoint(10.wxSizerFlags(1).5)). _T("Introduction")). wxBoxSizer *encodeFields= new wxBoxSizer(wxHORIZONTAL). wxSize(140. _T("Simona"). //level2Text->Add(new wxButton(this.Border(wxALL.n)"). publickey->Add(new wxStaticText(this. wxID_ANY.Expand(). wxBoxSizer *level2Text = new wxStaticBoxSizer(new wxStaticBox(this.//wxStaticText *m_readonly = new wxStaticText( this. //Sizer for the intro text and image //level2Text->Add(m_readonly.wxDefaultPosition.-1. //SetSizer(level2Text).Border( wxALL._T("in the form (e.Border(wxALL.wxSize(150. 5)).1).-1. codeword=new wxTextCtrl(this._T("Enter codeword")). wxID_ANY. publickey->Add(publickeyfields). wxBoxSizer *publickey = new wxBoxSizer(wxHORIZONTAL).wxDefaultSize). -1 .wxDefaultCoord). //wxSizerFlags(1).Expand(). //wxBoxSizer *level2Buttons = new wxBoxSizer(wxHORIZONTAL).5)).

} void InfoFrame::OnQuit(wxCommandEvent &WXUNUSED(event)) { Close(true).DECODE. //Uncomment this later if needed //topsizer->SetSizeHints(this).7 )).ENCODE.Border(wxALL._T("Encode")).wxSizerFlags(1).7 )). topsizer->Add(buttons.Border(wxALL.wxSizerFlags().10)).5)). //buttons->Add(new wxButton(this. wxBoxSizer *buttons=new wxBoxSizer(wxHORIZONTAL).Border(wxALL.wxSizerFlags().Expand().Center()).wxSizerFlags().10)). //topsizer->Add(encodeFields).wxSizerFlags(1).Expand().//. } void InfoFrame::OnAbout(wxCommandEvent &WXUNUSED(event)) . topsizer>Add(publickey).Border(wxALL. buttons->Add(new wxButton(this. topsizer->Add(encodeFields).encodeFields>Add(codeword.wxSizerFlags(1)._T("Decode")). SetSizerAndFit(topsizer).Expand(). topsizer>Add(level2Text.Border(wxALL.

push_back(e/n).n=8927. cout<<"Starting . int m=0. int main() { int e=2621. while(1) { //cout<<"In loop ". vector<double> r. //cout<<q[0]<<"__"<<double(e)/double(n)<<endl. . wxOK|wxICON_INFORMATION.cpp: #include<iostream> #include<vector> using namespace std.this). r. vector<int> q.. q. _("About RSA Killer"). } Rsacrack."<<endl.push_back(double(e)/double(n)).{ wxMessageBox(_("RSA Killer by Shikhar Kohli (751/IT/08) & Salil Saxena (749/IT/08)")..

begin().at(r. q.size()-1]<<endl.i!=q.end().0/r.size()-2)) break.size()-1))). } Screenshot: .m+=1.size()-1)).at(q. return 0.at(q.push_back((1. if(q. } for(vector<int>::iterator i=q. cout<<endl. //cout<<q[q.i++) cout<<*i<<" ".at(q.push_back((int)(1.0/r.size()-1)==q. r.size()-1))-q.at(r.


//cout<<c<<endl. x=pow(m. } int attack(int c. return c.int e) { vector<int> q. vector<double> r. int y=e%9.h> using namespace std. . //cout<<x<<endl.i<e-y-9.// RSA attack algorithm as implemented on devcpp #include<iostream> #include<vector> #include<conio.i+=9) c=(c*x)%n. for(int i=0.int n. c=(c*x)%n. long int encrypt(int m.y). //cout<<c<<endl.int e) { long int x=pow(m.int n.9).h> #include<math. long int c=x%n.

} for(int i=0.push_back(((double)e/(double)n)). q.push_back(q[0]*q[1]+1).size()-1]).push_back(1/r[r. nn.dg.vector<int> nn.j++) { nn.size()-1]==q[q.size().push_back(q[j]*nn[j-1]+nn[j-2]). int m=0. q. cout<<q[0]<<"__"<<r[0]<<endl. . //generating q and r vectors while(1) { m+=1.d.dg.size()-1])-q[q.g. dg. r. r. for(int j=2.i<r.push_back(q[j-1]*dg[j-1]+dg[j-2]).size()-1]). cout<<nn[0]<<' '<<dg[0]<<endl. cout<<nn[j-1]<<' '<<dg[j-1]<<endl.j<=m.push_back(1).size()-2]) break. if(q[q.push_back((1/r[r.dg.push_back(q[1]). //generating n and dg vectors nn.i++) cout<<q[i]<<"-->"<<r[i]<<endl.push_back(e/n).push_back(1).

k<dd-2. } int dd. } cout<<dd<<endl. //decryption: final stage of the attack algorithm long int retv=(c*c)%n. cout<<" enter the message along with the public keys ". .k++) { if(g[k]!=0) dd=dg[k]/g[k].} for(int k=0.m.e.k++) retv=(retv*c)%n.k++) { g. cout<<g[k]<<endl. for(int k=0. retv=retv%n.k<m. } int main() { int n. for(int k=0.k<g. return retv.push_back((e*dg[k])%nn[k]).size().

e).cin>>m>>n>>e. } . //the decrypted message cout<<" the retrieved message from the cipher-text is : "<<retv<<endl. getch(). return 0.n. cout<<" The cipher-text is : "<<c<<endl.e).n. int c=encrypt(m. int retv=attack(m.

Sign up to vote on this title
UsefulNot useful