Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Elixir CI

on:
push:
branches:
- master
pull_request:

env:
MIX_ENV: test
EXSRTP_BUILD: true

jobs:
test:
strategy:
matrix:
include:
- otp_version: 25.3
elixir_version: 1.15

- otp_version: 27.2
elixir_version: 1.18
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: erlef/setup-beam@v1
with:
elixir-version: ${{ matrix.elixir_version }}
otp-version: ${{ matrix.otp_version }}

- name: Install dependencies
run: mix deps.get
- name: Run tests
run: mix test --warnings-as-errors
- name: Run Credo
run: mix credo --strict

format:
runs-on: ubuntu-latest
name: mix format
steps:
- uses: actions/checkout@v4
- uses: erlef/setup-beam@v1
with:
otp-version: 27.2
elixir-version: 1.18
- run: mix deps.get
- run: mix format --check-formatted
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,10 @@ The library supports multiple backends for cryptographic operations:
For the rust backend, we offer precompiled NIFs for various platforms, so if your platform is supported, you can use the rust backend without needing to compile anything. However, if your platform is not supported or you want to compile from source, you need to have the rust toolchain installed on your system. You need aslo to add `rustler` dependency and set force build config:

```elixir
{:ex_srtp, "~> 0.4.0", system_env: %{"EXSRTP_BUILD" => "1"}}
{:rustler, "~> 0.37.0"}
```

```elixir
config :rust_precompiled, :force_build, ex_srtp: true
```

### Rust Backend and AES-GCM
The rust backend is using [graviola](https://github.com/ctz/graviola) for aes-gcm which only works on `aarch64` and `x86_64` architecture with some CPU features. If you are using an older CPU or different architecture, you should use the `elixir` backend or do not use AES_GCM crypto profile.

Expand Down
1 change: 1 addition & 0 deletions lib/ex_srtp/backend/rust_crypto.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ defmodule ExSRTP.Backend.RustCrypto.Native do
crate: "ex_srtp",
base_url: "https://github.com/elixir-streaming/ex_srtp/releases/download/v#{version}",
version: version,
force_build: System.get_env("EXSRTP_BUILD") in ["1", "true"],
targets: ~w(
aarch64-apple-darwin
aarch64-unknown-linux-gnu
Expand Down
1 change: 1 addition & 0 deletions lib/ex_srtp/cipher/aes_gcm.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
defmodule ExSRTP.Cipher.AesGcm do
@moduledoc """
An `ExSRTP.Cipher` implementation using AES-GCM (as per RFC 7714).
"""

import Bitwise
Expand Down
3 changes: 2 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ defmodule ExSRTP.MixProject do
{:ex_rtcp, "~> 0.4.0"},
{:rustler, "~> 0.37", runtime: false, optional: true},
{:rustler_precompiled, "~> 0.8"},
{:ex_doc, "~> 0.30", only: :dev, runtime: false}
{:ex_doc, "~> 0.30", only: :dev, runtime: false},
{:credo, "~> 1.7", only: [:dev, :test], runtime: false}
]
end

Expand Down
3 changes: 3 additions & 0 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
%{
"bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"},
"castore": {:hex, :castore, "1.0.17", "4f9770d2d45fbd91dcf6bd404cf64e7e58fed04fadda0923dc32acca0badffa2", [:mix], [], "hexpm", "12d24b9d80b910dd3953e165636d68f147a31db945d2dcb9365e441f8b5351e5"},
"credo": {:hex, :credo, "1.7.15", "283da72eeb2fd3ccf7248f4941a0527efb97afa224bcdef30b4b580bc8258e1c", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "291e8645ea3fea7481829f1e1eb0881b8395db212821338e577a90bf225c5607"},
"earmark_parser": {:hex, :earmark_parser, "1.4.44", "f20830dd6b5c77afe2b063777ddbbff09f9759396500cdbe7523efd58d7a339c", [:mix], [], "hexpm", "4778ac752b4701a5599215f7030989c989ffdc4f6df457c5f36938cc2d2a2750"},
"ex_doc": {:hex, :ex_doc, "0.39.3", "519c6bc7e84a2918b737aec7ef48b96aa4698342927d080437f61395d361dcee", [:mix], [{:earmark_parser, "~> 1.4.44", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "0590955cf7ad3b625780ee1c1ea627c28a78948c6c0a9b0322bd976a079996e1"},
"ex_rtcp": {:hex, :ex_rtcp, "0.4.0", "f9e515462a9581798ff6413583a25174cfd2101c94a2ebee871cca7639886f0a", [:mix], [], "hexpm", "28956602cf210d692fcdaf3f60ca49681634e1deb28ace41246aee61ee22dc3b"},
"ex_rtp": {:hex, :ex_rtp, "0.4.0", "1f1b5c1440a904706011e3afbb41741f5da309ce251cb986690ce9fd82636658", [:mix], [], "hexpm", "0f72d80d5953a62057270040f0f1ee6f955c08eeae82ac659c038001d7d5a790"},
"file_system": {:hex, :file_system, "1.1.1", "31864f4685b0148f25bd3fbef2b1228457c0c89024ad67f7a81a3ffbc0bbad3a", [:mix], [], "hexpm", "7a15ff97dfe526aeefb090a7a9d3d03aa907e100e262a0f8f7746b78f8f87a5d"},
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},
"makeup": {:hex, :makeup, "1.2.1", "e90ac1c65589ef354378def3ba19d401e739ee7ee06fb47f94c687016e3713d1", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "d36484867b0bae0fea568d10131197a4c2e47056a6fbe84922bf6ba71c8d17ce"},
"makeup_elixir": {:hex, :makeup_elixir, "1.0.1", "e928a4f984e795e41e3abd27bfc09f51db16ab8ba1aebdba2b3a575437efafc2", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "7284900d412a3e5cfd97fdaed4f5ed389b8f2b4cb49efc0eb3bd10e2febf9507"},
Expand Down
8 changes: 3 additions & 5 deletions test/ex_srtp_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,7 @@ defmodule ExSRTPTest do
156, 66, 244, 203, 218, 58, 80, 24, 60, 28, 171, 30, 89, 192, 155, 19, 59, 128, 0, 0, 1,
139, 226, 152, 17, 40, 71, 251, 110, 11, 235>>

assert {:ok, unprotected_packets, _srtp} =
ExSRTP.Backend.RustCrypto.unprotect_rtcp(protected_rtcp, srtp)

assert {:ok, unprotected_packets, _srtp} = RustCrypto.unprotect_rtcp(protected_rtcp, srtp)
assert unprotected_packets == packets
end

Expand Down Expand Up @@ -280,7 +278,7 @@ defmodule ExSRTPTest do
end

test "protect and unprotect", %{srtp: srtp, rust_srtp: rust_srtp} do
original_packets = packets(10000)
original_packets = packets(10_000)

{encrypted_packets, rust_srtp} =
Enum.map_reduce(original_packets, rust_srtp, fn pkt, srtp ->
Expand Down Expand Up @@ -388,7 +386,7 @@ defmodule ExSRTPTest do
|> Enum.take(size)
end

defp rand_payload() do
defp rand_payload do
len = :rand.uniform(1000) + 500
:crypto.strong_rand_bytes(len)
end
Expand Down
Loading