@@ -30,7 +30,7 @@ namespace cryptolens_io {
3030namespace v20190401 {
3131
3232void
33- verify (basic_Error & e, RSA * rsa, std::string const & message, std::string const & sig)
33+ verify (basic_Error & e, RSA * rsa, std::vector< unsigned char > const & message, std::vector< unsigned char > const & sig)
3434{
3535 using namespace errors ;
3636 api::main api;
@@ -61,10 +61,10 @@ verify(basic_Error & e, RSA * rsa, std::string const& message, std::string const
6161 r = EVP_DigestVerifyInit (ctx, NULL , EVP_sha256 (), NULL , pkey);
6262 if (r != 1 ) { e.set (api, Subsystem::SignatureVerifier, DIGEST_VERIFY_INIT_FAILED); goto end; }
6363
64- r = EVP_DigestVerifyUpdate (ctx, (unsigned char *)message.c_str (), message.size ());
64+ r = EVP_DigestVerifyUpdate (ctx, (unsigned char *)message.data (), message.size ());
6565 if (r != 1 ) { e.set (api, Subsystem::SignatureVerifier, DIGEST_VERIFY_UPDATE_FAILED); goto end; }
6666
67- r = EVP_DigestVerifyFinal (ctx, (unsigned char *)sig.c_str (), sig.size ());
67+ r = EVP_DigestVerifyFinal (ctx, (unsigned char *)sig.data (), sig.size ());
6868 if (r != 1 ) { e.set (api, Subsystem::SignatureVerifier, DIGEST_VERIFY_FINAL_FAILED); goto end; }
6969
7070end:
@@ -164,19 +164,19 @@ SignatureVerifier_OpenSSL::set_modulus_base64_(basic_Error & e, std::string cons
164164 if (e) { return ; }
165165 if (this ->rsa == NULL ) { e.set (api::main (), errors::Subsystem::SignatureVerifier, RSA_NULL); return ; }
166166
167- optional<std::string > modulus = ::cryptolens_io::v20190401::internal::b64_decode (modulus_base64);
167+ optional<std::vector< unsigned char > > modulus = ::cryptolens_io::v20190401::internal::b64_decode (modulus_base64);
168168 if (!modulus) { e.set (api::main (), errors::Subsystem::Base64); return ; }
169169
170170#if OPENSSL_VERSION_NUMBER < 0x10100000L
171- BIGNUM * n = BN_bin2bn ((unsigned char *)modulus->c_str (), modulus->size (), this ->rsa ->n );
171+ BIGNUM * n = BN_bin2bn ((unsigned char *)modulus->data (), modulus->size (), this ->rsa ->n );
172172 if (n == NULL ) { e.set (api::main (), errors::Subsystem::SignatureVerifier, BN_BIN2BN_FAILED); return ; }
173173#else
174174 BIGNUM const * exp_current;
175175
176176 // void return type
177177 RSA_get0_key (this ->rsa , NULL , &exp_current, NULL );
178178
179- BIGNUM * n = BN_bin2bn ((unsigned char *)modulus->c_str (), modulus->size (), NULL );
179+ BIGNUM * n = BN_bin2bn ((unsigned char *)modulus->data (), modulus->size (), NULL );
180180 if (n == NULL ) { e.set (api::main (), errors::Subsystem::SignatureVerifier, BN_BIN2BN_FAILED); return ; }
181181
182182 BIGNUM * exp;
@@ -201,19 +201,19 @@ SignatureVerifier_OpenSSL::set_exponent_base64_(basic_Error & e, std::string con
201201 if (e) { return ; }
202202 if (this ->rsa == NULL ) { e.set (api::main (), errors::Subsystem::SignatureVerifier, RSA_NULL); return ; }
203203
204- optional<std::string > exponent = ::cryptolens_io::v20190401::internal::b64_decode (exponent_base64);
204+ optional<std::vector< unsigned char > > exponent = ::cryptolens_io::v20190401::internal::b64_decode (exponent_base64);
205205 if (!exponent) { e.set (api::main (), errors::Subsystem::Base64); return ; }
206206
207207#if OPENSSL_VERSION_NUMBER < 0x10100000L
208- BIGNUM * exp = BN_bin2bn (( unsigned char *) exponent->c_str (), exponent->size (), this ->rsa ->e );
208+ BIGNUM * exp = BN_bin2bn (exponent->data (), exponent->size (), this ->rsa ->e );
209209 if (exp == NULL ) { e.set (api::main (), errors::Subsystem::SignatureVerifier, BN_BIN2BN_FAILED); return ; }
210210#else
211211 BIGNUM const * n_current;
212212
213213 // void return type
214214 RSA_get0_key (this ->rsa , &n_current, NULL , NULL );
215215
216- BIGNUM * exp = BN_bin2bn ((unsigned char *)exponent->c_str (), exponent->size (), NULL );
216+ BIGNUM * exp = BN_bin2bn ((unsigned char *)exponent->data (), exponent->size (), NULL );
217217 if (exp == NULL ) { e.set (api::main (), errors::Subsystem::SignatureVerifier, BN_NEW_FAILED); return ; }
218218
219219 BIGNUM * n;
@@ -238,15 +238,15 @@ SignatureVerifier_OpenSSL::set_exponent_base64_(basic_Error & e, std::string con
238238bool
239239SignatureVerifier_OpenSSL::verify_message
240240 ( basic_Error & e
241- , std::string const & message
241+ , std::vector< unsigned char > const & message
242242 , std::string const & signature_base64
243243 )
244244const
245245{
246246 if (e) { return false ; }
247247 if (this ->rsa == NULL ) { e.set (api::main (), errors::Subsystem::SignatureVerifier, RSA_NULL); return false ; }
248248
249- optional<std::string > sig = ::cryptolens_io::v20190401::internal::b64_decode (signature_base64);
249+ optional<std::vector< unsigned char > > sig = ::cryptolens_io::v20190401::internal::b64_decode (signature_base64);
250250 if (!sig) { e.set (api::main (), errors::Subsystem::Base64); return false ; }
251251
252252 verify (e, this ->rsa , message, *sig);
0 commit comments