diff options
Diffstat (limited to 'src/lib/tls/tls_extensions.cpp')
-rw-r--r-- | src/lib/tls/tls_extensions.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/lib/tls/tls_extensions.cpp b/src/lib/tls/tls_extensions.cpp index e38e4ccdc..d82df20c5 100644 --- a/src/lib/tls/tls_extensions.cpp +++ b/src/lib/tls/tls_extensions.cpp @@ -33,6 +33,9 @@ Extension* make_extension(TLS_Data_Reader& reader, case TLSEXT_USABLE_ELLIPTIC_CURVES: return new Supported_Elliptic_Curves(reader, size); + case TLSEXT_EC_POINT_FORMATS: + return new Supported_Point_Formats(reader, size); + case TLSEXT_SAFE_RENEGOTIATION: return new Renegotiation_Extension(reader, size); @@ -353,6 +356,51 @@ Supported_Elliptic_Curves::Supported_Elliptic_Curves(TLS_Data_Reader& reader, } } +std::vector<byte> Supported_Point_Formats::serialize() const + { + std::vector<byte> buf(1); + + // if we send this extension, we prefer compressed points, + // otherwise we don't send it (which is equal to supporting only uncompressed) + buf.push_back(ANSIX962_COMPRESSED_PRIME); + + // if this extension is sent, it MUST include uncompressed (RFC 4492, section 5.1) + buf.push_back(UNCOMPRESSED); + + buf[0] = static_cast<byte>(buf.size()-1); + + return buf; + } + +Supported_Point_Formats::Supported_Point_Formats(TLS_Data_Reader& reader, + u16bit extension_size) + { + byte len = reader.get_byte(); + + if(len + 1 != extension_size) + throw Decoding_Error("Inconsistent length field in supported point formats list"); + + for(size_t i = 0; i != len; ++i) + { + byte format = reader.get_byte(); + + if(format == UNCOMPRESSED) + { + m_prefers_compressed = false; + reader.discard_next(len-i-1); + return; + } + else if(format == ANSIX962_COMPRESSED_PRIME) + { + m_prefers_compressed = true; + reader.discard_next(len-i-1); + return; + } + + // ignore ANSIX962_COMPRESSED_CHAR2, we don't support these curves + } + } + std::string Signature_Algorithms::hash_algo_name(byte code) { switch(code) |