0

A string has 9 characters split in 3 groups of 3 chars each, [(x,x,x),(x,x,x),(x,x,x)].

The text is encrypted using secret-key cryptography and the function that encrypts is a simple function that does XOR with an unknown key. We know that they secret-key is of length 3. For each group (x1,x2,x3) each value is XOR with the corresponded value (y1,y2,y3) of secret-key.

Edit: Forgot to mention that characters are limited to a range of [a,b,c,d,e,f,g,h].

I want to calculate how many times should I try in order to find the correct key to decipher the string. I am interested more in the process of finding it rather than the answer because this is a question for learning purpose.

My solution idea consists as below:

The key is of length 3, -,-,-. Each of the positions can take 8 possible values, and since there is not any condition that does not allow me to have a key of all same values eg: aaa or bbb, etc the number of combinations is $8^3=512$. To try deciphering the string I would need to test each group, so $3\,groups \, times\,512 = 1536$ is the total number of tries.

Does it make any sense I am messing up something?

Sachihiro
  • 119

1 Answers1

0

If You have a plain string and it's encrypted counterpart, the answer is 0 since $x\oplus y=z\Rightarrow x\oplus z=y$.

If You don't have the plain string, but You can encrypt another, it's 1 since $0\oplus y=y$.

Otherwise frequency analysis or an average of $\frac{1+2^n}{2}$ different guesses are required, where $n$ is the number of bits in the key.

Ymh
  • 304
  • Can you check my post again, I made some changes. – Sachihiro Apr 04 '20 at 21:20
  • You correctly identified that there are $8^3$ combinations, but You didn't specify how the test is performed. How will You know that a single group is correct? In a password scenario the authority will only say the entire string is correct, so You will each time do 3 calculations, but only one test. – Ymh Apr 04 '20 at 22:11
  • It is a little bit different than the real life scenario that the whole password would be evaluated. How it is evaluated is that each of these 3 groups is evaluated at one time, then the next group then the last, so, because of this i think i have to multiply the $8^3 * 3!$ where 3! is the amount of combinations for 3 groups and one of them is correct combination. – Sachihiro Apr 04 '20 at 22:17
  • I understood that it's the same 3-character key used on each group. If there are 3 keys, but group 1 is always encrypted with key 1, we just have a single 9-length key for a 9-length password. $3!$ is a permutation, You're making it out to be a random assignment of 3 keys to 3 groups, is that it? – Ymh Apr 04 '20 at 22:38
  • It is the same character that is used in each group, but there is no way to know that the previous group was decoded with the correct key, therefore I have to think of all possible permutations and one of the is correct. – Sachihiro Apr 04 '20 at 22:44