aboutsummaryrefslogtreecommitdiffstats
path: root/src/tls/c_kex.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-01-27 15:47:33 +0000
committerlloyd <[email protected]>2012-01-27 15:47:33 +0000
commitb96fde715dddbb3fe1eb6a9077bb92182dfa1635 (patch)
treec0ff39002fbe7bff1a72a296140827388ccef468 /src/tls/c_kex.cpp
parent681a587b4766f660c758539110b6b8adb73a62a6 (diff)
Split up the psk function as the server also wants to be able to look
up a PSK from an identity.
Diffstat (limited to 'src/tls/c_kex.cpp')
-rw-r--r--src/tls/c_kex.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/tls/c_kex.cpp b/src/tls/c_kex.cpp
index 8dccb05c9..9f492c5a5 100644
--- a/src/tls/c_kex.cpp
+++ b/src/tls/c_kex.cpp
@@ -63,17 +63,20 @@ Client_Key_Exchange::Client_Key_Exchange(Record_Writer& writer,
identity_hint = reader.get_string(2, 0, 65535);
}
- std::pair<std::string, SymmetricKey> psk =
- creds.psk("tls-client",
- state->client_hello->sni_hostname(),
- identity_hint);
+ const std::string hostname = state->client_hello->sni_hostname();
- append_tls_length_value(key_material, psk.first, 2);
+ const std::string psk_identity = creds.psk_identity("tls-client",
+ hostname,
+ identity_hint);
- MemoryVector<byte> zeros(psk.second.length());
+ append_tls_length_value(key_material, psk_identity, 2);
+
+ SymmetricKey psk = creds.psk("tls-client", hostname, psk_identity);
+
+ MemoryVector<byte> zeros(psk.length());
append_tls_length_value(pre_master, zeros, 2);
- append_tls_length_value(pre_master, psk.second.bits_of(), 2);
+ append_tls_length_value(pre_master, psk.bits_of(), 2);
}
else if(state->server_kex)
{