Audible icon indicating copy to clipboard operation
Audible copied to clipboard

Multiple fixes for XXTEA encryption/decryption in metadata module

Open seidnerj opened this issue 2 years ago • 0 comments

  1. Use math.ceil instead of ldata when calculating ldata, otherwise encryption could sometimes result in invalid output, decryption could sometimes fail as well.

  2. Use math.floor instead of int in raw_xxtea, mainly for readability and parity with Amazon's xxtea implementation.

  3. Use metadata[9:] instead of metadata.lstrip("ECdITeCs:") when removing the metadata header, otherwise decryption fails when either of the aforementioned letters ("ECdITeCs:") appear as prefix in the metadata string (as lstrip works per letter in the string passed as a parameter, not for the entire string).

  4. Modified order of calculation in decrypt_metadata so it is exactly the reverse of the actions done in encrypt_metadata.

  5. Changed naming of variables in encrypt_metdata and decrypt_metadata so they better reflect their content, as well as keeping consistency in naming between the two aforementioned functions.

seidnerj avatar Sep 22 '22 21:09 seidnerj