Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 /* vim: set ts=2 et sw=2 tw=80: */ | 2 /* vim: set ts=2 et sw=2 tw=80: */ |
3 /* This Source Code Form is subject to the terms of the Mozilla Public | 3 /* This Source Code Form is subject to the terms of the Mozilla Public |
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file, | 4 * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ | 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | 6 |
7 #ifndef tls_agent_h_ | 7 #ifndef tls_agent_h_ |
8 #define tls_agent_h_ | 8 #define tls_agent_h_ |
9 | 9 |
10 #include "prio.h" | 10 #include "prio.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 void ConfigureSessionCache(SessionResumptionMode mode); | 109 void ConfigureSessionCache(SessionResumptionMode mode); |
110 void SetSessionTicketsEnabled(bool en); | 110 void SetSessionTicketsEnabled(bool en); |
111 void SetSessionCacheEnabled(bool en); | 111 void SetSessionCacheEnabled(bool en); |
112 void Set0RttEnabled(bool en); | 112 void Set0RttEnabled(bool en); |
113 void SetVersionRange(uint16_t minver, uint16_t maxver); | 113 void SetVersionRange(uint16_t minver, uint16_t maxver); |
114 void GetVersionRange(uint16_t* minver, uint16_t* maxver); | 114 void GetVersionRange(uint16_t* minver, uint16_t* maxver); |
115 void CheckPreliminaryInfo(); | 115 void CheckPreliminaryInfo(); |
116 void ResetPreliminaryInfo(); | 116 void ResetPreliminaryInfo(); |
117 void SetExpectedVersion(uint16_t version); | 117 void SetExpectedVersion(uint16_t version); |
118 void SetServerKeyBits(uint16_t bits); | 118 void SetServerKeyBits(uint16_t bits); |
119 void SetExpectedReadError(bool err); | 119 void ExpectReadWriteError(); |
120 void EnableFalseStart(); | 120 void EnableFalseStart(); |
121 void ExpectResumption(); | 121 void ExpectResumption(); |
122 void SetSignatureAlgorithms(const SSLSignatureAndHashAlg* algorithms, | 122 void SetSignatureAlgorithms(const SSLSignatureAndHashAlg* algorithms, |
123 size_t count); | 123 size_t count); |
124 void EnableAlpn(const uint8_t* val, size_t len); | 124 void EnableAlpn(const uint8_t* val, size_t len); |
125 void CheckAlpn(SSLNextProtoState expected_state, | 125 void CheckAlpn(SSLNextProtoState expected_state, |
126 const std::string& expected = "") const; | 126 const std::string& expected = "") const; |
127 void EnableSrtp(); | 127 void EnableSrtp(); |
128 void CheckSrtp() const; | 128 void CheckSrtp() const; |
129 void CheckErrorCode(int32_t expected) const; | 129 void CheckErrorCode(int32_t expected) const; |
130 void WaitForErrorCode(int32_t expected, uint32_t delay) const; | 130 void WaitForErrorCode(int32_t expected, uint32_t delay) const; |
131 // Send data on the socket, encrypting it. | 131 // Send data on the socket, encrypting it. |
132 void SendData(size_t bytes, size_t blocksize = 1024); | 132 void SendData(size_t bytes, size_t blocksize = 1024); |
133 // Send data directly to the underlying socket, skipping the TLS layer. | 133 // Send data directly to the underlying socket, skipping the TLS layer. |
134 void SendDirect(const DataBuffer& buf); | 134 void SendDirect(const DataBuffer& buf); |
135 void ReadBytes(); | 135 void ReadBytes(); |
136 void ResetSentBytes(); // Hack to test drops. | 136 void ResetSentBytes(); // Hack to test drops. |
137 void EnableExtendedMasterSecret(); | 137 void EnableExtendedMasterSecret(); |
138 void CheckExtendedMasterSecret(bool expected); | 138 void CheckExtendedMasterSecret(bool expected); |
139 void CheckEarlyDataAccepted(bool expected); | 139 void CheckEarlyDataAccepted(bool expected); |
140 void DisableRollbackDetection(); | 140 void DisableRollbackDetection(); |
141 void EnableCompression(); | 141 void EnableCompression(); |
142 void SetDowngradeCheckVersion(uint16_t version); | 142 void SetDowngradeCheckVersion(uint16_t version); |
143 void CheckSecretsDestroyed(); | 143 void CheckSecretsDestroyed(); |
144 void ConfigNamedGroup(SSLNamedGroup group, bool en); | 144 void ConfigNamedGroups(const SSLNamedGroup* groups, uint8_t num); |
mt
2016/08/24 00:19:32
The named group configuration was added in 3.27.
franziskus
2016/08/25 13:03:20
Done.
|
mt
2016/09/14 20:22:05
size_t instead of uint8_t
|
145 void ConfigNamedGroupPrefs(SSLNamedGroup *groups, uint8_t num); | |
146 | 145 |
147 const std::string& name() const { return name_; } | 146 const std::string& name() const { return name_; } |
148 | 147 |
149 Role role() const { return role_; } | 148 Role role() const { return role_; } |
150 std::string role_str() const { return role_ == SERVER ? "server" : "client"; } | 149 std::string role_str() const { return role_ == SERVER ? "server" : "client"; } |
151 | 150 |
152 State state() const { return state_; } | 151 State state() const { return state_; } |
153 | 152 |
154 const CERTCertificate* peer_cert() const { | 153 const CERTCertificate* peer_cert() const { |
155 return SSL_PeerCertificate(ssl_fd_); | 154 return SSL_PeerCertificate(ssl_fd_); |
(...skipping 29 matching lines...) Expand all Loading... | |
185 | 184 |
186 return csinfo_.cipherSuiteName; | 185 return csinfo_.cipherSuiteName; |
187 } | 186 } |
188 | 187 |
189 std::vector<uint8_t> session_id() const { | 188 std::vector<uint8_t> session_id() const { |
190 return std::vector<uint8_t>(info_.sessionID, | 189 return std::vector<uint8_t>(info_.sessionID, |
191 info_.sessionID + info_.sessionIDLength); | 190 info_.sessionID + info_.sessionIDLength); |
192 } | 191 } |
193 | 192 |
194 size_t received_bytes() const { return recv_ctr_; } | 193 size_t received_bytes() const { return recv_ctr_; } |
195 int32_t error_code() const { return error_code_; } | 194 PRErrorCode error_code() const { return error_code_; } |
196 | 195 |
197 bool can_falsestart_hook_called() const { | 196 bool can_falsestart_hook_called() const { |
198 return can_falsestart_hook_called_; | 197 return can_falsestart_hook_called_; |
199 } | 198 } |
200 | 199 |
201 void SetHandshakeCallback(HandshakeCallbackFunction handshake_callback) { | 200 void SetHandshakeCallback(HandshakeCallbackFunction handshake_callback) { |
202 handshake_callback_ = handshake_callback; | 201 handshake_callback_ = handshake_callback; |
203 } | 202 } |
204 | 203 |
205 void SetAuthCertificateCallback( | 204 void SetAuthCertificateCallback( |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
325 uint16_t expected_cipher_suite_; | 324 uint16_t expected_cipher_suite_; |
326 bool expect_resumption_; | 325 bool expect_resumption_; |
327 bool expect_client_auth_; | 326 bool expect_client_auth_; |
328 bool can_falsestart_hook_called_; | 327 bool can_falsestart_hook_called_; |
329 bool sni_hook_called_; | 328 bool sni_hook_called_; |
330 bool auth_certificate_hook_called_; | 329 bool auth_certificate_hook_called_; |
331 bool handshake_callback_called_; | 330 bool handshake_callback_called_; |
332 SSLChannelInfo info_; | 331 SSLChannelInfo info_; |
333 SSLCipherSuiteInfo csinfo_; | 332 SSLCipherSuiteInfo csinfo_; |
334 SSLVersionRange vrange_; | 333 SSLVersionRange vrange_; |
335 int32_t error_code_; | 334 PRErrorCode error_code_; |
336 size_t send_ctr_; | 335 size_t send_ctr_; |
337 size_t recv_ctr_; | 336 size_t recv_ctr_; |
338 bool expected_read_error_; | 337 bool expect_readwrite_error_; |
339 HandshakeCallbackFunction handshake_callback_; | 338 HandshakeCallbackFunction handshake_callback_; |
340 AuthCertificateCallbackFunction auth_certificate_callback_; | 339 AuthCertificateCallbackFunction auth_certificate_callback_; |
341 SniCallbackFunction sni_callback_; | 340 SniCallbackFunction sni_callback_; |
342 }; | 341 }; |
343 | 342 |
344 class TlsAgentTestBase : public ::testing::Test { | 343 class TlsAgentTestBase : public ::testing::Test { |
345 public: | 344 public: |
346 static ::testing::internal::ParamGenerator<std::string> kTlsRolesAll; | 345 static ::testing::internal::ParamGenerator<std::string> kTlsRolesAll; |
347 | 346 |
348 TlsAgentTestBase(TlsAgent::Role role, Mode mode) | 347 TlsAgentTestBase(TlsAgent::Role role, Mode mode) |
349 : agent_(nullptr), fd_(nullptr), role_(role), mode_(mode) {} | 348 : agent_(nullptr), fd_(nullptr), role_(role), mode_(mode) {} |
350 ~TlsAgentTestBase() { | 349 ~TlsAgentTestBase() { |
351 if (fd_) { | 350 if (fd_) { |
352 PR_Close(fd_); | 351 PR_Close(fd_); |
353 } | 352 } |
354 } | 353 } |
355 | 354 |
356 void SetUp(); | 355 void SetUp(); |
357 void TearDown(); | 356 void TearDown(); |
358 | 357 |
359 void MakeRecord(uint8_t type, uint16_t version, const uint8_t* buf, | 358 void MakeRecord(uint8_t type, uint16_t version, const uint8_t* buf, |
360 size_t len, DataBuffer* out, uint32_t seq_num = 0); | 359 size_t len, DataBuffer* out, uint64_t seq_num = 0); |
360 static void MakeRecord(Mode mode, uint8_t type, uint16_t version, | |
361 const uint8_t* buf, size_t len, DataBuffer* out, | |
362 uint64_t seq_num = 0); | |
361 void MakeHandshakeMessage(uint8_t hs_type, const uint8_t* data, size_t hs_len, | 363 void MakeHandshakeMessage(uint8_t hs_type, const uint8_t* data, size_t hs_len, |
362 DataBuffer* out, uint32_t seq_num = 0); | 364 DataBuffer* out, uint64_t seq_num = 0); |
363 void MakeHandshakeMessageFragment(uint8_t hs_type, const uint8_t* data, | 365 void MakeHandshakeMessageFragment(uint8_t hs_type, const uint8_t* data, |
364 size_t hs_len, DataBuffer* out, | 366 size_t hs_len, DataBuffer* out, |
365 uint32_t seq_num, uint32_t fragment_offset, | 367 uint64_t seq_num, uint32_t fragment_offset, |
366 uint32_t fragment_length); | 368 uint32_t fragment_length); |
367 void MakeTrivialHandshakeRecord(uint8_t hs_type, size_t hs_len, | 369 static void MakeTrivialHandshakeRecord(uint8_t hs_type, size_t hs_len, |
368 DataBuffer* out); | 370 DataBuffer* out); |
369 static inline TlsAgent::Role ToRole(const std::string& str) { | 371 static inline TlsAgent::Role ToRole(const std::string& str) { |
370 return str == "CLIENT" ? TlsAgent::CLIENT : TlsAgent::SERVER; | 372 return str == "CLIENT" ? TlsAgent::CLIENT : TlsAgent::SERVER; |
371 } | 373 } |
372 | 374 |
373 static inline Mode ToMode(const std::string& str) { | 375 static inline Mode ToMode(const std::string& str) { |
374 return str == "TLS" ? STREAM : DGRAM; | 376 return str == "TLS" ? STREAM : DGRAM; |
375 } | 377 } |
376 | 378 |
377 void Init(const std::string& server_name = TlsAgent::kServerRsa); | 379 void Init(const std::string& server_name = TlsAgent::kServerRsa); |
378 void Reset(const std::string& server_name = TlsAgent::kServerRsa); | 380 void Reset(const std::string& server_name = TlsAgent::kServerRsa); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
415 }; | 417 }; |
416 | 418 |
417 class TlsAgentDgramTestClient : public TlsAgentTestBase { | 419 class TlsAgentDgramTestClient : public TlsAgentTestBase { |
418 public: | 420 public: |
419 TlsAgentDgramTestClient() : TlsAgentTestBase(TlsAgent::CLIENT, DGRAM) {} | 421 TlsAgentDgramTestClient() : TlsAgentTestBase(TlsAgent::CLIENT, DGRAM) {} |
420 }; | 422 }; |
421 | 423 |
422 } // namespace nss_test | 424 } // namespace nss_test |
423 | 425 |
424 #endif | 426 #endif |
LEFT | RIGHT |