Check if XXTEA decrypted successfully

834 Views Asked by At

I am using XXTEA in javascript and all is working, but I want to be able to have an error check for the password - so I need to determine if the decryption of arbitrary text was successful or not.

Currently, the only solution I can think of, which is not ideal, is to start the text with a token during encryption, and check if it is there after decryption - but this is not ideal. Is there another way?

1

There are 1 best solutions below

5
Maarten Bodewes On

You could use a KBKDF such as HKDF or one of the NIST defined KBKDFs right after you performed you PBKDF such as PBKDF2. Then you could use a specific information field to generate a key to compare with a known, stored key and another information field to generate the key used for encryption. You may want to add some kind of integrity control as well.

This may sound like abracadabra to you, in that case first look up the relevant terms, e.g. on Wikipedia...