aboutsummaryrefslogtreecommitdiffstats
path: root/src/tls/tls_handshake_state.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-01-20 16:28:00 +0000
committerlloyd <[email protected]>2012-01-20 16:28:00 +0000
commitc6f0d82882522add74527a1657cc6ecd03c0af0c (patch)
treef2524954836690db4a4c6492dd119f672fa054b3 /src/tls/tls_handshake_state.cpp
parentb9980348ccd1687f44f53532f81c605aa4a1d752 (diff)
Somewhat contorted, but fixes the issue with sending hash/sig ids with
older versions.
Diffstat (limited to 'src/tls/tls_handshake_state.cpp')
-rw-r--r--src/tls/tls_handshake_state.cpp41
1 files changed, 31 insertions, 10 deletions
diff --git a/src/tls/tls_handshake_state.cpp b/src/tls/tls_handshake_state.cpp
index cfbb05b6a..dfa320cda 100644
--- a/src/tls/tls_handshake_state.cpp
+++ b/src/tls/tls_handshake_state.cpp
@@ -131,11 +131,11 @@ bool TLS_Handshake_State::received_handshake_msg(Handshake_Type handshake_msg) c
std::pair<std::string, Signature_Format>
TLS_Handshake_State::choose_sig_format(const Private_Key* key,
- std::string& hash_algo,
- std::string& sig_algo,
+ std::string& hash_algo_out,
+ std::string& sig_algo_out,
bool for_client_auth)
{
- sig_algo = key->algo_name();
+ const std::string sig_algo = key->algo_name();
/*
FIXME: This should respect the algo preferences in the client hello
@@ -144,6 +144,8 @@ TLS_Handshake_State::choose_sig_format(const Private_Key* key,
if(sig_algo == "RSA")
{
+ std::string hash_algo;
+
if(for_client_auth && this->version == SSL_V3)
{
hash_algo = "Raw";
@@ -155,6 +157,9 @@ TLS_Handshake_State::choose_sig_format(const Private_Key* key,
else
{
hash_algo = "SHA-256"; // should be policy
+
+ sig_algo_out = sig_algo;
+ hash_algo_out = hash_algo;
}
const std::string padding = "EMSA3(" + hash_algo + ")";
@@ -163,6 +168,8 @@ TLS_Handshake_State::choose_sig_format(const Private_Key* key,
}
else if(sig_algo == "DSA")
{
+ std::string hash_algo;
+
if(for_client_auth && this->version == SSL_V3)
{
hash_algo = "Raw";
@@ -174,6 +181,9 @@ TLS_Handshake_State::choose_sig_format(const Private_Key* key,
else
{
hash_algo = "SHA-1"; // should be policy
+
+ sig_algo_out = sig_algo;
+ hash_algo_out = hash_algo;
}
const std::string padding = "EMSA1(" + hash_algo + ")";
@@ -185,21 +195,32 @@ TLS_Handshake_State::choose_sig_format(const Private_Key* key,
}
std::pair<std::string, Signature_Format>
-TLS_Handshake_State::choose_sig_format(const Public_Key* key,
- std::string hash_algo,
- std::string sig_algo,
- bool for_client_auth)
+TLS_Handshake_State::understand_sig_format(const Public_Key* key,
+ std::string hash_algo,
+ std::string sig_algo,
+ bool for_client_auth)
{
const std::string algo_name = key->algo_name();
+ /*
+ FIXME: This should check what was sent against the client hello
+ preferences, or the certificate request, to ensure it was allowed
+ by those restrictions.
+ */
+
if(this->version < TLS_V12)
{
- if(hash_algo != "")
+ if(hash_algo != "" || sig_algo != "")
throw Decoding_Error("Counterparty sent hash/sig IDs with old version");
}
+ else
+ {
+ if(hash_algo == "")
+ throw Decoding_Error("Counterparty did not send hash/sig IDS");
- if(sig_algo != "" && sig_algo != algo_name)
- throw Decoding_Error("Counterparty sent inconsistent key and sig types");
+ if(sig_algo != algo_name)
+ throw Decoding_Error("Counterparty sent inconsistent key and sig types");
+ }
if(algo_name == "RSA")
{