00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include <axis2_defines.h>
00017 #include <axis2_env.h>
00018 #include <openssl/evp.h>
00019 #include <oxs_key.h>
00024 #ifndef OPENSSL_CIPHER_CTX_H
00025 #define OPENSSL_CIPHER_CTX_H
00026
00027 #ifdef __cplusplus
00028 extern "C" {
00029 #endif
00030
00031
00033 typedef struct openssl_cipher_ctx_ops openssl_cipher_ctx_ops_t;
00035 typedef struct openssl_cipher_ctx openssl_cipher_ctx_t;
00036
00037
00038 struct openssl_cipher_ctx_ops
00039 {
00046 axis2_status_t (AXIS2_CALL *
00047 free)(openssl_cipher_ctx_t *ctx,
00048 const axis2_env_t *env
00049 );
00056 const EVP_CIPHER* (AXIS2_CALL *
00057 get_cipher)(openssl_cipher_ctx_t *ctx,
00058 const axis2_env_t *env
00059 );
00066 oxs_key_t *(AXIS2_CALL *
00067 get_key)(openssl_cipher_ctx_t *ctx,
00068 const axis2_env_t *env
00069 );
00076 axis2_char_t *(AXIS2_CALL *
00077 get_iv)(openssl_cipher_ctx_t *ctx,
00078 const axis2_env_t *env
00079 );
00086 axis2_char_t *(AXIS2_CALL *
00087 get_pad)(openssl_cipher_ctx_t *ctx,
00088 const axis2_env_t *env
00089 );
00090
00091 axis2_status_t (AXIS2_CALL *
00092 set_cipher)(openssl_cipher_ctx_t *ctx,
00093 const axis2_env_t *env,
00094 const EVP_CIPHER* cipher
00095 );
00096
00097 axis2_status_t (AXIS2_CALL *
00098 set_key_value)(openssl_cipher_ctx_t *ctx,
00099 const axis2_env_t *env,
00100 oxs_key_t *key
00101 );
00102
00103 axis2_status_t (AXIS2_CALL *
00104 set_iv)(openssl_cipher_ctx_t *ctx,
00105 const axis2_env_t *env,
00106 axis2_char_t *iv
00107 );
00108
00109 axis2_status_t (AXIS2_CALL *
00110 set_pad)(openssl_cipher_ctx_t *ctx,
00111 const axis2_env_t *env,
00112 axis2_char_t *pad
00113 );
00114
00115 };
00116
00117 struct openssl_cipher_ctx
00118 {
00120 openssl_cipher_ctx_ops_t *ops;
00121 };
00122
00123
00124 AXIS2_EXTERN openssl_cipher_ctx_t *AXIS2_CALL
00125 openssl_cipher_ctx_create(const axis2_env_t *env);
00126
00127
00128 #define OPENSSL_CIPHER_CTX_FREE(ctx, env)\
00129 ((ctx)->ops->free(ctx, env))
00130
00131 #define OPENSSL_CIPHER_CTX_GET_CIPHER(ctx, env)\
00132 ((ctx)->ops->get_cipher(ctx, env))
00133
00134 #define OPENSSL_CIPHER_CTX_GET_KEY(ctx, env)\
00135 ((ctx)->ops->get_key(ctx, env))
00136
00137 #define OPENSSL_CIPHER_CTX_GET_IV(ctx, env)\
00138 ((ctx)->ops->get_iv(ctx, env))
00139
00140 #define OPENSSL_CIPHER_CTX_GET_PAD(ctx, env)\
00141 ((ctx)->ops->get_pad(ctx, env))
00142
00143 #define OPENSSL_CIPHER_CTX_SET_CIPHER(ctx, env, cipher)\
00144 ((ctx)->ops->set_cipher(ctx, env, cipher))
00145
00146 #define OPENSSL_CIPHER_CTX_SET_IV(ctx, env, iv)\
00147 ((ctx)->ops->set_iv(ctx, env, iv))
00148
00149 #define OPENSSL_CIPHER_CTX_SET_KEY(ctx, env, key)\
00150 ((ctx)->ops->set_key_value(ctx, env, key))
00151
00152 #define OPENSSL_CIPHER_CTX_SET_PAD(ctx, env, pad)\
00153 ((ctx)->ops->set_pad(ctx, env, pad))
00154
00155
00156 #ifdef __cplusplus
00157 }
00158 #endif
00159
00160 #endif