aboutsummaryrefslogtreecommitdiffstats
path: root/src/tls/tls_ciphersuite.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tls/tls_ciphersuite.cpp')
-rw-r--r--src/tls/tls_ciphersuite.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/tls/tls_ciphersuite.cpp b/src/tls/tls_ciphersuite.cpp
index 01c35a55a..82e2cdd28 100644
--- a/src/tls/tls_ciphersuite.cpp
+++ b/src/tls/tls_ciphersuite.cpp
@@ -18,7 +18,7 @@ namespace TLS {
/**
* Convert an SSL/TLS ciphersuite to algorithm fields
*/
-Ciphersuite Ciphersuite::lookup_ciphersuite(u16bit suite)
+Ciphersuite Ciphersuite::by_id(u16bit suite)
{
switch(static_cast<Ciphersuite_Code>(suite))
{
@@ -255,6 +255,22 @@ Ciphersuite Ciphersuite::lookup_ciphersuite(u16bit suite)
return Ciphersuite(); // some unknown ciphersuite
}
+Ciphersuite Ciphersuite::by_name(const std::string& name)
+ {
+ for(size_t i = 0; i != 65536; ++i)
+ {
+ Ciphersuite suite = Ciphersuite::by_id(i);
+
+ if(!suite.valid())
+ continue; // not a ciphersuite we know, skip
+
+ if(suite.to_string() == name)
+ return suite;
+ }
+
+ return Ciphersuite(); // some unknown ciphersuite
+ }
+
std::string Ciphersuite::to_string() const
{
if(m_cipher_keylen == 0)