Go Down

Topic: Implementing Pairing Based Crypto on arduino uno (Read 455 times) previous topic - next topic

Coding Badly

Program storage is unlikely to be the issue...
Probably should at least glance at the on-disk size of the two libraries before claiming "unlikely".   ;)


simsam

So, check if the code fits by looking at it. Does it assign any large buffers? How big are they?

Program storage is unlikely to be the issue, so you don't need to know how may bytes the program itself takes, just its SRAM storage while it's running.
Yes it does assign large buffers, there is a large string i was provided which is used in generating the private key, around 400 character long.

Should i switch boards to arduino due instead? Or someone other board.

I dont have much knowledge regarding this so i need some help in deciding.
As mentioned in the earlier comments a 32 bit processor is required so i looked up DUE

MorganS

Probably should at least glance at the on-disk size of the two libraries before claiming "unlikely".   ;)


What does that tell you about a large crypto library that the Arduino side only needs to compile and link a few functions to do the 'signing'' side of the transaction?  You may as well look at the size of the math.h library on disk and claim that won't fit on an Arduino.

Simsam: the internal storage of the core cryptography is probably many times larger than the key. It will teach you a lot by going through the code to find out what functions it actually uses and what storage they use. It is entirely possible that it assigns static buffers for the decryption routines that you aren't even going to use on the Arduino.
"The problem is in the code you didn't post."

Coding Badly

#18
May 18, 2018, 01:50 am Last Edit: May 18, 2018, 01:50 am by Coding Badly
What does that tell you about a large crypto library that the Arduino side only needs to compile and link a few functions to do the 'signing'' side of the transaction?
A few functions.  How quaint.

Quote
You may as well look at the size of the math.h library on disk and claim that won't fit on an Arduino.
When elliptic curve functions have been added to "math.h" let me know.  Until then that is a false analogy.

But, there is no point discussing hypothetical with you when there is a trivial practical path to follow...

I have implemented Digital Signature using PBC  and GMP libraries.( I have taken the code from the PBC library as liked above.)My code works correctly when i compile it on Visual Studios 2010.
Post the MAP file.  Armed with that it will be possible to assess the size processor.


simsam

A few functions.  How quaint.


Post the MAP file.  Armed with that it will be possible to assess the size processor.

I have attached the map file.

MarkT

#20
May 18, 2018, 01:37 pm Last Edit: May 18, 2018, 01:37 pm by MarkT
Sorry i think i didnt use the correct word, i should have used technique instead of requirement.
Though what you're saying is absolutely correct, the thing is that my supervisor has told me to use PBC here, i cant use an alternative.


Yes i understand that asymmetric crypto is more heavy weight, is there no way to implement this at all? What if i were to change from UNO to MEGA? Even that wouldnt suffice?
No, its ~ 10000 times slower than stock computer hardware, its an 8-bit microcontroller.

We are talking 3 to 5 orders of magnitude difference in performance, basically, between a
small micricontroller and a general purpose processor, considering memory, speed or transistor count.

For a small microcontroller an efficient block-cipher based MAC is feasible, asymmetric crypto systems are not.

Even on the Due or similar with 32 bit architecture you'll find the performance is dissappointingly slow, and
typically you'd only use asymmetric crypto to set up a secure channel using standard symmetric crypto, so that the heavyweight step only
has to happen once (or perhaps once per day or similar).  I recommend reading "Cryptography Engineering: Design Principles and Practical Applications" by Ferguson/Schneier/Kohno.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

simsam

No, its ~ 10000 times slower than stock computer hardware, its an 8-bit microcontroller.


For a small microcontroller an efficient block-cipher based MAC is feasible, asymmetric crypto systems are not.

Even on the Due or similar with 32 bit architecture you'll find the performance is dissappointingly slow, and
typically you'd only use asymmetric crypto to set up a secure channel using standard symmetric crypto, so that the heavyweight step only
has to happen once (or perhaps once per day or similar).  I recommend reading "Cryptography Engineering: Design Principles and Practical Applications" by Ferguson/Schneier/Kohno.

Thank you for your detailed answer. I will discuss this with my supervisor.
So the conclusion being that running an asymmetric crypto (PBC) will not be possible on any arduino board. I will have to move to something else.
Thank you again for your help.

gfvalvo

#22
May 18, 2018, 02:43 pm Last Edit: May 18, 2018, 03:19 pm by gfvalvo
So the conclusion being that running an asymmetric crypto (PBC) will not be possible on any arduino board.
If you're really interested, I'd say get a Teensy 3.6 (32-Bit ARM Cortex-M4, 180/360 MHz, 256 KB RAM, 1 MB Program Space) and give it a try. It will set you back all of $30.

simsam

If you're really interested, I'd say get a Teensy 3.6 (32-Bit ARM Cortex-M4, 180/360 MHz, 256 KB RAM, 1 MB Program Space) and give it a try. It will set you back all of $30.
Alright i will give that a try as well, using a digital signature is a key factor in the project i am given. So anything that'll make it work i'm up for it.
Thank you for helping me out.

Coding Badly

I have attached the map file.
sha.obj is the only module bound to the executable: 1953 bytes (Pentium class processor).  There are at least three SHA implementations for AVR processors so it is not too surprising that something named "sha" would be small enough to fit in an Uno's memory.  The rest (memory management, pbc, and floating-point) is dynamically linked.

The program uses structured exceptions which will be troublesome in the best case and non-existent in the worst case.  I believe the libraries are "pure C" in which case structured exceptions can be easily managed / avoided.


simsam


The program uses structured exceptions which will be troublesome in the best case and non-existent in the worst case.  I believe the libraries are "pure C" in which case structured exceptions can be easily managed / avoided.


Yes the libraries are pure C, could be please elaborate a little that what do you mean by structured exceptions.

When the code was compiles visual micro, there were a lot of errors regarding the cmath library, none of its functions were being recognized.

Should i also attach the code?

Coding Badly

#26
May 19, 2018, 10:28 pm Last Edit: May 19, 2018, 10:30 pm by Coding Badly
Yes the libraries are pure C, could be please elaborate a little that what do you mean by structured exceptions.
try ... catch

In your case that gets broadened to include Microsoft extensions...
https://www.google.com/search?q=c%2B%2B+structured+exception+handling


Coding Badly

#27
May 19, 2018, 10:37 pm Last Edit: May 19, 2018, 10:38 pm by Coding Badly
Should i also attach the code?
I suggest you create a test program that builds for an Arduino using stubs for the PBC calls.  Then get that to build and run correctly on a PC.  Doing that will eliminate most / all of the PC specific junk (like basic_string) and give you a starting point for building something that works correctly on an Arduino.


Go Up