Answer the question
In order to leave comments, you need to log in
Checking the correctness of the key for AES decryption
It seems to me that I am cycling and missed something, but how to implement a key check for AES that it is correct before decrypting the data, for example, the user specified an incorrect password. So far, as an idea to store:
password_crypt = AES.encrypt("True Secret Passphrase", "True Secret Passphrase")
"User Secret Passphrase" === AES.decrypt(password_crypt, "User Secret Passphrase") ? "мастер пароль правильный" : "мастер пароль введен некорректно"
Answer the question
In order to leave comments, you need to log in
Storing any magic numbers that are decrypted and compared is a significant reduction in cryptographic strength. A good solution is to store the crc block. The entire data block + crc is encrypted. For verification, a complete decryption with the provided key takes place, crc is removed and compared. If the crc match, the key was correct.
Then this is a completely legitimate method. We will still have to get the key and at least something, but decrypt it. See how TrueCrypt does it - before decrypting the entire disk, it checks that the volume header has been decrypted, and it is of a known format. If the conditions of the problem do not allow adding a known check string to the header to the plaintext data at the input, then it will have to be stored separately.
You can also store the key check value, but these are the same eggs - KCV is a truncated key hash from the key on the key :)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question