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
- First a random key is generated
- Then I will encrypt my input using this random key, with ECB/CBC algorithm ( to be determined)
- 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.
- 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.
- The output will be encrypted again with the same (passed-in random) key, before passed out of the dongle.
- 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
- The key is random
- Both the key and the encrypted input are stored in random input streams.
- 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.