|
10 | 10 | #include "api.hpp" |
11 | 11 | #include "base64.hpp" |
12 | 12 | #include "SignatureVerifier_OpenSSL3.hpp" |
| 13 | +#include "SignatureVerifier_shared.hpp" |
13 | 14 |
|
14 | 15 | namespace { |
15 | 16 |
|
@@ -148,34 +149,13 @@ SignatureVerifier_OpenSSL3::~SignatureVerifier_OpenSSL3() |
148 | 149 | * and the full string can be supplied as the argument to this method. |
149 | 150 | */ |
150 | 151 | void |
151 | | -SignatureVerifier_OpenSSL3::set_public_key_base64(basic_Error & e, std::string const& key) |
| 152 | +SignatureVerifier_OpenSSL3::set_public_key_xml(basic_Error & e, std::string const& key_xml) |
152 | 153 | { |
153 | 154 | if (e) { return; } |
154 | 155 |
|
155 | | - auto m_s = key.find("<Modulus>"); |
156 | | - auto m_e = key.find("</Modulus>"); |
| 156 | + ::cryptolens_io::v20190401::internal::set_public_key_xml(e, *this, key_xml); |
157 | 157 |
|
158 | | - auto e_s = key.find("<Exponent>"); |
159 | | - auto e_e = key.find("</Exponent>"); |
160 | | - |
161 | | - if (m_s == std::string::npos || m_e == std::string::npos || m_e < m_s + 9 || |
162 | | - e_s == std::string::npos || e_e == std::string::npos || e_e < e_s + 10) |
163 | | - { |
164 | | - e.set(api::main(), errors::Subsystem::Base64, __LINE__); |
165 | | - } else { |
166 | | - auto m_start = m_s + 9; |
167 | | - auto m_length = m_e - m_s - 9; |
168 | | - |
169 | | - auto e_start = e_s + 10; |
170 | | - auto e_length = e_e - e_s - 10; |
171 | | - |
172 | | - std::string modulus_base64 = key.substr(m_start, m_length); |
173 | | - std::string exponent_base64 = key.substr(e_start, e_length); |
174 | | - |
175 | | - this->set_public_key_base64_(e, modulus_base64, exponent_base64); |
176 | | - } |
177 | | - |
178 | | - if (e) { e.set_call(api::main(), errors::Call::SIGNATURE_VERIFIER_SET_MODULUS_BASE64); } |
| 158 | + if (e) { e.set_call(api::main(), errors::Call::SIGNATURE_VERIFIER_SET_MODULUS_BASE64); } // Update call |
179 | 159 | } |
180 | 160 |
|
181 | 161 | /** |
@@ -248,7 +228,7 @@ SignatureVerifier_OpenSSL3::set_modulus_base64(basic_Error & e, std::string cons |
248 | 228 | void |
249 | 229 | SignatureVerifier_OpenSSL3::set_exponent_base64(basic_Error & e, std::string const& exponent_base64) |
250 | 230 | { |
251 | | - // Exponent is set by set_modulus_base64() |
| 231 | + // Exponent is always AQAB in our API and we set it in set_modulus_base64() |
252 | 232 | } |
253 | 233 |
|
254 | 234 | /** |
|
0 commit comments