Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
15994b03
T
Third Party Openssl
项目概览
OpenHarmony
/
Third Party Openssl
接近 2 年 前同步成功
通知
12
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看板
提交
15994b03
编写于
11月 23, 2002
作者:
B
Bodo Möller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename some functions to improve consistency
Submitted by: Sheueling Chang
上级
922fa76e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
19 addition
and
20 deletion
+19
-20
crypto/ec/ec2_mult.c
crypto/ec/ec2_mult.c
+15
-16
crypto/ec/ec2_smpl.c
crypto/ec/ec2_smpl.c
+2
-2
crypto/ec/ec_lcl.h
crypto/ec/ec_lcl.h
+2
-2
未找到文件。
crypto/ec/ec2_mult.c
浏览文件 @
15994b03
...
...
@@ -79,7 +79,7 @@
* GF(2^m) without precomputation".
* modified to not require precomputation of c=b^{2^{m-1}}.
*/
static
int
Mdouble
(
const
EC_GROUP
*
group
,
BIGNUM
*
x
,
BIGNUM
*
z
,
BN_CTX
*
ctx
)
static
int
gf2m_
Mdouble
(
const
EC_GROUP
*
group
,
BIGNUM
*
x
,
BIGNUM
*
z
,
BN_CTX
*
ctx
)
{
BIGNUM
*
t1
;
int
ret
=
0
;
...
...
@@ -110,7 +110,7 @@ static int Mdouble(const EC_GROUP *group, BIGNUM *x, BIGNUM *z, BN_CTX *ctx)
* Lopex, J. and Dahab, R. "Fast multiplication on elliptic curves over
* GF(2^m) without precomputation".
*/
static
int
Madd
(
const
EC_GROUP
*
group
,
const
BIGNUM
*
x
,
BIGNUM
*
x1
,
BIGNUM
*
z1
,
static
int
gf2m_
Madd
(
const
EC_GROUP
*
group
,
const
BIGNUM
*
x
,
BIGNUM
*
x1
,
BIGNUM
*
z1
,
const
BIGNUM
*
x2
,
const
BIGNUM
*
z2
,
BN_CTX
*
ctx
)
{
BIGNUM
*
t1
,
*
t2
;
...
...
@@ -138,9 +138,8 @@ static int Madd(const EC_GROUP *group, const BIGNUM *x, BIGNUM *x1, BIGNUM *z1,
return
ret
;
}
/* Compute the affine coordinates x2, y2=z2 for the point (x1/z1) and (x2/x2) in
* Montgomery projective coordinates.
* Uses algorithm Mxy in appendix of
/* Compute the x, y affine coordinates from the point (x1, z1) (x2, z2)
* using Montgomery point multiplication algorithm Mxy() in appendix of
* Lopex, J. and Dahab, R. "Fast multiplication on elliptic curves over
* GF(2^m) without precomputation".
* Returns:
...
...
@@ -148,7 +147,7 @@ static int Madd(const EC_GROUP *group, const BIGNUM *x, BIGNUM *x1, BIGNUM *z1,
* 1 if return value should be the point at infinity
* 2 otherwise
*/
static
int
Mxy
(
const
EC_GROUP
*
group
,
const
BIGNUM
*
x
,
const
BIGNUM
*
y
,
BIGNUM
*
x1
,
static
int
gf2m_
Mxy
(
const
EC_GROUP
*
group
,
const
BIGNUM
*
x
,
const
BIGNUM
*
y
,
BIGNUM
*
x1
,
BIGNUM
*
z1
,
BIGNUM
*
x2
,
BIGNUM
*
z2
,
BN_CTX
*
ctx
)
{
BIGNUM
*
t3
,
*
t4
,
*
t5
;
...
...
@@ -213,7 +212,7 @@ static int Mxy(const EC_GROUP *group, const BIGNUM *x, const BIGNUM *y, BIGNUM *
* Lopex, J. and Dahab, R. "Fast multiplication on elliptic curves over
* GF(2^m) without precomputation".
*/
static
int
point_multiply
(
const
EC_GROUP
*
group
,
EC_POINT
*
r
,
const
BIGNUM
*
scalar
,
static
int
ec_GF2m_montgomery_
point_multiply
(
const
EC_GROUP
*
group
,
EC_POINT
*
r
,
const
BIGNUM
*
scalar
,
const
EC_POINT
*
point
,
BN_CTX
*
ctx
)
{
BIGNUM
*
x1
,
*
x2
,
*
z1
,
*
z2
;
...
...
@@ -269,13 +268,13 @@ static int point_multiply(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scal
{
if
(
scalar
->
d
[
i
]
&
mask
)
{
if
(
!
Madd
(
group
,
&
point
->
X
,
x1
,
z1
,
x2
,
z2
,
ctx
))
goto
err
;
if
(
!
Mdouble
(
group
,
x2
,
z2
,
ctx
))
goto
err
;
if
(
!
gf2m_
Madd
(
group
,
&
point
->
X
,
x1
,
z1
,
x2
,
z2
,
ctx
))
goto
err
;
if
(
!
gf2m_
Mdouble
(
group
,
x2
,
z2
,
ctx
))
goto
err
;
}
else
{
if
(
!
Madd
(
group
,
&
point
->
X
,
x2
,
z2
,
x1
,
z1
,
ctx
))
goto
err
;
if
(
!
Mdouble
(
group
,
x1
,
z1
,
ctx
))
goto
err
;
if
(
!
gf2m_
Madd
(
group
,
&
point
->
X
,
x2
,
z2
,
x1
,
z1
,
ctx
))
goto
err
;
if
(
!
gf2m_
Mdouble
(
group
,
x1
,
z1
,
ctx
))
goto
err
;
}
mask
>>=
1
;
}
...
...
@@ -284,7 +283,7 @@ static int point_multiply(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scal
}
/* convert out of "projective" coordinates */
i
=
Mxy
(
group
,
&
point
->
X
,
&
point
->
Y
,
x1
,
z1
,
x2
,
z2
,
ctx
);
i
=
gf2m_
Mxy
(
group
,
&
point
->
X
,
&
point
->
Y
,
x1
,
z1
,
x2
,
z2
,
ctx
);
if
(
i
==
0
)
goto
err
;
else
if
(
i
==
1
)
{
...
...
@@ -312,7 +311,7 @@ static int point_multiply(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scal
* scalar*group->generator + scalars[0]*points[0] + ... + scalars[num-1]*points[num-1]
* gracefully ignoring NULL scalar values.
*/
int
ec_GF2m_
mont
_mul
(
const
EC_GROUP
*
group
,
EC_POINT
*
r
,
const
BIGNUM
*
scalar
,
int
ec_GF2m_
simple
_mul
(
const
EC_GROUP
*
group
,
EC_POINT
*
r
,
const
BIGNUM
*
scalar
,
size_t
num
,
const
EC_POINT
*
points
[],
const
BIGNUM
*
scalars
[],
BN_CTX
*
ctx
)
{
BN_CTX
*
new_ctx
=
NULL
;
...
...
@@ -341,7 +340,7 @@ int ec_GF2m_mont_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
if
(
scalar
)
{
if
(
!
point_multiply
(
group
,
p
,
scalar
,
group
->
generator
,
ctx
))
goto
err
;
if
(
!
ec_GF2m_montgomery_
point_multiply
(
group
,
p
,
scalar
,
group
->
generator
,
ctx
))
goto
err
;
if
(
BN_get_sign
(
scalar
))
if
(
!
group
->
meth
->
invert
(
group
,
p
,
ctx
))
goto
err
;
if
(
!
group
->
meth
->
add
(
group
,
r
,
r
,
p
,
ctx
))
goto
err
;
...
...
@@ -349,7 +348,7 @@ int ec_GF2m_mont_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
for
(
i
=
0
;
i
<
num
;
i
++
)
{
if
(
!
point_multiply
(
group
,
p
,
scalars
[
i
],
points
[
i
],
ctx
))
goto
err
;
if
(
!
ec_GF2m_montgomery_
point_multiply
(
group
,
p
,
scalars
[
i
],
points
[
i
],
ctx
))
goto
err
;
if
(
BN_get_sign
(
scalars
[
i
]))
if
(
!
group
->
meth
->
invert
(
group
,
p
,
ctx
))
goto
err
;
if
(
!
group
->
meth
->
add
(
group
,
r
,
r
,
p
,
ctx
))
goto
err
;
...
...
@@ -366,7 +365,7 @@ int ec_GF2m_mont_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
/* Precomputation for point multiplication. */
int
ec_GF2m_
mont_
precompute_mult
(
EC_GROUP
*
group
,
BN_CTX
*
ctx
)
int
ec_GF2m_precompute_mult
(
EC_GROUP
*
group
,
BN_CTX
*
ctx
)
{
/* There is no precomputation to do for Montgomery scalar multiplication but
* since this implementation falls back to the wNAF multiplication for more than
...
...
crypto/ec/ec2_smpl.c
浏览文件 @
15994b03
...
...
@@ -99,8 +99,8 @@ const EC_METHOD *EC_GF2m_simple_method(void)
ec_GF2m_simple_add
,
ec_GF2m_simple_dbl
,
ec_GF2m_simple_invert
,
ec_GF2m_
mont
_mul
,
ec_GF2m_
mont_
precompute_mult
,
ec_GF2m_
simple
_mul
,
ec_GF2m_precompute_mult
,
ec_GF2m_simple_is_at_infinity
,
ec_GF2m_simple_is_on_curve
,
ec_GF2m_simple_cmp
,
...
...
crypto/ec/ec_lcl.h
浏览文件 @
15994b03
...
...
@@ -360,6 +360,6 @@ int ec_GF2m_simple_field_div(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, const
/* method functions in ec2_mult.c */
int
ec_GF2m_
mont
_mul
(
const
EC_GROUP
*
group
,
EC_POINT
*
r
,
const
BIGNUM
*
scalar
,
int
ec_GF2m_
simple
_mul
(
const
EC_GROUP
*
group
,
EC_POINT
*
r
,
const
BIGNUM
*
scalar
,
size_t
num
,
const
EC_POINT
*
points
[],
const
BIGNUM
*
scalars
[],
BN_CTX
*
);
int
ec_GF2m_
mont_
precompute_mult
(
EC_GROUP
*
group
,
BN_CTX
*
ctx
);
int
ec_GF2m_precompute_mult
(
EC_GROUP
*
group
,
BN_CTX
*
ctx
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录