| 1 |
Metadata-Version: 2.4 |
| 2 |
Name: pylibsrtp |
| 3 |
Version: 0.12.0 |
| 4 |
Summary: Python wrapper around the libsrtp library |
| 5 |
Author-email: Jeremy Lainé <[email protected]> |
| 6 |
License: BSD-3-Clause |
| 7 |
Project-URL: homepage, https://github.com/aiortc/pylibsrtp |
| 8 |
Project-URL: documentation, https://pylibsrtp.readthedocs.io/ |
| 9 |
Classifier: Development Status :: 5 - Production/Stable |
| 10 |
Classifier: Intended Audience :: Developers |
| 11 |
Classifier: License :: OSI Approved :: BSD License |
| 12 |
Classifier: Operating System :: OS Independent |
| 13 |
Classifier: Programming Language :: Python |
| 14 |
Classifier: Programming Language :: Python :: 3 |
| 15 |
Classifier: Programming Language :: Python :: 3.9 |
| 16 |
Classifier: Programming Language :: Python :: 3.10 |
| 17 |
Classifier: Programming Language :: Python :: 3.11 |
| 18 |
Classifier: Programming Language :: Python :: 3.12 |
| 19 |
Classifier: Programming Language :: Python :: 3.13 |
| 20 |
Classifier: Topic :: Communications :: Telephony |
| 21 |
Classifier: Topic :: Security :: Cryptography |
| 22 |
Requires-Python: >=3.9 |
| 23 |
Description-Content-Type: text/x-rst |
| 24 |
License-File: LICENSE |
| 25 |
Requires-Dist: cffi>=1.0.0 |
| 26 |
Provides-Extra: dev |
| 27 |
Requires-Dist: coverage[toml]>=7.2.2; extra == "dev" |
| 28 |
Dynamic: license-file |
| 29 |
|
| 30 |
pylibsrtp |
| 31 |
========= |
| 32 |
|
| 33 |
.. image:: https://img.shields.io/pypi/l/pylibsrtp.svg |
| 34 |
:target: https://pypi.python.org/pypi/pylibsrtp |
| 35 |
:alt: License |
| 36 |
|
| 37 |
.. image:: https://img.shields.io/pypi/v/pylibsrtp.svg |
| 38 |
:target: https://pypi.python.org/pypi/pylibsrtp |
| 39 |
:alt: Version |
| 40 |
|
| 41 |
.. image:: https://img.shields.io/pypi/pyversions/pylibsrtp.svg |
| 42 |
:target: https://pypi.python.org/pypi/pylibsrtp |
| 43 |
:alt: Python versions |
| 44 |
|
| 45 |
.. image:: https://github.com/aiortc/pylibsrtp/workflows/tests/badge.svg |
| 46 |
:target: https://github.com/aiortc/pylibsrtp/actions |
| 47 |
:alt: Tests |
| 48 |
|
| 49 |
.. image:: https://img.shields.io/codecov/c/github/aiortc/pylibsrtp.svg |
| 50 |
:target: https://codecov.io/gh/aiortc/pylibsrtp |
| 51 |
:alt: Coverage |
| 52 |
|
| 53 |
.. image:: https://readthedocs.org/projects/pylibsrtp/badge/?version=latest |
| 54 |
:target: https://pylibsrtp.readthedocs.io/ |
| 55 |
:alt: Documentation |
| 56 |
|
| 57 |
What is ``pylibsrtp``? |
| 58 |
---------------------- |
| 59 |
|
| 60 |
``pylibsrtp`` is a Python wrapper around `libsrtp`_, making it possible to |
| 61 |
encrypt and decrypt Secure Real-time Transport Protocol (SRTP) packets from |
| 62 |
Python code. |
| 63 |
|
| 64 |
SRTP is a profile of the Real-time Transport Protocol (RTP) which provides |
| 65 |
confidentiality, message authentication, and replay protection. It is defined |
| 66 |
by `RFC 3711`_. |
| 67 |
|
| 68 |
You can install ``pylibsrtp`` with ``pip``: |
| 69 |
|
| 70 |
.. code-block:: console |
| 71 |
|
| 72 |
$ pip install pylibsrtp |
| 73 |
|
| 74 |
To learn more about ``pylibsrtp`` please `read the documentation`_. |
| 75 |
|
| 76 |
.. _libsrtp: https://github.com/cisco/libsrtp |
| 77 |
|
| 78 |
.. _RFC 3711: https://tools.ietf.org/html/rfc3711 |
| 79 |
|
| 80 |
.. _read the documentation: https://pylibsrtp.readthedocs.io/en/stable/ |
| 81 |
|
| 82 |
Example |
| 83 |
------- |
| 84 |
|
| 85 |
.. code:: python |
| 86 |
|
| 87 |
#!/usr/bin/env python |
| 88 |
|
| 89 |
from pylibsrtp import Policy, Session |
| 90 |
|
| 91 |
key = (b'\x00' * 30) |
| 92 |
rtp = b'\x80\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' + (b'\xd4' * 160) |
| 93 |
|
| 94 |
# protect RTP |
| 95 |
tx_policy = Policy(key=key, ssrc_type=Policy.SSRC_ANY_OUTBOUND) |
| 96 |
tx_session = Session(policy=tx_policy) |
| 97 |
srtp = tx_session.protect(rtp) |
| 98 |
|
| 99 |
# unprotect RTP |
| 100 |
rx_policy = Policy(key=key, ssrc_type=Policy.SSRC_ANY_INBOUND) |
| 101 |
rx_session = Session(policy=rx_policy) |
| 102 |
rtp2 = rx_session.unprotect(srtp) |
| 103 |
|
| 104 |
# check roundtrip worked! |
| 105 |
assert rtp2 == rtp |
| 106 |
|
| 107 |
Building pylibsrtp |
| 108 |
------------------ |
| 109 |
|
| 110 |
If you wish to build pylibsrtp yourself, you will need libsrtp version 2.0 or better. |
| 111 |
|
| 112 |
Linux |
| 113 |
..... |
| 114 |
|
| 115 |
On Debian/Ubuntu run: |
| 116 |
|
| 117 |
.. code-block:: console |
| 118 |
|
| 119 |
$ apt install libsrtp2-dev |
| 120 |
|
| 121 |
On Fedora/CentOS run: |
| 122 |
|
| 123 |
.. code-block:: console |
| 124 |
|
| 125 |
$ dnf install libsrtp-devel |
| 126 |
|
| 127 |
macOS |
| 128 |
..... |
| 129 |
|
| 130 |
On macOS run: |
| 131 |
|
| 132 |
.. code-block:: console |
| 133 |
|
| 134 |
$ brew install srtp |
| 135 |
|
| 136 |
You will need to set some environment variables to link against libsrtp: |
| 137 |
|
| 138 |
.. code-block:: console |
| 139 |
|
| 140 |
export CFLAGS=-I$(brew --prefix openssl)/include -I$(brew --prefix srtp)/include |
| 141 |
export LDFLAGS=-L$(brew --prefix openssl)/lib -L$(brew --prefix srtp)/lib |
| 142 |
|
| 143 |
License |
| 144 |
------- |
| 145 |
|
| 146 |
``pylibsrtp`` is released under the `BSD license`_. |
| 147 |
|
| 148 |
.. _BSD license: https://pylibsrtp.readthedocs.io/en/stable/license.html |