Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
dba4b4a0
Commit
dba4b4a0
authored
15 years ago
by
Alexandre Savard
Browse files
Options
Downloads
Patches
Plain Diff
[#1722] use sfl::CryptoSuites to init crypto context
parent
66e9c374
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
sflphone-common/src/audio/audiortp/AudioSrtpSession.cpp
+12
-9
12 additions, 9 deletions
sflphone-common/src/audio/audiortp/AudioSrtpSession.cpp
sflphone-common/src/audio/audiortp/AudioSrtpSession.h
+34
-0
34 additions, 0 deletions
sflphone-common/src/audio/audiortp/AudioSrtpSession.h
with
46 additions
and
9 deletions
sflphone-common/src/audio/audiortp/AudioSrtpSession.cpp
+
12
−
9
View file @
dba4b4a0
...
...
@@ -45,6 +45,8 @@ namespace sfl
AudioSrtpSession
::
AudioSrtpSession
(
ManagerImpl
*
manager
,
SIPCall
*
sipcall
)
:
ost
::
SymmetricRTPSession
(
ost
::
InetHostAddress
(
sipcall
->
getLocalIp
().
c_str
()),
sipcall
->
getLocalAudioPort
()),
_localCryptoSuite
(
0
),
_remoteCryptoSuite
(
0
),
AudioRtpSession
<
AudioSrtpSession
>
(
manager
,
sipcall
)
{
...
...
@@ -68,7 +70,7 @@ std::string AudioSrtpSession::getLocalCryptoInfo() {
// cryptographic context tagged 1, 2, 3...
std
::
string
tag
=
"1"
;
std
::
string
crypto_suite
=
"AES_CM_128_HMAC_SHA1_32"
;
std
::
string
crypto_suite
=
sfl
::
CryptoSuites
[
_localCryptoSuite
].
name
;
// srtp keys formated as the following as the following
// inline:NzB4d1BINUAvLEw6UzF3WSJ+PSdFcGdUJShpX1Zj|2^20|1:32
...
...
@@ -104,7 +106,7 @@ void AudioSrtpSession::initializeLocalMasterKey(void)
{
// @TODO key may have different length depending on cipher suite
_localMasterKeyLength
=
16
;
_localMasterKeyLength
=
sfl
::
CryptoSuites
[
_localCryptoSuite
].
masterKeyLength
/
8
;
// Allocate memory for key
unsigned
char
*
random_key
=
new
unsigned
char
[
_localMasterKeyLength
];
...
...
@@ -130,7 +132,7 @@ void AudioSrtpSession::initializeLocalMasterSalt(void)
{
// @TODO key may have different length depending on cipher suite
_localMasterSaltLength
=
14
;
_localM
asterSaltLength
=
sfl
::
CryptoSuites
[
_localCryptoSuite
].
m
asterSaltLength
/
8
;
// Allocate memory for key
unsigned
char
*
random_key
=
new
unsigned
char
[
_localMasterSaltLength
];
...
...
@@ -174,8 +176,9 @@ std::string AudioSrtpSession::getBase64ConcatenatedKeys()
void
AudioSrtpSession
::
unBase64ConcatenatedKeys
(
std
::
string
base64keys
)
{
_remoteMasterKeyLength
=
16
;
_remoteMasterSaltLength
=
14
;
_remoteMasterKeyLength
=
sfl
::
CryptoSuites
[
1
].
masterKeyLength
/
8
;
_remoteMasterSaltLength
=
sfl
::
CryptoSuites
[
1
].
masterSaltLength
/
8
;
// length of decoded data data
int
length
;
...
...
@@ -203,9 +206,9 @@ void AudioSrtpSession::initializeRemoteCryptoContext(void)
SrtpEncryptionAESCM
,
// encryption algo
SrtpAuthenticationSha1Hmac
,
// authtication algo
_remoteMasterKey
,
// Master Key
128
/
8
,
// Master Key length
_remoteMasterKeyLength
,
// Master Key length
_remoteMasterSalt
,
// Master Salt
112
/
8
,
// Master Salt length
_remoteMasterSaltLength
,
// Master Salt length
128
/
8
,
// encryption keyl
160
/
8
,
// authentication key len
112
/
8
,
// session salt len
...
...
@@ -223,9 +226,9 @@ void AudioSrtpSession::initializeLocalCryptoContext(void)
SrtpEncryptionAESCM
,
// encryption algo
SrtpAuthenticationSha1Hmac
,
// authtication algo
_localMasterKey
,
// Master Key
128
/
8
,
// Master Key length
_localMasterKeyLength
,
// Master Key length
_localMasterSalt
,
// Master Salt
112
/
8
,
// Master Salt length
_localMasterSaltLength
,
// Master Salt length
128
/
8
,
// encryption keyl
160
/
8
,
// authentication key len
112
/
8
,
// session salt len
...
...
This diff is collapsed.
Click to expand it.
sflphone-common/src/audio/audiortp/AudioSrtpSession.h
+
34
−
0
View file @
dba4b4a0
...
...
@@ -28,6 +28,30 @@ class SdesNegotiator;
class
ManagerImpl
;
class
SIPCall
;
/*
Table from RFC 4568 6.2. Crypto-Suites, which define key parameters for supported
cipher suite
+---------------------+-------------+--------------+---------------+
| |AES_CM_128_ | AES_CM_128_ | F8_128_ |
| |HMAC_SHA1_80 | HMAC_SHA1_32 | HMAC_SHA1_80 |
+---------------------+-------------+--------------+---------------+
| Master key length | 128 bits | 128 bits | 128 bits |
| Master salt length | 112 bits | 112 bits | 112 bits |
| SRTP lifetime | 2^48 packets| 2^48 packets | 2^48 packets |
| SRTCP lifetime | 2^31 packets| 2^31 packets | 2^31 packets |
| Cipher | AES Counter | AES Counter | AES F8 Mode |
| | Mode | Mode | |
| Encryption key | 128 bits | 128 bits | 128 bits |
| MAC | HMAC-SHA1 | HMAC-SHA1 | HMAC-SHA1 |
| SRTP auth. tag | 80 bits | 32 bits | 80 bits |
| SRTCP auth. tag | 80 bits | 80 bits | 80 bits |
| SRTP auth. key len. | 160 bits | 160 bits | 160 bits |
| SRTCP auth. key len.| 160 bits | 160 bits | 160 bits |
+---------------------+-------------+--------------+---------------+
*/
namespace
sfl
{
class
SrtpException
:
public
std
::
exception
...
...
@@ -66,20 +90,30 @@ namespace sfl {
char
*
decodeBase64
(
unsigned
char
*
input
,
int
length
,
int
*
length_out
);
/** Default local crypto suite is AES_CM_128_HMAC_SHA1_80*/
int
_localCryptoSuite
;
/** Remote crypto suite is initialized at AES_CM_128_HMAC_SHA1_80*/
int
_remoteCryptoSuite
;
uint8
_localMasterKey
[
16
];
/** local master key length in byte */
int
_localMasterKeyLength
;
uint8
_localMasterSalt
[
14
];
/** local master salt length in byte */
int
_localMasterSaltLength
;
uint8
_remoteMasterKey
[
16
];
/** remote master key length in byte */
int
_remoteMasterKeyLength
;
uint8
_remoteMasterSalt
[
14
];
/** remote master salt length in byte */
int
_remoteMasterSaltLength
;
ost
::
CryptoContext
*
_remoteCryptoCtx
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment