Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
| 8 #include <certt.h> | 8 #include <certt.h> |
| 9 #include <keyt.h> | 9 #include <keyt.h> |
| 10 #include <nspr.h> | 10 #include <nspr.h> |
| 11 #include <nss.h> | 11 #include <nss.h> |
| 12 #include <stdint.h> | 12 #include <stdint.h> |
| 13 | 13 |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "net/base/completion_callback.h" | 16 #include "net/base/completion_callback.h" |
| 17 #include "net/base/host_port_pair.h" | 17 #include "net/base/host_port_pair.h" |
| 18 #include "net/base/nss_memio.h" | 18 #include "net/base/nss_memio.h" |
| 19 #include "net/log/net_log.h" | 19 #include "net/log/net_log.h" |
| 20 #include "net/socket/ssl_server_socket.h" | 20 #include "net/socket/ssl_server_socket.h" |
| 21 #include "net/ssl/ssl_server_config.h" | 21 #include "net/ssl/ssl_server_config.h" |
| 22 | 22 |
| 23 namespace net { | 23 namespace net { |
| 24 | 24 |
| 25 class SSLServerSocketContextNSS : public SSLServerSocketContext { | |
| 26 public: | |
| 27 SSLServerSocketContextNSS(scoped_refptr<X509Certificate> certificate, | |
| 28 const crypto::RSAPrivateKey& key, | |
| 29 const SSLServerConfig& ssl_server_config); | |
| 30 | |
| 31 scoped_ptr<SSLServerSocket> CreateSSLServerSocket( | |
| 32 scoped_ptr<StreamSocket> socket) override; | |
| 33 | |
| 34 private: | |
| 35 ~SSLServerSocketContextNSS(); | |
| 36 | |
| 37 // Options for the SSL socket. | |
| 38 SSLServerConfig ssl_server_config_; | |
| 39 | |
| 40 // Certificate for the server. | |
| 41 scoped_refptr<X509Certificate> cert_; | |
| 42 | |
| 43 // Private key used by the server. | |
| 44 scoped_ptr<crypto::RSAPrivateKey> key_; | |
| 45 }; | |
| 46 | |
| 25 class SSLServerSocketNSS : public SSLServerSocket { | 47 class SSLServerSocketNSS : public SSLServerSocket { |
|
davidben
2016/01/22 23:57:48
I don't think this type actually needs to be defin
ryanchung
2016/01/29 23:28:15
Done.
| |
| 26 public: | 48 public: |
| 27 // See comments on CreateSSLServerSocket for details of how these | |
| 28 // parameters are used. | |
| 29 SSLServerSocketNSS(scoped_ptr<StreamSocket> socket, | |
| 30 scoped_refptr<X509Certificate> certificate, | |
| 31 const crypto::RSAPrivateKey& key, | |
| 32 const SSLServerConfig& ssl_server_config); | |
| 33 ~SSLServerSocketNSS() override; | 49 ~SSLServerSocketNSS() override; |
| 34 | 50 |
| 35 // SSLServerSocket interface. | 51 // SSLServerSocket interface. |
| 36 int Handshake(const CompletionCallback& callback) override; | 52 int Handshake(const CompletionCallback& callback) override; |
| 37 | 53 |
| 38 // SSLSocket interface. | 54 // SSLSocket interface. |
| 39 int ExportKeyingMaterial(const base::StringPiece& label, | 55 int ExportKeyingMaterial(const base::StringPiece& label, |
| 40 bool has_context, | 56 bool has_context, |
| 41 const base::StringPiece& context, | 57 const base::StringPiece& context, |
| 42 unsigned char* out, | 58 unsigned char* out, |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 72 void ClearConnectionAttempts() override {} | 88 void ClearConnectionAttempts() override {} |
| 73 void AddConnectionAttempts(const ConnectionAttempts& attempts) override {} | 89 void AddConnectionAttempts(const ConnectionAttempts& attempts) override {} |
| 74 int64_t GetTotalReceivedBytes() const override; | 90 int64_t GetTotalReceivedBytes() const override; |
| 75 | 91 |
| 76 private: | 92 private: |
| 77 enum State { | 93 enum State { |
| 78 STATE_NONE, | 94 STATE_NONE, |
| 79 STATE_HANDSHAKE, | 95 STATE_HANDSHAKE, |
| 80 }; | 96 }; |
| 81 | 97 |
| 98 // See comments on CreateSSLServerSocket for details of how these | |
| 99 // parameters are used. | |
| 100 SSLServerSocketNSS(scoped_ptr<StreamSocket> socket, | |
| 101 scoped_refptr<X509Certificate> certificate, | |
| 102 const crypto::RSAPrivateKey& key, | |
| 103 const SSLServerConfig& ssl_server_config); | |
| 104 friend class SSLServerSocketContextNSS; | |
| 105 | |
| 82 int InitializeSSLOptions(); | 106 int InitializeSSLOptions(); |
| 83 | 107 |
| 84 void OnSendComplete(int result); | 108 void OnSendComplete(int result); |
| 85 void OnRecvComplete(int result); | 109 void OnRecvComplete(int result); |
| 86 void OnHandshakeIOComplete(int result); | 110 void OnHandshakeIOComplete(int result); |
| 87 | 111 |
| 88 int BufferSend(); | 112 int BufferSend(); |
| 89 void BufferSendComplete(int result); | 113 void BufferSendComplete(int result); |
| 90 int BufferRecv(); | 114 int BufferRecv(); |
| 91 void BufferRecvComplete(int result); | 115 void BufferRecvComplete(int result); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 | 173 |
| 150 State next_handshake_state_; | 174 State next_handshake_state_; |
| 151 bool completed_handshake_; | 175 bool completed_handshake_; |
| 152 | 176 |
| 153 DISALLOW_COPY_AND_ASSIGN(SSLServerSocketNSS); | 177 DISALLOW_COPY_AND_ASSIGN(SSLServerSocketNSS); |
| 154 }; | 178 }; |
| 155 | 179 |
| 156 } // namespace net | 180 } // namespace net |
| 157 | 181 |
| 158 #endif // NET_SOCKET_SSL_SERVER_SOCKET_NSS_H_ | 182 #endif // NET_SOCKET_SSL_SERVER_SOCKET_NSS_H_ |
| OLD | NEW |