0
\$\begingroup\$

I've programmed an 8051 microcontroller to send data out through an external transmitter (just a few bytes per transmission). I'm looking to encrypt this data in my microcontroller's program.

I have a 96-bit long key that I'd like to use (ideally) which is known by the transmitter's and receiver's uC.

I’m interested in knowing if there’s any simple encryption technique/library source code in C that you know of and would recommend for this purpose.

\$\endgroup\$
10
  • \$\begingroup\$ Why the key has to be exactly 96-bit long, if you are asking for something simple, why not 8-bit long? \$\endgroup\$ Commented Jan 7, 2021 at 20:39
  • 2
    \$\begingroup\$ I don't know the answer, but what is the threat against which you need protection? Balancing how much an attacker is willing to pay to crack your system vs. how much you or your client are willing to pay to protect the data is important. An 8051-based system might or might not have enough RAM and enough CPU cycles to do the job depending on how you answer those questions. \$\endgroup\$ Commented Jan 7, 2021 at 20:40
  • \$\begingroup\$ Exactly, it really depends on your threat model. What are you trying to protect? Are you worried about the secrecy of the data being transmitted? Or about its integrity? Or authenticity? What if I record your encrypted communication and replay it pretending I am the transmitter? \$\endgroup\$
    – Eugene Sh.
    Commented Jan 7, 2021 at 20:44
  • 1
    \$\begingroup\$ @J_And I've written custom commercial encryption and the SHA-256 hash function on the 8051 core for clients in Europe. They were experts, as they already had existing products. Just not fast enough nor small enough. I achieved many times the speed they wanted achieved and in much smaller space. But it took "sit-down" time and a thorough knowledge of the tasks as well as the core I was working with to get there. No libraries, but asm. The 8051 is a difficult target. Their prior failed attempts and eventual search for an 8051 expert with adequate math is evidence yours isn't an easy goal. \$\endgroup\$
    – jonk
    Commented Jan 7, 2021 at 20:53
  • 1
    \$\begingroup\$ What will happen if I manage to make a counterfeit receiver who is able interpret this data? \$\endgroup\$
    – Eugene Sh.
    Commented Jan 7, 2021 at 21:10

1 Answer 1

0
\$\begingroup\$

You can use simple XOR encryption, and I suppose if you had to use your 96 bit key you can rotate the register every next byte until you get to your last byte of the 96 bits, then you start again, and then on the receiver side just XOR it again to get the correct input. A changing XOR key every byte provides some small protection against brute-forcing the common key if an attacker tries to brute force multiple bytes, as they wont have the same XOR byte counterpart it will be much harder to crack. XOR encryption is very lightweight but its not the best, though with an 8051 it should be somewhat quick to compute and transmit.

There may be other libraries which rely on more complex encryption, although on an 8 bit MCU it's not going to be particularly fast and if you are just worried about having this info protected, then a rolling XOR key should be fine for use with the 8051 unless you have someone who's trying to target your system and break the encryption (which, if they build a program to do so, with a modern GPU it will be very quick to capture the transmitted bytes and brute force every single one (assuming a byte would be recognisable once decrypted) and recover your initial 96 bit key.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.