Skip to content

Commit

Permalink
BUTTON-185 fix normilized certificate
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Golosovskiy committed Dec 22, 2015
1 parent 275cd80 commit faadd03
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
11 changes: 6 additions & 5 deletions src/apps/relay/userdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,11 @@ int get_user_key(int in_oauth, int *out_oauth, int *max_session_time, u08bits *u
{
int token_len = stun_attr_get_len(sar);
const u08bits* token_ptr = stun_attr_get_value(sar);
u08bits token[128];
memcpy(token, token_ptr, token_len);

if(token_len && 0==stun_check_message_certificate(token, token_len, &cert, secret_key, iv))
u08bits token[128];
memcpy(token, token_ptr, token_len);
token[token_len]=0;
int err = stun_check_message_certificate(token, token_len, &cert, secret_key, iv);
if(token_len && err == 0)
{
const char* password = cert.call_id;
size_t sz = get_hmackey_size(SHATYPE_DEFAULT) * 2;
Expand Down Expand Up @@ -469,7 +470,7 @@ int get_user_key(int in_oauth, int *out_oauth, int *max_session_time, u08bits *u
}
else
{
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Incorrect token: user %s token: %s \n", usname, token);
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Incorrect token: user %s token: %s Error: %d\n", usname, token, err);
return -1;
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/client/ns_turn_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ int Base64Decode(const u08bits* b64message, unsigned char * output, int* output_
bio = BIO_push(b64, bio);

BIO_set_flags(bio, BIO_FLAGS_BASE64_NO_NL); //Do not use newlines to flush buffer
// char* test = (char*)(unsigned long)b64message;
length = BIO_read(bio, buffer, strlen((char*)(unsigned long)b64message));
if(length != decodeLen) //length should equal decodeLen, else something went horribly wrong
return 0;
Expand Down Expand Up @@ -1948,13 +1949,13 @@ int stun_check_message_certificate(const u08bits *cert_encrypted, size_t cert_en
decryptedtext_len = decrypt_aes_128((u08bits *)aes_128_token, aes_128_token_len, key, iv,
decryptedtext);
if(decryptedtext_len==0)
return -1;
return -2;

/* Add a NULL terminator. We are expecting printable text */
decryptedtext[decryptedtext_len] = 0;

if(!parse_token((const char *)decryptedtext, cert))
return -1;
return -3;

return 0;
}
Expand Down

0 comments on commit faadd03

Please sign in to comment.