35 {
36 SCAN_Name req(algo_spec);
37
38#if defined(BOTAN_HAS_EMSA_PKCS1)
39 if(req.algo_name() == "EMSA_PKCS1" || req.algo_name() == "PKCS1v15" || req.algo_name() == "EMSA-PKCS1-v1_5" ||
40 req.algo_name() == "EMSA3") {
41 if(req.arg_count() == 2 && req.arg(0) == "Raw") {
42 return std::make_unique<EMSA_PKCS1v15_Raw>(req.arg(1));
43 } else if(req.arg_count() == 1) {
44 if(req.arg(0) == "Raw") {
45 return std::make_unique<EMSA_PKCS1v15_Raw>();
46 } else {
48 return std::make_unique<EMSA_PKCS1v15>(std::move(hash));
49 }
50 }
51 }
52 }
53#endif
54
55#if defined(BOTAN_HAS_EMSA_PSSR)
56 if(req.algo_name() == "PSS_Raw" || req.algo_name() == "PSSR_Raw") {
57 if(req.arg_count_between(1, 3) && req.arg(1, "MGF1") == "MGF1") {
59 if(req.arg_count() == 3) {
60 const size_t salt_size = req.arg_as_integer(2, 0);
61 return std::make_unique<PSSR_Raw>(std::move(hash), salt_size);
62 } else {
63 return std::make_unique<PSSR_Raw>(std::move(hash));
64 }
65 }
66 }
67 }
68
69 if(req.algo_name() == "PSS" || req.algo_name() == "PSSR" || req.algo_name() == "EMSA-PSS" ||
70 req.algo_name() == "PSS-MGF1" || req.algo_name() == "EMSA4") {
71 if(req.arg_count_between(1, 3) && req.arg(1, "MGF1") == "MGF1") {
73 if(req.arg_count() == 3) {
74 const size_t salt_size = req.arg_as_integer(2, 0);
75 return std::make_unique<PSSR>(std::move(hash), salt_size);
76 } else {
77 return std::make_unique<PSSR>(std::move(hash));
78 }
79 }
80 }
81 }
82#endif
83
84#if defined(BOTAN_HAS_ISO_9796)
85 if(req.algo_name() == "ISO_9796_DS2") {
86 if(req.arg_count_between(1, 3)) {
88 const size_t salt_size = req.arg_as_integer(2, hash->output_length());
89 const bool implicit = req.arg(1, "exp") == "imp";
90 return std::make_unique<ISO_9796_DS2>(std::move(hash), implicit, salt_size);
91 }
92 }
93 }
94
95 if(req.algo_name() == "ISO_9796_DS3") {
96 if(req.arg_count_between(1, 2)) {
98 const bool implicit = req.arg(1, "exp") == "imp";
99 return std::make_unique<ISO_9796_DS3>(std::move(hash), implicit);
100 }
101 }
102 }
103#endif
104
105#if defined(BOTAN_HAS_EMSA_X931)
106 if(req.algo_name() == "EMSA_X931" || req.algo_name() == "EMSA2" || req.algo_name() == "X9.31") {
107 if(req.arg_count() == 1) {
109 return std::make_unique<EMSA_X931>(std::move(hash));
110 }
111 }
112 }
113#endif
114
115#if defined(BOTAN_HAS_EMSA_RAW)
116 if(req.algo_name() == "Raw") {
117 if(req.arg_count() == 0) {
118 return std::make_unique<EMSA_Raw>();
119 } else {
121 if(hash) {
122 return std::make_unique<EMSA_Raw>(hash->output_length());
123 }
124 }
125 }
126#endif
127
128 return nullptr;
129}
static std::unique_ptr< HashFunction > create(std::string_view algo_spec, std::string_view provider="")