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 #ifndef NET_HTTP_MAC_SIGNATURE_H_ | 5 #ifndef NET_HTTP_MAC_SIGNATURE_H_ |
6 #define NET_HTTP_MAC_SIGNATURE_H_ | 6 #define NET_HTTP_MAC_SIGNATURE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 const base::Time& creation_date, | 32 const base::Time& creation_date, |
33 const std::string& mac_key, | 33 const std::string& mac_key, |
34 const std::string& mac_algorithm); | 34 const std::string& mac_algorithm); |
35 | 35 |
36 // Returns whether this information is valid. | 36 // Returns whether this information is valid. |
37 bool AddHttpInfo(const std::string& method, | 37 bool AddHttpInfo(const std::string& method, |
38 const std::string& request_uri, | 38 const std::string& request_uri, |
39 const std::string& host, | 39 const std::string& host, |
40 int port); | 40 int port); |
41 | 41 |
42 // Returns the value of the Authorization header for use in an HTTP request. | 42 // Generates the Authorization header for use in an HTTP request. If |
43 std::string GenerateAuthorizationHeader(); | 43 // successfully generated, returns true and stores the resultant header in |
| 44 // |*header|. |
| 45 bool GenerateAuthorizationHeader(std::string* header); |
44 | 46 |
45 private: | 47 private: |
46 FRIEND_TEST_ALL_PREFIXES(HttpMacSignatureTest, GenerateHeaderString); | 48 FRIEND_TEST_ALL_PREFIXES(HttpMacSignatureTest, GenerateHeaderString); |
47 FRIEND_TEST_ALL_PREFIXES(HttpMacSignatureTest, GenerateNormalizedRequest); | 49 FRIEND_TEST_ALL_PREFIXES(HttpMacSignatureTest, GenerateNormalizedRequest); |
48 FRIEND_TEST_ALL_PREFIXES(HttpMacSignatureTest, GenerateMAC); | 50 FRIEND_TEST_ALL_PREFIXES(HttpMacSignatureTest, GenerateMAC); |
49 | 51 |
50 std::string GenerateHeaderString(const std::string& age, | 52 bool GenerateHeaderString(const std::string& age, |
51 const std::string& nonce); | 53 const std::string& nonce, |
| 54 std::string* header); |
52 std::string GenerateNormalizedRequest(const std::string& age, | 55 std::string GenerateNormalizedRequest(const std::string& age, |
53 const std::string& nonce); | 56 const std::string& nonce); |
54 std::string GenerateMAC(const std::string& age, | 57 bool GenerateMAC(const std::string& age, |
55 const std::string& nonce); | 58 const std::string& nonce, |
| 59 std::string* mac); |
56 | 60 |
57 std::string id_; | 61 std::string id_; |
58 base::Time creation_date_; | 62 base::Time creation_date_; |
59 std::string mac_key_; | 63 std::string mac_key_; |
60 crypto::HMAC::HashAlgorithm mac_algorithm_; | 64 crypto::HMAC::HashAlgorithm mac_algorithm_; |
61 | 65 |
62 std::string method_; | 66 std::string method_; |
63 std::string request_uri_; | 67 std::string request_uri_; |
64 std::string host_; | 68 std::string host_; |
65 std::string port_; | 69 std::string port_; |
66 // TODO(abarth): body_hash_ | 70 // TODO(abarth): body_hash_ |
67 | 71 |
68 DISALLOW_COPY_AND_ASSIGN(HttpMacSignature); | 72 DISALLOW_COPY_AND_ASSIGN(HttpMacSignature); |
69 }; | 73 }; |
70 | 74 |
71 } // namespace net | 75 } // namespace net |
72 | 76 |
73 #endif // NET_HTTP_MAC_SIGNATURE_H_ | 77 #endif // NET_HTTP_MAC_SIGNATURE_H_ |
OLD | NEW |