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

Side by Side Diff: crypto/hmac.cc

Issue 11419270: Use size_t as the type of key_length and digest_length arguments of HMAC. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fix compilation errors Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "crypto/hmac.h" 5 #include "crypto/hmac.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "crypto/secure_util.h" 10 #include "crypto/secure_util.h"
(...skipping 29 matching lines...) Expand all
40 return VerifyTruncated(data, digest); 40 return VerifyTruncated(data, digest);
41 } 41 }
42 42
43 bool HMAC::VerifyTruncated(const base::StringPiece& data, 43 bool HMAC::VerifyTruncated(const base::StringPiece& data,
44 const base::StringPiece& digest) const { 44 const base::StringPiece& digest) const {
45 if (digest.empty()) 45 if (digest.empty())
46 return false; 46 return false;
47 size_t digest_length = DigestLength(); 47 size_t digest_length = DigestLength();
48 scoped_array<unsigned char> computed_digest( 48 scoped_array<unsigned char> computed_digest(
49 new unsigned char[digest_length]); 49 new unsigned char[digest_length]);
50 if (!Sign(data, computed_digest.get(), static_cast<int>(digest_length))) 50 if (!Sign(data, computed_digest.get(), digest_length))
51 return false; 51 return false;
52 52
53 return SecureMemEqual(digest.data(), computed_digest.get(), 53 return SecureMemEqual(digest.data(), computed_digest.get(),
54 std::min(digest.size(), digest_length)); 54 std::min(digest.size(), digest_length));
55 } 55 }
56 56
57 } // namespace crypto 57 } // namespace crypto
OLDNEW
« no previous file with comments | « crypto/hmac.h ('k') | crypto/hmac_nss.cc » ('j') | crypto/hmac_openssl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698