I am trying to use AES as cipher for an application I am building. I am using a JavaScript library (https://code.google.com/p/crypto-js/) to perform encryption and decryption with AES. When I perform decryption, this happens:
AES.decrypt(ct, right_key) == 'message decrypted !' //true
AES.decrypt(ct, wrong_key) == '' //true
The problem is that I am using this decryption in a process in which there shouldn't be any way to determine if the key was right or wrong. I would like something like this to happen:
log(AES.decrypt(msg, wrong_key)) // 'random string fsdijw'
So that the result is 'compliant' to the expected result but it's not the expected result, and there is no way to understand if the key was right or wrong depending on the result of the decryption. I asked my professor and he told me that AES is probably bad implemented in that library, but he didn't understand my problem so clearly.
I wonder if the behavior described in the first snippet of code is expected or actually AES has been bad implemented in that library. If it was expected, is there any other cipher algorithm that doesn't allow to understand if the key was right or wrong from the result of decryption?