BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet software
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/dh.h>
5 #include <openssl/evp.h>
6 #include <openssl/conf.h>
7 #include <openssl/err.h>
8 #include <openssl/ecdsa.h>
9 #include <openssl/ecdh.h>
10 #include <openssl/sha.h>
11 #include <openssl/obj_mac.h>
12 
17 namespace fc
18 {
19  class path;
20 
21  template <typename ssl_type>
22  struct ssl_wrapper
23  {
24  ssl_wrapper(ssl_type* obj):obj(obj) {}
25  ssl_wrapper( ssl_wrapper& copy ) = delete;
26  ssl_wrapper& operator=( ssl_wrapper& copy ) = delete;
27 
28  operator ssl_type*() { return obj; }
29  operator const ssl_type*() const { return obj; }
30  ssl_type* operator->() { return obj; }
31  const ssl_type* operator->() const { return obj; }
32 
33  ssl_type* obj;
34  };
35 
36  #define SSL_TYPE_DECL(name, ssl_type) \
37  struct name : public ssl_wrapper<ssl_type> \
38  { \
39  name( ssl_type* obj=nullptr ); \
40  name( name&& move ); \
41  ~name(); \
42  name& operator=( name&& move ); \
43  };
44 
45  SSL_TYPE_DECL(ec_group, EC_GROUP)
46  SSL_TYPE_DECL(ec_point, EC_POINT)
47  SSL_TYPE_DECL(ecdsa_sig, ECDSA_SIG)
48  SSL_TYPE_DECL(bn_ctx, BN_CTX)
49  SSL_TYPE_DECL(evp_cipher_ctx, EVP_CIPHER_CTX)
50  SSL_TYPE_DECL(ssl_dh, DH)
51 
52 
53  struct ssl_bignum : public ssl_wrapper<BIGNUM>
54  {
55  ssl_bignum() : ssl_wrapper(BN_new()) {}
56  ~ssl_bignum() { BN_free(obj); }
57  };
58 
65  void store_configuration_path(const path& filePath);
66  int init_openssl();
67 
68 } // namespace fc
fc::ssl_wrapper::ssl_wrapper
ssl_wrapper(ssl_type *obj)
Definition: openssl.hpp:24
fc::copy
void copy(const path &from, const path &to)
Definition: filesystem.cpp:241
fc::ssl_bignum::~ssl_bignum
~ssl_bignum()
Definition: openssl.hpp:56
fc
Definition: api.hpp:15
fc::ssl_wrapper::operator=
ssl_wrapper & operator=(ssl_wrapper &copy)=delete
fc::ssl_bignum
Definition: openssl.hpp:53
fc::ssl_wrapper::operator->
const ssl_type * operator->() const
Definition: openssl.hpp:31
fc::ssl_wrapper::operator->
ssl_type * operator->()
Definition: openssl.hpp:30
SSL_TYPE_DECL
#define SSL_TYPE_DECL(name, ssl_type)
Definition: openssl.hpp:36
fc::init_openssl
int init_openssl()
Definition: openssl.cpp:63
fc::ssl_wrapper
Definition: openssl.hpp:22
fc::ssl_bignum::ssl_bignum
ssl_bignum()
Definition: openssl.hpp:55
fc::ssl_wrapper::obj
ssl_type * obj
Definition: openssl.hpp:33
fc::store_configuration_path
void store_configuration_path(const path &filePath)
Definition: openssl.cpp:58
BIGNUM
bignum_st BIGNUM
Definition: bigint.hpp:6