@@ -34,7 +34,8 @@ int DerivePBKDF2KeyFromRawKey(const std::vector<uint8_t> raw_key,
34
34
35
35
namespace webrtc {
36
36
37
- const size_t KEYRING_SIZE = 16 ;
37
+ const size_t DEFAULT_KEYRING_SIZE = 16 ;
38
+ const size_t MAX_KEYRING_SIZE = 255 ;
38
39
39
40
class ParticipantKeyHandler ;
40
41
@@ -44,14 +45,22 @@ struct KeyProviderOptions {
44
45
std::vector<uint8_t > uncrypted_magic_bytes;
45
46
int ratchet_window_size;
46
47
int failure_tolerance;
48
+ // key ring size should be between 1 and 255
49
+ int key_ring_size;
50
+ bool discard_frame_when_cryptor_not_ready;
47
51
KeyProviderOptions ()
48
- : shared_key(false ), ratchet_window_size(0 ), failure_tolerance(-1 ) {}
52
+ : shared_key(false ),
53
+ ratchet_window_size (0 ),
54
+ failure_tolerance(-1 ),
55
+ key_ring_size(DEFAULT_KEYRING_SIZE),
56
+ discard_frame_when_cryptor_not_ready(false ) {}
49
57
KeyProviderOptions (KeyProviderOptions& copy)
50
58
: shared_key(copy.shared_key),
51
59
ratchet_salt(copy.ratchet_salt),
52
60
uncrypted_magic_bytes(copy.uncrypted_magic_bytes),
53
61
ratchet_window_size(copy.ratchet_window_size),
54
- failure_tolerance(copy.failure_tolerance) {}
62
+ failure_tolerance(copy.failure_tolerance),
63
+ key_ring_size(copy.key_ring_size) {}
55
64
};
56
65
57
66
class KeyProvider : public rtc ::RefCountInterface {
@@ -99,7 +108,14 @@ class ParticipantKeyHandler : public rtc::RefCountInterface {
99
108
public:
100
109
ParticipantKeyHandler (KeyProvider* key_provider)
101
110
: key_provider_(key_provider) {
102
- crypto_key_ring_.resize (KEYRING_SIZE);
111
+ int key_ring_size = key_provider_->options ().key_ring_size ;
112
+ if (key_ring_size <= 0 ) {
113
+ key_ring_size = DEFAULT_KEYRING_SIZE;
114
+ } else if (key_ring_size > (int )MAX_KEYRING_SIZE) {
115
+ // Keyring size needs to be between 1 and 256
116
+ key_ring_size = MAX_KEYRING_SIZE;
117
+ }
118
+ crypto_key_ring_.resize (key_ring_size);
103
119
}
104
120
105
121
virtual ~ParticipantKeyHandler () = default ;
0 commit comments