Looking for Serpent cipher

Hi,

Does anyone is able to implement the Serpent encryption parameter in Rust, I search for a very long time!

Serpent official page: https://www.cl.cam.ac.uk/~rja14/serpent.html

Best regards

You could just grab the Python version of the reference implementation of Serpent and and start transcribing it to Rust. Looks fairly straight forward. A nice exercise for a rainy weekend:

https://www.cl.cam.ac.uk/~fms27/serpent/
https://www.cl.cam.ac.uk/~fms27/serpent/serpent.py.html

1 Like

It's a good idea yeah, unfortunately I don't have the level in rust for now, but its a good entry point yes

I blame the original poster for this - I've ported the reference C implementation to Rust and it seems to successfully process all of a test vector subset.

I went for C and the submission PDF instead of Python as the Python code was a bit too naive for my tastes, like how it represents bitstrings as sequences of textual zeroes and ones.

If you want to give it a go, I've published it as https://crates.io/crates/serpent-cipher and I cannot warn you enough, this isn't meant to be a production-grade implementation with sane memory/time characteristics. See it more as an escape hatch if you have some legacy junk you need to work with.

As ZiCog says, it's a fun exercise to implement something like this, but I wouldn't pick Serpent as a first choice. The submission paper can't quite decide if it wants to describe the normal implementation or their optimized bitslice implementation, which makes some sections more ambigious than one would like.

1 Like

Wow, well done zao. That was a bit more work than a rainy weekend!

I have had experience of implementing old military ciphers from their specifications. One of the most maddening things. The specifications can be ambiguous and difficult to follow, one has no idea how the algorithm works anyway, the expected test results are just random noise, so there is no way to verify parts of your solution as you go along.

In one case my implementation did not inter-operate with a device from another manufacturer, I found they had a bug in their message padding. I was glad to find it was not just me that found this hard!

1 Like

Wow incredible, a friend already try to implement Serpent in Rust, so if it works we will have two implementations, one from C and other from Python, it can be cool to compare it!