@@ -86,22 +86,21 @@ defmodule ExSRTPTest do
8686 end
8787
8888 describe "protect rtcp" do
89- test "Erlnag backend" , % { srtp: srtp , compound_packet: compound_packet } do
89+ setup do
9090 expected =
9191 << 128 , 200 , 0 , 6 , 137 , 161 , 255 , 135 , 235 , 3 , 169 , 113 , 236 , 134 , 217 , 36 , 127 , 210 , 78 ,
9292 156 , 66 , 244 , 203 , 218 , 58 , 80 , 24 , 60 , 28 , 171 , 30 , 89 , 192 , 155 , 19 , 59 , 128 , 0 , 0 , 1 ,
9393 139 , 226 , 152 , 17 , 40 , 71 , 251 , 110 , 11 , 235 >>
9494
95+ { :ok , expected: expected }
96+ end
97+
98+ test "Erlnag backend" , % { srtp: srtp , compound_packet: compound_packet , expected: expected } do
9599 assert { :ok , ^ expected , _srtp } = ExSRTP . protect_rtcp ( compound_packet , srtp )
96100 assert { ^ expected , _srtp } = ExSRTP . protect_rtcp! ( compound_packet , srtp )
97101 end
98102
99- test "Rust backend" , % { rust_srtp: srtp , compound_packet: compound_packet } do
100- expected =
101- << 128 , 200 , 0 , 6 , 137 , 161 , 255 , 135 , 235 , 3 , 169 , 113 , 236 , 134 , 217 , 36 , 127 , 210 , 78 ,
102- 156 , 66 , 244 , 203 , 218 , 58 , 80 , 24 , 60 , 28 , 171 , 30 , 89 , 192 , 155 , 19 , 59 , 128 , 0 , 0 , 1 ,
103- 139 , 226 , 152 , 17 , 40 , 71 , 251 , 110 , 11 , 235 >>
104-
103+ test "Rust backend" , % { rust_srtp: srtp , compound_packet: compound_packet , expected: expected } do
105104 assert { :ok , ^ expected , _srtp } = RustCrypto . protect_rtcp ( compound_packet , srtp )
106105 end
107106 end
@@ -137,6 +136,15 @@ defmodule ExSRTPTest do
137136 assert { :ok , ^ packet , srtp } = RustCrypto . unprotect ( protected_packet , srtp )
138137 assert { :error , :replay } = RustCrypto . unprotect ( protected_packet , srtp )
139138 end
139+
140+ test "authentication failed" , % { srtp: srtp , rust_srtp: rust_srtp } do
141+ packet =
142+ << 128 , 96 , 0 , 1 , 0 , 1 , 226 , 64 , 137 , 161 , 255 , 135 , 146 , 221 , 94 , 142 , 7 , 197 , 169 , 172 ,
143+ 155 , 23 , 74 , 128 , 181 , 142 , 46 >>
144+
145+ assert { :error , :authentication_failed } = ExSRTP . unprotect ( packet , srtp )
146+ assert { :error , :authentication_failed } = RustCrypto . unprotect ( packet , rust_srtp )
147+ end
140148 end
141149
142150 describe "unprotect rtcp" do
@@ -185,6 +193,18 @@ defmodule ExSRTPTest do
185193 ExSRTP . unprotect_rtcp! ( protected_rtcp , srtp )
186194 end
187195 end
196+
197+ test "authentication failed" , % { srtp: srtp , rust_srtp: rust_srtp } do
198+ protected_rtcp =
199+ << 128 , 200 , 0 , 6 , 137 , 161 , 255 , 135 , 235 , 3 , 169 , 113 , 236 , 134 , 217 , 36 , 127 , 210 , 78 ,
200+ 156 , 66 , 244 , 203 , 218 , 58 , 80 , 24 , 60 , 28 , 171 , 30 , 89 , 192 , 155 , 19 , 59 , 128 , 0 , 0 , 1 ,
201+ 139 , 226 , 152 , 17 , 40 , 70 , 251 , 110 , 11 , 235 >>
202+
203+ assert { :error , :authentication_failed } = ExSRTP . unprotect_rtcp ( protected_rtcp , srtp )
204+
205+ assert { :error , :authentication_failed } =
206+ RustCrypto . unprotect_rtcp ( protected_rtcp , rust_srtp )
207+ end
188208 end
189209
190210 for profile <- [ :aes_cm_128_hmac_sha1_80 , :aes_cm_128_hmac_sha1_32 , :aes_gcm_128_16_auth ] do
0 commit comments