Commit e60ef6a5 authored by Youness Alaoui's avatar Youness Alaoui

Should fix key checking for gtalk compat

parent fb73b847
...@@ -1058,7 +1058,7 @@ int conn_check_send (NiceAgent *agent, CandidateCheckPair *pair) ...@@ -1058,7 +1058,7 @@ int conn_check_send (NiceAgent *agent, CandidateCheckPair *pair)
&sockaddr, sizeof (sockaddr), &sockaddr, sizeof (sockaddr),
uname, password, uname, password,
cand_use, controlling, priority, cand_use, controlling, priority,
agent->tie_breaker); agent->tie_breaker, agent->compatibility);
timeout = stun_bind_timeout (pair->stun_ctx); timeout = stun_bind_timeout (pair->stun_ctx);
/* note: convert from milli to microseconds for g_time_val_add() */ /* note: convert from milli to microseconds for g_time_val_add() */
......
...@@ -201,8 +201,8 @@ int main (void) ...@@ -201,8 +201,8 @@ int main (void)
nice_udp_bsd_socket_factory_init (&udpfactory); nice_udp_bsd_socket_factory_init (&udpfactory);
/* step: create the agents L and R */ /* step: create the agents L and R */
lagent = nice_agent_new (&udpfactory, lmainctx, NICE_COMPATIBILITY_ID19); lagent = nice_agent_new (&udpfactory, lmainctx, NICE_COMPATIBILITY_GOOGLE);
ragent = nice_agent_new (&udpfactory, rmainctx, NICE_COMPATIBILITY_ID19); ragent = nice_agent_new (&udpfactory, rmainctx, NICE_COMPATIBILITY_GOOGLE);
g_object_set_data (G_OBJECT (lagent), "other-agent", ragent); g_object_set_data (G_OBJECT (lagent), "other-agent", ragent);
g_object_set_data (G_OBJECT (ragent), "other-agent", lagent); g_object_set_data (G_OBJECT (ragent), "other-agent", lagent);
......
...@@ -262,7 +262,7 @@ stun_conncheck_start (stun_bind_t **restrict context, int fd, ...@@ -262,7 +262,7 @@ stun_conncheck_start (stun_bind_t **restrict context, int fd,
const struct sockaddr *restrict srv, socklen_t srvlen, const struct sockaddr *restrict srv, socklen_t srvlen,
const char *username, const char *password, const char *username, const char *password,
bool cand_use, bool controlling, uint32_t priority, bool cand_use, bool controlling, uint32_t priority,
uint64_t tie) uint64_t tie, uint32_t compat)
{ {
int val; int val;
stun_bind_t *ctx; stun_bind_t *ctx;
...@@ -275,6 +275,7 @@ stun_conncheck_start (stun_bind_t **restrict context, int fd, ...@@ -275,6 +275,7 @@ stun_conncheck_start (stun_bind_t **restrict context, int fd,
return val; return val;
ctx = *context; ctx = *context;
if (compat != 1) {
ctx->trans.key.length = strlen (password); ctx->trans.key.length = strlen (password);
ctx->trans.key.value = malloc (ctx->trans.key.length); ctx->trans.key.value = malloc (ctx->trans.key.length);
if (ctx->trans.key.value == NULL) if (ctx->trans.key.value == NULL)
...@@ -284,6 +285,7 @@ stun_conncheck_start (stun_bind_t **restrict context, int fd, ...@@ -284,6 +285,7 @@ stun_conncheck_start (stun_bind_t **restrict context, int fd,
} }
memcpy (ctx->trans.key.value, password, ctx->trans.key.length); memcpy (ctx->trans.key.value, password, ctx->trans.key.length);
}
if (cand_use) if (cand_use)
{ {
......
...@@ -71,7 +71,7 @@ int stun_conncheck_start (stun_bind_t **restrict context, int fd, ...@@ -71,7 +71,7 @@ int stun_conncheck_start (stun_bind_t **restrict context, int fd,
const struct sockaddr *restrict srv, socklen_t srvlen, const struct sockaddr *restrict srv, socklen_t srvlen,
const char *username, const char *password, const char *username, const char *password,
bool cand_use, bool controlling, uint32_t priority, bool cand_use, bool controlling, uint32_t priority,
uint64_t tie); uint64_t tie, uint32_t compat);
/** /**
* Tries to parse a STUN connectivity check (Binding request) and format a * Tries to parse a STUN connectivity check (Binding request) and format a
......
...@@ -119,10 +119,12 @@ stun_conncheck_reply (uint8_t *restrict buf, size_t *restrict plen, ...@@ -119,10 +119,12 @@ stun_conncheck_reply (uint8_t *restrict buf, size_t *restrict plen,
return EPROTO; return EPROTO;
} }
DBG ("compat = %d - username %d - pass %d\n", compat, stun_present (msg, STUN_USERNAME), stun_present (msg, STUN_MESSAGE_INTEGRITY));
/* Short term credentials checking */ /* Short term credentials checking */
val = 0; val = 0;
if (!stun_present (msg, STUN_MESSAGE_INTEGRITY) if (!stun_present (msg, STUN_USERNAME)
|| (compat != 1 && !stun_present (msg, STUN_USERNAME))) || (compat != 1 && !stun_present (msg, STUN_MESSAGE_INTEGRITY)))
{ {
DBG (" Missing USERNAME or MESSAGE-INTEGRITY.\n"); DBG (" Missing USERNAME or MESSAGE-INTEGRITY.\n");
val = STUN_BAD_REQUEST; val = STUN_BAD_REQUEST;
......
...@@ -71,7 +71,7 @@ int stun_conncheck_start (stun_bind_t **restrict context, int fd, ...@@ -71,7 +71,7 @@ int stun_conncheck_start (stun_bind_t **restrict context, int fd,
const struct sockaddr *restrict srv, socklen_t srvlen, const struct sockaddr *restrict srv, socklen_t srvlen,
const char *username, const char *password, const char *username, const char *password,
bool cand_use, bool controlling, uint32_t priority, bool cand_use, bool controlling, uint32_t priority,
uint64_t tie); uint64_t tie, uint32_t compat);
/** /**
* Tries to parse a STUN connectivity check (Binding request) and format a * Tries to parse a STUN connectivity check (Binding request) and format a
......
...@@ -601,12 +601,12 @@ stun_match_answer (const uint8_t *msg, stun_method_t method, ...@@ -601,12 +601,12 @@ stun_match_answer (const uint8_t *msg, stun_method_t method,
* currently ignore them. */ * currently ignore them. */
if (stun_verify_key (msg, key, keylen) != 0) if (stun_verify_key (msg, key, keylen) != 0)
return false; return false;
} }/*
else else
{ {
if (stun_present (msg, STUN_MESSAGE_INTEGRITY)) if (stun_present (msg, STUN_MESSAGE_INTEGRITY))
return false; return false;
} }*/
return true; return true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment