FIX: GitHub Actions failures due to encrypted audit logs#15
Merged
Conversation
This commit fixes all GitHub Actions test failures caused by the encryption changes implemented in the previous commit. The tests were trying to grep encrypted binary audit logs, which fails because the data is no longer plain text. Changes: 1. Implement Audit Log Decryption (hsm_enhanced.c): - Add decrypt_audit_entry_helper() function to decrypt individual audit entries - Rewrite handle_list_audit_logs_command() to read encrypted audit logs - Support both encrypted (VHSMAUD1 magic) and legacy plain text formats - Read format: Magic(8) + [IV(12) + Tag(16) + Ciphertext(sizeof(AuditLogEntry))]* - Decrypt each entry and display in human-readable format - Filter by timestamp range as before - Fixed buffer overflow: GCM mode ciphertext size == plaintext size 2. Export Audit Encryption Functions (hsm_security.h): - Change audit_enc_key from static to exported (for decrypt_audit_entry_helper) - Change audit_enc_key_initialized from static to exported - Change init_audit_encryption_key() from static to exported - Allows hsm_enhanced.c to reuse encryption keys for decryption 3. Fix GitHub Actions Workflow (hsm_tester.yml): - Replace direct grep on hsm_audit.log (binary encrypted file) - Use ./hsm_enhanced -audit_logs 365 command to decrypt and display - Redirect output to audit_output.txt for grepping - Tests now grep decrypted text output instead of encrypted binary Testing Performed: - Built hsm_enhanced successfully (minor truncation warning only) - Verified audit log encryption works (binary format) - Tested -audit_logs command decrypts and displays entries correctly - Verified grep on decrypted output finds KEY_CREATED and SIGN_OPERATION - Confirmed backward compatibility with plain text audit logs - Fixed stack smashing error (buffer overflow in ciphertext reading) Technical Details: - AES-256-GCM mode: ciphertext length == plaintext length (no padding) - Each encrypted entry: IV(12) + Tag(16) + Ciphertext(sizeof(AuditLogEntry)) - Decryption validates authentication tag (detects tampering) - Format detection via magic number comparison - Proper error handling for incomplete/corrupted entries This ensures all GitHub Actions tests pass while maintaining full encryption of sensitive audit log data. The -audit_logs command provides authorized access to view encrypted logs for auditing and compliance purposes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit fixes all GitHub Actions test failures caused by the encryption changes implemented in the previous commit. The tests were trying to grep encrypted binary audit logs, which fails because the data is no longer plain text.
Changes:
Implement Audit Log Decryption (hsm_enhanced.c):
Export Audit Encryption Functions (hsm_security.h):
Fix GitHub Actions Workflow (hsm_tester.yml):
Testing Performed:
Technical Details:
This ensures all GitHub Actions tests pass while maintaining full encryption of sensitive audit log data. The -audit_logs command provides authorized access to view encrypted logs for auditing and compliance purposes.