1 Star 0 Fork 101

zhuofeng/openssl

forked from src-openEuler/openssl 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Backport-Fix-no-ec-no-sm2-and-no-sm3.patch 2.27 KB
一键复制 编辑 原始数据 按行查看 历史
s_c_c 提交于 2022-06-08 20:13 . Add TLCP feature
From 380cf570be1ded495141e16ceab7afb7f7c57ab7 Mon Sep 17 00:00:00 2001
From: Matt Caswell <matt@openssl.org>
Date: Thu, 28 Feb 2019 13:47:26 +0000
Subject: [PATCH 02/15] Fix no-ec, no-sm2 and no-sm3
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8372)
---
apps/pkeyutl.c | 11 +++++++----
test/recipes/20-test_pkeyutl.t | 9 +++++++--
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/apps/pkeyutl.c b/apps/pkeyutl.c
index bca0464..1d3d57b 100644
--- a/apps/pkeyutl.c
+++ b/apps/pkeyutl.c
@@ -473,14 +473,16 @@ static EVP_PKEY_CTX *init_ctx(const char *kdfalg, int *pkeysize,
}
ctx = EVP_PKEY_CTX_new_id(kdfnid, impl);
} else {
- EC_KEY *eckey = NULL;
- const EC_GROUP *group = NULL;
- int nid;
-
if (pkey == NULL)
goto end;
+
+#ifndef OPENSSL_NO_EC
/* SM2 needs a special treatment */
if (EVP_PKEY_id(pkey) == EVP_PKEY_EC) {
+ EC_KEY *eckey = NULL;
+ const EC_GROUP *group = NULL;
+ int nid;
+
if ((eckey = EVP_PKEY_get0_EC_KEY(pkey)) == NULL
|| (group = EC_KEY_get0_group(eckey)) == NULL
|| (nid = EC_GROUP_get_curve_name(group)) == 0)
@@ -488,6 +490,7 @@ static EVP_PKEY_CTX *init_ctx(const char *kdfalg, int *pkeysize,
if (nid == NID_sm2)
EVP_PKEY_set_alias_type(pkey, EVP_PKEY_SM2);
}
+#endif
*pkeysize = EVP_PKEY_size(pkey);
ctx = EVP_PKEY_CTX_new(pkey, impl);
if (ppkey != NULL)
diff --git a/test/recipes/20-test_pkeyutl.t b/test/recipes/20-test_pkeyutl.t
index a051138..1457530 100644
--- a/test/recipes/20-test_pkeyutl.t
+++ b/test/recipes/20-test_pkeyutl.t
@@ -37,7 +37,12 @@ sub verify
'-digest', 'sm3', '-pkeyopt', 'sm2_id:someid'])));
}
-ok(sign, "Sign a piece of data using SM2");
-ok(verify, "Verify an SM2 signature against a piece of data");
+SKIP: {
+ skip "Skipping tests that require EC, SM2 or SM3", 2
+ if disabled("ec") || disabled("sm2") || disabled("sm3");
+
+ ok(sign, "Sign a piece of data using SM2");
+ ok(verify, "Verify an SM2 signature against a piece of data");
+}
unlink 'signature.sm2';
--
2.20.1 (Apple Git-117)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhuofeng6/openssl.git
git@gitee.com:zhuofeng6/openssl.git
zhuofeng6
openssl
openssl
master

搜索帮助