加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-Avoid-calling-into-provider-with-the-same-iv_len-or-.patch 1.56 KB
一键复制 编辑 原始数据 按行查看 历史
From 6f8002014dda3f45aa864b38b92c2df7611af52e Mon Sep 17 00:00:00 2001
From: Tomas Mraz <tomas@openssl.org>
Date: Fri, 31 Mar 2023 15:46:15 +0200
Subject: [PATCH] Avoid calling into provider with the same iv_len or key_len
Fixes #20625
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20664)
(cherry picked from commit eb52450f5151e8e78743ab05de21a344823316f5)
---
crypto/evp/evp_enc.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/crypto/evp/evp_enc.c b/crypto/evp/evp_enc.c
index e6af8b1c7b..231be1adf4 100644
--- a/crypto/evp/evp_enc.c
+++ b/crypto/evp/evp_enc.c
@@ -1078,6 +1078,11 @@ int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
switch (type) {
case EVP_CTRL_SET_KEY_LENGTH:
+ if (arg < 0)
+ return 0;
+ if (ctx->key_len == arg)
+ /* Skip calling into provider if unchanged. */
+ return 1;
params[0] = OSSL_PARAM_construct_size_t(OSSL_CIPHER_PARAM_KEYLEN, &sz);
ctx->key_len = -1;
break;
@@ -1103,6 +1108,9 @@ int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr)
case EVP_CTRL_AEAD_SET_IVLEN:
if (arg < 0)
return 0;
+ if (ctx->iv_len == arg)
+ /* Skip calling into provider if unchanged. */
+ return 1;
params[0] = OSSL_PARAM_construct_size_t(OSSL_CIPHER_PARAM_IVLEN, &sz);
ctx->iv_len = -1;
break;
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化