Reference Guide

28 Chapter 3: Resource Management
RSA BSAFE Crypto-C Micro Edition 3.x to 4.1.4 Migration Guide
Environment Variable
With Crypto-C ME 4.1.4 use of the RSA_CRYPTOCME_HDW_DLL environment
variable is deprecated and it is strongly recommended to store the PKCS #11 driver
location and any other information in an external source, such as a configuration file
or registry variable, and pass the information into Crypto-C ME.
However, applications can continue using the environment variable by adding a
feature to the PKCS #11 provider. The following code examples show using the
RSA_CRYPTOCME_HDW_DLL environment variable for Crypto-C ME 3.x and
Crypto-C ME 4.1.4.
Environment Variable - Crypto-C ME 3.x
int main(int argc, char **argv)
{
int ret;
R_LIB_CTX *lib_ctx = NULL;
R_CR_CTX cr_ctx;
/* Default resource list contains hardware operations */
R_RES_LIST *list = PRODUCT_DEFAULT_RESOURCE_LIST();
ret = R_LIB_CTX_new(list, R_RES_FLAG_DEFAULT, &lib_ctx);
if (R_ERROR_NONE != ret)
goto end;
/* Load the PKCS #11 driver from the environment variable
* and scan for devices
*/
ret = R_CR_CTX_new(lib_ctx, R_RES_FLAG_DEF, &cr_ctx);
if (R_ERROR_NONE != ret)
goto end;
/* Perform cryptographic operations */
end:
R_LIB_CTX_free(lib_ctx);
return 0;
}