ALL: improve readability

This commit is contained in:
2014-05-28 01:17:19 +02:00
parent d8f95240c0
commit 2ec61bc87e
8 changed files with 88 additions and 0 deletions

View File

@@ -76,6 +76,8 @@ static char *
get_bin_arr_to_ascii(char *binary_rep);
/*------------------------------------------------------------------------*/
static char *
get_int_to_bin_str(uint8_t value)
{
@@ -93,6 +95,8 @@ get_int_to_bin_str(uint8_t value)
return bin_string;
}
/*------------------------------------------------------------------------*/
static char *
get_bin_arr_to_ascii(char *binary_rep)
{
@@ -121,6 +125,8 @@ get_bin_arr_to_ascii(char *binary_rep)
return int_string;
}
/*------------------------------------------------------------------------*/
fmpz_poly_t *
ascii_bin_to_bin_poly(char *to_poly, ntru_context *ctx)
{
@@ -148,6 +154,8 @@ ascii_bin_to_bin_poly(char *to_poly, ntru_context *ctx)
return new_poly;
}
/*------------------------------------------------------------------------*/
fmpz_poly_t **
ascii_to_bin_poly_arr(char *to_poly, ntru_context *ctx)
{
@@ -190,6 +198,8 @@ ascii_to_bin_poly_arr(char *to_poly, ntru_context *ctx)
return poly_array;
}
/*------------------------------------------------------------------------*/
string *
bin_poly_to_ascii(fmpz_poly_t poly,
ntru_context *ctx)
@@ -218,6 +228,8 @@ bin_poly_to_ascii(fmpz_poly_t poly,
return result_string;
}
/*------------------------------------------------------------------------*/
string *
bin_poly_arr_to_ascii(fmpz_poly_t **bin_poly_arr, ntru_context *ctx)
{
@@ -266,6 +278,8 @@ bin_poly_arr_to_ascii(fmpz_poly_t **bin_poly_arr, ntru_context *ctx)
return result_string;
}
/*------------------------------------------------------------------------*/
fmpz_poly_t **
base64_to_poly_arr(string *to_poly, ntru_context *ctx)
{
@@ -321,6 +335,8 @@ base64_to_poly_arr(string *to_poly, ntru_context *ctx)
return poly_array;
}
/*------------------------------------------------------------------------*/
string *
poly_to_base64(fmpz_poly_t poly,
ntru_context *ctx)
@@ -349,6 +365,8 @@ poly_to_base64(fmpz_poly_t poly,
return result_string;
}
/*------------------------------------------------------------------------*/
string *
poly_arr_to_base64(fmpz_poly_t **poly_array,
ntru_context *ctx)
@@ -388,3 +406,5 @@ poly_arr_to_base64(fmpz_poly_t **poly_array,
return result_string;
}
/*------------------------------------------------------------------------*/

View File

