Reference Guide

44 Chapter 5: Cryptographic API Changes
RSA BSAFE Crypto-C Micro Edition 3.x to 4.1.4 Migration Guide
Symmetric Key Encryption Cryptographic Objects
Creation of cryptographic objects for symmetric key encryption now expects one or
both of the
R_CR_SUB_DECRYPT and R_CR_SUB_ENCRYPT sub-identifiers to be
specified explicitly to identify the type of operations to be performed. During creation
of the cryptographic object, all requested operations are checked for availability in the
resource list. There is therefore less overhead if only specifying a single operations.
For compatibility, the library modifies the symmetric key object to include both
operations if neither is set.
The following code examples show creating a symmetric key object for
Crypto-C ME 3.x and Crypto-C ME 4.1.4.
Creating a Symmetric Key Object - Crypto-C ME 3.x
int function(R_CR_CTX *ctx, R_SKEY *key, R_ITEM *iv)
{
int ret;
R_CR *ciph = NULL;
ret = R_CR_new(crypto_ctx, R_CR_TYPE_CIPHER,
R_CR_ID_AES128_CBC, 0, &ciph);
if (R_ERROR_NONE != ret)
goto end;
ret = R_CR_encrypt_init(ciph, key, iv);
if (R_ERROR_NONE != ret)
goto end;
ret = R_CR_encrypt(ciph, data, sizeof(data), out, &olen);
if (R_ERROR_NONE != ret)
goto end;
end:
R_CR_free(rng);
return ret;
}