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
ec719f08
Commit
ec719f08
authored
Apr 03, 2017
by
Olivier Crête
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stun: Make hmac code NDEBUG safe
parent
6d3a7a1b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
10 deletions
+15
-10
stun/stunhmac.c
stun/stunhmac.c
+15
-10
No files found.
stun/stunhmac.c
View file @
ec719f08
...
...
@@ -56,31 +56,36 @@ void stun_sha1 (const uint8_t *msg, size_t len, size_t msg_len, uint8_t *sha,
uint16_t
fakelen
=
htons
(
msg_len
);
uint8_t
pad_char
[
64
]
=
{
0
};
gnutls_hmac_hd_t
handle
;
#ifdef NDEBUG
#define TRY(x) x;
#else
int
ret
;
#define TRY(x) \
ret = x; \
assert (ret >= 0);
#endif
assert
(
len
>=
44u
);
assert
(
gnutls_hmac_get_len
(
GNUTLS_MAC_SHA1
)
==
20
);
ret
=
gnutls_hmac_init
(
&
handle
,
GNUTLS_MAC_SHA1
,
key
,
keylen
);
assert
(
ret
>=
0
);
TRY
(
gnutls_hmac_init
(
&
handle
,
GNUTLS_MAC_SHA1
,
key
,
keylen
));
ret
=
gnutls_hmac
(
handle
,
msg
,
2
);
assert
(
ret
>=
0
);
ret
=
gnutls_hmac
(
handle
,
&
fakelen
,
2
);
assert
(
ret
>=
0
);
ret
=
gnutls_hmac
(
handle
,
msg
+
4
,
len
-
28
);
assert
(
ret
>=
0
);
TRY
(
gnutls_hmac
(
handle
,
msg
,
2
));
TRY
(
gnutls_hmac
(
handle
,
&
fakelen
,
2
));
TRY
(
gnutls_hmac
(
handle
,
msg
+
4
,
len
-
28
));
/* RFC 3489 specifies that the message's size should be 64 bytes,
and \x00 padding should be done */
if
(
padding
&&
((
len
-
24
)
%
64
)
>
0
)
{
uint16_t
pad_size
=
64
-
((
len
-
24
)
%
64
);
ret
=
gnutls_hmac
(
handle
,
pad_char
,
pad_size
);
assert
(
ret
>=
0
);
TRY
(
gnutls_hmac
(
handle
,
pad_char
,
pad_size
));
}
gnutls_hmac_deinit
(
handle
,
sha
);
#undef TRY
}
static
const
uint8_t
*
priv_trim_var
(
const
uint8_t
*
var
,
size_t
*
var_len
)
...
...
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