Reuse EVP_CIPHER_CTX when key data changes #22341
-
Our test is doing the initialization of EVP_CIPHER_CTX once and then we are doing encryption multiple times using same EVP_CIPHER_CTX. We do call EVP_CipherInit() with NULL EVP_CIPHER object, NULL IV, and NULL key, before starting the next round of encryption. This is like a reset of EVP_CIPHER_CTX for next round of encryption. This is working well for us. But now we want to change the key in between our encryption rounds, while using the same EVP_CIPHER_CTX. We tested by passing the new key data into EVP_CipherInit() call before each round of encryption, so that it takes the new key for current encryption. This also seems to be working fine for us. But we wanted to get a confirmation on the recommended way to reuse the same EVP_CIPHER_CTX when key data changes in between the iterations. Is the approach just mentioned the correct one? OR should we follow some other approach ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
That approach is good. |
Beta Was this translation helpful? Give feedback.
That approach is good.