8#include <botan/tls_signature_scheme.h>
10#include <botan/pk_keys.h>
11#include <botan/pss_params.h>
12#include <botan/tls_version.h>
13#include <botan/internal/stl_util.h>
21 static const std::vector<Signature_Scheme> all_schemes = {
58 return m_code !=
NONE;
64 return "RSA_PKCS1_SHA1";
66 return "RSA_PKCS1_SHA256";
68 return "RSA_PKCS1_SHA384";
70 return "RSA_PKCS1_SHA512";
75 return "ECDSA_SHA256";
77 return "ECDSA_SHA384";
79 return "ECDSA_SHA512";
82 return "RSA_PSS_SHA256";
84 return "RSA_PSS_SHA384";
86 return "RSA_PSS_SHA512";
94 return "Unknown signature scheme: " + std::to_string(m_code);
124 return "Unknown hash function";
131 return "PKCS1v15(SHA-1)";
133 return "PKCS1v15(SHA-256)";
135 return "PKCS1v15(SHA-384)";
137 return "PKCS1v15(SHA-512)";
149 return "PSS(SHA-256,MGF1,32)";
151 return "PSS(SHA-384,MGF1,48)";
153 return "PSS(SHA-512,MGF1,64)";
160 return "Unknown padding";
188 return "Unknown algorithm";
193 const auto der_encode_oid = [](
const std::string_view oid_name) {
196 return oid->BER_encode();
205 return {
"ECDSA", der_encode_oid(
"secp256r1")};
207 return {
"ECDSA", der_encode_oid(
"secp384r1")};
209 return {
"ECDSA", der_encode_oid(
"secp521r1")};
316 const auto keylen = private_key.key_length();
321 if(m_code ==
ECDSA_SHA256 && !(keylen >= 250 && keylen <= 350)) {
325 if(m_code ==
ECDSA_SHA384 && !(keylen >= 350 && keylen <= 450)) {
329 if(m_code ==
ECDSA_SHA512 && !(keylen >= 450 && keylen <= 550)) {
337 std::vector<AlgorithmIdentifier> result;
338 result.reserve(schemes.size());
339 for(
const auto& scheme : schemes) {
340 result.push_back(scheme.algorithm_identifier());
#define BOTAN_ASSERT_UNREACHABLE()
static std::optional< OID > from_name(std::string_view name)
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
Signature_Scheme::Code wire_code() 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 V &val)