aboutsummaryrefslogtreecommitdiffstats
path: root/src/tls/tls_server.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-04-04 15:23:44 +0000
committerlloyd <[email protected]>2012-04-04 15:23:44 +0000
commitfedd69e75ffe23c6249d49e4d23cc1b4ae2823aa (patch)
treee0994c61aadb39e245486f2ba7089f4a13b18d8b /src/tls/tls_server.cpp
parentf5d35f360a04acef3ad19b0abf9a830b0d52d5d8 (diff)
Remove Policy::choose_compression and move to tls_server
Make ciphersuite_list a free standing function Now the Policy interface only contains actual policy hooks (no non-virtual functions). Though choose_curve is a little dubious.
Diffstat (limited to 'src/tls/tls_server.cpp')
-rw-r--r--src/tls/tls_server.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/tls/tls_server.cpp b/src/tls/tls_server.cpp
index 43556e1bc..f5b4efc30 100644
--- a/src/tls/tls_server.cpp
+++ b/src/tls/tls_server.cpp
@@ -95,7 +95,7 @@ u16bit choose_ciphersuite(
const Client_Hello* client_hello)
{
const std::vector<u16bit> client_suites = client_hello->ciphersuites();
- const std::vector<u16bit> server_suites = policy.ciphersuite_list(false);
+ const std::vector<u16bit> server_suites = ciphersuite_list(policy, false);
const bool have_shared_ecc_curve =
(policy.choose_curve(client_hello->supported_ecc_curves()) != "");
@@ -123,6 +123,23 @@ u16bit choose_ciphersuite(
"Can't agree on a ciphersuite with client");
}
+
+/*
+* Choose which compression algorithm to use
+*/
+byte choose_compression(const Policy& policy,
+ const std::vector<byte>& c_comp)
+ {
+ std::vector<byte> s_comp = policy.compression();
+
+ for(size_t i = 0; i != s_comp.size(); ++i)
+ for(size_t j = 0; j != c_comp.size(); ++j)
+ if(s_comp[i] == c_comp[j])
+ return s_comp[i];
+
+ return NO_COMPRESSION;
+ }
+
std::map<std::string, std::vector<X509_Certificate> >
get_server_certs(const std::string& hostname,
Credentials_Manager& creds)
@@ -352,7 +369,7 @@ void Server::process_handshake_msg(Handshake_Type type,
rng.random_vec(32), // new session ID
state->version(),
choose_ciphersuite(policy, cert_chains, state->client_hello),
- policy.choose_compression(state->client_hello->compression_methods()),
+ choose_compression(policy, state->client_hello->compression_methods()),
state->client_hello->fragment_size(),
secure_renegotiation.supported(),
secure_renegotiation.for_server_hello(),