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

Side by Side Diff: remoting/protocol/auth_util.cc

Issue 9663043: Add a boolean |had_context| argument to the TLS ExportKeyingMaterial (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Make suggested changes, add patch file Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/third_party/nss/ssl/sslinfo.c ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "remoting/protocol/auth_util.h" 5 #include "remoting/protocol/auth_util.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "crypto/hmac.h" 10 #include "crypto/hmac.h"
(...skipping 29 matching lines...) Expand all
40 return expected_token == auth_token; 40 return expected_token == auth_token;
41 } 41 }
42 42
43 // static 43 // static
44 std::string GetAuthBytes(net::SSLSocket* socket, 44 std::string GetAuthBytes(net::SSLSocket* socket,
45 const base::StringPiece& label, 45 const base::StringPiece& label,
46 const base::StringPiece& shared_secret) { 46 const base::StringPiece& shared_secret) {
47 // Get keying material from SSL. 47 // Get keying material from SSL.
48 unsigned char key_material[kAuthDigestLength]; 48 unsigned char key_material[kAuthDigestLength];
49 int export_result = socket->ExportKeyingMaterial( 49 int export_result = socket->ExportKeyingMaterial(
50 label, "", key_material, kAuthDigestLength); 50 label, false, "", key_material, kAuthDigestLength);
wtc 2012/03/14 03:35:46 Here we're using no context (""), so the new has_c
51 if (export_result != net::OK) { 51 if (export_result != net::OK) {
52 LOG(ERROR) << "Error fetching keying material: " << export_result; 52 LOG(ERROR) << "Error fetching keying material: " << export_result;
53 return std::string(); 53 return std::string();
54 } 54 }
55 55
56 // Generate auth digest based on the keying material and shared secret. 56 // Generate auth digest based on the keying material and shared secret.
57 crypto::HMAC response(crypto::HMAC::SHA256); 57 crypto::HMAC response(crypto::HMAC::SHA256);
58 if (!response.Init(key_material, kAuthDigestLength)) { 58 if (!response.Init(key_material, kAuthDigestLength)) {
59 NOTREACHED() << "HMAC::Init failed"; 59 NOTREACHED() << "HMAC::Init failed";
60 return std::string(); 60 return std::string();
61 } 61 }
62 unsigned char out_bytes[kAuthDigestLength]; 62 unsigned char out_bytes[kAuthDigestLength];
63 if (!response.Sign(shared_secret, out_bytes, kAuthDigestLength)) { 63 if (!response.Sign(shared_secret, out_bytes, kAuthDigestLength)) {
64 NOTREACHED() << "HMAC::Sign failed"; 64 NOTREACHED() << "HMAC::Sign failed";
65 return std::string(); 65 return std::string();
66 } 66 }
67 67
68 return std::string(out_bytes, out_bytes + kAuthDigestLength); 68 return std::string(out_bytes, out_bytes + kAuthDigestLength);
69 } 69 }
70 70
71 } // namespace protocol 71 } // namespace protocol
72 } // namespace remoting 72 } // namespace remoting
OLDNEW
« no previous file with comments | « net/third_party/nss/ssl/sslinfo.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698