oxs_key.h

Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one or more
00003  * contributor license agreements.  See the NOTICE file distributed with
00004  * this work for additional information regarding copyright ownership.
00005  * The ASF licenses this file to You under the Apache License, Version 2.0
00006  * (the "License"); you may not use this file except in compliance with
00007  * the License.  You may obtain a copy of the License at
00008  *
00009  *      http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 #ifndef OXS_KEY_H
00019 #define OXS_KEY_H
00020 
00021 
00027 #include <axis2_defines.h>
00028 #include <oxs_constants.h>
00029 #include <axis2_env.h>
00030 
00031 #ifdef __cplusplus
00032 extern "C"
00033 {
00034 #endif
00035 
00036 /*Key is for signing*/
00037 #define OXS_KEY_USAGE_SIGN          0
00038 /*Key is for verifying signature*/
00039 #define OXS_KEY_USAGE_VERIFY        1
00040 /*Key is for encrypting */
00041 #define OXS_KEY_USAGE_ENCRYPT       2
00042 /*Key is for decrypting*/
00043 #define OXS_KEY_USAGE_DECRYPT       3
00044 /*Key usage is not specified yet*/
00045 #define OXS_KEY_USAGE_NONE          4
00046 
00047 #define OXS_KEY_DEFAULT_SIZE        64
00048 
00050     typedef struct oxs_key_ops oxs_key_ops_t;
00051 
00053     typedef struct oxs_key oxs_key_t;
00054 
00055     struct oxs_key_ops
00056     {
00064         unsigned char *(AXIS2_CALL *
00065                 get_data)(
00066                     const oxs_key_t *key,
00067                     const axis2_env_t *env);
00074         axis2_char_t *(AXIS2_CALL *
00075                 get_name)(
00076                     const oxs_key_t *key,
00077                     const axis2_env_t *env);
00084         int (AXIS2_CALL *
00085                 get_size)(
00086                     const oxs_key_t *key,
00087                     const axis2_env_t *env);
00094         int (AXIS2_CALL *
00095                 get_usage)(
00096                     const oxs_key_t *key,
00097                     const axis2_env_t *env);
00098         
00099 
00107         axis2_status_t (AXIS2_CALL *
00108                 set_name)(
00109                     oxs_key_t *key,
00110                     const axis2_env_t *env,
00111                     axis2_char_t *name);
00112 
00113 
00121         axis2_status_t (AXIS2_CALL *
00122                 set_usage)(
00123                     oxs_key_t *key,
00124                     const axis2_env_t *env,
00125                     int usage);
00126 
00133         axis2_status_t (AXIS2_CALL *
00134                 free)(
00135                     oxs_key_t *key,
00136                     const axis2_env_t *env
00137                 );
00138 
00149         axis2_status_t (AXIS2_CALL *
00150                 populate)(
00151                     oxs_key_t *key,
00152                     const axis2_env_t *env,
00153                     unsigned char *data,
00154                     axis2_char_t *name,
00155                     int size,
00156                     int usage
00157                 );
00158         
00165         axis2_status_t (AXIS2_CALL *
00166                 read_from_file)(
00167                     oxs_key_t *key,
00168                     const axis2_env_t *env,
00169                     axis2_char_t *file_name
00170                 );
00171         
00178         axis2_status_t (AXIS2_CALL *
00179                 for_algo)(
00180                     oxs_key_t *key,
00181                     const axis2_env_t *env,
00182                     axis2_char_t *key_algo
00183                 );
00184     };
00185 
00186     struct oxs_key
00187     {
00188         oxs_key_ops_t *ops;
00189     };
00190 
00191 AXIS2_EXTERN oxs_key_t *AXIS2_CALL
00192 oxs_key_create(const axis2_env_t *env);
00193 
00194 /*Macros*/
00195 
00196 
00197 #define OXS_KEY_GET_DATA(key,env)\
00198     ((key)->ops->get_data(key,env))
00199 
00200 #define OXS_KEY_GET_NAME(key,env)\
00201     ((key)->ops->get_name(key,env))
00202 
00203 #define OXS_KEY_GET_SIZE(key,env)\
00204     ((key)->ops->get_size(key,env))
00205 
00206 #define OXS_KEY_GET_USAGE(key,env)\
00207     ((key)->ops->get_usage(key,env))
00208 
00209 #define OXS_KEY_SET_NAME(key,env, name)\
00210     ((key)->ops->set_name(key, env, name))
00211 
00212 #define OXS_KEY_SET_USAGE(key,env, usage)\
00213     ((key)->ops->set_usage(key, env, usage))
00214 
00215 #define OXS_KEY_FREE(key,env)\
00216     ((key)->ops->free(key, env))
00217 
00218 #define OXS_KEY_POPULATE(key,env, data, name, size, usage)\
00219     ((key)->ops->populate(key, env, data, name, size, usage))
00220 
00221 #define OXS_KEY_READ_FROM_FILE(key,env, file_name)\
00222     ((key)->ops->read_from_file(key, env, file_name))
00223 
00224 #define OXS_KEY_FOR_ALGO(key,env, key_algo)\
00225     ((key)->ops->for_algo(key, env, key_algo))
00226 
00228 #ifdef __cplusplus
00229 }
00230 #endif
00231 
00232 #endif                          /* OXS_KEY_H */

Generated on Wed Dec 20 20:14:10 2006 for Axis2/C by  doxygen 1.5.1