| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 * and certificate verification. | 52 * and certificate verification. |
| 53 */ | 53 */ |
| 54 class SSLFilter { | 54 class SSLFilter { |
| 55 public: | 55 public: |
| 56 // These enums must agree with those in sdk/lib/io/secure_socket.dart. | 56 // These enums must agree with those in sdk/lib/io/secure_socket.dart. |
| 57 enum BufferIndex { | 57 enum BufferIndex { |
| 58 kReadPlaintext, | 58 kReadPlaintext, |
| 59 kWritePlaintext, | 59 kWritePlaintext, |
| 60 kReadEncrypted, | 60 kReadEncrypted, |
| 61 kWriteEncrypted, | 61 kWriteEncrypted, |
| 62 kNumBuffers | 62 kNumBuffers, |
| 63 kFirstEncrypted = kReadEncrypted |
| 63 }; | 64 }; |
| 64 | 65 |
| 65 SSLFilter() | 66 SSLFilter() |
| 66 : string_start_(NULL), | 67 : string_start_(NULL), |
| 67 string_length_(NULL), | 68 string_length_(NULL), |
| 68 handshake_complete_(NULL), | 69 handshake_complete_(NULL), |
| 69 bad_certificate_callback_(NULL), | 70 bad_certificate_callback_(NULL), |
| 70 in_handshake_(false), | 71 in_handshake_(false), |
| 71 client_certificate_name_(NULL), | 72 client_certificate_name_(NULL), |
| 72 filter_(NULL) { } | 73 filter_(NULL) { } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 91 intptr_t ProcessBuffer(int bufferIndex); | 92 intptr_t ProcessBuffer(int bufferIndex); |
| 92 Dart_Handle PeerCertificate(); | 93 Dart_Handle PeerCertificate(); |
| 93 | 94 |
| 94 private: | 95 private: |
| 95 static const int kMemioBufferSize = 20 * KB; | 96 static const int kMemioBufferSize = 20 * KB; |
| 96 static bool library_initialized_; | 97 static bool library_initialized_; |
| 97 static const char* password_; | 98 static const char* password_; |
| 98 static dart::Mutex mutex_; // To protect library initialization. | 99 static dart::Mutex mutex_; // To protect library initialization. |
| 99 | 100 |
| 100 uint8_t* buffers_[kNumBuffers]; | 101 uint8_t* buffers_[kNumBuffers]; |
| 101 int64_t buffer_size_; | 102 int buffer_size_; |
| 103 int encrypted_buffer_size_; |
| 102 Dart_Handle string_start_; | 104 Dart_Handle string_start_; |
| 103 Dart_Handle string_length_; | 105 Dart_Handle string_length_; |
| 104 Dart_Handle dart_buffer_objects_[kNumBuffers]; | 106 Dart_Handle dart_buffer_objects_[kNumBuffers]; |
| 105 Dart_Handle handshake_complete_; | 107 Dart_Handle handshake_complete_; |
| 106 Dart_Handle bad_certificate_callback_; | 108 Dart_Handle bad_certificate_callback_; |
| 107 bool in_handshake_; | 109 bool in_handshake_; |
| 108 bool is_server_; | 110 bool is_server_; |
| 109 char* client_certificate_name_; | 111 char* client_certificate_name_; |
| 110 PRFileDesc* filter_; | 112 PRFileDesc* filter_; |
| 111 | 113 |
| 114 static bool isEncrypted(int i) { |
| 115 return static_cast<BufferIndex>(i) >= kFirstEncrypted; |
| 116 } |
| 112 void InitializeBuffers(Dart_Handle dart_this); | 117 void InitializeBuffers(Dart_Handle dart_this); |
| 113 void InitializePlatformData(); | 118 void InitializePlatformData(); |
| 114 | 119 |
| 115 DISALLOW_COPY_AND_ASSIGN(SSLFilter); | 120 DISALLOW_COPY_AND_ASSIGN(SSLFilter); |
| 116 }; | 121 }; |
| 117 | 122 |
| 118 #endif // BIN_SECURE_SOCKET_H_ | 123 #endif // BIN_SECURE_SOCKET_H_ |
| OLD | NEW |