Soreing / des-cpp-encrypt

Simple DES encryption library for C++
3 stars 0 forks source link

Implementation does not work! #1

Open mcfoi opened 1 week ago

mcfoi commented 1 week ago

Running the test code delivers wrong results. Basically whatever is passed as plain text, the same cipher is returned. The cipher changes only on changing the roundKeys.

Soreing commented 1 week ago

I'm really sorry this small university project I made 5 years ago and uploaded 3 years ago and haven't touched since is not to your satisfaction. I took some time out of my morning before my 9-5 work that usually has nothing to do with cryptography to brush up on DES and what the hell I was coding half a decade ago, so please bear with me.

Isn't the point of DES and other symmetric key encryption to return the same cipher for the same plain text using the same key? If you want a different cipher text for the same key, you can implement other modes of operation like CBC or CFB to add a random IV to your plain text, or to feed your cipher text into the next encryption block. This package does 1 block of encryption/decryption.

I'm wondering how the key would even be managed to produce different cipher texts when you run DES parallelly on multiple blocks at the same time (ECB).

mcfoi commented 1 week ago

I'm really sorry this small university project I made 5 years ago .. First let me thank you for your prompt reply: I exactly know the feeling of going back to code lost in memory! My goal was to take an 8-chars array (ASCII), encode it then decode it leveraging DES symmetric encryption strategy. This is why I tested your small library. I first tried the integration with my code but things were not working as expected. So i run the code in: https://github.com/Soreing/des-cpp-encrypt/blob/main/src/Source.cpp that should take the input "TestData", encryipt it the decrypt it back to "TestData". The problem is this does not occurr: the 'original' deciphered is a weird mix of unprintable chars. I am new to C++ and so I cannot help much with the internals of your tool as I do not know much even of criptography (I just know what is required to to use it). I am testing it using Linux with a C++ v.17 compiler optimised for 'aarm64' as the code is running in a Raspberry Pi5. I thought this was not an issue but. What do you think? Can you still run the code successfully?