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

Unified Diff: net/quic/crypto/crypto_utils.cc

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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 | « net/quic/crypto/crypto_framer.cc ('k') | net/quic/crypto/p256_key_exchange_nss.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/crypto/crypto_utils.cc
diff --git a/net/quic/crypto/crypto_utils.cc b/net/quic/crypto/crypto_utils.cc
index 67af2e9469ca622abd475b15712c82134e48dbad..c5957750654659225bc2cf0ccf796e7e476cfaaa 100644
--- a/net/quic/crypto/crypto_utils.cc
+++ b/net/quic/crypto/crypto_utils.cc
@@ -28,19 +28,21 @@ void CryptoUtils::GenerateNonce(QuicWallTime now,
// a 4-byte timestamp + 28 random bytes.
nonce->reserve(kNonceSize);
nonce->resize(kNonceSize);
- uint32 gmt_unix_time = now.ToUNIXSeconds();
+
+ uint32 gmt_unix_time = static_cast<uint32>(now.ToUNIXSeconds());
// The time in the nonce must be encoded in big-endian because the
// strike-register depends on the nonces being ordered by time.
(*nonce)[0] = static_cast<char>(gmt_unix_time >> 24);
(*nonce)[1] = static_cast<char>(gmt_unix_time >> 16);
(*nonce)[2] = static_cast<char>(gmt_unix_time >> 8);
(*nonce)[3] = static_cast<char>(gmt_unix_time);
+ size_t bytes_written = 4;
- size_t bytes_written = sizeof(gmt_unix_time);
if (orbit.size() == 8) {
memcpy(&(*nonce)[bytes_written], orbit.data(), orbit.size());
bytes_written += orbit.size();
}
+
random_generator->RandBytes(&(*nonce)[bytes_written],
kNonceSize - bytes_written);
}
« no previous file with comments | « net/quic/crypto/crypto_framer.cc ('k') | net/quic/crypto/p256_key_exchange_nss.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698