Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(281)

Side by Side Diff: webrtc/p2p/base/dtlstransportchannel.h

Issue 2815513012: Negotiate the same SRTP crypto suites for every DTLS association formed. (Closed)
Patch Set: Merge with master Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/base/sslstreamadapter.cc ('k') | webrtc/p2p/base/dtlstransportchannel.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2011 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 // downward_, so it immediately calls downward_->Read(). 79 // downward_, so it immediately calls downward_->Read().
80 // 80 //
81 // - Data written to DtlsTransport is passed either to downward_ or directly 81 // - Data written to DtlsTransport is passed either to downward_ or directly
82 // to ice_transport_, depending on whether DTLS is negotiated and whether 82 // to ice_transport_, depending on whether DTLS is negotiated and whether
83 // the flags include PF_SRTP_BYPASS 83 // the flags include PF_SRTP_BYPASS
84 // 84 //
85 // - The SSLStreamAdapter writes to downward_->Write() which translates it 85 // - The SSLStreamAdapter writes to downward_->Write() which translates it
86 // into packet writes on ice_transport_. 86 // into packet writes on ice_transport_.
87 class DtlsTransport : public DtlsTransportInternal { 87 class DtlsTransport : public DtlsTransportInternal {
88 public: 88 public:
89 // The parameters here is: 89 // |ice_transport| is the ICE transport this DTLS transport is wrapping.
90 // ice_transport -- the ice transport we are wrapping 90 //
91 explicit DtlsTransport(IceTransportInternal* ice_transport); 91 // |crypto_options| are the options used for the DTLS handshake. This affects
92 // whether GCM crypto suites are negotiated.
93 explicit DtlsTransport(IceTransportInternal* ice_transport,
94 const rtc::CryptoOptions& crypto_options);
92 ~DtlsTransport() override; 95 ~DtlsTransport() override;
93 96
94 DtlsTransportState dtls_state() const override { return dtls_state_; } 97 DtlsTransportState dtls_state() const override { return dtls_state_; }
95 98
96 const std::string& transport_name() const override { return transport_name_; } 99 const std::string& transport_name() const override { return transport_name_; }
97 100
98 int component() const override { return component_; } 101 int component() const override { return component_; }
99 102
100 // Returns false if no local certificate was set, or if the peer doesn't 103 // Returns false if no local certificate was set, or if the peer doesn't
101 // support DTLS. 104 // support DTLS.
(...skipping 13 matching lines...) Expand all
115 size_t size, 118 size_t size,
116 const rtc::PacketOptions& options, 119 const rtc::PacketOptions& options,
117 int flags) override; 120 int flags) override;
118 121
119 bool GetOption(rtc::Socket::Option opt, int* value) override { 122 bool GetOption(rtc::Socket::Option opt, int* value) override {
120 return ice_transport_->GetOption(opt, value); 123 return ice_transport_->GetOption(opt, value);
121 } 124 }
122 125
123 virtual bool SetSslMaxProtocolVersion(rtc::SSLProtocolVersion version); 126 virtual bool SetSslMaxProtocolVersion(rtc::SSLProtocolVersion version);
124 127
125 // Set up the ciphers to use for DTLS-SRTP. If this method is not called
126 // before DTLS starts, or |ciphers| is empty, SRTP keys won't be negotiated.
127 // This method should be called before SetupDtls.
128 bool SetSrtpCryptoSuites(const std::vector<int>& ciphers) override;
129
130 // Find out which DTLS-SRTP cipher was negotiated 128 // Find out which DTLS-SRTP cipher was negotiated
131 bool GetSrtpCryptoSuite(int* cipher) override; 129 bool GetSrtpCryptoSuite(int* cipher) override;
132 130
133 bool GetSslRole(rtc::SSLRole* role) const override; 131 bool GetSslRole(rtc::SSLRole* role) const override;
134 bool SetSslRole(rtc::SSLRole role) override; 132 bool SetSslRole(rtc::SSLRole role) override;
135 133
136 // Find out which DTLS cipher was negotiated 134 // Find out which DTLS cipher was negotiated
137 bool GetSslCipherSuite(int* cipher) override; 135 bool GetSslCipherSuite(int* cipher) override;
138 136
139 // Once DTLS has been established, this method retrieves the certificate in 137 // Once DTLS has been established, this method retrieves the certificate in
(...skipping 27 matching lines...) Expand all
167 bool receiving() const override { return receiving_; } 165 bool receiving() const override { return receiving_; }
168 166
169 bool writable() const override { return writable_; } 167 bool writable() const override { return writable_; }
170 168
171 int GetError() override { return ice_transport_->GetError(); } 169 int GetError() override { return ice_transport_->GetError(); }
172 170
173 int SetOption(rtc::Socket::Option opt, int value) override { 171 int SetOption(rtc::Socket::Option opt, int value) override {
174 return ice_transport_->SetOption(opt, value); 172 return ice_transport_->SetOption(opt, value);
175 } 173 }
176 174
177 bool SetSrtpCiphers(const std::vector<std::string>& ciphers) override {
178 std::vector<int> crypto_suites;
179 for (const auto cipher : ciphers) {
180 crypto_suites.push_back(rtc::SrtpCryptoSuiteFromName(cipher));
181 }
182 return SetSrtpCryptoSuites(crypto_suites);
183 }
184
185 std::string ToString() const { 175 std::string ToString() const {
186 const char RECEIVING_ABBREV[2] = {'_', 'R'}; 176 const char RECEIVING_ABBREV[2] = {'_', 'R'};
187 const char WRITABLE_ABBREV[2] = {'_', 'W'}; 177 const char WRITABLE_ABBREV[2] = {'_', 'W'};
188 std::stringstream ss; 178 std::stringstream ss;
189 ss << "DtlsTransport[" << transport_name_ << "|" << component_ << "|" 179 ss << "DtlsTransport[" << transport_name_ << "|" << component_ << "|"
190 << RECEIVING_ABBREV[receiving()] << WRITABLE_ABBREV[writable()] << "]"; 180 << RECEIVING_ABBREV[receiving()] << WRITABLE_ABBREV[writable()] << "]";
191 return ss.str(); 181 return ss.str();
192 } 182 }
193 183
194 private: 184 private:
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 228
239 bool receiving_ = false; 229 bool receiving_ = false;
240 bool writable_ = false; 230 bool writable_ = false;
241 231
242 RTC_DISALLOW_COPY_AND_ASSIGN(DtlsTransport); 232 RTC_DISALLOW_COPY_AND_ASSIGN(DtlsTransport);
243 }; 233 };
244 234
245 } // namespace cricket 235 } // namespace cricket
246 236
247 #endif // WEBRTC_P2P_BASE_DTLSTRANSPORTCHANNEL_H_ 237 #endif // WEBRTC_P2P_BASE_DTLSTRANSPORTCHANNEL_H_
OLDNEW
« no previous file with comments | « webrtc/base/sslstreamadapter.cc ('k') | webrtc/p2p/base/dtlstransportchannel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698