Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
4a22ba54
提交
4a22ba54
authored
1月 02, 2016
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Work in DTLSAgent.
上级
05d5447c
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
51 行增加
和
67 行删除
+51
-67
DTLSAgent.h
worker/include/RTC/DTLSAgent.h
+31
-15
DTLSRole.h
worker/include/RTC/DTLSRole.h
+0
-14
FingerprintHash.h
worker/include/RTC/FingerprintHash.h
+0
-17
SRTPProfile.h
worker/include/RTC/SRTPProfile.h
+0
-14
SRTPSession.h
worker/include/RTC/SRTPSession.h
+9
-2
Transport.h
worker/include/RTC/Transport.h
+1
-0
Peer.cpp
worker/src/RTC/Peer.cpp
+0
-1
SRTPSession.cpp
worker/src/RTC/SRTPSession.cpp
+3
-3
Transport.cpp
worker/src/RTC/Transport.cpp
+7
-1
没有找到文件。
worker/include/RTC/DTLSAgent.h
浏览文件 @
4a22ba54
...
@@ -2,26 +2,43 @@
...
@@ -2,26 +2,43 @@
#define MS_RTC_DTLS_AGENT_H
#define MS_RTC_DTLS_AGENT_H
#include "common.h"
#include "common.h"
#include "RTC/SRTPSession.h"
#include "handles/Timer.h"
#include "handles/Timer.h"
#include "RTC/DTLSRole.h"
#include "RTC/FingerprintHash.h"
#include "RTC/SRTPProfile.h"
#include <string>
#include <string>
#include <map>
#include <vector>
#include <vector>
#include <openssl/ssl.h>
#include <openssl/ssl.h>
#include <openssl/bio.h>
#include <openssl/bio.h>
#include <openssl/x509.h>
#include <openssl/x509.h>
#include <json/json.h>
namespace
RTC
namespace
RTC
{
{
class
DTLSAgent
:
class
DTLSAgent
:
public
Timer
::
Listener
public
Timer
::
Listener
{
{
public
:
enum
class
DTLSRole
{
NONE
=
0
,
SERVER
=
1
,
CLIENT
};
public
:
enum
class
FingerprintHash
{
NONE
=
0
,
SHA1
=
1
,
SHA224
,
SHA256
,
SHA384
,
SHA512
};
private
:
private
:
struct
SrtpProfileMapEntry
struct
SrtpProfileMapEntry
{
{
SRTPProfile
profile
;
RTC
::
SRTPSession
::
SRTPProfile
profile
;
const
char
*
name
;
const
char
*
name
;
};
};
...
@@ -37,15 +54,15 @@ namespace RTC
...
@@ -37,15 +54,15 @@ namespace RTC
virtual
void
onDTLSConnected
(
DTLSAgent
*
dtlsAgent
)
=
0
;
virtual
void
onDTLSConnected
(
DTLSAgent
*
dtlsAgent
)
=
0
;
virtual
void
onDTLSDisconnected
(
DTLSAgent
*
dtlsAgent
)
=
0
;
virtual
void
onDTLSDisconnected
(
DTLSAgent
*
dtlsAgent
)
=
0
;
virtual
void
onDTLSFailed
(
DTLSAgent
*
dtlsAgent
)
=
0
;
virtual
void
onDTLSFailed
(
DTLSAgent
*
dtlsAgent
)
=
0
;
virtual
void
onSRTPKeyMaterial
(
DTLSAgent
*
dtlsAgent
,
RTC
::
SRTPProfile
srtp_profile
,
MS_BYTE
*
srtp_local_key
,
size_t
srtp_local_key_len
,
MS_BYTE
*
srtp_remote_key
,
size_t
srtp_remote_key_len
)
=
0
;
virtual
void
onSRTPKeyMaterial
(
DTLSAgent
*
dtlsAgent
,
RTC
::
SRTP
Session
::
SRTP
Profile
srtp_profile
,
MS_BYTE
*
srtp_local_key
,
size_t
srtp_local_key_len
,
MS_BYTE
*
srtp_remote_key
,
size_t
srtp_remote_key_len
)
=
0
;
virtual
void
onDTLSApplicationData
(
DTLSAgent
*
dtlsAgent
,
const
MS_BYTE
*
data
,
size_t
len
)
=
0
;
virtual
void
onDTLSApplicationData
(
DTLSAgent
*
dtlsAgent
,
const
MS_BYTE
*
data
,
size_t
len
)
=
0
;
};
};
public
:
public
:
static
void
ClassInit
();
static
void
ClassInit
();
static
void
ClassDestroy
();
static
void
ClassDestroy
();
static
Json
::
Value
&
GetLocalFingerprints
();
static
bool
IsDTLS
(
const
MS_BYTE
*
data
,
size_t
len
);
static
bool
IsDTLS
(
const
MS_BYTE
*
data
,
size_t
len
);
static
const
std
::
string
&
GetFingerprint
(
RTC
::
FingerprintHash
hash
);
private
:
private
:
static
void
GenerateCertificateAndPrivateKey
();
static
void
GenerateCertificateAndPrivateKey
();
...
@@ -57,8 +74,7 @@ namespace RTC
...
@@ -57,8 +74,7 @@ namespace RTC
static
X509
*
certificate
;
static
X509
*
certificate
;
static
EVP_PKEY
*
privateKey
;
static
EVP_PKEY
*
privateKey
;
static
SSL_CTX
*
sslCtx
;
static
SSL_CTX
*
sslCtx
;
typedef
std
::
map
<
RTC
::
FingerprintHash
,
std
::
string
>
Fingerprints
;
static
Json
::
Value
localFingerprints
;
static
Fingerprints
fingerprints
;
typedef
std
::
vector
<
SrtpProfileMapEntry
>
SRTPProfiles
;
typedef
std
::
vector
<
SrtpProfileMapEntry
>
SRTPProfiles
;
static
SRTPProfiles
srtpProfiles
;
static
SRTPProfiles
srtpProfiles
;
static
MS_BYTE
sslReadBuffer
[];
static
MS_BYTE
sslReadBuffer
[];
...
@@ -67,8 +83,8 @@ namespace RTC
...
@@ -67,8 +83,8 @@ namespace RTC
DTLSAgent
(
Listener
*
listener
);
DTLSAgent
(
Listener
*
listener
);
virtual
~
DTLSAgent
();
virtual
~
DTLSAgent
();
void
Run
(
RTC
::
DTLSRole
role
);
void
Run
(
DTLSRole
role
);
void
SetRemoteFingerprint
(
RTC
::
FingerprintHash
hash
,
std
::
string
&
fingerprint
);
void
SetRemoteFingerprint
(
FingerprintHash
hash
,
std
::
string
&
fingerprint
);
void
Reset
();
void
Reset
();
void
Close
();
void
Close
();
void
ProcessDTLSData
(
const
MS_BYTE
*
data
,
size_t
len
);
void
ProcessDTLSData
(
const
MS_BYTE
*
data
,
size_t
len
);
...
@@ -83,8 +99,8 @@ namespace RTC
...
@@ -83,8 +99,8 @@ namespace RTC
void
SetTimeout
();
void
SetTimeout
();
void
ProcessHandshake
();
void
ProcessHandshake
();
bool
CheckRemoteFingerprint
();
bool
CheckRemoteFingerprint
();
RTC
::
SRTPProfile
GetNegotiatedSRTPProfile
();
RTC
::
SRTP
Session
::
SRTP
Profile
GetNegotiatedSRTPProfile
();
void
ExtractSRTPKeys
(
RTC
::
SRTPProfile
srtp_profile
);
void
ExtractSRTPKeys
(
RTC
::
SRTP
Session
::
SRTP
Profile
srtp_profile
);
/* Callbacks fired by OpenSSL events. */
/* Callbacks fired by OpenSSL events. */
public
:
public
:
...
@@ -103,8 +119,8 @@ namespace RTC
...
@@ -103,8 +119,8 @@ namespace RTC
BIO
*
sslBioToNetwork
=
nullptr
;
// The BIO in which ssl writes.
BIO
*
sslBioToNetwork
=
nullptr
;
// The BIO in which ssl writes.
Timer
*
timer
=
nullptr
;
Timer
*
timer
=
nullptr
;
// Others.
// Others.
RTC
::
DTLSRole
role
;
DTLSRole
role
=
DTLSRole
::
NONE
;
RTC
::
FingerprintHash
remoteFingerprintHash
=
RTC
::
FingerprintHash
::
NONE
;
FingerprintHash
remoteFingerprintHash
=
FingerprintHash
::
NONE
;
std
::
string
remoteFingerprint
;
std
::
string
remoteFingerprint
;
bool
isRunning
=
false
;
bool
isRunning
=
false
;
bool
isHandshakeDone
=
false
;
bool
isHandshakeDone
=
false
;
...
...
worker/include/RTC/DTLSRole.h
deleted
100644 → 0
浏览文件 @
05d5447c
#ifndef MS_RTC_DTLS_ROLE_H
#define MS_RTC_DTLS_ROLE_H
namespace
RTC
{
enum
class
DTLSRole
{
NONE
=
0
,
SERVER
=
1
,
CLIENT
};
}
#endif
worker/include/RTC/FingerprintHash.h
deleted
100644 → 0
浏览文件 @
05d5447c
#ifndef MS_RTC_FINGERPRINT_HASH_H
#define MS_RTC_FINGERPRINT_HASH_H
namespace
RTC
{
enum
class
FingerprintHash
{
NONE
=
0
,
SHA1
=
1
,
SHA224
,
SHA256
,
SHA384
,
SHA512
};
}
#endif
worker/include/RTC/SRTPProfile.h
deleted
100644 → 0
浏览文件 @
05d5447c
#ifndef MS_RTC_SRTP_PROFILE_H
#define MS_RTC_SRTP_PROFILE_H
namespace
RTC
{
enum
class
SRTPProfile
{
NONE
=
0
,
AES_CM_128_HMAC_SHA1_80
=
1
,
AES_CM_128_HMAC_SHA1_32
};
}
#endif
worker/include/RTC/SRTPSession.h
浏览文件 @
4a22ba54
...
@@ -3,13 +3,20 @@
...
@@ -3,13 +3,20 @@
#include "common.h"
#include "common.h"
#include "DepLibSRTP.h"
#include "DepLibSRTP.h"
#include "RTC/SRTPProfile.h"
#include <srtp/srtp.h>
#include <srtp/srtp.h>
namespace
RTC
namespace
RTC
{
{
class
SRTPSession
class
SRTPSession
{
{
public
:
enum
class
SRTPProfile
{
NONE
=
0
,
AES_CM_128_HMAC_SHA1_80
=
1
,
AES_CM_128_HMAC_SHA1_32
};
public
:
public
:
enum
class
Type
enum
class
Type
{
{
...
@@ -27,7 +34,7 @@ namespace RTC
...
@@ -27,7 +34,7 @@ namespace RTC
static
MS_BYTE
encryptBuffer
[];
static
MS_BYTE
encryptBuffer
[];
public
:
public
:
SRTPSession
(
Type
type
,
RTC
::
SRTPProfile
profile
,
MS_BYTE
*
key
,
size_t
key_len
);
SRTPSession
(
Type
type
,
SRTPProfile
profile
,
MS_BYTE
*
key
,
size_t
key_len
);
~
SRTPSession
();
~
SRTPSession
();
bool
EncryptRTP
(
const
MS_BYTE
**
data
,
size_t
*
len
);
bool
EncryptRTP
(
const
MS_BYTE
**
data
,
size_t
*
len
);
...
...
worker/include/RTC/Transport.h
浏览文件 @
4a22ba54
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
#include "common.h"
#include "common.h"
#include "RTC/IceCandidate.h"
#include "RTC/IceCandidate.h"
#include "RTC/IceServer.h"
#include "RTC/IceServer.h"
#include "RTC/DTLSAgent.h"
#include "RTC/STUNMessage.h"
#include "RTC/STUNMessage.h"
#include "RTC/TransportSource.h"
#include "RTC/TransportSource.h"
#include "RTC/UDPSocket.h"
#include "RTC/UDPSocket.h"
...
...
worker/src/RTC/Peer.cpp
浏览文件 @
4a22ba54
#define MS_CLASS "RTC::Peer"
#define MS_CLASS "RTC::Peer"
#include "RTC/Peer.h"
#include "RTC/Peer.h"
#include "RTC/DTLSRole.h"
#include "MediaSoupError.h"
#include "MediaSoupError.h"
#include "Logger.h"
#include "Logger.h"
...
...
worker/src/RTC/SRTPSession.cpp
浏览文件 @
4a22ba54
...
@@ -56,7 +56,7 @@ namespace RTC
...
@@ -56,7 +56,7 @@ namespace RTC
/* Instance methods. */
/* Instance methods. */
SRTPSession
::
SRTPSession
(
Type
type
,
RTC
::
SRTPProfile
profile
,
MS_BYTE
*
key
,
size_t
key_len
)
SRTPSession
::
SRTPSession
(
Type
type
,
SRTPProfile
profile
,
MS_BYTE
*
key
,
size_t
key_len
)
{
{
MS_TRACE
();
MS_TRACE
();
...
@@ -68,11 +68,11 @@ namespace RTC
...
@@ -68,11 +68,11 @@ namespace RTC
switch
(
profile
)
switch
(
profile
)
{
{
case
RTC
:
:
SRTPProfile
::
AES_CM_128_HMAC_SHA1_80
:
case
SRTPProfile
:
:
AES_CM_128_HMAC_SHA1_80
:
crypto_policy_set_aes_cm_128_hmac_sha1_80
(
&
policy
.
rtp
);
crypto_policy_set_aes_cm_128_hmac_sha1_80
(
&
policy
.
rtp
);
crypto_policy_set_aes_cm_128_hmac_sha1_80
(
&
policy
.
rtcp
);
crypto_policy_set_aes_cm_128_hmac_sha1_80
(
&
policy
.
rtcp
);
break
;
break
;
case
RTC
:
:
SRTPProfile
::
AES_CM_128_HMAC_SHA1_32
:
case
SRTPProfile
:
:
AES_CM_128_HMAC_SHA1_32
:
crypto_policy_set_aes_cm_128_hmac_sha1_32
(
&
policy
.
rtp
);
crypto_policy_set_aes_cm_128_hmac_sha1_32
(
&
policy
.
rtp
);
crypto_policy_set_aes_cm_128_hmac_sha1_80
(
&
policy
.
rtcp
);
// NOTE: Must be 80 for RTCP!.
crypto_policy_set_aes_cm_128_hmac_sha1_80
(
&
policy
.
rtcp
);
// NOTE: Must be 80 for RTCP!.
break
;
break
;
...
...
worker/src/RTC/Transport.cpp
浏览文件 @
4a22ba54
...
@@ -235,24 +235,30 @@ namespace RTC
...
@@ -235,24 +235,30 @@ namespace RTC
static
const
Json
::
StaticString
k_iceLocalCandidates
(
"iceLocalCandidates"
);
static
const
Json
::
StaticString
k_iceLocalCandidates
(
"iceLocalCandidates"
);
static
const
Json
::
StaticString
v_RTP
(
"RTP"
);
static
const
Json
::
StaticString
v_RTP
(
"RTP"
);
static
const
Json
::
StaticString
v_RTCP
(
"RTCP"
);
static
const
Json
::
StaticString
v_RTCP
(
"RTCP"
);
static
const
Json
::
StaticString
k_dtlsLocalFingerprints
(
"dtlsLocalFingerprints"
);
Json
::
Value
data
;
Json
::
Value
data
;
// Add `iceComponent`.
if
(
this
->
iceComponent
==
IceComponent
::
RTP
)
if
(
this
->
iceComponent
==
IceComponent
::
RTP
)
data
[
k_iceComponent
]
=
v_RTP
;
data
[
k_iceComponent
]
=
v_RTP
;
else
else
data
[
k_iceComponent
]
=
v_RTCP
;
data
[
k_iceComponent
]
=
v_RTCP
;
// Add `iceLocalParameters`.
data
[
k_iceLocalParameters
][
k_usernameFragment
]
=
this
->
iceServer
->
GetUsernameFragment
();
data
[
k_iceLocalParameters
][
k_usernameFragment
]
=
this
->
iceServer
->
GetUsernameFragment
();
data
[
k_iceLocalParameters
][
k_password
]
=
this
->
iceServer
->
GetPassword
();
data
[
k_iceLocalParameters
][
k_password
]
=
this
->
iceServer
->
GetPassword
();
// Add `iceLocalCandidates`.
data
[
k_iceLocalCandidates
]
=
Json
::
arrayValue
;
data
[
k_iceLocalCandidates
]
=
Json
::
arrayValue
;
for
(
auto
iceCandidate
:
this
->
iceLocalCandidates
)
for
(
auto
iceCandidate
:
this
->
iceLocalCandidates
)
{
{
data
[
k_iceLocalCandidates
].
append
(
iceCandidate
.
toJson
());
data
[
k_iceLocalCandidates
].
append
(
iceCandidate
.
toJson
());
}
}
// Add `dtlsLocalFingerprints`.
data
[
k_dtlsLocalFingerprints
]
=
RTC
::
DTLSAgent
::
GetLocalFingerprints
();
return
data
;
return
data
;
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论