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 28 matching lines...) Expand all Loading... |
39 // These enums must agree with those in sdk/lib/io/secure_socket.dart. | 39 // These enums must agree with those in sdk/lib/io/secure_socket.dart. |
40 enum BufferIndex { | 40 enum BufferIndex { |
41 kReadPlaintext, | 41 kReadPlaintext, |
42 kWritePlaintext, | 42 kWritePlaintext, |
43 kReadEncrypted, | 43 kReadEncrypted, |
44 kWriteEncrypted, | 44 kWriteEncrypted, |
45 kNumBuffers, | 45 kNumBuffers, |
46 kFirstEncrypted = kReadEncrypted | 46 kFirstEncrypted = kReadEncrypted |
47 }; | 47 }; |
48 | 48 |
49 static dart::Mutex* mutex; // To protect library initialization. | |
50 | |
51 SSLFilter() | 49 SSLFilter() |
52 : callback_error(NULL), | 50 : callback_error(NULL), |
53 string_start_(NULL), | 51 string_start_(NULL), |
54 string_length_(NULL), | 52 string_length_(NULL), |
55 handshake_complete_(NULL), | 53 handshake_complete_(NULL), |
56 bad_certificate_callback_(NULL), | 54 bad_certificate_callback_(NULL), |
57 in_handshake_(false), | 55 in_handshake_(false), |
58 client_certificate_name_(NULL), | 56 client_certificate_name_(NULL), |
59 filter_(NULL) { } | 57 filter_(NULL) { } |
60 | 58 |
(...skipping 21 matching lines...) Expand all Loading... |
82 int start2, int end2); | 80 int start2, int end2); |
83 intptr_t ProcessReadEncryptedBuffer(int start, int end); | 81 intptr_t ProcessReadEncryptedBuffer(int start, int end); |
84 intptr_t ProcessWriteEncryptedBuffer(int start, int end); | 82 intptr_t ProcessWriteEncryptedBuffer(int start, int end); |
85 bool ProcessAllBuffers(int starts[kNumBuffers], | 83 bool ProcessAllBuffers(int starts[kNumBuffers], |
86 int ends[kNumBuffers], | 84 int ends[kNumBuffers], |
87 bool in_handshake); | 85 bool in_handshake); |
88 Dart_Handle PeerCertificate(); | 86 Dart_Handle PeerCertificate(); |
89 static void InitializeLibrary(const char* certificate_database, | 87 static void InitializeLibrary(const char* certificate_database, |
90 const char* password, | 88 const char* password, |
91 bool use_builtin_root_certificates, | 89 bool use_builtin_root_certificates, |
92 bool read_only, | |
93 bool report_duplicate_initialization = true); | 90 bool report_duplicate_initialization = true); |
94 static Dart_Port GetServicePort(); | 91 static Dart_Port GetServicePort(); |
95 Dart_Handle callback_error; | 92 Dart_Handle callback_error; |
96 | 93 |
97 static char* GetPassword() { return password_; } | |
98 | |
99 private: | 94 private: |
100 static const int kMemioBufferSize = 20 * KB; | 95 static const int kMemioBufferSize = 20 * KB; |
101 static bool library_initialized_; | 96 static bool library_initialized_; |
102 static char* password_; | 97 static const char* password_; |
| 98 static dart::Mutex* mutex_; // To protect library initialization. |
103 static NativeService filter_service_; | 99 static NativeService filter_service_; |
104 | 100 |
105 uint8_t* buffers_[kNumBuffers]; | 101 uint8_t* buffers_[kNumBuffers]; |
106 int buffer_size_; | 102 int buffer_size_; |
107 int encrypted_buffer_size_; | 103 int encrypted_buffer_size_; |
108 Dart_PersistentHandle string_start_; | 104 Dart_PersistentHandle string_start_; |
109 Dart_PersistentHandle string_length_; | 105 Dart_PersistentHandle string_length_; |
110 Dart_PersistentHandle dart_buffer_objects_[kNumBuffers]; | 106 Dart_PersistentHandle dart_buffer_objects_[kNumBuffers]; |
111 Dart_PersistentHandle handshake_complete_; | 107 Dart_PersistentHandle handshake_complete_; |
112 Dart_PersistentHandle bad_certificate_callback_; | 108 Dart_PersistentHandle bad_certificate_callback_; |
113 bool in_handshake_; | 109 bool in_handshake_; |
114 bool is_server_; | 110 bool is_server_; |
115 char* client_certificate_name_; | 111 char* client_certificate_name_; |
116 PRFileDesc* filter_; | 112 PRFileDesc* filter_; |
117 | 113 |
118 static bool isBufferEncrypted(int i) { | 114 static bool isBufferEncrypted(int i) { |
119 return static_cast<BufferIndex>(i) >= kFirstEncrypted; | 115 return static_cast<BufferIndex>(i) >= kFirstEncrypted; |
120 } | 116 } |
121 void InitializeBuffers(Dart_Handle dart_this); | 117 void InitializeBuffers(Dart_Handle dart_this); |
| 118 void InitializePlatformData(); |
122 | 119 |
123 DISALLOW_COPY_AND_ASSIGN(SSLFilter); | 120 DISALLOW_COPY_AND_ASSIGN(SSLFilter); |
124 }; | 121 }; |
125 | 122 |
126 } // namespace bin | 123 } // namespace bin |
127 } // namespace dart | 124 } // namespace dart |
128 | 125 |
129 #endif // BIN_SECURE_SOCKET_H_ | 126 #endif // BIN_SECURE_SOCKET_H_ |
OLD | NEW |