Repository: pion/dtls
Pull request #273 (2020-07-15 23:32:51)

Add AEAD_AES_128_GCM SRTP Profiles
Relates to pion/srtp#85


Sean-Der: I couldn't find any docs on client (or server) preference for SRTP protection profile. I just added a test to make sure the current behavior never changes unexpectedly.
codecov[bot]: # [Codecov](https://codecov.io/gh/pion/dtls/pull/273?src=pr&el=h1) Report
> Merging [#273](https://codecov.io/gh/pion/dtls/pull/273?src=pr&el=desc) into [master](https://codecov.io/gh/pion/dtls/commit/66552a52774dd30cbf7cb0e1048106d14d430a3a&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/pion/dtls/pull/273/graphs/tree.svg?width=650&height=150&src=pr&token=bcCB2jB88I)](https://codecov.io/gh/pion/dtls/pull/273?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master     #273   +/-   ##
=======================================
  Coverage   77.43%   77.43%           
=======================================
  Files          75       75           
  Lines        3944     3944           
=======================================
  Hits         3054     3054           
  Misses        609      609           
  Partials      281      281           
```

| Flag | Coverage Δ | |
|---|---|---|
| #go | `77.47% <ø> (ø)` | |
| #wasm | `75.07% <ø> (ø)` | |


------

[Continue to review full report at Codecov](https://codecov.io/gh/pion/dtls/pull/273?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pion/dtls/pull/273?src=pr&el=footer). Last update [66552a5...71d9947](https://codecov.io/gh/pion/dtls/pull/273?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/srtp_protection_profile.go b/srtp_protection_profile.go
index 3ae3c28..7443519 100644
--- a/srtp_protection_profile.go
+++ b/srtp_protection_profile.go
@@ -6,8 +6,14 @@ type SRTPProtectionProfile uint16
 
 const (
 	SRTP_AES128_CM_HMAC_SHA1_80 SRTPProtectionProfile = 0x0001 // nolint
+	SRTP_AES128_CM_HMAC_SHA1_32 SRTPProtectionProfile = 0x0002 // nolint
+	SRTP_AEAD_AES_128_GCM       SRTPProtectionProfile = 0x0007 // nolint
+	SRTP_AEAD_AES_256_GCM       SRTPProtectionProfile = 0x0008 // nolint
 )
 
 var srtpProtectionProfiles = map[SRTPProtectionProfile]bool{
 	SRTP_AES128_CM_HMAC_SHA1_80: true,
+	SRTP_AES128_CM_HMAC_SHA1_32: true,
+	SRTP_AEAD_AES_128_GCM:       true,
+	SRTP_AEAD_AES_256_GCM:       true,
 }


Test patch:
diff --git a/conn_test.go b/conn_test.go
index 4da395a..ceb9dde 100644
--- a/conn_test.go
+++ b/conn_test.go
@@ -605,6 +605,22 @@ func TestSRTPConfiguration(t *testing.T) {
 			WantClientError: nil,
 			WantServerError: nil,
 		},
+		{
+			Name:            "Multiple Suites",
+			ClientSRTP:      []SRTPProtectionProfile{SRTP_AES128_CM_HMAC_SHA1_80, SRTP_AES128_CM_HMAC_SHA1_32},
+			ServerSRTP:      []SRTPProtectionProfile{SRTP_AES128_CM_HMAC_SHA1_80, SRTP_AES128_CM_HMAC_SHA1_32},
+			ExpectedProfile: SRTP_AES128_CM_HMAC_SHA1_80,
+			WantClientError: nil,
+			WantServerError: nil,
+		},
+		{
+			Name:            "Multiple Suites, Client Chooses",
+			ClientSRTP:      []SRTPProtectionProfile{SRTP_AES128_CM_HMAC_SHA1_80, SRTP_AES128_CM_HMAC_SHA1_32},
+			ServerSRTP:      []SRTPProtectionProfile{SRTP_AES128_CM_HMAC_SHA1_32, SRTP_AES128_CM_HMAC_SHA1_80},
+			ExpectedProfile: SRTP_AES128_CM_HMAC_SHA1_80,
+			WantClientError: nil,
+			WantServerError: nil,
+		},
 	} {
 		ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
 		defer cancel()