summaryrefslogtreecommitdiff
path: root/src/lib/emile
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2015-03-17 08:50:37 +0100
committerCedric BAIL <cedric@osg.samsung.com>2015-03-17 09:58:19 +0100
commit8f3ec959b9d22d93f6ec38fc47e2339089598f8d (patch)
tree7785b85b47ceafeadf24573cdce2c6407f62dcfe /src/lib/emile
parentd32f310a9262dc055ea18ae0391b7dd629e283a6 (diff)
emile: change the API to allow supporting other cipher in the future.
Diffstat (limited to 'src/lib/emile')
-rw-r--r--src/lib/emile/emile_cipher.c6
-rw-r--r--src/lib/emile/emile_cipher.h11
-rw-r--r--src/lib/emile/emile_cipher_gnutls.c8
-rw-r--r--src/lib/emile/emile_cipher_openssl.c8
4 files changed, 25 insertions, 8 deletions
diff --git a/src/lib/emile/emile_cipher.c b/src/lib/emile/emile_cipher.c
index 544f271400..5e2db4a0e3 100644
--- a/src/lib/emile/emile_cipher.c
+++ b/src/lib/emile/emile_cipher.c
@@ -23,7 +23,8 @@ emile_binbuf_sha1(const char *key EINA_UNUSED,
23} 23}
24 24
25EAPI Eina_Binbuf * 25EAPI Eina_Binbuf *
26emile_binbuf_cipher(const Eina_Binbuf *data EINA_UNUSED, 26emile_binbuf_cipher(Emile_Cipher_Algorithm algo EINA_UNUSED,
27 const Eina_Binbuf *data EINA_UNUSED,
27 const char *key EINA_UNUSED, 28 const char *key EINA_UNUSED,
28 unsigned int length EINA_UNUSED) 29 unsigned int length EINA_UNUSED)
29{ 30{
@@ -31,7 +32,8 @@ emile_binbuf_cipher(const Eina_Binbuf *data EINA_UNUSED,
31} 32}
32 33
33EAPI Eina_Binbuf * 34EAPI Eina_Binbuf *
34emile_binbuf_decipher(const Eina_Binbuf *data EINA_UNUSED, 35emile_binbuf_decipher(Emile_Cipher_Algorithm algo EINA_UNUSED,
36 const Eina_Binbuf *data EINA_UNUSED,
35 const char *key EINA_UNUSED, 37 const char *key EINA_UNUSED,
36 unsigned int length EINA_UNUSED) 38 unsigned int length EINA_UNUSED)
37{ 39{
diff --git a/src/lib/emile/emile_cipher.h b/src/lib/emile/emile_cipher.h
index 1e2be24f24..ecf0952454 100644
--- a/src/lib/emile/emile_cipher.h
+++ b/src/lib/emile/emile_cipher.h
@@ -19,13 +19,20 @@ typedef enum
19 EMILE_WANT_WRITE = 3 19 EMILE_WANT_WRITE = 3
20} Emile_Want_Type; 20} Emile_Want_Type;
21 21
22typedef enum
23{
24 EMILE_AES256_CBC
25} Emile_Cipher_Algorithm;
26
22EAPI Eina_Bool emile_cipher_init(void); 27EAPI Eina_Bool emile_cipher_init(void);
23EAPI const char *emile_cipher_module_get(void); 28EAPI const char *emile_cipher_module_get(void);
24 29
25EAPI Eina_Binbuf *emile_binbuf_cipher(const Eina_Binbuf *in, 30EAPI Eina_Binbuf *emile_binbuf_cipher(Emile_Cipher_Algorithm algo,
31 const Eina_Binbuf *in,
26 const char *key, unsigned int length); 32 const char *key, unsigned int length);
27 33
28EAPI Eina_Binbuf *emile_binbuf_decipher(const Eina_Binbuf *in, 34EAPI Eina_Binbuf *emile_binbuf_decipher(Emile_Cipher_Algorithm algo,
35 const Eina_Binbuf *in,
29 const char *key, unsigned int length); 36 const char *key, unsigned int length);
30 37
31EAPI Eina_Bool emile_binbuf_sha1(const char *key, 38EAPI Eina_Bool emile_binbuf_sha1(const char *key,
diff --git a/src/lib/emile/emile_cipher_gnutls.c b/src/lib/emile/emile_cipher_gnutls.c
index d51ae8bb9a..5cf85e4cc5 100644
--- a/src/lib/emile/emile_cipher_gnutls.c
+++ b/src/lib/emile/emile_cipher_gnutls.c
@@ -182,7 +182,8 @@ emile_binbuf_sha1(const char *key,
182} 182}
183 183
184EAPI Eina_Binbuf * 184EAPI Eina_Binbuf *
185emile_binbuf_cipher(const Eina_Binbuf *data, 185emile_binbuf_cipher(Emile_Cipher_Algorithm algo,
186 const Eina_Binbuf *data,
186 const char *key, 187 const char *key,
187 unsigned int length) 188 unsigned int length)
188{ 189{
@@ -200,6 +201,7 @@ emile_binbuf_cipher(const Eina_Binbuf *data,
200 gcry_error_t err = 0; 201 gcry_error_t err = 0;
201 gcry_cipher_hd_t cipher; 202 gcry_cipher_hd_t cipher;
202 203
204 if (algo != EMILE_AES256_CBC) return NULL;
203 if (!emile_cipher_init()) return NULL; 205 if (!emile_cipher_init()) return NULL;
204 206
205 /* Gcrypt salt generation */ 207 /* Gcrypt salt generation */
@@ -283,7 +285,8 @@ on_error:
283} 285}
284 286
285EAPI Eina_Binbuf * 287EAPI Eina_Binbuf *
286emile_binbuf_decipher(const Eina_Binbuf *data, 288emile_binbuf_decipher(Emile_Cipher_Algorithm algo,
289 const Eina_Binbuf *data,
287 const char *key, 290 const char *key,
288 unsigned int length) 291 unsigned int length)
289{ 292{
@@ -299,6 +302,7 @@ emile_binbuf_decipher(const Eina_Binbuf *data,
299 int tmp_len; 302 int tmp_len;
300 int tmp = 0; 303 int tmp = 0;
301 304
305 if (algo != EMILE_AES256_CBC) return NULL;
302 if (!emile_cipher_init()) return NULL; 306 if (!emile_cipher_init()) return NULL;
303 307
304 over = (unsigned int*) eina_binbuf_string_get(data); 308 over = (unsigned int*) eina_binbuf_string_get(data);
diff --git a/src/lib/emile/emile_cipher_openssl.c b/src/lib/emile/emile_cipher_openssl.c
index 46143d0b45..37dbc89a2e 100644
--- a/src/lib/emile/emile_cipher_openssl.c
+++ b/src/lib/emile/emile_cipher_openssl.c
@@ -71,7 +71,8 @@ emile_binbuf_sha1(const char *key,
71} 71}
72 72
73EAPI Eina_Binbuf * 73EAPI Eina_Binbuf *
74emile_binbuf_cipher(const Eina_Binbuf *data, 74emile_binbuf_cipher(Emile_Cipher_Algorithm algo,
75 const Eina_Binbuf *data,
75 const char *key, 76 const char *key,
76 unsigned int length) 77 unsigned int length)
77{ 78{
@@ -90,6 +91,7 @@ emile_binbuf_cipher(const Eina_Binbuf *data,
90 unsigned int *buffer = NULL; 91 unsigned int *buffer = NULL;
91 int tmp_len; 92 int tmp_len;
92 93
94 if (algo != EMILE_AES256_CBC) return NULL;
93 if (!emile_cipher_init()) return NULL; 95 if (!emile_cipher_init()) return NULL;
94 96
95 /* Openssl salt generation */ 97 /* Openssl salt generation */
@@ -177,7 +179,8 @@ on_error:
177 179
178 180
179EAPI Eina_Binbuf * 181EAPI Eina_Binbuf *
180emile_binbuf_decipher(const Eina_Binbuf *data, 182emile_binbuf_decipher(Emile_Cipher_Algorithm algo,
183 const Eina_Binbuf *data,
181 const char *key, 184 const char *key,
182 unsigned int length) 185 unsigned int length)
183{ 186{
@@ -193,6 +196,7 @@ emile_binbuf_decipher(const Eina_Binbuf *data,
193 int tmp = 0; 196 int tmp = 0;
194 int opened = 0; 197 int opened = 0;
195 198
199 if (algo != EMILE_AES256_CBC) return NULL;
196 if (!emile_cipher_init()) return NULL; 200 if (!emile_cipher_init()) return NULL;
197 201
198 over = (unsigned int*) eina_binbuf_string_get(data); 202 over = (unsigned int*) eina_binbuf_string_get(data);