diff options
Diffstat (limited to 'src/ssl')
-rw-r--r-- | src/ssl/tls_record.h | 1 | ||||
-rw-r--r-- | src/ssl/tls_server.cpp | 21 | ||||
-rw-r--r-- | src/ssl/tls_server.h | 15 |
3 files changed, 20 insertions, 17 deletions
diff --git a/src/ssl/tls_record.h b/src/ssl/tls_record.h index 84929b0ff..9fe3769e3 100644 --- a/src/ssl/tls_record.h +++ b/src/ssl/tls_record.h @@ -10,7 +10,6 @@ #include <botan/tls_session_key.h> #include <botan/tls_suites.h> -#include <botan/socket.h> #include <botan/pipe.h> #include <botan/mac.h> #include <botan/secqueue.h> diff --git a/src/ssl/tls_server.cpp b/src/ssl/tls_server.cpp index 6f79fe0fb..4e071da59 100644 --- a/src/ssl/tls_server.cpp +++ b/src/ssl/tls_server.cpp @@ -85,20 +85,21 @@ void server_check_state(Handshake_Type new_msg, Handshake_State* state) /* * TLS Server Constructor */ -TLS_Server::TLS_Server(const TLS_Policy& pol, - RandomNumberGenerator& r, - Socket& sock, +TLS_Server::TLS_Server(std::tr1::function<size_t (byte[], size_t)> input_fn, + std::tr1::function<void (const byte[], size_t)> output_fn, + const TLS_Policy& policy, + RandomNumberGenerator& rng, const X509_Certificate& cert, - const Private_Key& key) : - policy(pol), - rng(r), - peer(sock), - writer(std::tr1::bind(&Socket::write, std::tr1::ref(peer), _1, _2)) + const Private_Key& cert_key) : + input_fn(input_fn), + policy(policy), + rng(rng), + writer(output_fn) { state = 0; cert_chain.push_back(cert); - private_key = PKCS8::copy_key(key, rng); + private_key = PKCS8::copy_key(cert_key, rng); try { active = false; @@ -218,7 +219,7 @@ void TLS_Server::state_machine() while(bytes_needed) { size_t to_get = std::min<size_t>(record.size(), bytes_needed); - size_t got = peer.read(&record[0], to_get); + size_t got = input_fn(&record[0], to_get); if(got == 0) { diff --git a/src/ssl/tls_server.h b/src/ssl/tls_server.h index 09a1ef40b..69ccf46e8 100644 --- a/src/ssl/tls_server.h +++ b/src/ssl/tls_server.h @@ -11,7 +11,6 @@ #include <botan/tls_connection.h> #include <botan/tls_record.h> #include <botan/tls_policy.h> -#include <botan/socket.h> #include <vector> namespace Botan { @@ -34,11 +33,14 @@ class BOTAN_DLL TLS_Server : public TLS_Connection void close(); bool is_closed() const; - // FIXME: support cert chains (!) - // FIXME: support anonymous servers - TLS_Server(const TLS_Policy& policy, + /* + * FIXME: support cert chains (!) + * FIXME: support anonymous servers + */ + TLS_Server(std::tr1::function<size_t (byte[], size_t)> input_fn, + std::tr1::function<void (const byte[], size_t)> output_fn, + const TLS_Policy& policy, RandomNumberGenerator& rng, - Socket& peer, const X509_Certificate& cert, const Private_Key& cert_key); @@ -52,9 +54,10 @@ class BOTAN_DLL TLS_Server : public TLS_Connection void process_handshake_msg(Handshake_Type, const MemoryRegion<byte>&); + std::tr1::function<size_t (byte[], size_t)> input_fn; + const TLS_Policy& policy; RandomNumberGenerator& rng; - Socket& peer; Record_Writer writer; Record_Reader reader; |