1 #ifndef EAGINE_SSL_API_API_HPP
9 #define EAGINE_SSL_API_API_HPP
11 #include "../callable_ref.hpp"
12 #include "../memory/split_block.hpp"
19 namespace eagine::sslp {
21 #define SSLPAFP(FUNC) decltype(c_api::FUNC), &c_api::FUNC
23 class password_callback {
25 constexpr password_callback() noexcept = default;
27 constexpr password_callback(
29 : _callback{std::move(callback)} {}
31 constexpr
auto native_func() noexcept -> auto* {
32 return _callback ? &_impl :
nullptr;
35 constexpr
auto native_data() noexcept -> auto* {
36 return _callback ?
static_cast<void*
>(
this) :
nullptr;
40 static auto _impl(
char* dst,
int len,
int writing,
void* ptr) ->
int {
41 if(
auto*
self =
static_cast<password_callback*
>(ptr)) {
42 return self->_callback(
53 template <
typename ApiTraits>
54 class basic_ssl_operations :
public basic_ssl_c_api<ApiTraits> {
57 using api_traits = ApiTraits;
58 using c_api = basic_ssl_c_api<ApiTraits>;
60 template <
typename W, W c_api::*F,
typename Signature =
typename W::signature>
63 template <
typename W, W c_api::*F,
typename RVC,
typename... Params>
64 class func<W, F, RVC(Params...)>
65 :
public wrapped_c_api_function<c_api, api_traits, nothing_t, W, F> {
66 using base = wrapped_c_api_function<c_api, api_traits, nothing_t, W, F>;
69 template <
typename Res>
70 constexpr
auto _check(Res&& res)
const noexcept {
71 res.error_code(this->api().err_get_error());
72 return std::forward<Res>(res);
76 template <
typename... Args>
77 constexpr
auto _chkcall(Args&&... args)
const noexcept {
78 return this->_check(this->_call(std::forward<Args>(args)...));
83 template <
typename Tag,
typename Handle>
84 static constexpr
auto _conv(basic_handle<Tag, Handle> obj) noexcept {
85 return static_cast<Handle
>(obj);
88 template <
typename Object>
89 static constexpr
auto _conv(
const object_stack<Object>& stk) noexcept {
93 template <
typename... Args>
94 constexpr
auto _cnvchkcall(Args&&... args)
const noexcept {
95 return this->_chkcall(_conv(args)...).cast_to(type_identity<RVC>{});
101 constexpr
auto operator()(Params... params)
const noexcept {
102 return this->_chkcall(_conv(params)...)
103 .cast_to(type_identity<RVC>{});
106 constexpr
auto fake() const noexcept {
107 auto result{this->_fake(0)};
108 result.set_unknown_error();
114 struct : func<SSLPAFP(ui_null)> {
115 using func<SSLPAFP(ui_null)>::func;
117 constexpr
auto operator()() const noexcept {
118 return this->_chkcall().cast_to(type_identity<ui_method>{});
123 struct : func<SSLPAFP(ui_openssl)> {
124 using func<SSLPAFP(ui_openssl)>::func;
126 constexpr
auto operator()() const noexcept {
127 return this->_chkcall().cast_to(type_identity<ui_method>{});
132 struct : func<SSLPAFP(engine_load_builtin_engines)> {
133 using func<SSLPAFP(engine_load_builtin_engines)>::func;
135 constexpr
auto operator()() const noexcept {
136 return this->_chkcall();
138 } load_builtin_engines;
141 struct : func<SSLPAFP(engine_get_first)> {
142 using func<SSLPAFP(engine_get_first)>::func;
144 constexpr
auto operator()() const noexcept {
145 return this->_chkcall().cast_to(type_identity<owned_engine>{});
150 struct : func<SSLPAFP(engine_get_last)> {
151 using func<SSLPAFP(engine_get_last)>::func;
153 constexpr
auto operator()() const noexcept {
154 return this->_chkcall().cast_to(type_identity<owned_engine>{});
159 struct : func<SSLPAFP(engine_get_next)> {
160 using func<SSLPAFP(engine_get_next)>::func;
162 constexpr
auto operator()(owned_engine& eng)
const noexcept {
163 return this->_cnvchkcall(eng.release())
164 .cast_to(type_identity<owned_engine>{});
169 struct : func<SSLPAFP(engine_get_prev)> {
170 using func<SSLPAFP(engine_get_prev)>::func;
172 constexpr
auto operator()(owned_engine& eng)
const noexcept {
173 return this->_cnvchkcall(eng.release())
174 .cast_to(type_identity<owned_engine>{});
179 struct : func<SSLPAFP(engine_new)> {
180 using func<SSLPAFP(engine_new)>::func;
182 constexpr
auto operator()() const noexcept {
183 return this->_chkcall().cast_to(type_identity<owned_engine>{});
188 struct : func<SSLPAFP(engine_by_id)> {
189 using func<SSLPAFP(engine_by_id)>::func;
191 constexpr
auto operator()(
string_view id)
const noexcept {
192 return this->_cnvchkcall(
id).cast_to(type_identity<owned_engine>{});
197 struct : func<SSLPAFP(engine_up_ref)> {
198 using func<SSLPAFP(engine_up_ref)>::func;
200 constexpr
auto operator()(engine eng)
const noexcept {
201 return this->_cnvchkcall(eng).replaced_with(owned_engine(eng));
206 struct : func<SSLPAFP(engine_free)> {
207 using func<SSLPAFP(engine_free)>::func;
209 constexpr
auto operator()(owned_engine& eng)
const noexcept {
210 return this->_chkcall(eng.release());
213 auto raii(owned_engine& eng)
const noexcept {
220 struct : func<SSLPAFP(engine_init)> {
221 using func<SSLPAFP(engine_init)>::func;
223 constexpr
auto operator()(engine eng)
const noexcept {
224 return collapse_bool(this->_cnvchkcall(eng));
229 struct : func<SSLPAFP(engine_finish)> {
230 using func<SSLPAFP(engine_finish)>::func;
232 constexpr
auto operator()(engine eng)
const noexcept {
233 return collapse_bool(this->_cnvchkcall(eng));
236 auto raii(owned_engine& eng)
const noexcept {
242 struct : func<SSLPAFP(engine_get_id)> {
243 using func<SSLPAFP(engine_get_id)>::func;
245 constexpr
auto operator()(engine eng)
const noexcept {
246 return this->_cnvchkcall(eng).cast_to(type_identity<string_view>{});
251 struct : func<SSLPAFP(engine_get_name)> {
252 using func<SSLPAFP(engine_get_name)>::func;
254 constexpr
auto operator()(engine eng)
const noexcept {
255 return this->_cnvchkcall(eng).cast_to(type_identity<string_view>{});
260 struct : func<SSLPAFP(engine_set_default_rsa)> {
261 using func<SSLPAFP(engine_set_default_rsa)>::func;
263 constexpr
auto operator()(engine eng)
const noexcept {
264 return this->_cnvchkcall(eng);
269 struct : func<SSLPAFP(engine_set_default_dsa)> {
270 using func<SSLPAFP(engine_set_default_dsa)>::func;
272 constexpr
auto operator()(engine eng)
const noexcept {
273 return this->_cnvchkcall(eng);
278 struct : func<SSLPAFP(engine_set_default_dh)> {
279 using func<SSLPAFP(engine_set_default_dh)>::func;
281 constexpr
auto operator()(engine eng)
const noexcept {
282 return this->_cnvchkcall(eng);
287 struct : func<SSLPAFP(engine_set_default_rand)> {
288 using func<SSLPAFP(engine_set_default_rand)>::func;
290 constexpr
auto operator()(engine eng)
const noexcept {
291 return this->_cnvchkcall(eng);
296 struct : func<SSLPAFP(engine_set_default_ciphers)> {
297 using func<SSLPAFP(engine_set_default_ciphers)>::func;
299 constexpr
auto operator()(engine eng)
const noexcept {
300 return this->_cnvchkcall(eng);
302 } set_default_ciphers;
305 struct : func<SSLPAFP(engine_set_default_digests)> {
306 using func<SSLPAFP(engine_set_default_digests)>::func;
308 constexpr
auto operator()(engine eng)
const noexcept {
309 return this->_cnvchkcall(eng);
311 } set_default_digests;
314 struct : func<SSLPAFP(engine_load_private_key)> {
315 using func<SSLPAFP(engine_load_private_key)>::func;
317 constexpr
auto operator()(engine eng,
string_view key_id, ui_method uim)
319 return this->_cnvchkcall(eng, key_id, uim,
nullptr)
320 .cast_to(type_identity<owned_pkey>{});
322 } load_engine_private_key;
325 struct : func<SSLPAFP(engine_load_public_key)> {
326 using func<SSLPAFP(engine_load_public_key)>::func;
329 operator()(engine eng,
string_view key_id)
const noexcept {
330 return this->_cnvchkcall(eng, key_id, this->ui_openssl())
331 .cast_to(type_identity<owned_pkey>{});
333 } load_engine_public_key;
336 struct : func<SSLPAFP(bio_new)> {
337 using func<SSLPAFP(bio_new)>::func;
339 constexpr
auto operator()(basic_io_method method)
const noexcept {
340 return this->_chkcall(method).cast_to(
341 type_identity<owned_basic_io>{});
346 struct : func<SSLPAFP(bio_new_mem_buf)> {
347 using func<SSLPAFP(bio_new_mem_buf)>::func;
350 return this->_chkcall(blk.data(), limit_cast<int>(blk.size()))
351 .cast_to(type_identity<owned_basic_io>{});
354 } new_block_basic_io;
357 struct : func<SSLPAFP(bio_free)> {
358 using func<SSLPAFP(bio_free)>::func;
360 constexpr
auto operator()(owned_basic_io& bio)
const noexcept {
361 return this->_chkcall(bio.release());
364 auto raii(owned_basic_io& bio)
const noexcept {
371 struct : func<SSLPAFP(bio_free_all)> {
372 using func<SSLPAFP(bio_free_all)>::func;
374 constexpr
auto operator()(owned_basic_io& bio)
const noexcept {
375 return this->_chkcall(bio.release());
378 auto raii(owned_basic_io& bio)
const noexcept {
382 } delete_all_basic_ios;
385 struct : func<SSLPAFP(rand_bytes)> {
386 using func<SSLPAFP(rand_bytes)>::func;
388 constexpr
auto operator()(
memory::block blk)
const noexcept {
389 return this->_cnvchkcall(blk.data(), limit_cast<int>(blk.size()));
395 struct : func<SSLPAFP(evp_pkey_up_ref)> {
396 using func<SSLPAFP(evp_pkey_up_ref)>::func;
398 constexpr
auto operator()(pkey pky)
const noexcept {
399 return this->_cnvchkcall(pky).replaced_with(owned_pkey(pky));
404 struct : func<SSLPAFP(evp_pkey_free)> {
405 using func<SSLPAFP(evp_pkey_free)>::func;
407 constexpr
auto operator()(owned_pkey& pky)
const noexcept {
408 return this->_chkcall(pky.release());
411 auto raii(owned_pkey& pky)
const noexcept {
418 struct : func<SSLPAFP(evp_aes_128_ctr)> {
419 using func<SSLPAFP(evp_aes_128_ctr)>::func;
421 constexpr
auto operator()() const noexcept {
422 return this->_chkcall().cast_to(type_identity<cipher_type>{});
424 } cipher_aes_128_ctr;
426 struct : func<SSLPAFP(evp_aes_128_ccm)> {
427 using func<SSLPAFP(evp_aes_128_ccm)>::func;
429 constexpr
auto operator()() const noexcept {
430 return this->_chkcall().cast_to(type_identity<cipher_type>{});
432 } cipher_aes_128_ccm;
434 struct : func<SSLPAFP(evp_aes_128_gcm)> {
435 using func<SSLPAFP(evp_aes_128_gcm)>::func;
437 constexpr
auto operator()() const noexcept {
438 return this->_chkcall().cast_to(type_identity<cipher_type>{});
440 } cipher_aes_128_gcm;
442 struct : func<SSLPAFP(evp_aes_128_xts)> {
443 using func<SSLPAFP(evp_aes_128_xts)>::func;
445 constexpr
auto operator()() const noexcept {
446 return this->_chkcall().cast_to(type_identity<cipher_type>{});
448 } cipher_aes_128_xts;
450 struct : func<SSLPAFP(evp_aes_192_ecb)> {
451 using func<SSLPAFP(evp_aes_192_ecb)>::func;
453 constexpr
auto operator()() const noexcept {
454 return this->_chkcall().cast_to(type_identity<cipher_type>{});
456 } cipher_aes_192_ecb;
458 struct : func<SSLPAFP(evp_aes_192_cbc)> {
459 using func<SSLPAFP(evp_aes_192_cbc)>::func;
461 constexpr
auto operator()() const noexcept {
462 return this->_chkcall().cast_to(type_identity<cipher_type>{});
464 } cipher_aes_192_cbc;
467 struct : func<SSLPAFP(evp_cipher_ctx_new)> {
468 using func<SSLPAFP(evp_cipher_ctx_new)>::func;
470 constexpr
auto operator()() const noexcept {
471 return this->_chkcall().cast_to(type_identity<owned_cipher>{});
476 struct : func<SSLPAFP(evp_cipher_ctx_free)> {
477 using func<SSLPAFP(evp_cipher_ctx_free)>::func;
479 constexpr
auto operator()(owned_cipher& cyc)
const noexcept {
480 return this->_chkcall(cyc.release());
483 auto raii(owned_cipher& cyc)
const noexcept {
490 struct : func<SSLPAFP(evp_cipher_ctx_reset)> {
491 using func<SSLPAFP(evp_cipher_ctx_reset)>::func;
493 constexpr
auto operator()(cipher cyc)
const noexcept {
494 return this->_cnvchkcall(cyc);
500 struct : func<SSLPAFP(evp_cipher_init)> {
501 using func<SSLPAFP(evp_cipher_init)>::func;
503 constexpr
auto operator()(
508 bool enc)
const noexcept {
509 return this->_cnvchkcall(
510 cyc, cyt, key.data(), iv.data(), enc ? 1 : 0);
515 struct : func<SSLPAFP(evp_cipher_init_ex)> {
516 using func<SSLPAFP(evp_cipher_init_ex)>::func;
518 constexpr
auto operator()(
524 bool enc)
const noexcept {
525 return this->_cnvchkcall(
526 cyc, cyt, eng, key.data(), iv.data(), enc ? 1 : 0);
531 struct : func<SSLPAFP(evp_cipher_update)> {
532 using func<SSLPAFP(evp_cipher_update)>::func;
534 constexpr
auto operator()(
545 limit_cast<int>(in.size()))
546 .replaced_with(out.advance(
span_size(outl)));
552 struct : func<SSLPAFP(evp_cipher_final)> {
553 using func<SSLPAFP(evp_cipher_final)>::func;
558 return this->_cnvchkcall(cyc, out.tail().data(), &outl)
559 .replaced_with(out.advance(
span_size(outl)));
564 struct : func<SSLPAFP(evp_cipher_final_ex)> {
565 using func<SSLPAFP(evp_cipher_final_ex)>::func;
570 return this->_cnvchkcall(cyc, out.tail().data(), &outl)
571 .replaced_with(out.advance(
span_size(outl)));
576 struct : func<SSLPAFP(evp_encrypt_init)> {
577 using func<SSLPAFP(evp_encrypt_init)>::func;
579 constexpr
auto operator()(
584 bool enc)
const noexcept {
585 return this->_cnvchkcall(
586 cyc, cyt, key.data(), iv.data(), enc ? 1 : 0);
591 struct : func<SSLPAFP(evp_encrypt_init_ex)> {
592 using func<SSLPAFP(evp_encrypt_init_ex)>::func;
594 constexpr
auto operator()(
600 bool enc)
const noexcept {
601 return this->_cnvchkcall(
602 cyc, cyt, eng, key.data(), iv.data(), enc ? 1 : 0);
607 struct : func<SSLPAFP(evp_encrypt_update)> {
608 using func<SSLPAFP(evp_encrypt_update)>::func;
610 constexpr
auto operator()(
621 limit_cast<int>(in.size()))
622 .replaced_with(out.advance(
span_size(outl)));
628 struct : func<SSLPAFP(evp_encrypt_final)> {
629 using func<SSLPAFP(evp_encrypt_final)>::func;
634 return this->_cnvchkcall(cyc, out.tail().data(), &outl)
635 .replaced_with(out.advance(
span_size(outl)));
640 struct : func<SSLPAFP(evp_encrypt_final_ex)> {
641 using func<SSLPAFP(evp_encrypt_final_ex)>::func;
646 return this->_cnvchkcall(cyc, out.tail().data(), &outl)
647 .replaced_with(out.advance(
span_size(outl)));
652 struct : func<SSLPAFP(evp_decrypt_init)> {
653 using func<SSLPAFP(evp_decrypt_init)>::func;
655 constexpr
auto operator()(
660 bool enc)
const noexcept {
661 return this->_cnvchkcall(
662 cyc, cyt, key.data(), iv.data(), enc ? 1 : 0);
667 struct : func<SSLPAFP(evp_decrypt_init_ex)> {
668 using func<SSLPAFP(evp_decrypt_init_ex)>::func;
670 constexpr
auto operator()(
676 bool enc)
const noexcept {
677 return this->_cnvchkcall(
678 cyc, cyt, eng, key.data(), iv.data(), enc ? 1 : 0);
683 struct : func<SSLPAFP(evp_decrypt_update)> {
684 using func<SSLPAFP(evp_decrypt_update)>::func;
686 constexpr
auto operator()(
697 limit_cast<int>(in.size()))
698 .replaced_with(out.advance(
span_size(outl)));
704 struct : func<SSLPAFP(evp_decrypt_final)> {
705 using func<SSLPAFP(evp_decrypt_final)>::func;
710 return this->_cnvchkcall(cyc, out.tail().data(), &outl)
711 .replaced_with(out.advance(
span_size(outl)));
716 struct : func<SSLPAFP(evp_decrypt_final_ex)> {
717 using func<SSLPAFP(evp_decrypt_final_ex)>::func;
722 return this->_cnvchkcall(cyc, out.tail().data(), &outl)
723 .replaced_with(out.advance(
span_size(outl)));
728 struct : func<SSLPAFP(evp_md_null)> {
729 using func<SSLPAFP(evp_md_null)>::func;
731 constexpr
auto operator()() const noexcept {
732 return this->_chkcall().cast_to(
733 type_identity<message_digest_type>{});
735 } message_digest_noop;
737 struct : func<SSLPAFP(evp_md5)> {
738 using func<SSLPAFP(evp_md5)>::func;
740 constexpr
auto operator()() const noexcept {
741 return this->_chkcall().cast_to(
742 type_identity<message_digest_type>{});
744 } message_digest_md5;
746 struct : func<SSLPAFP(evp_sha1)> {
747 using func<SSLPAFP(evp_sha1)>::func;
749 constexpr
auto operator()() const noexcept {
750 return this->_chkcall().cast_to(
751 type_identity<message_digest_type>{});
753 } message_digest_sha1;
755 struct : func<SSLPAFP(evp_sha224)> {
756 using func<SSLPAFP(evp_sha224)>::func;
758 constexpr
auto operator()() const noexcept {
759 return this->_chkcall().cast_to(
760 type_identity<message_digest_type>{});
762 } message_digest_sha224;
764 struct : func<SSLPAFP(evp_sha256)> {
765 using func<SSLPAFP(evp_sha256)>::func;
767 constexpr
auto operator()() const noexcept {
768 return this->_chkcall().cast_to(
769 type_identity<message_digest_type>{});
771 } message_digest_sha256;
773 struct : func<SSLPAFP(evp_sha384)> {
774 using func<SSLPAFP(evp_sha384)>::func;
776 constexpr
auto operator()() const noexcept {
777 return this->_chkcall().cast_to(
778 type_identity<message_digest_type>{});
780 } message_digest_sha384;
782 struct : func<SSLPAFP(evp_sha512)> {
783 using func<SSLPAFP(evp_sha512)>::func;
785 constexpr
auto operator()() const noexcept {
786 return this->_chkcall().cast_to(
787 type_identity<message_digest_type>{});
789 } message_digest_sha512;
791 struct : func<SSLPAFP(evp_md_size)> {
792 using func<SSLPAFP(evp_md_size)>::func;
794 constexpr
auto operator()(message_digest_type mdt)
const noexcept {
795 return this->_cnvchkcall(mdt);
797 } message_digest_size;
800 struct : func<SSLPAFP(evp_md_ctx_new)> {
801 using func<SSLPAFP(evp_md_ctx_new)>::func;
803 constexpr
auto operator()() const noexcept {
804 return this->_chkcall().cast_to(
805 type_identity<owned_message_digest>{});
807 } new_message_digest;
810 struct : func<SSLPAFP(evp_md_ctx_free)> {
811 using func<SSLPAFP(evp_md_ctx_free)>::func;
813 constexpr
auto operator()(owned_message_digest& mdc)
const noexcept {
814 return this->_chkcall(mdc.release());
817 auto raii(owned_message_digest& mdc)
const noexcept {
821 } delete_message_digest;
824 struct : func<SSLPAFP(evp_md_ctx_reset)> {
825 using func<SSLPAFP(evp_md_ctx_reset)>::func;
827 constexpr
auto operator()(message_digest mdc)
const noexcept {
828 return this->_cnvchkcall(mdc);
831 } message_digest_reset;
834 struct : func<SSLPAFP(evp_digest_init)> {
835 using func<SSLPAFP(evp_digest_init)>::func;
838 operator()(message_digest mdc, message_digest_type mdt)
const noexcept {
839 return this->_cnvchkcall(mdc, mdt);
841 } message_digest_init;
844 struct : func<SSLPAFP(evp_digest_init_ex)> {
845 using func<SSLPAFP(evp_digest_init_ex)>::func;
847 constexpr
auto operator()(
849 message_digest_type mdt,
850 engine eng)
const noexcept {
851 return this->_cnvchkcall(mdc, mdt, eng);
853 } message_digest_init_ex;
856 struct : func<SSLPAFP(evp_digest_update)> {
857 using func<SSLPAFP(evp_digest_update)>::func;
861 return this->_cnvchkcall(mdc, blk.data(),
std_size(blk.size()));
864 } message_digest_update;
867 struct : func<SSLPAFP(evp_digest_final)> {
868 using func<SSLPAFP(evp_digest_final)>::func;
871 operator()(message_digest mdc,
memory::block blk)
const noexcept {
872 unsigned int size{0U};
873 return this->_cnvchkcall(mdc, blk.data(), &size)
876 } message_digest_final;
879 struct : func<SSLPAFP(evp_digest_final_ex)> {
880 using func<SSLPAFP(evp_digest_final_ex)>::func;
883 operator()(message_digest mdc,
memory::block blk)
const noexcept {
884 unsigned int size{0U};
885 return this->_cnvchkcall(mdc, blk.data(), &size)
888 } message_digest_final_ex;
891 struct : func<SSLPAFP(evp_digest_sign_init)> {
892 using func<SSLPAFP(evp_digest_sign_init)>::func;
894 constexpr
auto operator()(
896 message_digest_type mdt,
897 pkey pky)
const noexcept {
898 return this->_cnvchkcall(mdc,
nullptr, mdt,
nullptr, pky);
901 constexpr
auto operator()(
903 message_digest_type mdt,
905 pkey pky)
const noexcept {
906 return this->_cnvchkcall(mdc,
nullptr, mdt, eng, pky);
908 } message_digest_sign_init;
911 struct : func<SSLPAFP(evp_digest_sign_update)> {
912 using func<SSLPAFP(evp_digest_sign_update)>::func;
916 return this->_cnvchkcall(mdc, blk.data(),
std_size(blk.size()));
919 } message_digest_sign_update;
922 struct : func<SSLPAFP(evp_digest_sign_final)> {
923 using func<SSLPAFP(evp_digest_sign_final)>::func;
925 constexpr
auto required_size(message_digest mdc)
const noexcept {
927 return this->_cnvchkcall(mdc,
nullptr, &size)
932 operator()(message_digest mdc,
memory::block blk)
const noexcept {
933 auto size = limit_cast<size_t>(blk.size());
934 return this->_cnvchkcall(mdc, blk.data(), &size)
937 } message_digest_sign_final;
940 struct : func<SSLPAFP(evp_digest_verify_init)> {
941 using func<SSLPAFP(evp_digest_verify_init)>::func;
943 constexpr
auto operator()(
945 message_digest_type mdt,
946 pkey pky)
const noexcept {
947 return this->_cnvchkcall(mdc,
nullptr, mdt,
nullptr, pky);
950 constexpr
auto operator()(
952 message_digest_type mdt,
954 pkey pky)
const noexcept {
955 return this->_cnvchkcall(mdc,
nullptr, mdt, eng, pky);
957 } message_digest_verify_init;
960 struct : func<SSLPAFP(evp_digest_verify_update)> {
961 using func<SSLPAFP(evp_digest_verify_update)>::func;
965 return this->_cnvchkcall(mdc, blk.data(),
std_size(blk.size()));
968 } message_digest_verify_update;
971 struct : func<SSLPAFP(evp_digest_verify_final)> {
972 using func<SSLPAFP(evp_digest_verify_final)>::func;
976 return this->_cnvchkcall(mdc, blk.data(),
std_size(blk.size()))
977 .transformed([](
int result) {
return result == 1; });
979 } message_digest_verify_final;
982 struct : func<SSLPAFP(x509_store_ctx_new)> {
983 using func<SSLPAFP(x509_store_ctx_new)>::func;
985 constexpr
auto operator()() const noexcept {
986 return this->_chkcall().cast_to(
987 type_identity<owned_x509_store_ctx>{});
989 } new_x509_store_ctx;
992 struct : func<SSLPAFP(x509_store_ctx_init)> {
993 using func<SSLPAFP(x509_store_ctx_init)>::func;
995 constexpr
auto operator()(x509_store_ctx xsc, x509_store xst, x509 crt)
997 return this->_cnvchkcall(xsc, xst, crt,
nullptr);
1000 constexpr
auto operator()(
1004 const object_stack<x509>& chain)
const noexcept {
1005 return this->_cnvchkcall(xsc, xst, crt, chain);
1008 } init_x509_store_ctx;
1011 struct : func<SSLPAFP(x509_store_ctx_set0_trusted_stack)> {
1012 using func<SSLPAFP(x509_store_ctx_set0_trusted_stack)>::func;
1014 constexpr
auto operator()(
1016 const object_stack<x509>& stk)
const noexcept {
1017 return this->_cnvchkcall(xsc, stk);
1020 } set_x509_store_trusted_stack;
1023 struct : func<SSLPAFP(x509_store_ctx_set0_verified_chain)> {
1024 using func<SSLPAFP(x509_store_ctx_set0_verified_chain)>::func;
1026 constexpr
auto operator()(
1028 const object_stack<x509>& stk)
const noexcept {
1029 return this->_cnvchkcall(xsc, stk);
1032 } set_x509_store_verified_chain;
1035 struct : func<SSLPAFP(x509_store_ctx_set0_untrusted)> {
1036 using func<SSLPAFP(x509_store_ctx_set0_untrusted)>::func;
1038 constexpr
auto operator()(
1040 const object_stack<x509>& stk)
const noexcept {
1041 return this->_cnvchkcall(xsc, stk);
1044 } set_x509_store_untrusted;
1047 struct : func<SSLPAFP(x509_store_ctx_cleanup)> {
1048 using func<SSLPAFP(x509_store_ctx_cleanup)>::func;
1050 constexpr
auto operator()(x509_store_ctx xsc)
const noexcept {
1051 return this->_chkcall(xsc);
1054 auto raii(x509_store_ctx xsc)
const noexcept {
1058 } cleanup_x509_store_ctx;
1061 struct : func<SSLPAFP(x509_store_ctx_free)> {
1062 using func<SSLPAFP(x509_store_ctx_free)>::func;
1064 constexpr
auto operator()(owned_x509_store_ctx& xsc)
const noexcept {
1065 return this->_chkcall(xsc.release());
1068 auto raii(owned_x509_store_ctx& xsc)
const noexcept {
1072 } delete_x509_store_ctx;
1075 struct : func<SSLPAFP(x509_verify_cert)> {
1076 using func<SSLPAFP(x509_verify_cert)>::func;
1078 constexpr
auto operator()(x509_store_ctx xsc)
const noexcept {
1079 return collapse_bool(this->_cnvchkcall(xsc));
1082 } x509_verify_certificate;
1085 struct : func<SSLPAFP(x509_store_new)> {
1086 using func<SSLPAFP(x509_store_new)>::func;
1088 constexpr
auto operator()() const noexcept {
1089 return this->_chkcall().cast_to(type_identity<owned_x509_store>{});
1094 struct : func<SSLPAFP(x509_store_up_ref)> {
1095 using func<SSLPAFP(x509_store_up_ref)>::func;
1097 constexpr
auto operator()(x509_store xst)
const noexcept {
1098 return this->_chkcall().replaced_with(owned_x509_store{xst});
1103 struct : func<SSLPAFP(x509_store_free)> {
1104 using func<SSLPAFP(x509_store_free)>::func;
1106 constexpr
auto operator()(owned_x509_store& xst)
const noexcept {
1107 return this->_chkcall(xst.release());
1110 auto raii(owned_x509_store& xst)
const noexcept {
1114 } delete_x509_store;
1117 struct : func<SSLPAFP(x509_store_add_cert)> {
1118 using func<SSLPAFP(x509_store_add_cert)>::func;
1120 constexpr
auto operator()(x509_store xst, x509 crt)
const noexcept {
1121 return this->_cnvchkcall(xst, crt);
1124 } add_cert_into_x509_store;
1127 struct : func<SSLPAFP(x509_store_add_crl)> {
1128 using func<SSLPAFP(x509_store_add_crl)>::func;
1130 constexpr
auto operator()(x509_store xst, x509_crl crl)
const noexcept {
1131 return this->_cnvchkcall(xst, crl);
1134 } add_crl_into_x509_store;
1137 struct : func<SSLPAFP(x509_store_load_locations)> {
1138 using func<SSLPAFP(x509_store_load_locations)>::func;
1141 operator()(x509_store xst,
string_view file_path)
const noexcept {
1142 return this->_cnvchkcall(xst, file_path,
nullptr);
1145 } load_into_x509_store;
1148 struct : func<SSLPAFP(x509_crl_new)> {
1149 using func<SSLPAFP(x509_crl_new)>::func;
1151 constexpr
auto operator()() const noexcept {
1152 return this->_chkcall().cast_to(type_identity<owned_x509_crl>{});
1157 struct : func<SSLPAFP(x509_crl_free)> {
1158 using func<SSLPAFP(x509_crl_free)>::func;
1160 constexpr
auto operator()(owned_x509_crl& crl)
const noexcept {
1161 return this->_chkcall(crl.release());
1164 auto raii(owned_x509_crl& crl)
const noexcept {
1171 struct : func<SSLPAFP(x509_new)> {
1172 using func<SSLPAFP(x509_new)>::func;
1174 constexpr
auto operator()() const noexcept {
1175 return this->_chkcall().cast_to(type_identity<owned_x509>{});
1180 struct : func<SSLPAFP(x509_get_pubkey)> {
1181 using func<SSLPAFP(x509_get_pubkey)>::func;
1183 constexpr
auto operator()(x509 crt)
const noexcept {
1184 return this->_cnvchkcall(crt).cast_to(type_identity<owned_pkey>{});
1189 struct : func<SSLPAFP(x509_free)> {
1190 using func<SSLPAFP(x509_free)>::func;
1192 constexpr
auto operator()(owned_x509& crt)
const noexcept {
1193 return this->_chkcall(crt.release());
1196 auto raii(owned_x509& crt)
const noexcept {
1203 struct : func<SSLPAFP(pem_read_bio_private_key)> {
1204 using func<SSLPAFP(pem_read_bio_private_key)>::func;
1206 constexpr
auto operator()(basic_io bio)
const noexcept {
1207 return this->_cnvchkcall(bio,
nullptr,
nullptr,
nullptr)
1208 .cast_to(type_identity<owned_pkey>{});
1212 operator()(basic_io bio, password_callback get_passwd)
const noexcept {
1215 bio,
nullptr, get_passwd.native_func(), get_passwd.native_data())
1216 .cast_to(type_identity<owned_pkey>{});
1219 } read_bio_private_key;
1222 struct : func<SSLPAFP(pem_read_bio_pubkey)> {
1223 using func<SSLPAFP(pem_read_bio_pubkey)>::func;
1225 constexpr
auto operator()(basic_io bio)
const noexcept {
1226 return this->_cnvchkcall(bio,
nullptr,
nullptr,
nullptr)
1227 .cast_to(type_identity<owned_pkey>{});
1231 operator()(basic_io bio, password_callback get_passwd)
const noexcept {
1234 bio,
nullptr, get_passwd.native_func(), get_passwd.native_data())
1235 .cast_to(type_identity<owned_pkey>{});
1238 } read_bio_public_key;
1241 struct : func<SSLPAFP(pem_read_bio_x509_crl)> {
1242 using func<SSLPAFP(pem_read_bio_x509_crl)>::func;
1244 constexpr
auto operator()(basic_io bio)
const noexcept {
1245 return this->_cnvchkcall(bio,
nullptr,
nullptr,
nullptr)
1246 .cast_to(type_identity<owned_x509_crl>{});
1250 operator()(basic_io bio, password_callback get_passwd)
const noexcept {
1253 bio,
nullptr, get_passwd.native_func(), get_passwd.native_data())
1254 .cast_to(type_identity<owned_x509_crl>{});
1257 } read_bio_x509_crl;
1260 struct : func<SSLPAFP(pem_read_bio_x509)> {
1261 using func<SSLPAFP(pem_read_bio_x509)>::func;
1263 constexpr
auto operator()(basic_io bio)
const noexcept {
1264 return this->_cnvchkcall(bio,
nullptr,
nullptr,
nullptr)
1265 .cast_to(type_identity<owned_x509>{});
1269 operator()(basic_io bio, password_callback get_passwd)
const noexcept {
1272 bio,
nullptr, get_passwd.native_func(), get_passwd.native_data())
1273 .cast_to(type_identity<owned_x509>{});
1278 constexpr basic_ssl_operations(api_traits& traits)
1280 , null_ui(
"null_ui", traits, *
this)
1281 , openssl_ui(
"openssl_ui", traits, *
this)
1282 , load_builtin_engines(
"load_builtin_engines", traits, *
this)
1283 , get_first_engine(
"get_first_engine", traits, *
this)
1284 , get_last_engine(
"get_last_engine", traits, *
this)
1285 , get_next_engine(
"get_next_engine", traits, *
this)
1286 , get_prev_engine(
"get_prev_engine", traits, *
this)
1287 , new_engine(
"new_engine", traits, *
this)
1288 , open_engine(
"open_engine", traits, *
this)
1289 , copy_engine(
"copy_engine", traits, *
this)
1290 , delete_engine(
"delete_engine", traits, *
this)
1291 , init_engine(
"init_engine", traits, *
this)
1292 , finish_engine(
"finish_engine", traits, *
this)
1293 , get_engine_id(
"get_engine_id", traits, *
this)
1294 , get_engine_name(
"get_engine_name", traits, *
this)
1295 , set_default_rsa(
"set_default_rsa", traits, *
this)
1296 , set_default_dsa(
"set_default_dsa", traits, *
this)
1297 , set_default_dh(
"set_default_dh", traits, *
this)
1298 , set_default_rand(
"set_default_rand", traits, *
this)
1299 , set_default_ciphers(
"set_default_ciphers", traits, *
this)
1300 , set_default_digests(
"set_default_digests", traits, *
this)
1301 , load_engine_private_key(
"load_engine_private_key", traits, *
this)
1302 , load_engine_public_key(
"load_engine_public_key", traits, *
this)
1303 , new_basic_io(
"new_basic_io", traits, *
this)
1304 , new_block_basic_io(
"new_block_basic_io", traits, *
this)
1305 , delete_basic_io(
"delete_basic_io", traits, *
this)
1306 , delete_all_basic_ios(
"delete_all_basic_ios", traits, *
this)
1307 , random_bytes(
"random_bytes", traits, *
this)
1308 , copy_pkey(
"copy_pkey", traits, *
this)
1309 , delete_pkey(
"delete_pkey", traits, *
this)
1310 , cipher_aes_128_ctr(
"cipher_aes_128_ctr", traits, *
this)
1311 , cipher_aes_128_ccm(
"cipher_aes_128_ccm", traits, *
this)
1312 , cipher_aes_128_gcm(
"cipher_aes_128_gcm", traits, *
this)
1313 , cipher_aes_128_xts(
"cipher_aes_128_xts", traits, *
this)
1314 , cipher_aes_192_ecb(
"cipher_aes_192_ecb", traits, *
this)
1315 , cipher_aes_192_cbc(
"cipher_aes_192_cbc", traits, *
this)
1316 , new_cipher(
"new_cipher", traits, *
this)
1317 , delete_cipher(
"delete_cipher", traits, *
this)
1318 , cipher_reset(
"cipher_reset", traits, *
this)
1319 , cipher_init(
"cipher_init", traits, *
this)
1320 , cipher_init_ex(
"cipher_init_ex", traits, *
this)
1321 , cipher_update(
"cipher_update", traits, *
this)
1322 , cipher_final(
"cipher_final", traits, *
this)
1323 , cipher_final_ex(
"cipher_final", traits, *
this)
1324 , encrypt_init(
"encrypt_init", traits, *
this)
1325 , encrypt_init_ex(
"encrypt_init_ex", traits, *
this)
1326 , encrypt_update(
"encrypt_update", traits, *
this)
1327 , encrypt_final(
"encrypt_final", traits, *
this)
1328 , encrypt_final_ex(
"encrypt_final", traits, *
this)
1329 , decrypt_init(
"decrypt_init", traits, *
this)
1330 , decrypt_init_ex(
"decrypt_init_ex", traits, *
this)
1331 , decrypt_update(
"decrypt_update", traits, *
this)
1332 , decrypt_final(
"decrypt_final", traits, *
this)
1333 , decrypt_final_ex(
"decrypt_final", traits, *
this)
1334 , message_digest_noop(
"message_digest_noop", traits, *
this)
1335 , message_digest_md5(
"message_digest_md5", traits, *
this)
1336 , message_digest_sha1(
"message_digest_sha1", traits, *
this)
1337 , message_digest_sha224(
"message_digest_sha224", traits, *
this)
1338 , message_digest_sha256(
"message_digest_sha256", traits, *
this)
1339 , message_digest_sha384(
"message_digest_sha384", traits, *
this)
1340 , message_digest_sha512(
"message_digest_sha512", traits, *
this)
1341 , message_digest_size(
"message_digest_size", traits, *
this)
1342 , new_message_digest(
"new_message_digest", traits, *
this)
1343 , delete_message_digest(
"delete_message_digest", traits, *
this)
1344 , message_digest_reset(
"message_digest_reset", traits, *
this)
1345 , message_digest_init(
"message_digest_init", traits, *
this)
1346 , message_digest_init_ex(
"message_digest_init_ex", traits, *
this)
1347 , message_digest_update(
"message_digest_update", traits, *
this)
1348 , message_digest_final(
"message_digest_final", traits, *
this)
1349 , message_digest_final_ex(
"message_digest_final", traits, *
this)
1350 , message_digest_sign_init(
"message_digest_sign_init", traits, *
this)
1351 , message_digest_sign_update(
"message_digest_sign_update", traits, *
this)
1352 , message_digest_sign_final(
"message_digest_sign_final", traits, *
this)
1353 , message_digest_verify_init(
"message_digest_verify_init", traits, *
this)
1354 , message_digest_verify_update(
1355 "message_digest_verify_update",
1358 , message_digest_verify_final(
"message_digest_verify_final", traits, *
this)
1359 , new_x509_store_ctx(
"new_x509_store_ctx", traits, *
this)
1360 , init_x509_store_ctx(
"init_x509_store_ctx", traits, *
this)
1361 , set_x509_store_trusted_stack(
1362 "set_x509_store_trusted_stack",
1365 , set_x509_store_verified_chain(
1366 "set_x509_store_verified_chain",
1369 , set_x509_store_untrusted(
"set_x509_store_untrusted", traits, *
this)
1370 , cleanup_x509_store_ctx(
"cleanup_x509_store_ctx", traits, *
this)
1371 , delete_x509_store_ctx(
"delete_x509_store_ctx", traits, *
this)
1372 , x509_verify_certificate(
"x509_verify_certificate", traits, *
this)
1373 , new_x509_store(
"new_x509_store", traits, *
this)
1374 , copy_x509_store(
"copy_x509_store", traits, *
this)
1375 , delete_x509_store(
"delete_x509_store", traits, *
this)
1376 , add_cert_into_x509_store(
"add_cert_into_x509_store", traits, *
this)
1377 , add_crl_into_x509_store(
"add_crl_into_x509_store", traits, *
this)
1378 , load_into_x509_store(
"load_into_x509_store", traits, *
this)
1379 , new_x509_crl(
"new_x509_crl", traits, *
this)
1380 , delete_x509_crl(
"delete_x509_crl", traits, *
this)
1381 , new_x509(
"new_x509", traits, *
this)
1382 , get_x509_pubkey(
"get_x509_pubkey", traits, *
this)
1383 , delete_x509(
"delete_x509", traits, *
this)
1384 , read_bio_private_key(
"read_bio_private_key", traits, *
this)
1385 , read_bio_public_key(
"read_bio_public_key", traits, *
this)
1386 , read_bio_x509_crl(
"read_bio_x509_crl", traits, *
this)
1387 , read_bio_x509(
"read_bio_x509", traits, *
this) {}
1394 #endif // EAGINE_SSL_API_API_HPP