1// Copyright 2019 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5syntax = "proto2";
6
7option optimize_for = LITE_RUNTIME;
8
9// TODO(crbug.com/openscreen/90): Rename to openscreen.cast, to update to the
10// current namespacing of the library. Also, this file should probably be moved
11// to the public directory. And, all of this will have to be coordinated with a
12// DEPS roll in Chromium (since Chromium code depends on this).
13package cast.channel;
14
15message CastMessage {
16  // Always pass a version of the protocol for future compatibility
17  // requirements.
18  enum ProtocolVersion {
19    CASTV2_1_0 = 0;
20    CASTV2_1_1 = 1;  // message chunking support (deprecated).
21    CASTV2_1_2 = 2;  // reworked message chunking.
22    CASTV2_1_3 = 3;  // binary payload over utf8.
23  }
24  required ProtocolVersion protocol_version = 1;
25
26  // source and destination ids identify the origin and destination of the
27  // message.  They are used to route messages between endpoints that share a
28  // device-to-device channel.
29  //
30  // For messages between applications:
31  //   - The sender application id is a unique identifier generated on behalf of
32  //     the sender application.
33  //   - The receiver id is always the the session id for the application.
34  //
35  // For messages to or from the sender or receiver platform, the special ids
36  // 'sender-0' and 'receiver-0' can be used.
37  //
38  // For messages intended for all endpoints using a given channel, the
39  // wildcard destination_id '*' can be used.
40  required string source_id = 2;
41  required string destination_id = 3;
42
43  // This is the core multiplexing key.  All messages are sent on a namespace
44  // and endpoints sharing a channel listen on one or more namespaces.  The
45  // namespace defines the protocol and semantics of the message.
46  required string namespace = 4;
47
48  // Encoding and payload info follows.
49
50  // What type of data do we have in this message.
51  enum PayloadType {
52    STRING = 0;
53    BINARY = 1;
54  }
55  required PayloadType payload_type = 5;
56
57  // Depending on payload_type, exactly one of the following optional fields
58  // will always be set.
59  optional string payload_utf8 = 6;
60  optional bytes payload_binary = 7;
61
62  // --- Begin new 1.1 fields.
63
64  // Flag indicating whether there are more chunks to follow for this message.
65  // If the flag is false or is not present, then this is the last (or only)
66  // chunk of the message.
67  optional bool continued = 8;
68
69  // If this is a chunk of a larger message, and the remaining length of the
70  // message payload (the sum of the lengths of the payloads of the remaining
71  // chunks) is known, this field will indicate that length. For a given
72  // chunked message, this field should either be present in all of the chunks,
73  // or in none of them.
74  optional uint32 remaining_length = 9;
75}
76
77enum SignatureAlgorithm {
78  UNSPECIFIED = 0;
79  RSASSA_PKCS1v15 = 1;
80  RSASSA_PSS = 2;
81}
82
83enum HashAlgorithm {
84  SHA1 = 0;
85  SHA256 = 1;
86}
87
88// Messages for authentication protocol between a sender and a receiver.
89message AuthChallenge {
90  optional SignatureAlgorithm signature_algorithm = 1
91      [default = RSASSA_PKCS1v15];
92  optional bytes sender_nonce = 2;
93  optional HashAlgorithm hash_algorithm = 3 [default = SHA1];
94}
95
96message AuthResponse {
97  required bytes signature = 1;
98  required bytes client_auth_certificate = 2;
99  repeated bytes intermediate_certificate = 3;
100  optional SignatureAlgorithm signature_algorithm = 4
101      [default = RSASSA_PKCS1v15];
102  optional bytes sender_nonce = 5;
103  optional HashAlgorithm hash_algorithm = 6 [default = SHA1];
104  optional bytes crl = 7;
105}
106
107message AuthError {
108  enum ErrorType {
109    INTERNAL_ERROR = 0;
110    NO_TLS = 1;  // The underlying connection is not TLS
111    SIGNATURE_ALGORITHM_UNAVAILABLE = 2;
112  }
113  required ErrorType error_type = 1;
114}
115
116message DeviceAuthMessage {
117  // Request fields
118  optional AuthChallenge challenge = 1;
119  // Response fields
120  optional AuthResponse response = 2;
121  optional AuthError error = 3;
122}
123