Example: AES-128-CTR Encryption API

This example shows the usage of AES-128-CTR APIs:

void *enc_ctx = NULL;
/* Initialize AES-128-CTR encryption context */
if (!jdeSystemEncryptDataAESCTRInit(huser, key_b64, key_b64len, iv_b64,  iv_b64len, &enc_ctx))
{
   jdePrintf(_J("Encryption ctx init failed\n"));
   return 0;
}

/* Encrypt the plain-text and Base64 encode the cipher-text */
if (!jdeSystemEncryptDataAESCTR(huser, enc_ctx,(BYTE *)plaintext, plaintext_len,
                               &b64ciphertext, &b64ciphertext_len))
                             
{
   jdePrintf(_J("Encryption/Base64 encoding failed\n"));
}

/* Free the context */
if (enc_ctx)
{
   jdeSystemFreeDataAESCTR(huser, enc_ctx);
   enc_ctx = NULL;
}