Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-1.1
Commits
7788eb79
Commit
7788eb79
authored
Jun 07, 2008
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SRTP: support for parsing key and salt from a string
parent
593ead3e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
0 deletions
+49
-0
libs/srtp/srtp.c
libs/srtp/srtp.c
+47
-0
libs/srtp/srtp.h
libs/srtp/srtp.h
+2
-0
No files found.
libs/srtp/srtp.c
View file @
7788eb79
...
@@ -372,6 +372,53 @@ srtp_setkey (srtp_session_t *s, const void *key, size_t keylen,
...
@@ -372,6 +372,53 @@ srtp_setkey (srtp_session_t *s, const void *key, size_t keylen,
return
srtp_derive
(
s
,
key
,
keylen
,
salt
,
saltlen
)
?
EINVAL
:
0
;
return
srtp_derive
(
s
,
key
,
keylen
,
salt
,
saltlen
)
?
EINVAL
:
0
;
}
}
static
int
hexdigit
(
char
c
)
{
if
((
c
>=
'0'
)
&&
(
c
<=
'9'
))
return
c
-
'0'
;
if
((
c
>=
'A'
)
&&
(
c
<=
'F'
))
return
c
-
'A'
+
0xA
;
if
((
c
>=
'a'
)
&&
(
c
<=
'f'
))
return
c
-
'a'
+
0xa
;
return
-
1
;
}
static
ssize_t
hexstring
(
const
char
*
in
,
uint8_t
*
out
,
size_t
outlen
)
{
size_t
inlen
=
strlen
(
in
);
if
((
inlen
>
(
2
*
outlen
))
||
(
inlen
&
1
))
return
-
1
;
for
(
size_t
i
=
0
;
i
<
inlen
;
i
+=
2
)
{
int
a
=
hexdigit
(
in
[
2
*
i
]),
b
=
hexdigit
(
in
[
2
*
i
+
1
]);
if
((
a
==
-
1
)
||
(
b
==
-
1
))
return
EINVAL
;
out
[
i
]
=
(
a
<<
4
)
|
b
;
}
return
inlen
/
2
;
}
/**
* Sets (or resets) the master key and master salt for a SRTP session
* from hexadecimal strings. See also srtp_setkey().
*
* @return 0 on success, in case of error:
* EINVAL invalid or unsupported key/salt sizes combination
*/
int
srtp_setkeystring
(
srtp_session_t
*
s
,
const
char
*
key
,
const
char
*
salt
)
{
uint8_t
bkey
[
32
];
/* TODO/NOTE: hard-coded for AES */
uint8_t
bsalt
[
14
];
/* TODO/NOTE: hard-coded for the PRF-AES-CM */
ssize_t
bkeylen
=
hexstring
(
key
,
bkey
,
sizeof
(
bkey
));
ssize_t
bsaltlen
=
hexstring
(
salt
,
bsalt
,
sizeof
(
bsalt
));
if
((
bkeylen
==
-
1
)
||
(
bsaltlen
==
-
1
))
return
EINVAL
;
return
srtp_derive
(
s
,
bkey
,
bkeylen
,
bsalt
,
bsaltlen
)
?
EINVAL
:
0
;
}
/**
/**
* Sets Roll-over-Counter Carry (RCC) rate for the SRTP session. If not
* Sets Roll-over-Counter Carry (RCC) rate for the SRTP session. If not
...
...
libs/srtp/srtp.h
View file @
7788eb79
...
@@ -66,6 +66,8 @@ void srtp_destroy (srtp_session_t *s);
...
@@ -66,6 +66,8 @@ void srtp_destroy (srtp_session_t *s);
int
srtp_setkey
(
srtp_session_t
*
s
,
const
void
*
key
,
size_t
keylen
,
int
srtp_setkey
(
srtp_session_t
*
s
,
const
void
*
key
,
size_t
keylen
,
const
void
*
salt
,
size_t
saltlen
);
const
void
*
salt
,
size_t
saltlen
);
int
srtp_setkeystring
(
srtp_session_t
*
s
,
const
char
*
key
,
const
char
*
salt
);
void
srtp_setrcc_rate
(
srtp_session_t
*
s
,
uint16_t
rate
);
void
srtp_setrcc_rate
(
srtp_session_t
*
s
,
uint16_t
rate
);
int
srtp_send
(
srtp_session_t
*
s
,
uint8_t
*
buf
,
size_t
*
lenp
,
size_t
maxsize
);
int
srtp_send
(
srtp_session_t
*
s
,
uint8_t
*
buf
,
size_t
*
lenp
,
size_t
maxsize
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment