Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
31909cfc
Unverified
提交
31909cfc
authored
7月 11, 2019
作者:
Iñaki Baz Castillo
提交者:
GitHub
7月 11, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
SRTP: add support for AEAD_AES_256_GCM and AEAD_AES_128_GCM (#322)
上级
3a98f2a9
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
98 行增加
和
21 行删除
+98
-21
SrtpSession.hpp
worker/include/RTC/SrtpSession.hpp
+3
-1
DtlsTransport.cpp
worker/src/RTC/DtlsTransport.cpp
+68
-18
SrtpSession.cpp
worker/src/RTC/SrtpSession.cpp
+27
-2
没有找到文件。
worker/include/RTC/SrtpSession.hpp
浏览文件 @
31909cfc
...
@@ -13,7 +13,9 @@ namespace RTC
...
@@ -13,7 +13,9 @@ namespace RTC
{
{
NONE
=
0
,
NONE
=
0
,
AES_CM_128_HMAC_SHA1_80
=
1
,
AES_CM_128_HMAC_SHA1_80
=
1
,
AES_CM_128_HMAC_SHA1_32
AES_CM_128_HMAC_SHA1_32
,
AEAD_AES_256_GCM
,
AEAD_AES_128_GCM
};
};
public
:
public
:
...
...
worker/src/RTC/DtlsTransport.cpp
浏览文件 @
31909cfc
...
@@ -60,13 +60,21 @@ namespace RTC
...
@@ -60,13 +60,21 @@ namespace RTC
{
{
/* Static. */
/* Static. */
// clang-format off
static
constexpr
int
DtlsMtu
{
1350
};
static
constexpr
int
DtlsMtu
{
1350
};
static
constexpr
int
SslReadBufferSize
{
65536
};
static
constexpr
int
SslReadBufferSize
{
65536
};
// NOTE: Those values are hardcoded as we just use AES_CM_128_HMAC_SHA1_80 and
// AES-HMAC: http://tools.ietf.org/html/rfc3711
// AES_CM_128_HMAC_SHA1_32 which share same length values for key and salt.
static
constexpr
size_t
SrtpMasterKeyLength
{
16
};
static
constexpr
size_t
SrtpMasterKeyLength
{
16
};
static
constexpr
size_t
SrtpMasterSaltLength
{
14
};
static
constexpr
size_t
SrtpMasterSaltLength
{
14
};
static
constexpr
size_t
SrtpMasterLength
{
SrtpMasterKeyLength
+
SrtpMasterSaltLength
};
static
constexpr
size_t
SrtpMasterLength
{
SrtpMasterKeyLength
+
SrtpMasterSaltLength
};
// AES-GCM: http://tools.ietf.org/html/rfc7714
static
constexpr
size_t
SrtpAesGcm256MasterKeyLength
{
32
};
static
constexpr
size_t
SrtpAesGcm256MasterSaltLength
{
12
};
static
constexpr
size_t
SrtpAesGcm256MasterLength
{
SrtpAesGcm256MasterKeyLength
+
SrtpAesGcm256MasterSaltLength
};
static
constexpr
size_t
SrtpAesGcm128MasterKeyLength
{
16
};
static
constexpr
size_t
SrtpAesGcm128MasterSaltLength
{
12
};
static
constexpr
size_t
SrtpAesGcm128MasterLength
{
SrtpAesGcm128MasterKeyLength
+
SrtpAesGcm128MasterSaltLength
};
// clang-format on
/* Class variables. */
/* Class variables. */
...
@@ -102,6 +110,8 @@ namespace RTC
...
@@ -102,6 +110,8 @@ namespace RTC
// clang-format off
// clang-format off
std
::
vector
<
DtlsTransport
::
SrtpProfileMapEntry
>
DtlsTransport
::
srtpProfiles
=
std
::
vector
<
DtlsTransport
::
SrtpProfileMapEntry
>
DtlsTransport
::
srtpProfiles
=
{
{
{
RTC
::
SrtpSession
::
Profile
::
AEAD_AES_256_GCM
,
"SRTP_AEAD_AES_256_GCM"
},
{
RTC
::
SrtpSession
::
Profile
::
AEAD_AES_128_GCM
,
"SRTP_AEAD_AES_128_GCM"
},
{
RTC
::
SrtpSession
::
Profile
::
AES_CM_128_HMAC_SHA1_80
,
"SRTP_AES128_CM_SHA1_80"
},
{
RTC
::
SrtpSession
::
Profile
::
AES_CM_128_HMAC_SHA1_80
,
"SRTP_AES128_CM_SHA1_80"
},
{
RTC
::
SrtpSession
::
Profile
::
AES_CM_128_HMAC_SHA1_32
,
"SRTP_AES128_CM_SHA1_32"
}
{
RTC
::
SrtpSession
::
Profile
::
AES_CM_128_HMAC_SHA1_32
,
"SRTP_AES128_CM_SHA1_32"
}
};
};
...
@@ -1226,17 +1236,57 @@ namespace RTC
...
@@ -1226,17 +1236,57 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
uint8_t
srtpMaterial
[
SrtpMasterLength
*
2
];
size_t
srtpKeyLength
{
0
};
size_t
srtpSaltLength
{
0
};
size_t
srtpMasterLength
{
0
};
switch
(
srtpProfile
)
{
case
RTC
:
:
SrtpSession
::
Profile
::
AES_CM_128_HMAC_SHA1_80
:
case
RTC
:
:
SrtpSession
::
Profile
::
AES_CM_128_HMAC_SHA1_32
:
{
srtpKeyLength
=
SrtpMasterKeyLength
;
srtpSaltLength
=
SrtpMasterSaltLength
;
srtpMasterLength
=
SrtpMasterLength
;
break
;
}
case
RTC
:
:
SrtpSession
::
Profile
::
AEAD_AES_256_GCM
:
{
srtpKeyLength
=
SrtpAesGcm256MasterKeyLength
;
srtpSaltLength
=
SrtpAesGcm256MasterSaltLength
;
srtpMasterLength
=
SrtpAesGcm256MasterLength
;
break
;
}
case
RTC
:
:
SrtpSession
::
Profile
::
AEAD_AES_128_GCM
:
{
srtpKeyLength
=
SrtpAesGcm128MasterKeyLength
;
srtpSaltLength
=
SrtpAesGcm128MasterSaltLength
;
srtpMasterLength
=
SrtpAesGcm128MasterLength
;
break
;
}
default
:
{
MS_ABORT
(
"unknown SRTP profile"
);
}
}
uint8_t
srtpMaterial
[
srtpMasterLength
*
2
];
uint8_t
*
srtpLocalKey
;
uint8_t
*
srtpLocalKey
;
uint8_t
*
srtpLocalSalt
;
uint8_t
*
srtpLocalSalt
;
uint8_t
*
srtpRemoteKey
;
uint8_t
*
srtpRemoteKey
;
uint8_t
*
srtpRemoteSalt
;
uint8_t
*
srtpRemoteSalt
;
uint8_t
srtpLocalMasterKey
[
S
rtpMasterLength
];
uint8_t
srtpLocalMasterKey
[
s
rtpMasterLength
];
uint8_t
srtpRemoteMasterKey
[
S
rtpMasterLength
];
uint8_t
srtpRemoteMasterKey
[
s
rtpMasterLength
];
int
ret
;
int
ret
;
ret
=
SSL_export_keying_material
(
ret
=
SSL_export_keying_material
(
this
->
ssl
,
srtpMaterial
,
S
rtpMasterLength
*
2
,
"EXTRACTOR-dtls_srtp"
,
19
,
nullptr
,
0
,
0
);
this
->
ssl
,
srtpMaterial
,
s
rtpMasterLength
*
2
,
"EXTRACTOR-dtls_srtp"
,
19
,
nullptr
,
0
,
0
);
MS_ASSERT
(
ret
!=
0
,
"SSL_export_keying_material() failed"
);
MS_ASSERT
(
ret
!=
0
,
"SSL_export_keying_material() failed"
);
...
@@ -1245,9 +1295,9 @@ namespace RTC
...
@@ -1245,9 +1295,9 @@ namespace RTC
case
Role
:
:
SERVER
:
case
Role
:
:
SERVER
:
{
{
srtpRemoteKey
=
srtpMaterial
;
srtpRemoteKey
=
srtpMaterial
;
srtpLocalKey
=
srtpRemoteKey
+
SrtpMaster
KeyLength
;
srtpLocalKey
=
srtpRemoteKey
+
srtp
KeyLength
;
srtpRemoteSalt
=
srtpLocalKey
+
SrtpMaster
KeyLength
;
srtpRemoteSalt
=
srtpLocalKey
+
srtp
KeyLength
;
srtpLocalSalt
=
srtpRemoteSalt
+
SrtpMaster
SaltLength
;
srtpLocalSalt
=
srtpRemoteSalt
+
srtp
SaltLength
;
break
;
break
;
}
}
...
@@ -1255,9 +1305,9 @@ namespace RTC
...
@@ -1255,9 +1305,9 @@ namespace RTC
case
Role
:
:
CLIENT
:
case
Role
:
:
CLIENT
:
{
{
srtpLocalKey
=
srtpMaterial
;
srtpLocalKey
=
srtpMaterial
;
srtpRemoteKey
=
srtpLocalKey
+
SrtpMaster
KeyLength
;
srtpRemoteKey
=
srtpLocalKey
+
srtp
KeyLength
;
srtpLocalSalt
=
srtpRemoteKey
+
SrtpMaster
KeyLength
;
srtpLocalSalt
=
srtpRemoteKey
+
srtp
KeyLength
;
srtpRemoteSalt
=
srtpLocalSalt
+
SrtpMaster
SaltLength
;
srtpRemoteSalt
=
srtpLocalSalt
+
srtp
SaltLength
;
break
;
break
;
}
}
...
@@ -1269,11 +1319,11 @@ namespace RTC
...
@@ -1269,11 +1319,11 @@ namespace RTC
}
}
// Create the SRTP local master key.
// Create the SRTP local master key.
std
::
memcpy
(
srtpLocalMasterKey
,
srtpLocalKey
,
SrtpMaster
KeyLength
);
std
::
memcpy
(
srtpLocalMasterKey
,
srtpLocalKey
,
srtp
KeyLength
);
std
::
memcpy
(
srtpLocalMasterKey
+
SrtpMasterKeyLength
,
srtpLocalSalt
,
SrtpMaster
SaltLength
);
std
::
memcpy
(
srtpLocalMasterKey
+
srtpKeyLength
,
srtpLocalSalt
,
srtp
SaltLength
);
// Create the SRTP remote master key.
// Create the SRTP remote master key.
std
::
memcpy
(
srtpRemoteMasterKey
,
srtpRemoteKey
,
SrtpMaster
KeyLength
);
std
::
memcpy
(
srtpRemoteMasterKey
,
srtpRemoteKey
,
srtp
KeyLength
);
std
::
memcpy
(
srtpRemoteMasterKey
+
SrtpMasterKeyLength
,
srtpRemoteSalt
,
SrtpMaster
SaltLength
);
std
::
memcpy
(
srtpRemoteMasterKey
+
srtpKeyLength
,
srtpRemoteSalt
,
srtp
SaltLength
);
// Set state and notify the listener.
// Set state and notify the listener.
this
->
state
=
DtlsState
::
CONNECTED
;
this
->
state
=
DtlsState
::
CONNECTED
;
...
@@ -1281,9 +1331,9 @@ namespace RTC
...
@@ -1281,9 +1331,9 @@ namespace RTC
this
,
this
,
srtpProfile
,
srtpProfile
,
srtpLocalMasterKey
,
srtpLocalMasterKey
,
S
rtpMasterLength
,
s
rtpMasterLength
,
srtpRemoteMasterKey
,
srtpRemoteMasterKey
,
S
rtpMasterLength
,
s
rtpMasterLength
,
this
->
remoteCert
);
this
->
remoteCert
);
}
}
...
...
worker/src/RTC/SrtpSession.cpp
浏览文件 @
31909cfc
...
@@ -66,17 +66,42 @@ namespace RTC
...
@@ -66,17 +66,42 @@ namespace RTC
switch
(
profile
)
switch
(
profile
)
{
{
case
Profile
:
:
AES_CM_128_HMAC_SHA1_80
:
case
Profile
:
:
AES_CM_128_HMAC_SHA1_80
:
{
srtp_crypto_policy_set_aes_cm_128_hmac_sha1_80
(
&
policy
.
rtp
);
srtp_crypto_policy_set_aes_cm_128_hmac_sha1_80
(
&
policy
.
rtp
);
srtp_crypto_policy_set_aes_cm_128_hmac_sha1_80
(
&
policy
.
rtcp
);
srtp_crypto_policy_set_aes_cm_128_hmac_sha1_80
(
&
policy
.
rtcp
);
break
;
break
;
}
case
Profile
:
:
AES_CM_128_HMAC_SHA1_32
:
case
Profile
:
:
AES_CM_128_HMAC_SHA1_32
:
{
srtp_crypto_policy_set_aes_cm_128_hmac_sha1_32
(
&
policy
.
rtp
);
srtp_crypto_policy_set_aes_cm_128_hmac_sha1_32
(
&
policy
.
rtp
);
srtp_crypto_policy_set_aes_cm_128_hmac_sha1_80
(
&
policy
.
rtcp
);
// NOTE: Must be 80 for RTCP!.
// NOTE: Must be 80 for RTCP.
srtp_crypto_policy_set_aes_cm_128_hmac_sha1_80
(
&
policy
.
rtcp
);
break
;
break
;
}
case
Profile
:
:
AEAD_AES_256_GCM
:
{
srtp_crypto_policy_set_aes_gcm_256_16_auth
(
&
policy
.
rtp
);
srtp_crypto_policy_set_aes_gcm_256_16_auth
(
&
policy
.
rtcp
);
break
;
}
case
Profile
:
:
AEAD_AES_128_GCM
:
{
srtp_crypto_policy_set_aes_gcm_128_16_auth
(
&
policy
.
rtp
);
srtp_crypto_policy_set_aes_gcm_128_16_auth
(
&
policy
.
rtcp
);
break
;
}
default
:
default
:
MS_ABORT
(
"unknown SRTP suite"
);
{
MS_ABORT
(
"unknown SRTP profile"
);
}
}
}
MS_ASSERT
(
MS_ASSERT
(
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论