提交 f6b94279 编写于 作者: A Andy Polyakov

evp/evp_enc.c: allow EVP_CIPHER.ctx_size to be 0.

In such case it would be EVP_CIPHER.cleanup's reponsibility to wipe
EVP_CIPHEX_CTX.cipher_data.
Reviewed-by: NRichard Levitte <levitte@openssl.org>
上级 72bb2f64
......@@ -105,10 +105,8 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
* previous handle, re-querying for an ENGINE, and having a
* reinitialisation, when it may all be unecessary.
*/
if (ctx->engine && ctx->cipher && (!cipher ||
(cipher
&& (cipher->nid ==
ctx->cipher->nid))))
if (ctx->engine && ctx->cipher
&& (!cipher || (cipher && (cipher->nid == ctx->cipher->nid))))
goto skip_to_init;
#endif
if (cipher) {
......@@ -531,7 +529,7 @@ int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *c)
if (c->cipher->cleanup && !c->cipher->cleanup(c))
return 0;
/* Cleanse cipher context data */
if (c->cipher_data)
if (c->cipher_data && c->cipher->ctx_size)
OPENSSL_cleanse(c->cipher_data, c->cipher->ctx_size);
}
OPENSSL_free(c->cipher_data);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册