OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 enum SSLRole { SSL_CLIENT, SSL_SERVER }; | 100 enum SSLRole { SSL_CLIENT, SSL_SERVER }; |
101 enum SSLMode { SSL_MODE_TLS, SSL_MODE_DTLS }; | 101 enum SSLMode { SSL_MODE_TLS, SSL_MODE_DTLS }; |
102 enum SSLProtocolVersion { | 102 enum SSLProtocolVersion { |
103 SSL_PROTOCOL_TLS_10, | 103 SSL_PROTOCOL_TLS_10, |
104 SSL_PROTOCOL_TLS_11, | 104 SSL_PROTOCOL_TLS_11, |
105 SSL_PROTOCOL_TLS_12, | 105 SSL_PROTOCOL_TLS_12, |
106 SSL_PROTOCOL_DTLS_10 = SSL_PROTOCOL_TLS_11, | 106 SSL_PROTOCOL_DTLS_10 = SSL_PROTOCOL_TLS_11, |
107 SSL_PROTOCOL_DTLS_12 = SSL_PROTOCOL_TLS_12, | 107 SSL_PROTOCOL_DTLS_12 = SSL_PROTOCOL_TLS_12, |
108 }; | 108 }; |
109 enum class SSLPeerCertificateDigestError { | |
110 NONE, | |
111 UNKNOWN_ALGORITHM, | |
112 INVALID_LENGTH, | |
113 VERIFICATION_FAILED, | |
114 }; | |
115 | 109 |
116 // Errors for Read -- in the high range so no conflict with OpenSSL. | 110 // Errors for Read -- in the high range so no conflict with OpenSSL. |
117 enum { SSE_MSG_TRUNC = 0xff0001 }; | 111 enum { SSE_MSG_TRUNC = 0xff0001 }; |
118 | 112 |
119 // Used to send back UMA histogram value. Logged when Dtls handshake fails. | 113 // Used to send back UMA histogram value. Logged when Dtls handshake fails. |
120 enum class SSLHandshakeError { UNKNOWN, INCOMPATIBLE_CIPHERSUITE, MAX_VALUE }; | 114 enum class SSLHandshakeError { UNKNOWN, INCOMPATIBLE_CIPHERSUITE, MAX_VALUE }; |
121 | 115 |
122 class SSLStreamAdapter : public StreamAdapterInterface { | 116 class SSLStreamAdapter : public StreamAdapterInterface { |
123 public: | 117 public: |
124 // Instantiate an SSLStreamAdapter wrapping the given stream, | 118 // Instantiate an SSLStreamAdapter wrapping the given stream, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 // asynchronously. In that case, the exposed stream will open after | 166 // asynchronously. In that case, the exposed stream will open after |
173 // successful negotiation and verification, or an SE_CLOSE event will be | 167 // successful negotiation and verification, or an SE_CLOSE event will be |
174 // raised if negotiation fails. | 168 // raised if negotiation fails. |
175 virtual int StartSSL() = 0; | 169 virtual int StartSSL() = 0; |
176 | 170 |
177 // Specify the digest of the certificate that our peer is expected to use. | 171 // Specify the digest of the certificate that our peer is expected to use. |
178 // Only this certificate will be accepted during SSL verification. The | 172 // Only this certificate will be accepted during SSL verification. The |
179 // certificate is assumed to have been obtained through some other secure | 173 // certificate is assumed to have been obtained through some other secure |
180 // channel (such as the signaling channel). This must specify the terminal | 174 // channel (such as the signaling channel). This must specify the terminal |
181 // certificate, not just a CA. SSLStream makes a copy of the digest value. | 175 // certificate, not just a CA. SSLStream makes a copy of the digest value. |
182 virtual SSLPeerCertificateDigestError SetPeerCertificateDigest( | 176 virtual bool SetPeerCertificateDigest(const std::string& digest_alg, |
183 const std::string& digest_alg, | 177 const unsigned char* digest_val, |
184 const unsigned char* digest_val, | 178 size_t digest_len) = 0; |
185 size_t digest_len) = 0; | |
186 | 179 |
187 // Retrieves the peer's X.509 certificate, if a connection has been | 180 // Retrieves the peer's X.509 certificate, if a connection has been |
188 // established. It returns the transmitted over SSL, including the entire | 181 // established. It returns the transmitted over SSL, including the entire |
189 // chain. | 182 // chain. |
190 virtual std::unique_ptr<SSLCertificate> GetPeerCertificate() const = 0; | 183 virtual std::unique_ptr<SSLCertificate> GetPeerCertificate() const = 0; |
191 | 184 |
192 // Retrieves the IANA registration id of the cipher suite used for the | 185 // Retrieves the IANA registration id of the cipher suite used for the |
193 // connection (e.g. 0x2F for "TLS_RSA_WITH_AES_128_CBC_SHA"). | 186 // connection (e.g. 0x2F for "TLS_RSA_WITH_AES_128_CBC_SHA"). |
194 virtual bool GetSslCipherSuite(int* cipher_suite); | 187 virtual bool GetSslCipherSuite(int* cipher_suite); |
195 | 188 |
(...skipping 15 matching lines...) Expand all Loading... |
211 const uint8_t* context, | 204 const uint8_t* context, |
212 size_t context_len, | 205 size_t context_len, |
213 bool use_context, | 206 bool use_context, |
214 uint8_t* result, | 207 uint8_t* result, |
215 size_t result_len); | 208 size_t result_len); |
216 | 209 |
217 // DTLS-SRTP interface | 210 // DTLS-SRTP interface |
218 virtual bool SetDtlsSrtpCryptoSuites(const std::vector<int>& crypto_suites); | 211 virtual bool SetDtlsSrtpCryptoSuites(const std::vector<int>& crypto_suites); |
219 virtual bool GetDtlsSrtpCryptoSuite(int* crypto_suite); | 212 virtual bool GetDtlsSrtpCryptoSuite(int* crypto_suite); |
220 | 213 |
221 // Returns true if a TLS connection has been established. | |
222 // The only difference between this and "GetState() == SE_OPEN" is that if | |
223 // the peer certificate digest hasn't been verified, the state will still be | |
224 // SS_OPENING but IsTlsConnected should return true. | |
225 virtual bool IsTlsConnected() = 0; | |
226 | |
227 // Capabilities testing | 214 // Capabilities testing |
228 static bool HaveDtls(); | 215 static bool HaveDtls(); |
229 static bool HaveDtlsSrtp(); | 216 static bool HaveDtlsSrtp(); |
230 static bool HaveExporter(); | 217 static bool HaveExporter(); |
231 static bool IsBoringSsl(); | 218 static bool IsBoringSsl(); |
232 | 219 |
233 // Returns true iff the supplied cipher is deemed to be strong. | 220 // Returns true iff the supplied cipher is deemed to be strong. |
234 // TODO(torbjorng): Consider removing the KeyType argument. | 221 // TODO(torbjorng): Consider removing the KeyType argument. |
235 static bool IsAcceptableCipher(int cipher, KeyType key_type); | 222 static bool IsAcceptableCipher(int cipher, KeyType key_type); |
236 static bool IsAcceptableCipher(const std::string& cipher, KeyType key_type); | 223 static bool IsAcceptableCipher(const std::string& cipher, KeyType key_type); |
(...skipping 13 matching lines...) Expand all Loading... |
250 | 237 |
251 // If true (default), the client is required to provide a certificate during | 238 // If true (default), the client is required to provide a certificate during |
252 // handshake. If no certificate is given, handshake fails. This applies to | 239 // handshake. If no certificate is given, handshake fails. This applies to |
253 // server mode only. | 240 // server mode only. |
254 bool client_auth_enabled_; | 241 bool client_auth_enabled_; |
255 }; | 242 }; |
256 | 243 |
257 } // namespace rtc | 244 } // namespace rtc |
258 | 245 |
259 #endif // WEBRTC_BASE_SSLSTREAMADAPTER_H_ | 246 #endif // WEBRTC_BASE_SSLSTREAMADAPTER_H_ |
OLD | NEW |