35 {
36 SCAN_Name req(algo_spec);
37
38#if defined(BOTAN_HAS_EMSA_PKCS1)
39 if(req.algo_name() == "EMSA_PKCS1" ||
40 req.algo_name() == "PKCS1v15" ||
41 req.algo_name() == "EMSA-PKCS1-v1_5" ||
42 req.algo_name() == "EMSA3")
43 {
44 if(req.arg_count() == 2 && req.arg(0) == "Raw")
45 {
46 return std::make_unique<EMSA_PKCS1v15_Raw>(req.arg(1));
47 }
48 else if(req.arg_count() == 1)
49 {
50 if(req.arg(0) == "Raw")
51 {
52 return std::make_unique<EMSA_PKCS1v15_Raw>();
53 }
54 else
55 {
57 {
58 return std::make_unique<EMSA_PKCS1v15>(std::move(hash));
59 }
60 }
61 }
62 }
63#endif
64
65#if defined(BOTAN_HAS_EMSA_PSSR)
66 if(req.algo_name() == "PSS_Raw" ||
67 req.algo_name() == "PSSR_Raw")
68 {
69 if(req.arg_count_between(1, 3) && req.arg(1, "MGF1") == "MGF1")
70 {
72 {
73 if(req.arg_count() == 3)
74 {
75 const size_t salt_size = req.arg_as_integer(2, 0);
76 return std::make_unique<PSSR_Raw>(std::move(hash), salt_size);
77 }
78 else
79 {
80 return std::make_unique<PSSR_Raw>(std::move(hash));
81 }
82 }
83 }
84 }
85
86 if(req.algo_name() == "PSS" ||
87 req.algo_name() == "PSSR" ||
88 req.algo_name() == "EMSA-PSS" ||
89 req.algo_name() == "PSS-MGF1" ||
90 req.algo_name() == "EMSA4")
91 {
92 if(req.arg_count_between(1, 3) && req.arg(1, "MGF1") == "MGF1")
93 {
95 {
96 if(req.arg_count() == 3)
97 {
98 const size_t salt_size = req.arg_as_integer(2, 0);
99 return std::make_unique<PSSR>(std::move(hash), salt_size);
100 }
101 else
102 {
103 return std::make_unique<PSSR>(std::move(hash));
104 }
105 }
106 }
107 }
108#endif
109
110#if defined(BOTAN_HAS_ISO_9796)
111 if(req.algo_name() == "ISO_9796_DS2")
112 {
113 if(req.arg_count_between(1, 3))
114 {
116 {
117 const size_t salt_size = req.arg_as_integer(2, hash->output_length());
118 const bool implicit = req.arg(1, "exp") == "imp";
119 return std::make_unique<ISO_9796_DS2>(std::move(hash), implicit, salt_size);
120 }
121 }
122 }
123
124 if(req.algo_name() == "ISO_9796_DS3")
125 {
126 if(req.arg_count_between(1, 2))
127 {
129 {
130 const bool implicit = req.arg(1, "exp") == "imp";
131 return std::make_unique<ISO_9796_DS3>(std::move(hash), implicit);
132 }
133 }
134 }
135#endif
136
137#if defined(BOTAN_HAS_EMSA_X931)
138 if(req.algo_name() == "EMSA_X931" ||
139 req.algo_name() == "EMSA2" ||
140 req.algo_name() == "X9.31")
141 {
142 if(req.arg_count() == 1)
143 {
145 {
146 return std::make_unique<EMSA_X931>(std::move(hash));
147 }
148 }
149 }
150#endif
151
152#if defined(BOTAN_HAS_EMSA_RAW)
153 if(req.algo_name() == "Raw")
154 {
155 if(req.arg_count() == 0)
156 {
157 return std::make_unique<EMSA_Raw>();
158 }
159 else
160 {
162 if(hash)
163 return std::make_unique<EMSA_Raw>(hash->output_length());
164 }
165 }
166#endif
167
168 return nullptr;
169 }
static std::unique_ptr< HashFunction > create(std::string_view algo_spec, std::string_view provider="")