| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 patch class TlsSocket { | |
| 6 /* patch */ static void setCertificateDatabase(String certificateDatabase, | |
| 7 [String password]) | |
| 8 native "TlsSocket_SetCertificateDatabase"; | |
| 9 } | |
| 10 | |
| 11 | |
| 12 patch class _TlsFilter { | |
| 13 /* patch */ factory _TlsFilter() => new _TlsFilterImpl(); | |
| 14 } | |
| 15 | |
| 16 | |
| 17 /** | |
| 18 * _TlsFilterImpl wraps a filter that encrypts and decrypts data travelling | |
| 19 * over a TLS encrypted socket. The filter also handles the handshaking | |
| 20 * and certificate verification. | |
| 21 * | |
| 22 * The filter exposes its input and output buffers as Dart objects that | |
| 23 * are backed by an external C array of bytes, so that both Dart code and | |
| 24 * native code can access the same data. | |
| 25 */ | |
| 26 class _TlsFilterImpl extends NativeFieldWrapperClass1 implements _TlsFilter { | |
| 27 _TlsFilterImpl() { | |
| 28 buffers = new List<_TlsExternalBuffer>(_TlsSocket.NUM_BUFFERS); | |
| 29 for (int i = 0; i < _TlsSocket.NUM_BUFFERS; ++i) { | |
| 30 buffers[i] = new _TlsExternalBuffer(); | |
| 31 } | |
| 32 } | |
| 33 | |
| 34 void connect(String hostName, | |
| 35 int port, | |
| 36 bool is_server, | |
| 37 String certificate_name) native "TlsSocket_Connect"; | |
| 38 | |
| 39 void destroy() { | |
| 40 buffers = null; | |
| 41 _destroy(); | |
| 42 } | |
| 43 | |
| 44 void _destroy() native "TlsSocket_Destroy"; | |
| 45 | |
| 46 void handshake() native "TlsSocket_Handshake"; | |
| 47 | |
| 48 void init() native "TlsSocket_Init"; | |
| 49 | |
| 50 int processBuffer(int bufferIndex) native "TlsSocket_ProcessBuffer"; | |
| 51 | |
| 52 void registerHandshakeCompleteCallback(Function handshakeCompleteHandler) | |
| 53 native "TlsSocket_RegisterHandshakeCompleteCallback"; | |
| 54 | |
| 55 List<_TlsExternalBuffer> buffers; | |
| 56 } | |
| OLD | NEW |