Reference Guide

14 Chapter 2: Changes in MES 4.2
RSA BSAFE Micro Edition Suite 4.4 Migration Guide
Cryptographic API Changes
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 operation.
For compatibility, the library modifies the symmetric key encryption object to include
both operations if neither is set.
The following code examples show creating a symmetric key encryption object for
MES 4.1 and MES 4.2.
Create a Symmetric Key Encryption Object - MES 4.1
int function(R_CR_CTX *ctx, R_SKEY *key, R_ITEM *iv, unsigned
char *data, unsigned int dlen, unsigned char *out, unsigned
int *olen)
{
int ret;
R_CR *ciph = NULL;
ret = R_CR_new(ctx, R_CR_TYPE_CIPHER,
R_CR_ID_AES_128_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, dlen, out, olen);
if (R_ERROR_NONE != ret)
goto end;
end:
R_CR_free(ciph);
return ret;
}