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() { return Dart_NewHandleFromPersistent(b
ad_certificate_callback_); } |
93 static void InitializeLibrary(const char* certificate_database, | 93 static void InitializeLibrary(const char* certificate_database, |
94 const char* password, | 94 const char* password, |
95 bool use_builtin_root_certificates, | 95 bool use_builtin_root_certificates, |
96 bool report_duplicate_initialization = true); | 96 bool report_duplicate_initialization = true); |
97 intptr_t ProcessBuffer(int bufferIndex); | 97 intptr_t ProcessBuffer(int bufferIndex); |
98 Dart_Handle PeerCertificate(); | 98 Dart_Handle PeerCertificate(); |
99 | 99 |
100 private: | 100 private: |
101 static const int kMemioBufferSize = 20 * KB; | 101 static const int kMemioBufferSize = 20 * KB; |
102 static bool library_initialized_; | 102 static bool library_initialized_; |
103 static const char* password_; | 103 static const char* password_; |
104 static dart::Mutex mutex_; // To protect library initialization. | 104 static dart::Mutex mutex_; // To protect library initialization. |
105 | 105 |
106 uint8_t* buffers_[kNumBuffers]; | 106 uint8_t* buffers_[kNumBuffers]; |
107 int buffer_size_; | 107 int buffer_size_; |
108 int encrypted_buffer_size_; | 108 int encrypted_buffer_size_; |
109 Dart_Handle string_start_; | 109 Dart_PersistentHandle string_start_; |
110 Dart_Handle string_length_; | 110 Dart_PersistentHandle string_length_; |
111 Dart_Handle dart_buffer_objects_[kNumBuffers]; | 111 Dart_PersistentHandle dart_buffer_objects_[kNumBuffers]; |
112 Dart_Handle handshake_complete_; | 112 Dart_PersistentHandle handshake_complete_; |
113 Dart_Handle bad_certificate_callback_; | 113 Dart_PersistentHandle bad_certificate_callback_; |
114 bool in_handshake_; | 114 bool in_handshake_; |
115 bool is_server_; | 115 bool is_server_; |
116 char* client_certificate_name_; | 116 char* client_certificate_name_; |
117 PRFileDesc* filter_; | 117 PRFileDesc* filter_; |
118 | 118 |
119 static bool isEncrypted(int i) { | 119 static bool isEncrypted(int i) { |
120 return static_cast<BufferIndex>(i) >= kFirstEncrypted; | 120 return static_cast<BufferIndex>(i) >= kFirstEncrypted; |
121 } | 121 } |
122 void InitializeBuffers(Dart_Handle dart_this); | 122 void InitializeBuffers(Dart_Handle dart_this); |
123 void InitializePlatformData(); | 123 void InitializePlatformData(); |
124 | 124 |
125 DISALLOW_COPY_AND_ASSIGN(SSLFilter); | 125 DISALLOW_COPY_AND_ASSIGN(SSLFilter); |
126 }; | 126 }; |
127 | 127 |
128 } // namespace bin | 128 } // namespace bin |
129 } // namespace dart | 129 } // namespace dart |
130 | 130 |
131 #endif // BIN_SECURE_SOCKET_H_ | 131 #endif // BIN_SECURE_SOCKET_H_ |
OLD | NEW |