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_SERVER_SOCKET_NSS_H_ | 5 #ifndef NET_SOCKET_SSL_SERVER_SOCKET_NSS_H_ |
6 #define NET_SOCKET_SSL_SERVER_SOCKET_NSS_H_ | 6 #define NET_SOCKET_SSL_SERVER_SOCKET_NSS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <certt.h> | 9 #include <certt.h> |
10 #include <keyt.h> | 10 #include <keyt.h> |
(...skipping 24 matching lines...) Expand all Loading... |
35 base::RSAPrivateKey* key, | 35 base::RSAPrivateKey* key, |
36 const SSLConfig& ssl_config); | 36 const SSLConfig& ssl_config); |
37 virtual ~SSLServerSocketNSS(); | 37 virtual ~SSLServerSocketNSS(); |
38 | 38 |
39 // SSLServerSocket implementation. | 39 // SSLServerSocket implementation. |
40 virtual int Accept(CompletionCallback* callback); | 40 virtual int Accept(CompletionCallback* callback); |
41 virtual int Read(IOBuffer* buf, int buf_len, | 41 virtual int Read(IOBuffer* buf, int buf_len, |
42 CompletionCallback* callback); | 42 CompletionCallback* callback); |
43 virtual int Write(IOBuffer* buf, int buf_len, | 43 virtual int Write(IOBuffer* buf, int buf_len, |
44 CompletionCallback* callback); | 44 CompletionCallback* callback); |
45 virtual bool SetReceiveBufferSize(int32 size) { return false; } | 45 virtual bool SetReceiveBufferSize(int32 size); |
46 virtual bool SetSendBufferSize(int32 size) { return false; } | 46 virtual bool SetSendBufferSize(int32 size); |
47 | 47 |
48 private: | 48 private: |
49 virtual int Init(); | 49 enum State { |
| 50 STATE_NONE, |
| 51 STATE_HANDSHAKE, |
| 52 }; |
50 | 53 |
51 int InitializeSSLOptions(); | 54 int InitializeSSLOptions(); |
52 | 55 |
53 void OnSendComplete(int result); | 56 void OnSendComplete(int result); |
54 void OnRecvComplete(int result); | 57 void OnRecvComplete(int result); |
55 void OnHandshakeIOComplete(int result); | 58 void OnHandshakeIOComplete(int result); |
56 | 59 |
57 int BufferSend(); | 60 int BufferSend(); |
58 void BufferSendComplete(int result); | 61 void BufferSendComplete(int result); |
59 int BufferRecv(); | 62 int BufferRecv(); |
60 void BufferRecvComplete(int result); | 63 void BufferRecvComplete(int result); |
61 bool DoTransportIO(); | 64 bool DoTransportIO(); |
| 65 int DoPayloadRead(); |
62 int DoPayloadWrite(); | 66 int DoPayloadWrite(); |
63 int DoPayloadRead(); | |
64 | 67 |
65 int DoHandshakeLoop(int last_io_result); | 68 int DoHandshakeLoop(int last_io_result); |
66 int DoReadLoop(int result); | 69 int DoReadLoop(int result); |
67 int DoWriteLoop(int result); | 70 int DoWriteLoop(int result); |
68 int DoHandshake(); | 71 int DoHandshake(); |
69 void DoAcceptCallback(int result); | 72 void DoAcceptCallback(int result); |
70 void DoReadCallback(int result); | 73 void DoReadCallback(int result); |
71 void DoWriteCallback(int result); | 74 void DoWriteCallback(int result); |
72 | 75 |
73 static SECStatus OwnAuthCertHandler(void* arg, | 76 static SECStatus OwnAuthCertHandler(void* arg, |
74 PRFileDesc* socket, | 77 PRFileDesc* socket, |
75 PRBool checksig, | 78 PRBool checksig, |
76 PRBool is_server); | 79 PRBool is_server); |
77 static void HandshakeCallback(PRFileDesc* socket, void* arg); | 80 static void HandshakeCallback(PRFileDesc* socket, void* arg); |
78 | 81 |
| 82 virtual int Init(); |
| 83 |
79 // Members used to send and receive buffer. | 84 // Members used to send and receive buffer. |
80 CompletionCallbackImpl<SSLServerSocketNSS> buffer_send_callback_; | 85 CompletionCallbackImpl<SSLServerSocketNSS> buffer_send_callback_; |
81 CompletionCallbackImpl<SSLServerSocketNSS> buffer_recv_callback_; | 86 CompletionCallbackImpl<SSLServerSocketNSS> buffer_recv_callback_; |
82 bool transport_send_busy_; | 87 bool transport_send_busy_; |
83 bool transport_recv_busy_; | 88 bool transport_recv_busy_; |
84 | 89 |
85 scoped_refptr<IOBuffer> recv_buffer_; | 90 scoped_refptr<IOBuffer> recv_buffer_; |
86 | 91 |
87 BoundNetLog net_log_; | 92 BoundNetLog net_log_; |
88 | 93 |
(...skipping 22 matching lines...) Expand all Loading... |
111 // TODO(hclam): This memeber is currently not used. Should make use of this | 116 // TODO(hclam): This memeber is currently not used. Should make use of this |
112 // member to configure the socket. | 117 // member to configure the socket. |
113 SSLConfig ssl_config_; | 118 SSLConfig ssl_config_; |
114 | 119 |
115 // Certificate for the server. | 120 // Certificate for the server. |
116 scoped_refptr<X509Certificate> cert_; | 121 scoped_refptr<X509Certificate> cert_; |
117 | 122 |
118 // Private key used by the server. | 123 // Private key used by the server. |
119 scoped_ptr<base::RSAPrivateKey> key_; | 124 scoped_ptr<base::RSAPrivateKey> key_; |
120 | 125 |
121 enum State { | |
122 STATE_NONE, | |
123 STATE_HANDSHAKE, | |
124 }; | |
125 State next_handshake_state_; | 126 State next_handshake_state_; |
126 bool completed_handshake_; | 127 bool completed_handshake_; |
127 | 128 |
128 DISALLOW_COPY_AND_ASSIGN(SSLServerSocketNSS); | 129 DISALLOW_COPY_AND_ASSIGN(SSLServerSocketNSS); |
129 }; | 130 }; |
130 | 131 |
131 } // namespace net | 132 } // namespace net |
132 | 133 |
133 #endif // NET_SOCKET_SSL_SERVER_SOCKET_NSS_H_ | 134 #endif // NET_SOCKET_SSL_SERVER_SOCKET_NSS_H_ |
OLD | NEW |