Last night, i was coding RSA Public Key Cipher for PIC18F4550 microcontroller till 1.30 AM🙂 , phew . Actually, this is out of my plan. I am supposed to finisih coding Anubis and RC5 cipher but i suddenly wondering how RSA works in microcontroller Hmm… ❓ . See, sometimes commiting plan is hard to me, i better work spontaneously. Yeah, regularity will bored me in a few nanoseconds. But nothing useless, RSA is a powerfull cipher compared to others. This cipher was invented by the threesome cool and damn genius Guys : Ron Rivest, Adi Shamir, and Leonard Adleman. Despite of its high security, RSA algorithm runs sluggy slow on PIC18F4550. For higher keylength, it also hogs PIC18F4550 data memory. I could not imagine what if code it on PIC16F84 or PIC16F877, Hmm👿 . For sure, i’ll code RSA cipher for PIC16F84 and PIC16F877, too see how slow it could be .
I’ve tested the code against several test vecor and it shows exactly the same result. That was a nice news to hear. For example 887 mod 187 will result 11. I believe that this code is compatible with the RSA specification. However this is a free open source software that comes with no guarantee, so take your own risk if yiu wish to use this code.
In addition, i divided the RSA implementation into 7 version. Each version has its own characteristics listed below.
- Version 1.x for 32-bit RSA implementation
- Version 2.x for 64-bit RSA implementation
- Version 3.x for 128-bit RSA implementation
- Version 4.x for 256-bit RSA implementation
- Version 5.x for 512-bit RSA implementation
- Version 6.x for 1024-bit RSA implementation
- Version 7.x for 2048-bit RSA implementation
See this screenshots below. First boxed row denote RSA input, second boxed row denote exponentiaion constant, third boxed row denote mod operation constant and fourth boxed row denote the result of RSA algorithm.
So far, the code only contains the core of RSA cipher, it has no capability of doing key scheduling i.e. key generating. I’ll code and upgrade all of that version gradually, so keep visiting this blog and please mail me your suggestion or even question.