ENC/DEC: implement compression via lz4

This speeds up encryption/decryption considerably, but also
causes complete failure for any non-recoverable char in a message,
since the decompression will fail then.

Also remove the double base64 encode/decode.
This commit is contained in:
2014-06-09 22:11:07 +02:00
parent 0abcfee7f1
commit e4b6ca84e5
8 changed files with 106 additions and 26 deletions

View File

@@ -146,8 +146,7 @@ base64_to_poly_arr(const string *to_poly, const ntru_params *params)
uint32_t i = 0,
polyc = 0;
gsize out_len;
guchar *base64_decoded = NULL,
*base_tmp = NULL;
guchar *base64_decoded = NULL;
string *new_string = ntru_malloc(sizeof(*new_string));
fmpz_poly_t **poly_array;
char *tmp = ntru_malloc(sizeof(char) * (to_poly->len + 1));
@@ -156,13 +155,6 @@ base64_to_poly_arr(const string *to_poly, const ntru_params *params)
memcpy(tmp, to_poly->ptr, to_poly->len);
tmp[to_poly->len] = '\0';
base_tmp = g_base64_decode((const gchar *)tmp, &out_len);
/* g_base64_decode() needs it null-terminated */
REALLOC(tmp, sizeof(char) * (out_len + 1));
memcpy(tmp, base_tmp, out_len);
tmp[out_len] = '\0';
base64_decoded = g_base64_decode((const gchar *)tmp, &out_len);
new_string->ptr = (char *)base64_decoded;
@@ -200,7 +192,6 @@ base64_to_poly_arr(const string *to_poly, const ntru_params *params)
poly_array[polyc] = NULL;
string_delete(new_string);
free(base_tmp);
free(tmp);
return poly_array;