harbor run -t LiteCoder/verify-aes-openssl-cryptoharbor download LiteCoder/verify-aes-openssl-cryptoUse OpenSSL command-line tools to set up a cryptographic verification scenario, then verify the integrity and authenticity of an AES-encrypted file before decrypting it.
/app/appCreate the following files to simulate a co-worker sending you an encrypted file with authentication:
RSA key pair for the co-worker:
/app/coworker_priv.pem — RSA 2048-bit private key (PEM format, unencrypted)/app/coworker_pub.pem — corresponding RSA public key (PEM format)Original plaintext file:
/app/important_data.txt — a text file containing exactly: CONFIDENTIAL: Project Atlas launch date is 2025-09-15AES encryption of the plaintext:
/app/important_data.txt using AES-256-CBC with the following fixed key and IV (hex-encoded):
0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdefabcdef0123456789abcdef0123456789/app/important_data.encHMAC for integrity verification:
/app/important_data.enc using the HMAC key string shared-secret-key-2025/app/important_data.hmacRSA signature for authenticity verification:
/app/important_data.enc using the co-worker's private key with SHA-256/app/important_data.sigVerify HMAC integrity:
/app/important_data.enc using the same key shared-secret-key-2025/app/important_data.hmacVerify RSA signature authenticity:
/app/important_data.sig against /app/important_data.enc using /app/coworker_pub.pemDecrypt the file:
/app/important_data.enc using AES-256-CBC with the same key and IV from Step 1/app/decrypted_output.txtWrite a JSON report to /app/verification_report.json with the following exact structure:
{
"hmac_verification": "PASS" or "FAIL",
"signature_verification": "PASS" or "FAIL",
"decryption_successful": true or false,
"decrypted_content_match": true or false,
"original_plaintext": "<content of important_data.txt>",
"decrypted_plaintext": "<content of decrypted_output.txt>"
}
hmac_verification: "PASS" if the recomputed HMAC matches the stored one, "FAIL" otherwise.signature_verification: "PASS" if the RSA signature verification succeeds, "FAIL" otherwise.decryption_successful: true if decryption produced output without error, false otherwise.decrypted_content_match: true if decrypted output exactly matches the original plaintext, false otherwise.| File | Description |
|---|---|
/app/coworker_priv.pem |
RSA 2048 private key (PEM) |
/app/coworker_pub.pem |
RSA 2048 public key (PEM) |
/app/important_data.txt |
Original plaintext |
/app/important_data.enc |
AES-256-CBC encrypted file |
/app/important_data.hmac |
Hex-encoded HMAC-SHA256 digest |
/app/important_data.sig |
Binary RSA-SHA256 signature |
/app/decrypted_output.txt |
Decrypted plaintext |
/app/verification_report.json |
JSON verification report |