post quantum cryptography
Highly optimized implementation of the NTRUEncrypt algorithm
 All Data Structures Files Functions Variables Typedefs Macros Pages
Functions
ntru_rnd.c File Reference

random polynomials More...

#include "math.h"
#include "ntru_err.h"
#include "ntru_params.h"
#include "ntru_poly.h"
#include <fmpz_poly.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
Include dependency graph for ntru_rnd.c:

Go to the source code of this file.

Functions

int get_rnd_int (void)
 
int get_urnd_int (void)
 
void ntru_get_rnd_tern_poly_num (fmpz_poly_t poly, const ntru_params *params, uint32_t num_ones, uint32_t num_neg_ones, int(*rnd_int)(void))
 

Detailed Description

random polynomials

This file allows generation of random polynomials.

Definition in file ntru_rnd.c.

Function Documentation

int get_rnd_int ( void  )

Get a random integer from /dev/random.

Returns
random integer

Definition at line 42 of file ntru_rnd.c.

int get_urnd_int ( void  )

Get a pseudo random integer from /dev/urandom.

Returns
pseudo-random integer.

Definition at line 66 of file ntru_rnd.c.

void ntru_get_rnd_tern_poly_num ( fmpz_poly_t  poly,
const ntru_params params,
uint32_t  num_ones,
uint32_t  num_neg_ones,
int(*)(void)  rnd_int 
)

Get a random ternary polynomial with specified numbers of 1 coefficients and -1 coefficients.

Parameters
polythe resulting random polynomial [out]
paramsthe NTRU context
num_onesthe number of 1 coefficients
num_neg_onesthe number of -1 coefficients
rnd_intfunction callback which should return a random integer

Definition at line 86 of file ntru_rnd.c.