I've got a code base which stores some sensitive data in the database. Before I store the data in the DB I encrypt the data using this Crypto library (docs here).
To decrypt it I use the following
use \Defuse\Crypto\Crypto;
use \Defuse\Crypto\Exception as Ex;
// The following is inside a class, but for clarity I only copy pasted this part
try {
return Crypto::decrypt($aStr, Crypt::$cryptoKey);
} catch (Ex\InvalidCiphertextException $ex) { // VERY IMPORTANT
// Either:
// 1. The ciphertext was modified by the attacker,
// 2. The key is wrong, or
// 3. $ciphertext is not a valid ciphertext or was corrupted.
// Assume the worst.
die('The ciphertext has been tampered with! Message:'.$ex->getMessage());
}
// I've got some more catch blocks here but they're not relevant for this question
This code works great, but today I stumbled upon one database record which makes the whole thing die on this InvalidCiphertextException
catch. I've manually tried it with some sample code, but I always get the InvalidCiphertextException
.
I presume the data is corrupt, but I'm not sure whether that is the case.
The record is in the middle of a table with 15000 records which are all fine and there have been no sudden changes to that part of the code for ages.
Is there any more I can do to investigate (or even decrypt) this? Or is there any more info I can find about this record or a way to debug this further?
All tips are welcome!
Firebase Cloud Functions: PubSub, "res.on is not a function"
TypeError: Cannot read properties of undefined (reading 'createMessageComponentCollector')
I am using mysql_real_escape_string on my code and the data on the form is:
I have been trying to create an update function for my database and have been stuck for days on this now so thought that I would ask for helpThe code seems to run without issues and no errors are being reported but it isn't being updated
I share encrypted data with an external providerThe provider gives me the algo where the input string needs to be padded with blanks into 16byte blocks, i