diff options
author | lloyd <[email protected]> | 2012-01-23 15:30:29 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2012-01-23 15:30:29 +0000 |
commit | a445f7f4a1089fc034c35c500e1572eb9518f44f (patch) | |
tree | 3231b324a290cb9c67e9a0512a40acad8fa024a1 /doc | |
parent | 8bba8bab6077ee184c102d6634b288e7dd32b1dc (diff) |
Since this branch is hugely API breaking already, go ahead and put
everything into a new namespace (Botan::TLS), removing the TLS_
prefixes on everything.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/examples/asio_tls_server.cpp | 20 | ||||
-rw-r--r-- | doc/examples/tls_client.cpp | 17 | ||||
-rw-r--r-- | doc/examples/tls_server.cpp | 16 |
3 files changed, 27 insertions, 26 deletions
diff --git a/doc/examples/asio_tls_server.cpp b/doc/examples/asio_tls_server.cpp index 2ff640983..90f4fc20a 100644 --- a/doc/examples/asio_tls_server.cpp +++ b/doc/examples/asio_tls_server.cpp @@ -23,9 +23,9 @@ class tls_server_session : public boost::enable_shared_from_this<tls_server_sess typedef boost::shared_ptr<tls_server_session> pointer; static pointer create(asio::io_service& io_service, - Botan::TLS_Session_Manager& session_manager, + Botan::TLS::Session_Manager& session_manager, Botan::Credentials_Manager& credentials, - Botan::TLS_Policy& policy, + Botan::TLS::Policy& policy, Botan::RandomNumberGenerator& rng) { return pointer( @@ -53,9 +53,9 @@ class tls_server_session : public boost::enable_shared_from_this<tls_server_sess private: tls_server_session(asio::io_service& io_service, - Botan::TLS_Session_Manager& session_manager, + Botan::TLS::Session_Manager& session_manager, Botan::Credentials_Manager& credentials, - Botan::TLS_Policy& policy, + Botan::TLS::Policy& policy, Botan::RandomNumberGenerator& rng) : m_socket(io_service), m_tls(boost::bind(&tls_server_session::tls_output_wanted, this, _1, _2), @@ -135,7 +135,7 @@ class tls_server_session : public boost::enable_shared_from_this<tls_server_sess void tls_data_recv(const byte buf[], size_t buf_len, Botan::u16bit alert_info) { - if(buf_len == 0 && alert_info != Botan::NULL_ALERT) + if(buf_len == 0 && alert_info != Botan::TLS::NULL_ALERT) { //printf("Alert: %d\n", alert_info); if(alert_info == 0) @@ -164,15 +164,15 @@ class tls_server_session : public boost::enable_shared_from_this<tls_server_sess } } - bool tls_handshake_complete(const Botan::TLS_Session& session) + bool tls_handshake_complete(const Botan::TLS::Session& session) { return true; } tcp::socket m_socket; - Botan::TLS_Server m_tls; + Botan::TLS::Server m_tls; - unsigned char m_read_buf[Botan::MAX_TLS_RECORD_SIZE]; + unsigned char m_read_buf[Botan::TLS::MAX_TLS_RECORD_SIZE]; // used to hold the data currently being written by the system std::vector<byte> m_write_buf; @@ -215,7 +215,7 @@ class Credentials_Manager_Simple : public Botan::Credentials_Manager std::map<Botan::X509_Certificate, Botan::Private_Key*> certs_and_keys; }; -class Server_TLS_Policy : public Botan::TLS_Policy +class Server_TLS_Policy : public Botan::TLS::Policy { public: //bool require_client_auth() const { return true; } @@ -289,7 +289,7 @@ class tls_server tcp::acceptor m_acceptor; Botan::AutoSeeded_RNG m_rng; - Botan::TLS_Session_Manager_In_Memory m_session_manager; + Botan::TLS::Session_Manager_In_Memory m_session_manager; Server_TLS_Policy m_policy; Credentials_Manager_Simple m_creds; }; diff --git a/doc/examples/tls_client.cpp b/doc/examples/tls_client.cpp index 42fecaf37..3d4dd38b7 100644 --- a/doc/examples/tls_client.cpp +++ b/doc/examples/tls_client.cpp @@ -20,7 +20,7 @@ using namespace Botan; using namespace std::tr1::placeholders; -class Client_TLS_Policy : public TLS_Policy +class Client_TLS_Policy : public TLS::Policy { public: //Version_Code pref_version() const { return TLS_V12; } @@ -72,11 +72,12 @@ int connect_to_host(const std::string& host, u16bit port) return fd; } -bool handshake_complete(const TLS_Session& session) +bool handshake_complete(const TLS::Session& session) { std::cout << "Handshake complete!\n"; std::cout << "Protocol version " << (int)session.major_version() << "." << (int)session.minor_version() << "\n"; + std::cout << "Ciphersuite " << std::hex << session.ciphersuite() << "\n"; std::cout << "Session ID " << hex_encode(session.session_id()) << "\n"; return true; @@ -108,7 +109,7 @@ bool got_alert = false; void process_data(const byte buf[], size_t buf_size, u16bit alert_info) { - if(alert_info != NULL_ALERT) + if(alert_info != TLS::NULL_ALERT) { std::cout << "Alert: " << alert_info << "\n"; got_alert = true; @@ -128,15 +129,15 @@ std::string protocol_chooser(const std::vector<std::string>& protocols) } void doit(RandomNumberGenerator& rng, - TLS_Policy& policy, - TLS_Session_Manager& session_manager, + TLS::Policy& policy, + TLS::Session_Manager& session_manager, Credentials_Manager& creds, const std::string& host, u16bit port) { int sockfd = connect_to_host(host, port); - TLS_Client client(std::tr1::bind(socket_write, sockfd, _1, _2), + TLS::Client client(std::tr1::bind(socket_write, sockfd, _1, _2), process_data, handshake_complete, session_manager, @@ -180,7 +181,7 @@ void doit(RandomNumberGenerator& rng, } const size_t needed = client.received_data(buf, got); - std::cout << "Socket - got " << got << " bytes, need " << needed << "\n"; + //std::cout << "Socket - got " << got << " bytes, need " << needed << "\n"; } else if(FD_ISSET(STDIN_FILENO, &readfds)) { @@ -251,7 +252,7 @@ int main(int argc, char* argv[]) LibraryInitializer botan_init; AutoSeeded_RNG rng; Client_TLS_Policy policy; - TLS_Session_Manager_In_Memory session_manager; + TLS::Session_Manager_In_Memory session_manager; Credentials_Manager_Simple creds(rng); diff --git a/doc/examples/tls_server.cpp b/doc/examples/tls_server.cpp index 2dbfb4aeb..6f986c7a1 100644 --- a/doc/examples/tls_server.cpp +++ b/doc/examples/tls_server.cpp @@ -52,7 +52,7 @@ class Credentials_Manager_Simple : public Credentials_Manager std::map<X509_Certificate, Private_Key*> certs_and_keys; }; -bool handshake_complete(const TLS_Session& session) +bool handshake_complete(const TLS::Session& session) { printf("Handshake complete, protocol=%04X ciphersuite=%04X compression=%d\n", session.version(), session.ciphersuite(), @@ -69,9 +69,9 @@ class Blocking_TLS_Server Blocking_TLS_Server(std::tr1::function<void (const byte[], size_t)> output_fn, std::tr1::function<size_t (byte[], size_t)> input_fn, std::vector<std::string>& protocols, - TLS_Session_Manager& sessions, + TLS::Session_Manager& sessions, Credentials_Manager& creds, - TLS_Policy& policy, + TLS::Policy& policy, RandomNumberGenerator& rng) : input_fn(input_fn), server( @@ -109,7 +109,7 @@ class Blocking_TLS_Server bool is_active() const { return server.is_active(); } - TLS_Server& underlying() { return server; } + TLS::Server& underlying() { return server; } private: void read_loop(size_t init_desired = 0) { @@ -135,7 +135,7 @@ class Blocking_TLS_Server void reader_fn(const byte buf[], size_t buf_len, u16bit alert_code) { - if(buf_len == 0 && alert_code != NULL_ALERT) + if(buf_len == 0 && alert_code != TLS::NULL_ALERT) { printf("Alert: %d\n", alert_code); //exit = true; @@ -153,12 +153,12 @@ class Blocking_TLS_Server } std::tr1::function<size_t (byte[], size_t)> input_fn; - TLS_Server server; + TLS::Server server; SecureQueue read_queue; bool exit; }; -class Server_TLS_Policy : public TLS_Policy +class Server_TLS_Policy : public TLS::Policy { public: //bool require_client_auth() const { return true; } @@ -194,7 +194,7 @@ int main(int argc, char* argv[]) Server_TLS_Policy policy; - TLS_Session_Manager_In_Memory sessions; + TLS::Session_Manager_In_Memory sessions; Credentials_Manager_Simple creds(rng); |