| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |