| RSA BSAFE Micro Edition Suite |
Streamlined security for mobile and embedded devices |
 
![]() |
00001 /* $Id: r_lib.h,v 1.80 2005/07/29 05:16:53 itaylor Exp $ */
00002 /*
00003 * Copyright (C) 1998-2003 RSA Security Inc. All rights reserved.
00004 *
00005 * This work contains proprietary information of RSA Security.
00006 * Distribution is limited to authorized licensees of RSA
00007 * Security. Any unauthorized reproduction, distribution or
00008 * modification of this work is strictly prohibited.
00009 */
00016 #ifndef HEADER_COMMON_R_LIB_H
00017 #define HEADER_COMMON_R_LIB_H
00018
00019 #ifdef __cplusplus
00020 extern "C" {
00021 #endif
00022
00023 #if defined(SMALL_CODE_SIZE) && !defined(Rm_LIB_CTX_DIRECT)
00024 #define Rm_LIB_CTX_DIRECT
00025 #endif
00026
00027 #if defined(Rm_LIB_CTX_TABLE) && defined(Rm_LIB_CTX_DIRECT)
00028 #undef Rm_LIB_CTX_TABLE
00029 #endif
00030
00031 #ifdef Rm_LIB_CTX_FULL
00032
00033 #ifdef Rm_LIB_CTX_TABLE
00034 #undef Rm_LIB_CTX_TABLE
00035 #endif /* Rm_LIB_CTX_TABLE */
00036
00037 #ifdef Rm_LIB_CTX_DIRECT
00038 #undef Rm_LIB_CTX_DIRECT
00039 #endif /* Rm_LIB_CTX_DIRECT */
00040
00041 #endif /* Rm_LIB_CTX_FULL */
00042
00043 #include "r_com.h"
00044 #include "r_res.h"
00045 #include "r_flg.h"
00046 #include "r_strtbl.h"
00047
00048 #ifndef NO_BIO
00049 #include "bio.h"
00050 #endif
00051
00076 #ifndef HEADER_COMMON_R_LIB_CTX_TYPEDEF_DEF
00077 #define HEADER_COMMON_R_LIB_CTX_TYPEDEF_DEF
00078
00086 typedef struct r_lib_ctx_st R_LIB_CTX;
00087 #endif
00088
00093 typedef struct r_lib_method_st R_LIB_METHOD;
00094
00095 /* The library context debug structure which is used to define the type of
00096 * debugging required and the location where the debug information is sent.
00097 */
00098 typedef struct r_lib_debug_st
00099 {
00100 R_FLG dbg_flg;
00101 #ifndef NO_BIO
00102 BIO *bio;
00103 #else
00104 void *bio;
00105 #endif
00106 } R_LIB_DEBUG;
00107
00108 #define R_DBG_SET(bit_num, dbg_prt) \
00109 (((dbg_prt) != NULL) ? R_FLG_SET((bit_num), (&((dbg_prt)->dbg_flg))) : 0)
00110 #define R_DBG_ON(bit_num, dbg_prt) \
00111 (((dbg_prt) != NULL) ? R_FLG_ISSET((bit_num), (&((dbg_prt)->dbg_flg))) : 0)
00112 #define R_DBG_CLR(bit_num, dbg_prt) \
00113 (((dbg_prt) != NULL) ? R_FLG_CLR((bit_num), (&((dbg_prt)->dbg_flg))) : 0)
00114 #define R_DBG_SET_ALL(dbg_prt) \
00115 (((dbg_prt) != NULL) ? R_FLG_SET_ALL((&((dbg_prt)->dbg_flg))) : 0)
00116 #define R_DBG_ZERO(dbg_prt) \
00117 (((dbg_prt) != NULL) ? R_FLG_ZERO((&((dbg_prt)->dbg_flg))) : 0)
00118
00119 /* The R_LIB_DEBUG control defines */
00120 #define R_LIB_DEBUG_GET 1
00121 #define R_LIB_DEBUG_SET 2
00122
00123 /* The library context feature structure which is used to store the state of
00124 * the library features.
00125 */
00126 typedef struct r_lib_feat_st
00127 {
00128 unsigned long feature;
00129 } R_LIB_FEAT;
00130
00131 /* Feature hash defines */
00132 #define R_LIB_FEATURE_LOCKING 0x00000001L
00133
00134 /* The R_LIB_FEAT control defines */
00135 #define R_LIB_FEAT_SET 1
00136 #define R_LIB_FEAT_GET 2
00137 #define R_LIB_FEAT_DISABLE 3
00138 #define R_LIB_FEAT_ENABLE 4
00139 #define R_LIB_FEAT_IS_ENABLED 5
00140
00191 #define R_LIB_CTX_INFO_ID_RESOURCE_LIST 0x01
00192
00196 #define R_LIB_CTX_INFO_ID_MODE 0x02
00197
00201 #define R_LIB_CTX_INFO_ID_HW_CTX 0x03
00202
00203 /* the old name for the hardware context info id */
00204 #define R_LIB_CTX_INFO_HDW_CTX R_LIB_CTX_INFO_ID_HW_CTX
00205
00209 #define R_LIB_CTX_FIPS140_MODE 0x01
00210
00214 #define R_LIB_CTX_STANDARD_MODE 0x02
00215
00219 #define R_LIB_CTX_HARDWARE_MODE 0x04
00220
00224 #define R_LIB_CTX_SOFTWARE_MODE 0x08
00225
00243 /* Retrieve string defines */
00244 #define R_LIB_CTX_get_error_string(lib_ctx, mod_id, code) \
00245 R_LIB_CTX_get_string((lib_ctx), (mod_id), R_RES_SUB_ID_ERROR_STRINGS, \
00246 (code))
00247 #define R_LIB_CTX_get_reason_string(lib_ctx, mod_id, code) \
00248 R_LIB_CTX_get_string((lib_ctx), (mod_id), R_RES_SUB_ID_REASON_STRINGS, \
00249 (code))
00250 #define R_LIB_CTX_get_detail_string(lib_ctx, mod_id, code) \
00251 R_LIB_CTX_get_string((lib_ctx), (mod_id), R_RES_SUB_ID_DETAIL_STRINGS, \
00252 (code))
00253 #define R_LIB_CTX_get_function_string(lib_ctx, mod_id, code) \
00254 R_LIB_CTX_get_string((lib_ctx), (mod_id), R_RES_SUB_ID_FUNCTION_STRINGS, \
00255 (code))
00256
00257 #define R_LIB_CTX_load_module(lib_ctx, mod_id, impl_id, sub_id, \
00258 flag, ptr, type, name) \
00259 (*type) = R_RES_FLAG_GLOBAL; \
00260 if (R_LIB_CTX_get_module((lib_ctx), (mod_id), (impl_id), (sub_id), \
00261 (flag), (void **)(ptr)) != R_ERROR_NONE) \
00262 { \
00263 name((lib_ctx), (flag), (ptr)); \
00264 (*type) = R_RES_FLAG_PRIVATE; \
00265 }
00266
00267 #define R_LIB_CTX_load_typed_module(lib_ctx, mod_id, impl_id, sub_id, \
00268 flag, ptr, type, name) \
00269 (*type) = R_RES_FLAG_GLOBAL; \
00270 if (R_LIB_CTX_get_module((lib_ctx), (mod_id), (impl_id), (sub_id), \
00271 (flag), (void **)(ptr)) != R_ERROR_NONE) \
00272 { \
00273 name((lib_ctx), (flag), (sub_id), (ptr)); \
00274 (*type) = R_RES_FLAG_PRIVATE; \
00275 }
00276
00277 #define R_LIB_CTX_unload_module(lib_ctx, ptr, type, name) \
00278 if (type == R_RES_FLAG_PRIVATE) \
00279 { \
00280 name(ptr); \
00281 }
00282
00283 int R_CDECL R_LIB_CTX_new(R_RES_LIST *r_list, R_RES_FLAG flag, R_LIB_CTX **lib_ctx);
00284 int R_CDECL R_LIB_CTX_free(R_LIB_CTX *lib_ctx);
00285 int R_CDECL R_LIB_CTX_dup(R_LIB_CTX *lib_ctx, R_RES_FLAG flag, R_LIB_CTX **res_ctx);
00286 int R_CDECL R_LIB_CTX_set_info(R_LIB_CTX *lib_ctx, int info_id, void *value);
00287 int R_CDECL R_LIB_CTX_get_info(R_LIB_CTX *lib_ctx, int info_id, void *value);
00288
00289 int R_CDECL R_LIB_CTX_module_setup(R_LIB_CTX *lib_ctx, int mod_id, int imp_id,
00290 int sub_id, R_RES_FLAG flag, void *rgen);
00291
00292 R_RES_LIST * R_CDECL R_LIB_CTX_get_resource_list(R_LIB_CTX *lib_ctx);
00293
00294 char * R_CDECL R_LIB_CTX_get_string(R_LIB_CTX *lib_ctx, int mod_id, int table_id,
00295 int err_code);
00296
00297 #if defined(Rm_LIB_CTX_TABLE) || defined(Rm_LIB_CTX_DIRECT)
00298
00299 #include "rx_lib.h"
00300
00301 #endif /* defined(Rm_LIB_CTX_TABLE) || defined(Rm_LIB_CTX_DIRECT) */
00302
00303 #if !defined(Rm_LIB_CTX_TABLE) && !defined(Rm_LIB_CTX_DIRECT)
00304
00305 int R_CDECL R_LIB_CTX_get_resource(R_LIB_CTX *res_ctx, int mod_id, int impl_id,
00306 int sub_id, R_RES_FLAG flag, int res_type, void **data);
00307 int R_CDECL R_LIB_CTX_get_module(R_LIB_CTX *res_ctx, int mod_id, int impl_id,
00308 int sub_id, R_RES_FLAG flag, void **mod);
00309 int R_CDECL R_LIB_CTX_get_module_data(R_LIB_CTX *lib_ctx, int mod_id, void **impl_data);
00310
00311 int R_CDECL R_LIB_CTX_set_features(R_LIB_CTX *lib_ctx, int impl_id,
00312 R_LIB_FEAT *features);
00313 int R_CDECL R_LIB_CTX_get_features(R_LIB_CTX *lib_ctx, int impl_id,
00314 R_LIB_FEAT *features);
00315 int R_CDECL R_LIB_CTX_reset_features(R_LIB_CTX *lib_ctx, int impl_id);
00316 int R_CDECL R_LIB_CTX_feature_disable(R_LIB_CTX *lib_ctx, int impl_id,
00317 R_LIB_FEAT *feature);
00318 int R_CDECL R_LIB_CTX_feature_enable(R_LIB_CTX *lib_ctx, int impl_id,
00319 R_LIB_FEAT *feature);
00320 int R_CDECL R_LIB_CTX_is_feature_enabled(R_LIB_CTX *lib_ctx, int impl_id,
00321 R_LIB_FEAT *feature);
00322
00323 int R_CDECL R_LIB_CTX_get_lib_debug_data(R_LIB_CTX *lib_ctx, R_LIB_DEBUG **data);
00324 int R_CDECL R_LIB_CTX_set_lib_debug_data(R_LIB_CTX *lib_ctx, R_LIB_DEBUG *data);
00325
00326 #endif /* !defined(Rm_LIB_CTX_TABLE) && !defined(Rm_LIB_CTX_DIRECT) */
00327
00334 #ifdef __cplusplus
00335 }
00336 #endif
00337
00338 #endif /* HEADER_COMMON_R_LIB_H */