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

Unified Diff: base/sha1_portable.cc

Issue 382423003: The message length should be serialized as a 64-bit value. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/sha1_portable.cc
diff --git a/base/sha1_portable.cc b/base/sha1_portable.cc
index 529fc905b7a84d882e3c9fef96b5063a69f6c61a..0b9df830797c6f5de28b587f0ccafc9168b7eedf 100644
--- a/base/sha1_portable.cc
+++ b/base/sha1_portable.cc
@@ -60,7 +60,7 @@ class SecureHashAlgorithm {
};
uint32 cursor;
wtc 2014/07/12 01:23:40 Yukawa also suggested that |cursor| should be defi
yukawa 2014/07/12 03:40:01 Makes sense. Thanks.
- uint32 l;
+ uint64 l;
};
static inline uint32 f(uint32 t, uint32 B, uint32 C, uint32 D) {
@@ -92,10 +92,7 @@ static inline uint32 K(uint32 t) {
}
static inline void swapends(uint32* t) {
- *t = ((*t & 0xff000000) >> 24) |
- ((*t & 0xff0000) >> 8) |
- ((*t & 0xff00) << 8) |
- ((*t & 0xff) << 24);
+ *t = (*t >> 24) | ((*t >> 8) & 0xff00) | ((*t & 0xff00) << 8) | (*t << 24);
}
const int SecureHashAlgorithm::kDigestSizeBytes = 20;
@@ -144,13 +141,17 @@ void SecureHashAlgorithm::Pad() {
Process();
}
- while (cursor < 64-4)
+ while (cursor < 64-8)
M[cursor++] = 0;
- M[64-4] = (l & 0xff000000) >> 24;
- M[64-3] = (l & 0xff0000) >> 16;
- M[64-2] = (l & 0xff00) >> 8;
- M[64-1] = (l & 0xff);
+ M[cursor++] = (l >> 56) & 0xff;
+ M[cursor++] = (l >> 48) & 0xff;
+ M[cursor++] = (l >> 40) & 0xff;
+ M[cursor++] = (l >> 32) & 0xff;
+ M[cursor++] = (l >> 24) & 0xff;
+ M[cursor++] = (l >> 16) & 0xff;
+ M[cursor++] = (l >> 8) & 0xff;
+ M[cursor++] = l & 0xff;
wtc 2014/07/12 01:23:40 All the & 0xff operations can be omitted.
Mark Mentovai 2014/07/12 14:48:47 wtc wrote:
}
void SecureHashAlgorithm::Process() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698