Hi,
I am trying to add CTR mode support for AES in OpenSSL.
The function provided for CTR mode encryption/decryption for AES in OpenSSL
has following signature:
void AES_ctr128_encrypt(const unsigned char *in, unsigned char *out,
const unsigned long length, const AES_KEY *key,
unsigned char ivec[AES_BLOCK_SIZE],
unsigned char ecount_buf[AES_BLOCK_SIZE],
unsigned int *num)
In this function, the ecount_buf need to be saved for subsequent encryption
and decryption operation using the same CTX object.
According to me, this ecount_buf data can be saved be in two ways:
1. Modify the "struct evp_cipher_ctx_st" by adding a new buffer which also
store this data along with the other data members (like EVP_CIPHER, ENGINE,
buf, iv, oiv, cipher_data, ….etc.)
2. Use already existing buffer final from "struct
evp_cipher_ctx_st", since there is no use of final buffer in CTR mode.
I am not able to figure out that the above methods are correct or not?
If they are not correct then which is the correct way to implement it?
If they are correct then which one is more appropriate?
If anybody has already implemented it, please share the info with me.
Thanks in advance
Regards,
Rakesh
Explore and discover exciting holidays and getaways with Yahoo! India
Travel http://in.travel.yahoo.com/