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-03-19 00:47:10 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b58ab508f9c42fe104fcf69ba0edf34e7f31b615
b58ab508
1 parent
1c055e74
add rtmp handshake utest, for arm to finger out the bug
隐藏空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
451 行增加
和
269 行删除
trunk/configure
trunk/src/rtmp/srs_protocol_handshake.cpp
trunk/src/rtmp/srs_protocol_handshake.hpp
trunk/src/srs/srs.upp
trunk/src/utest/srs_utest_handshake.cpp
trunk/src/utest/srs_utest_handshake.hpp
trunk/configure
查看文件 @
b58ab50
...
...
@@ -392,7 +392,7 @@ if [ $SRS_LIBRTMP = YES ]; then
fi
#
# utest, the unit-test cases of srs, base on gtest1.6
MODULE_FILES
=(
"srs_utest"
"srs_utest_amf0"
)
MODULE_FILES
=(
"srs_utest"
"srs_utest_amf0"
"srs_utest_handshake"
)
ModuleLibIncs
=(
${
SRS_OBJS
}
${
LibSTRoot
}
)
ModuleLibFiles
=(
${
LibSTfile
}
${
LibHttpParserfile
}
${
LibSSLfile
}
)
MODULE_DEPENDS
=(
"CORE"
"KERNEL"
"RTMP"
"APP"
)
...
...
trunk/src/rtmp/srs_protocol_handshake.cpp
查看文件 @
b58ab50
...
...
@@ -31,6 +31,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_kernel_log.hpp>
#include <srs_protocol_io.hpp>
using
namespace
srs
;
void
srs_random_generate
(
char
*
bytes
,
int
size
)
{
static
char
cdata
[]
=
{
...
...
@@ -47,7 +49,7 @@ void srs_random_generate(char* bytes, int size)
#ifdef SRS_SSL
// 68bytes FMS key which is used to sign the sever packet.
u_int8_t
SrsGenuineFMSKey
[]
=
{
u_int8_t
srs
::
SrsGenuineFMSKey
[]
=
{
0x47
,
0x65
,
0x6e
,
0x75
,
0x69
,
0x6e
,
0x65
,
0x20
,
0x41
,
0x64
,
0x6f
,
0x62
,
0x65
,
0x20
,
0x46
,
0x6c
,
0x61
,
0x73
,
0x68
,
0x20
,
0x4d
,
0x65
,
0x64
,
0x69
,
...
...
@@ -60,7 +62,7 @@ u_int8_t SrsGenuineFMSKey[] = {
};
// 68
// 62bytes FP key which is used to sign the client packet.
u_int8_t
SrsGenuineFPKey
[]
=
{
u_int8_t
srs
::
SrsGenuineFPKey
[]
=
{
0x47
,
0x65
,
0x6E
,
0x75
,
0x69
,
0x6E
,
0x65
,
0x20
,
0x41
,
0x64
,
0x6F
,
0x62
,
0x65
,
0x20
,
0x46
,
0x6C
,
0x61
,
0x73
,
0x68
,
0x20
,
0x50
,
0x6C
,
0x61
,
0x79
,
...
...
@@ -73,7 +75,8 @@ u_int8_t SrsGenuineFPKey[] = {
#include <openssl/evp.h>
#include <openssl/hmac.h>
int
openssl_HMACsha256
(
const
void
*
data
,
int
data_size
,
const
void
*
key
,
int
key_size
,
void
*
digest
)
{
int
srs
::
openssl_HMACsha256
(
const
void
*
data
,
int
data_size
,
const
void
*
key
,
int
key_size
,
void
*
digest
)
{
HMAC_CTX
ctx
;
HMAC_CTX_init
(
&
ctx
);
...
...
@@ -234,32 +237,6 @@ int openssl_generate_key(char* _private_key, char* _public_key, int32_t size)
return
ret
;
}
// the digest key generate size.
#define OpensslHashSize 512
/**
* 764bytes key结构
* random-data: (offset)bytes
* key-data: 128bytes
* random-data: (764-offset-128-4)bytes
* offset: 4bytes
*/
struct
key_block
{
// (offset)bytes
char
*
random0
;
int
random0_size
;
// 128bytes
char
key
[
128
];
// (764-offset-128-4)bytes
char
*
random1
;
int
random1_size
;
// 4bytes
int32_t
offset
;
};
// calc the offset of key,
// the key->offset cannot be used as the offset of key.
int
srs_key_block_get_offset
(
key_block
*
key
)
...
...
@@ -349,29 +326,6 @@ void srs_key_block_free(key_block* key)
}
}
/**
* 764bytes digest结构
* offset: 4bytes
* random-data: (offset)bytes
* digest-data: 32bytes
* random-data: (764-4-offset-32)bytes
*/
struct
digest_block
{
// 4bytes
int32_t
offset
;
// (offset)bytes
char
*
random0
;
int
random0_size
;
// 32bytes
char
digest
[
32
];
// (764-4-offset-32)bytes
char
*
random1
;
int
random1_size
;
};
// calc the offset of digest,
// the key->offset cannot be used as the offset of digest.
int
srs_digest_block_get_offset
(
digest_block
*
digest
)
...
...
@@ -460,15 +414,6 @@ void srs_digest_block_free(digest_block* digest)
}
}
/**
* the schema type.
*/
enum
srs_schema_type
{
srs_schema0
=
0
,
// key-digest sequence
srs_schema1
=
1
,
// digest-key sequence
srs_schema_invalid
=
2
,
};
void
__srs_time_copy_to
(
char
*&
pp
,
int32_t
time
)
{
// 4bytes time
...
...
@@ -560,13 +505,14 @@ void srs_schema1_copy_to(char* bytes, bool with_digest,
srs_assert
(
pp
-
bytes
==
1536
-
32
);
}
}
/**
* c1s1 is splited by digest:
* c1s1-part1: n bytes (time, version, key and digest-part1).
* digest-data: 32bytes
* c1s1-part2: (1536-n-32)bytes (digest-part2)
*/
char
*
srs_bytes_join_schema0
(
int32_t
time
,
int32_t
version
,
key_block
*
key
,
digest_block
*
digest
)
char
*
srs
::
srs
_bytes_join_schema0
(
int32_t
time
,
int32_t
version
,
key_block
*
key
,
digest_block
*
digest
)
{
char
*
bytes
=
new
char
[
1536
-
32
];
...
...
@@ -574,13 +520,14 @@ char* srs_bytes_join_schema0(int32_t time, int32_t version, key_block* key, dige
return
bytes
;
}
/**
* c1s1 is splited by digest:
* c1s1-part1: n bytes (time, version and digest-part1).
* digest-data: 32bytes
* c1s1-part2: (1536-n-32)bytes (digest-part2 and key)
*/
char
*
srs_bytes_join_schema1
(
int32_t
time
,
int32_t
version
,
digest_block
*
digest
,
key_block
*
key
)
char
*
srs
::
srs
_bytes_join_schema1
(
int32_t
time
,
int32_t
version
,
digest_block
*
digest
,
key_block
*
key
)
{
char
*
bytes
=
new
char
[
1536
-
32
];
...
...
@@ -592,7 +539,8 @@ char* srs_bytes_join_schema1(int32_t time, int32_t version, digest_block* digest
/**
* compare the memory in bytes.
*/
bool
srs_bytes_equals
(
void
*
pa
,
void
*
pb
,
int
size
){
bool
srs
::
srs_bytes_equals
(
void
*
pa
,
void
*
pb
,
int
size
)
{
u_int8_t
*
a
=
(
u_int8_t
*
)
pa
;
u_int8_t
*
b
=
(
u_int8_t
*
)
pb
;
...
...
@@ -605,126 +553,6 @@ bool srs_bytes_equals(void* pa, void* pb, int size){
return
true
;
}
/**
* c1s1 schema0
* time: 4bytes
* version: 4bytes
* key: 764bytes
* digest: 764bytes
* c1s1 schema1
* time: 4bytes
* version: 4bytes
* digest: 764bytes
* key: 764bytes
*/
struct
c1s1
{
union
block
{
key_block
key
;
digest_block
digest
;
};
// 4bytes
int32_t
time
;
// 4bytes
int32_t
version
;
// 764bytes
// if schema0, use key
// if schema1, use digest
block
block0
;
// 764bytes
// if schema0, use digest
// if schema1, use key
block
block1
;
// the logic schema
srs_schema_type
schema
;
c1s1
();
virtual
~
c1s1
();
/**
* get the digest key.
*/
virtual
char
*
get_digest
();
/**
* copy to bytes.
*/
virtual
void
dump
(
char
*
_c1s1
);
/**
* client: create and sign c1 by schema.
* sign the c1, generate the digest.
* calc_c1_digest(c1, schema) {
* get c1s1-joined from c1 by specified schema
* digest-data = HMACsha256(c1s1-joined, FPKey, 30)
* return digest-data;
* }
* random fill 1536bytes c1 // also fill the c1-128bytes-key
* time = time() // c1[0-3]
* version = [0x80, 0x00, 0x07, 0x02] // c1[4-7]
* schema = choose schema0 or schema1
* digest-data = calc_c1_digest(c1, schema)
* copy digest-data to c1
*/
virtual
int
c1_create
(
srs_schema_type
_schema
);
/**
* server: parse the c1s1, discovery the key and digest by schema.
* use the c1_validate_digest() to valid the digest of c1.
*/
virtual
int
c1_parse
(
char
*
_c1s1
,
srs_schema_type
_schema
);
/**
* server: validate the parsed schema and c1s1
*/
virtual
int
c1_validate_digest
(
bool
&
is_valid
);
/**
* server: create and sign the s1 from c1.
*/
virtual
int
s1_create
(
c1s1
*
c1
);
private
:
virtual
int
calc_s1_digest
(
char
*&
digest
);
virtual
int
calc_c1_digest
(
char
*&
digest
);
virtual
void
destroy_blocks
();
};
/**
* the c2s2 complex handshake structure.
* random-data: 1504bytes
* digest-data: 32bytes
*/
struct
c2s2
{
char
random
[
1504
];
char
digest
[
32
];
c2s2
();
virtual
~
c2s2
();
/**
* copy to bytes.
*/
virtual
void
dump
(
char
*
_c2s2
);
/**
* create c2.
* random fill c2s2 1536 bytes
*
* // client generate C2, or server valid C2
* temp-key = HMACsha256(s1-digest, FPKey, 62)
* c2-digest-data = HMACsha256(c2-random-data, temp-key, 32)
*/
virtual
int
c2_create
(
c1s1
*
s1
);
/**
* create s2.
* random fill c2s2 1536 bytes
*
* // server generate S2, or client valid S2
* temp-key = HMACsha256(c1-digest, FMSKey, 68)
* s2-digest-data = HMACsha256(s2-random-data, temp-key, 32)
*/
virtual
int
s2_create
(
c1s1
*
c1
);
};
c2s2
::
c2s2
()
{
srs_random_generate
(
random
,
1504
);
...
...
trunk/src/rtmp/srs_protocol_handshake.hpp
查看文件 @
b58ab50
...
...
@@ -76,4 +76,217 @@ public:
virtual
int
handshake_with_server
(
ISrsProtocolReaderWriter
*
io
);
};
namespace
srs
{
/**
* the schema type.
*/
enum
srs_schema_type
{
srs_schema0
=
0
,
// key-digest sequence
srs_schema1
=
1
,
// digest-key sequence
srs_schema_invalid
=
2
,
};
/**
* 764bytes key结构
* random-data: (offset)bytes
* key-data: 128bytes
* random-data: (764-offset-128-4)bytes
* offset: 4bytes
* @see also: http://blog.csdn.net/win_lin/article/details/13006803
*/
struct
key_block
{
// (offset)bytes
char
*
random0
;
int
random0_size
;
// 128bytes
char
key
[
128
];
// (764-offset-128-4)bytes
char
*
random1
;
int
random1_size
;
// 4bytes
int32_t
offset
;
};
/**
* 764bytes digest结构
* offset: 4bytes
* random-data: (offset)bytes
* digest-data: 32bytes
* random-data: (764-4-offset-32)bytes
* @see also: http://blog.csdn.net/win_lin/article/details/13006803
*/
struct
digest_block
{
// 4bytes
int32_t
offset
;
// (offset)bytes
char
*
random0
;
int
random0_size
;
// 32bytes
char
digest
[
32
];
// (764-4-offset-32)bytes
char
*
random1
;
int
random1_size
;
};
/**
* c1s1 schema0
* time: 4bytes
* version: 4bytes
* key: 764bytes
* digest: 764bytes
* c1s1 schema1
* time: 4bytes
* version: 4bytes
* digest: 764bytes
* key: 764bytes
* @see also: http://blog.csdn.net/win_lin/article/details/13006803
*/
struct
c1s1
{
union
block
{
key_block
key
;
digest_block
digest
;
};
// 4bytes
int32_t
time
;
// 4bytes
int32_t
version
;
// 764bytes
// if schema0, use key
// if schema1, use digest
block
block0
;
// 764bytes
// if schema0, use digest
// if schema1, use key
block
block1
;
// the logic schema
srs_schema_type
schema
;
c1s1
();
virtual
~
c1s1
();
/**
* get the digest key.
*/
virtual
char
*
get_digest
();
/**
* copy to bytes.
*/
virtual
void
dump
(
char
*
_c1s1
);
/**
* client: create and sign c1 by schema.
* sign the c1, generate the digest.
* calc_c1_digest(c1, schema) {
* get c1s1-joined from c1 by specified schema
* digest-data = HMACsha256(c1s1-joined, FPKey, 30)
* return digest-data;
* }
* random fill 1536bytes c1 // also fill the c1-128bytes-key
* time = time() // c1[0-3]
* version = [0x80, 0x00, 0x07, 0x02] // c1[4-7]
* schema = choose schema0 or schema1
* digest-data = calc_c1_digest(c1, schema)
* copy digest-data to c1
*/
virtual
int
c1_create
(
srs_schema_type
_schema
);
/**
* server: parse the c1s1, discovery the key and digest by schema.
* use the c1_validate_digest() to valid the digest of c1.
*/
virtual
int
c1_parse
(
char
*
_c1s1
,
srs_schema_type
_schema
);
/**
* server: validate the parsed schema and c1s1
*/
virtual
int
c1_validate_digest
(
bool
&
is_valid
);
/**
* server: create and sign the s1 from c1.
*/
virtual
int
s1_create
(
c1s1
*
c1
);
private
:
virtual
int
calc_s1_digest
(
char
*&
digest
);
virtual
int
calc_c1_digest
(
char
*&
digest
);
virtual
void
destroy_blocks
();
};
/**
* the c2s2 complex handshake structure.
* random-data: 1504bytes
* digest-data: 32bytes
* @see also: http://blog.csdn.net/win_lin/article/details/13006803
*/
struct
c2s2
{
char
random
[
1504
];
char
digest
[
32
];
c2s2
();
virtual
~
c2s2
();
/**
* copy to bytes.
*/
virtual
void
dump
(
char
*
_c2s2
);
/**
* create c2.
* random fill c2s2 1536 bytes
*
* // client generate C2, or server valid C2
* temp-key = HMACsha256(s1-digest, FPKey, 62)
* c2-digest-data = HMACsha256(c2-random-data, temp-key, 32)
*/
virtual
int
c2_create
(
c1s1
*
s1
);
/**
* create s2.
* random fill c2s2 1536 bytes
*
* // server generate S2, or client valid S2
* temp-key = HMACsha256(c1-digest, FMSKey, 68)
* s2-digest-data = HMACsha256(s2-random-data, temp-key, 32)
*/
virtual
int
s2_create
(
c1s1
*
c1
);
};
/**
* compare the memory in bytes.
*/
bool
srs_bytes_equals
(
void
*
pa
,
void
*
pb
,
int
size
);
/**
* c1s1 is splited by digest:
* c1s1-part1: n bytes (time, version, key and digest-part1).
* digest-data: 32bytes
* c1s1-part2: (1536-n-32)bytes (digest-part2)
* @return a new allocated bytes, user must free it.
*/
char
*
srs_bytes_join_schema0
(
int32_t
time
,
int32_t
version
,
key_block
*
key
,
digest_block
*
digest
);
/**
* c1s1 is splited by digest:
* c1s1-part1: n bytes (time, version and digest-part1).
* digest-data: 32bytes
* c1s1-part2: (1536-n-32)bytes (digest-part2 and key)
* @return a new allocated bytes, user must free it.
*/
char
*
srs_bytes_join_schema1
(
int32_t
time
,
int32_t
version
,
digest_block
*
digest
,
key_block
*
key
);
// the digest key generate size.
#define OpensslHashSize 512
extern
u_int8_t
SrsGenuineFMSKey
[];
extern
u_int8_t
SrsGenuineFPKey
[];
int
openssl_HMACsha256
(
const
void
*
data
,
int
data_size
,
const
void
*
key
,
int
key_size
,
void
*
digest
);
}
#endif
\ No newline at end of file
...
...
trunk/src/srs/srs.upp
查看文件 @
b58ab50
file
main readonly separator,
..\main\srs_main_server.cpp,
..\main\srs_main_bandcheck.cpp,
auto readonly separator,
..\..\objs\srs_auto_headers.hpp,
libs readonly separator,
..\libs\srs_librtmp.hpp,
..\libs\srs_librtmp.cpp,
..\libs\srs_lib_simple_socket.hpp,
..\libs\srs_lib_simple_socket.cpp,
core readonly separator,
..\core\srs_core.hpp,
..\core\srs_core.cpp,
..\core\srs_core_autofree.hpp,
..\core\srs_core_autofree.cpp,
kernel readonly separator,
..\kernel\srs_kernel_buffer.hpp,
..\kernel\srs_kernel_buffer.cpp,
..\kernel\srs_kernel_error.hpp,
..\kernel\srs_kernel_error.cpp,
..\kernel\srs_kernel_log.hpp,
..\kernel\srs_kernel_log.cpp,
..\kernel\srs_kernel_stream.hpp,
..\kernel\srs_kernel_stream.cpp,
rtmp-protocol readonly separator,
..\rtmp\srs_protocol_amf0.hpp,
..\rtmp\srs_protocol_amf0.cpp,
..\rtmp\srs_protocol_handshake.hpp,
..\rtmp\srs_protocol_handshake.cpp,
..\rtmp\srs_protocol_io.hpp,
..\rtmp\srs_protocol_io.cpp,
..\rtmp\srs_protocol_rtmp.hpp,
..\rtmp\srs_protocol_rtmp.cpp,
..\rtmp\srs_protocol_rtmp_stack.hpp,
..\rtmp\srs_protocol_rtmp_stack.cpp,
..\rtmp\srs_protocol_utility.hpp,
..\rtmp\srs_protocol_utility.cpp,
app readonly separator,
..\app\srs_app_bandwidth.hpp,
..\app\srs_app_bandwidth.cpp,
..\app\srs_app_client.hpp,
..\app\srs_app_client.cpp,
..\app\srs_app_codec.hpp,
..\app\srs_app_codec.cpp,
..\app\srs_app_conn.hpp,
..\app\srs_app_conn.cpp,
..\app\srs_app_config.hpp,
..\app\srs_app_config.cpp,
..\app\srs_app_encoder.hpp,
..\app\srs_app_encoder.cpp,
..\app\srs_app_forward.hpp,
..\app\srs_app_forward.cpp,
..\app\srs_app_hls.hpp,
..\app\srs_app_hls.cpp,
..\app\srs_app_http.hpp,
..\app\srs_app_http.cpp,
..\app\srs_app_log.hpp,
..\app\srs_app_log.cpp,
..\app\srs_app_refer.hpp,
..\app\srs_app_refer.cpp,
..\app\srs_app_reload.hpp,
..\app\srs_app_reload.cpp,
..\app\srs_app_pithy_print.hpp,
..\app\srs_app_pithy_print.cpp,
..\app\srs_app_thread.hpp,
..\app\srs_app_thread.cpp,
..\app\srs_app_server.hpp,
..\app\srs_app_server.cpp,
..\app\srs_app_st.hpp,
..\app\srs_app_st.cpp,
..\app\srs_app_socket.hpp,
..\app\srs_app_socket.cpp,
..\app\srs_app_source.hpp,
..\app\srs_app_source.cpp,
utest readonly separator,
..\utest\srs_utest.hpp,
..\utest\srs_utest.cpp,
..\utest\srs_utest_amf0.hpp,
..\utest\srs_utest_amf0.cpp,
research readonly separator,
..\..\research\librtmp\srs_play.c,
..\..\research\librtmp\srs_publish.c,
..\..\research\hls\ts_info.cc;
main readonly separator,
..\main\srs_main_server.cpp,
..\main\srs_main_bandcheck.cpp,
auto readonly separator,
..\..\objs\srs_auto_headers.hpp,
libs readonly separator,
..\libs\srs_librtmp.hpp,
..\libs\srs_librtmp.cpp,
..\libs\srs_lib_simple_socket.hpp,
..\libs\srs_lib_simple_socket.cpp,
core readonly separator,
..\core\srs_core.hpp,
..\core\srs_core.cpp,
..\core\srs_core_autofree.hpp,
..\core\srs_core_autofree.cpp,
kernel readonly separator,
..\kernel\srs_kernel_buffer.hpp,
..\kernel\srs_kernel_buffer.cpp,
..\kernel\srs_kernel_error.hpp,
..\kernel\srs_kernel_error.cpp,
..\kernel\srs_kernel_log.hpp,
..\kernel\srs_kernel_log.cpp,
..\kernel\srs_kernel_stream.hpp,
..\kernel\srs_kernel_stream.cpp,
rtmp-protocol readonly separator,
..\rtmp\srs_protocol_amf0.hpp,
..\rtmp\srs_protocol_amf0.cpp,
..\rtmp\srs_protocol_handshake.hpp,
..\rtmp\srs_protocol_handshake.cpp,
..\rtmp\srs_protocol_io.hpp,
..\rtmp\srs_protocol_io.cpp,
..\rtmp\srs_protocol_rtmp.hpp,
..\rtmp\srs_protocol_rtmp.cpp,
..\rtmp\srs_protocol_rtmp_stack.hpp,
..\rtmp\srs_protocol_rtmp_stack.cpp,
..\rtmp\srs_protocol_utility.hpp,
..\rtmp\srs_protocol_utility.cpp,
app readonly separator,
..\app\srs_app_bandwidth.hpp,
..\app\srs_app_bandwidth.cpp,
..\app\srs_app_client.hpp,
..\app\srs_app_client.cpp,
..\app\srs_app_codec.hpp,
..\app\srs_app_codec.cpp,
..\app\srs_app_conn.hpp,
..\app\srs_app_conn.cpp,
..\app\srs_app_config.hpp,
..\app\srs_app_config.cpp,
..\app\srs_app_encoder.hpp,
..\app\srs_app_encoder.cpp,
..\app\srs_app_forward.hpp,
..\app\srs_app_forward.cpp,
..\app\srs_app_hls.hpp,
..\app\srs_app_hls.cpp,
..\app\srs_app_http.hpp,
..\app\srs_app_http.cpp,
..\app\srs_app_log.hpp,
..\app\srs_app_log.cpp,
..\app\srs_app_refer.hpp,
..\app\srs_app_refer.cpp,
..\app\srs_app_reload.hpp,
..\app\srs_app_reload.cpp,
..\app\srs_app_pithy_print.hpp,
..\app\srs_app_pithy_print.cpp,
..\app\srs_app_thread.hpp,
..\app\srs_app_thread.cpp,
..\app\srs_app_server.hpp,
..\app\srs_app_server.cpp,
..\app\srs_app_st.hpp,
..\app\srs_app_st.cpp,
..\app\srs_app_socket.hpp,
..\app\srs_app_socket.cpp,
..\app\srs_app_source.hpp,
..\app\srs_app_source.cpp,
utest readonly separator,
..\utest\srs_utest.hpp,
..\utest\srs_utest.cpp,
..\utest\srs_utest_amf0.hpp,
..\utest\srs_utest_amf0.cpp,
..\utest\srs_utest_handshake.hpp,
..\utest\srs_utest_handshake.cpp,
research readonly separator,
..\..\research\librtmp\srs_play.c,
..\..\research\librtmp\srs_publish.c,
..\..\research\hls\ts_info.cc;
mainconfig
"" = "MAIN";
"" = "MAIN";
...
...
trunk/src/utest/srs_utest_handshake.cpp
0 → 100644
查看文件 @
b58ab50
/*
The MIT License (MIT)
Copyright (c) 2013-2014 winlin
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <srs_utest_handshake.hpp>
#include <srs_kernel_error.hpp>
#include <srs_core_autofree.hpp>
// verify the sha256
VOID
TEST
(
HandshakeTest
,
OpensslSha256
)
{
// randome bytes to ensure the openssl sha256 is ok.
char
random_bytes
[]
=
{
0x8b
,
0x1c
,
0x5c
,
0x5c
,
0x3b
,
0x98
,
0x60
,
0x80
,
0x3c
,
0x97
,
0x43
,
0x79
,
0x9c
,
0x94
,
0xec
,
0x63
,
0xaa
,
0xd9
,
0x10
,
0xd7
,
0x0d
,
0x91
,
0xfb
,
0x1f
,
0xbf
,
0xe0
,
0x29
,
0xde
,
0x77
,
0x09
,
0x21
,
0x34
,
0xa5
,
0x7d
,
0xdf
,
0xe3
,
0xdf
,
0x11
,
0xdf
,
0xd4
,
0x00
,
0x57
,
0x38
,
0x5b
,
0xae
,
0x9e
,
0x89
,
0x35
,
0xcf
,
0x07
,
0x48
,
0xca
,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
0x6e
,
0xe3
,
0x22
,
0xbf
,
0x7b
,
0x72
,
0x8a
,
0xc3
,
0x79
,
0xd6
,
0x1b
,
0x6c
,
0xe7
,
0x9c
,
0xc9
,
0xfd
,
0x48
,
0xaa
,
0xc1
,
0xfa
,
0xbf
,
0x33
,
0x87
,
0x5c
,
0x0d
,
0xe5
,
0x34
,
0x24
,
0x70
,
0x14
,
0x1e
,
0x4a
,
0x48
,
0x07
,
0x6e
,
0xaf
,
0xbf
,
0xfe
,
0x34
,
0x1e
,
0x1e
,
0x19
,
0xfc
,
0xb5
,
0x8a
,
0x4f
,
0x3c
,
0xb4
,
0xcf
,
0xde
,
0x24
,
0x79
,
0x65
,
0x17
,
0x22
,
0x3f
,
0xc0
,
0x06
,
0x76
,
0x4e
,
0x3c
,
0xfb
,
0xc3
,
0xd0
,
0x7f
,
0x7b
,
0x87
,
0x5c
,
0xeb
,
0x97
,
0x87
,
};
char
digest
[
OpensslHashSize
];
ASSERT_EQ
(
ERROR_SUCCESS
,
openssl_HMACsha256
(
random_bytes
,
sizeof
(
random_bytes
),
SrsGenuineFPKey
,
30
,
digest
)
);
char
expect_digest
[]
=
{
0x1b
,
0xc7
,
0xe6
,
0x14
,
0xd5
,
0x19
,
0x8d
,
0x99
,
0x42
,
0x0a
,
0x21
,
0x95
,
0x26
,
0x9a
,
0x8a
,
0x56
,
0xb4
,
0x82
,
0x2a
,
0x7f
,
0xd3
,
0x1d
,
0xc3
,
0xd8
,
0x92
,
0x97
,
0xc4
,
0x61
,
0xb7
,
0x4d
,
0x5d
,
0xd2
};
EXPECT_TRUE
(
srs_bytes_equals
(
digest
,
expect_digest
,
32
));
}
// flash will sendout a c0c1 encrypt by ssl.
VOID
TEST
(
HandshakeTest
,
VerifyFPC0C1
)
{
char
c0c1
[]
=
{
0x03
,
0x00
,
0x0f
,
0x64
,
0xd0
,
0x80
,
0x00
,
0x07
,
0x02
,
0xe6
,
0x42
,
0xe5
,
0x2b
,
0xf1
,
0x1d
,
0x0f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0x40
,
0x31
,
0xf9
,
0x2c
,
0xf6
,
0x38
,
0xea
,
0x45
,
0x33
,
0xc1
,
0xb6
,
0xd5
,
0x93
,
0x0f
,
0x5c
,
0xaf
,
0x3a
,
0x53
,
0x75
,
0xd6
,
0xe8
,
0x97
,
0xa0
,
0x51
,
0x3f
,
0x96
,
0x41
,
0x32
,
0x0b
,
0x59
,
0x48
,
0xbf
,
0x2b
,
0x19
,
0x67
,
0x98
,
0x42
,
0xfe
,
0x44
,
0x23
,
0x84
,
0xa9
,
0x09
,
0x40
,
0x4e
,
0x10
,
0x25
,
0xdf
,
0x68
,
0x93
,
0x6b
,
0x0d
,
0xa8
,
0x51
,
0x47
,
0x55
,
0xb7
,
0xb8
,
0x22
,
0xab
,
0xa3
,
0x3c
,
0x78
,
0xd6
,
0x8b
,
0x4f
,
0x2a
,
0x73
,
0xc1
,
0x4a
,
0x4a
,
0xdd
,
0x73
,
0xb1
,
0xc0
,
0x8c
,
0x5f
,
0xf6
,
0xe7
,
0xbe
,
0x9c
,
0x96
,
0xd6
,
0x37
,
0x91
,
0x05
,
0x52
,
0xd1
,
0x2f
,
0xa9
,
0xdc
,
0xca
,
0x11
,
0x30
,
0x6d
,
0x4f
,
0xb5
,
0x6e
,
0x39
,
0x24
,
0x28
,
0x80
,
0x54
,
0x28
,
0x87
,
0xe6
,
0x40
,
0xeb
,
0xd8
,
0x7a
,
0x1f
,
0x63
,
0x56
,
0xc1
,
0x4d
,
0xa0
,
0xf8
};
ASSERT_EQ
(
1537
,
(
int
)
sizeof
(
c0c1
));
// c0
EXPECT_EQ
(
0x03
,
c0c1
[
0
]);
// c1
c1s1
c1
;
// the schema of data must be schema0: key-digest.
ASSERT_EQ
(
ERROR_SUCCESS
,
c1
.
c1_parse
(
c0c1
+
1
,
srs_schema0
));
EXPECT_EQ
((
int32_t
)
0xd0640f00
,
c1
.
time
);
EXPECT_EQ
((
int32_t
)
0x2070080
,
c1
.
version
);
// manually validate the c1
// @see: calc_c1_digest
char
*
c1s1_joined_bytes
=
srs_bytes_join_schema0
(
c1
.
time
,
c1
.
version
,
&
c1
.
block0
.
key
,
&
c1
.
block1
.
digest
);
SrsAutoFree
(
char
,
c1s1_joined_bytes
,
true
);
bool
is_valid
;
ASSERT_EQ
(
ERROR_SUCCESS
,
c1
.
c1_validate_digest
(
is_valid
));
ASSERT_TRUE
(
is_valid
);
// 128bytes key
char
key
[]
=
{
0x01
,
0xc6
,
0xba
,
0xe4
,
0xb8
,
0xd5
,
0xbd
,
0x7b
,
0x43
,
0xc9
,
0x69
,
0x6b
,
0x40
,
0xf7
,
0xdc
,
0x65
,
0xa4
,
0xf7
,
0xca
,
0x1f
,
0xd8
,
0xe5
,
0xba
,
0x4c
,
0xdf
,
0xe4
,
0x64
,
0x9e
,
0x7d
,
0xbd
,
0x54
,
0x13
,
0x13
,
0xc6
,
0x0c
,
0xb8
,
0x1d
,
0x31
,
0x0a
,
0x49
,
0xe2
,
0x43
,
0xb6
,
0x95
,
0x5f
,
0x05
,
0x6e
,
0x66
,
0xf4
,
0x21
,
0xa8
,
0x65
,
0xce
,
0xf8
,
0x8e
,
0xcc
,
0x16
,
0x1e
,
0xbb
,
0xd8
,
0x0e
,
0xcb
,
0xd2
,
0x48
,
0x37
,
0xaf
,
0x4e
,
0x67
,
0x45
,
0xf1
,
0x79
,
0x69
,
0xd2
,
0xee
,
0xa4
,
0xb5
,
0x01
,
0xbf
,
0x57
,
0x0f
,
0x68
,
0x37
,
0xbe
,
0x4e
,
0xff
,
0xc9
,
0xb9
,
0x92
,
0x23
,
0x06
,
0x75
,
0xa0
,
0x42
,
0xe4
,
0x0a
,
0x30
,
0xf0
,
0xaf
,
0xb0
,
0x54
,
0x88
,
0x7c
,
0xc0
,
0xc1
,
0x0c
,
0x6d
,
0x01
,
0x36
,
0x63
,
0xf3
,
0x3d
,
0xbc
,
0x72
,
0xf6
,
0x96
,
0xc8
,
0x87
,
0xab
,
0x8b
,
0x0c
,
0x91
,
0x2f
,
0x42
,
0x2a
,
0x11
,
0xf6
,
0x2d
,
0x5e
};
EXPECT_TRUE
(
srs_bytes_equals
(
c1
.
block0
.
key
.
key
,
key
,
128
));
// 32bytes digest
char
digest
[]
=
{
0x6c
,
0x96
,
0x9f
,
0x26
,
0xeb
,
0xdc
,
0x61
,
0xc4
,
0x8f
,
0xd3
,
0x2b
,
0x81
,
0x86
,
0x6c
,
0x9c
,
0xc2
,
0xb1
,
0xb5
,
0xbc
,
0xa6
,
0xd6
,
0xd6
,
0x1d
,
0xce
,
0x93
,
0x78
,
0xb3
,
0xec
,
0xa8
,
0x64
,
0x19
,
0x13
};
EXPECT_TRUE
(
srs_bytes_equals
(
c1
.
block1
.
digest
.
digest
,
digest
,
32
));
}
...
...
trunk/src/utest/srs_utest_handshake.hpp
0 → 100644
查看文件 @
b58ab50
/*
The MIT License (MIT)
Copyright (c) 2013-2014 winlin
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef SRS_UTEST_HANDSHAKE_HPP
#define SRS_UTEST_HANDSHAKE_HPP
/*
#include <srs_utest_handshake.hpp>
*/
#include <srs_utest.hpp>
#include <srs_protocol_handshake.hpp>
using
namespace
srs
;
#endif
...
...
请
注册
或
登录
后发表评论