Cryptography (like Diffie Helman )

Please add any feature requests for Flowcode version 7 here

Moderator: Benj

Post Reply
MJU
Posts: 502
Joined: Wed Nov 07, 2007 6:51 pm
Location: Antwerp Belgium
Has thanked: 121 times
Been thanked: 108 times
Contact:

Cryptography (like Diffie Helman )

Post by MJU »

Isn't it possible to make a encryption macro to secure the communication between two devices?

I found the math for the Diffie Helman crypto, and it doesn't look like it's wont work on a microcontroller.
More than this, there are examples for Arduino to use this.
Look at this: https://github.com/DevMomo/Diffie-Hellman-Arduino

Maybe something to use in Flowcode?
Maybe a "master" and "slaves" macro?
The master will generate the prime number and shares it with the slaves?

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Cryptography (like Diffie Helman )

Post by Benj »

Yes this is certainly possible. I'll add it to the list and investigate how much work it would be to add in.

Seems to be a form of PGP Public Private Key, I've studied this and know how it works but am a little rusty on the subject. PGP was developed by a programmer under contract and when he realised what he had, he released it for free to the public as open source. He went to jail for it because it was the IP of the company who employed him. Thanks to this public availability we now have things like digitally secure signatures and advanced WIFI network protection.

I've got quite far in making a component, everything apart from the setup and loop code.
Enc_Diffie_Hellman.fcfx
(12.32 KiB) Downloaded 326 times
However the example code use the randomSeed function which is not available for PIC devices. It seems pretty important as it is called multiple times. Maybe it's just a way of adding extra randomness? But I wonder if it is somehow syncing the random values from tx and rx?

Code: Select all

//reseed the random number generator with the shared secret key k
randomSeed(k);
randomSeed() initializes the pseudo-random number generator, causing it to start at an arbitrary point in its random sequence. This sequence, while very long, and random, is always the same.
Yes there seems to be a sync going on there.

Hmmm...

I can make it work for AVR no problem but PICs and other targets may have problems.

MJU
Posts: 502
Joined: Wed Nov 07, 2007 6:51 pm
Location: Antwerp Belgium
Has thanked: 121 times
Been thanked: 108 times
Contact:

Re: Cryptography (like Diffie Helman )

Post by MJU »

Looks good BenJ :-)

I'm watching this like a cow watches a passing train.
For now I don't understand whats going on, but on the other hand, I never said I'm smart :-)

Thanks for your efforts.
Hope to have a working macro in the future.

HKPhysicist
Posts: 4
Joined: Tue Apr 07, 2020 6:49 pm
Contact:

Re: Cryptography (like Diffie Helman )

Post by HKPhysicist »

PIC24F128GA204 has a built-in hardware AES encryption. It may generate random seed.

Just copy to it and see what can happen. :mrgreen:

Post Reply