|
Botan
1.11.15
|
#include <tls_extensions.h>
Public Member Functions | |
| bool | empty () const |
| std::vector< byte > | serialize () const |
| Signature_Algorithms (const std::vector< std::string > &hashes, const std::vector< std::string > &sig_algos) | |
| Signature_Algorithms (const std::vector< std::pair< std::string, std::string > > &algos) | |
| Signature_Algorithms (TLS_Data_Reader &reader, u16bit extension_size) | |
| std::vector< std::pair < std::string, std::string > > | supported_signature_algorthms () const |
| Handshake_Extension_Type | type () const |
Static Public Member Functions | |
| static byte | hash_algo_code (const std::string &name) |
| static std::string | hash_algo_name (byte code) |
| static byte | sig_algo_code (const std::string &name) |
| static std::string | sig_algo_name (byte code) |
| static Handshake_Extension_Type | static_type () |
Signature Algorithms Extension for TLS 1.2 (RFC 5246)
Definition at line 294 of file tls_extensions.h.
| Botan::TLS::Signature_Algorithms::Signature_Algorithms | ( | const std::vector< std::string > & | hashes, |
| const std::vector< std::string > & | sig_algos | ||
| ) |
Definition at line 510 of file tls_extensions.cpp.
{
for(size_t i = 0; i != hashes.size(); ++i)
for(size_t j = 0; j != sigs.size(); ++j)
m_supported_algos.push_back(std::make_pair(hashes[i], sigs[j]));
}
| Botan::TLS::Signature_Algorithms::Signature_Algorithms | ( | const std::vector< std::pair< std::string, std::string > > & | algos | ) | [inline] |
Definition at line 321 of file tls_extensions.h.
:
m_supported_algos(algos) {}
| Botan::TLS::Signature_Algorithms::Signature_Algorithms | ( | TLS_Data_Reader & | reader, |
| u16bit | extension_size | ||
| ) |
Definition at line 518 of file tls_extensions.cpp.
References Botan::TLS::TLS_Data_Reader::get_byte(), and Botan::TLS::TLS_Data_Reader::get_u16bit().
{
u16bit len = reader.get_u16bit();
if(len + 2 != extension_size)
throw Decoding_Error("Bad encoding on signature algorithms extension");
while(len)
{
const std::string hash_code = hash_algo_name(reader.get_byte());
const std::string sig_code = sig_algo_name(reader.get_byte());
len -= 2;
// If not something we know, ignore it completely
if(hash_code == "" || sig_code == "")
continue;
m_supported_algos.push_back(std::make_pair(hash_code, sig_code));
}
}
| bool Botan::TLS::Signature_Algorithms::empty | ( | ) | const [inline, virtual] |
Implements Botan::TLS::Extension.
Definition at line 316 of file tls_extensions.h.
{ return false; }
| byte Botan::TLS::Signature_Algorithms::hash_algo_code | ( | const std::string & | name | ) | [static] |
Definition at line 434 of file tls_extensions.cpp.
{
if(name == "MD5")
return 1;
if(name == "SHA-1")
return 2;
if(name == "SHA-224")
return 3;
if(name == "SHA-256")
return 4;
if(name == "SHA-384")
return 5;
if(name == "SHA-512")
return 6;
throw Internal_Error("Unknown hash ID " + name + " for signature_algorithms");
}
| std::string Botan::TLS::Signature_Algorithms::hash_algo_name | ( | byte | code | ) | [static] |
Definition at line 411 of file tls_extensions.cpp.
Referenced by Botan::TLS::Certificate_Verify::Certificate_Verify(), and Botan::TLS::Server_Key_Exchange::Server_Key_Exchange().
{
switch(code)
{
case 1:
return "MD5";
// code 1 is MD5 - ignore it
case 2:
return "SHA-1";
case 3:
return "SHA-224";
case 4:
return "SHA-256";
case 5:
return "SHA-384";
case 6:
return "SHA-512";
default:
return "";
}
}
| std::vector< byte > Botan::TLS::Signature_Algorithms::serialize | ( | ) | const [virtual] |
Implements Botan::TLS::Extension.
Definition at line 486 of file tls_extensions.cpp.
{
std::vector<byte> buf(2);
for(size_t i = 0; i != m_supported_algos.size(); ++i)
{
try
{
const byte hash_code = hash_algo_code(m_supported_algos[i].first);
const byte sig_code = sig_algo_code(m_supported_algos[i].second);
buf.push_back(hash_code);
buf.push_back(sig_code);
}
catch(...)
{}
}
buf[0] = get_byte<u16bit>(0, buf.size()-2);
buf[1] = get_byte<u16bit>(1, buf.size()-2);
return buf;
}
| byte Botan::TLS::Signature_Algorithms::sig_algo_code | ( | const std::string & | name | ) | [static] |
Definition at line 472 of file tls_extensions.cpp.
{
if(name == "RSA")
return 1;
if(name == "DSA")
return 2;
if(name == "ECDSA")
return 3;
throw Internal_Error("Unknown sig ID " + name + " for signature_algorithms");
}
| std::string Botan::TLS::Signature_Algorithms::sig_algo_name | ( | byte | code | ) | [static] |
Definition at line 457 of file tls_extensions.cpp.
Referenced by Botan::TLS::Certificate_Verify::Certificate_Verify(), and Botan::TLS::Server_Key_Exchange::Server_Key_Exchange().
{
switch(code)
{
case 1:
return "RSA";
case 2:
return "DSA";
case 3:
return "ECDSA";
default:
return "";
}
}
| static Handshake_Extension_Type Botan::TLS::Signature_Algorithms::static_type | ( | ) | [inline, static] |
Definition at line 297 of file tls_extensions.h.
References Botan::TLS::TLSEXT_SIGNATURE_ALGORITHMS.
Referenced by type().
{ return TLSEXT_SIGNATURE_ALGORITHMS; }
| std::vector<std::pair<std::string, std::string> > Botan::TLS::Signature_Algorithms::supported_signature_algorthms | ( | ) | const [inline] |
Definition at line 309 of file tls_extensions.h.
{
return m_supported_algos;
}
| Handshake_Extension_Type Botan::TLS::Signature_Algorithms::type | ( | ) | const [inline, virtual] |
Implements Botan::TLS::Extension.
Definition at line 300 of file tls_extensions.h.
References static_type().
{ return static_type(); }
1.7.6.1