Monday, September 20, 2010

RSA algorithm in Ns2

RSA This algorithm is used in cryptography Technique in that RSA is added along with it. These are procedures followed



Key generation

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.
* For security purposes, the integers p and q should be chosen uniformly at random and should be of similar bit-length. Prime integers can be efficiently found using a primality test.
2. Compute n = pq.
* n is used as the modulus for both the public and private keys
3. Compute φ(pq) = (p − 1)(q − 1). (φ is Euler's totient function).
4. Choose an integer e such that 1 < e < φ(pq), and e and φ(pq) share no divisors other than 1 (i.e., e and φ(pq) are coprime).
* e is released as the public key exponent.
* e having a short bit-length and small Hamming weight results in more efficient encryption. However, small values of e (such as e = 3) have been shown to be less secure in some settings.[4]
5. Determine d (using modular arithmetic) which satisfies the congruence relation d e \equiv 1\pmod{\varphi(pq)}.
* Stated differently, ed − 1 can be evenly divided by the totient (p − 1)(q − 1).
* This is often computed using the extended Euclidean algorithm.
* 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.

Note:

* An alternative, used by PKCS#1, is to choose d matching e d ≡ 1 (mod λ) with λ = lcm(p-1,q-1), where lcm is the least common multiple. Using λ instead of φ(n) allows more choices for d. λ can also be defined using the Carmichael function λ(n).
* For efficiency the following values may be precomputed and stored as part of the private key:
o p and q: the primes from the key generation,
o d\mod (p - 1) and d\mod(q - 1),
o q^{-1} \mod(p).

[edit] Encryption

Alice transmits her public key (n,e) to Bob and keeps the private key secret. Bob then wishes to send message M to Alice.

He first turns M into an integer 0 < m < n by using an agreed-upon reversible protocol known as a padding scheme. He then computes the ciphertext c corresponding to:

c = m^e\,\bmod\,n

This can be done quickly using the method of exponentiation by squaring. Bob then transmits c to Alice.
[edit] Decryption

Alice can recover m from c by using her private key exponent d by the following computation:

m = c^d\,\bmod{\,n}.

Given m, she can recover the original message M by reversing the padding scheme.

(In practice, there are more efficient methods of calculating cd using the pre computed values above.)
[edit] A worked example

Here is an example of RSA encryption and decryption. The parameters used here are artificially small, but one can also use OpenSSL to generate and examine a real keypair.

1. Choose two prime numbers

p = 61 and q = 53 Make sure that these prime numbers are distinct.

2. Compute n = pq

n=61\cdot53=3233

3. Compute the totients of product. For primes the totient is maximal and equals the prime minus one. Therefore \varphi(pq) = (p-1)(q-1) \,

\varphi(61\cdot53) = (61 - 1)\cdot(53 - 1) = 3120\,

4. Choose any number e > 1 that is coprime to 3120. Choosing a prime number for e leaves you with a single check: that e is not a divisor of 3120.

e = 17

5. Compute d such that d e \equiv 1\pmod{\varphi(pq)}\, e.g., by computing the modular multiplicative inverse of e modulo \varphi(pq)\,:

d = 2753
since 17 · 2753 = 46801 and 46801 mod 3120 = 1, this is the correct answer.
(iterating finds (15 times 3120)+1 divided by 17 is 2753, an integer, whereas other values in place of 15 do not produce an integer. The extended euclidean algorithm finds the solution to Bézout's identity of 3120x2 + 17x-367=1, and -367 mod 3120 is 2753)

The public key is (n = 3233, e = 17). For a padded message m the encryption function is m^{17} \mod {3233} or abstractly:

c = m^e\mod {n}

The private key is (n = 3233, d = 2753). The decryption function is c^{2753} \mod {3233} or in its general form:

m = c^d\mod {n}

For instance, in order to encrypt m = 65, we calculate

c = 2790 = 65^{17}\mod {3233}

To decrypt c = 2790, we tap

m = 65 = 2790^{2753}\mod {3233}.

Both of these calculations can be computed efficiently using the square-and-multiply algorithm for modular exponentiation. In real life situations the primes selected would be much larger; in our example it would be relatively trivial to factor n, 3233, obtained from the freely available public key back to the primes p and q. Given e, also from the public key, we could then compute d and so acquire the private key.

These Procedures implemented in TCL coding to run in NS2 .For codings and queries please send the mail to admin.

90 comments:

  1. Hi could you provide me the code for RSA in ns-2 it would be very helpful for my research work thanks email is shivprakasht@gmail.com

    ReplyDelete
  2. Hi could you provide me the code for RSA in ns-2 it would be very helpful for my research work thanks email is yahiatene.y@gmail.com

    Thank you very much

    ReplyDelete
  3. Hi could you provide me the code for RSA in ns-2 it would be very helpful for my research work thanks email is prakash20031990@gmail.com

    thank u...:)

    ReplyDelete
  4. Dear friend i want RSA algorithm in Ns2 for my research work...can u help me
    my id: sunda.pass@gmail.com

    ReplyDelete
  5. Hi could you provide me the code for RSA in ns-2 it would be very helpful for my research work thanks email is
    rsmanian1946@gmail.com

    ReplyDelete
  6. hello, can you provide ns2 coding for this algorithm..
    i would be really thankfull
    rahuldagar89@gmail.com

    ReplyDelete
  7. hello!could u pls send me the code for this RSA algo in ns-2?it will really be very helpful in doing my thesis work... i shall be very thankful to u..
    email id is
    sneha_mnc24@yahoo.co.in
    thanks with regards
    sneha

    ReplyDelete
  8. hello!could u pls send me the code for this RSA algo in ns-2?it will really be very helpful in doing my thesis work... i shall be very thankful to u..
    email id is
    sneha_mnc24@yahoo.co.in
    thanks with regards
    sneha

    ReplyDelete
  9. Hi sure no probs pls can explain any criteria in that iam having in TCl

    ReplyDelete
  10. ok..u can send me in tcl..i have to run it on ns-2..

    thanks with regards,
    sneha

    ReplyDelete
  11. Please send me the .tcl file to my email id shiva1533@gmail.com

    ReplyDelete
  12. Pleas send the .tcl file.its very useful to learn ns2 for me.so send me the file to my mail id shiva1533@gmail.com

    ReplyDelete
  13. can u pls mail the tcl and the c coding?? it will be very helpful...
    mail id: barvind89@gmail.com

    ReplyDelete
  14. hi can u send me the tcl coding for rsa algorithm i need it for my project purpose...thanks..here is my mail id praveent08@yahoo.co.in

    ReplyDelete
  15. hi. i too need the tcl fime for th same. can u pls forwarrd it to me as well.
    thanks in advance. my email id is - a23_soumya2004@yahoo.co.in

    ReplyDelete
  16. hi, could you please give me the ns2 coding for rsa?
    authemax_07@yahoo.com

    thanks a lot...

    ReplyDelete
  17. Hi Ba,

    Sure helps you Kindly say which RSA needed and give me the full requirements, RSA advanced versions had been reveled. Thanks

    ReplyDelete
  18. hi,
    I need to do encryption/Dec. in AODV protocol. do u hav the code,pls send me at reena_dubey_2006@yahoo.co.in i'l be very thankful to u

    ReplyDelete
  19. Hi, could you provide me the code for RSA in ns-2 it would be very helpful for my training
    thanks
    email is ahlam.awala@utt.fr

    ReplyDelete
  20. Hi, could you provide me the code for RSA in ns-2 it would be very helpful for my research
    thanks
    email is maram_mhmd@yahoo.com

    ReplyDelete
  21. i really need a help i cannot develop the RSA algorithm in the tcl file can you please send them for me??

    ReplyDelete
  22. Hi, could you provide me the code for RSA in ns-2 it would be very helpful for my research
    thanks
    email is iefazaid@gmail.com

    ReplyDelete
  23. hello!could u pls send me the code for this RSA algo in ns-2?it will really be very helpful in doing my thesis work... i shall be very thankful to u..
    email id is sasikumar.j@pantechmail.com

    ReplyDelete
  24. hello!could u pls send me the code for this RSA algo in ns-2?it will really be very helpful in doing my thesis work
    mail id-matu76556@gmail.com

    ReplyDelete
  25. hi... i am willing to develop a security based project in ns2.... so,snd me the RSA based tcl code...my mail id is sasikumar.j@pantechmail.com....
    thanks in advance......

    ReplyDelete
  26. hai,um doind project on ns2.
    i ned rsa code on ns2 asap....
    thank u in advance

    my email_id:kranthi1056@gmail.com

    ReplyDelete
  27. Hi could you provide me the code for RSA in ns-2 it would be very helpful for my research work thanks email is rasj.tamu@gmail.com

    ReplyDelete
  28. Hi can you please send me the code for RSA in ns2.

    please mail to elshuba12@gmail.com

    ReplyDelete
  29. hi..I'am doing a project in ns2. so, could u pls send me the code for this RSA algo in ns-2.
    thanks in advance....
    my_email : rajitha.danushka88@gmail.com

    ReplyDelete
  30. Hi can you please send me the code for RSA in ns2.

    please mail to nikhil.mawandia@gmail.com

    ReplyDelete
  31. Hi i'm doing a project based on security in networks so could you please send me the code for RSA in ns2 thanks in advance
    please mail it to gss2756@gmail.com

    ReplyDelete
  32. hi please send me the code for RSA in ns2 thanks in advance
    please mail to karthiky87@gmail.com

    ReplyDelete
  33. Dear sir,
    code is ok. But how to use the code and what are the changes are needed in this implementation
    thanks and regards,
    M.Alex

    ReplyDelete
  34. Could you please mail this code at manisha_mehta_in@yahoo.com
    Thanks in advance,
    Manisha.

    ReplyDelete
  35. Hi Could you please mail the code of RSA algo in ns-2 to vijaychandra.manai@gmail.com

    Thanks & regards

    Vijaya

    ReplyDelete
  36. Could you please send me a copy of the NS2 RSA code?

    quinto0827 [at] hotmail dot com.

    Thanks!

    ReplyDelete
  37. please send me a copy of the NS2 RSA code!
    ntekriwal@gmail.com

    Thanks

    ReplyDelete
  38. Could you please mail RSA code in ns-2 to supasj@gmail.com

    Many thank for you help

    ReplyDelete
  39. Hi i'm doing a project based on security in networks so could you please send me the code for RSA in ns2 thanks in advance
    please mail it to ravindra.mehta3@gmail.com

    ReplyDelete
  40. hello!

    could you please send me the code for this RSA algo in ns-2?

    my email is phothar.99@gmail.com

    thanks in advance
    regards,
    pho

    ReplyDelete
  41. Sir,
    I need RSA algorithm implementation in NS2.. Please help me.. mail ID: saran.satvi@gmail.com

    Thanx in advance.

    ReplyDelete
  42. hi sir..
    i need source code of RSA in ns2.
    please help me sir. my id is ramucevvell@gmail.com
    thanks in advance

    ReplyDelete
  43. hi sir,

    i need source code of RSA in ns2 can u plz mail me rajeshcodes@gmail.com

    ReplyDelete
  44. Hi sir,
    Thanks for ur post, can u plz mail me the code for the RSA. my mail id is kathirselvam91@gmail.com

    ReplyDelete
  45. hi plz send me the codes..
    id:smriti2101@gmail.com

    ReplyDelete
  46. Hi could you provide me the code for RSA in ns-2 it would be very helpful for my research work thanks email is kalyanipolagani@gmail.com

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
  47. hi my friend
    can i have your RSA code in NS2 ?
    i need it for my research
    thank you in advance
    malaysia.timche@gmail.com

    ReplyDelete
  48. Hi i'm doing a project based on location proof updating system in WSN so could you please send me the code for RSA in ns2 thanks in advance
    please mail it to lp8394@gmail.com

    ReplyDelete
  49. Hi friend
    i m trying to perform RSA algorithm in ns2 ..kindly send me the tcl code ..
    email : parthi_29@rocketmail.com
    thank u in advance

    ReplyDelete
  50. hi,
    im working on rsa algorithm implementation in ns2.it would be great if u cn help me by sending the tcl code
    thank you.
    manasagunda18@gmail.com

    ReplyDelete
  51. Hello sir!I am working on this RSA algorithm for my M.E project,Kindly send me the TCL code for RSA algorithm.
    My mail Id:art_18king@yahoo.co.in

    ReplyDelete
  52. Hi!

    We want to simulate wireless sensor network in ns-2 with RSA as authentication protocol in nodes and BS. can you give us some idea how to simulate such network and run rsa ?

    Kindly email me with your reply asap at muhammadwaqararshad@gmail.com

    Would be really kind of you thanks

    ReplyDelete
  53. hi..
    im working on RSA algorithm in ns2.
    could u plz send me the code for the same..
    Ill be really thankful if u do that..
    My mail id is emailme.mahak@gmail.com

    ReplyDelete
  54. sir i recieved ur mail.. i need 64 bit.. i want to implement it on aodv..
    thanks for the help..plz reply

    ReplyDelete
  55. i want RSA coding please send me my mail id is charanyaraman@gmail.com

    ReplyDelete
  56. This comment has been removed by the author.

    ReplyDelete
  57. a very good article...keep up the good work. Just sent an email requesting for the code. Thanks in advance.

    ReplyDelete
  58. can you provide the code.. article is fine.. good to follow

    ReplyDelete
  59. Hello sir,
    i m trying to perform RSA algorithm in ns2 ..kindly send me the tcl code ..
    email : geetha.balu25@gmail.com
    thank u in advance

    ReplyDelete
  60. sir, i am trying to do key generation using ECC for security in wireless sensor networks. kindly send me the tcl code.
    email: ramyacse1993@gmail.com

    ReplyDelete
  61. dear sir,
    I am planning to implement RSA in ns2 for my project. It would really useful, if you could send me the code. thanks and sorry for troubling you.

    my mail id reachgopal87@gmail.com

    regadrs,g
    opal

    ReplyDelete
  62. hai,
    could you please send me tcl code for rsa and digital signatures to rosebud.yalini@gmail.com

    ReplyDelete
    Replies
    1. Hi

      Sure i can help you in RSA algorithm just mail me your requirement like how much key bit needed, any detection or prevention is needed so that can help in it Thanks

      Delete
  63. Sir kindly send me RSA-1024 code .ASAP.. it need it for my research work...
    my email id ... star1star123456@gmail.com
    Thanks in advance...

    ReplyDelete
  64. Hello sir..
    kindly send me RSA 512 bit digital signature ...ns-2 implementaion code ,,, this is going to very much help for me..
    my email is,,,ashishpokiya010@gmail.com

    ReplyDelete
  65. need complete coding in ns2 with configuaration of rsa encyrption plz send me kindly urgent email id is contact_to_mehta@yahoo.co.in

    ReplyDelete
  66. i need of rsa encrption coding in ns2 . please send to me .email id is sundar93mitian@gmail.com

    ReplyDelete
  67. Hello sir,
    i m trying to perform RSA algorithm in ns2 ..kindly send me the tcl code ..my mail id:menavinyadav@gmail.com

    ReplyDelete
  68. Ekta Gupta

    Sir,
    pls send me rsa.tcl file in ns2 on my mail
    id: er.ekta1015@gmail.com

    ReplyDelete
  69. Sir,
    I need tcl code for rsa algorithm'
    my mail id:soniadevi37@gmail.com

    ReplyDelete
  70. Hi could you provide me the code for RSA in ns-2 it would be very helpful for my research work thanks email is contact_to_mehta@yahoo.co.in

    ReplyDelete
  71. hello Sir kindly provide me this code..... mail me to rasagna.nov21@gmail.com

    ReplyDelete
  72. hai sir,
    please send me tha rsa tcl code. it is very helpful for my ME project. sooryasanthi@gmail.com

    ReplyDelete
  73. Hi,
    please provide me the code for RSA in ns2.It would be helpful for my main project work.Please mail to sarika24786@gmail.com

    Thanks & Regards
    Sarika

    ReplyDelete
  74. i could you provide me the code for RSA in ns-2 it would be very helpful for my research work thanks email is justinnagy19@gmail.com

    ReplyDelete
  75. Hi,
    I want DES algorithm code in ns2 ,I couldn't understand how to apply any algorithm in ns2 also how to attach with our .tcl file, please explain me,,,
    E_mail:- saylihivarkar@yahoo.in

    ReplyDelete
  76. I requried RSA and Des algo. code in NS2 (tcl file) . If ant body have than please send me at gauttam2008@gmail.com


    thanx

    ReplyDelete
    Replies
    1. Hi nandan

      Hope you got required information if still help needed please let me know thanks

      Delete
  77. Hi can you please send me the code for RSA in ns2.
    My mail id: ramanmoorthy4@gmail.com

    ReplyDelete
  78. I requried RSA and Des algo. code in NS2 (tcl file) . If anybody have than please send me at anuj0072002@gmail.com

    ReplyDelete
  79. hi, can you send me the code..vry urgent pls
    my email revient.ode@gmail.com
    thanks

    ReplyDelete
    Replies
    1. HI Revient

      Thanks for comment can you please share me the details like key size 128 or 64 bit so that code can be shared thanks

      Delete
  80. HI please provide me the RSA code. please send it to me at ersimranpreet1@gmail.com

    ReplyDelete
  81. HI Sandhya

    Yes sure will send the mail pls can you share me the base paper and other details will send the code and let me know the key bit size and other stuff in detail in mail thanks

    ReplyDelete
  82. Hey could I have the code for the RSA algo please

    ReplyDelete
  83. Hey could I have the code for the RSA algo please

    ReplyDelete
  84. HI

    Please confirm the key bit and how do you want in tcl or c++

    ReplyDelete
  85. can u pls mail the tcl and the c coding?? it will be very helpful...
    mail id: islam_zakaria2010@yahoo.com

    ReplyDelete

Thanks for using my blog any queries or help please email to clickprasan@gmail.com . Please be careful from spammers .do not reply to any other email address other than mentioned above