2 #ifndef TECGRAF_SDK_OPENBUS_OPENSSL_H_
3 #define TECGRAF_SDK_OPENBUS_OPENSSL_H_
5 #include "openbus/decl.hpp"
7 #include <openssl/pem.h>
8 #include <boost/shared_ptr.hpp>
9 #include <boost/function.hpp>
18 explicit pkey_ctx(EVP_PKEY_CTX *ctx) : ctx(ctx)
30 EVP_PKEY_CTX_free(ctx);
34 EVP_PKEY_CTX *
get()
const
44 typedef bool(pkey_ctx::*unspecified_bool_type)()
const;
46 operator unspecified_bool_type()
const
48 unspecified_bool_type n = 0;
49 return is_empty()?n:&pkey_ctx::is_empty;
52 bool operator!()
const
62 explicit openssl_buffer(
unsigned char *buffer)
63 : buffer(buffer), deleter_(CRYPTO_free)
75 void deleter(boost::function<
void (
unsigned char *)> p)
80 unsigned char &operator[](std::size_t s)
85 unsigned char const &operator[](std::size_t s)
const
90 unsigned char *release()
92 unsigned char *tmp = buffer;
102 typedef bool(openssl_buffer::* unspecified_bool_type)()
const;
104 operator unspecified_bool_type ()
const
106 unspecified_bool_type n = 0;
107 return is_empty()? n : &openssl_buffer::is_empty;
110 unsigned char *
get()
const
115 unsigned char *buffer;
116 boost::function<void (unsigned char *)> deleter_;
121 explicit pkey(EVP_PKEY *key) : key(key, & ::EVP_PKEY_free)
129 EVP_PKEY *
get()
const
134 bool is_empty()
const
139 typedef bool(pkey::* unspecified_bool_type)()
const;
141 operator unspecified_bool_type ()
const
143 unspecified_bool_type n = 0;
144 return is_empty()?n:&pkey::is_empty;
147 bool operator!()
const
152 boost::shared_ptr<EVP_PKEY> key;
155 OPENBUS_SDK_DECL pkey byteSeq2PubKey(
const unsigned char *,
size_t len);
156 OPENBUS_SDK_DECL pkey byteSeq2PrvKey(
const unsigned char *,
size_t len);
157 OPENBUS_SDK_DECL CORBA::OctetSeq PubKey2byteSeq(pkey);
158 OPENBUS_SDK_DECL CORBA::OctetSeq PrvKey2byteSeq(pkey);
159 OPENBUS_SDK_DECL CORBA::OctetSeq encrypt(pkey,
const unsigned char *,
size_t len);
160 OPENBUS_SDK_DECL CORBA::OctetSeq decrypt(pkey,
const unsigned char *,
size_t len);
openbus
Definition: Connection.hpp:41