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

Side by Side Diff: chrome/browser/devtools/adb/android_rsa.cc

Issue 86913002: Make base::Base64Encode() return void (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: One more chromeos-specific fix. Created 7 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "chrome/browser/devtools/adb/android_rsa.h" 5 #include "chrome/browser/devtools/adb/android_rsa.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "chrome/browser/prefs/pref_service_syncable.h" 9 #include "chrome/browser/prefs/pref_service_syncable.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 std::vector<uint8> key_info(decoded_key.begin(), decoded_key.end()); 189 std::vector<uint8> key_info(decoded_key.begin(), decoded_key.end());
190 key.reset(crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(key_info)); 190 key.reset(crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(key_info));
191 } 191 }
192 if (!key) { 192 if (!key) {
193 key.reset(crypto::RSAPrivateKey::Create(2048)); 193 key.reset(crypto::RSAPrivateKey::Create(2048));
194 std::vector<uint8> key_info; 194 std::vector<uint8> key_info;
195 if (!key || !key->ExportPrivateKey(&key_info)) 195 if (!key || !key->ExportPrivateKey(&key_info))
196 return NULL; 196 return NULL;
197 197
198 std::string key_string(key_info.begin(), key_info.end()); 198 std::string key_string(key_info.begin(), key_info.end());
199 if (base::Base64Encode(key_string, &encoded_key)) { 199 base::Base64Encode(key_string, &encoded_key);
200 profile->GetPrefs()->SetString(prefs::kDevToolsAdbKey, 200 profile->GetPrefs()->SetString(prefs::kDevToolsAdbKey,
201 encoded_key); 201 encoded_key);
202 }
203 } 202 }
204 return key.release(); 203 return key.release();
205 } 204 }
206 205
207 std::string AndroidRSAPublicKey(crypto::RSAPrivateKey* key) { 206 std::string AndroidRSAPublicKey(crypto::RSAPrivateKey* key) {
208 std::vector<uint8> public_key; 207 std::vector<uint8> public_key;
209 if (!key) 208 if (!key)
210 return kDummyRSAPublicKey; 209 return kDummyRSAPublicKey;
211 210
212 key->ExportPublicKey(&public_key); 211 key->ExportPublicKey(&public_key);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 std::string AndroidRSASign(crypto::RSAPrivateKey* key, 261 std::string AndroidRSASign(crypto::RSAPrivateKey* key,
263 const std::string& body) { 262 const std::string& body) {
264 std::vector<uint8> digest(body.begin(), body.end()); 263 std::vector<uint8> digest(body.begin(), body.end());
265 std::vector<uint8> result; 264 std::vector<uint8> result;
266 if (!crypto::SignatureCreator::Sign(key, vector_as_array(&digest), 265 if (!crypto::SignatureCreator::Sign(key, vector_as_array(&digest),
267 digest.size(), &result)) { 266 digest.size(), &result)) {
268 return std::string(); 267 return std::string();
269 } 268 }
270 return std::string(result.begin(), result.end()); 269 return std::string(result.begin(), result.end());
271 } 270 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698