Add pluggable logging hook to safe-crypto-lib (issue #184, PR A) - #185
Merged
Conversation
Introduces crypto_log.hpp: a zero-dependency, opt-in logging hook with CryptoLogLevel (Debug/Info/Warn/Error/Off), crypto_set_log_sink() for registration, crypto_log_enabled() for cheap fast-path guards, and crypto_log() for emission. Default state is no-op; existing callers are unaffected. Instruments every public API wrapper (sha, hmac_generate/verify, aes256_gcm_encrypt/decrypt, chacha20_poly1305_encrypt/decrypt, symmetric_encrypt/decrypt, random_bytes, ecdsa_*, ecdh_*, rsa_*, hkdf_derive/expand, generate_rsa_key, slh_dsa_*, ml_dsa_*, ml_kem_*) with Debug traces at entry and success, and Error traces forwarding CryptoError::message() on failure. _impl functions are untouched. Key material, IVs, and payload bytes are never included in log messages. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Owner
Author
|
Reviewed latest head 4519e82. I do not see a code blocker in this logging PR. What I checked:
Local verification:
GitHub CI is almost green: all reported jobs pass except |
This was referenced May 21, 2026
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.
Summary
safe-crypto-lib/crypto_log.hpp: a zero-dependency, opt-in logging hookCryptoLogLevelenum (Debug/Info/Warn/Error/Off)crypto_set_log_sink(fn, threshold)— register any callable once at startup; passingnullptrdisables logging; default state is silentcrypto_log_enabled(level)— single relaxed atomic load for fast-path guarding of expensive message constructioncrypto_log(level, msg)— emit; no-op when below thresholdcrypto_log_detail::msg(op, k, v...)— helper building"op: k=N bytes"strings without<format>CryptoError::message()—_implfunctions are completely untouchedsha,hmac_generate/verify,aes256_gcm_encrypt/decrypt,chacha20_poly1305_encrypt/decrypt,symmetric_encrypt/decrypt,random_bytes,ecdsa_*,ecdh_*,rsa_oaep_*,rsa_pss_*,hkdf_derive/expand,generate_rsa_key,slh_dsa_*,ml_dsa_*,ml_kem_*Test plan
safe_crypto_lib_test— verified locally, all pass)Closes part of #184
🤖 Generated with Claude Code