37 {
38
39 if(!options.using_padding()) {
40 throw Lookup_Error("RSA signatures require specifying a padding scheme");
41 }
42
43 const std::string padding = options.padding().value();
44
45 if(padding == "Raw") {
46#if defined(BOTAN_HAS_EMSA_RAW)
47
48 return std::make_unique<SignRawBytes>(options);
49#endif
50 } else {
51#if defined(BOTAN_HAS_EMSA_PKCS1)
52
53 if(padding == "PKCS1v15" && options.using_externally_computed_prehash()) {
54 return std::make_unique<PKCS1v15_Raw_SignaturePaddingScheme>(options);
55 }
56#endif
57
58 if(!options.using_hash()) {
59 throw Lookup_Error(
fmt(
"RSA/{} signatures require specifying a hash function", padding));
60 }
61
62 const std::string& hash_fn = options.hash_function_name();
64
65#if defined(BOTAN_HAS_EMSA_PKCS1)
66 if(padding == "PKCS1v15" && hash_available) {
67 return std::make_unique<PKCS1v15_SignaturePaddingScheme>(options);
68 }
69#endif
70
71#if defined(BOTAN_HAS_PSS)
72 if(padding == "PSS_Raw" && hash_available) {
73 return std::make_unique<PSS_Raw>(options);
74 }
75
76 if(padding == "PSS" && hash_available) {
77 return std::make_unique<PSSR>(options);
78 }
79#endif
80
81#if defined(BOTAN_HAS_ISO_9796)
82 if(padding == "ISO_9796_DS2" && hash_available) {
83 return std::make_unique<ISO_9796_DS2>(options);
84 }
85
86 if(padding == "ISO_9796_DS3" && hash_available) {
87 return std::make_unique<ISO_9796_DS3>(options);
88 }
89#endif
90
91#if defined(BOTAN_HAS_EMSA_X931)
92 if(padding == "X9.31" && hash_available) {
93 return std::make_unique<X931_SignaturePadding>(options);
94 }
95#endif
96 }
97
98 throw Lookup_Error("Invalid or unavailable signature padding scheme " + options.to_string());
99}
static std::unique_ptr< HashFunction > create(std::string_view algo_spec, std::string_view provider="")
std::string fmt(std::string_view format, const T &... args)