summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Friloux <guillaume.friloux@gmail.com>2013-08-14 22:59:02 +0200
committerGuillaume Friloux <guillaume.friloux@gmail.com>2013-08-14 22:59:02 +0200
commit84879bc9f39abd93b81b717403513e52fbb1c38d (patch)
tree74a8c53461a095240351105c7d426922dbd5d007
parentc0bad0a721b14f7ccf91a177476e053735c9da5c (diff)
Password encoding now works correctly.
-rw-r--r--src/bin/main.c2
-rw-r--r--src/lib/Makefile.mk10
-rw-r--r--src/modules/Makefile.mk6
-rw-r--r--src/modules/mega/mega.h3
-rw-r--r--src/modules/mega/mega_main.c12
-rw-r--r--src/modules/mega/mega_utils.c38
6 files changed, 57 insertions, 14 deletions
diff --git a/src/bin/main.c b/src/bin/main.c
index 5e62b22..46da263 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -7,7 +7,7 @@ int main(int argc, char **argv)
7 7
8 skypunch_init(); 8 skypunch_init();
9 skypunch = skypunch_new(SKYPUNCH_MEGA, 9 skypunch = skypunch_new(SKYPUNCH_MEGA,
10 "toto@toto.fr:bidule"); 10 "guillaume.friloux@gmx.fr:deepshadow");
11 skypunch_login(skypunch); 11 skypunch_login(skypunch);
12 12
13 ecore_main_loop_begin(); 13 ecore_main_loop_begin();
diff --git a/src/lib/Makefile.mk b/src/lib/Makefile.mk
index a928215..b981cb0 100644
--- a/src/lib/Makefile.mk
+++ b/src/lib/Makefile.mk
@@ -3,7 +3,9 @@ LIB_CPPFLAGS= \
3-I$(top_srcdir)/src/include \ 3-I$(top_srcdir)/src/include \
4-DSKYPUNCH_MODULE_PATH=\"$(libdir)/skypunch/$(MODULE_ARCH)\" 4-DSKYPUNCH_MODULE_PATH=\"$(libdir)/skypunch/$(MODULE_ARCH)\"
5 5
6noinst_LTLIBRARIES = src/lib/libskypunch.la 6noinst_LTLIBRARIES = \
7src/lib/libskypunch.la \
8src/lib/libaes.la
7 9
8src_lib_libskypunch_la_CFLAGS = @SKYPUNCH_CFLAGS@ 10src_lib_libskypunch_la_CFLAGS = @SKYPUNCH_CFLAGS@
9src_lib_libskypunch_la_CPPFLAGS = $(LIB_CPPFLAGS) 11src_lib_libskypunch_la_CPPFLAGS = $(LIB_CPPFLAGS)
@@ -12,3 +14,9 @@ src_lib_libskypunch_la_SOURCES = \
12src/include/Skypunch.h \ 14src/include/Skypunch.h \
13src/lib/skypunch_main.c \ 15src/lib/skypunch_main.c \
14src/lib/skypunch_private.h 16src/lib/skypunch_private.h
17
18src_lib_libaes_la_CFLAGS =
19src_lib_libaes_la_LDFLAGS =
20src_lib_libaes_la_SOURCES = \
21src/lib/extra/aes.c \
22src/lib/extra/aes.h
diff --git a/src/modules/Makefile.mk b/src/modules/Makefile.mk
index aff3124..8a3fb00 100644
--- a/src/modules/Makefile.mk
+++ b/src/modules/Makefile.mk
@@ -1,7 +1,8 @@
1MODULE_CPPFLAGS= \ 1MODULE_CPPFLAGS= \
2-I$(top_srcdir) \ 2-I$(top_srcdir) \
3-I$(top_srcdir)/src/include \ 3-I$(top_srcdir)/src/include \
4-I$(top_srcdir)/src/lib 4-I$(top_srcdir)/src/lib \
5-I$(top_srcdir)/src/lib/extra
5 6
6moddir = $(libdir)/skypunch/$(MODULE_ARCH) 7moddir = $(libdir)/skypunch/$(MODULE_ARCH)
7mod_LTLIBRARIES = src/modules/mega.la 8mod_LTLIBRARIES = src/modules/mega.la
@@ -12,7 +13,8 @@ src/modules/mega/mega_utils.c
12 13
13src_modules_mega_la_CFLAGS = @SKYPUNCH_CFLAGS@ 14src_modules_mega_la_CFLAGS = @SKYPUNCH_CFLAGS@
14src_modules_mega_la_LIBADD = \ 15src_modules_mega_la_LIBADD = \
15src/lib/libskypunch.la 16src/lib/libskypunch.la \
17src/lib/libaes.la
16src_modules_mega_la_CPPFLAGS= $(MODULE_CPPFLAGS) 18src_modules_mega_la_CPPFLAGS= $(MODULE_CPPFLAGS)
17src_modules_mega_la_LDFLAGS = \ 19src_modules_mega_la_LDFLAGS = \
18@SKYPUNCH_LIBS@ \ 20@SKYPUNCH_LIBS@ \
diff --git a/src/modules/mega/mega.h b/src/modules/mega/mega.h
index 388c0c4..b7bae74 100644
--- a/src/modules/mega/mega.h
+++ b/src/modules/mega/mega.h
@@ -1,4 +1,5 @@
1#include <skypunch_private.h> 1#include <skypunch_private.h>
2#include <aes.h>
2 3
3const char * mega_utils_str_to_a32(const char *s, size_t *l); 4const char * mega_utils_str_to_a32(const char *s, size_t *l);
4 5const char * mega_utils_key_encode(const char *s, size_t *l);
diff --git a/src/modules/mega/mega_main.c b/src/modules/mega/mega_main.c
index 60431b2..1c5473d 100644
--- a/src/modules/mega/mega_main.c
+++ b/src/modules/mega/mega_main.c
@@ -3,8 +3,11 @@
3Eina_Bool 3Eina_Bool
4mega_login(Skypunch *skypunch) 4mega_login(Skypunch *skypunch)
5{ 5{
6 size_t len; 6 size_t len,
7 char **auth; 7 len_enc;
8 char **auth,
9 *password,
10 *password_enc;
8 unsigned int nb; 11 unsigned int nb;
9 12
10 EINA_SAFETY_ON_NULL_RETURN_VAL(skypunch, EINA_FALSE); 13 EINA_SAFETY_ON_NULL_RETURN_VAL(skypunch, EINA_FALSE);
@@ -13,8 +16,11 @@ mega_login(Skypunch *skypunch)
13 16
14 auth = eina_str_split_full(skypunch->auth, ":", 2, &nb); 17 auth = eina_str_split_full(skypunch->auth, ":", 2, &nb);
15 18
16 mega_utils_str_to_a32(auth[1], &len); 19 password = mega_utils_str_to_a32(auth[1], &len);
20 password_enc = mega_utils_key_encode(password, &len_enc);
17 21
22 free(password_enc);
23 free(password);
18 free(auth[0]); 24 free(auth[0]);
19 free(auth); 25 free(auth);
20 return EINA_TRUE; 26 return EINA_TRUE;
diff --git a/src/modules/mega/mega_utils.c b/src/modules/mega/mega_utils.c
index 57dba31..9a46641 100644
--- a/src/modules/mega/mega_utils.c
+++ b/src/modules/mega/mega_utils.c
@@ -18,23 +18,49 @@ mega_utils_str_to_a32(const char *s, size_t *l)
18 return s2; 18 return s2;
19} 19}
20 20
21/*
22void
23___print(char *s, int len)
24{
25 int i;
26 printf("___print = ");
27 for (i=0; i<len; i++)
28 printf("%02x ", s[i]);
29 printf("\n");
30}
31*/
32
21const char * 33const char *
22mega_utils_key_encode(const char *s, size_t *l) 34mega_utils_key_encode(const char *s, size_t *l)
23{ 35{
24 unsigned int i, 36 unsigned int i,
25 r = 65536; 37 r = 65536,
38 n;
26 size_t sl; 39 size_t sl;
27 char *key; 40 char pkey[16] = {0x93, 0xC4, 0x67, 0xE3, 0x7D, 0xB0, 0xC7, 0xA4,
41 0xD1, 0xBE, 0x3F, 0x81, 0x01, 0x52, 0xCB, 0x56},
42 *key;
43 WORD key_schedule[60];
28 44
29 EINA_SAFETY_ON_NULL_RETURN_VAL(s, NULL); 45 EINA_SAFETY_ON_NULL_RETURN_VAL(s, NULL);
30 EINA_SAFETY_ON_NULL_RETURN_VAL(l, NULL); 46 EINA_SAFETY_ON_NULL_RETURN_VAL(l, NULL);
31 47
32 sl = strlen(s); 48 sl = strlen(s);
33 key = calloc(1, 1024); 49 n = (sl+15)/16;
34 50
35 while (r) 51 while (r--)
36 { 52 {
37 53 for (i = 0; i < sl; i+=16)
38 r--; 54 {
55 char key[16];
56 memset(key, 0, sizeof(key));
57 strncpy(key, s + i, 16);
58
59 aes_key_setup(key, key_schedule, 128);
60 aes_encrypt(pkey, pkey, key_schedule, 128);
61 }
39 } 62 }
63 key = calloc(1, 16);
64 memcpy(key, pkey, 16);
65 return key;
40} 66}