Table Of Contents

Previous topic

Welcome to PyECC’s documentation!

Next topic

_pyecc.c

This Page

libseccure

libseccure is a small, portable C library that handles abstracting much of the work involved with ECC.

Constants

DEFAULT_CURVE: p384

DEFAULT_MAC_LEN: 10

Datatypes

ECC_State

The ECC_State object is passed from function to function in order to ensure some information about the curves, the state of the libgcrypt memory pools, etc are accessible.

  • bool gcrypt_init: set to true if the libgcrypt memory pool(s) and number generators have been properly initialized
  • ECC_Options options: defaults to NULL but can be filled with an allocated ECC_Options object
  • struct curveparams * curveparams: allocated curveparams structure, the contents of this struct are dependent on the curve loaded (defaults to DEFAULT_CURVE)

ECC_Options

  • char * curve: string representation of the curve to use, defaults to DEFAULT_CURVE
  • bool secure_random: enable/disable libgcrypt’s secure random number generator (defaults to true)

ECC_KeyPair

  • gcry_mpi_t priv: numeric representation of the private key, use ecc_new_keypair to properly generate this
  • void * pub: binary data representing the public key
  • unsigned int pub_bytes: number of bytes the pub member contains (as it’s not NULL terminated)

ECC_Data

  • void * data: generic pointer referncing the memory containing data
  • unsigned int datalen: number of bytes the data member contains

Internal Functions

ECC_State ecc_new_state( ECC_Options options )

void ecc_free_state( ECC_State state )

ECC_KeyPair ecc_new_keypair( char * publickey, char * privatekey, ECC_State state )

void ecc_free_keypair( ECC_KeyPair keypair )

ECC_Options ecc_new_options(void)

ECC_Data ecc_new_data(void)

void ecc_free_data( ECC_Data data )

Crypto Functions

const char * ecc_mpi_to_str( gcry_mpi_t key )

char * ecc_serialize_private_key( ECC_KeyPair keypair, ECC_State state )

ECC_Data ecc_encrypt( void * data, int datalen, ECC_KeyPair keypair, ECC_State state )

ECC_Data ecc_decrypt( ECC_Data data, ECC_KeyPair keypair, ECC_State state )

ECC_Data ecc_sign( char * data, ECC_KeyPair keypair, ECC_State state )

bool ecc_verify( char * data, char * signature, ECC_KeyPair keypair, ECC_State state )