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

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

Issue 13976007: Land Recent QUIC Changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated copyright notice Created 7 years, 8 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 | « net/quic/crypto/crypto_utils.h ('k') | net/quic/quic_client_session.h » ('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 b6ae58bf50f756dbf2879a133c0e0559a502da6f..6e52898462cc50f9c7553e169099eae305a16d3a 100644
--- a/net/quic/crypto/crypto_utils.cc
+++ b/net/quic/crypto/crypto_utils.cc
@@ -10,7 +10,7 @@
#include "net/quic/crypto/quic_decrypter.h"
#include "net/quic/crypto/quic_encrypter.h"
#include "net/quic/crypto/quic_random.h"
-#include "net/quic/quic_clock.h"
+#include "net/quic/quic_time.h"
using base::StringPiece;
using std::string;
@@ -64,14 +64,13 @@ bool CryptoUtils::FindMutualTag(const CryptoTagVector& our_tags_vector,
return false;
}
-void CryptoUtils::GenerateNonce(const QuicClock* clock,
+void CryptoUtils::GenerateNonce(QuicTime::Delta now,
QuicRandom* random_generator,
- const string& orbit,
+ StringPiece orbit,
string* nonce) {
// a 4-byte timestamp + 28 random bytes.
nonce->reserve(kNonceSize);
nonce->resize(kNonceSize);
- QuicTime::Delta now = clock->NowAsDeltaSinceUnixEpoch();
uint32 gmt_unix_time = now.ToSeconds();
memcpy(&(*nonce)[0], &gmt_unix_time, sizeof(gmt_unix_time));
@@ -85,7 +84,7 @@ void CryptoUtils::GenerateNonce(const QuicClock* clock,
}
void CryptoUtils::DeriveKeys(QuicCryptoNegotiatedParameters* params,
- StringPiece nonce,
+ StringPiece client_nonce,
const string& hkdf_input,
Perspective perspective) {
params->encrypter.reset(QuicEncrypter::Create(params->aead));
@@ -93,6 +92,13 @@ void CryptoUtils::DeriveKeys(QuicCryptoNegotiatedParameters* params,
size_t key_bytes = params->encrypter->GetKeySize();
size_t nonce_prefix_bytes = params->encrypter->GetNoncePrefixSize();
+ StringPiece nonce = client_nonce;
+ string nonce_storage;
+ if (!params->server_nonce.empty()) {
+ nonce_storage = client_nonce.as_string() + params->server_nonce;
+ nonce = nonce_storage;
+ }
+
crypto::HKDF hkdf(params->premaster_secret, nonce,
hkdf_input, key_bytes, nonce_prefix_bytes);
if (perspective == SERVER) {
« no previous file with comments | « net/quic/crypto/crypto_utils.h ('k') | net/quic/quic_client_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698