|
Botan
1.11.15
|
#include <tls_extensions.h>
Public Member Functions | |
| const std::vector< std::string > & | curves () const |
| bool | empty () const |
| std::vector< byte > | serialize () const |
| Supported_Elliptic_Curves (const std::vector< std::string > &curves) | |
| Supported_Elliptic_Curves (TLS_Data_Reader &reader, u16bit extension_size) | |
| Handshake_Extension_Type | type () const |
Static Public Member Functions | |
| static std::string | curve_id_to_name (u16bit id) |
| static u16bit | name_to_curve_id (const std::string &name) |
| static Handshake_Extension_Type | static_type () |
Supported Elliptic Curves Extension (RFC 4492)
Definition at line 265 of file tls_extensions.h.
| Botan::TLS::Supported_Elliptic_Curves::Supported_Elliptic_Curves | ( | const std::vector< std::string > & | curves | ) | [inline] |
Definition at line 280 of file tls_extensions.h.
:
m_curves(curves) {}
| Botan::TLS::Supported_Elliptic_Curves::Supported_Elliptic_Curves | ( | TLS_Data_Reader & | reader, |
| u16bit | extension_size | ||
| ) |
Definition at line 388 of file tls_extensions.cpp.
References Botan::TLS::TLS_Data_Reader::get_u16bit().
{
u16bit len = reader.get_u16bit();
if(len + 2 != extension_size)
throw Decoding_Error("Inconsistent length field in elliptic curve list");
if(len % 2 == 1)
throw Decoding_Error("Elliptic curve list of strange size");
len /= 2;
for(size_t i = 0; i != len; ++i)
{
const u16bit id = reader.get_u16bit();
const std::string name = curve_id_to_name(id);
if(name != "")
m_curves.push_back(name);
}
}
| std::string Botan::TLS::Supported_Elliptic_Curves::curve_id_to_name | ( | u16bit | id | ) | [static] |
Definition at line 300 of file tls_extensions.cpp.
Referenced by Botan::TLS::Client_Key_Exchange::Client_Key_Exchange(), and Botan::TLS::Server_Key_Exchange::Server_Key_Exchange().
{
switch(id)
{
case 15:
return "secp160k1";
case 16:
return "secp160r1";
case 17:
return "secp160r2";
case 18:
return "secp192k1";
case 19:
return "secp192r1";
case 20:
return "secp224k1";
case 21:
return "secp224r1";
case 22:
return "secp256k1";
case 23:
return "secp256r1";
case 24:
return "secp384r1";
case 25:
return "secp521r1";
case 26:
return "brainpool256r1";
case 27:
return "brainpool384r1";
case 28:
return "brainpool512r1";
default:
return ""; // something we don't know or support
}
}
| const std::vector<std::string>& Botan::TLS::Supported_Elliptic_Curves::curves | ( | ) | const [inline] |
Definition at line 276 of file tls_extensions.h.
{ return m_curves; }
| bool Botan::TLS::Supported_Elliptic_Curves::empty | ( | ) | const [inline, virtual] |
Implements Botan::TLS::Extension.
Definition at line 286 of file tls_extensions.h.
{ return m_curves.empty(); }
| u16bit Botan::TLS::Supported_Elliptic_Curves::name_to_curve_id | ( | const std::string & | name | ) | [static] |
Definition at line 337 of file tls_extensions.cpp.
Referenced by Botan::TLS::Server_Key_Exchange::Server_Key_Exchange().
{
if(name == "secp160k1")
return 15;
if(name == "secp160r1")
return 16;
if(name == "secp160r2")
return 17;
if(name == "secp192k1")
return 18;
if(name == "secp192r1")
return 19;
if(name == "secp224k1")
return 20;
if(name == "secp224r1")
return 21;
if(name == "secp256k1")
return 22;
if(name == "secp256r1")
return 23;
if(name == "secp384r1")
return 24;
if(name == "secp521r1")
return 25;
if(name == "brainpool256r1")
return 26;
if(name == "brainpool384r1")
return 27;
if(name == "brainpool512r1")
return 28;
throw Invalid_Argument("name_to_curve_id unknown name " + name);
}
| std::vector< byte > Botan::TLS::Supported_Elliptic_Curves::serialize | ( | ) | const [virtual] |
Implements Botan::TLS::Extension.
Definition at line 371 of file tls_extensions.cpp.
References Botan::get_byte().
{
std::vector<byte> buf(2);
for(size_t i = 0; i != m_curves.size(); ++i)
{
const u16bit id = name_to_curve_id(m_curves[i]);
buf.push_back(get_byte(0, id));
buf.push_back(get_byte(1, id));
}
buf[0] = get_byte<u16bit>(0, buf.size()-2);
buf[1] = get_byte<u16bit>(1, buf.size()-2);
return buf;
}
| static Handshake_Extension_Type Botan::TLS::Supported_Elliptic_Curves::static_type | ( | ) | [inline, static] |
Definition at line 268 of file tls_extensions.h.
References Botan::TLS::TLSEXT_USABLE_ELLIPTIC_CURVES.
Referenced by type().
{ return TLSEXT_USABLE_ELLIPTIC_CURVES; }
| Handshake_Extension_Type Botan::TLS::Supported_Elliptic_Curves::type | ( | ) | const [inline, virtual] |
Implements Botan::TLS::Extension.
Definition at line 271 of file tls_extensions.h.
References static_type().
{ return static_type(); }
1.7.6.1