Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
openssl.hpp
Go to the documentation of this file.
1#pragma once
2#include <openssl/ec.h>
3#include <openssl/crypto.h>
4#include <openssl/evp.h>
5#include <openssl/conf.h>
6#include <openssl/err.h>
7#include <openssl/ecdsa.h>
8#include <openssl/ecdh.h>
9#include <openssl/sha.h>
10#include <openssl/obj_mac.h>
11#include <openssl/bn.h>
12
17namespace fc
18{
19 class path;
20
21 template <typename ssl_type>
23 {
24 ssl_wrapper(ssl_type* obj):obj(obj) {}
25
26 operator ssl_type*() { return obj; }
27 operator const ssl_type*() const { return obj; }
28 ssl_type* operator->() { return obj; }
29 const ssl_type* operator->() const { return obj; }
30
31 ssl_type* obj;
32 };
33
34 #define SSL_TYPE(name, ssl_type, free_func) \
35 struct name : public ssl_wrapper<ssl_type> \
36 { \
37 name(ssl_type* obj=nullptr) \
38 : ssl_wrapper(obj) {} \
39 ~name() \
40 { \
41 if( obj != nullptr ) \
42 free_func(obj); \
43 } \
44 };
45
46 SSL_TYPE(ec_group, EC_GROUP, EC_GROUP_free)
47 SSL_TYPE(ec_point, EC_POINT, EC_POINT_free)
48 SSL_TYPE(ecdsa_sig, ECDSA_SIG, ECDSA_SIG_free)
49 SSL_TYPE(bn_ctx, BN_CTX, BN_CTX_free)
50 SSL_TYPE(evp_cipher_ctx, EVP_CIPHER_CTX, EVP_CIPHER_CTX_free )
51 SSL_TYPE(ec_key, EC_KEY, EC_KEY_free)
52
53
54 struct ssl_bignum : public ssl_wrapper<BIGNUM>
55 {
56 ssl_bignum() : ssl_wrapper(BN_new()) {}
57 ~ssl_bignum() { BN_free(obj); }
58 };
59
60} // namespace fc
bignum_st BIGNUM
Definition bigint.hpp:7
namespace sysio::chain
Definition authority.cpp:3
#define SSL_TYPE(name, ssl_type, free_func)
Definition openssl.hpp:34
const ssl_type * operator->() const
Definition openssl.hpp:29
ssl_type * operator->()
Definition openssl.hpp:28
ssl_wrapper(ssl_type *obj)
Definition openssl.hpp:24
ssl_type * obj
Definition openssl.hpp:31