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 "net/http/http_mac_signature.h" | 5 #include "net/http/http_mac_signature.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 | 125 |
126 *header = "MAC id=\"" + id_ + | 126 *header = "MAC id=\"" + id_ + |
127 "\", nonce=\"" + age + ":" + nonce + | 127 "\", nonce=\"" + age + ":" + nonce + |
128 "\", mac=\"" + mac + "\""; | 128 "\", mac=\"" + mac + "\""; |
129 return true; | 129 return true; |
130 } | 130 } |
131 | 131 |
132 std::string HttpMacSignature::GenerateNormalizedRequest( | 132 std::string HttpMacSignature::GenerateNormalizedRequest( |
133 const std::string& age, | 133 const std::string& age, |
134 const std::string& nonce) { | 134 const std::string& nonce) { |
135 static const std::string kNewLine = "\n"; | 135 const std::string kNewLine = "\n"; |
136 | 136 |
137 std::string normalized_request = age + ":" + nonce + kNewLine; | 137 std::string normalized_request = age + ":" + nonce + kNewLine; |
138 normalized_request += method_ + kNewLine; | 138 normalized_request += method_ + kNewLine; |
139 normalized_request += request_uri_ + kNewLine; | 139 normalized_request += request_uri_ + kNewLine; |
140 normalized_request += host_ + kNewLine; | 140 normalized_request += host_ + kNewLine; |
141 normalized_request += port_ + kNewLine; | 141 normalized_request += port_ + kNewLine; |
142 normalized_request += kNewLine; | 142 normalized_request += kNewLine; |
143 normalized_request += kNewLine; | 143 normalized_request += kNewLine; |
144 | 144 |
145 return normalized_request; | 145 return normalized_request; |
(...skipping 23 matching lines...) Expand all Loading... |
169 if (!base::Base64Encode(signature, &encoded_signature)) { | 169 if (!base::Base64Encode(signature, &encoded_signature)) { |
170 NOTREACHED(); | 170 NOTREACHED(); |
171 return false; | 171 return false; |
172 } | 172 } |
173 | 173 |
174 mac->swap(encoded_signature); | 174 mac->swap(encoded_signature); |
175 return true; | 175 return true; |
176 } | 176 } |
177 | 177 |
178 } // namespace net | 178 } // namespace net |
OLD | NEW |