Topic: AES in counter mode

I'm porting my code from openssl to wolfssl.
In my code I use AES in counter mode to encrypt data which arrives in parts and send it to the receiver.
In my code I use EVP_EncryptInit() to set the key and any time the data arrive, I encrypt it
with EVP_EncryptUpdate().
I never call EVP_EncryptFinal() since it will affect the context.
In wolfssl there is no compatibility for EVP_EncryptInit() but there is EVP_CipherInit(), so I intend to use EVP_CipherInit().
My difficulty comes down to EVP_EncryptUpdate().
Is their anyway I can achieve my objective since there is no alternative for EVP_EncryptUpdate()?

EDIT:
Further search through the source reveals that  CyaSSL_EVP_Cipher [EVP_Cipher] is available
which i can use by passing CyaSSL_EVP_aes_128_ctr to select 128 counter mode.
I have realized that in counter mode, CyaSSL_EVP_Cipher only call AesCtrEncrypt()
This brings me back to the initial issue of context.
AesCtrEncrypt() does not accept context structure, hence will not update the context.

Thank you

Share

Re: AES in counter mode

Hi Frank,

Thanks for looking at using wolfSSL embedded SSL.  Do you mind if I ask what kind of application you are working on?

Do you need to use the OpenSSL API, or would it work to use the native wolfSSL/wolfCrypt API?

As you noted, wolfSSL provides AesSetKeyDirect() and AesCtrEncrypt() to be used for AES-CTR encryption.  The AesCtrEncrypt() function looks like:

void AesCtrEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)

aes is a pointer to the Aes object (or "context") being used for the given AES encrypt operation.  in is a pointer to your input data, of size sz.  The AES-CTR encrypted data is then placed into the buffer pointed to by out.

Although wolfSSL does have the wolfSSL_EVP_aes_128_ctr() function in its OpenSSL compatibility layer, it is currently just a stub.

Best Regards,
Chris