| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BIN_SECURE_SOCKET_H_ | 5 #ifndef BIN_SECURE_SOCKET_H_ |
| 6 #define BIN_SECURE_SOCKET_H_ | 6 #define BIN_SECURE_SOCKET_H_ |
| 7 | 7 |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 int port, | 82 int port, |
| 83 bool is_server, | 83 bool is_server, |
| 84 const char* certificate_name, | 84 const char* certificate_name, |
| 85 bool request_client_certificate, | 85 bool request_client_certificate, |
| 86 bool require_client_certificate, | 86 bool require_client_certificate, |
| 87 bool send_client_certificate); | 87 bool send_client_certificate); |
| 88 void Destroy(); | 88 void Destroy(); |
| 89 void Handshake(); | 89 void Handshake(); |
| 90 void RegisterHandshakeCompleteCallback(Dart_Handle handshake_complete); | 90 void RegisterHandshakeCompleteCallback(Dart_Handle handshake_complete); |
| 91 void RegisterBadCertificateCallback(Dart_Handle callback); | 91 void RegisterBadCertificateCallback(Dart_Handle callback); |
| 92 Dart_Handle bad_certificate_callback() { return bad_certificate_callback_; } | 92 Dart_Handle bad_certificate_callback() { |
| 93 return Dart_HandleFromPersistent(bad_certificate_callback_); |
| 94 } |
| 93 static void InitializeLibrary(const char* certificate_database, | 95 static void InitializeLibrary(const char* certificate_database, |
| 94 const char* password, | 96 const char* password, |
| 95 bool use_builtin_root_certificates, | 97 bool use_builtin_root_certificates, |
| 96 bool report_duplicate_initialization = true); | 98 bool report_duplicate_initialization = true); |
| 97 intptr_t ProcessBuffer(int bufferIndex); | 99 intptr_t ProcessBuffer(int bufferIndex); |
| 98 Dart_Handle PeerCertificate(); | 100 Dart_Handle PeerCertificate(); |
| 99 | 101 |
| 100 private: | 102 private: |
| 101 static const int kMemioBufferSize = 20 * KB; | 103 static const int kMemioBufferSize = 20 * KB; |
| 102 static bool library_initialized_; | 104 static bool library_initialized_; |
| 103 static const char* password_; | 105 static const char* password_; |
| 104 static dart::Mutex mutex_; // To protect library initialization. | 106 static dart::Mutex mutex_; // To protect library initialization. |
| 105 | 107 |
| 106 uint8_t* buffers_[kNumBuffers]; | 108 uint8_t* buffers_[kNumBuffers]; |
| 107 int buffer_size_; | 109 int buffer_size_; |
| 108 int encrypted_buffer_size_; | 110 int encrypted_buffer_size_; |
| 109 Dart_Handle string_start_; | 111 Dart_PersistentHandle string_start_; |
| 110 Dart_Handle string_length_; | 112 Dart_PersistentHandle string_length_; |
| 111 Dart_Handle dart_buffer_objects_[kNumBuffers]; | 113 Dart_PersistentHandle dart_buffer_objects_[kNumBuffers]; |
| 112 Dart_Handle handshake_complete_; | 114 Dart_PersistentHandle handshake_complete_; |
| 113 Dart_Handle bad_certificate_callback_; | 115 Dart_PersistentHandle bad_certificate_callback_; |
| 114 bool in_handshake_; | 116 bool in_handshake_; |
| 115 bool is_server_; | 117 bool is_server_; |
| 116 char* client_certificate_name_; | 118 char* client_certificate_name_; |
| 117 PRFileDesc* filter_; | 119 PRFileDesc* filter_; |
| 118 | 120 |
| 119 static bool isEncrypted(int i) { | 121 static bool isEncrypted(int i) { |
| 120 return static_cast<BufferIndex>(i) >= kFirstEncrypted; | 122 return static_cast<BufferIndex>(i) >= kFirstEncrypted; |
| 121 } | 123 } |
| 122 void InitializeBuffers(Dart_Handle dart_this); | 124 void InitializeBuffers(Dart_Handle dart_this); |
| 123 void InitializePlatformData(); | 125 void InitializePlatformData(); |
| 124 | 126 |
| 125 DISALLOW_COPY_AND_ASSIGN(SSLFilter); | 127 DISALLOW_COPY_AND_ASSIGN(SSLFilter); |
| 126 }; | 128 }; |
| 127 | 129 |
| 128 } // namespace bin | 130 } // namespace bin |
| 129 } // namespace dart | 131 } // namespace dart |
| 130 | 132 |
| 131 #endif // BIN_SECURE_SOCKET_H_ | 133 #endif // BIN_SECURE_SOCKET_H_ |
| OLD | NEW |