| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/api/cast_channel/cast_auth_util.h" | 5 #include "components/cast_channel/cast_auth_util.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/feature_list.h" | 9 #include "base/feature_list.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
| 14 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
| 15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
| 18 #include "components/cast_certificate/cast_cert_validator.h" | 18 #include "components/cast_certificate/cast_cert_validator.h" |
| 19 #include "components/cast_certificate/cast_crl.h" | 19 #include "components/cast_certificate/cast_crl.h" |
| 20 #include "components/cast_channel/cast_message_util.h" |
| 21 #include "components/cast_channel/proto/cast_channel.pb.h" |
| 20 #include "crypto/random.h" | 22 #include "crypto/random.h" |
| 21 #include "extensions/browser/api/cast_channel/cast_message_util.h" | |
| 22 #include "extensions/common/api/cast_channel/cast_channel.pb.h" | |
| 23 #include "net/cert/x509_certificate.h" | 23 #include "net/cert/x509_certificate.h" |
| 24 #include "net/der/parse_values.h" | 24 #include "net/der/parse_values.h" |
| 25 | 25 |
| 26 namespace extensions { | |
| 27 namespace api { | |
| 28 namespace cast_channel { | 26 namespace cast_channel { |
| 29 namespace { | 27 namespace { |
| 30 | 28 |
| 31 const char kParseErrorPrefix[] = "Failed to parse auth message: "; | 29 const char kParseErrorPrefix[] = "Failed to parse auth message: "; |
| 32 | 30 |
| 33 // The maximum number of days a cert can live for. | 31 // The maximum number of days a cert can live for. |
| 34 const int kMaxSelfSignedCertLifetimeInDays = 4; | 32 const int kMaxSelfSignedCertLifetimeInDays = 4; |
| 35 | 33 |
| 36 // The size of the nonce challenge in bytes. | 34 // The size of the nonce challenge in bytes. |
| 37 const int kNonceSizeInBytes = 16; | 35 const int kNonceSizeInBytes = 16; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 } | 160 } |
| 163 | 161 |
| 164 } // namespace | 162 } // namespace |
| 165 | 163 |
| 166 AuthResult::AuthResult() | 164 AuthResult::AuthResult() |
| 167 : error_type(ERROR_NONE), channel_policies(POLICY_NONE) {} | 165 : error_type(ERROR_NONE), channel_policies(POLICY_NONE) {} |
| 168 | 166 |
| 169 AuthResult::AuthResult(const std::string& error_message, ErrorType error_type) | 167 AuthResult::AuthResult(const std::string& error_message, ErrorType error_type) |
| 170 : error_message(error_message), error_type(error_type) {} | 168 : error_message(error_message), error_type(error_type) {} |
| 171 | 169 |
| 172 AuthResult::~AuthResult() { | 170 AuthResult::~AuthResult() {} |
| 173 } | |
| 174 | 171 |
| 175 // static | 172 // static |
| 176 AuthResult AuthResult::CreateWithParseError(const std::string& error_message, | 173 AuthResult AuthResult::CreateWithParseError(const std::string& error_message, |
| 177 ErrorType error_type) { | 174 ErrorType error_type) { |
| 178 return AuthResult(kParseErrorPrefix + error_message, error_type); | 175 return AuthResult(kParseErrorPrefix + error_message, error_type); |
| 179 } | 176 } |
| 180 | 177 |
| 181 // static | 178 // static |
| 182 AuthContext AuthContext::Create() { | 179 AuthContext AuthContext::Create() { |
| 183 return AuthContext(CastNonce::Get()); | 180 return AuthContext(CastNonce::Get()); |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 const cast_crypto::CRLPolicy& crl_policy, | 385 const cast_crypto::CRLPolicy& crl_policy, |
| 389 net::TrustStore* cast_trust_store, | 386 net::TrustStore* cast_trust_store, |
| 390 net::TrustStore* crl_trust_store, | 387 net::TrustStore* crl_trust_store, |
| 391 const base::Time& verification_time) { | 388 const base::Time& verification_time) { |
| 392 return VerifyCredentialsImpl(response, signature_input, crl_policy, | 389 return VerifyCredentialsImpl(response, signature_input, crl_policy, |
| 393 cast_trust_store, crl_trust_store, | 390 cast_trust_store, crl_trust_store, |
| 394 verification_time); | 391 verification_time); |
| 395 } | 392 } |
| 396 | 393 |
| 397 } // namespace cast_channel | 394 } // namespace cast_channel |
| 398 } // namespace api | |
| 399 } // namespace extensions | |
| OLD | NEW |