Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
btwise
openssl
提交
28f4580c
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,发现更多精彩内容 >>
提交
28f4580c
编写于
11月 24, 2015
作者:
D
Dr. Stephen Henson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use EVP_md5_sha1() to process client verify
Reviewed-by:
N
Tim Hudson
<
tjh@openssl.org
>
上级
a0f63828
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
44 addition
and
130 deletion
+44
-130
ssl/statem/statem_srvr.c
ssl/statem/statem_srvr.c
+44
-130
未找到文件。
ssl/statem/statem_srvr.c
浏览文件 @
28f4580c
...
...
@@ -1550,8 +1550,7 @@ WORK_STATE tls_post_process_client_hello(SSL *s, WORK_STATE wst)
s
->
s3
->
tmp
.
new_cipher
=
s
->
session
->
cipher
;
}
if
(
!
(
SSL_USE_SIGALGS
(
s
)
||
(
s
->
s3
->
tmp
.
new_cipher
->
algorithm_auth
&
(
SSL_aGOST12
|
SSL_aGOST01
))
)
||
!
(
s
->
verify_mode
&
SSL_VERIFY_PEER
))
{
if
(
!
(
s
->
verify_mode
&
SSL_VERIFY_PEER
))
{
if
(
!
ssl3_digest_cached_records
(
s
,
0
))
{
al
=
SSL_AD_INTERNAL_ERROR
;
goto
f_err
;
...
...
@@ -2933,8 +2932,7 @@ WORK_STATE tls_post_process_client_key_exchange(SSL *s, WORK_STATE wst)
BIO_free
(
s
->
s3
->
handshake_buffer
);
s
->
s3
->
handshake_buffer
=
NULL
;
return
WORK_FINISHED_CONTINUE
;
}
else
if
(
SSL_USE_SIGALGS
(
s
)
||
(
s
->
s3
->
tmp
.
new_cipher
->
algorithm_auth
&
(
SSL_aGOST12
|
SSL_aGOST01
)
))
{
}
else
{
if
(
!
s
->
session
->
peer
)
{
/* No peer certificate so we no longer need the handshake_buffer */
BIO_free
(
s
->
s3
->
handshake_buffer
);
...
...
@@ -2954,41 +2952,6 @@ WORK_STATE tls_post_process_client_key_exchange(SSL *s, WORK_STATE wst)
ossl_statem_set_error
(
s
);
return
WORK_ERROR
;
}
}
else
{
int
offset
=
0
;
int
dgst_num
;
/*
* We need to get hashes here so if there is a client cert,
* it can be verified FIXME - digest processing for
* CertificateVerify should be generalized. But it is next
* step
*/
if
(
!
ssl3_digest_cached_records
(
s
,
0
))
{
ossl_statem_set_error
(
s
);
return
WORK_ERROR
;
}
for
(
dgst_num
=
0
;
dgst_num
<
SSL_MAX_DIGEST
;
dgst_num
++
)
{
if
(
s
->
s3
->
handshake_dgst
[
dgst_num
])
{
int
dgst_size
;
s
->
method
->
ssl3_enc
->
cert_verify_mac
(
s
,
EVP_MD_CTX_type
(
s
->
s3
->
handshake_dgst
[
dgst_num
]),
&
(
s
->
s3
->
tmp
.
cert_verify_md
[
offset
]));
dgst_size
=
EVP_MD_CTX_size
(
s
->
s3
->
handshake_dgst
[
dgst_num
]);
if
(
dgst_size
<
0
)
{
ossl_statem_set_error
(
s
);
return
WORK_ERROR
;
}
offset
+=
dgst_size
;
}
}
}
return
WORK_FINISHED_CONTINUE
;
...
...
@@ -2999,10 +2962,13 @@ MSG_PROCESS_RETURN tls_process_cert_verify(SSL *s, PACKET *pkt)
EVP_PKEY
*
pkey
=
NULL
;
unsigned
char
*
sig
,
*
data
;
int
al
,
ret
=
MSG_PROCESS_ERROR
;
int
type
=
0
,
i
,
j
;
int
type
=
0
,
j
;
unsigned
int
len
;
X509
*
peer
;
const
EVP_MD
*
md
=
NULL
;
long
hdatalen
=
0
;
void
*
hdata
;
EVP_MD_CTX
mctx
;
EVP_MD_CTX_init
(
&
mctx
);
...
...
@@ -3043,6 +3009,10 @@ MSG_PROCESS_RETURN tls_process_cert_verify(SSL *s, PACKET *pkt)
#ifdef SSL_DEBUG
fprintf
(
stderr
,
"USING TLSv1.2 HASH %s
\n
"
,
EVP_MD_name
(
md
));
#endif
}
else
if
(
pkey
->
type
==
EVP_PKEY_RSA
)
{
md
=
EVP_md5_sha1
();
}
else
{
md
=
EVP_sha1
();
}
if
(
!
PACKET_get_net_2
(
pkt
,
&
len
))
{
SSLerr
(
SSL_F_TLS_PROCESS_CERT_VERIFY
,
SSL_R_LENGTH_MISMATCH
);
...
...
@@ -3063,101 +3033,45 @@ MSG_PROCESS_RETURN tls_process_cert_verify(SSL *s, PACKET *pkt)
goto
f_err
;
}
if
(
SSL_USE_SIGALGS
(
s
)
||
pkey
->
type
==
NID_id_GostR3410_2001
||
pkey
->
type
==
NID_id_GostR3410_2012_256
||
pkey
->
type
==
NID_id_GostR3410_2012_512
)
{
long
hdatalen
=
0
;
void
*
hdata
;
hdatalen
=
BIO_get_mem_data
(
s
->
s3
->
handshake_buffer
,
&
hdata
);
if
(
hdatalen
<=
0
)
{
SSLerr
(
SSL_F_TLS_PROCESS_CERT_VERIFY
,
ERR_R_INTERNAL_ERROR
);
al
=
SSL_AD_INTERNAL_ERROR
;
goto
f_err
;
}
hdatalen
=
BIO_get_mem_data
(
s
->
s3
->
handshake_buffer
,
&
hdata
);
if
(
hdatalen
<=
0
)
{
SSLerr
(
SSL_F_TLS_PROCESS_CERT_VERIFY
,
ERR_R_INTERNAL_ERROR
);
al
=
SSL_AD_INTERNAL_ERROR
;
goto
f_err
;
}
#ifdef SSL_DEBUG
fprintf
(
stderr
,
"Using TLS 1.2 with client verify alg %s
\n
"
,
EVP_MD_name
(
md
));
fprintf
(
stderr
,
"Using client verify alg %s
\n
"
,
EVP_MD_name
(
md
));
#endif
if
(
!
SSL_USE_SIGALGS
(
s
))
{
int
dgst_nid
;
if
(
EVP_PKEY_get_default_digest_nid
(
pkey
,
&
dgst_nid
)
<=
0
||
(
md
=
EVP_get_digestbynid
(
dgst_nid
))
==
NULL
)
{
SSLerr
(
SSL_F_TLS_PROCESS_CERT_VERIFY
,
ERR_R_INTERNAL_ERROR
);
al
=
SSL_AD_INTERNAL_ERROR
;
goto
f_err
;
}
}
if
(
!
EVP_VerifyInit_ex
(
&
mctx
,
md
,
NULL
)
||
!
EVP_VerifyUpdate
(
&
mctx
,
hdata
,
hdatalen
))
{
SSLerr
(
SSL_F_TLS_PROCESS_CERT_VERIFY
,
ERR_R_EVP_LIB
);
al
=
SSL_AD_INTERNAL_ERROR
;
goto
f_err
;
}
if
(
!
EVP_VerifyInit_ex
(
&
mctx
,
md
,
NULL
)
||
!
EVP_VerifyUpdate
(
&
mctx
,
hdata
,
hdatalen
))
{
SSLerr
(
SSL_F_TLS_PROCESS_CERT_VERIFY
,
ERR_R_EVP_LIB
);
al
=
SSL_AD_INTERNAL_ERROR
;
goto
f_err
;
}
if
(
pkey
->
type
==
NID_id_GostR3410_2001
||
pkey
->
type
==
NID_id_GostR3410_2012_256
||
pkey
->
type
==
NID_id_GostR3410_2012_512
)
{
unsigned
int
j1
,
j2
;
for
(
j1
=
len
-
1
,
j2
=
0
;
j2
<
len
/
2
;
j2
++
,
j1
--
)
{
char
c
=
data
[
j2
];
data
[
j2
]
=
data
[
j1
];
data
[
j1
]
=
c
;
}
if
(
pkey
->
type
==
NID_id_GostR3410_2001
||
pkey
->
type
==
NID_id_GostR3410_2012_256
||
pkey
->
type
==
NID_id_GostR3410_2012_512
)
{
unsigned
int
j1
,
j2
;
for
(
j1
=
len
-
1
,
j2
=
0
;
j2
<
len
/
2
;
j2
++
,
j1
--
)
{
char
c
=
data
[
j2
];
data
[
j2
]
=
data
[
j1
];
data
[
j1
]
=
c
;
}
}
if
(
EVP_VerifyFinal
(
&
mctx
,
data
,
len
,
pkey
)
<=
0
)
{
al
=
SSL_AD_DECRYPT_ERROR
;
SSLerr
(
SSL_F_TLS_PROCESS_CERT_VERIFY
,
SSL_R_BAD_SIGNATURE
);
goto
f_err
;
}
}
else
#ifndef OPENSSL_NO_RSA
if
(
pkey
->
type
==
EVP_PKEY_RSA
)
{
i
=
RSA_verify
(
NID_md5_sha1
,
s
->
s3
->
tmp
.
cert_verify_md
,
MD5_DIGEST_LENGTH
+
SHA_DIGEST_LENGTH
,
data
,
len
,
pkey
->
pkey
.
rsa
);
if
(
i
<
0
)
{
al
=
SSL_AD_DECRYPT_ERROR
;
SSLerr
(
SSL_F_TLS_PROCESS_CERT_VERIFY
,
SSL_R_BAD_RSA_DECRYPT
);
goto
f_err
;
}
if
(
i
==
0
)
{
al
=
SSL_AD_DECRYPT_ERROR
;
SSLerr
(
SSL_F_TLS_PROCESS_CERT_VERIFY
,
SSL_R_BAD_RSA_SIGNATURE
);
goto
f_err
;
}
}
else
#endif
#ifndef OPENSSL_NO_DSA
if
(
pkey
->
type
==
EVP_PKEY_DSA
)
{
j
=
DSA_verify
(
pkey
->
save_type
,
&
(
s
->
s3
->
tmp
.
cert_verify_md
[
MD5_DIGEST_LENGTH
]),
SHA_DIGEST_LENGTH
,
data
,
len
,
pkey
->
pkey
.
dsa
);
if
(
j
<=
0
)
{
/* bad signature */
al
=
SSL_AD_DECRYPT_ERROR
;
SSLerr
(
SSL_F_TLS_PROCESS_CERT_VERIFY
,
SSL_R_BAD_DSA_SIGNATURE
);
goto
f_err
;
}
}
else
#endif
#ifndef OPENSSL_NO_EC
if
(
pkey
->
type
==
EVP_PKEY_EC
)
{
j
=
ECDSA_verify
(
pkey
->
save_type
,
&
(
s
->
s3
->
tmp
.
cert_verify_md
[
MD5_DIGEST_LENGTH
]),
SHA_DIGEST_LENGTH
,
data
,
len
,
pkey
->
pkey
.
ec
);
if
(
j
<=
0
)
{
/* bad signature */
al
=
SSL_AD_DECRYPT_ERROR
;
SSLerr
(
SSL_F_TLS_PROCESS_CERT_VERIFY
,
SSL_R_BAD_ECDSA_SIGNATURE
);
goto
f_err
;
}
}
else
#endif
{
SSLerr
(
SSL_F_TLS_PROCESS_CERT_VERIFY
,
ERR_R_INTERNAL_ERROR
);
al
=
SSL_AD_UNSUPPORTED_CERTIFICATE
;
if
(
s
->
version
==
SSL3_VERSION
&&
!
EVP_MD_CTX_ctrl
(
&
mctx
,
EVP_CTRL_SSL3_MASTER_SECRET
,
s
->
session
->
master_key_length
,
s
->
session
->
master_key
))
{
SSLerr
(
SSL_F_TLS_PROCESS_CERT_VERIFY
,
ERR_R_EVP_LIB
);
al
=
SSL_AD_INTERNAL_ERROR
;
goto
f_err
;
}
if
(
EVP_VerifyFinal
(
&
mctx
,
data
,
len
,
pkey
)
<=
0
)
{
al
=
SSL_AD_DECRYPT_ERROR
;
SSLerr
(
SSL_F_TLS_PROCESS_CERT_VERIFY
,
SSL_R_BAD_SIGNATURE
);
goto
f_err
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录