mirror of
https://github.com/ossrs/srs.git
synced 2025-02-12 11:21:52 +00:00
fix #235, refine handshake, replace union with template method. 2.0.38.
This commit is contained in:
parent
abb0fce3d8
commit
efb73c5487
4 changed files with 31 additions and 23 deletions
|
@ -485,7 +485,8 @@ Supported operating systems and hardware:
|
|||
* 2013-10-17, Created.<br/>
|
||||
|
||||
## History
|
||||
* v2.0, 2014-11-28, fix [#215](https://github.com/winlinvip/simple-rtmp-server/issues/215), for bug #215, add srs_rtmp_dump tool. 2.0.37.
|
||||
* v2.0, 2014-11-29, fix [#235](https://github.com/winlinvip/simple-rtmp-server/issues/235), refine handshake, replace union with template method. 2.0.38.
|
||||
* v2.0, 2014-11-28, fix [#215](https://github.com/winlinvip/simple-rtmp-server/issues/215), add srs_rtmp_dump tool. 2.0.37.
|
||||
* v2.0, 2014-11-25, update PRIMARY, AUTHORS, CONTRIBUTORS rule. 2.0.32.
|
||||
* v2.0, 2014-11-24, fix [#212](https://github.com/winlinvip/simple-rtmp-server/issues/212), support publish aac adts raw stream. 2.0.31.
|
||||
* v2.0, 2014-11-22, fix [#217](https://github.com/winlinvip/simple-rtmp-server/issues/217), remove timeout recv, support 7.5k+ 250kbps clients. 2.0.30.
|
||||
|
|
|
@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
// current release version
|
||||
#define VERSION_MAJOR 2
|
||||
#define VERSION_MINOR 0
|
||||
#define VERSION_REVISION 37
|
||||
#define VERSION_REVISION 38
|
||||
// server info.
|
||||
#define RTMP_SIG_SRS_KEY "SRS"
|
||||
#define RTMP_SIG_SRS_ROLE "origin/edge server"
|
||||
|
|
|
@ -514,7 +514,7 @@ namespace _srs_internal
|
|||
return ret;
|
||||
}
|
||||
|
||||
int c1s1_strategy::s1_create(c1s1* owner)
|
||||
int c1s1_strategy::s1_create(c1s1* owner, c1s1* c1)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
|
@ -528,8 +528,7 @@ namespace _srs_internal
|
|||
// directly generate the public key.
|
||||
// @see: https://github.com/winlinvip/simple-rtmp-server/issues/148
|
||||
int pkey_size = 128;
|
||||
// TODO: FIXME: use c1 public key to calc the shared key.
|
||||
if ((ret = dh.copy_public_key(key.key, pkey_size)) != ERROR_SUCCESS) {
|
||||
if ((ret = dh.copy_shared_key(c1->get_key(), 128, key.key, pkey_size)) != ERROR_SUCCESS) {
|
||||
srs_error("calc s1 key failed. ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
@ -827,7 +826,6 @@ namespace _srs_internal
|
|||
return ret;
|
||||
}
|
||||
|
||||
// TODO: FIXME: move to the right position.
|
||||
c1s1::c1s1()
|
||||
{
|
||||
payload = NULL;
|
||||
|
@ -835,21 +833,6 @@ namespace _srs_internal
|
|||
c1s1::~c1s1()
|
||||
{
|
||||
srs_freep(payload);
|
||||
/*
|
||||
void c1s1::destroy_blocks()
|
||||
{
|
||||
if (schema == srs_schema_invalid) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (schema == srs_schema0) {
|
||||
block0.key.free();
|
||||
block1.digest.free();
|
||||
} else {
|
||||
block0.digest.free();
|
||||
block1.key.free();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
srs_schema_type c1s1::schema()
|
||||
|
@ -960,7 +943,7 @@ namespace _srs_internal
|
|||
payload = new c1s1_strategy_schema1();
|
||||
}
|
||||
|
||||
return payload->s1_create(this);
|
||||
return payload->s1_create(this, c1);
|
||||
}
|
||||
|
||||
int c1s1::s1_validate_digest(bool& is_valid)
|
||||
|
|
|
@ -245,8 +245,32 @@ namespace _srs_internal
|
|||
virtual int c1_validate_digest(c1s1* owner, bool& is_valid);
|
||||
/**
|
||||
* server: create and sign the s1 from c1.
|
||||
* // decode c1 try schema0 then schema1
|
||||
* c1-digest-data = get-c1-digest-data(schema0)
|
||||
* if c1-digest-data equals to calc_c1_digest(c1, schema0) {
|
||||
* c1-key-data = get-c1-key-data(schema0)
|
||||
* schema = schema0
|
||||
* } else {
|
||||
* c1-digest-data = get-c1-digest-data(schema1)
|
||||
* if c1-digest-data not equals to calc_c1_digest(c1, schema1) {
|
||||
* switch to simple handshake.
|
||||
* return
|
||||
* }
|
||||
* c1-key-data = get-c1-key-data(schema1)
|
||||
* schema = schema1
|
||||
* }
|
||||
*
|
||||
* // generate s1
|
||||
* random fill 1536bytes s1
|
||||
* time = time() // c1[0-3]
|
||||
* version = [0x04, 0x05, 0x00, 0x01] // s1[4-7]
|
||||
* s1-key-data=shared_key=DH_compute_key(peer_pub_key=c1-key-data)
|
||||
* get c1s1-joined by specified schema
|
||||
* s1-digest-data = HMACsha256(c1s1-joined, FMSKey, 36)
|
||||
* copy s1-digest-data and s1-key-data to s1.
|
||||
* @param c1, to get the peer_pub_key of client.
|
||||
*/
|
||||
virtual int s1_create(c1s1* owner);
|
||||
virtual int s1_create(c1s1* owner, c1s1* c1);
|
||||
/**
|
||||
* server: validate the parsed s1 schema
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue