package srtp
import "fmt"
type ProtectionProfile uint16
const (
ProtectionProfileAes128CmHmacSha1_80 ProtectionProfile = 0x0001
ProtectionProfileAes128CmHmacSha1_32 ProtectionProfile = 0x0002
ProtectionProfileAes256CmHmacSha1_80 ProtectionProfile = 0x0003
ProtectionProfileAes256CmHmacSha1_32 ProtectionProfile = 0x0004
ProtectionProfileNullHmacSha1_80 ProtectionProfile = 0x0005
ProtectionProfileNullHmacSha1_32 ProtectionProfile = 0x0006
ProtectionProfileAeadAes128Gcm ProtectionProfile = 0x0007
ProtectionProfileAeadAes256Gcm ProtectionProfile = 0x0008
)
func (p ProtectionProfile ) KeyLen () (int , error ) {
switch p {
case ProtectionProfileAes128CmHmacSha1_32 ,
ProtectionProfileAes128CmHmacSha1_80 ,
ProtectionProfileAeadAes128Gcm ,
ProtectionProfileNullHmacSha1_32 ,
ProtectionProfileNullHmacSha1_80 :
return 16 , nil
case ProtectionProfileAeadAes256Gcm , ProtectionProfileAes256CmHmacSha1_32 , ProtectionProfileAes256CmHmacSha1_80 :
return 32 , nil
default :
return 0 , fmt .Errorf ("%w: %#v" , errNoSuchSRTPProfile , p )
}
}
func (p ProtectionProfile ) SaltLen () (int , error ) {
switch p {
case ProtectionProfileAes128CmHmacSha1_32 ,
ProtectionProfileAes128CmHmacSha1_80 ,
ProtectionProfileAes256CmHmacSha1_32 ,
ProtectionProfileAes256CmHmacSha1_80 ,
ProtectionProfileNullHmacSha1_32 ,
ProtectionProfileNullHmacSha1_80 :
return 14 , nil
case ProtectionProfileAeadAes128Gcm , ProtectionProfileAeadAes256Gcm :
return 12 , nil
default :
return 0 , fmt .Errorf ("%w: %#v" , errNoSuchSRTPProfile , p )
}
}
func (p ProtectionProfile ) AuthTagRTPLen () (int , error ) {
switch p {
case ProtectionProfileAes128CmHmacSha1_80 , ProtectionProfileAes256CmHmacSha1_80 , ProtectionProfileNullHmacSha1_80 :
return 10 , nil
case ProtectionProfileAes128CmHmacSha1_32 , ProtectionProfileAes256CmHmacSha1_32 , ProtectionProfileNullHmacSha1_32 :
return 4 , nil
case ProtectionProfileAeadAes128Gcm , ProtectionProfileAeadAes256Gcm :
return 0 , nil
default :
return 0 , fmt .Errorf ("%w: %#v" , errNoSuchSRTPProfile , p )
}
}
func (p ProtectionProfile ) AuthTagRTCPLen () (int , error ) {
switch p {
case ProtectionProfileAes128CmHmacSha1_32 ,
ProtectionProfileAes128CmHmacSha1_80 ,
ProtectionProfileAes256CmHmacSha1_32 ,
ProtectionProfileAes256CmHmacSha1_80 ,
ProtectionProfileNullHmacSha1_32 ,
ProtectionProfileNullHmacSha1_80 :
return 10 , nil
case ProtectionProfileAeadAes128Gcm , ProtectionProfileAeadAes256Gcm :
return 0 , nil
default :
return 0 , fmt .Errorf ("%w: %#v" , errNoSuchSRTPProfile , p )
}
}
func (p ProtectionProfile ) AEADAuthTagLen () (int , error ) {
switch p {
case ProtectionProfileAes128CmHmacSha1_32 ,
ProtectionProfileAes128CmHmacSha1_80 ,
ProtectionProfileAes256CmHmacSha1_32 ,
ProtectionProfileAes256CmHmacSha1_80 ,
ProtectionProfileNullHmacSha1_32 ,
ProtectionProfileNullHmacSha1_80 :
return 0 , nil
case ProtectionProfileAeadAes128Gcm , ProtectionProfileAeadAes256Gcm :
return 16 , nil
default :
return 0 , fmt .Errorf ("%w: %#v" , errNoSuchSRTPProfile , p )
}
}
func (p ProtectionProfile ) AuthKeyLen () (int , error ) {
switch p {
case ProtectionProfileAes128CmHmacSha1_32 ,
ProtectionProfileAes128CmHmacSha1_80 ,
ProtectionProfileAes256CmHmacSha1_32 ,
ProtectionProfileAes256CmHmacSha1_80 ,
ProtectionProfileNullHmacSha1_32 ,
ProtectionProfileNullHmacSha1_80 :
return 20 , nil
case ProtectionProfileAeadAes128Gcm , ProtectionProfileAeadAes256Gcm :
return 0 , nil
default :
return 0 , fmt .Errorf ("%w: %#v" , errNoSuchSRTPProfile , p )
}
}
func (p ProtectionProfile ) String () string {
switch p {
case ProtectionProfileAes128CmHmacSha1_80 :
return "SRTP_AES128_CM_HMAC_SHA1_80"
case ProtectionProfileAes128CmHmacSha1_32 :
return "SRTP_AES128_CM_HMAC_SHA1_32"
case ProtectionProfileAes256CmHmacSha1_80 :
return "SRTP_AES256_CM_HMAC_SHA1_80"
case ProtectionProfileAes256CmHmacSha1_32 :
return "SRTP_AES256_CM_HMAC_SHA1_32"
case ProtectionProfileAeadAes128Gcm :
return "SRTP_AEAD_AES_128_GCM"
case ProtectionProfileAeadAes256Gcm :
return "SRTP_AEAD_AES_256_GCM"
case ProtectionProfileNullHmacSha1_80 :
return "SRTP_NULL_HMAC_SHA1_80"
case ProtectionProfileNullHmacSha1_32 :
return "SRTP_NULL_HMAC_SHA1_32"
default :
return fmt .Sprintf ("Unknown SRTP profile: %#v" , p )
}
}
The pages are generated with Golds v0.8.2 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .