Get a Pentest and security assessment of your IT network.

Cyber Security

Protecting Encrypted Data in Public Storage

TL;DR

To ensure encrypted data integrity when stored publicly (e.g., cloud storage), use a strong hashing algorithm (like SHA-256) to create a unique fingerprint of the file before encryption. Store this hash securely alongside the encrypted file, but separately. When you need to verify the data, re-hash the downloaded file and compare it to the stored hash. Any mismatch means tampering.

How to Ensure Encrypted Data Integrity in Public Storage

  1. Choose a Strong Hashing Algorithm: A hashing algorithm creates a fixed-size ‘fingerprint’ of your data. If even one bit changes, the hash will be completely different. SHA-256 is a good choice; it’s widely used and considered secure.
    • Avoid MD5 or SHA-1: These are older algorithms with known vulnerabilities and shouldn’t be used for security purposes.
  2. Hash the File Before Encryption: Before you encrypt your file, calculate its hash value.
    sha256sum myfile.txt

    This command will output a long string of characters – this is your hash.

  3. Securely Store the Hash: This is crucial! Don’t store the hash in the same location as the encrypted file, or with the same provider if possible. Consider these options:
    • Separate Cloud Storage Provider: Use a different cloud service to store only the hash value.
    • Local Secure Storage: Store it on an offline device (USB drive, external hard drive) kept in a secure location.
    • Trusted Third Party: A trusted friend or family member could hold the hash for you.
  4. Encrypt Your File: Use a robust encryption method (e.g., AES-256) with a strong, randomly generated password/key.
    openssl aes-256-cbc -salt -in myfile.txt -out myfile.enc

    You will be prompted for a password.

  5. Upload the Encrypted File and Hash: Upload both the encrypted file to your public storage location and the hash value to its secure storage location.
  6. Verification Process (When Downloading): This is how you check if the data has been tampered with.
    1. Download the Encrypted File: Retrieve the encrypted file from public storage.
    2. Decrypt the File: Decrypt the downloaded file using your password/key.
      openssl aes-256-cbc -d -salt -in myfile.enc -out myfile_decrypted.txt
    3. Re-Hash the Decrypted File: Calculate the SHA-256 hash of the decrypted file.
      sha256sum myfile_decrypted.txt
    4. Compare Hashes: Compare the newly calculated hash with the securely stored original hash value.
      • If the hashes match: The file is intact and hasn’t been altered.
      • If the hashes don’t match: The file has been tampered with or corrupted. Do not use it! Investigate the cause (potential security breach, storage issues).
  7. Consider Using a File Integrity Checker: Tools like `AIDE` or `Tripwire` can automate this process. They create a baseline hash of your files and alert you to any changes.
  8. Regularly Re-Verify: Don’t just verify once. Regularly re-verify the integrity of your data, especially if it’s critical.

By following these steps, you significantly improve the security and reliability of your encrypted data stored in a public place.

Related posts
Cyber Security

Zip Codes & PII: Are They Personal Data?

Cyber Security

Zero-Day Vulnerabilities: User Defence Guide

Cyber Security

Zero Knowledge Voting with Trusted Server

Cyber Security

ZeroNet: 51% Attack Risks & Mitigation