forked from enlightenment/efl
emile: change the API to allow supporting other cipher in the future.
This commit is contained in:
parent
d32f310a92
commit
8f3ec959b9
|
@ -883,7 +883,7 @@ eet_cipher(const void *data,
|
|||
Eina_Binbuf *in;
|
||||
|
||||
in = eina_binbuf_manage_read_only_new_length(data, size);
|
||||
out = emile_binbuf_cipher(in, key, length);
|
||||
out = emile_binbuf_cipher(EMILE_AES256_CBC, in, key, length);
|
||||
|
||||
if (result_length) *result_length = out ? eina_binbuf_length_get(out) : 0;
|
||||
if (result) *result = out ? eina_binbuf_string_steal(out) : NULL;
|
||||
|
@ -904,7 +904,7 @@ eet_decipher(const void *data,
|
|||
Eina_Binbuf *in;
|
||||
|
||||
in = eina_binbuf_manage_read_only_new_length(data, size);
|
||||
out = emile_binbuf_decipher(in, key, length);
|
||||
out = emile_binbuf_decipher(EMILE_AES256_CBC, in, key, length);
|
||||
|
||||
if (result_length) *result_length = out ? eina_binbuf_length_get(out) : 0;
|
||||
if (result) *result = out ? eina_binbuf_string_steal(out) : NULL;
|
||||
|
|
|
@ -1873,7 +1873,8 @@ eet_read_cipher(Eet_File *ef,
|
|||
{
|
||||
Eina_Binbuf *out;
|
||||
|
||||
out = emile_binbuf_decipher(in, cipher_key, strlen(cipher_key));
|
||||
out = emile_binbuf_decipher(EMILE_AES256_CBC, in,
|
||||
cipher_key, strlen(cipher_key));
|
||||
|
||||
eina_binbuf_free(in);
|
||||
if (!out) goto on_error;
|
||||
|
@ -2352,7 +2353,8 @@ eet_write_cipher(Eet_File *ef,
|
|||
{
|
||||
Eina_Binbuf *out;
|
||||
|
||||
out = emile_binbuf_cipher(in, cipher_key, strlen(cipher_key));
|
||||
out = emile_binbuf_cipher(EMILE_AES256_CBC, in,
|
||||
cipher_key, strlen(cipher_key));
|
||||
// Old behaviour was to not fail if the cipher where not built in
|
||||
if (out)
|
||||
{
|
||||
|
|
|
@ -23,7 +23,8 @@ emile_binbuf_sha1(const char *key EINA_UNUSED,
|
|||
}
|
||||
|
||||
EAPI Eina_Binbuf *
|
||||
emile_binbuf_cipher(const Eina_Binbuf *data EINA_UNUSED,
|
||||
emile_binbuf_cipher(Emile_Cipher_Algorithm algo EINA_UNUSED,
|
||||
const Eina_Binbuf *data EINA_UNUSED,
|
||||
const char *key EINA_UNUSED,
|
||||
unsigned int length EINA_UNUSED)
|
||||
{
|
||||
|
@ -31,7 +32,8 @@ emile_binbuf_cipher(const Eina_Binbuf *data EINA_UNUSED,
|
|||
}
|
||||
|
||||
EAPI Eina_Binbuf *
|
||||
emile_binbuf_decipher(const Eina_Binbuf *data EINA_UNUSED,
|
||||
emile_binbuf_decipher(Emile_Cipher_Algorithm algo EINA_UNUSED,
|
||||
const Eina_Binbuf *data EINA_UNUSED,
|
||||
const char *key EINA_UNUSED,
|
||||
unsigned int length EINA_UNUSED)
|
||||
{
|
||||
|
|
|
@ -19,13 +19,20 @@ typedef enum
|
|||
EMILE_WANT_WRITE = 3
|
||||
} Emile_Want_Type;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
EMILE_AES256_CBC
|
||||
} Emile_Cipher_Algorithm;
|
||||
|
||||
EAPI Eina_Bool emile_cipher_init(void);
|
||||
EAPI const char *emile_cipher_module_get(void);
|
||||
|
||||
EAPI Eina_Binbuf *emile_binbuf_cipher(const Eina_Binbuf *in,
|
||||
EAPI Eina_Binbuf *emile_binbuf_cipher(Emile_Cipher_Algorithm algo,
|
||||
const Eina_Binbuf *in,
|
||||
const char *key, unsigned int length);
|
||||
|
||||
EAPI Eina_Binbuf *emile_binbuf_decipher(const Eina_Binbuf *in,
|
||||
EAPI Eina_Binbuf *emile_binbuf_decipher(Emile_Cipher_Algorithm algo,
|
||||
const Eina_Binbuf *in,
|
||||
const char *key, unsigned int length);
|
||||
|
||||
EAPI Eina_Bool emile_binbuf_sha1(const char *key,
|
||||
|
|
|
@ -182,7 +182,8 @@ emile_binbuf_sha1(const char *key,
|
|||
}
|
||||
|
||||
EAPI Eina_Binbuf *
|
||||
emile_binbuf_cipher(const Eina_Binbuf *data,
|
||||
emile_binbuf_cipher(Emile_Cipher_Algorithm algo,
|
||||
const Eina_Binbuf *data,
|
||||
const char *key,
|
||||
unsigned int length)
|
||||
{
|
||||
|
@ -200,6 +201,7 @@ emile_binbuf_cipher(const Eina_Binbuf *data,
|
|||
gcry_error_t err = 0;
|
||||
gcry_cipher_hd_t cipher;
|
||||
|
||||
if (algo != EMILE_AES256_CBC) return NULL;
|
||||
if (!emile_cipher_init()) return NULL;
|
||||
|
||||
/* Gcrypt salt generation */
|
||||
|
@ -283,7 +285,8 @@ on_error:
|
|||
}
|
||||
|
||||
EAPI Eina_Binbuf *
|
||||
emile_binbuf_decipher(const Eina_Binbuf *data,
|
||||
emile_binbuf_decipher(Emile_Cipher_Algorithm algo,
|
||||
const Eina_Binbuf *data,
|
||||
const char *key,
|
||||
unsigned int length)
|
||||
{
|
||||
|
@ -299,6 +302,7 @@ emile_binbuf_decipher(const Eina_Binbuf *data,
|
|||
int tmp_len;
|
||||
int tmp = 0;
|
||||
|
||||
if (algo != EMILE_AES256_CBC) return NULL;
|
||||
if (!emile_cipher_init()) return NULL;
|
||||
|
||||
over = (unsigned int*) eina_binbuf_string_get(data);
|
||||
|
|
|
@ -71,7 +71,8 @@ emile_binbuf_sha1(const char *key,
|
|||
}
|
||||
|
||||
EAPI Eina_Binbuf *
|
||||
emile_binbuf_cipher(const Eina_Binbuf *data,
|
||||
emile_binbuf_cipher(Emile_Cipher_Algorithm algo,
|
||||
const Eina_Binbuf *data,
|
||||
const char *key,
|
||||
unsigned int length)
|
||||
{
|
||||
|
@ -90,6 +91,7 @@ emile_binbuf_cipher(const Eina_Binbuf *data,
|
|||
unsigned int *buffer = NULL;
|
||||
int tmp_len;
|
||||
|
||||
if (algo != EMILE_AES256_CBC) return NULL;
|
||||
if (!emile_cipher_init()) return NULL;
|
||||
|
||||
/* Openssl salt generation */
|
||||
|
@ -177,7 +179,8 @@ on_error:
|
|||
|
||||
|
||||
EAPI Eina_Binbuf *
|
||||
emile_binbuf_decipher(const Eina_Binbuf *data,
|
||||
emile_binbuf_decipher(Emile_Cipher_Algorithm algo,
|
||||
const Eina_Binbuf *data,
|
||||
const char *key,
|
||||
unsigned int length)
|
||||
{
|
||||
|
@ -193,6 +196,7 @@ emile_binbuf_decipher(const Eina_Binbuf *data,
|
|||
int tmp = 0;
|
||||
int opened = 0;
|
||||
|
||||
if (algo != EMILE_AES256_CBC) return NULL;
|
||||
if (!emile_cipher_init()) return NULL;
|
||||
|
||||
over = (unsigned int*) eina_binbuf_string_get(data);
|
||||
|
|
Loading…
Reference in New Issue