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 11:34:17 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d4c2aa1e8e084385df9822a5469c741c3fa703f6
d4c2aa1e
1 parent
7adbe7f4
add __openssl_compute_key to calc the shared key
隐藏空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
33 行增加
和
0 行删除
trunk/src/kernel/srs_kernel_error.hpp
trunk/src/rtmp/srs_protocol_handshake.cpp
trunk/src/kernel/srs_kernel_error.hpp
查看文件 @
d4c2aa1
...
...
@@ -129,6 +129,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define ERROR_OpenSslSha256Final 2035
#define ERROR_OpenSslSha256EvpDigest 2036
#define ERROR_OpenSslSha256DigestSize 2037
#define ERROR_OpenSslGetPeerPublicKey 2038
#define ERROR_OpenSslComputeSharedKey 2039
//
// system control message,
// not an error, but special control logic.
...
...
trunk/src/rtmp/srs_protocol_handshake.cpp
查看文件 @
d4c2aa1
...
...
@@ -202,6 +202,37 @@ namespace _srs_internal
return
ret
;
}
int
__openssl_compute_key
(
DH
*
pdh
,
const
char
*
peer_pub_key
,
int
ppk_size
,
char
*
secret
)
{
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
)
{
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
;
return
ret
;
}
// if failed, donot return, do cleanup.
if
(
DH_compute_key
((
unsigned
char
*
)
secret
,
ppk
,
pdh
)
<
0
)
{
ret
=
ERROR_OpenSslComputeSharedKey
;
}
if
(
ppk
)
{
BN_free
(
ppk
);
}
return
ret
;
}
void
__openssl_free
(
DH
*
pdh
)
{
if
(
pdh
!=
NULL
)
{
...
...
请
注册
或
登录
后发表评论