Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disable encryption #167

Closed
wants to merge 1 commit into from
Closed
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
19 changes: 19 additions & 0 deletions srtp_cipher_aes_cm_hmac_sha1.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ func (s *srtpCipherAesCmHmacSha1) aeadAuthTagLen() int {
}

func (s *srtpCipherAesCmHmacSha1) encryptRTP(dst []byte, header *rtp.Header, payload []byte, roc uint32) (ciphertext []byte, err error) {
// ** disabled encryption **
return s.encryptRTPNoOp(dst, header, payload, roc)


// Grow the given buffer to fit the output.
dst = growBufferSize(dst, header.MarshalSize()+len(payload)+s.authTagLen())

Expand Down Expand Up @@ -100,6 +104,21 @@ func (s *srtpCipherAesCmHmacSha1) encryptRTP(dst []byte, header *rtp.Header, pay
return dst, nil
}

func (s *srtpCipherAesCmHmacSha1) encryptRTPNoOp(dst []byte, header *rtp.Header, payload []byte, roc uint32) (ciphertext []byte, err error) {
// Grow the given buffer to fit the output.
dst = growBufferSize(dst, header.MarshalSize()+len(payload))

// Copy the header unencrypted.
n, err := header.MarshalTo(dst)
if err != nil {
return nil, err
}

copy(dst[n:], payload)

return dst, nil
}

func (s *srtpCipherAesCmHmacSha1) decryptRTP(dst, ciphertext []byte, header *rtp.Header, roc uint32) ([]byte, error) {
// Split the auth tag and the cipher text into two parts.
actualTag := ciphertext[len(ciphertext)-s.authTagLen():]
Expand Down