8#include <botan/tls_signature_scheme.h>
10#include <botan/der_enc.h>
11#include <botan/ec_group.h>
12#include <botan/hash.h>
14#include <botan/tls_exceptn.h>
15#include <botan/tls_version.h>
16#include <botan/internal/pss_params.h>
17#include <botan/internal/stl_util.h>
25 static const std::vector<Signature_Scheme> all_schemes = {
62 return m_code !=
NONE;
68 return "RSA_PKCS1_SHA1";
70 return "RSA_PKCS1_SHA256";
72 return "RSA_PKCS1_SHA384";
74 return "RSA_PKCS1_SHA512";
79 return "ECDSA_SHA256";
81 return "ECDSA_SHA384";
83 return "ECDSA_SHA512";
86 return "RSA_PSS_SHA256";
88 return "RSA_PSS_SHA384";
90 return "RSA_PSS_SHA512";
98 return "Unknown signature scheme: " + std::to_string(m_code);
128 return "Unknown hash function";
135 return "EMSA_PKCS1(SHA-1)";
137 return "EMSA_PKCS1(SHA-256)";
139 return "EMSA_PKCS1(SHA-384)";
141 return "EMSA_PKCS1(SHA-512)";
153 return "PSSR(SHA-256,MGF1,32)";
155 return "PSSR(SHA-384,MGF1,48)";
157 return "PSSR(SHA-512,MGF1,64)";
165 return "Unknown padding";
193 return "Unknown algorithm";
289 if(hash_function_name() ==
"SHA-1") {
298 if(!protocol_version.is_pre_tls_13() && (m_code == RSA_PKCS1_SHA1 || m_code == RSA_PKCS1_SHA256 ||
299 m_code == RSA_PKCS1_SHA384 || m_code == RSA_PKCS1_SHA512)) {
307 if(algorithm_name() != private_key.algo_name()) {
312 const auto keylen = private_key.key_length();
317 if(m_code == ECDSA_SHA256 && !(keylen >= 250 && keylen <= 350)) {
321 if(m_code == ECDSA_SHA384 && !(keylen >= 350 && keylen <= 450)) {
325 if(m_code == ECDSA_SHA512 && !(keylen >= 450 && keylen <= 550)) {
333 std::vector<AlgorithmIdentifier> result;
334 std::transform(schemes.begin(), schemes.end(), std::back_inserter(result), [](
const auto& scheme) {
335 return scheme.algorithm_identifier();
static EC_Group from_name(std::string_view name)
std::vector< uint8_t > DER_encode(EC_Group_Encoding form) const
static OID from_string(std::string_view str)
std::string hash_function_name() const noexcept
bool is_compatible_with(const Protocol_Version &protocol_version) const noexcept
AlgorithmIdentifier key_algorithm_identifier() const noexcept
AlgorithmIdentifier algorithm_identifier() const noexcept
std::optional< Signature_Format > format() const noexcept
bool is_suitable_for(const Private_Key &private_key) const noexcept
std::string to_string() const noexcept
bool is_set() const noexcept
static const std::vector< Signature_Scheme > & all_available_schemes()
std::string padding_string() const noexcept
bool is_available() const noexcept
std::string algorithm_name() const noexcept
std::vector< AlgorithmIdentifier > to_algorithm_identifiers(const std::vector< Signature_Scheme > &schemes)
bool value_exists(const std::vector< T > &vec, const OT &val)