I have logs containing sensitive data (mail addresses, usernames etc.) that need not only be made GDPR compliant, but in general be secured as best as possible, so anonymization/hashing would be an easy solution. However, at the same time I need to be able to correlate the information for monitoring purposes (e.g. identifying attacks). For that, the plaintext values are not relevant, but I need the pseudonymized hashes to be equal for the same plaintext source (determinism). As I cannot store the data in plaintext, but only in pseudonymized fashion, I also need to be able to decrypt the values if necessary . As there might be multiple data sources that need to be decrypted individually (rarely would all at once be needed), my initial idea would be to use a plain old public/private key approach using RSA, which I know from my SSH day-to-day: Encrypt the values using a pub key per source, store the private keys in a safe. However, RSA introduces randomness to the hashes, which makes sense from a security standpoint, but ruins my "must be able to correlate" deterministic requirement.
Any ideas on a good solution? Is there a similar algorithm that I can use that is not too easy to bruteforce, but can use the public/private key approach? Am I missing other weakspots in e.g. attempting to use raw RSA without randomized padding?
In terms of operations: The risk is a lot higher that an attacker might access a large number of hashes than that he gain access to the public key, which already is highly secured. The biggest identified risk (still very unlikey) is that an attacker might be able to inject his own data at the source of the pipeline to be processed/encrypted and then view the hashes, allowing him to compare plaintext and hashes ( = guessing the hashes). Encryption speed does not need to be very high, and decryption speed is even less important.
If relevant, the actual implementation will need to be done using Python.