/* This function initializes a AES encryption algorithm, i.e. fills the psCipherContext_t structure pointed to by ctx with necessary data.  */
int tls_crypto_aes_init(psCipherContext_t *ctx, const unsigned char *IV, const unsigned char *key, u32 keylen, CRYPTO_MODE cbc)
/* This function initializes a AES encryption algorithm, i.e. fills the psCipherContext_t structure pointed to by ctx with necessary data.  */
int tls_crypto_aes_init(psCipherContext_t *ctx, const unsigned char *IV, const unsigned char *key, u32 keylen, CRYPTO_MODE cbc)
{
    int x = 0;
    if (keylen != 16)
        return ERR_FAILURE;
    memcpy(ctx->aes.key.skey, key, keylen);
    ctx->aes.key.type = cbc;
    ctx->aes.key.rounds = 16;
	if(IV)
	{
	    for (x = 0; x < ctx->aes.key.rounds; x++)
	    {
	        ctx->aes.IV[x] = IV[x];
	    }
	}
    return ERR_CRY_OK;
}