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_TLS_SOCKET_H_ | 5 #ifndef BIN_SECURE_SOCKET_H_ |
6 #define BIN_TLS_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 | 16 |
(...skipping 20 matching lines...) Expand all Loading... |
37 error_message[error_length] = '\0'; | 37 error_message[error_length] = '\0'; |
38 OSError os_error_struct(error_code, error_message, OSError::kNSS); | 38 OSError os_error_struct(error_code, error_message, OSError::kNSS); |
39 Dart_Handle os_error = DartUtils::NewDartOSError(&os_error_struct); | 39 Dart_Handle os_error = DartUtils::NewDartOSError(&os_error_struct); |
40 Dart_Handle socket_io_exception = | 40 Dart_Handle socket_io_exception = |
41 DartUtils::NewDartSocketIOException(message, os_error); | 41 DartUtils::NewDartSocketIOException(message, os_error); |
42 free(error_message); | 42 free(error_message); |
43 Dart_ThrowException(socket_io_exception); | 43 Dart_ThrowException(socket_io_exception); |
44 } | 44 } |
45 | 45 |
46 /* | 46 /* |
47 * TlsFilter encapsulates the NSS SSL(TLS) code in a filter, that communicates | 47 * SSLFilter encapsulates the NSS SSL(TLS) code in a filter, that communicates |
48 * with the containing _TlsFilterImpl Dart object through four shared | 48 * with the containing _SecureFilterImpl Dart object through four shared |
49 * ExternalByteArray buffers, for reading and writing plaintext, and | 49 * ExternalByteArray buffers, for reading and writing plaintext, and |
50 * reading and writing encrypted text. The filter handles handshaking | 50 * reading and writing encrypted text. The filter handles handshaking |
51 * and certificate verification. | 51 * and certificate verification. |
52 */ | 52 */ |
53 class TlsFilter { | 53 class SSLFilter { |
54 public: | 54 public: |
55 // These enums must agree with those in sdk/lib/io/tls_socket.dart. | 55 // These enums must agree with those in sdk/lib/io/secure_socket.dart. |
56 enum BufferIndex { | 56 enum BufferIndex { |
57 kReadPlaintext, | 57 kReadPlaintext, |
58 kWritePlaintext, | 58 kWritePlaintext, |
59 kReadEncrypted, | 59 kReadEncrypted, |
60 kWriteEncrypted, | 60 kWriteEncrypted, |
61 kNumBuffers | 61 kNumBuffers |
62 }; | 62 }; |
63 | 63 |
64 TlsFilter() | 64 SSLFilter() |
65 : string_start_(NULL), | 65 : string_start_(NULL), |
66 string_length_(NULL), | 66 string_length_(NULL), |
67 handshake_complete_(NULL), | 67 handshake_complete_(NULL), |
68 in_handshake_(false), | 68 in_handshake_(false), |
69 filter_(NULL) { } | 69 filter_(NULL) { } |
70 | 70 |
71 void Init(Dart_Handle dart_this); | 71 void Init(Dart_Handle dart_this); |
72 void Connect(const char* host, | 72 void Connect(const char* host, |
73 int port, | 73 int port, |
74 bool is_server, | 74 bool is_server, |
(...skipping 18 matching lines...) Expand all Loading... |
93 Dart_Handle string_length_; | 93 Dart_Handle string_length_; |
94 Dart_Handle dart_buffer_objects_[kNumBuffers]; | 94 Dart_Handle dart_buffer_objects_[kNumBuffers]; |
95 Dart_Handle handshake_complete_; | 95 Dart_Handle handshake_complete_; |
96 bool in_handshake_; | 96 bool in_handshake_; |
97 bool is_server_; | 97 bool is_server_; |
98 PRFileDesc* filter_; | 98 PRFileDesc* filter_; |
99 | 99 |
100 void InitializeBuffers(Dart_Handle dart_this); | 100 void InitializeBuffers(Dart_Handle dart_this); |
101 void InitializePlatformData(); | 101 void InitializePlatformData(); |
102 | 102 |
103 DISALLOW_COPY_AND_ASSIGN(TlsFilter); | 103 DISALLOW_COPY_AND_ASSIGN(SSLFilter); |
104 }; | 104 }; |
105 | 105 |
106 #endif // BIN_TLS_SOCKET_H_ | 106 #endif // BIN_SECURE_SOCKET_H_ |
OLD | NEW |