0
$\begingroup$

I am doing protection for my software, which involves storing a part of the crucial algorithm inside a smart-card based dongle. I will supply the input to the dongle, and I will expect the output of the dongle to be correct. If it's not then I know something is wrong.

The idea is that

  1. First a random key is generated
  2. Then I will encrypt my input using this random key, with ECB/CBC algorithm ( to be determined)
  3. Then I will store both the key and the encrypted input in a random, much larger input stream. The position and the size of the key and encrypted input are indicated in the first two bytes of the input stream.
  4. Once the input stream is passed to the dongle, the dongle will read out the key and the encrypted input and do necessary decryption, and then do the computation, and the output passed out.
  5. The output will be encrypted again with the same (passed-in random) key, before passed out of the dongle.
  6. The software side will then check the received output and decrypt accordingly.

Due to the nature of the protection, the hacker can only know the input/output stream to/from the dongle. He can't know what I do in the software, so he won't be able to tell what is the random key, and the encrypted input, and also the position and the size of the key and encrypted input.

I am thinking whether to use ECB/CBC for encryption algorithm. I am aware that ECB is less secure in general because if you encrypt two messages which has two blocks of plaintexts in common, then with ECB mode the corresponding ciphertext blocks will be the same. But in my case, even if my raw input is the same, what the hacker sees looks quite random because

  1. The key is random
  2. Both the key and the encrypted input are stored in random input streams.
  3. The actual, meaningful unencrypted input size is quite small compared to the random input streams that the hacker has accessed to, less than 64 bytes ( 8 blocks). So there isn't too much of same text for the hacker to guess ( not sure about this point)

Also, both of the ECB/CBC contains only one secret key, and the only way how CBC "improves" over ECB is that it applies a random initial vector on the inputs, but I think this "improvement" can be nullified by random key/much bigger random input stream, no?

So I wonder whether CBC really improves over ECB in this case, and whether is there any need to use CBC or not.

$\endgroup$
  • 1
    $\begingroup$ Security by obscurity does not work. I suspect after seeing a few messages the scheme would be discovered. Sure it could be made better but the flaw is that once discovered all security is lost. $\endgroup$ – zaph Jul 18 '17 at 3:18
  • $\begingroup$ @zaph, what do you mean? Isn't all encryption algorithm all security by obscurity in essence? $\endgroup$ – Graviton Jul 18 '17 at 3:20
  • 1
    $\begingroup$ @zaph, then would you like to explain further on this via an answer ( and not comment)? $\endgroup$ – Graviton Jul 18 '17 at 3:34
  • 2
    $\begingroup$ @zaph, both of the ECB/CBC contains only one secret key, and the only way how CBC "improves" over ECB is that it applies a random initial vector on the texts, but I think this "improvement" can be nullified by random key/much bigger random input stream, no? $\endgroup$ – Graviton Jul 18 '17 at 3:39
  • 1
    $\begingroup$ @zaph, In that case, even if you can figure out the key, so? The key is changing every time. And at the software end, I will check to see whether the key is the one that I recently generated and passed into the dongle ( and not something that was generated many days ago on attacker's machine). $\endgroup$ – Graviton Jul 18 '17 at 4:11
1
$\begingroup$

After observing many transactions the ECB will likely break. The random data is not likely to repeat. Any repeating cipher blocks will be from the data revealing both the location in cipher stream and the fact the matching plain text was the same in both messages. Encrypting only the small message with CBC and a random IV will be faster and more secure.

$\endgroup$
  • $\begingroup$ When the hacker doesn't even know where the truly meaningful message starts and stops in a stream of random bytes, how can he tell how to even start comparing for the same block of bytes? $\endgroup$ – Graviton Jul 18 '17 at 7:25
  • $\begingroup$ If I capture many such messages, I look for repeating cipher blocks between messages. The repeating cipher blocks will be from the message not from the random data. $\endgroup$ – Meir Maor Jul 18 '17 at 11:39
  • $\begingroup$ @MeirMaor Note the OP states explicitly in a comment:"key is random every time". The only thing that is not random is the index to the encrypted data. $\endgroup$ – zaph Jul 18 '17 at 12:22
  • $\begingroup$ @zaph I indeed missed that, upon a second reading it makes no sense, if the key is random every time and provided and there is no pre shared secret or certificate or such then there is indeed no difference between ECB and CBC because there is no security at all and anyone can decrypt or forge anything. $\endgroup$ – Meir Maor Jul 18 '17 at 12:56
  • $\begingroup$ @MeirMaor I agree, I just don't have the cryptology knowledge to make that statement. But the overall problem is that there is an index to the message, in a known position and is not random so there is really no creditable security. $\endgroup$ – zaph Jul 18 '17 at 13:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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