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

Unified Diff: crypto/hkdf.cc

Issue 12806002: Land Recent QUIC Changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment update to hkdf.cc Created 7 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 | « no previous file | net/net.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crypto/hkdf.cc
diff --git a/crypto/hkdf.cc b/crypto/hkdf.cc
index e621bcb45b0818d64bce70893ba8308f39bca168..27388f9764639ed999acb728b376fd0d9702c23f 100644
--- a/crypto/hkdf.cc
+++ b/crypto/hkdf.cc
@@ -72,17 +72,24 @@ HKDF::HKDF(const base::StringPiece& secret,
}
size_t j = 0;
- client_write_key_ = base::StringPiece(reinterpret_cast<char*>(&output_[j]),
- key_bytes_to_generate);
- j += key_bytes_to_generate;
- server_write_key_ = base::StringPiece(reinterpret_cast<char*>(&output_[j]),
- key_bytes_to_generate);
- j += key_bytes_to_generate;
- client_write_iv_ = base::StringPiece(reinterpret_cast<char*>(&output_[j]),
- iv_bytes_to_generate);
- j += iv_bytes_to_generate;
- server_write_iv_ = base::StringPiece(reinterpret_cast<char*>(&output_[j]),
- iv_bytes_to_generate);
+ // On Windows, when output's size is zero, dereference of 0'th element results
wtc 2013/03/14 00:38:08 output's => the size of output_ because "output_'
ramant (doing other things) 2013/03/14 03:05:15 Deleted this comment
ramant (doing other things) 2013/03/14 03:26:20 Added the comment.
+ // in a crash. C++11 solves this problem by passing std::vector's data.
wtc 2013/03/14 00:38:08 This should read: C++11 solves this problem by a
ramant (doing other things) 2013/03/14 03:05:15 Changed the code to use output_.data() + j. Thanks
ramant (doing other things) 2013/03/14 03:26:20 Added the comment. output_.data() + j is not suppo
+ if (key_bytes_to_generate > 0) {
+ client_write_key_ = base::StringPiece(reinterpret_cast<char*>(&output_[j]),
+ key_bytes_to_generate);
+ j += key_bytes_to_generate;
+ server_write_key_ = base::StringPiece(reinterpret_cast<char*>(&output_[j]),
+ key_bytes_to_generate);
+ j += key_bytes_to_generate;
+ }
+
+ if (iv_bytes_to_generate > 0) {
+ client_write_iv_ = base::StringPiece(reinterpret_cast<char*>(&output_[j]),
+ iv_bytes_to_generate);
+ j += iv_bytes_to_generate;
+ server_write_iv_ = base::StringPiece(reinterpret_cast<char*>(&output_[j]),
+ iv_bytes_to_generate);
+ }
}
HKDF::~HKDF() {
« no previous file with comments | « no previous file | net/net.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698