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

Side by Side Diff: google_apis/cup/client_update_protocol.cc

Issue 86913002: Make base::Base64Encode() return void (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase. 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "google_apis/cup/client_update_protocol.h" 5 #include "google_apis/cup/client_update_protocol.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/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/sha1.h" 10 #include "base/sha1.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 result.insert(result.end(), digest.begin(), digest.end()); 115 result.insert(result.end(), digest.begin(), digest.end());
116 DCHECK_EQ(result.size(), rsa_key_size); 116 DCHECK_EQ(result.size(), rsa_key_size);
117 return result; 117 return result;
118 } 118 }
119 119
120 // CUP passes the versioned secret in the query portion of the URL for the 120 // CUP passes the versioned secret in the query portion of the URL for the
121 // update check service -- and that means that a URL-safe variant of Base64 is 121 // update check service -- and that means that a URL-safe variant of Base64 is
122 // needed. Call the standard Base64 encoder/decoder and then apply fixups. 122 // needed. Call the standard Base64 encoder/decoder and then apply fixups.
123 std::string UrlSafeB64Encode(const std::vector<uint8>& data) { 123 std::string UrlSafeB64Encode(const std::vector<uint8>& data) {
124 std::string result; 124 std::string result;
125 if (!base::Base64Encode(ByteVectorToSP(data), &result)) 125 base::Base64Encode(ByteVectorToSP(data), &result);
126 return std::string();
127 126
128 // Do an tr|+/|-_| on the output, and strip any '=' padding. 127 // Do an tr|+/|-_| on the output, and strip any '=' padding.
129 for (std::string::iterator it = result.begin(); it != result.end(); ++it) { 128 for (std::string::iterator it = result.begin(); it != result.end(); ++it) {
130 switch (*it) { 129 switch (*it) {
131 case '+': 130 case '+':
132 *it = '-'; 131 *it = '-';
133 break; 132 break;
134 case '/': 133 case '/':
135 *it = '_'; 134 *it = '_';
136 break; 135 break;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 294
296 // Encrypt the key source (r) using the public key (pk[v]) to generate the 295 // Encrypt the key source (r) using the public key (pk[v]) to generate the
297 // encrypted key source (w). 296 // encrypted key source (w).
298 if (!EncryptKeySource(source)) 297 if (!EncryptKeySource(source))
299 return false; 298 return false;
300 if (encrypted_key_source_.size() != PublicKeyLength()) 299 if (encrypted_key_source_.size() != PublicKeyLength())
301 return false; 300 return false;
302 301
303 return true; 302 return true;
304 } 303 }
305
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698