1
vote
$\begingroup$

Is there any tool available that can test whether a simple substitution cipher is working. I will put my scenario in detail. Lets say I built a simple substitution cipher that maps 8 bit data to 16 bit encrypted cipher using an 8 bit key. I need to verify whether the substitution cipher is actually unique for all possible permutations of 8 bit data and 8 bit keys with my algorithm.

Before you guys eat me alive with 'You think you can build a superior cipher?' questions, this is not a high security application but a simple app where sending plain data is not preferred. Existing ciphers like columnar transposition and caesar cipher were not an option considering user experience and ease of implementation. You can assume it is just simple XOR.

I just want to verify whether the substitution is happening correctly or not. If I need to manually write a program that can verify this, can anyone give me a brief detail about how I should start?

$\endgroup$

locked by e-sushi Mar 12 '17 at 11:43

This question exists because it has historical significance, but it is not considered a good, on-topic question for this site so please do not use it as evidence that you can ask similar questions here. This question and its answers are frozen and cannot be changed. See the help center for guidance on writing a good question.

Read more about locked posts here.

2
votes
$\begingroup$

Regarding the test of unicity

You could just script the test in Python (or any other language, really). The language in which you already implemented your cipher might be a good choice otherwise.

Then, given the size you are talking about (256 possibilities of 16bits = 4Ko), you can basically just generate all the results in a 256-array, and check the unicity of each element in your array.

Regarding your cipher

I've got a pretty hard time figuring the security level of your application. With a basic substitution over basically each character (8bit), your ciphertext is extremely vulnerable even with not-so-long messages, and especially if your data/protocol/application has any kind of predictable headers and such. It's not clear which kind of threat you want to protect the data from.

$\endgroup$
  • $\begingroup$ I am operating at bit level. So when I say 8 bit, the data is actually 8 bit. Not a readable character. It is OK if the an intruder reads data. My job is just to make it a little harder . And since I am implementing this in a micro controller, ease of encryption is also important. $\endgroup$ – nightgaunt Nov 7 '14 at 12:10
  • $\begingroup$ As per your suggestion, to test the possibilities, I just need to store the output in an array and for every permutation, I need to search this array to check whether the code already exists. right? $\endgroup$ – nightgaunt Nov 7 '14 at 12:13
  • $\begingroup$ Yes exactly, for each 8bit possible value from 0x00 to 0xFF, encrypt it, check if not equal to any previously computed value, and add it to your already-calculated list. $\endgroup$ – Dillinur Nov 7 '14 at 12:15
  • $\begingroup$ Just asking. If the data and key bits are more, should I use the same technique? Or is there any shortcut available? $\endgroup$ – nightgaunt Nov 7 '14 at 12:27
  • $\begingroup$ Well you could always use a bloom filter if you're constricted by memory, but you'll need to code way more than the 5-10 lines of the naive solution. $\endgroup$ – Dillinur Nov 7 '14 at 13:28

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