80-bit data type control in C

I am implementing some cryptographic algorithm in C that includes an 80 bit key. A particular operation includes a rotation shifting the key x number of bits.

I tried a long double type, which, if I'm not mistaken, is 80bit, but this does not work with a bitrate operator.

The only alternative I can come up with is to use an array of 10 char elements with some complex loops and if-else.

My question is whether there is a simple and effective way to do it.

Thanks.

+8
c bit-shift cryptography rotation fpga
source share
2 answers

Sorry, you need the bignum library. Although native C data types support 80-bit floats, they actually don't do what you want.

You can associate something like GMP, or even use less desirable approaches, such as a 10-character array or two numbers long and short (64-bit and 16-bit integers).

Nothing special, but they really work, and if you plan on using this for anything other than a class, GMP is the way to go. Otherwise, you may have a whole mess of time attacks that you could encode, but it can become really nasty, real fast.

+4
source share

Something went wrong here. If I understand you correctly, you are using a soft processor on FPGA.

  • Traditionally, people use FPGAs to create their own shift registers through VHDL / Verilog. Such algorithms are pretty painless to implement and very fast. Back at the university, I did this for a cryptographic project.

  • In addition, the article you mentioned talks about a 128-bit key. Would that be much easier to implement?

+4
source share

All Articles