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