Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2014-08-08 13:34:50 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b317abbaeed3c22f248ec800d8afa7ee762ad4a3
b317abba
1 parent
d4c2aa1e
refine openssl, add compute_key, for bug #148
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
14 行增加
和
7 行删除
trunk/src/rtmp/srs_protocol_handshake.cpp
trunk/src/rtmp/srs_protocol_handshake.cpp
查看文件 @
b317abb
...
...
@@ -145,6 +145,9 @@ namespace _srs_internal
"E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" \
"EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381" \
"FFFFFFFFFFFFFFFF"
/**
* initialize DH, create the public/private key.
*/
int
__openssl_initialize_dh
(
DH
*
pdh
,
int32_t
bits_count
)
{
int
ret
=
ERROR_SUCCESS
;
...
...
@@ -180,6 +183,9 @@ namespace _srs_internal
return
ret
;
}
/**
* create DH and copy the 128bytes public key.
*/
int
__openssl_copy_key
(
DH
*
pdh
,
char
*
public_key
,
int32_t
size
)
{
int
ret
=
ERROR_SUCCESS
;
...
...
@@ -202,20 +208,21 @@ namespace _srs_internal
return
ret
;
}
int
__openssl_compute_key
(
DH
*
pdh
,
const
char
*
peer_pub_key
,
int
ppk_size
,
char
*
secret
)
/**
* create DH and copy the 128bytes public key,
* generate and copy the shared key.
*/
int
__openssl_compute_key
(
DH
*
pdh
,
const
char
*
peer_pub_key
,
int
ppk_size
,
char
*
public_key
,
char
*
shared_key
)
{
int
ret
=
ERROR_SUCCESS
;
int32_t
bits_count
=
1024
;
// 2. generate the g, p, private/public key.
if
((
ret
=
__openssl_initialize_dh
(
pdh
,
bits_count
))
!=
ERROR_SUCCESS
)
{
// create DH and copy the 128bytes public key
if
((
ret
=
__openssl_copy_key
(
pdh
,
public_key
,
ppk_size
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
// copy public key to bytes.
srs_assert
(
BN_num_bytes
(
pdh
->
pub_key
)
==
ppk_size
);
BIGNUM
*
ppk
=
NULL
;
if
((
ppk
=
BN_bin2bn
((
const
unsigned
char
*
)
peer_pub_key
,
ppk_size
,
0
))
==
NULL
)
{
ret
=
ERROR_OpenSslGetPeerPublicKey
;
...
...
@@ -223,7 +230,7 @@ namespace _srs_internal
}
// if failed, donot return, do cleanup.
if
(
DH_compute_key
((
unsigned
char
*
)
s
ecret
,
ppk
,
pdh
)
<
0
)
{
if
(
DH_compute_key
((
unsigned
char
*
)
s
hared_key
,
ppk
,
pdh
)
<
0
)
{
ret
=
ERROR_OpenSslComputeSharedKey
;
}
...
...
请
注册
或
登录
后发表评论