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

Unified Diff: base/sha1.cc

Issue 2076593002: base: In SHA-1 implementation use base::ByteSwap for endian conversion (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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.cc
diff --git a/base/sha1.cc b/base/sha1.cc
index dd2ab6fe17765b70a722176c6d1f09bac2a28729..a710001ab70ec7a00ec2096370d2bbc6d255c05d 100644
--- a/base/sha1.cc
+++ b/base/sha1.cc
@@ -8,6 +8,7 @@
#include <stdint.h>
#include <string.h>
+#include "base/sys_byteorder.h"
namespace base {
@@ -92,10 +93,6 @@ static inline uint32_t K(uint32_t t) {
}
}
-static inline void swapends(uint32_t* t) {
- *t = (*t >> 24) | ((*t >> 8) & 0xff00) | ((*t & 0xff00) << 8) | (*t << 24);
-}
-
const int SecureHashAlgorithm::kDigestSizeBytes = 20;
void SecureHashAlgorithm::Init() {
@@ -118,7 +115,7 @@ void SecureHashAlgorithm::Final() {
Process();
for (int t = 0; t < 5; ++t)
- swapends(&H[t]);
+ H[t] = ByteSwap(H[t]);
}
void SecureHashAlgorithm::Update(const void* data, size_t nbytes) {
@@ -165,7 +162,7 @@ void SecureHashAlgorithm::Process() {
// W and M are in a union, so no need to memcpy.
// memcpy(W, M, sizeof(M));
for (t = 0; t < 16; ++t)
- swapends(&W[t]);
+ W[t] = ByteSwap(W[t]);
// b.
for (t = 16; t < 80; ++t)
« 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