webRTC - 正确使用SIP并寻求Python库

问题描述 投票:0回答:1

我正在尝试使用DTLS和SIP完成握手。该网站[0]告诉我,我需要向传入请求发送SIP响应,该响应包含我的SDP文件和用于完成DTLS握手的指纹。我目前正在使用客户端< - >服务器模型。客户端正在请求呼叫,我已经有RTP数据包,但是我需要在建立连接时将它们发送回客户端。我很难建立连接。

为了参考DTLS握手,我有一个我所指的数据包的截图,我在使用webRTC库的浏览器浏览器调用期间使用wireshark找到了这些数据包。 https://imgur.com/a/00bi7

我在哪里可以找到用于这些目的的好的python库?

1 ) Setup the DTLS handshake and encrypt my RTP packets to SRTP?

[0] https://tools.ietf.org/html/rfc5763

python webrtc sip rtp dtls
1个回答
0
投票

对于实际的SRTP加密/解密,您可以使用pylibsrtp:

https://pypi.python.org/pypi/pylibsrtp

DTLS握手(生成SRTP主密钥)比较棘手,但是pyOpenSSL很快就会有必要的绑定来启用SRTP扩展:

https://github.com/pyca/pyopenssl/pull/734

一旦可用,您将能够提取生成密钥材料,如下所示:

SRTP_KEY_LEN = 16
SRTP_SALT_LEN = 14

def get_srtp_key_salt(src, idx):
    key_start = idx * SRTP_KEY_LEN
    salt_start = 2 * SRTP_KEY_LEN + idx * SRTP_SALT_LEN
    return (
        src[key_start:key_start + SRTP_KEY_LEN] +
        src[salt_start:salt_start + SRTP_SALT_LEN]
    )

material = connection.export_keying_material(
    b'EXTRACTOR-dtls_srtp',
    2 * (SRTP_KEY_LEN + SRTP_SALT_LEN))

if is_server:
    srtp_tx_key = get_srtp_key_salt(material, 1)
    srtp_rx_key = get_srtp_key_salt(material, 0)
else:
    srtp_tx_key = get_srtp_key_salt(material, 0)
    srtp_rx_key = get_srtp_key_salt(material, 1)
© www.soinside.com 2019 - 2024. All rights reserved.