post quantum cryptography
Highly optimized implementation of the NTRUEncrypt algorithm
|
ascii to polynomials More...
#include "ntru_ascii_poly.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 char * | get_int_to_bin_str (uint8_t value) |
fmpz_poly_t * | ascii_bin_to_bin_poly (const char *to_poly, const ntru_params *params) |
fmpz_poly_t ** | ascii_to_bin_poly_arr (const string *to_poly, const ntru_params *params) |
fmpz_poly_t ** | base64_to_poly_arr (const string *to_poly, const ntru_params *params) |
ascii to polynomials
This file allows to convert ascii strings, including base64 encoded ones, to polynomials.
Definition in file ntru_ascii_poly.c.
fmpz_poly_t* ascii_bin_to_bin_poly | ( | const char * | to_poly, |
const ntru_params * | params | ||
) |
Convert a "binary" ascii string to a binary polyomial. The ascii string will be converted to a binary representation and the following mapping will apply between binary -> poly:
1 => 1
0 => -1
If the polynomial is of degree less than N -1, then it will be filled with trailing 2's for later use in bin_poly_to_ascii().
to_poly | the string to get into binary polynomial format |
params | the NTRUEncrypt context |
Definition at line 81 of file ntru_ascii_poly.c.
fmpz_poly_t** ascii_to_bin_poly_arr | ( | const string * | to_poly, |
const ntru_params * | params | ||
) |
Convert an ascii string to an array of binary polyomials. The ascii string will be converted to a binary representation and the following mapping will apply between binary -> poly:
1 => 1
0 => -1
If the last polynomial is of degree less than N -1, then it will be filled with trailing 2's for later use in bin_poly_arr_to_ascii().
to_poly | the string to get into binary polynomial format |
params | the NTRUEncrypt context |
Definition at line 101 of file ntru_ascii_poly.c.
fmpz_poly_t** base64_to_poly_arr | ( | const string * | to_poly, |
const ntru_params * | params | ||
) |
Convert an base64 encoded string to an array of polyomials with coefficients which are expected to be in the range [0, q-1]. The chars will be converted (after decoding) to their integer representation and directly put into the coefficients.
If the last polynomial is of degree less than N -1, then it will be filled with trailing q's for later user in poly_arr_to_base64().
to_poly | the string to get into polynomial format, which is of type string, so we can iterate safely over it (the string might have null-bytes in the middle of it) |
params | the NTRUEncrypt context |
Definition at line 146 of file ntru_ascii_poly.c.
|
static |
Convert an integer to it's binary representation as a string and return it.
As in: 90 => "10110101"
value | the integer to convert |
Definition at line 62 of file ntru_ascii_poly.c.