00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <openssl/rand.h>
00018 #include <openssl/evp.h>
00019 #include <openssl/pem.h>
00020 #include <openssl/bio.h>
00021 #include <openssl/rand.h>
00022 #include <openssl_constants.h>
00023 #include <axis2_util.h>
00024
00030 #ifndef OPENSSL_PKEY_H
00031 #define OPENSSL_PKEY_H
00032
00033 #ifdef __cplusplus
00034 extern "C" {
00035 #endif
00036
00042 #define OPENSSL_PKEY_TYPE_UNKNOWN 0
00043 #define OPENSSL_PKEY_TYPE_PUBLIC_KEY 1
00044 #define OPENSSL_PKEY_TYPE_PRIVATE_KEY 2
00045
00047 typedef struct openssl_pkey_ops openssl_pkey_ops_t;
00049 typedef struct openssl_pkey openssl_pkey_t;
00050
00051
00052 struct openssl_pkey_ops
00053 {
00054
00055 EVP_PKEY *(AXIS2_CALL *
00056 get_key)(
00057 const openssl_pkey_t *pkey,
00058 const axis2_env_t *env
00059 );
00060 axis2_char_t *(AXIS2_CALL *
00061 get_name) (
00062 const openssl_pkey_t *pkey,
00063 const axis2_env_t *env
00064 );
00065 int (AXIS2_CALL *
00066 get_size)(
00067 const openssl_pkey_t *pkey,
00068 const axis2_env_t *env
00069 );
00070 int (AXIS2_CALL *
00071 get_type) (
00072 const openssl_pkey_t *pkey,
00073 const axis2_env_t *env
00074 );
00075
00076 axis2_status_t (AXIS2_CALL *
00077 set_key )(
00078 openssl_pkey_t *pkey,
00079 const axis2_env_t *env,
00080 EVP_PKEY *key
00081 );
00082
00083 axis2_status_t (AXIS2_CALL*
00084 set_name )(
00085 openssl_pkey_t *pkey,
00086 const axis2_env_t *env,
00087 axis2_char_t *name
00088 );
00089 axis2_status_t (AXIS2_CALL*
00090 set_type )(
00091 openssl_pkey_t *pkey,
00092 const axis2_env_t *env,
00093 int type
00094 );
00095
00096 axis2_status_t (AXIS2_CALL*
00097 load )(
00098 openssl_pkey_t *pkey,
00099 const axis2_env_t *env,
00100 axis2_char_t *filename,
00101 axis2_char_t *password
00102 );
00103
00104 axis2_status_t (AXIS2_CALL*
00105 populate)(
00106 openssl_pkey_t *pkey,
00107 const axis2_env_t *env,
00108 EVP_PKEY *key,
00109 axis2_char_t *name,
00110 int type
00111 );
00112
00113 axis2_status_t (AXIS2_CALL*
00114 free )(
00115 openssl_pkey_t *pkey,
00116 const axis2_env_t *env
00117 );
00118
00119 };
00120
00121 struct openssl_pkey
00122 {
00124 openssl_pkey_ops_t *ops;
00125 };
00126
00127
00128 AXIS2_EXTERN openssl_pkey_t *AXIS2_CALL
00129 openssl_pkey_create(const axis2_env_t *env);
00130
00131
00132
00133 #define OPENSSL_PKEY_GET_KEY(pkey, env) \
00134 ((pkey)->ops->get_key(pkey, env))
00135
00136 #define OPENSSL_PKEY_GET_NAME(pkey, env) \
00137 ((pkey)->ops->get_name(pkey, env))
00138
00139 #define OPENSSL_PKEY_GET_SIZE(pkey, env) \
00140 ((pkey)->ops->get_size(pkey, env))
00141
00142 #define OPENSSL_PKEY_GET_TYPE(pkey, env) \
00143 ((pkey)->ops->get_type(pkey, env))
00144
00145 #define OPENSSL_PKEY_SET_KEY(pkey, env, key) \
00146 ((pkey)->ops->set_key(pkey, env, key))
00147
00148 #define OPENSSL_PKEY_SET_NAME(pkey, env, name) \
00149 ((pkey)->ops->set_name(pkey, env, name))
00150
00151 #define OPENSSL_PKEY_SET_TYPE(pkey, env, type) \
00152 ((pkey)->ops->set_type(pkey, env, type))
00153
00154 #define OPENSSL_PKEY_LOAD(pkey, env, filename, password) \
00155 ((pkey)->ops->load(pkey, env, filename, password))
00156
00157 #define OPENSSL_PKEY_POPULATE(pkey, env, key, name, type) \
00158 ((pkey)->ops->populate(pkey, env, key, name, type))
00159
00160 #define OPENSSL_PKEY_FREE(pkey, env) \
00161 ((pkey)->ops->free(pkey, env))
00162
00163
00165 #ifdef __cplusplus
00166 }
00167 #endif
00168
00169 #endif