Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(973)

Unified Diff: base/openssl_util.h

Issue 5105003: Implements Signature Creator & Verifier for openssl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: bulach comments Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/crypto/signature_verifier_openssl.cc ('k') | base/openssl_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/openssl_util.h
diff --git a/base/openssl_util.h b/base/openssl_util.h
index 1d290ae3ad0cd6dcb13206d943961ceb75bd2a8b..0f69c8f95f60551810cb441a520cab3ccb325533 100644
--- a/base/openssl_util.h
+++ b/base/openssl_util.h
@@ -16,10 +16,17 @@ namespace base {
template <typename T, void (*destructor)(T*)>
class ScopedOpenSSL {
public:
- explicit ScopedOpenSSL(T* ptr_) : ptr_(ptr_) { }
+ ScopedOpenSSL() : ptr_(NULL) { }
+ explicit ScopedOpenSSL(T* ptr) : ptr_(ptr) { }
~ScopedOpenSSL() { if (ptr_) (*destructor)(ptr_); }
T* get() const { return ptr_; }
+ void reset(T* ptr) {
+ if (ptr != ptr_) {
+ if (ptr_) (*destructor)(ptr_);
+ ptr_ = ptr;
+ }
+ }
private:
T* ptr_;
@@ -72,9 +79,24 @@ class ScopedOpenSSLSafeSizeBuffer {
void EnsureOpenSSLInit();
// Drains the OpenSSL ERR_get_error stack. On a debug build the error codes
-// are send to VLOG(1), on a release build they are disregarded.
+// are send to VLOG(1), on a release build they are disregarded. An optional
+// |message| can be passed, which will be prepended to the error stack output
+// if present.
+void ClearOpenSSLERRStack(const char* message);
wtc 2010/11/17 20:30:48 Please consult the Style Guide's recommendations o
joth 2010/11/18 12:52:47 Done. It falls under the "overloads must be obviou
void ClearOpenSSLERRStack();
+// Place an instance of this class on the call stack to automatically clear
+// the OpenSSL error stack on function exit. If |message| is not null it will
+// be included in any error dump.
+class OpenSSLErrStackTracer {
+ public:
+ explicit OpenSSLErrStackTracer(const char* message) : message_(message) {}
+ ~OpenSSLErrStackTracer() { ClearOpenSSLERRStack(message_); }
+
+ private:
+ const char* const message_;
+};
+
} // namespace base
#endif // BASE_OPENSSL_UTIL_H_
« no previous file with comments | « base/crypto/signature_verifier_openssl.cc ('k') | base/openssl_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698