| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_SOCKET_SSL_CLIENT_SOCKET_NSS_H_ | 5 #ifndef NET_SOCKET_SSL_CLIENT_SOCKET_NSS_H_ |
| 6 #define NET_SOCKET_SSL_CLIENT_SOCKET_NSS_H_ | 6 #define NET_SOCKET_SSL_CLIENT_SOCKET_NSS_H_ |
| 7 | 7 |
| 8 // Work around https://bugzilla.mozilla.org/show_bug.cgi?id=455424 | 8 // Work around https://bugzilla.mozilla.org/show_bug.cgi?id=455424 |
| 9 // until NSS 3.12.2 comes out and we update to it. | 9 // until NSS 3.12.2 comes out and we update to it. |
| 10 #define Lock FOO_NSS_Lock | 10 #define Lock FOO_NSS_Lock |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 | 50 |
| 51 // Socket methods: | 51 // Socket methods: |
| 52 virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback); | 52 virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback); |
| 53 virtual int Write(IOBuffer* buf, int buf_len, CompletionCallback* callback); | 53 virtual int Write(IOBuffer* buf, int buf_len, CompletionCallback* callback); |
| 54 virtual bool SetReceiveBufferSize(int32 size); | 54 virtual bool SetReceiveBufferSize(int32 size); |
| 55 virtual bool SetSendBufferSize(int32 size); | 55 virtual bool SetSendBufferSize(int32 size); |
| 56 | 56 |
| 57 private: | 57 private: |
| 58 void InvalidateSessionIfBadCertificate(); | 58 void InvalidateSessionIfBadCertificate(); |
| 59 X509Certificate* UpdateServerCert(); | 59 X509Certificate* UpdateServerCert(); |
| 60 void DoCallback(int result); | 60 void DoReadCallback(int result); |
| 61 void DoWriteCallback(int result); |
| 61 void DoConnectCallback(int result); | 62 void DoConnectCallback(int result); |
| 62 void OnIOComplete(int result); | 63 void OnHandshakeIOComplete(int result); |
| 64 void OnSendComplete(int result); |
| 65 void OnRecvComplete(int result); |
| 63 | 66 |
| 64 int DoLoop(int last_io_result); | 67 int DoHandshakeLoop(int last_io_result); |
| 65 int DoHandshakeRead(); | 68 int DoReadLoop(int result); |
| 69 int DoWriteLoop(int result); |
| 70 |
| 71 int DoHandshake(); |
| 66 int DoVerifyCert(int result); | 72 int DoVerifyCert(int result); |
| 67 int DoVerifyCertComplete(int result); | 73 int DoVerifyCertComplete(int result); |
| 68 int DoPayloadRead(); | 74 int DoPayloadRead(); |
| 69 int DoPayloadWrite(); | 75 int DoPayloadWrite(); |
| 70 int Init(); | 76 int Init(); |
| 77 |
| 78 bool DoTransportIO(); |
| 71 int BufferSend(void); | 79 int BufferSend(void); |
| 72 int BufferRecv(void); | 80 int BufferRecv(void); |
| 73 void BufferSendComplete(int result); | 81 void BufferSendComplete(int result); |
| 74 void BufferRecvComplete(int result); | 82 void BufferRecvComplete(int result); |
| 75 | 83 |
| 76 // NSS calls this when checking certificates. We pass 'this' as the first | 84 // NSS calls this when checking certificates. We pass 'this' as the first |
| 77 // argument. | 85 // argument. |
| 78 static SECStatus OwnAuthCertHandler(void* arg, PRFileDesc* socket, | 86 static SECStatus OwnAuthCertHandler(void* arg, PRFileDesc* socket, |
| 79 PRBool checksig, PRBool is_server); | 87 PRBool checksig, PRBool is_server); |
| 80 // NSS calls this when handshake is completed. We pass 'this' as the second | 88 // NSS calls this when handshake is completed. We pass 'this' as the second |
| 81 // argument. | 89 // argument. |
| 82 static void HandshakeCallback(PRFileDesc* socket, void* arg); | 90 static void HandshakeCallback(PRFileDesc* socket, void* arg); |
| 83 | 91 |
| 84 CompletionCallbackImpl<SSLClientSocketNSS> buffer_send_callback_; | 92 CompletionCallbackImpl<SSLClientSocketNSS> buffer_send_callback_; |
| 85 CompletionCallbackImpl<SSLClientSocketNSS> buffer_recv_callback_; | 93 CompletionCallbackImpl<SSLClientSocketNSS> buffer_recv_callback_; |
| 86 bool transport_send_busy_; | 94 bool transport_send_busy_; |
| 87 bool transport_recv_busy_; | 95 bool transport_recv_busy_; |
| 88 scoped_refptr<IOBuffer> recv_buffer_; | 96 scoped_refptr<IOBuffer> recv_buffer_; |
| 89 | 97 |
| 90 CompletionCallbackImpl<SSLClientSocketNSS> io_callback_; | 98 CompletionCallbackImpl<SSLClientSocketNSS> handshake_io_callback_; |
| 91 scoped_ptr<ClientSocket> transport_; | 99 scoped_ptr<ClientSocket> transport_; |
| 92 std::string hostname_; | 100 std::string hostname_; |
| 93 SSLConfig ssl_config_; | 101 SSLConfig ssl_config_; |
| 94 | 102 |
| 95 CompletionCallback* user_connect_callback_; | 103 CompletionCallback* user_connect_callback_; |
| 96 CompletionCallback* user_callback_; | 104 CompletionCallback* user_read_callback_; |
| 105 CompletionCallback* user_write_callback_; |
| 97 | 106 |
| 98 // Used by both Read and Write functions. | 107 // Used by Read function. |
| 99 scoped_refptr<IOBuffer> user_buf_; | 108 scoped_refptr<IOBuffer> user_read_buf_; |
| 100 int user_buf_len_; | 109 int user_read_buf_len_; |
| 110 |
| 111 // Used by Write function. |
| 112 scoped_refptr<IOBuffer> user_write_buf_; |
| 113 int user_write_buf_len_; |
| 101 | 114 |
| 102 // Set when handshake finishes. | 115 // Set when handshake finishes. |
| 103 scoped_refptr<X509Certificate> server_cert_; | 116 scoped_refptr<X509Certificate> server_cert_; |
| 104 CertVerifyResult server_cert_verify_result_; | 117 CertVerifyResult server_cert_verify_result_; |
| 105 | 118 |
| 106 scoped_ptr<CertVerifier> verifier_; | 119 scoped_ptr<CertVerifier> verifier_; |
| 107 | 120 |
| 108 bool completed_handshake_; | 121 bool completed_handshake_; |
| 109 | 122 |
| 110 enum State { | 123 enum State { |
| 111 STATE_NONE, | 124 STATE_NONE, |
| 112 STATE_HANDSHAKE_READ, | 125 STATE_HANDSHAKE, |
| 113 STATE_VERIFY_CERT, | 126 STATE_VERIFY_CERT, |
| 114 STATE_VERIFY_CERT_COMPLETE, | 127 STATE_VERIFY_CERT_COMPLETE, |
| 115 STATE_PAYLOAD_WRITE, | |
| 116 STATE_PAYLOAD_READ, | |
| 117 }; | 128 }; |
| 118 State next_state_; | 129 State next_handshake_state_; |
| 119 | 130 |
| 120 // The NSS SSL state machine | 131 // The NSS SSL state machine |
| 121 PRFileDesc* nss_fd_; | 132 PRFileDesc* nss_fd_; |
| 122 | 133 |
| 123 // Buffers for the network end of the SSL state machine | 134 // Buffers for the network end of the SSL state machine |
| 124 memio_Private* nss_bufs_; | 135 memio_Private* nss_bufs_; |
| 125 | 136 |
| 126 static bool nss_options_initialized_; | 137 static bool nss_options_initialized_; |
| 127 }; | 138 }; |
| 128 | 139 |
| 129 } // namespace net | 140 } // namespace net |
| 130 | 141 |
| 131 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_NSS_H_ | 142 #endif // NET_SOCKET_SSL_CLIENT_SOCKET_NSS_H_ |
| OLD | NEW |