diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/chrome/services/sharing | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/chrome/services/sharing')
9 files changed, 518 insertions, 0 deletions
diff --git a/chromium/chrome/services/sharing/BUILD.gn b/chromium/chrome/services/sharing/BUILD.gn index 2e78dd96183..7d3500d4f39 100644 --- a/chromium/chrome/services/sharing/BUILD.gn +++ b/chromium/chrome/services/sharing/BUILD.gn @@ -28,6 +28,7 @@ source_set("sharing") { ] deps = [ + "nearby_decoder", "//jingle:webrtc_glue", "//third_party/webrtc_overrides:webrtc_component", ] diff --git a/chromium/chrome/services/sharing/nearby_decoder/BUILD.gn b/chromium/chrome/services/sharing/nearby_decoder/BUILD.gn new file mode 100644 index 00000000000..6b7666f303d --- /dev/null +++ b/chromium/chrome/services/sharing/nearby_decoder/BUILD.gn @@ -0,0 +1,47 @@ +# Copyright 2020 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//testing/libfuzzer/fuzzer_test.gni") + +source_set("nearby_decoder") { + sources = [ + "advertisement.cc", + "advertisement.h", + "nearby_decoder.cc", + "nearby_decoder.h", + ] + + deps = [ "//chrome/services/sharing/nearby_decoder/proto" ] + + public_deps = [ + "//base", + "//chrome/services/sharing/public/mojom", + "//mojo/public/cpp/bindings", + ] +} + +source_set("unit_tests") { + testonly = true + + sources = [ + "advertisement_unittest.cc", + "nearby_decoder_unittest.cc", + ] + + deps = [ + ":nearby_decoder", + "//base/test:test_support", + "//testing/gmock", + "//testing/gtest", + ] +} + +fuzzer_test("nearby_decoder_fuzzer") { + sources = [ "nearby_decoder_fuzzer.cc" ] + deps = [ + ":nearby_decoder", + "//base", + "//mojo/core/embedder", + ] +} diff --git a/chromium/chrome/services/sharing/nearby_decoder/proto/BUILD.gn b/chromium/chrome/services/sharing/nearby_decoder/proto/BUILD.gn new file mode 100644 index 00000000000..eccfabf7f61 --- /dev/null +++ b/chromium/chrome/services/sharing/nearby_decoder/proto/BUILD.gn @@ -0,0 +1,16 @@ +# Copyright 2020 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import("//third_party/protobuf/proto_library.gni") + +group("proto_lite") { + public_deps = [ + ":proto", + "//third_party/protobuf:protobuf_lite", + ] +} + +proto_library("proto") { + sources = [ "wire_format.proto" ] +} diff --git a/chromium/chrome/services/sharing/public/mojom/BUILD.gn b/chromium/chrome/services/sharing/public/mojom/BUILD.gn index be3e851d409..0d6cefed42e 100644 --- a/chromium/chrome/services/sharing/public/mojom/BUILD.gn +++ b/chromium/chrome/services/sharing/public/mojom/BUILD.gn @@ -3,11 +3,15 @@ import("//mojo/public/tools/bindings/mojom.gni") mojom("mojom") { sources = [ "nearby_connections.mojom", + "nearby_connections_types.mojom", + "nearby_decoder.mojom", + "nearby_decoder_types.mojom", "sharing.mojom", "webrtc.mojom", ] public_deps = [ + "//device/bluetooth/public/mojom:deprecated_experimental_interfaces", "//mojo/public/mojom/base", "//services/network/public/mojom", "//url/mojom:url_mojom_gurl", diff --git a/chromium/chrome/services/sharing/public/mojom/nearby_connections.mojom b/chromium/chrome/services/sharing/public/mojom/nearby_connections.mojom index 1ac9134495d..3cf7aa72359 100644 --- a/chromium/chrome/services/sharing/public/mojom/nearby_connections.mojom +++ b/chromium/chrome/services/sharing/public/mojom/nearby_connections.mojom @@ -4,6 +4,9 @@ module location.nearby.connections.mojom; +import "chrome/services/sharing/public/mojom/nearby_connections_types.mojom"; +import "device/bluetooth/public/mojom/adapter.mojom"; + // Main interface to control the NearbyConnections library. Implemented in a // sandboxed process. This interface is used by the browser process to connect // to remote devices and send / receive raw data packets. Parsing of those @@ -18,4 +21,14 @@ interface NearbyConnections { // process and called from a sandboxed process typically at startup to get all // available mediums. interface NearbyConnectionsHost { + // Gets the current Bluetooth adapter from the host. + // There are three cases for the return value: + // 1) If Bluetooth is not supported by Chrome on the OS (see + // BluetoothAdapterFactory::IsBluetoothSupported) we return a null remote. + // 2) If Bluetooth is supported by Chrome on the OS but there is not a valid + // adapter, we return an adapter with the AdapterInfo.present=false because + // this is the way BluetoothAdapterFactory currently behaves. + // 3) If Bluetooth is supported by Chrome on the OS and there is valid adapter + // we return an adapter instance with the AdapterInfo.present=true. + GetBluetoothAdapter() => (pending_remote<bluetooth.mojom.Adapter>? adapter); }; diff --git a/chromium/chrome/services/sharing/public/mojom/nearby_connections_types.mojom b/chromium/chrome/services/sharing/public/mojom/nearby_connections_types.mojom new file mode 100644 index 00000000000..4442143eaac --- /dev/null +++ b/chromium/chrome/services/sharing/public/mojom/nearby_connections_types.mojom @@ -0,0 +1,201 @@ +// Copyright 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +module location.nearby.connections.mojom; + +import "mojo/public/mojom/base/file.mojom"; + +// Generic result status of NearbyConnections API calls. +enum Status { + // The operation was successful. + kSuccess, + // The operation failed, without any more information. + kError, + // The app called an API method out of order (i.e. another method is expected + // to be called first). + kOutOfOrderApiCall, + // The app already has active operations (advertising, discovering, or + // connected to other devices) with another Strategy. Stop these operations on + // the current Strategy before trying to advertise or discover with a new + // Strategy. + kAlreadyHaveActiveStrategy, + // The app is already advertising; call StopAdvertising() before trying to + // advertise again. + kAlreadyAdvertising, + // The app is already discovering; call StopDiscovery() before trying to + // discover again. + kAlreadyDiscovering, + // An attempt to read from/write to a connected remote endpoint failed. If + // this occurs repeatedly, consider invoking DisconnectFromEndpoint(). + kEndpointIOError, + // An attempt to interact with a remote endpoint failed because it's unknown + // to us -- it's either an endpoint that was never discovered, or an endpoint + // that never connected to us (both of which are indicative of bad input from + // the client app). + kEndpointUnknown, + // The remote endpoint rejected the connection request. + kConnectionRejected, + // The app is already connected to the specified endpoint. Multiple + // connections to a remote endpoint cannot be maintained simultaneously. + kAlreadyConnectedToEndpoint, + // The remote endpoint is not connected; messages cannot be sent to it. + kNotConnectedToEndpoint, + // There was an error trying to use the device's Bluetooth/WiFi/NFC + // capabilities. + kRadioError, + // An attempt to interact with an in-flight Payload failed because it's + // unknown to us. + kPayloadUnknown, +}; + +// Information about a connection that is being initiated. +struct ConnectionInfo { + // The name of the remote device we're connecting to. + string remote_endpoint_name; + // A short human-readable authentication token that has been given to both + // devices. + string authentication_token; + // The raw (significantly longer) version of the authentication token of + // authentication_token -- this is intended for headless authentication, + // typically on devices with no output capabilities, where the authentication + // is purely programmatic and does not have the luxury of human intervention. + array<uint8> raw_authentication_token; + // True if the connection request was initiated from a remote device. False if + // this device was the one to try and initiate the connection. + bool is_incoming_connection; + // Information that represents the remote device. + array<uint8> endpoint_info; +}; + +// Information about an endpoint when it's discovered. +struct DiscoveredEndpointInfo { + // The ID of the service advertised by the remote endpoint. + string service_id; + // The human readable name of the remote endpoint. + string endpoint_name; + // Information advertised by the remote endpoint. + array<uint8> endpoint_info; +}; + +// The Strategy to be used when discovering or advertising to Nearby devices. +// The Strategy defines the connectivity requirements for the device, and the +// topology constraints of the connection. +enum Strategy { + // Peer-to-peer strategy that supports an M-to-N, or cluster-shaped, + // connection topology. In other words, this enables connecting amorphous + // clusters of devices within radio range (~100m), where each device can both + // initiate outgoing connections to M other devices and accept incoming + // connections from N other devices. + kP2pCluster, + // Peer-to-peer strategy that supports a 1-to-N, or star-shaped, connection + // topology. In other words, this enables connecting devices within radio + // range (~100m) in a star shape, where each device can, at any given time, + // play the role of either a hub (where it can accept incoming connections + // from N other devices), or a spoke (where it can initiate an outgoing + // connection to a single hub), but not both. + kP2pStar, + // Peer-to-peer strategy that supports a 1-to-1 connection topology. In other + // words, this enables connecting to a single device within radio range + // (~100m). This strategy will give the absolute highest bandwidth, but will + // not allow multiple connections at a time. + kP2pPointToPoint, +}; + +// Options for a call to NearbyConnections::StartAdvertising(). +struct AdvertisingOptions { + // The strategy to use for advertising. Must match the strategy used in + // DiscoveryOptions for remote devices to see this advertisement. + Strategy strategy; + // By default, this option is true. If false, we will not attempt to upgrade + // the bandwidth until a call to InitiateBandwidthUpgrade() is made. + bool auto_upgrade_bandwidth = true; + // By default, this option is true. If false, restrictions on topology will be + // ignored. This allows you treat all strategies as kP2pCluster (N to M), + // although bandwidth will be severely throttled if you don't maintain the + // original topology. When used in conjunction with auto_upgrade_bandwidth, + // you can initially connect as a kP2pCluster and then trim connections until + // you match kP2pStar or kP2pPointToPoint before upgrading the bandwidth. + bool enforce_topology_constraints = true; +}; + +// Options for a call to NearbyConnections::StartDiscovery(). +struct DiscoveryOptions { + // The strategy to use for discovering. Must match the strategy used in + // AdvertisingOptions in order to see advertisements. + Strategy strategy; +}; + +// A simple payload containing raw bytes. +struct BytesPayload { + // The bytes of this payload. + array<uint8> bytes; +}; + +// A file payload representing a file. +struct FilePayload { + // The file to which this payload points to. When sending this payload, the + // NearbyConnections library reads from this file. When receiving a file + // payload it writes to this file. + mojo_base.mojom.File file; +}; + +// Union of all supported payload types. +union PayloadContent { + // A Payload consisting of a single byte array. + BytesPayload bytes; + // A Payload representing a file on the device. + FilePayload file; +}; + +// A Payload sent between devices. Payloads sent with a particular content type +// will be received as that same type on the other device, e.g. the content for +// a Payload of type BytesPayload must be received by reading from the bytes +// field returned by Payload::content::bytes. +struct Payload { + // A unique identifier for this payload. Generated by the sender of the + // payload and used to keep track of the transfer progress. + int64 id; + // The content of this payload which is one of multiple types, see + // PayloadContent for all possible types. + PayloadContent content; +}; + +// The status of the payload transfer at the time of this update. +enum PayloadStatus { + // The payload transfer has completed successfully. + kSuccess, + // The payload transfer failed. + kFailure, + // The payload transfer is still in progress. + kInProgress, + // The payload transfer has been canceled. + kCanceled, +}; + +// Describes the status for an active Payload transfer, either incoming or +// outgoing. Delivered to PayloadListener::OnPayloadTransferUpdate. +struct PayloadTransferUpdate { + // The ID for the payload related to this update. Clients should match this + // with Payload::id. + int64 payload_id; + // The status of this payload transfer. Always starts with kInProgress and + // ends with one of kSuccess, kFailure or kCanceled. + PayloadStatus status; + // The total expected bytes of this transfer. + uint64 total_bytes; + // The number of bytes transferred so far. + uint64 bytes_transferred; +}; + +// Bandwidth quality of a connection. +enum BandwidthQuality { + // Unknown connection quality. + kUnknown, + // Low quality, e.g. connected via NFC or BLE. + kLow, + // Medium quality, e.g. connected via Bluetooth Classic. + kMedium, + // High quality, e.g. connected via WebRTC or WiFi LAN. + kHigh, +}; diff --git a/chromium/chrome/services/sharing/public/mojom/nearby_decoder.mojom b/chromium/chrome/services/sharing/public/mojom/nearby_decoder.mojom new file mode 100644 index 00000000000..b8e85d95cdf --- /dev/null +++ b/chromium/chrome/services/sharing/public/mojom/nearby_decoder.mojom @@ -0,0 +1,21 @@ +// Copyright 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +module sharing.mojom; + +import "chrome/services/sharing/public/mojom/nearby_decoder_types.mojom"; +import "mojo/public/mojom/base/time.mojom"; + +// Decode raw data into structured. Runs in the sharing utility process. +// Called by the NearbySharingService running in the browser process. +interface NearbySharingDecoder { + // Decode the advertisement. The advertisement is sent by a device in + // the receiver mode, and may be advertising to everyone or only + // known contacts. + DecodeAdvertisement(array<uint8> data) => (Advertisement? advertisement); + + // Decode a payload frame. The frame may be one of several types, and is + // used by NearbySharingService to manage the connections protocol. + DecodeFrame(array<uint8> data) => (Frame? frame); +}; diff --git a/chromium/chrome/services/sharing/public/mojom/nearby_decoder_types.mojom b/chromium/chrome/services/sharing/public/mojom/nearby_decoder_types.mojom new file mode 100644 index 00000000000..7c59fb1af35 --- /dev/null +++ b/chromium/chrome/services/sharing/public/mojom/nearby_decoder_types.mojom @@ -0,0 +1,210 @@ +// Copyright 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +module sharing.mojom; + +import "mojo/public/mojom/base/time.mojom"; + +// An advertisement send by a device in receiving mode. +struct Advertisement { + // Random data erived from a device's private key. + array<uint8, 2> salt; + + // Derived from a device's private key. Identifying data for the device. + array<uint8, 14> encrypted_metadata; + + // If present, the device is visible to everyone rather than contacts only. + string? device_name; +}; + +// A frame used when sending messages over the wire. +union Frame { + // A frame of one possible type. + V1Frame v1; +}; + +// The possible types of a frame. +union V1Frame { + IntroductionFrame introduction; + + ConnectionResponseFrame connection_response; + + PairedKeyEncryptionFrame paired_key_encryption; + + PairedKeyResultFrame paired_key_result; + + CertificateInfoFrame certificate_info; +}; + +// An introduction packet sent by the sending side. Contains a list of files +// they'd like to share. +struct IntroductionFrame { + // Description of a file to be sent. + array<FileMetadata> file_metadata; + + // Description of text to be sent. + array<TextMetadata> text_metadata; + + // The required app package to open the content. May be null. + string? required_package; + + // Credentials of the wifi network. + array<WifiCredentialsMetadata> wifi_credentials_metadata; +}; + +// File metadata. Does not include the actual bytes of the shared file +// in transit. +struct FileMetadata { + enum Type { + kUnknown = 0, + kImage = 1, + kVideo = 2, + kApp = 3, + kAudio = 4 + }; + + // The human readable name of this file (eg. 'Cookbook.pdf'). + string name; + + // The type of file (eg. 'kImage' from 'dog.jpg'). Specifying a type helps + // provide a richer experience on the receiving side. + Type type = kUnknown; + + // The FILE payload id that will be sent as a follow up containing the actual + // bytes of the file. + int64 payload_id; + + // The total size of the file. + uint64 size; + + // The mimeType of file (eg. 'image/jpeg' from 'dog.jpg'). Specifying a + // mimeType helps provide a richer experience on receiving side. + string mime_type = "application/octet-stream"; +}; + +// Text metadata. Does not include the actual bytes of the text in transit. +struct TextMetadata { + enum Type { + kUnknown = 0, + kText = 1, + // Open with browsers. + kUrl = 2, + // Open with map apps. + kAddress = 3, + // Dial. + kPhoneNumber = 4 + }; + + // The title of the text content. + string text_title; + + // The type of text (phone number, url, address, or plain text). + Type type = kUnknown; + + // The BYTE payload id that will be sent as a follow up containing the actual + // bytes of the text. + int64 payload_id; + + // The size of the text content. + uint64 size; +}; + +// Wifi credentails metadata. Describes the wifi network to be used by the +// connection. +struct WifiCredentialsMetadata { + enum SecurityType { + kUnknownSecurityType = 0, + kOpen = 1, + kWpaPsk = 2, + kWep = 3 + }; + + // The Wifi network name. This will be sent in introduction. + string ssid; + + // The security type of network (OPEN, WPA_PSK, WEP). + SecurityType security_type = kUnknownSecurityType; + + // The BYTE payload id that will be sent as a follow up containing the + // password. + int64 payload_id; +}; + +// A response packet sent by the receiving side. Accepts or rejects the list of +// files. +struct ConnectionResponseFrame { + enum Status { + kUnknown = 0, + kAccept = 1, + kReject = 2, + kNotEnoughSpace = 3, + kUnsupportedAttachmentType = 4, + kTimedOut = 5 + }; + + // The receiving side's response. + Status status; +}; + +// A paired key encryption packet sent between devices, contains signed data. +struct PairedKeyEncryptionFrame { + // The encrypted data in byte array format. + // The size of byte array generated by signing should be 72. + array<uint8> signed_data; + + // The HMAC 256 based HKDF of UKEY2 authentication key with + // authenticity_key salt. + // The size of bytes of secret id after hash should be 6. + array<uint8> secret_id_hash; +}; + +// A paired key verification result packet sent between devices. +struct PairedKeyResultFrame { + enum Status { + kUnknown = 0, + kSuccess = 1, + kFail = 2, + kUnable = 3 + }; + + // The verification result. + Status status; +}; + +// A package containing certificate info to be shared to remote device offline. +struct CertificateInfoFrame { + // The public certificates to be shared with remote devices. + array<PublicCertificate> public_certificate; +}; + +// A public certificate from the local device. +struct PublicCertificate { + // The unique id of the public certificate. + array<uint8> secret_id; + + // A bytes representation of a Secret Key owned by contact, to decrypt the + // metadata_key stored within the advertisement. + // The size should be 32. + array<uint8> authenticity_key; + + // A bytes representation a public key of X509Certificate, owned by contact, + // to decrypt UKEY2 (from Nearby Connections API) as a hand shake in + // contact verification phase. + array<uint8> public_key; + + // Time from epoch when this certificate becomes effective. + mojo_base.mojom.Time start_time; + + // Time from epoch when this certificate expires. + mojo_base.mojom.Time end_time; + + // The encrypted metadata in bytes, contains personal information of the + // device/user who created this certificate. Needs to be decrypted into bytes, + // and converted back to EncryptedMetadata object to access fields. + array<uint8> encrypted_metadata_bytes; + + // The tag for verifying metadata_encryption_key. + // The size should be 32. + array<uint8> metadata_encryption_key_tag; +}; diff --git a/chromium/chrome/services/sharing/public/mojom/sharing.mojom b/chromium/chrome/services/sharing/public/mojom/sharing.mojom index 6718bac85fc..300955eb765 100644 --- a/chromium/chrome/services/sharing/public/mojom/sharing.mojom +++ b/chromium/chrome/services/sharing/public/mojom/sharing.mojom @@ -5,6 +5,7 @@ module sharing.mojom; import "chrome/services/sharing/public/mojom/nearby_connections.mojom"; +import "chrome/services/sharing/public/mojom/nearby_decoder.mojom"; import "chrome/services/sharing/public/mojom/webrtc.mojom"; import "services/network/public/mojom/p2p.mojom"; import "services/network/public/mojom/mdns_responder.mojom"; @@ -41,4 +42,8 @@ interface Sharing { host) => (pending_remote<location.nearby.connections.mojom.NearbyConnections> connections); + + // Creates a new Nearby Sharing Decoder. + CreateNearbySharingDecoder() + => (pending_remote<sharing.mojom.NearbySharingDecoder> decoder); }; |