diff options
author | Jack Lloyd <[email protected]> | 2018-01-27 11:39:38 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-01-27 11:39:38 -0500 |
commit | ef741f408e4fd793fe75a142ac63863e906cc61a (patch) | |
tree | 3810c8fed21facccaeb05f98c176d56702e4d2ea /src/lib/tls/tls_extensions.h | |
parent | dd960f0a5e34ec4b0319c8069fb1ccb58ef8c901 (diff) |
Make it possible to test custom extensions
Diffstat (limited to 'src/lib/tls/tls_extensions.h')
-rw-r--r-- | src/lib/tls/tls_extensions.h | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/src/lib/tls/tls_extensions.h b/src/lib/tls/tls_extensions.h index 7b7b645bf..114b16489 100644 --- a/src/lib/tls/tls_extensions.h +++ b/src/lib/tls/tls_extensions.h @@ -432,6 +432,30 @@ class Certificate_Status_Request final : public Extension }; /** +* Unknown extensions are deserialized as this type +*/ +class BOTAN_UNSTABLE_API Unknown_Extension final : public Extension + { + public: + Unknown_Extension(Handshake_Extension_Type type, + TLS_Data_Reader& reader, + uint16_t extension_size); + + std::vector<uint8_t> serialize() const override; // always fails + + const std::vector<uint8_t>& value() { return m_value; } + + bool empty() const { return false; } + + Handshake_Extension_Type type() const { return m_type; } + + private: + Handshake_Extension_Type m_type; + std::vector<uint8_t> m_value; + + }; + +/** * Represents a block of extensions in a hello message */ class BOTAN_UNSTABLE_API Extensions final @@ -442,13 +466,7 @@ class BOTAN_UNSTABLE_API Extensions final template<typename T> T* get() const { - Handshake_Extension_Type type = T::static_type(); - - auto i = m_extensions.find(type); - - if(i != m_extensions.end()) - return dynamic_cast<T*>(i->second.get()); - return nullptr; + return dynamic_cast<T*>(get(T::static_type())); } template<typename T> @@ -462,6 +480,15 @@ class BOTAN_UNSTABLE_API Extensions final m_extensions[extn->type()].reset(extn); } + Extension* get(Handshake_Extension_Type type) const + { + auto i = m_extensions.find(type); + + if(i != m_extensions.end()) + return i->second.get(); + return nullptr; + } + std::vector<uint8_t> serialize() const; void deserialize(TLS_Data_Reader& reader); |