-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
key+salt len should be determined by profile Relates to #85
- Loading branch information
Showing
9 changed files
with
115 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package srtp | ||
|
||
import "fmt" | ||
|
||
// ProtectionProfile specifies Cipher and AuthTag details, similar to TLS cipher suite | ||
type ProtectionProfile uint16 | ||
|
||
// Supported protection profiles | ||
const ( | ||
ProtectionProfileAes128CmHmacSha1_80 ProtectionProfile = 0x0001 | ||
) | ||
|
||
func (p ProtectionProfile) keyLen() (int, error) { | ||
switch p { | ||
case ProtectionProfileAes128CmHmacSha1_80: | ||
return 16, nil | ||
default: | ||
return 0, fmt.Errorf("no such ProtectionProfile %#v", p) | ||
} | ||
} | ||
|
||
func (p ProtectionProfile) saltLen() (int, error) { | ||
switch p { | ||
case ProtectionProfileAes128CmHmacSha1_80: | ||
return 14, nil | ||
default: | ||
return 0, fmt.Errorf("no such ProtectionProfile %#v", p) | ||
} | ||
} | ||
|
||
func (p ProtectionProfile) authTagLen() (int, error) { | ||
switch p { | ||
case ProtectionProfileAes128CmHmacSha1_80: | ||
return 10, nil | ||
default: | ||
return 0, fmt.Errorf("no such ProtectionProfile %#v", p) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package srtp | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestInvalidProtectionProfile(t *testing.T) { | ||
var invalidProtectionProfile ProtectionProfile | ||
|
||
_, err := invalidProtectionProfile.keyLen() | ||
assert.Error(t, err) | ||
|
||
_, err = invalidProtectionProfile.saltLen() | ||
assert.Error(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters