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

Side by Side Diff: trunk/src/google_apis/gaia/oauth_request_signer.cc

Issue 101113004: Revert 239759 "The comment in base64.h implies that base::Base64..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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 | Annotate | Revision Log
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 if (result) { 208 base::Base64Encode(std::string(reinterpret_cast<const char*>(digest),
209 base::Base64Encode( 209 kHmacDigestLength),
210 std::string(reinterpret_cast<const char*>(digest), kHmacDigestLength), 210 signature_return);
211 signature_return);
212 }
213 return result; 211 return result;
214 } 212 }
215 213
216 // Creates the value for the oauth_signature parameter when the 214 // Creates the value for the oauth_signature parameter when the
217 // oauth_signature_method is PLAINTEXT. 215 // oauth_signature_method is PLAINTEXT.
218 // 216 //
219 // Not yet implemented, and might never be. 217 // Not yet implemented, and might never be.
220 bool SignPlaintext(const std::string& text, 218 bool SignPlaintext(const std::string& text,
221 const std::string& key, 219 const std::string& key,
222 std::string* result) { 220 std::string* result) {
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 signed_text += 448 signed_text +=
451 base::StringPrintf( 449 base::StringPrintf(
452 "%s=\"%s\"", 450 "%s=\"%s\"",
453 OAuthRequestSigner::Encode(param->first).c_str(), 451 OAuthRequestSigner::Encode(param->first).c_str(),
454 OAuthRequestSigner::Encode(param->second).c_str()); 452 OAuthRequestSigner::Encode(param->second).c_str());
455 } 453 }
456 *signed_text_return = signed_text; 454 *signed_text_return = signed_text;
457 } 455 }
458 return is_signed; 456 return is_signed;
459 } 457 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698