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

Side by Side Diff: google_apis/gaia/oauth_request_signer.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) 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 "google_apis/gaia/oauth_request_signer.h" 5 #include "google_apis/gaia/oauth_request_signer.h"
6 6
7 #include <cctype> 7 #include <cctype>
8 #include <cstddef> 8 #include <cstddef>
9 #include <cstdlib> 9 #include <cstdlib>
10 #include <cstring> 10 #include <cstring>
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 197
198 // Creates the value for the oauth_signature parameter when the 198 // Creates the value for the oauth_signature parameter when the
199 // oauth_signature_method is HMAC-SHA1. 199 // oauth_signature_method is HMAC-SHA1.
200 bool SignHmacSha1(const std::string& text, 200 bool SignHmacSha1(const std::string& text,
201 const std::string& key, 201 const std::string& key,
202 std::string* signature_return) { 202 std::string* signature_return) {
203 crypto::HMAC hmac(crypto::HMAC::SHA1); 203 crypto::HMAC hmac(crypto::HMAC::SHA1);
204 DCHECK(hmac.DigestLength() == kHmacDigestLength); 204 DCHECK(hmac.DigestLength() == kHmacDigestLength);
205 unsigned char digest[kHmacDigestLength]; 205 unsigned char digest[kHmacDigestLength];
206 bool result = hmac.Init(key) && 206 bool result = hmac.Init(key) &&
207 hmac.Sign(text, digest, kHmacDigestLength) && 207 hmac.Sign(text, digest, kHmacDigestLength);
208 base::Base64Encode(std::string(reinterpret_cast<const char*>(digest), 208 if (result) {
209 kHmacDigestLength), 209 base::Base64Encode(
210 signature_return); 210 std::string(reinterpret_cast<const char*>(digest), kHmacDigestLength),
211 signature_return);
212 }
211 return result; 213 return result;
212 } 214 }
213 215
214 // Creates the value for the oauth_signature parameter when the 216 // Creates the value for the oauth_signature parameter when the
215 // oauth_signature_method is PLAINTEXT. 217 // oauth_signature_method is PLAINTEXT.
216 // 218 //
217 // Not yet implemented, and might never be. 219 // Not yet implemented, and might never be.
218 bool SignPlaintext(const std::string& text, 220 bool SignPlaintext(const std::string& text,
219 const std::string& key, 221 const std::string& key,
220 std::string* result) { 222 std::string* result) {
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 signed_text += 450 signed_text +=
449 base::StringPrintf( 451 base::StringPrintf(
450 "%s=\"%s\"", 452 "%s=\"%s\"",
451 OAuthRequestSigner::Encode(param->first).c_str(), 453 OAuthRequestSigner::Encode(param->first).c_str(),
452 OAuthRequestSigner::Encode(param->second).c_str()); 454 OAuthRequestSigner::Encode(param->second).c_str());
453 } 455 }
454 *signed_text_return = signed_text; 456 *signed_text_return = signed_text;
455 } 457 }
456 return is_signed; 458 return is_signed;
457 } 459 }
OLDNEW
« no previous file with comments | « google_apis/cup/client_update_protocol.cc ('k') | jingle/notifier/listener/push_notifications_send_update_task.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698