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

Unified Diff: base/md5.cc

Issue 211273009: base::MD5IntermediateFinal() generates digest non-destructively. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change to suggested comment. Created 6 years, 9 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 | « base/md5.h ('k') | base/md5_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/md5.cc
diff --git a/base/md5.cc b/base/md5.cc
index 754994c0e562b45b2bc4b90cc2a7c612d14ec5a7..e77885e3a352be137aecba2b6686c85f048e895a 100644
--- a/base/md5.cc
+++ b/base/md5.cc
@@ -260,6 +260,14 @@ void MD5Final(MD5Digest* digest, MD5Context* context) {
memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */
}
+void MD5IntermediateFinal(MD5Digest* digest, const MD5Context* context) {
+ /* MD5Final mutates the MD5Context*. Make a copy for generating the
+ intermediate value. */
+ MD5Context context_copy;
+ memcpy(&context_copy, context, sizeof(context_copy));
+ MD5Final(digest, &context_copy);
+}
+
std::string MD5DigestToBase16(const MD5Digest& digest) {
static char const zEncode[] = "0123456789abcdef";
« no previous file with comments | « base/md5.h ('k') | base/md5_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698