@@ -36,6 +36,8 @@
#include <fmpz.h>
/*------------------------------------------------------------------------*/
void
ntru_decrypt_poly(
fmpz_poly_t encr_msg,
@@ -57,6 +59,8 @@ ntru_decrypt_poly(
fmpz_poly_clear(a);
}
/*------------------------------------------------------------------------*/
string *
ntru_decrypt_string(
string *encr_msg,
@@ -82,3 +86,5 @@ ntru_decrypt_string(
return decr_msg;
}
/*------------------------------------------------------------------------*/

View File

@@ -37,6 +37,8 @@
#include <fmpz.h>
/*------------------------------------------------------------------------*/
void
ntru_encrypt_poly(
fmpz_poly_t msg_bin,
@@ -58,6 +60,8 @@ ntru_encrypt_poly(
fmpz_poly_clear(tmp_poly_msg);
}
/*------------------------------------------------------------------------*/
string *
ntru_encrypt_string(
char *msg,
@@ -82,3 +86,5 @@ ntru_encrypt_string(
return enc_msg;
}
/*------------------------------------------------------------------------*/

View File

@@ -44,6 +44,8 @@
#define STD_FILE_BUF 4096
/*------------------------------------------------------------------------*/
string *
read_file(char const * const filename)
{
@@ -90,6 +92,8 @@ read_file(char const * const filename)
}
}
/*------------------------------------------------------------------------*/
void
write_file(string const *wstring, char const * const filename)
{
@@ -105,3 +109,5 @@ write_file(string const *wstring, char const * const filename)
fclose(fp);
}
/*------------------------------------------------------------------------*/

View File

@@ -36,6 +36,8 @@
#include <stdbool.h>
/*------------------------------------------------------------------------*/
bool
ntru_create_keypair(
fmpz_poly_t f,
@@ -82,6 +84,8 @@ cleanup:
return retval;
}
/*------------------------------------------------------------------------*/
void
ntru_delete_keypair(keypair *pair)
{
@@ -89,3 +93,5 @@ ntru_delete_keypair(keypair *pair)
fmpz_poly_clear(pair->priv);
fmpz_poly_clear(pair->pub);
}
/*------------------------------------------------------------------------*/

View File

@@ -32,6 +32,8 @@
#include <stdlib.h>
/*------------------------------------------------------------------------*/
void *
ntru_malloc(size_t size)
{
@@ -48,6 +50,8 @@ ntru_malloc(size_t size)
return ptr;
}
/*------------------------------------------------------------------------*/
void *
ntru_calloc(size_t nmemb, size_t size)
{
@@ -63,3 +67,5 @@ ntru_calloc(size_t nmemb, size_t size)
return ptr;
}
/*------------------------------------------------------------------------*/

View File

@@ -31,6 +31,8 @@
#include <stdio.h>
/*------------------------------------------------------------------------*/
void
prints(string *print_string)
{
@@ -39,9 +41,13 @@ prints(string *print_string)
}
/*------------------------------------------------------------------------*/
void
string_delete(string *del_string)
{
free(del_string->ptr);
free(del_string);
}
/*------------------------------------------------------------------------*/

View File

@@ -57,6 +57,8 @@ void poly_mod2_to_modq(fmpz_poly_t a,
ntru_context *ctx);
/*------------------------------------------------------------------------*/
static void
poly_mod2_to_modq(fmpz_poly_t a,
fmpz_poly_t Fq,
@@ -85,6 +87,8 @@ poly_mod2_to_modq(fmpz_poly_t a,
}
/*------------------------------------------------------------------------*/
void
poly_new(fmpz_poly_t new_poly,
int const * const c,
@@ -96,12 +100,16 @@ poly_new(fmpz_poly_t new_poly,
fmpz_poly_set_coeff_si(new_poly, i, c[i]);
}
/*------------------------------------------------------------------------*/
void
poly_delete(fmpz_poly_t poly)
{
fmpz_poly_clear(poly);
}
/*------------------------------------------------------------------------*/
void
poly_delete_array(fmpz_poly_t **poly_array)
{
@@ -115,6 +123,8 @@ poly_delete_array(fmpz_poly_t **poly_array)
free(poly_array);
}
/*------------------------------------------------------------------------*/
void
poly_delete_all(fmpz_poly_t poly, ...)
{
@@ -130,6 +140,8 @@ poly_delete_all(fmpz_poly_t poly, ...)
va_end(args);
}
/*------------------------------------------------------------------------*/
void
fmpz_poly_mod_unsigned(fmpz_poly_t a,
uint32_t mod)
@@ -144,6 +156,8 @@ fmpz_poly_mod_unsigned(fmpz_poly_t a,
nmod_poly_clear(nmod_tmp);
}
/*------------------------------------------------------------------------*/
void
fmpz_poly_mod(fmpz_poly_t a,
uint32_t mod)
@@ -158,6 +172,8 @@ fmpz_poly_mod(fmpz_poly_t a,
nmod_poly_clear(nmod_tmp);
}
/*------------------------------------------------------------------------*/
void
fmpz_poly_set_coeff_fmpz_n(fmpz_poly_t poly, slong n,
const fmpz_t x)
@@ -168,6 +184,8 @@ fmpz_poly_set_coeff_fmpz_n(fmpz_poly_t poly, slong n,
fmpz_poly_set_coeff_si(poly, n, 0);
}
/*------------------------------------------------------------------------*/
int
fmpz_invmod_ui(fmpz_t f, const fmpz_t g, uint32_t mod)
{
@@ -178,6 +196,8 @@ fmpz_invmod_ui(fmpz_t f, const fmpz_t g, uint32_t mod)
return fmpz_invmod(f, g, modulus);
}
/*------------------------------------------------------------------------*/
void
fmpz_add_n(fmpz_t f, const fmpz_t g, const fmpz_t h)
{
@@ -193,6 +213,8 @@ fmpz_add_n(fmpz_t f, const fmpz_t g, const fmpz_t h)
}
}
/*------------------------------------------------------------------------*/
void
poly_starmultiply(fmpz_poly_t a,
fmpz_poly_t b,
@@ -249,6 +271,8 @@ poly_starmultiply(fmpz_poly_t a,
fmpz_poly_clear(a_tmp);
}
/*------------------------------------------------------------------------*/
bool
poly_inverse_poly_q(fmpz_poly_t a,
fmpz_poly_t Fq,
@@ -364,6 +388,8 @@ cleanup:
return retval;
}
/*------------------------------------------------------------------------*/
bool
poly_inverse_poly_p(fmpz_poly_t a,
fmpz_poly_t Fp,
@@ -532,6 +558,8 @@ cleanup:
return retval;
}
/*------------------------------------------------------------------------*/
void
poly_draw(fmpz_poly_t poly)
{
@@ -539,9 +567,13 @@ poly_draw(fmpz_poly_t poly)
flint_printf("\n");
}
/*------------------------------------------------------------------------*/
void
poly_draw_pretty(fmpz_poly_t poly)
{
fmpz_poly_print_pretty(poly, "x");
flint_printf("\n");
}
/*------------------------------------------------------------------------*/