## 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).

 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.
 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.)
 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.

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

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

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...:)

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

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

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

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

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

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

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

thanks with regards,
sneha

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

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

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

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

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

16. Hi soumya sure i will help

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

thanks a lot...

18. Hi Ba,

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

19. 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

20. 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

21. 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

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

23. 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

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... i shall be very thankful to u..
email id is sasikumar.j@pantechmail.com

25. 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

26. 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....

27. hai,um doind project on ns2.
i ned rsa code on ns2 asap....

my email_id:kranthi1056@gmail.com

28. 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

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

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

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

32. 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

33. hi please send me the code for RSA in ns2 thanks in advance

34. 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

35. Could you please mail this code at manisha_mehta_in@yahoo.com
Manisha.

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

Thanks & regards

Vijaya

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

quinto0827 [at] hotmail dot com.

Thanks!

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

Thanks

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

Many thank for you help

40. 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

41. hello!

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

my email is phothar.99@gmail.com

regards,
pho

42. Sir,

43. hi sir..
i need source code of RSA in ns2.

44. hi sir,

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

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

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

47. 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

1. This comment has been removed by the author.

48. hi my friend
can i have your RSA code in NS2 ?
i need it for my research
malaysia.timche@gmail.com

49. 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

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

51. 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

52. 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

53. 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 ?

Would be really kind of you thanks

54. 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

55. sir i recieved ur mail.. i need 64 bit.. i want to implement it on aodv..

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

57. This comment has been removed by the author.

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

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

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

61. 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

62. 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

opal

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

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

64. Sir kindly send me RSA-1024 code .ASAP.. it need it for my research work...
my email id ... star1star123456@gmail.com

65. 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

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

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

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

69. Ekta Gupta

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

70. Sir,
I need tcl code for rsa algorithm'

71. 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

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

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

74. 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

75. 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

76. 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

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

thanx

1. Hi nandan

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

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

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

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

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

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

82. 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

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

84. Hey could I have the code for the RSA algo please

85. HI

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

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

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