post quantum cryptography
Highly optimized implementation of the NTRUEncrypt algorithm
 All Data Structures Files Functions Variables Typedefs Pages
Data Structures | Typedefs | Functions
ntru_keypair.h File Reference

public API, key handling More...

#include <ntru.h>
#include <fmpz_poly.h>
#include <fmpz.h>
#include <stdbool.h>
#include <stdint.h>
Include dependency graph for ntru_keypair.h:

Go to the source code of this file.

Data Structures

struct  keypair
 

Typedefs

typedef struct keypair keypair
 

Functions

bool ntru_create_keypair (keypair *pair, const fmpz_poly_t f, const fmpz_poly_t g, const ntru_params *params)
 
bool export_public_key (char const *const filename, const fmpz_poly_t pub, const ntru_params *params)
 
bool export_priv_key (char const *const filename, const fmpz_poly_t priv, const ntru_params *params)
 
bool import_public_key (fmpz_poly_t pub, char const *const filename, const ntru_params *params)
 
bool import_priv_key (fmpz_poly_t priv, fmpz_poly_t priv_inv, char const *const filename, const ntru_params *params)
 
void ntru_delete_keypair (keypair *pair)
 

Detailed Description

public API, key handling

This file holds the public API of generating, exporting and importing public and private keys of the pqc NTRU implementation and is meant to be installed on the client system.

Definition in file ntru_keypair.h.

Typedef Documentation

typedef struct keypair keypair

Definition at line 42 of file ntru_keypair.h.

Function Documentation

bool export_priv_key ( char const *const  filename,
const fmpz_poly_t  priv,
const ntru_params params 
)

Export the private key to a file.

Parameters
filenamethe file to save the private key into
privthe private key
paramsthe NTRU context
Returns
true for success, false if any of the file operations failed
bool export_public_key ( char const *const  filename,
const fmpz_poly_t  pub,
const ntru_params params 
)

Export the public key to a file.

Parameters
filenamethe file to save the public key into
pubthe public key
paramsthe NTRU context
Returns
true for success, false if any of the file operations failed
bool import_priv_key ( fmpz_poly_t  priv,
fmpz_poly_t  priv_inv,
char const *const  filename,
const ntru_params params 
)

Import the private key from a file and store him along with his inverse.

Parameters
privwhere to save the private key, must be initialized [out]
priv_invwhere to save the inverse of the private key, must be initialized [out]
filenamethe file to get the private key from
paramsthe NTRU context
Returns
true for success, false if any of the file operations failed
bool import_public_key ( fmpz_poly_t  pub,
char const *const  filename,
const ntru_params params 
)

Import the public key from a file.

Parameters
pubwhere to save the public key, must be initialized [out]
filenamethe file to get the public key from
paramsthe NTRU context
Returns
true for success, false if any of the file operations failed
bool ntru_create_keypair ( keypair pair,
const fmpz_poly_t  f,
const fmpz_poly_t  g,
const ntru_params params 
)

Creates an NTRU key pair, consisting of public and private components.

Parameters
pairstore private and public components here (the polynomials inside the struct will be automatically initialized) [out]
fa random ternary polynomial
ga random ternary polynomial
paramsthe NTRU context
Returns
true for success, false if f or g are not invertible (then the caller has to try different ones)
void ntru_delete_keypair ( keypair pair)

Used to free the inner structure of a keypair. This will not call free() on the pair itself.

Parameters
pairthe pair to free the inner structure of