| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_CAST_PRIVATE_DELEGA
TE_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_CAST_PRIVATE_DELEGA
TE_H_ |
| 6 #define EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_CAST_PRIVATE_DELEGA
TE_H_ | 6 #define EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_CAST_PRIVATE_DELEGA
TE_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 8 #include <string> | 9 #include <string> |
| 10 #include <vector> |
| 9 | 11 |
| 10 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/macros.h" |
| 11 #include "extensions/common/api/networking_private.h" | 14 #include "extensions/common/api/networking_private.h" |
| 12 | 15 |
| 13 namespace extensions { | 16 namespace extensions { |
| 14 | 17 |
| 15 // Delegate interface that provides crypto methods needed to verify cast | 18 // Delegate interface that provides crypto methods needed to verify cast |
| 16 // certificates and encrypt data using public key derived from the verified | 19 // certificates and encrypt data using public key derived from the verified |
| 17 // certificate. | 20 // certificate. |
| 18 // TODO(tbarzic): This is to be used during migration of | 21 // TODO(tbarzic): This is to be used during migration of |
| 19 // networkingPrivate.verify* methods to networking.castPrivate API to share | 22 // networkingPrivate.verify* methods to networking.castPrivate API to share |
| 20 // verification logic shared between networkingPrivate and | 23 // verification logic shared between networkingPrivate and |
| 21 // networking.castPrivate API. When the deprecated networkingPrivate methods | 24 // networking.castPrivate API. When the deprecated networkingPrivate methods |
| 22 // are removed, this interface should be removed, too. | 25 // are removed, this interface should be removed, too. |
| 23 class NetworkingCastPrivateDelegate { | 26 class NetworkingCastPrivateDelegate { |
| 24 public: | 27 public: |
| 25 virtual ~NetworkingCastPrivateDelegate() {} | 28 virtual ~NetworkingCastPrivateDelegate() {} |
| 26 | 29 |
| 27 using FailureCallback = base::Callback<void(const std::string& error)>; | 30 using FailureCallback = base::Callback<void(const std::string& error)>; |
| 28 using VerifiedCallback = base::Callback<void(bool is_valid)>; | 31 using VerifiedCallback = base::Callback<void(bool is_valid)>; |
| 29 using DataCallback = base::Callback<void(const std::string& encrypted_data)>; | 32 using DataCallback = base::Callback<void(const std::string& encrypted_data)>; |
| 30 | 33 |
| 31 // Verifies that data provided in |properties| authenticates a cast device. | 34 // API independent wrapper around cast device verification properties. |
| 32 virtual void VerifyDestination( | 35 class Credentials { |
| 33 const api::networking_private::VerificationProperties& properties, | 36 public: |
| 34 const VerifiedCallback& success_callback, | 37 Credentials(const std::string& certificate, |
| 35 const FailureCallback& failure_callback) = 0; | 38 const std::vector<std::string>& intermediate_certificates, |
| 39 const std::string& signed_data, |
| 40 const std::string& device_ssid, |
| 41 const std::string& device_serial, |
| 42 const std::string& device_bssid, |
| 43 const std::string& public_key, |
| 44 const std::string& nonce); |
| 45 ~Credentials(); |
| 36 | 46 |
| 37 // Verifies that data provided in |properties| authenticates a cast device. | 47 const std::string& certificate() const { return certificate_; } |
| 48 const std::vector<std::string>& intermediate_certificates() const { |
| 49 return intermediate_certificates_; |
| 50 } |
| 51 const std::string& signed_data() const { return signed_data_; } |
| 52 const std::string& unsigned_data() const { return unsigned_data_; } |
| 53 const std::string& device_bssid() const { return device_bssid_; } |
| 54 const std::string& public_key() const { return public_key_; } |
| 55 |
| 56 private: |
| 57 std::string certificate_; |
| 58 std::vector<std::string> intermediate_certificates_; |
| 59 std::string signed_data_; |
| 60 std::string unsigned_data_; |
| 61 std::string device_bssid_; |
| 62 std::string public_key_; |
| 63 |
| 64 private: |
| 65 DISALLOW_COPY_AND_ASSIGN(Credentials); |
| 66 }; |
| 67 |
| 68 // Verifies that data provided in |credentials| authenticates a cast device. |
| 69 virtual void VerifyDestination(std::unique_ptr<Credentials> credentials, |
| 70 const VerifiedCallback& success_callback, |
| 71 const FailureCallback& failure_callback) = 0; |
| 72 |
| 73 // Verifies that data provided in |credentials| authenticates a cast device. |
| 38 // If the device is verified as a cast device, it fetches credentials of the | 74 // If the device is verified as a cast device, it fetches credentials of the |
| 39 // network identified with |network_guid| and returns the network credentials | 75 // network identified with |network_guid| and returns the network credentials |
| 40 // encrypted with a public key derived from |properties|. | 76 // encrypted with a public key derived from |credentials|. |
| 41 virtual void VerifyAndEncryptCredentials( | 77 virtual void VerifyAndEncryptCredentials( |
| 42 const std::string& network_guid, | 78 const std::string& network_guid, |
| 43 const api::networking_private::VerificationProperties& properties, | 79 std::unique_ptr<Credentials> credentials, |
| 44 const DataCallback& encrypted_credetials_callback, | 80 const DataCallback& encrypted_credetials_callback, |
| 45 const FailureCallback& failure_callback) = 0; | 81 const FailureCallback& failure_callback) = 0; |
| 46 | 82 |
| 47 // Verifies that data provided in |properties| authenticates a cast device. | 83 // Verifies that data provided in |credentials| authenticates a cast device. |
| 48 // If the device is verified as a cast device, it returns |data| encrypted | 84 // If the device is verified as a cast device, it returns |data| encrypted |
| 49 // with a public key derived from |properties|. | 85 // with a public key derived from |credentials|. |
| 50 virtual void VerifyAndEncryptData( | 86 virtual void VerifyAndEncryptData( |
| 51 const std::string& data, | 87 const std::string& data, |
| 52 const api::networking_private::VerificationProperties& properties, | 88 std::unique_ptr<Credentials> credentials, |
| 53 const DataCallback& enrypted_data_callback, | 89 const DataCallback& enrypted_data_callback, |
| 54 const FailureCallback& failure_callback) = 0; | 90 const FailureCallback& failure_callback) = 0; |
| 55 }; | 91 }; |
| 56 | 92 |
| 57 } // namespace extensions | 93 } // namespace extensions |
| 58 | 94 |
| 59 #endif // EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_CAST_PRIVATE_DEL
EGATE_H_ | 95 #endif // EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_CAST_PRIVATE_DEL
EGATE_H_ |
| OLD | NEW |