diff options
author | lloyd <[email protected]> | 2012-01-28 15:41:22 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2012-01-28 15:41:22 +0000 |
commit | e2e9105071f2d0a1360603f06c2acf68865ff072 (patch) | |
tree | 42f5bb0f689c2221b63ff20628e130552735ef9f /src/tls/tls_ciphersuite.cpp | |
parent | ee7f6c030776c17a47e9d4f12e59aad86366e0da (diff) |
Support getting ciphersuites by name as well as suite ID
Diffstat (limited to 'src/tls/tls_ciphersuite.cpp')
-rw-r--r-- | src/tls/tls_ciphersuite.cpp | 18 |
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) |