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-11-29 17:05:54 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6d49cddc9deaaff5288be8ca629782001cdcaf91
6d49cddc
1 parent
646d6f66
for bug #235, refine code order of c1s1 and c2s2
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
128 行增加
和
128 行删除
trunk/src/rtmp/srs_protocol_handshake.cpp
trunk/src/rtmp/srs_protocol_handshake.cpp
查看文件 @
6d49cdd
...
...
@@ -833,127 +833,6 @@ namespace _srs_internal
}
}
c2s2
::
c2s2
()
{
srs_random_generate
(
random
,
1504
);
int
size
=
snprintf
(
random
,
1504
,
"%s"
,
RTMP_SIG_SRS_HANDSHAKE
);
srs_assert
(
++
size
<
1504
);
snprintf
(
random
+
1504
-
size
,
size
,
"%s"
,
RTMP_SIG_SRS_HANDSHAKE
);
srs_random_generate
(
digest
,
32
);
}
c2s2
::~
c2s2
()
{
}
void
c2s2
::
dump
(
char
*
_c2s2
)
{
memcpy
(
_c2s2
,
random
,
1504
);
memcpy
(
_c2s2
+
1504
,
digest
,
32
);
}
void
c2s2
::
parse
(
char
*
_c2s2
)
{
memcpy
(
random
,
_c2s2
,
1504
);
memcpy
(
digest
,
_c2s2
+
1504
,
32
);
}
int
c2s2
::
c2_create
(
c1s1
*
s1
)
{
int
ret
=
ERROR_SUCCESS
;
char
temp_key
[
__SRS_OpensslHashSize
];
if
((
ret
=
openssl_HMACsha256
(
SrsGenuineFPKey
,
62
,
s1
->
get_digest
(),
32
,
temp_key
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"create c2 temp key failed. ret=%d"
,
ret
);
return
ret
;
}
srs_verbose
(
"generate c2 temp key success."
);
char
_digest
[
__SRS_OpensslHashSize
];
if
((
ret
=
openssl_HMACsha256
(
temp_key
,
32
,
random
,
1504
,
_digest
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"create c2 digest failed. ret=%d"
,
ret
);
return
ret
;
}
srs_verbose
(
"generate c2 digest success."
);
memcpy
(
digest
,
_digest
,
32
);
return
ret
;
}
int
c2s2
::
c2_validate
(
c1s1
*
s1
,
bool
&
is_valid
)
{
is_valid
=
false
;
int
ret
=
ERROR_SUCCESS
;
char
temp_key
[
__SRS_OpensslHashSize
];
if
((
ret
=
openssl_HMACsha256
(
SrsGenuineFPKey
,
62
,
s1
->
get_digest
(),
32
,
temp_key
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"create c2 temp key failed. ret=%d"
,
ret
);
return
ret
;
}
srs_verbose
(
"generate c2 temp key success."
);
char
_digest
[
__SRS_OpensslHashSize
];
if
((
ret
=
openssl_HMACsha256
(
temp_key
,
32
,
random
,
1504
,
_digest
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"create c2 digest failed. ret=%d"
,
ret
);
return
ret
;
}
srs_verbose
(
"generate c2 digest success."
);
is_valid
=
srs_bytes_equals
(
digest
,
_digest
,
32
);
return
ret
;
}
int
c2s2
::
s2_create
(
c1s1
*
c1
)
{
int
ret
=
ERROR_SUCCESS
;
char
temp_key
[
__SRS_OpensslHashSize
];
if
((
ret
=
openssl_HMACsha256
(
SrsGenuineFMSKey
,
68
,
c1
->
get_digest
(),
32
,
temp_key
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"create s2 temp key failed. ret=%d"
,
ret
);
return
ret
;
}
srs_verbose
(
"generate s2 temp key success."
);
char
_digest
[
__SRS_OpensslHashSize
];
if
((
ret
=
openssl_HMACsha256
(
temp_key
,
32
,
random
,
1504
,
_digest
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"create s2 digest failed. ret=%d"
,
ret
);
return
ret
;
}
srs_verbose
(
"generate s2 digest success."
);
memcpy
(
digest
,
_digest
,
32
);
return
ret
;
}
int
c2s2
::
s2_validate
(
c1s1
*
c1
,
bool
&
is_valid
)
{
is_valid
=
false
;
int
ret
=
ERROR_SUCCESS
;
char
temp_key
[
__SRS_OpensslHashSize
];
if
((
ret
=
openssl_HMACsha256
(
SrsGenuineFMSKey
,
68
,
c1
->
get_digest
(),
32
,
temp_key
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"create s2 temp key failed. ret=%d"
,
ret
);
return
ret
;
}
srs_verbose
(
"generate s2 temp key success."
);
char
_digest
[
__SRS_OpensslHashSize
];
if
((
ret
=
openssl_HMACsha256
(
temp_key
,
32
,
random
,
1504
,
_digest
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"create s2 digest failed. ret=%d"
,
ret
);
return
ret
;
}
srs_verbose
(
"generate s2 digest success."
);
is_valid
=
srs_bytes_equals
(
digest
,
_digest
,
32
);
return
ret
;
}
// TODO: FIXME: move to the right position.
c1s1
::
c1s1
()
{
...
...
@@ -1052,13 +931,6 @@ namespace _srs_internal
return
payload
->
c1_validate_digest
(
this
,
is_valid
);
}
int
c1s1
::
s1_validate_digest
(
bool
&
is_valid
)
{
is_valid
=
false
;
srs_assert
(
payload
);
return
payload
->
s1_validate_digest
(
this
,
is_valid
);
}
int
c1s1
::
s1_create
(
c1s1
*
c1
)
{
int
ret
=
ERROR_SUCCESS
;
...
...
@@ -1081,6 +953,134 @@ namespace _srs_internal
return
payload
->
s1_create
(
this
);
}
int
c1s1
::
s1_validate_digest
(
bool
&
is_valid
)
{
is_valid
=
false
;
srs_assert
(
payload
);
return
payload
->
s1_validate_digest
(
this
,
is_valid
);
}
c2s2
::
c2s2
()
{
srs_random_generate
(
random
,
1504
);
int
size
=
snprintf
(
random
,
1504
,
"%s"
,
RTMP_SIG_SRS_HANDSHAKE
);
srs_assert
(
++
size
<
1504
);
snprintf
(
random
+
1504
-
size
,
size
,
"%s"
,
RTMP_SIG_SRS_HANDSHAKE
);
srs_random_generate
(
digest
,
32
);
}
c2s2
::~
c2s2
()
{
}
void
c2s2
::
dump
(
char
*
_c2s2
)
{
memcpy
(
_c2s2
,
random
,
1504
);
memcpy
(
_c2s2
+
1504
,
digest
,
32
);
}
void
c2s2
::
parse
(
char
*
_c2s2
)
{
memcpy
(
random
,
_c2s2
,
1504
);
memcpy
(
digest
,
_c2s2
+
1504
,
32
);
}
int
c2s2
::
c2_create
(
c1s1
*
s1
)
{
int
ret
=
ERROR_SUCCESS
;
char
temp_key
[
__SRS_OpensslHashSize
];
if
((
ret
=
openssl_HMACsha256
(
SrsGenuineFPKey
,
62
,
s1
->
get_digest
(),
32
,
temp_key
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"create c2 temp key failed. ret=%d"
,
ret
);
return
ret
;
}
srs_verbose
(
"generate c2 temp key success."
);
char
_digest
[
__SRS_OpensslHashSize
];
if
((
ret
=
openssl_HMACsha256
(
temp_key
,
32
,
random
,
1504
,
_digest
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"create c2 digest failed. ret=%d"
,
ret
);
return
ret
;
}
srs_verbose
(
"generate c2 digest success."
);
memcpy
(
digest
,
_digest
,
32
);
return
ret
;
}
int
c2s2
::
c2_validate
(
c1s1
*
s1
,
bool
&
is_valid
)
{
is_valid
=
false
;
int
ret
=
ERROR_SUCCESS
;
char
temp_key
[
__SRS_OpensslHashSize
];
if
((
ret
=
openssl_HMACsha256
(
SrsGenuineFPKey
,
62
,
s1
->
get_digest
(),
32
,
temp_key
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"create c2 temp key failed. ret=%d"
,
ret
);
return
ret
;
}
srs_verbose
(
"generate c2 temp key success."
);
char
_digest
[
__SRS_OpensslHashSize
];
if
((
ret
=
openssl_HMACsha256
(
temp_key
,
32
,
random
,
1504
,
_digest
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"create c2 digest failed. ret=%d"
,
ret
);
return
ret
;
}
srs_verbose
(
"generate c2 digest success."
);
is_valid
=
srs_bytes_equals
(
digest
,
_digest
,
32
);
return
ret
;
}
int
c2s2
::
s2_create
(
c1s1
*
c1
)
{
int
ret
=
ERROR_SUCCESS
;
char
temp_key
[
__SRS_OpensslHashSize
];
if
((
ret
=
openssl_HMACsha256
(
SrsGenuineFMSKey
,
68
,
c1
->
get_digest
(),
32
,
temp_key
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"create s2 temp key failed. ret=%d"
,
ret
);
return
ret
;
}
srs_verbose
(
"generate s2 temp key success."
);
char
_digest
[
__SRS_OpensslHashSize
];
if
((
ret
=
openssl_HMACsha256
(
temp_key
,
32
,
random
,
1504
,
_digest
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"create s2 digest failed. ret=%d"
,
ret
);
return
ret
;
}
srs_verbose
(
"generate s2 digest success."
);
memcpy
(
digest
,
_digest
,
32
);
return
ret
;
}
int
c2s2
::
s2_validate
(
c1s1
*
c1
,
bool
&
is_valid
)
{
is_valid
=
false
;
int
ret
=
ERROR_SUCCESS
;
char
temp_key
[
__SRS_OpensslHashSize
];
if
((
ret
=
openssl_HMACsha256
(
SrsGenuineFMSKey
,
68
,
c1
->
get_digest
(),
32
,
temp_key
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"create s2 temp key failed. ret=%d"
,
ret
);
return
ret
;
}
srs_verbose
(
"generate s2 temp key success."
);
char
_digest
[
__SRS_OpensslHashSize
];
if
((
ret
=
openssl_HMACsha256
(
temp_key
,
32
,
random
,
1504
,
_digest
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"create s2 digest failed. ret=%d"
,
ret
);
return
ret
;
}
srs_verbose
(
"generate s2 digest success."
);
is_valid
=
srs_bytes_equals
(
digest
,
_digest
,
32
);
return
ret
;
}
}
#endif
...
...
请
注册
或
登录
后发表评论