post quantum cryptography
Highly optimized implementation of the NTRUEncrypt algorithm
|
polynomials to acii More...
#include "ntru_poly_ascii.h"
#include "ntru_common.h"
#include "ntru_mem.h"
#include "ntru_params.h"
#include "ntru_poly.h"
#include "ntru_string.h"
#include <glib.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <fmpz_poly.h>
#include <fmpz.h>
Go to the source code of this file.
Functions | |
static string * | get_bin_arr_to_ascii (const char *binary_rep) |
string * | bin_poly_to_ascii (const fmpz_poly_t poly, const ntru_params *params) |
string * | bin_poly_arr_to_ascii (const fmpz_poly_t **bin_poly_arr, const uint32_t poly_c, const ntru_params *params) |
string * | poly_to_ascii (const fmpz_poly_t poly, const ntru_params *params) |
string * | poly_arr_to_ascii (const fmpz_poly_t **poly_array, const uint32_t poly_c, const ntru_params *params) |
string * | poly_to_base64 (const fmpz_poly_t poly, const ntru_params *params) |
string * | poly_arr_to_base64 (const fmpz_poly_t **poly_array, const uint32_t poly_c, const ntru_params *params) |
polynomials to acii
This file allows to convert polynomials to ascii strings, including base64 encoded.
Definition in file ntru_poly_ascii.c.
string* bin_poly_arr_to_ascii | ( | const fmpz_poly_t ** | bin_poly_arr, |
const uint32_t | poly_c, | ||
const ntru_params * | params | ||
) |
Convert an array of binary polynomials back to a real string. The polynomial coefficients represent a binary format of the ascii string with the following mapping:
1 => 1
-1 => 0
2 => 0
The 2's are only used for filling up the last polynomial, so they will just end up as '\0's at the end of the string and will not confuse the result.
bin_poly_arr | the array of polynomials |
poly_c | the amount of polynomials in bin_poly_arr |
params | the NTRU parameters |
Definition at line 143 of file ntru_poly_ascii.c.
string* bin_poly_to_ascii | ( | const fmpz_poly_t | poly, |
const ntru_params * | params | ||
) |
Convert a single binary polynomial back to a real string. The polynomial coefficients represent a binary format of the ascii string with the following mapping:
1 => 1
-1 => 0
2 => 0
The 2's are only used for filling up the rest of the polynomial, so they will just end up as '\0's at the end of the string and will not confuse the result.
poly | the binary polynomial to convert |
params | the NTRU parameters |
Definition at line 114 of file ntru_poly_ascii.c.
static string * get_bin_arr_to_ascii | ( | const char * | binary_rep | ) | [static] |
Converts a binary representation of multiple concatenated integers to the corresponding array of ascii chars, which is NULL-terminated.
It reads in 8bit chunks, as in:
10110101|00111100|01011001 => 90|60|89 => "Z<Y"
Chunks that are 00000000 are stripped from the result.
binary_rep | the binary representation of multiple integers concatenated |
Definition at line 69 of file ntru_poly_ascii.c.
string* poly_arr_to_ascii | ( | const fmpz_poly_t ** | poly_array, |
const uint32_t | poly_c, | ||
const ntru_params * | params | ||
) |
Convert an array of polynomials back to a real string. The polynomial coefficients are expected to be in the range [0, q-1] and will be casted back to chars without any mapping.
Trailing q coefficients are only used for filling up the rest of a polynomial with '\0', so they will not confuse the result.
poly_array | the array of polynomials |
poly_c | the amount of polynomials in poly_arr |
params | the NTRU parameters |
Definition at line 203 of file ntru_poly_ascii.c.
string* poly_arr_to_base64 | ( | const fmpz_poly_t ** | poly_arr, |
const uint32_t | poly_c, | ||
const ntru_params * | params | ||
) |
Convert an array of polynomials back to a real string which is base64 encoded. The polynomial coefficients are expected to be in the range [0, q-1] and will be casted back to chars without any mapping.
Trailing q coefficients are only used for filling up the rest of a polynomial with '\0', so they will not confuse the result.
poly_arr | the array of polynomials |
poly_c | the amount of polynomials in poly_arr |
params | the NTRU parameters |
Definition at line 264 of file ntru_poly_ascii.c.
string* poly_to_ascii | ( | const fmpz_poly_t | poly, |
const ntru_params * | params | ||
) |
Convert a single polynom back to a real string which is ascii encoded (full 256 C char spectrum). The polynomial coefficients are expected to be in the range [0, q-1] and will be casted back to chars without any mapping.
Trailing q coefficients are only used for filling up the rest of a polynomial with '\0', so they will not confuse the result.
poly | the polynomial to convert |
params | the NTRU parameters |
Definition at line 180 of file ntru_poly_ascii.c.
string* poly_to_base64 | ( | const fmpz_poly_t | poly, |
const ntru_params * | params | ||
) |
Convert a single polynom back to a real string which is base64 encoded. The polynomial coefficients are expected to be in the range [0, q-1] and will be casted back to chars without any mapping.
Trailing q coefficients are only used for filling up the rest of a polynomial with '\0', so they will not confuse the result.
poly | the polynomial to convert |
params | the NTRU parameters |
Definition at line 237 of file ntru_poly_ascii.c.