Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
btwise
openssl
提交
91e7bcc2
O
openssl
项目概览
btwise
/
openssl
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
openssl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
91e7bcc2
编写于
12月 09, 2015
作者:
D
Dr. Stephen Henson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use NULL comparison
Reviewed-by:
N
Richard Levitte
<
levitte@openssl.org
>
上级
7bb75a5d
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
41 addition
and
39 deletion
+41
-39
crypto/ec/ec_asn1.c
crypto/ec/ec_asn1.c
+2
-2
crypto/ec/ec_key.c
crypto/ec/ec_key.c
+24
-21
crypto/ec/ec_kmeth.c
crypto/ec/ec_kmeth.c
+6
-6
crypto/ec/ecdsa_ossl.c
crypto/ec/ecdsa_ossl.c
+2
-2
crypto/ec/ecdsa_sign.c
crypto/ec/ecdsa_sign.c
+3
-3
crypto/ec/ecdsa_vrf.c
crypto/ec/ecdsa_vrf.c
+2
-3
crypto/engine/tb_eckey.c
crypto/engine/tb_eckey.c
+2
-2
未找到文件。
crypto/ec/ec_asn1.c
浏览文件 @
91e7bcc2
...
...
@@ -1314,9 +1314,9 @@ IMPLEMENT_ASN1_FUNCTIONS_const(ECDSA_SIG)
void
ECDSA_SIG_get0
(
BIGNUM
**
pr
,
BIGNUM
**
ps
,
ECDSA_SIG
*
sig
)
{
if
(
pr
)
if
(
pr
!=
NULL
)
*
pr
=
sig
->
r
;
if
(
ps
)
if
(
ps
!=
NULL
)
*
ps
=
sig
->
s
;
}
...
...
crypto/ec/ec_key.c
浏览文件 @
91e7bcc2
...
...
@@ -84,7 +84,8 @@ EC_KEY *EC_KEY_new_by_curve_name(int nid)
EC_KEY_free
(
ret
);
return
NULL
;
}
if
(
ret
->
meth
->
set_group
&&
ret
->
meth
->
set_group
(
ret
,
ret
->
group
)
==
0
)
{
if
(
ret
->
meth
->
set_group
!=
NULL
&&
ret
->
meth
->
set_group
(
ret
,
ret
->
group
)
==
0
)
{
EC_KEY_free
(
ret
);
return
NULL
;
}
...
...
@@ -111,11 +112,11 @@ void EC_KEY_free(EC_KEY *r)
}
#endif
if
(
r
->
meth
->
finish
)
if
(
r
->
meth
->
finish
!=
NULL
)
r
->
meth
->
finish
(
r
);
#ifndef OPENSSL_NO_ENGINE
if
(
r
->
engine
)
if
(
r
->
engine
!=
NULL
)
ENGINE_finish
(
r
->
engine
);
#endif
...
...
@@ -137,16 +138,16 @@ EC_KEY *EC_KEY_copy(EC_KEY *dest, const EC_KEY *src)
return
NULL
;
}
if
(
src
->
meth
!=
dest
->
meth
)
{
if
(
dest
->
meth
->
finish
)
if
(
dest
->
meth
->
finish
!=
NULL
)
dest
->
meth
->
finish
(
dest
);
#ifndef OPENSSL_NO_ENGINE
if
(
dest
->
engine
&&
ENGINE_finish
(
dest
->
engine
)
==
0
)
if
(
dest
->
engine
!=
NULL
&&
ENGINE_finish
(
dest
->
engine
)
==
0
)
return
0
;
dest
->
engine
=
NULL
;
#endif
}
/* copy the parameters */
if
(
src
->
group
)
{
if
(
src
->
group
!=
NULL
)
{
const
EC_METHOD
*
meth
=
EC_GROUP_method_of
(
src
->
group
);
/* clear the old group */
EC_GROUP_free
(
dest
->
group
);
...
...
@@ -157,7 +158,7 @@ EC_KEY *EC_KEY_copy(EC_KEY *dest, const EC_KEY *src)
return
NULL
;
}
/* copy the public key */
if
(
src
->
pub_key
&&
src
->
group
)
{
if
(
src
->
pub_key
!=
NULL
&&
src
->
group
!=
NULL
)
{
EC_POINT_free
(
dest
->
pub_key
);
dest
->
pub_key
=
EC_POINT_new
(
src
->
group
);
if
(
dest
->
pub_key
==
NULL
)
...
...
@@ -166,7 +167,7 @@ EC_KEY *EC_KEY_copy(EC_KEY *dest, const EC_KEY *src)
return
NULL
;
}
/* copy the private key */
if
(
src
->
priv_key
)
{
if
(
src
->
priv_key
!=
NULL
)
{
if
(
dest
->
priv_key
==
NULL
)
{
dest
->
priv_key
=
BN_new
();
if
(
dest
->
priv_key
==
NULL
)
...
...
@@ -186,7 +187,7 @@ EC_KEY *EC_KEY_copy(EC_KEY *dest, const EC_KEY *src)
if
(
!
EC_EX_DATA_set_data
(
&
dest
->
method_data
,
t
,
d
->
dup_func
,
d
->
free_func
,
d
->
clear_free_func
))
return
0
;
return
NULL
;
}
/* copy the rest */
...
...
@@ -197,15 +198,15 @@ EC_KEY *EC_KEY_copy(EC_KEY *dest, const EC_KEY *src)
if
(
src
->
meth
!=
dest
->
meth
)
{
#ifndef OPENSSL_NO_ENGINE
if
(
src
->
engine
&&
ENGINE_init
(
src
->
engine
)
==
0
)
return
0
;
if
(
src
->
engine
!=
NULL
&&
ENGINE_init
(
src
->
engine
)
==
0
)
return
NULL
;
dest
->
engine
=
src
->
engine
;
#endif
dest
->
meth
=
src
->
meth
;
}
if
(
src
->
meth
->
copy
&&
src
->
meth
->
copy
(
dest
,
src
)
==
0
)
return
0
;
if
(
src
->
meth
->
copy
!=
NULL
&&
src
->
meth
->
copy
(
dest
,
src
)
==
0
)
return
NULL
;
return
dest
;
}
...
...
@@ -239,11 +240,11 @@ int EC_KEY_up_ref(EC_KEY *r)
int
EC_KEY_generate_key
(
EC_KEY
*
eckey
)
{
if
(
!
eckey
||
!
eckey
->
group
)
{
if
(
eckey
==
NULL
||
eckey
->
group
==
NULL
)
{
ECerr
(
EC_F_EC_KEY_GENERATE_KEY
,
ERR_R_PASSED_NULL_PARAMETER
);
return
0
;
}
if
(
eckey
->
meth
->
keygen
)
if
(
eckey
->
meth
->
keygen
!=
NULL
)
return
eckey
->
meth
->
keygen
(
eckey
);
ECerr
(
EC_F_EC_KEY_GENERATE_KEY
,
EC_R_OPERATION_NOT_SUPPORTED
);
return
0
;
...
...
@@ -308,7 +309,7 @@ int EC_KEY_check_key(const EC_KEY *eckey)
const
BIGNUM
*
order
=
NULL
;
EC_POINT
*
point
=
NULL
;
if
(
!
eckey
||
!
eckey
->
group
||
!
eckey
->
pub_key
)
{
if
(
eckey
==
NULL
||
eckey
->
group
==
NULL
||
eckey
->
pub_key
==
NULL
)
{
ECerr
(
EC_F_EC_KEY_CHECK_KEY
,
ERR_R_PASSED_NULL_PARAMETER
);
return
0
;
}
...
...
@@ -346,7 +347,7 @@ int EC_KEY_check_key(const EC_KEY *eckey)
* in case the priv_key is present : check if generator * priv_key ==
* pub_key
*/
if
(
eckey
->
priv_key
)
{
if
(
eckey
->
priv_key
!=
NULL
)
{
if
(
BN_cmp
(
eckey
->
priv_key
,
order
)
>=
0
)
{
ECerr
(
EC_F_EC_KEY_CHECK_KEY
,
EC_R_WRONG_ORDER
);
goto
err
;
...
...
@@ -379,7 +380,7 @@ int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x,
int
tmp_nid
,
is_char_two
=
0
;
#endif
if
(
!
key
||
!
key
->
group
||
!
x
||
!
y
)
{
if
(
key
==
NULL
||
key
->
group
==
NULL
||
x
==
NULL
||
y
==
NULL
)
{
ECerr
(
EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES
,
ERR_R_PASSED_NULL_PARAMETER
);
return
0
;
...
...
@@ -453,7 +454,7 @@ const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key)
int
EC_KEY_set_group
(
EC_KEY
*
key
,
const
EC_GROUP
*
group
)
{
if
(
key
->
meth
->
set_group
&&
key
->
meth
->
set_group
(
key
,
group
)
==
0
)
if
(
key
->
meth
->
set_group
!=
NULL
&&
key
->
meth
->
set_group
(
key
,
group
)
==
0
)
return
0
;
EC_GROUP_free
(
key
->
group
);
key
->
group
=
EC_GROUP_dup
(
group
);
...
...
@@ -467,7 +468,8 @@ const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key)
int
EC_KEY_set_private_key
(
EC_KEY
*
key
,
const
BIGNUM
*
priv_key
)
{
if
(
key
->
meth
->
set_private
&&
key
->
meth
->
set_private
(
key
,
priv_key
)
==
0
)
if
(
key
->
meth
->
set_private
!=
NULL
&&
key
->
meth
->
set_private
(
key
,
priv_key
)
==
0
)
return
0
;
BN_clear_free
(
key
->
priv_key
);
key
->
priv_key
=
BN_dup
(
priv_key
);
...
...
@@ -481,7 +483,8 @@ const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key)
int
EC_KEY_set_public_key
(
EC_KEY
*
key
,
const
EC_POINT
*
pub_key
)
{
if
(
key
->
meth
->
set_public
&&
key
->
meth
->
set_public
(
key
,
pub_key
)
==
0
)
if
(
key
->
meth
->
set_public
!=
NULL
&&
key
->
meth
->
set_public
(
key
,
pub_key
)
==
0
)
return
0
;
EC_POINT_free
(
key
->
pub_key
);
key
->
pub_key
=
EC_POINT_dup
(
pub_key
,
key
->
group
);
...
...
crypto/ec/ec_kmeth.c
浏览文件 @
91e7bcc2
...
...
@@ -103,7 +103,7 @@ EC_KEY *EC_KEY_new_method(ENGINE *engine)
}
ret
->
meth
=
EC_KEY_get_default_method
();
#ifndef OPENSSL_NO_ENGINE
if
(
engine
)
{
if
(
engine
!=
NULL
)
{
if
(
!
ENGINE_init
(
engine
))
{
ECerr
(
EC_F_EC_KEY_NEW_METHOD
,
ERR_R_ENGINE_LIB
);
OPENSSL_free
(
ret
);
...
...
@@ -112,9 +112,9 @@ EC_KEY *EC_KEY_new_method(ENGINE *engine)
ret
->
engine
=
engine
;
}
else
ret
->
engine
=
ENGINE_get_default_EC
();
if
(
ret
->
engine
)
{
if
(
ret
->
engine
!=
NULL
)
{
ret
->
meth
=
ENGINE_get_EC
(
ret
->
engine
);
if
(
!
ret
->
meth
)
{
if
(
ret
->
meth
==
NULL
)
{
ECerr
(
EC_F_EC_KEY_NEW_METHOD
,
ERR_R_ENGINE_LIB
);
ENGINE_finish
(
ret
->
engine
);
OPENSSL_free
(
ret
);
...
...
@@ -126,7 +126,7 @@ EC_KEY *EC_KEY_new_method(ENGINE *engine)
ret
->
version
=
1
;
ret
->
conv_form
=
POINT_CONVERSION_UNCOMPRESSED
;
ret
->
references
=
1
;
if
(
ret
->
meth
->
init
&&
ret
->
meth
->
init
(
ret
)
==
0
)
{
if
(
ret
->
meth
->
init
!=
NULL
&&
ret
->
meth
->
init
(
ret
)
==
0
)
{
EC_KEY_free
(
ret
);
return
NULL
;
}
...
...
@@ -138,7 +138,7 @@ int ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,
void
*
(
*
KDF
)
(
const
void
*
in
,
size_t
inlen
,
void
*
out
,
size_t
*
outlen
))
{
if
(
eckey
->
meth
->
compute_key
)
if
(
eckey
->
meth
->
compute_key
!=
NULL
)
return
eckey
->
meth
->
compute_key
(
out
,
outlen
,
pub_key
,
eckey
,
KDF
);
ECerr
(
EC_F_ECDH_COMPUTE_KEY
,
EC_R_OPERATION_NOT_SUPPORTED
);
return
0
;
...
...
@@ -150,7 +150,7 @@ EC_KEY_METHOD *EC_KEY_METHOD_new(const EC_KEY_METHOD *meth)
ret
=
OPENSSL_zalloc
(
sizeof
(
*
meth
));
if
(
ret
==
NULL
)
return
NULL
;
if
(
meth
)
if
(
meth
!=
NULL
)
*
ret
=
*
meth
;
ret
->
flags
|=
EC_KEY_METHOD_DYNAMIC
;
return
ret
;
...
...
crypto/ec/ecdsa_ossl.c
浏览文件 @
91e7bcc2
...
...
@@ -365,7 +365,7 @@ int ossl_ecdsa_verify(int type, const unsigned char *dgst, int dgst_len,
goto
err
;
/* Ensure signature uses DER and doesn't have trailing garbage */
derlen
=
i2d_ECDSA_SIG
(
s
,
&
der
);
if
(
derlen
!=
sig_len
||
memcmp
(
sigbuf
,
der
,
derlen
))
if
(
derlen
!=
sig_len
||
memcmp
(
sigbuf
,
der
,
derlen
)
!=
0
)
goto
err
;
ret
=
ECDSA_do_verify
(
dgst
,
dgst_len
,
s
,
eckey
);
err:
...
...
@@ -402,7 +402,7 @@ int ossl_ecdsa_verify_sig(const unsigned char *dgst, int dgst_len,
u2
=
BN_CTX_get
(
ctx
);
m
=
BN_CTX_get
(
ctx
);
X
=
BN_CTX_get
(
ctx
);
if
(
!
X
)
{
if
(
X
==
NULL
)
{
ECerr
(
EC_F_OSSL_ECDSA_VERIFY_SIG
,
ERR_R_BN_LIB
);
goto
err
;
}
...
...
crypto/ec/ecdsa_sign.c
浏览文件 @
91e7bcc2
...
...
@@ -70,7 +70,7 @@ ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dlen,
const
BIGNUM
*
kinv
,
const
BIGNUM
*
rp
,
EC_KEY
*
eckey
)
{
if
(
eckey
->
meth
->
sign_sig
)
if
(
eckey
->
meth
->
sign_sig
!=
NULL
)
return
eckey
->
meth
->
sign_sig
(
dgst
,
dlen
,
kinv
,
rp
,
eckey
);
ECerr
(
EC_F_ECDSA_DO_SIGN_EX
,
EC_R_OPERATION_NOT_SUPPORTED
);
return
NULL
;
...
...
@@ -86,7 +86,7 @@ int ECDSA_sign_ex(int type, const unsigned char *dgst, int dlen,
unsigned
char
*
sig
,
unsigned
int
*
siglen
,
const
BIGNUM
*
kinv
,
const
BIGNUM
*
r
,
EC_KEY
*
eckey
)
{
if
(
eckey
->
meth
->
sign
)
if
(
eckey
->
meth
->
sign
!=
NULL
)
return
eckey
->
meth
->
sign
(
type
,
dgst
,
dlen
,
sig
,
siglen
,
kinv
,
r
,
eckey
);
ECerr
(
EC_F_ECDSA_SIGN_EX
,
EC_R_OPERATION_NOT_SUPPORTED
);
return
0
;
...
...
@@ -95,7 +95,7 @@ int ECDSA_sign_ex(int type, const unsigned char *dgst, int dlen,
int
ECDSA_sign_setup
(
EC_KEY
*
eckey
,
BN_CTX
*
ctx_in
,
BIGNUM
**
kinvp
,
BIGNUM
**
rp
)
{
if
(
eckey
->
meth
->
sign_setup
)
if
(
eckey
->
meth
->
sign_setup
!=
NULL
)
return
eckey
->
meth
->
sign_setup
(
eckey
,
ctx_in
,
kinvp
,
rp
);
ECerr
(
EC_F_ECDSA_SIGN_SETUP
,
EC_R_OPERATION_NOT_SUPPORTED
);
return
0
;
...
...
crypto/ec/ecdsa_vrf.c
浏览文件 @
91e7bcc2
...
...
@@ -73,7 +73,7 @@
int
ECDSA_do_verify
(
const
unsigned
char
*
dgst
,
int
dgst_len
,
const
ECDSA_SIG
*
sig
,
EC_KEY
*
eckey
)
{
if
(
eckey
->
meth
->
verify_sig
)
if
(
eckey
->
meth
->
verify_sig
!=
NULL
)
return
eckey
->
meth
->
verify_sig
(
dgst
,
dgst_len
,
sig
,
eckey
);
ECerr
(
EC_F_ECDSA_DO_VERIFY
,
EC_R_OPERATION_NOT_SUPPORTED
);
return
0
;
...
...
@@ -88,10 +88,9 @@ int ECDSA_do_verify(const unsigned char *dgst, int dgst_len,
int
ECDSA_verify
(
int
type
,
const
unsigned
char
*
dgst
,
int
dgst_len
,
const
unsigned
char
*
sigbuf
,
int
sig_len
,
EC_KEY
*
eckey
)
{
if
(
eckey
->
meth
->
verify
)
if
(
eckey
->
meth
->
verify
!=
NULL
)
return
eckey
->
meth
->
verify
(
type
,
dgst
,
dgst_len
,
sigbuf
,
sig_len
,
eckey
);
ECerr
(
EC_F_ECDSA_VERIFY
,
EC_R_OPERATION_NOT_SUPPORTED
);
return
0
;
return
0
;
}
crypto/engine/tb_eckey.c
浏览文件 @
91e7bcc2
...
...
@@ -76,7 +76,7 @@ static void engine_unregister_all_EC(void)
int
ENGINE_register_EC
(
ENGINE
*
e
)
{
if
(
e
->
ec_meth
)
if
(
e
->
ec_meth
!=
NULL
)
return
engine_table_register
(
&
dh_table
,
engine_unregister_all_EC
,
e
,
&
dummy_nid
,
1
,
0
);
...
...
@@ -93,7 +93,7 @@ void ENGINE_register_all_EC()
int
ENGINE_set_default_EC
(
ENGINE
*
e
)
{
if
(
e
->
ec_meth
)
if
(
e
->
ec_meth
!=
NULL
)
return
engine_table_register
(
&
dh_table
,
engine_unregister_all_EC
,
e
,
&
dummy_nid
,
1
,
1
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录