-
Notifications
You must be signed in to change notification settings - Fork 246
Put sha256 context init/shutdown under a RAII wrapper #7251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Put sha256 context init/shutdown under a RAII wrapper #7251
Conversation
1f9175a to
6fe6f69
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a RAII wrapper (Sha256ContextGuard) to replace manual initialization and cleanup calls for the OpenSSL SHA256 context management, improving resource safety and reducing boilerplate code.
- Replaced manual
ccf::crypto::openssl_sha256_init()andccf::crypto::openssl_sha256_shutdown()calls with RAII pattern - Added
Sha256ContextGuardclass that handles initialization in constructor and cleanup in destructor - Updated documentation to reflect the new API usage pattern
Reviewed Changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| include/ccf/crypto/openssl_init.h | Defines new Sha256ContextGuard RAII wrapper class |
| src/crypto/openssl/hash.cpp | Implements the guard constructor/destructor and improves error handling |
| tests/perf-system/submitter/submit.cpp | Migrates from manual init/shutdown calls to RAII guard |
| src/pal/test/snp_ioctl_test.cpp | Migrates test code to use the new RAII pattern |
| src/pal/test/snp_attestation_validation.cpp | Migrates test code to use the new RAII pattern |
| src/node/test/* | Multiple test files migrated to use the RAII pattern |
| src/kv/test/* | Multiple test files migrated to use the RAII pattern |
| src/indexing/test/indexing.cpp | Migrates test code to use the RAII pattern |
| src/host/test/ledger.cpp | Migrates test code to use the RAII pattern |
| src/host/run.cpp | Migrates main application code to use the RAII pattern |
| src/enclave/enclave.h | Migrates enclave initialization to use the RAII pattern |
| src/crypto/test/* | Multiple crypto test files migrated to use the RAII pattern |
| doc/build_apps/get_started.rst | Updates documentation to reflect new API usage |
| CHANGELOG.md | Documents the API change |
Comments suppressed due to low confidence (1)
src/node/test/history_bench.cpp:1
- This line should call
openssl_sha256_shutdown()instead ofopenssl_sha256_init(). The original code had a shutdown call here, but the replacement is incorrect.
// Copyright (c) Microsoft Corporation. All rights reserved.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
6fe6f69 to
61e3e53
Compare
Because why not?..
Do not merge before: