| 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> |
| 11 #include <sys/types.h> | 11 #include <sys/types.h> |
| 12 | 12 |
| 13 #include <prinit.h> | 13 #include <prinit.h> |
| 14 #include <prerror.h> | 14 #include <prerror.h> |
| 15 #include <prnetdb.h> | 15 #include <prnetdb.h> |
| 16 #include <ssl.h> | 16 #include <ssl.h> |
| 17 | 17 |
| 18 #include "platform/globals.h" | 18 #include "platform/globals.h" |
| 19 #include "platform/thread.h" | 19 #include "platform/thread.h" |
| 20 | 20 |
| 21 #include "bin/builtin.h" | 21 #include "bin/builtin.h" |
| 22 #include "bin/dartutils.h" | 22 #include "bin/dartutils.h" |
| 23 #include "bin/socket.h" | 23 #include "bin/socket.h" |
| 24 #include "bin/utils.h" | 24 #include "bin/utils.h" |
| 25 #include "bin/native_service.h" |
| 25 | 26 |
| 26 namespace dart { | 27 namespace dart { |
| 27 namespace bin { | 28 namespace bin { |
| 28 | 29 |
| 29 static void ThrowException(const char* message) { | 30 static void ThrowException(const char* message) { |
| 30 Dart_Handle socket_exception = | 31 Dart_Handle socket_exception = |
| 31 DartUtils::NewDartSocketException(message, Dart_Null()); | 32 DartUtils::NewDartSocketException(message, Dart_Null()); |
| 32 Dart_ThrowException(socket_exception); | 33 Dart_ThrowException(socket_exception); |
| 33 } | 34 } |
| 34 | 35 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 bool request_client_certificate, | 82 bool request_client_certificate, |
| 82 bool require_client_certificate, | 83 bool require_client_certificate, |
| 83 bool send_client_certificate); | 84 bool send_client_certificate); |
| 84 void Destroy(); | 85 void Destroy(); |
| 85 void Handshake(); | 86 void Handshake(); |
| 86 void RegisterHandshakeCompleteCallback(Dart_Handle handshake_complete); | 87 void RegisterHandshakeCompleteCallback(Dart_Handle handshake_complete); |
| 87 void RegisterBadCertificateCallback(Dart_Handle callback); | 88 void RegisterBadCertificateCallback(Dart_Handle callback); |
| 88 Dart_Handle bad_certificate_callback() { | 89 Dart_Handle bad_certificate_callback() { |
| 89 return Dart_HandleFromPersistent(bad_certificate_callback_); | 90 return Dart_HandleFromPersistent(bad_certificate_callback_); |
| 90 } | 91 } |
| 92 intptr_t ProcessReadPlaintextBuffer(int start, int end); |
| 93 intptr_t ProcessWritePlaintextBuffer(int start1, int end1, |
| 94 int start2, int end2); |
| 95 intptr_t ProcessReadEncryptedBuffer(int start, int end); |
| 96 intptr_t ProcessWriteEncryptedBuffer(int start, int end); |
| 97 void ProcessAllBuffers(int starts[kNumBuffers], |
| 98 int ends[kNumBuffers], |
| 99 bool in_handshake); |
| 100 Dart_Handle PeerCertificate(); |
| 91 static void InitializeLibrary(const char* certificate_database, | 101 static void InitializeLibrary(const char* certificate_database, |
| 92 const char* password, | 102 const char* password, |
| 93 bool use_builtin_root_certificates, | 103 bool use_builtin_root_certificates, |
| 94 bool report_duplicate_initialization = true); | 104 bool report_duplicate_initialization = true); |
| 95 intptr_t ProcessBuffer(int bufferIndex); | 105 static Dart_Port GetServicePort(); |
| 96 Dart_Handle PeerCertificate(); | |
| 97 | 106 |
| 98 private: | 107 private: |
| 99 static const int kMemioBufferSize = 20 * KB; | 108 static const int kMemioBufferSize = 20 * KB; |
| 100 static bool library_initialized_; | 109 static bool library_initialized_; |
| 101 static const char* password_; | 110 static const char* password_; |
| 102 static dart::Mutex mutex_; // To protect library initialization. | 111 static dart::Mutex mutex_; // To protect library initialization. |
| 112 static NativeService filter_service_; |
| 103 | 113 |
| 104 uint8_t* buffers_[kNumBuffers]; | 114 uint8_t* buffers_[kNumBuffers]; |
| 105 int buffer_size_; | 115 int buffer_size_; |
| 106 int encrypted_buffer_size_; | 116 int encrypted_buffer_size_; |
| 107 Dart_PersistentHandle string_start_; | 117 Dart_PersistentHandle string_start_; |
| 108 Dart_PersistentHandle string_length_; | 118 Dart_PersistentHandle string_length_; |
| 109 Dart_PersistentHandle dart_buffer_objects_[kNumBuffers]; | 119 Dart_PersistentHandle dart_buffer_objects_[kNumBuffers]; |
| 110 Dart_PersistentHandle handshake_complete_; | 120 Dart_PersistentHandle handshake_complete_; |
| 111 Dart_PersistentHandle bad_certificate_callback_; | 121 Dart_PersistentHandle bad_certificate_callback_; |
| 112 bool in_handshake_; | 122 bool in_handshake_; |
| 113 bool is_server_; | 123 bool is_server_; |
| 114 char* client_certificate_name_; | 124 char* client_certificate_name_; |
| 115 PRFileDesc* filter_; | 125 PRFileDesc* filter_; |
| 116 | 126 |
| 117 static bool isEncrypted(int i) { | 127 static bool isBufferEncrypted(int i) { |
| 118 return static_cast<BufferIndex>(i) >= kFirstEncrypted; | 128 return static_cast<BufferIndex>(i) >= kFirstEncrypted; |
| 119 } | 129 } |
| 120 void InitializeBuffers(Dart_Handle dart_this); | 130 void InitializeBuffers(Dart_Handle dart_this); |
| 121 void InitializePlatformData(); | 131 void InitializePlatformData(); |
| 122 | 132 |
| 123 DISALLOW_COPY_AND_ASSIGN(SSLFilter); | 133 DISALLOW_COPY_AND_ASSIGN(SSLFilter); |
| 124 }; | 134 }; |
| 125 | 135 |
| 126 } // namespace bin | 136 } // namespace bin |
| 127 } // namespace dart | 137 } // namespace dart |
| 128 | 138 |
| 129 #endif // BIN_SECURE_SOCKET_H_ | 139 #endif // BIN_SECURE_SOCKET_H_ |
| OLD | NEW |