Skip to content

Commit 06b4e89

Browse files
authored
Added WithDTLSEllipticCurves ConnectOption for FIPS (#869)
1 parent fbcb73e commit 06b4e89

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

engine.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ func (e *RTCEngine) createPublisherPCLocked(configuration webrtc.Configuration)
350350
IncludeDefaultInterceptors: e.connParams.IncludeDefaultInterceptors,
351351
OnRTTUpdate: e.setRTT,
352352
IsSender: true,
353+
DTLSEllipticCurves: e.connParams.DTLSEllipticCurves,
353354
}); err != nil {
354355
return err
355356
}
@@ -435,6 +436,7 @@ func (e *RTCEngine) createSubscriberPCLocked(configuration webrtc.Configuration)
435436
RetransmitBufferSize: e.connParams.RetransmitBufferSize,
436437
Interceptors: e.connParams.Interceptors,
437438
IncludeDefaultInterceptors: e.connParams.IncludeDefaultInterceptors,
439+
DTLSEllipticCurves: e.connParams.DTLSEllipticCurves,
438440
}); err != nil {
439441
return err
440442
}

room.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ import (
4040
"github.com/livekit/protocol/auth"
4141
protoCodecs "github.com/livekit/protocol/codecs"
4242
"github.com/livekit/protocol/livekit"
43+
44+
dtlsElliptic "github.com/pion/dtls/v3/pkg/crypto/elliptic"
4345
)
4446

4547
var (
@@ -195,6 +197,15 @@ func WithCodecs(codecs []livekit.Codec) ConnectOption {
195197
}
196198
}
197199

200+
// WithDTLSEllipticCurves configures the DTLS elliptic curves used for key exchange.
201+
// Use this on FIPS 140-enabled systems to specify NIST-approved curves (e.g. P-256, P-384)
202+
// instead of the default X25519.
203+
func WithDTLSEllipticCurves(curves ...dtlsElliptic.Curve) ConnectOption {
204+
return func(p *signalling.ConnectParams) {
205+
p.DTLSEllipticCurves = curves
206+
}
207+
}
208+
198209
type PLIWriter func(webrtc.SSRC)
199210

200211
type Room struct {

signalling/interfaces.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/livekit/mediatransportutil/pkg/pacer"
2323
"github.com/livekit/protocol/livekit"
2424
protoLogger "github.com/livekit/protocol/logger"
25+
dtlsElliptic "github.com/pion/dtls/v3/pkg/crypto/elliptic"
2526
"github.com/pion/interceptor"
2627
"github.com/pion/webrtc/v4"
2728
"google.golang.org/protobuf/proto"
@@ -89,6 +90,8 @@ type ConnectParams struct {
8990

9091
ICETransportPolicy webrtc.ICETransportPolicy
9192

93+
DTLSEllipticCurves []dtlsElliptic.Curve // FIPS 140: override default DTLS curves
94+
9295
// internal use
9396
Codecs []webrtc.RTPCodecParameters
9497
}

transport.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424

2525
"github.com/bep/debounce"
2626
"github.com/pion/dtls/v3"
27+
dtlsElliptic "github.com/pion/dtls/v3/pkg/crypto/elliptic"
2728
"github.com/pion/interceptor"
2829
"github.com/pion/interceptor/pkg/nack"
2930
"github.com/pion/interceptor/pkg/twcc"
@@ -79,6 +80,7 @@ type PCTransportParams struct {
7980
IncludeDefaultInterceptors bool
8081
OnRTTUpdate func(rtt uint32)
8182
IsSender bool
83+
DTLSEllipticCurves []dtlsElliptic.Curve
8284
}
8385

8486
func (t *PCTransport) registerDefaultInterceptors(params PCTransportParams, i *interceptor.Registry) error {
@@ -208,6 +210,9 @@ func NewPCTransport(params PCTransportParams) (*PCTransport, error) {
208210

209211
se := webrtc.SettingEngine{}
210212
se.SetSRTPProtectionProfiles(dtls.SRTP_AEAD_AES_128_GCM, dtls.SRTP_AES128_CM_HMAC_SHA1_80)
213+
if len(params.DTLSEllipticCurves) > 0 {
214+
se.SetDTLSEllipticCurves(params.DTLSEllipticCurves...)
215+
}
211216
se.SetDTLSRetransmissionInterval(dtlsRetransmissionInterval)
212217
se.SetICETimeouts(iceDisconnectedTimeout, iceFailedTimeout, iceKeepaliveInterval)
213218
lf := pionlogger.NewLoggerFactory(logger)

0 commit comments

Comments
 (0)