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

Unified Diff: base/sha2.h

Issue 6276002: Abstracts SHA256 context for NSS / OpenSSL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Implements SHA256Context abstracting NSS / OpenSSL. Created 9 years, 11 months 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 | « no previous file | base/sha2.cc » ('j') | base/sha2_unittest.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/sha2.h
diff --git a/base/sha2.h b/base/sha2.h
index 19e41c30b227a97f771e9d0ee522fc6fc55a8c73..8b9a98ce705f809e94dcd99c497a9c45c8bd36fd 100644
--- a/base/sha2.h
+++ b/base/sha2.h
@@ -8,6 +8,8 @@
#include <string>
+#include "base/basictypes.h"
+
namespace base {
// These functions perform SHA-256 operations.
@@ -27,6 +29,24 @@ void SHA256HashString(const std::string& str, void* output, size_t len);
// string.
std::string SHA256HashString(const std::string& str);
+// A wrapper for calculating SHA256 when the full string is not known in
+// advance.
+class SHA256Context {
wtc 2011/01/21 22:48:51 Please name this class SHA256Hash or SHA256. (I a
bulach 2011/01/24 20:54:33 I liked this idea, seems more flexible. I extracte
+ public:
+ virtual ~SHA256Context() {}
+
+ static SHA256Context* Create();
+
+ virtual void Update(const std::string& str) = 0;
+ virtual void Finish(void* output, size_t len) = 0;
wtc 2011/01/21 22:48:51 This method should be named Final.
bulach 2011/01/24 20:54:33 done, in the new files.
+
+ protected:
+ SHA256Context() {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(SHA256Context);
+};
+
} // namespace base
#endif // BASE_SHA2_H_
« no previous file with comments | « no previous file | base/sha2.cc » ('j') | base/sha2_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698