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

Unified Diff: crypto/hkdf.cc

Issue 12330157: CRYPTO - Resolved comments from wtc. Used scoped_ptr<char[]> and (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 10 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 | « crypto/hkdf.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crypto/hkdf.cc
===================================================================
--- crypto/hkdf.cc (revision 184497)
+++ crypto/hkdf.cc (working copy)
@@ -49,7 +49,7 @@
output_.resize(n * kSHA256HashLength);
base::StringPiece previous;
- char* buf = new char[kSHA256HashLength + info.size() + 1];
+ scoped_ptr<char[]> buf(new char[kSHA256HashLength + info.size() + 1]);
uint8 digest[kSHA256HashLength];
HMAC hmac(HMAC::SHA256);
@@ -57,13 +57,13 @@
DCHECK(result);
for (size_t i = 0; i < n; i++) {
- memcpy(buf, previous.data(), previous.size());
+ memcpy(buf.get(), previous.data(), previous.size());
size_t j = previous.size();
- memcpy(buf + j, info.data(), info.size());
+ memcpy(buf.get() + j, info.data(), info.size());
j += info.size();
- buf[j++] = static_cast<char>((i + 1) & 0xFF);
+ buf[j++] = static_cast<char>(i + 1);
- result = hmac.Sign(base::StringPiece(buf, j), digest, sizeof(digest));
+ result = hmac.Sign(base::StringPiece(buf.get(), j), digest, sizeof(digest));
DCHECK(result);
memcpy(&output_[i*sizeof(digest)], digest, sizeof(digest));
@@ -83,7 +83,6 @@
j += iv_bytes_to_generate;
server_write_iv_ = base::StringPiece(reinterpret_cast<char*>(&output_[j]),
iv_bytes_to_generate);
- delete[] buf;
}
HKDF::~HKDF() {
« no previous file with comments | « crypto/hkdf.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698