RSA BSAFE Cert-C Micro Edition

The power of PKI for the smallest of devices

cryp_macros.h

Go to the documentation of this file.
00001 /* $Id: cryp_macros.h,v 1.13 2002/07/28 22:36:09 mfscott Exp $ */
00002 /*
00003  * Copyright (C) 1998-2002 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  *
00010  */
00011 
00012 /**
00013  * @file cryp_macros.h
00014  * This file contains the macro functions used to reduce code size.
00015  * Use of these macros removes the call to the public Application Programming
00016  * Interface (API) objects that perform variable validation before executing
00017  * the method table entries.
00018  */
00019 
00020 #ifndef HEADER_COMMON_CRYP_MACROS_H
00021 #define HEADER_COMMON_CRYP_MACROS_H
00022 
00023 #ifdef  __cplusplus
00024 extern "C" {
00025 #endif
00026 
00027 #ifdef NO_R_CR_FUNC
00028 #define R_CR_CTX_free(ctx) \
00029     ctx->method->ctx_free(ctx)
00030 
00031 #define R_CR_new(ctx,alg_type,alg_id,alg_sub,crypto) \
00032     ctx->method->crypto_new(ctx,alg_type,alg_id,alg_sub,crypto)
00033 #define R_CR_dup(crypto,new_crypto) \
00034     crypto->method->crypto_dup(crypto,new_crypto)
00035 #define R_CR_free(crypto) \
00036     crypto->method->crypto_free(crypto)
00037 
00038 #define R_CR_encrypt_init(crypto,key,iv) \
00039     crypto->method->encrypt_init(crypto,key,iv)
00040 #define R_CR_encrypt(crypto,data,data_len,out,out_len) \
00041     crypto->method->encrypt(crypto,data,data_len,out,olen)
00042 #define R_CR_encrypt_update(crypto,data,data_len,out,out_len) \
00043     crypto->method->encrypt_update(crypto,data,data_len,out,olen)
00044 #define R_CR_encrypt_final(crypto,out,out_len) \
00045     crypto->method->encrypt_final(crypto,out,olen)
00046 
00047 #define R_CR_decrypt_init(crypto,key,iv) \
00048     crypto->method->decrypt_init(crypto,key,iv)
00049 #define R_CR_decrypt(crypto,data,data_len,out,out_len) \
00050     crypto->method->decrypt(crypto,data,data_len,out,olen)
00051 #define R_CR_decrypt_update(crypto,data,data_len,out,out_len) \
00052     crypto->method->decrypt_update(crypto,data,data_len,out,olen)
00053 #define R_CR_decrypt_final(crypto,out,out_len) \
00054     crypto->method->decrypt_final(crypto,out,olen)
00055 
00056 #define R_CR_sign_init(crypto,key) \
00057     (crypto->method->sign_init(crypto,key)
00058 #define R_CR_sign(crypto,data,data_len,out,out_len) \
00059     crypto->method->sign(crypto,data,data_len,out,olen)
00060 #define R_CR_sign_update(crypto,data,data_len) \
00061     crypto->method->sign_update(crypto,data,data_len)
00062 #define R_CR_sign_final(crypto,out,out_len) \
00063     crypto->method->sign_final(crypto,out,out_len)
00064 
00065 #define R_CR_verify_init(crypto,key) \
00066     crypto->method->verify_init(crypto,key)
00067 #define R_CR_verify(crypto,data,data_len,signature,sig_len,result) \
00068     crypto->method->verify(crypto,data,data_len,signature,sig_len,result)
00069 #define R_CR_verify_update(crypto,data,data_len) \
00070     crypto->method->verify_update(crypto,data,data_len)
00071 #define R_CR_verify_final(crypto,signature,sig_len,result) \
00072     crypto->method->verify_final(crypto,signature,sig_len,result)
00073 
00074 #define R_CR_asym_encrypt_init(crypto,key) \
00075     crypto->method->asym_encrypt_init(crypto,key)
00076 #define R_CR_asym_encrypt(crypto,data,data_len,out,out_len) \
00077     crypto->method->asym_encrypt(crypto,data,data_len,out,out_len)
00078 #define R_CR_asym_decrypt_init(crypto,key) \
00079     crypto->method->asym_decrypt_init(crypto,key)
00080 #define R_CR_asym_decrypt(crypto,data,data_len,out,out_len) \
00081     crypto->method->asym_decrypt(crypto,data,data_len,out,out_len)
00082 
00083 #define R_CR_digest_init(crypto) \
00084     crypto->method->digest_init(crypto)
00085 #define R_CR_digest(crypto,data,data_len,out,out_len) \
00086     crypto->method->digest(crypto,data,data_len,out,out_len)
00087 #define R_CR_digest_update(crypto,data,data_len) \
00088     crypto->method->digest_update(crypto,data,data_len)
00089 #define R_CR_digest_final(crypto,out,out_len) \
00090     crypto->method->digest_final(crypto,out,out_len)
00091 
00092 #define R_CR_mac_init(crypto,key) \
00093     crypto->method->mac_init(crypto, key)
00094 #define R_CR_mac(crypto,data,data_len,out,out_len) \
00095     crypto->method->mac(crypto,data,data_len,out,out_len)
00096 #define R_CR_mac_update(crypto,data,data_len) \
00097     crypto->method->mac_update(crypto,data,data_len)
00098 #define R_CR_mac_final(crypto,out,out_len) \
00099     crypto->method->mac_final(crypto,out,out_len)
00100 
00101 #define R_CR_verify_mac_init(crypto,key) \
00102     crypto->method->verify_mac_init(crypto, key)
00103 #define R_CR_verify_mac(crypto,data,data_len,mac,mac_len,result) \
00104     crypto->method->verify_mac(crypto,data,data_len,mac,mac_len,result)
00105 #define R_CR_verify_mac_update(crypto,data,data_len) \
00106     crypto->method->verify_mac_update(crypto,data,data_len)
00107 #define R_CR_verify_mac_final(crypto,mac,mac_len,result) \
00108     crypto->method->verify_mac_final(crypto,mac,mac_len,result)
00109 
00110 #define R_CR_key_exchange_init(crypto,params) \
00111     crypto->method->key_exchange_init(crypto,key)
00112 #define R_CR_key_exchange_phase_1(crypto,out,out_len) \
00113     crypto->method->key_exchange_phase_1(crypto,out,out_len)
00114 #define R_CR_key_exchange_phase_2(crypto,data,data_len,out, out_len) \
00115     crypto->method->key_exchange_phase_2(crypto,data,data_len,out,out_len)
00116 
00117 #define R_CR_generate_key_init(crypto) \
00118     crypto->method->generate_key_init(crypto)
00119 #define R_CR_generate_key(crypto,key) \
00120     crypto->method->generate_key(crypto, key)
00121 
00122 #define R_CR_generate_parameter_init(crypto) \
00123     crypto->method->generate_params_init(crypto)
00124 #define R_CR_generate_parameter(crypto,key) \
00125     crypto->method->generate_params(crypto, key)
00126 
00127 #define R_CR_random_seed(crypto,bytes,len) \
00128     crypto->method->random_seed(crypto,bytes,len)
00129 #define R_CR_random_bytes(crypto,dlen,out,out_len) \
00130     crypto->method->gen_rand(crypto,dlen,out,out_len)
00131 
00132 #define R_CR_get_error(crypto,data)                                 \
00133     crypto->method->crypto_get_errinfo(crypto,R_CR_ERRINFO_ERROR,   \
00134         (void *)data)
00135 #define R_CR_get_reason(crypto,data)                                \
00136     crypto->method->crypto_get_errinfo(crypto,R_CR_ERRINFO_REASON,  \
00137         (void *)data)
00138 #define R_CR_get_detail(crypto,data)                                \
00139     crypto->method->crypto_get_errinfo(crypto,R_CR_ERRINFO_DETAIL,  \
00140         (void *)data)
00141 #define R_CR_get_function(crypto,data)                              \
00142     crypto->method->crypto_get_errinfo(crypto,R_CR_ERRINFO_FUNCTION,\
00143         (void *)data)
00144 #define R_CR_get_line(crypto,data)                                  \
00145     crypto->method->crypto_get_errinfo(crypto,R_CR_ERRINFO_LINE,    \
00146         (void *)data)
00147 
00148 #define R_CR_get_file(crypto,data)                  \
00149     crypto->method->crypto_get_errinfo(crypto,      \
00150         R_CR_ERRINFO_FILE,(void **)data)
00151 #define R_CR_get_error_string(crypto,data)          \
00152     crypto->method->crypto_get_errinfo(crypto,      \
00153         R_CR_ERRINFO_ERROR_STRING,(void **)data)
00154 #define R_CR_get_reason_string(crypto,data)         \
00155     crypto->method->crypto_get_errinfo(crypto,      \
00156         R_CR_ERRINFO_REASON_STRING,(void **)data)
00157 #define R_CR_get_detail_string(crypto,data)         \
00158     crypto->method->crypto_get_errinfo(crypto,      \
00159         R_CR_ERRINFO_DETAIL_STRING,(void **)data)
00160 #define R_CR_get_function_string(crypto,data)       \
00161     crypto->method->crypto_get_errinfo(crypto,      \
00162         R_CR_ERRINFO_FUNCTION_STRING,(void **)data)
00163 
00164 #endif /* NO_R_CR_FUNC */
00165 /**
00166  * Macros created by the use of #NO_R_CR_METH_TABLE_CRM
00167  * call directly to the cryptographic method functions without
00168  * the use of the library or resource initialization.
00169  */
00170 #ifdef NO_R_CR_METH_TABLE_CRM
00171 #define NO_R_CR_METH_TABLE
00172 
00173 #include "cryp_meth.h"
00174 
00175 #define R_CR_CTX_new(lib_ctx,flag,crypto_ctx) \
00176     r_crm_ctx_new(lib_ctx,flag,crypto_ctx)
00177 #define R_CR_CTX_free(ctx) \
00178     r_crm_ctx_free(ctx)
00179 
00180 #define R_CR_new(ctx,alg_type,alg_id,alg_sub,crypto) \
00181     r_crm_new(ctx,alg_type,alg_id,alg_sub,crypto)
00182 #define R_CR_dup(crypto,new_crypto) \
00183     r_crm_dup(crypto,new_crypto)
00184 #define R_CR_free(crypto) \
00185     r_crm_free(crypto)
00186 
00187 #define R_CR_encrypt_init(crypto,key,iv) \
00188     r_crm_encrypt_init(crypto,key,iv)
00189 #define R_CR_encrypt(crypto,data,data_len,out,out_len) \
00190     r_crm_cipher(crypto,data,data_len,out,out_len)
00191 #define R_CR_encrypt_update(crypto,data,data_len,out,out_len) \
00192     r_crm_cipher_update(crypto,data,data_len,out,out_len)
00193 #define R_CR_encrypt_final(crypto,out,out_len) \
00194     r_crm_cipher_final(crypto,out,out_len)
00195 
00196 #define R_CR_decrypt_init(crypto,key,iv) \
00197     r_crm_decrypt_init(crypto,key,iv)
00198 #define R_CR_decrypt(crypto,data,data_len,out,out_len) \
00199     r_crm_cipher(crypto,data,data_len,out,out_len)
00200 #define R_CR_decrypt_update(crypto,data,data_len,out,out_len) \
00201     r_crm_cipher_update(crypto,data,data_len,out,out_len)
00202 #define R_CR_decrypt_final(crypto,out,out_len) \
00203     r_crm_cipher_final(crypto,out,out_len)
00204 
00205 #define R_CR_sign_init(crypto,key) \
00206     r_crm_sign_vfy_init(crypto,key)
00207 #define R_CR_sign(crypto,data,data_len,out,out_len) \
00208     r_crm_sign(crypto,data,data_len,out,out_len)
00209 #define R_CR_sign_update(crypto,data,data_len) \
00210     r_crm_sign_update(crypto,data,data_len)
00211 #define R_CR_sign_final(crypto,out,out_len) \
00212     r_crm_sign_final(crypto,out,out_len)
00213 
00214 #define R_CR_verify_init(crypto,key) \
00215     r_crm_sign_vfy_init(crypto,key)
00216 #define R_CR_verify(crypto,data,data_len,signature,sig_len,result) \
00217     r_crm_verify(crypto,data,data_len,signature,sig_len,result)
00218 #define R_CR_verify_update(crypto,data,data_len) \
00219     r_crm_verify_update(crypto,data,data_len)
00220 #define R_CR_verify_final(crypto,signature,sig_len,result) \
00221     r_crm_verify_final(crypto,signature,sig_len,result)
00222 
00223 #define R_CR_asym_encrypt_init(crypto,key) \
00224     r_crm_asym_init(crypto,key)
00225 #define R_CR_asym_encrypt(crypto,data,data_len,out,out_len) \
00226     r_crm_asym_enc(crypto,data,data_len,out,out_len)
00227 #define R_CR_asym_decrypt_init(crypto,key) \
00228     r_crm_asym_init(crypto,key)
00229 #define R_CR_asym_decrypt(crypto,data,data_len,out,out_len) \
00230     r_crm_asym_dec(crypto,data,data_len,out,out_len)
00231 
00232 #define R_CR_digest_init(crypto) \
00233     r_crm_digest_init(crypto)
00234 #define R_CR_digest(crypto,data,data_len,out,out_len) \
00235     r_crm_digest(crypto,data,data_len,out,out_len)
00236 #define R_CR_digest_update(crypto,data,data_len) \
00237     r_crm_digest_update(crypto,data,data_len)
00238 #define R_CR_digest_final(crypto,out,out_len) \
00239     r_crm_digest_final(crypto,out,out_len)
00240 
00241 #define R_CR_mac_init(crypto,key) \
00242     r_crm_mac_init(crypto, key)
00243 #define R_CR_mac(crypto,data,data_len,out,out_len) \
00244     r_crm_mac(crypto,data,data_len,out,out_len)
00245 #define R_CR_mac_update(crypto,data,data_len) \
00246     r_crm_mac_update(crypto,data,data_len)
00247 #define R_CR_mac_final(crypto,out,out_len) \
00248     r_crm_mac_final(crypto,out,out_len)
00249 
00250 #define R_CR_verify_mac_init(crypto,key) \
00251     r_crm_mac_init(crypto, key)
00252 #define R_CR_verify_mac(crypto,data,data_len,mac,mac_len,result) \
00253     r_crm_verify_mac(crypto,data,data_len,mac,mac_len,result)
00254 #define R_CR_verify_mac_update(crypto,data,data_len) \
00255     r_crm_verify_mac_update(crypto,data,data_len)
00256 #define R_CR_verify_mac_final(crypto,mac,mac_len,result) \
00257     r_crm_verify_mac_final(crypto,mac,mac_len,result)
00258 
00259 #define R_CR_key_exchange_init(crypto,key) \
00260     r_crm_ke_init(crypto,key)
00261 #define R_CR_key_exchange_phase_1(crypto,out,out_len) \
00262     r_crm_ke_phase_1(crypto,out,out_len)
00263 #define R_CR_key_exchange_phase_2(crypto,data,data_len,out, out_len) \
00264     r_crm_ke_phase_2(crypto,data,data_len,out,out_len)
00265 
00266 #define R_CR_generate_key_init(crypto) \
00267     r_crm_kgen_init(crypto)
00268 #define R_CR_generate_key(crypto,key) \
00269     r_crm_generate_key(crypto, key)
00270 
00271 #define R_CR_generate_parameter_init(crypto) \
00272     r_crm_pgen_init(crypto)
00273 #define R_CR_generate_parameter(crypto,key) \
00274     r_crm_generate_params(crypto, key)
00275 
00276 #define R_CR_random_seed(crypto,bytes,len) \
00277     r_crm_random_seed(crypto,bytes,len)
00278 #define R_CR_random_bytes(crypto,dlen,out,out_len) \
00279     r_crm_gen_rand(crypto,dlen,out,out_len)
00280 
00281 #define R_CR_get_error(crypto,data)            \
00282     r_crm_get_errinfo(crypto,R_CR_ERRINFO_ERROR,    \
00283         (void *)data)
00284 #define R_CR_get_reason(crypto,data)            \
00285     r_crm_get_errinfo(crypto,R_CR_ERRINFO_REASON,    \
00286         (void *)data)
00287 #define R_CR_get_detail(crypto,data)            \
00288     r_crm_get_errinfo(crypto,R_CR_ERRINFO_DETAIL,    \
00289         (void *)data)
00290 #define R_CR_get_function(crypto,data)            \
00291     r_crm_get_errinfo(crypto,R_CR_ERRINFO_FUNCTION,    \
00292         (void *)data)
00293 #define R_CR_get_line(crypto,data)            \
00294     r_crm_get_errinfo(crypto,R_CR_ERRINFO_LINE,    \
00295         (void *)data)
00296 
00297 #define R_CR_get_file(crypto,data)        \
00298     r_crm_get_errinfo(crypto,        \
00299         R_CR_ERRINFO_FILE,(void **)data)
00300 #define R_CR_get_error_string(crypto,data)    \
00301     r_crm_get_errinfo(crypto,        \
00302         R_CR_ERRINFO_ERROR_STRING,(void **)data)
00303 #define R_CR_get_reason_string(crypto,data)    \
00304     r_crm_get_errinfo(crypto,        \
00305         R_CR_ERRINFO_REASON_STRING,(void **)data)
00306 #define R_CR_get_detail_string(crypto,data)    \
00307     r_crm_get_errinfo(crypto,        \
00308         R_CR_ERRINFO_DETAIL_STRING,(void **)data)
00309 #define R_CR_get_function_string(crypto,data)    \
00310     r_crm_get_errinfo(crypto,        \
00311         R_CR_ERRINFO_FUNCTION_STRING,(void **)data)
00312 
00313 #endif /* NO_R_CR_METH_TABLE_CRM */
00314 
00315 
00316 #ifdef  __cplusplus
00317 }
00318 #endif
00319 #endif /* HEADER_COMMON_CRYP_MACROS_H */
00320 

Copyright (c) 1999-2002 RSA Security Inc. All rights reserved. 061-001005-150-001-000-3768 - 1.5