fork/rust-sdks

git clone https://git.julia.blue/fork/rust-sdks

lukasIOUse proto2 syntax for FFI (#470)e6f2164

main
4.3 KiB154 linesraw
1// Copyright 2023 LiveKit, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15syntax = "proto2";
16
17package livekit.proto;
18option csharp_namespace = "LiveKit.Proto";
19
20// TODO(theomonnom): Should FrameCryptor be stateful on the client side and have their own handle?
21
22enum EncryptionType {
23    NONE = 0;
24    GCM = 1;
25    CUSTOM = 2;
26}
27
28message FrameCryptor {
29    required string participant_identity = 1;
30    required string track_sid = 2;
31    required int32 key_index = 3;
32    required bool enabled = 4;
33}
34
35message KeyProviderOptions {
36    // Only specify if you want to use a shared_key
37    optional bytes shared_key = 1; 
38    required int32 ratchet_window_size = 2;
39    required bytes ratchet_salt = 3;
40    required int32 failure_tolerance = 4; // -1 = no tolerance
41}
42
43message E2eeOptions {
44    required EncryptionType encryption_type = 1;
45    required KeyProviderOptions key_provider_options = 2;
46}
47
48enum EncryptionState {
49    NEW = 0;
50    OK = 1;
51    ENCRYPTION_FAILED = 2;
52    DECRYPTION_FAILED = 3;
53    MISSING_KEY = 4;
54    KEY_RATCHETED = 5;
55    INTERNAL_ERROR = 6;
56}
57
58message E2eeManagerSetEnabledRequest {
59    required bool enabled = 1;
60}
61message E2eeManagerSetEnabledResponse {}
62
63message E2eeManagerGetFrameCryptorsRequest {}
64message E2eeManagerGetFrameCryptorsResponse {
65    repeated FrameCryptor frame_cryptors = 1;
66}
67
68message FrameCryptorSetEnabledRequest {
69    required string participant_identity = 1;
70    required string track_sid = 2;
71    required bool enabled = 3;
72}
73message FrameCryptorSetEnabledResponse {}
74
75message FrameCryptorSetKeyIndexRequest {
76    required string participant_identity = 1;
77    required string track_sid = 2;
78    required int32 key_index = 3;
79}
80message FrameCryptorSetKeyIndexResponse {}
81
82message SetSharedKeyRequest {
83    required bytes shared_key = 1;
84    required int32 key_index = 2;
85}
86message SetSharedKeyResponse {}
87
88message RatchetSharedKeyRequest {
89    required int32 key_index = 1;   
90}
91message RatchetSharedKeyResponse {
92    optional bytes new_key = 1;
93}
94
95message GetSharedKeyRequest {
96    required int32 key_index = 1;
97}
98message GetSharedKeyResponse {
99    optional bytes key = 1;
100}
101
102message SetKeyRequest {
103    required string participant_identity = 1;
104    required bytes key = 2;
105    required int32 key_index = 3;
106}
107message SetKeyResponse {}
108
109message RatchetKeyRequest {
110    required string participant_identity = 1;
111    required int32 key_index = 2;
112}
113message RatchetKeyResponse {
114    optional bytes new_key = 1;
115}
116
117message GetKeyRequest {
118    required string participant_identity = 1;
119    required int32 key_index = 2;
120}
121message GetKeyResponse {
122    optional bytes key = 1;
123}
124
125message E2eeRequest {
126    required uint64 room_handle = 1;
127    oneof message {
128        E2eeManagerSetEnabledRequest manager_set_enabled = 2;
129        E2eeManagerGetFrameCryptorsRequest manager_get_frame_cryptors = 3;
130        FrameCryptorSetEnabledRequest cryptor_set_enabled = 4;
131        FrameCryptorSetKeyIndexRequest cryptor_set_key_index = 5;
132        SetSharedKeyRequest set_shared_key = 6;
133        RatchetSharedKeyRequest ratchet_shared_key = 7;
134        GetSharedKeyRequest get_shared_key = 8;
135        SetKeyRequest set_key = 9;
136        RatchetKeyRequest ratchet_key = 10;
137        GetKeyRequest get_key = 11;
138    }
139}
140
141message E2eeResponse {
142    oneof message {
143        E2eeManagerSetEnabledResponse manager_set_enabled = 1;
144        E2eeManagerGetFrameCryptorsResponse manager_get_frame_cryptors = 2;
145        FrameCryptorSetEnabledResponse cryptor_set_enabled = 3;
146        FrameCryptorSetKeyIndexResponse cryptor_set_key_index = 4;
147        SetSharedKeyResponse set_shared_key = 5;
148        RatchetSharedKeyResponse ratchet_shared_key = 6;
149        GetSharedKeyResponse get_shared_key = 7;
150        SetKeyResponse set_key = 8;
151        RatchetKeyResponse ratchet_key = 9;
152        GetKeyResponse get_key = 10;
153    }
154}