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
1d7714b6
Commit
1d7714b6
authored
Sep 09, 2008
by
Youness Alaoui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean the stun_make_transid to avoid heart attacks
parent
f0b40bf8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
31 deletions
+1
-31
stun/stunhmac.c
stun/stunhmac.c
+1
-31
No files found.
stun/stunhmac.c
View file @
1d7714b6
...
@@ -121,35 +121,5 @@ void stun_hash_creds (const uint8_t *realm, size_t realm_len,
...
@@ -121,35 +121,5 @@ void stun_hash_creds (const uint8_t *realm, size_t realm_len,
void
stun_make_transid
(
stun_transid_t
id
)
void
stun_make_transid
(
stun_transid_t
id
)
{
{
/*
RAND_bytes
(
id
,
sizeof
(
id
));
* transid = (HMAC_SHA1 (secret, counter) >> 64)
* This consumes sizeof (secret) bytes of entropy every 2^64 messages.
*/
static
struct
{
pthread_mutex_t
lock
;
uint64_t
counter
;
uint8_t
secret
[
16
];
}
store
=
{
PTHREAD_MUTEX_INITIALIZER
,
0
,
""
};
union
{
uint64_t
value
;
uint8_t
bytes
[
1
];
}
counter
;
uint8_t
key
[
16
],
sha
[
20
];
pthread_mutex_lock
(
&
store
.
lock
);
counter
.
value
=
store
.
counter
++
;
if
(
counter
.
value
==
0
)
RAND_pseudo_bytes
(
store
.
secret
,
sizeof
(
store
.
secret
));
memcpy
(
key
,
store
.
secret
,
sizeof
(
key
));
pthread_mutex_unlock
(
&
store
.
lock
);
/* Computes hash out of contentious area */
HMAC
(
EVP_sha1
(),
key
,
sizeof
(
key
),
counter
.
bytes
,
sizeof
(
counter
),
sha
,
NULL
);
memcpy
(
id
,
sha
,
16
);
}
}
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