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

Side by Side Diff: remoting/host/me2me_preference_pane.mm

Issue 10406022: Address outstanding comments from CL 10384140 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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 | « base/base64.cc ('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) 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 #import "remoting/host/me2me_preference_pane.h" 5 #import "remoting/host/me2me_preference_pane.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 #include <CommonCrypto/CommonHMAC.h> 8 #include <CommonCrypto/CommonHMAC.h>
9 #include <launch.h> 9 #include <launch.h>
10 #import <PreferencePanes/PreferencePanes.h> 10 #import <PreferencePanes/PreferencePanes.h>
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 LOG(ERROR) << "Authentication method '" << method << "' not supported"; 76 LOG(ERROR) << "Authentication method '" << method << "' not supported";
77 return false; 77 return false;
78 } 78 }
79 79
80 std::string hash_base64 = host_secret_hash.substr(separator + 1); 80 std::string hash_base64 = host_secret_hash.substr(separator + 1);
81 81
82 // Convert |hash_base64| to |hash|, based on code from base/base64.cc. 82 // Convert |hash_base64| to |hash|, based on code from base/base64.cc.
83 int hash_base64_size = static_cast<int>(hash_base64.size()); 83 int hash_base64_size = static_cast<int>(hash_base64.size());
84 std::string hash; 84 std::string hash;
85 hash.resize(modp_b64_decode_len(hash_base64_size)); 85 hash.resize(modp_b64_decode_len(hash_base64_size));
86
87 // modp_b64_decode_len() returns at least 1, so hash[0] is safe here.
86 int hash_size = modp_b64_decode(&(hash[0]), hash_base64.data(), 88 int hash_size = modp_b64_decode(&(hash[0]), hash_base64.data(),
87 hash_base64_size); 89 hash_base64_size);
88 if (hash_size < 0) { 90 if (hash_size < 0) {
89 LOG(ERROR) << "Failed to parse host_secret_hash"; 91 LOG(ERROR) << "Failed to parse host_secret_hash";
90 return false; 92 return false;
91 } 93 }
92 hash.resize(hash_size); 94 hash.resize(hash_size);
93 95
94 std::string computed_hash; 96 std::string computed_hash;
95 computed_hash.resize(CC_SHA256_DIGEST_LENGTH); 97 computed_hash.resize(CC_SHA256_DIGEST_LENGTH);
96 98
97 CCHmac(kCCHmacAlgSHA256, 99 CCHmac(kCCHmacAlgSHA256,
98 host_id.data(), host_id.size(), 100 host_id.data(), host_id.size(),
99 pin.data(), pin.size(), 101 pin.data(), pin.size(),
100 &(computed_hash[0])); 102 &(computed_hash[0]));
101 103
104 // Normally, a constant-time comparison function would be used, but it is
105 // unnecessary here as the "secret" is already readable by the user
106 // supplying input to this routine.
102 return computed_hash == hash; 107 return computed_hash == hash;
103 } 108 }
104 109
105 } // namespace 110 } // namespace
106 111
107 namespace remoting { 112 namespace remoting {
108 JsonHostConfig::JsonHostConfig(const std::string& filename) 113 JsonHostConfig::JsonHostConfig(const std::string& filename)
109 : filename_(filename) { 114 : filename_(filename) {
110 } 115 }
111 116
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 - (void)notifyPlugin:(const char*)message { 491 - (void)notifyPlugin:(const char*)message {
487 NSDistributedNotificationCenter* center = 492 NSDistributedNotificationCenter* center =
488 [NSDistributedNotificationCenter defaultCenter]; 493 [NSDistributedNotificationCenter defaultCenter];
489 NSString* name = [NSString stringWithUTF8String:message]; 494 NSString* name = [NSString stringWithUTF8String:message];
490 [center postNotificationName:name 495 [center postNotificationName:name
491 object:nil 496 object:nil
492 userInfo:nil]; 497 userInfo:nil];
493 } 498 }
494 499
495 @end 500 @end
OLDNEW
« no previous file with comments | « base/base64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698