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

Side by Side Diff: chrome/common/net/gaia/oauth_request_signer.cc

Issue 7522014: Add WARN_UNUSED_RESULT to crypto/hmac.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase onto CL 7532020 and update remoting Created 9 years, 4 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 | « chrome/browser/internal_auth.cc ('k') | crypto/hmac.h » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/common/net/gaia/oauth_request_signer.h" 5 #include "chrome/common/net/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 198
199 // Creates the value for the oauth_signature parameter when the 199 // Creates the value for the oauth_signature parameter when the
200 // oauth_signature_method is HMAC-SHA1. 200 // oauth_signature_method is HMAC-SHA1.
201 bool SignHmacSha1(const std::string& text, 201 bool SignHmacSha1(const std::string& text,
202 const std::string& key, 202 const std::string& key,
203 std::string* signature_return) { 203 std::string* signature_return) {
204 crypto::HMAC hmac(crypto::HMAC::SHA1); 204 crypto::HMAC hmac(crypto::HMAC::SHA1);
205 DCHECK(hmac.DigestLength() == kHmacDigestLength); 205 DCHECK(hmac.DigestLength() == kHmacDigestLength);
206 unsigned char digest[kHmacDigestLength]; 206 unsigned char digest[kHmacDigestLength];
207 hmac.Init(key); 207 bool result = hmac.Init(key) &&
208 bool result = hmac.Sign(text, digest, kHmacDigestLength) && 208 hmac.Sign(text, digest, kHmacDigestLength) &&
209 base::Base64Encode(std::string(reinterpret_cast<const char*>(digest), 209 base::Base64Encode(std::string(reinterpret_cast<const char*>(digest),
210 kHmacDigestLength), 210 kHmacDigestLength),
211 signature_return); 211 signature_return);
212 return result; 212 return result;
213 } 213 }
214 214
215 // Creates the value for the oauth_signature parameter when the 215 // Creates the value for the oauth_signature parameter when the
216 // oauth_signature_method is PLAINTEXT. 216 // oauth_signature_method is PLAINTEXT.
217 // 217 //
218 // Not yet implemented, and might never be. 218 // Not yet implemented, and might never be.
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 signed_text += base_parameters + '&' + kOAuthSignatureLabel + '=' + 401 signed_text += base_parameters + '&' + kOAuthSignatureLabel + '=' +
402 Encode(signature); 402 Encode(signature);
403 break; 403 break;
404 default: 404 default:
405 NOTREACHED(); 405 NOTREACHED();
406 } 406 }
407 *signed_text_return = signed_text; 407 *signed_text_return = signed_text;
408 } 408 }
409 return is_signed; 409 return is_signed;
410 } 410 }
OLDNEW
« no previous file with comments | « chrome/browser/internal_auth.cc ('k') | crypto/hmac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698