forked from pion/srtp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
srtp_cipher_unencrypted.go
62 lines (48 loc) · 1.5 KB
/
srtp_cipher_unencrypted.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package srtp
import (
"crypto/cipher"
"github.com/pion/rtp"
)
type srtpCipherUnencrypted struct {
srtpCipher, srtcpCipher cipher.AEAD
srtpSessionSalt, srtcpSessionSalt []byte
}
func newSrtpCipherUnencrypted(masterKey, masterSalt []byte) (*srtpCipherUnencrypted, error) {
s := &srtpCipherUnencrypted{}
return s, nil
}
func (s *srtpCipherUnencrypted) authTagLen() int {
return 0
}
func (s *srtpCipherUnencrypted) aeadAuthTagLen() int {
return 0
}
func (s *srtpCipherUnencrypted) encryptRTP(dst []byte, header *rtp.Header, payload []byte, roc uint32) (ciphertext []byte, err error) {
dst = growBufferSize(dst, header.MarshalSize()+len(payload)+s.aeadAuthTagLen())
hdr, err := header.Marshal()
if err != nil {
return nil, err
}
nHdr := len(hdr)
copy(dst[:nHdr], hdr)
copy(dst[nHdr:], payload)
return dst, nil
}
func (s *srtpCipherUnencrypted) decryptRTP(dst, ciphertext []byte, header *rtp.Header, headerLen int, roc uint32) ([]byte, error){
dst = growBufferSize(dst, len(ciphertext))
copy(dst, ciphertext)
return ciphertext, nil
}
func (s *srtpCipherUnencrypted) encryptRTCP(dst, decrypted []byte, srtcpIndex uint32, ssrc uint32) ([]byte, error) {
dst = growBufferSize(dst, len(decrypted))
copy(dst, decrypted)
return dst, nil
}
func (s *srtpCipherUnencrypted) decryptRTCP(dst, encrypted []byte, srtcpIndex, ssrc uint32) ([]byte, error) {
dst = growBufferSize(dst, len(encrypted))
copy(dst, encrypted)
return dst, nil
}
func (s *srtpCipherUnencrypted) getRTCPIndex(in []byte) uint32 {
return 0
}