Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
fef1c40b
T
Third Party Openssl
项目概览
OpenHarmony
/
Third Party Openssl
大约 1 年 前同步成功
通知
8
Star
18
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Openssl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fef1c40b
编写于
1月 24, 2011
作者:
D
Dr. Stephen Henson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
New function EC_KEY_set_affine_coordinates() this performs all the
NIST PKV tests.
上级
a428ac47
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
89 addition
and
1 deletion
+89
-1
crypto/ec/ec.h
crypto/ec/ec.h
+11
-0
crypto/ec/ec_err.c
crypto/ec/ec_err.c
+2
-0
crypto/ec/ec_key.c
crypto/ec/ec_key.c
+76
-1
未找到文件。
crypto/ec/ec.h
浏览文件 @
fef1c40b
...
...
@@ -806,6 +806,15 @@ int EC_KEY_generate_key(EC_KEY *key);
*/
int
EC_KEY_check_key
(
const
EC_KEY
*
key
);
/** Sets a public key from affine coordindates performing
* neccessary NIST PKV tests.
* \param key the EC_KEY object
* \param x public key x coordinate
* \param y public key y coordinate
* \return 1 on success and 0 otherwise.
*/
int
EC_KEY_set_public_key_affine_coordinates
(
EC_KEY
*
key
,
BIGNUM
*
x
,
BIGNUM
*
y
);
/********************************************************************/
/* de- and encoding functions for SEC1 ECPrivateKey */
...
...
@@ -1021,6 +1030,7 @@ void ERR_load_EC_strings(void);
#define EC_F_EC_KEY_NEW 182
#define EC_F_EC_KEY_PRINT 180
#define EC_F_EC_KEY_PRINT_FP 181
#define EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES 229
#define EC_F_EC_POINTS_MAKE_AFFINE 136
#define EC_F_EC_POINT_ADD 112
#define EC_F_EC_POINT_CMP 113
...
...
@@ -1066,6 +1076,7 @@ void ERR_load_EC_strings(void);
#define EC_R_ASN1_UNKNOWN_FIELD 116
#define EC_R_BIGNUM_OUT_OF_RANGE 144
#define EC_R_BUFFER_TOO_SMALL 100
#define EC_R_COORDINATES_OUT_OF_RANGE 146
#define EC_R_D2I_ECPKPARAMETERS_FAILURE 117
#define EC_R_DECODE_ERROR 142
#define EC_R_DISCRIMINANT_IS_ZERO 118
...
...
crypto/ec/ec_err.c
浏览文件 @
fef1c40b
...
...
@@ -158,6 +158,7 @@ static ERR_STRING_DATA EC_str_functs[]=
{
ERR_FUNC
(
EC_F_EC_KEY_NEW
),
"EC_KEY_new"
},
{
ERR_FUNC
(
EC_F_EC_KEY_PRINT
),
"EC_KEY_print"
},
{
ERR_FUNC
(
EC_F_EC_KEY_PRINT_FP
),
"EC_KEY_print_fp"
},
{
ERR_FUNC
(
EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES
),
"EC_KEY_set_public_key_affine_coordinates"
},
{
ERR_FUNC
(
EC_F_EC_POINTS_MAKE_AFFINE
),
"EC_POINTs_make_affine"
},
{
ERR_FUNC
(
EC_F_EC_POINT_ADD
),
"EC_POINT_add"
},
{
ERR_FUNC
(
EC_F_EC_POINT_CMP
),
"EC_POINT_cmp"
},
...
...
@@ -206,6 +207,7 @@ static ERR_STRING_DATA EC_str_reasons[]=
{
ERR_REASON
(
EC_R_ASN1_UNKNOWN_FIELD
)
,
"asn1 unknown field"
},
{
ERR_REASON
(
EC_R_BIGNUM_OUT_OF_RANGE
)
,
"bignum out of range"
},
{
ERR_REASON
(
EC_R_BUFFER_TOO_SMALL
)
,
"buffer too small"
},
{
ERR_REASON
(
EC_R_COORDINATES_OUT_OF_RANGE
),
"coordinates out of range"
},
{
ERR_REASON
(
EC_R_D2I_ECPKPARAMETERS_FAILURE
),
"d2i ecpkparameters failure"
},
{
ERR_REASON
(
EC_R_DECODE_ERROR
)
,
"decode error"
},
{
ERR_REASON
(
EC_R_DISCRIMINANT_IS_ZERO
)
,
"discriminant is zero"
},
...
...
crypto/ec/ec_key.c
浏览文件 @
fef1c40b
...
...
@@ -310,7 +310,7 @@ int EC_KEY_check_key(const EC_KEY *eckey)
ECerr
(
EC_F_EC_KEY_CHECK_KEY
,
EC_R_POINT_AT_INFINITY
);
goto
err
;
}
if
((
ctx
=
BN_CTX_new
())
==
NULL
)
goto
err
;
if
((
point
=
EC_POINT_new
(
eckey
->
group
))
==
NULL
)
...
...
@@ -371,6 +371,81 @@ err:
return
(
ok
);
}
int
EC_KEY_set_public_key_affine_coordinates
(
EC_KEY
*
key
,
BIGNUM
*
x
,
BIGNUM
*
y
)
{
BN_CTX
*
ctx
=
NULL
;
BIGNUM
*
tx
,
*
ty
;
EC_POINT
*
point
=
NULL
;
int
ok
=
0
,
tmp_nid
,
is_char_two
=
0
;
if
(
!
key
||
!
key
->
group
||
!
x
||
!
y
)
{
ECerr
(
EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES
,
ERR_R_PASSED_NULL_PARAMETER
);
return
0
;
}
ctx
=
BN_CTX_new
();
if
(
!
ctx
)
goto
err
;
point
=
EC_POINT_new
(
key
->
group
);
if
(
!
point
)
goto
err
;
tmp_nid
=
EC_METHOD_get_field_type
(
EC_GROUP_method_of
(
key
->
group
));
if
(
tmp_nid
==
NID_X9_62_characteristic_two_field
)
is_char_two
=
1
;
tx
=
BN_CTX_get
(
ctx
);
ty
=
BN_CTX_get
(
ctx
);
if
(
is_char_two
)
{
if
(
!
EC_POINT_set_affine_coordinates_GF2m
(
key
->
group
,
point
,
x
,
y
,
ctx
))
goto
err
;
if
(
!
EC_POINT_get_affine_coordinates_GF2m
(
key
->
group
,
point
,
tx
,
ty
,
ctx
))
goto
err
;
}
else
{
if
(
!
EC_POINT_set_affine_coordinates_GFp
(
key
->
group
,
point
,
x
,
y
,
ctx
))
goto
err
;
if
(
!
EC_POINT_get_affine_coordinates_GFp
(
key
->
group
,
point
,
tx
,
ty
,
ctx
))
goto
err
;
}
/* Check if retrieved coordinates match originals: if not values
* are out of range.
*/
if
(
BN_cmp
(
x
,
tx
)
||
BN_cmp
(
y
,
ty
))
{
ECerr
(
EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES
,
EC_R_COORDINATES_OUT_OF_RANGE
);
goto
err
;
}
if
(
!
EC_KEY_set_public_key
(
key
,
point
))
goto
err
;
if
(
EC_KEY_check_key
(
key
)
==
0
)
goto
err
;
ok
=
1
;
err:
if
(
ctx
)
BN_CTX_free
(
ctx
);
if
(
point
)
EC_POINT_free
(
point
);
return
ok
;
}
const
EC_GROUP
*
EC_KEY_get0_group
(
const
EC_KEY
*
key
)
{
return
key
->
group
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录