| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/gcm_driver/crypto/encryption_header_parsers.h" | 5 #include "components/gcm_driver/crypto/encryption_header_parsers.h" |
| 6 | 6 |
| 7 #include "base/base64url.h" | 7 #include "base/base64url.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/string_piece.h" | 9 #include "base/strings/string_piece.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 // This means that the three supported parameters are: | 68 // This means that the three supported parameters are: |
| 69 // | 69 // |
| 70 // [ "keyid" "=" string ] | 70 // [ "keyid" "=" string ] |
| 71 // [ ";" "salt" "=" base64url ] | 71 // [ ";" "salt" "=" base64url ] |
| 72 // [ ";" "rs" "=" octet-count ] | 72 // [ ";" "rs" "=" octet-count ] |
| 73 bool ParseEncryptionHeaderValuesImpl(std::string::const_iterator input_begin, | 73 bool ParseEncryptionHeaderValuesImpl(std::string::const_iterator input_begin, |
| 74 std::string::const_iterator input_end, | 74 std::string::const_iterator input_end, |
| 75 EncryptionHeaderValues* values) { | 75 EncryptionHeaderValues* values) { |
| 76 net::HttpUtil::NameValuePairsIterator name_value_pairs( | 76 net::HttpUtil::NameValuePairsIterator name_value_pairs( |
| 77 input_begin, input_end, ';', | 77 input_begin, input_end, ';', |
| 78 net::HttpUtil::NameValuePairsIterator::VALUES_NOT_OPTIONAL); | 78 net::HttpUtil::NameValuePairsIterator::Values::NOT_OPTIONAL, |
| 79 net::HttpUtil::NameValuePairsIterator::Quotes::NOT_STRICT); |
| 79 | 80 |
| 80 while (name_value_pairs.GetNext()) { | 81 while (name_value_pairs.GetNext()) { |
| 81 const base::StringPiece name(name_value_pairs.name_begin(), | 82 const base::StringPiece name(name_value_pairs.name_begin(), |
| 82 name_value_pairs.name_end()); | 83 name_value_pairs.name_end()); |
| 83 | 84 |
| 84 if (base::LowerCaseEqualsASCII(name, "keyid")) { | 85 if (base::LowerCaseEqualsASCII(name, "keyid")) { |
| 85 values->keyid.assign(name_value_pairs.value_begin(), | 86 values->keyid.assign(name_value_pairs.value_begin(), |
| 86 name_value_pairs.value_end()); | 87 name_value_pairs.value_end()); |
| 87 } else if (base::LowerCaseEqualsASCII(name, "salt")) { | 88 } else if (base::LowerCaseEqualsASCII(name, "salt")) { |
| 88 if (!ValueToDecodedString(name_value_pairs.value_begin(), | 89 if (!ValueToDecodedString(name_value_pairs.value_begin(), |
| (...skipping 27 matching lines...) Expand all Loading... |
| 116 // This means that the three supported parameters are: | 117 // This means that the three supported parameters are: |
| 117 // | 118 // |
| 118 // [ "keyid" "=" string ] | 119 // [ "keyid" "=" string ] |
| 119 // [ ";" "aesgcm128" "=" base64url ] | 120 // [ ";" "aesgcm128" "=" base64url ] |
| 120 // [ ";" "dh" "=" base64url ] | 121 // [ ";" "dh" "=" base64url ] |
| 121 bool ParseCryptoKeyHeaderValuesImpl(std::string::const_iterator input_begin, | 122 bool ParseCryptoKeyHeaderValuesImpl(std::string::const_iterator input_begin, |
| 122 std::string::const_iterator input_end, | 123 std::string::const_iterator input_end, |
| 123 CryptoKeyHeaderValues* values) { | 124 CryptoKeyHeaderValues* values) { |
| 124 net::HttpUtil::NameValuePairsIterator name_value_pairs( | 125 net::HttpUtil::NameValuePairsIterator name_value_pairs( |
| 125 input_begin, input_end, ';', | 126 input_begin, input_end, ';', |
| 126 net::HttpUtil::NameValuePairsIterator::VALUES_NOT_OPTIONAL); | 127 net::HttpUtil::NameValuePairsIterator::Values::NOT_OPTIONAL, |
| 128 net::HttpUtil::NameValuePairsIterator::Quotes::NOT_STRICT); |
| 127 | 129 |
| 128 while (name_value_pairs.GetNext()) { | 130 while (name_value_pairs.GetNext()) { |
| 129 const base::StringPiece name(name_value_pairs.name_begin(), | 131 const base::StringPiece name(name_value_pairs.name_begin(), |
| 130 name_value_pairs.name_end()); | 132 name_value_pairs.name_end()); |
| 131 | 133 |
| 132 if (base::LowerCaseEqualsASCII(name, "keyid")) { | 134 if (base::LowerCaseEqualsASCII(name, "keyid")) { |
| 133 values->keyid.assign(name_value_pairs.value_begin(), | 135 values->keyid.assign(name_value_pairs.value_begin(), |
| 134 name_value_pairs.value_end()); | 136 name_value_pairs.value_end()); |
| 135 } else if (base::LowerCaseEqualsASCII(name, "aesgcm128")) { | 137 } else if (base::LowerCaseEqualsASCII(name, "aesgcm128")) { |
| 136 if (!ValueToDecodedString(name_value_pairs.value_begin(), | 138 if (!ValueToDecodedString(name_value_pairs.value_begin(), |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 } | 195 } |
| 194 | 196 |
| 195 candidate_values.push_back(candidate_value); | 197 candidate_values.push_back(candidate_value); |
| 196 } | 198 } |
| 197 | 199 |
| 198 values->swap(candidate_values); | 200 values->swap(candidate_values); |
| 199 return true; | 201 return true; |
| 200 } | 202 } |
| 201 | 203 |
| 202 } // namespace gcm | 204 } // namespace gcm |
| OLD | NEW |