| 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 part of dart.io; | 5 part of dart.io; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * SecureSocket provides a secure (SSL or TLS) client connection to a server. | 8 * SecureSocket provides a secure (SSL or TLS) client connection to a server. |
| 9 * The certificate provided by the server is checked | 9 * The certificate provided by the server is checked |
| 10 * using the certificate database (optionally) provided in initialize(). | 10 * using the certificate database (optionally) provided in initialize(). |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 Function _socketDataHandler; | 634 Function _socketDataHandler; |
| 635 Function _socketErrorHandler; | 635 Function _socketErrorHandler; |
| 636 Function _socketCloseHandler; | 636 Function _socketCloseHandler; |
| 637 Timer scheduledDataEvent; | 637 Timer scheduledDataEvent; |
| 638 | 638 |
| 639 _SecureFilter secureFilter; | 639 _SecureFilter secureFilter; |
| 640 } | 640 } |
| 641 | 641 |
| 642 | 642 |
| 643 class _ExternalBuffer { | 643 class _ExternalBuffer { |
| 644 // Performance is improved if a full buffer of plaintext fits |
| 645 // in the encrypted buffer, when encrypted. |
| 644 static final int SIZE = 8 * 1024; | 646 static final int SIZE = 8 * 1024; |
| 647 static final int ENCRYPTED_SIZE = 10 * 1024; |
| 645 _ExternalBuffer() : start = 0, length = 0; | 648 _ExternalBuffer() : start = 0, length = 0; |
| 646 | 649 |
| 647 // TODO(whesse): Consider making this a circular buffer. Only if it helps. | 650 // TODO(whesse): Consider making this a circular buffer. Only if it helps. |
| 648 void advanceStart(int numBytes) { | 651 void advanceStart(int numBytes) { |
| 649 start += numBytes; | 652 start += numBytes; |
| 650 length -= numBytes; | 653 length -= numBytes; |
| 651 if (length == 0) { | 654 if (length == 0) { |
| 652 start = 0; | 655 start = 0; |
| 653 } | 656 } |
| 654 } | 657 } |
| 655 | 658 |
| 656 int get free => SIZE - (start + length); | 659 int get free => data.length - (start + length); |
| 657 | 660 |
| 658 List data; // This will be a ExternalByteArray, backed by C allocated data. | 661 List data; // This will be a ExternalByteArray, backed by C allocated data. |
| 659 int start; | 662 int start; |
| 660 int length; | 663 int length; |
| 661 } | 664 } |
| 662 | 665 |
| 663 | 666 |
| 664 abstract class _SecureFilter { | 667 abstract class _SecureFilter { |
| 665 external factory _SecureFilter(); | 668 external factory _SecureFilter(); |
| 666 | 669 |
| 667 void connect(String hostName, | 670 void connect(String hostName, |
| 668 int port, | 671 int port, |
| 669 bool is_server, | 672 bool is_server, |
| 670 String certificateName, | 673 String certificateName, |
| 671 bool requestClientCertificate, | 674 bool requestClientCertificate, |
| 672 bool requireClientCertificate, | 675 bool requireClientCertificate, |
| 673 bool sendClientCertificate); | 676 bool sendClientCertificate); |
| 674 void destroy(); | 677 void destroy(); |
| 675 void handshake(); | 678 void handshake(); |
| 676 void init(); | 679 void init(); |
| 677 X509Certificate get peerCertificate; | 680 X509Certificate get peerCertificate; |
| 678 int processBuffer(int bufferIndex); | 681 int processBuffer(int bufferIndex); |
| 679 void registerBadCertificateCallback(Function callback); | 682 void registerBadCertificateCallback(Function callback); |
| 680 void registerHandshakeCompleteCallback(Function handshakeCompleteHandler); | 683 void registerHandshakeCompleteCallback(Function handshakeCompleteHandler); |
| 681 | 684 |
| 682 List<_ExternalBuffer> get buffers; | 685 List<_ExternalBuffer> get buffers; |
| 683 } | 686 } |
| OLD | NEW |