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

NTRU encryption. More...

#include "ntru_ascii_poly.h"
#include "ntru_encrypt.h"
#include "ntru_mem.h"
#include "ntru_params.h"
#include "ntru_poly.h"
#include "ntru_poly_ascii.h"
#include "ntru_string.h"
#include <string.h>
#include <fmpz_poly.h>
#include <fmpz.h>
Include dependency graph for ntru_encrypt.c:

Go to the source code of this file.

Functions

void ntru_encrypt_poly (const fmpz_poly_t msg_bin, const fmpz_poly_t pub_key, const fmpz_poly_t rnd, fmpz_poly_t out, const ntru_params *params)
 
stringntru_encrypt_string (const string *msg, const fmpz_poly_t pub_key, const fmpz_poly_t rnd, const ntru_params *params)
 

Detailed Description

NTRU encryption.

This file handles the NTRU encryption algorithm.

Definition in file ntru_encrypt.c.

Function Documentation

void ntru_encrypt_poly ( const fmpz_poly_t  msg_tern,
const fmpz_poly_t  pub_key,
const fmpz_poly_t  rnd,
fmpz_poly_t  out,
const ntru_params params 
)

encrypt the msg, using the math: e = (h ∗ r) + m (mod q)

e = the encrypted poly

h = the public key

r = the random poly

m = the message poly

q = large mod

Parameters
msg_ternthe message to encrypt, in ternary format
pub_keythe public key
rndthe random poly (should have relatively small coefficients, but not restricted to {-1, 0, 1})
outthe output poly which is in the range {0, q-1} (not ternary!) [out]
paramsntru_params the ntru context

Definition at line 46 of file ntru_encrypt.c.

string* ntru_encrypt_string ( const string msg,
const fmpz_poly_t  pub_key,
const fmpz_poly_t  rnd,
const ntru_params params 
)

Encrypt a message in the form of a null-terminated char array and return a string.

Parameters
msgthe message
pub_keythe public key
rndthe random poly (should have relatively small coefficients, but not restricted to {-1, 0, 1})
paramsntru_params the ntru context
Returns
the newly allocated encrypted string

Definition at line 74 of file ntru_encrypt.c.