summaryrefslogtreecommitdiffstats
path: root/friendfinder
diff options
context:
space:
mode:
authorPatrick Hornecker2010-02-27 18:21:05 +0100
committerPatrick Hornecker2010-02-27 18:21:05 +0100
commitc8ffc7b23e89571f3fcf588db0221f56a37934c8 (patch)
tree6dcbf6076806bdc1b3aace222478759c1f651c10 /friendfinder
parenttex source (diff)
downloadfriendfinder-c8ffc7b23e89571f3fcf588db0221f56a37934c8.tar.gz
friendfinder-c8ffc7b23e89571f3fcf588db0221f56a37934c8.tar.xz
friendfinder-c8ffc7b23e89571f3fcf588db0221f56a37934c8.zip
tex source and bit code
Diffstat (limited to 'friendfinder')
-rw-r--r--friendfinder/msg_sender.c7
-rw-r--r--friendfinder/receiver.c16
-rw-r--r--friendfinder/sender.c47
3 files changed, 35 insertions, 35 deletions
diff --git a/friendfinder/msg_sender.c b/friendfinder/msg_sender.c
index d643a66..ac5c4e2 100644
--- a/friendfinder/msg_sender.c
+++ b/friendfinder/msg_sender.c
@@ -161,6 +161,7 @@ void set_txt_msg(char *msg)
void send_message(irc_session_t *session, struct msg_part *msg_p)
{
+ int blubb = 0;
if (msg_p->msg_parts != NULL && strlen(msg_p->msg_parts[0]) > 0)
{
for (int i = 0; i <= msg_p->part_count; i++)
@@ -169,7 +170,8 @@ void send_message(irc_session_t *session, struct msg_part *msg_p)
char *crypted_msg_base64 = (char*) malloc(sizeof(char) * 50);
if (msg_p->msg_parts[i] != NULL)
- {
+ {
+ blubb = blubb + sizeof(msg_p->msg_parts[i]);
BF_ecb_encrypt(msg_p->msg_parts[i], crypted_msg, &key, BF_ENCRYPT);
to_base64(crypted_msg, strlen(crypted_msg), crypted_msg_base64, 50);
irc_cmd_msg(session, "#msg", crypted_msg_base64);
@@ -186,7 +188,8 @@ void send_message(irc_session_t *session, struct msg_part *msg_p)
BF_ecb_encrypt(eof, crypted_eof, &key, BF_ENCRYPT);
to_base64(crypted_eof, strlen(crypted_eof), crypted_eof_base64, 50);
irc_cmd_msg(session, "#msg", crypted_eof_base64);
-
+ blubb = blubb + sizeof(eof);
+ printf("%i \n", blubb);
free(crypted_eof);
free(crypted_eof_base64);
diff --git a/friendfinder/receiver.c b/friendfinder/receiver.c
index 9ee0737..0cf1a44 100644
--- a/friendfinder/receiver.c
+++ b/friendfinder/receiver.c
@@ -257,10 +257,10 @@ void get_position(irc_session_t * session, const char * event, const char * orig
if (s_sender[pos]->lat_set == 0)
{
- encrypted_base64 = (char*) malloc(sizeof(char) * 50);
+ encrypted_base64 = (char*) malloc(sizeof(char) *60);
decrypted = (char*) malloc(sizeof(char) * 7);
- from_base64(params[1], strlen(params[1]), encrypted_base64, 50);
+ from_base64(params[1], strlen(params[1]), encrypted_base64, 60);
BF_ecb_encrypt(encrypted_base64, decrypted, &key, BF_DECRYPT);
decrypted[strlen(decrypted)] = '\0';
@@ -275,10 +275,10 @@ void get_position(irc_session_t * session, const char * event, const char * orig
else if (s_sender[pos]->lon_set == 0)
{
- encrypted_base64 = (char*) malloc(sizeof(char) * 50);
+ encrypted_base64 = (char*) malloc(sizeof(char) * 60);
decrypted = (char*) malloc(sizeof(char) * 7);
- from_base64(params[1], strlen(params[1]), encrypted_base64, 50);
+ from_base64(params[1], strlen(params[1]), encrypted_base64, 60);
BF_ecb_encrypt(encrypted_base64, decrypted, &key, BF_DECRYPT);
decrypted[strlen(decrypted)] = '\0';
@@ -328,12 +328,12 @@ void get_position(irc_session_t * session, const char * event, const char * orig
void send_acknowledgement(char *sender)
{
- char* sender_base64 = (char*) malloc(sizeof(char) * 50);
+ char* sender_base64 = (char*) malloc(sizeof(char) * 60);
char* sender_crypted = (char*) malloc(sizeof(char) * 20);
printf("sender: %s \n", sender);
BF_ecb_encrypt(sender, sender_crypted, &key, BF_ENCRYPT);
- to_base64(sender_crypted, strlen(sender_crypted), sender_base64, 50);
+ to_base64(sender_crypted, strlen(sender_crypted), sender_base64, 60);
irc_cmd_msg(session, "#test", sender_base64);
free(sender_base64);
@@ -344,10 +344,10 @@ int check_message(char *msg, char *sender)
{
if (sender[strlen(sender) - 1] == 's')
{
- char* ack_base64 = (char*) malloc(sizeof(char) * 50);
+ char* ack_base64 = (char*) malloc(sizeof(char) * 60);
char* ack_decrypted = (char*) malloc(sizeof(char) * 20);
- from_base64(msg, strlen(msg), ack_base64, 50);
+ from_base64(msg, strlen(msg), ack_base64, 60);
BF_ecb_encrypt(ack_base64, ack_decrypted, &key, BF_DECRYPT);
if (strcmp(sender, ack_decrypted) == 0)
diff --git a/friendfinder/sender.c b/friendfinder/sender.c
index a924d19..3a81389 100644
--- a/friendfinder/sender.c
+++ b/friendfinder/sender.c
@@ -12,12 +12,11 @@
static irc_session_t *session;
irc_callbacks_t callbacks;
-int exit_ = 0;
int lat_first_set = 0;
-int msg_count = 0;
int ack_count = 0;
int resend = 0;
+int msg_count = 0;
char *sender_server_ip, *username, *suffix_username;
double own_lat, own_lon;
@@ -132,10 +131,10 @@ void send_position(irc_session_t * session, const char * event, const char * ori
unsigned char *crypted_lon_first = (char*) malloc(sizeof(char) * 9);
unsigned char *crypted_lon_second = (char*) malloc(sizeof(char) * 9);
- unsigned char *crypted_lat_first_base64 = (char*) malloc(sizeof(char) * 50);
- unsigned char *crypted_lat_second_base64 = (char*) malloc(sizeof(char) * 50);
- unsigned char *crypted_lon_first_base64 = (char*) malloc(sizeof(char) * 50);
- unsigned char *crypted_lon_second_base64 = (char*) malloc(sizeof(char) * 50);
+ unsigned char *crypted_lat_first_base64 = (char*) malloc(sizeof(char) * 60);
+ unsigned char *crypted_lat_second_base64 = (char*) malloc(sizeof(char) * 60);
+ unsigned char *crypted_lon_first_base64 = (char*) malloc(sizeof(char) * 60);
+ unsigned char *crypted_lon_second_base64 = (char*) malloc(sizeof(char) * 60);
@@ -156,30 +155,28 @@ void send_position(irc_session_t * session, const char * event, const char * ori
free(keyd);
}
- if (exit_ == 1)
- disconnect_sender();
-
const unsigned char *lat_char = (char*) malloc(sizeof(char) * 10);
sprintf(lat_char, "%f", own_lat);
const unsigned char *lon_char = (char*) malloc(sizeof(char) * 10);
sprintf(lon_char, "%f", own_lon);
-
+
struct sender_data *pos = (struct sender_data*) malloc(sizeof(struct sender_data));
pos = prepare_position(lat_char, lon_char);
+ printf("%i \n", sizeof(pos->lat_first) + sizeof(pos->lat_second) + sizeof(pos->lon_first) + sizeof(pos->lon_second));
BF_ecb_encrypt(pos->lat_first, crypted_lat_first, &key, BF_ENCRYPT);
BF_ecb_encrypt(pos->lat_second, crypted_lat_second, &key, BF_ENCRYPT);
BF_ecb_encrypt(pos->lon_first, crypted_lon_first, &key, BF_ENCRYPT);
BF_ecb_encrypt(pos->lon_second, crypted_lon_second, &key, BF_ENCRYPT);
- to_base64(crypted_lat_first, strlen(crypted_lat_first), crypted_lat_first_base64, 50);
- to_base64(crypted_lat_second, strlen(crypted_lat_second), crypted_lat_second_base64, 50);
+ to_base64(crypted_lat_first, strlen(crypted_lat_first), crypted_lat_first_base64, 60);
+ to_base64(crypted_lat_second, strlen(crypted_lat_second), crypted_lat_second_base64, 60);
- to_base64(crypted_lon_first, strlen(crypted_lon_first), crypted_lon_first_base64, 50);
- to_base64(crypted_lon_second, strlen(crypted_lon_second), crypted_lon_second_base64, 50);
+ to_base64(crypted_lon_first, strlen(crypted_lon_first), crypted_lon_first_base64, 60);
+ to_base64(crypted_lon_second, strlen(crypted_lon_second), crypted_lon_second_base64, 60);
irc_cmd_msg(session, "#test", crypted_lat_first_base64);
@@ -189,11 +186,11 @@ void send_position(irc_session_t * session, const char * event, const char * ori
irc_cmd_msg(session, "#test", crypted_lon_second_base64);
- msg_count = msg_count + 2;
+ msg_count = msg_count + 4;
- if(resend == 1)
+ if (resend == 1)
{
- get_aknowledge(session, event, origin, params, count);
+ get_acknowledge(session, event, origin, params, count);
resend = 0;
ack_count = 0;
}
@@ -214,10 +211,10 @@ void send_position(irc_session_t * session, const char * event, const char * ori
free(pos);
}
-void get_aknowledge(irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count)
+void get_acknowledge(irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count)
{
char* ack = (char*) malloc(sizeof(char) * 20);
- char* ack_base64 = (char*) malloc(sizeof(char) * 50);
+ char* ack_base64 = (char*) malloc(sizeof(char) * 60);
char *sender_name = (char*) malloc(sizeof(char) * 50);
char *own_receiver_name = (char*) malloc(sizeof(username) + 2);
@@ -225,7 +222,7 @@ void get_aknowledge(irc_session_t * session, const char * event, const char * or
memcpy(own_receiver_name, username, strlen(username));
strcat(own_receiver_name, "_r");
- from_base64(params[1], strlen(params[1]), ack_base64, 50);
+ from_base64(params[1], strlen(params[1]), ack_base64, 60);
BF_ecb_encrypt(ack_base64, ack, &key, BF_DECRYPT);
@@ -234,13 +231,13 @@ void get_aknowledge(irc_session_t * session, const char * event, const char * or
if(strcmp(suffix_username, sender_name) != 0 && strcmp(ack, suffix_username) == 0 && strcmp(sender_name, own_receiver_name) != 0 &&
strcmp(sender_name, "_r") > 0)
{
- if (ack_count <= 1 && msg_count > 0)
- {
+ if (ack_count < 4 && msg_count > 0)
+ {
ack_count++;
msg_count--;
}
-
- if (ack_count == 2 && msg_count == 0)
+
+ if (ack_count == 4 && msg_count == 0)
{
resend = 1;
@@ -256,7 +253,7 @@ void sender_main(void *user)
memset(&callbacks, 0, sizeof(callbacks));
callbacks.event_connect = send_position;
- callbacks.event_channel = get_aknowledge;
+ callbacks.event_channel = get_acknowledge;
username = (char*) malloc(sizeof(char) * 50);
suffix_username = (char*) malloc(sizeof(char) * 50);