Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libnice
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
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
cpp-libs
libnice
Commits
ce13b71f
Commit
ce13b71f
authored
Jul 30, 2008
by
Youness Alaoui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add RFC 3489 support for stun by having padding in the message integrity generation
parent
49a92546
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
4 deletions
+18
-4
stun/stunagent.c
stun/stunagent.c
+4
-2
stun/stunhmac.c
stun/stunhmac.c
+13
-1
stun/stunhmac.h
stun/stunhmac.h
+1
-1
No files found.
stun/stunagent.c
View file @
ce13b71f
...
...
@@ -213,7 +213,8 @@ StunValidationStatus stun_agent_validate (StunAgent *agent, StunMessage *msg,
if
(
hash
)
{
/* We must give the size from start to the end of the attribute
because you might have a FINGERPRINT attribute after it... */
stun_sha1
(
msg
->
buffer
,
hash
+
20
-
msg
->
buffer
,
sha
,
key
,
key_len
);
stun_sha1
(
msg
->
buffer
,
hash
+
20
-
msg
->
buffer
,
sha
,
key
,
key_len
,
agent
->
compatibility
==
STUN_COMPATIBILITY_RFC3489
?
TRUE
:
FALSE
);
stun_debug
(
" Message HMAC-SHA1 fingerprint:"
);
stun_debug
(
"
\n
key : "
);
stun_debug_bytes
(
key
,
key_len
);
...
...
@@ -422,7 +423,8 @@ size_t stun_agent_finish_message (StunAgent *agent, StunMessage *msg,
return
0
;
}
stun_sha1
(
msg
->
buffer
,
stun_message_length
(
msg
),
ptr
,
key
,
key_len
);
stun_sha1
(
msg
->
buffer
,
stun_message_length
(
msg
),
ptr
,
key
,
key_len
,
agent
->
compatibility
==
STUN_COMPATIBILITY_RFC3489
?
TRUE
:
FALSE
);
stun_debug
(
" Message HMAC-SHA1 message integrity:"
"
\n
key : "
);
...
...
stun/stunhmac.c
View file @
ce13b71f
...
...
@@ -52,7 +52,7 @@
#include <assert.h>
void
stun_sha1
(
const
uint8_t
*
msg
,
size_t
len
,
uint8_t
*
sha
,
const
void
*
restrict
key
,
size_t
keylen
)
const
void
*
restrict
key
,
size_t
keylen
,
int
padding
)
{
HMAC_CTX
ctx
;
uint16_t
fakelen
=
htons
(
len
-
20u
);
...
...
@@ -65,6 +65,18 @@ void stun_sha1 (const uint8_t *msg, size_t len, uint8_t *sha,
HMAC_Update
(
&
ctx
,
(
const
uint8_t
*
)
&
fakelen
,
2
);
/* first 4 bytes done, last 24 bytes not summed */
HMAC_Update
(
&
ctx
,
msg
+
4
,
len
-
28u
);
/* RFC 3489 specifies that the message's size should be 64 bytes,
and \x00 padding should be done */
if
(
padding
)
{
uint16_t
pad_size
=
64
-
((
len
-
24
)
%
64
);
int
i
;
uint8_t
pad_char
[
1
]
=
{
0
};
for
(
i
=
0
;
i
<
pad_size
;
i
++
)
{
HMAC_Update
(
&
ctx
,
pad_char
,
1
);
}
}
HMAC_Final
(
&
ctx
,
sha
,
NULL
);
HMAC_CTX_cleanup
(
&
ctx
);
}
...
...
stun/stunhmac.h
View file @
ce13b71f
...
...
@@ -49,7 +49,7 @@
* @return fingerprint value in <b>host</b> byte order.
*/
void
stun_sha1
(
const
uint8_t
*
msg
,
size_t
len
,
uint8_t
*
sha
,
const
void
*
key
,
size_t
keylen
);
uint8_t
*
sha
,
const
void
*
key
,
size_t
keylen
,
int
padding
);
/**
* SIP H(A1) computation
...
...
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