I'm implementing some cryptographic algorithm in C which involves an 80 bits key. A particular operation involves a rotate shifting the key x number of bits.
I've tried the long double type which if I'm not wrong is 80bits, but that doesn't work with the bitshift operator.
The only alternative I can come up with is to use a 10 element char array with some complicated looping and if-else.
My question is whether there's some simple and efficient way of carrying this out.
Thanks.
There is something a bit messed up here. If I understand you correctly, you are using a "soft" cpu on the FPGA.
Traditionally, people use the FPGA to make their own shift registers through VHDL/Verilog. These kind of algorithms are fairly painless to implement and very fast. Back at the university I did this is for a cryptography project.
Moreover, the paper you mentioned talks about a 128 bit key. This would be significantly easier to implement?
Sadly you need a bignum library. While C native data types have support for 80 bit floats it doesn't actually do what you want.
It is possible to link something like GMP or even use a less desirable approaches like 10 character array or two numbers a long and short (64bit and 16bit integers).
Neither is particularly pretty but they do work and if you're planning on using this for anything but a class, GMP is the way to go. Otherwise you could end up with a whole mess of timing attacks which you could code around but it could get really nasty, real quick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With