ndn-lite
Data Structures | Macros | Typedefs | Functions | Variables
tc_ecc.h File Reference

– Interface to common ECC functions. More...

#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  tc_uECC_Curve_t
 

Macros

#define tc_uECC_WORD_SIZE   4
 
#define tc_uECC_RNG_MAX_TRIES   64
 
#define HIGH_BIT_SET   0x80000000
 
#define tc_uECC_WORD_BITS   32
 
#define tc_uECC_WORD_BITS_SHIFT   5
 
#define tc_uECC_WORD_BITS_MASK   0x01F
 
#define NUM_ECC_WORDS   8
 
#define NUM_ECC_BYTES   (tc_uECC_WORD_SIZE*NUM_ECC_WORDS)
 
#define BYTES_TO_WORDS_8(a, b, c, d, e, f, g, h)   0x##d##c##b##a, 0x##h##g##f##e
 
#define BYTES_TO_WORDS_4(a, b, c, d)   0x##d##c##b##a
 
#define BITS_TO_WORDS(num_bits)   ((num_bits + ((tc_uECC_WORD_SIZE * 8) - 1)) / (tc_uECC_WORD_SIZE * 8))
 
#define BITS_TO_BYTES(num_bits)   ((num_bits + 7) / 8)
 

Typedefs

typedef int8_t wordcount_t
 
typedef int16_t bitcount_t
 
typedef int8_t cmpresult_t
 
typedef unsigned int tc_uECC_word_t
 
typedef uint64_t tc_uECC_dword_t
 
typedef const struct tc_uECC_Curve_ttc_uECC_Curve
 
typedef int(* tc_uECC_RNG_Function) (uint8_t *dest, unsigned int size)
 

Functions

void double_jacobian_default (tc_uECC_word_t *X1, tc_uECC_word_t *Y1, tc_uECC_word_t *Z1, tc_uECC_Curve curve)
 
void x_side_default (tc_uECC_word_t *result, const tc_uECC_word_t *x, tc_uECC_Curve curve)
 
void vli_mmod_fast_secp256r1 (unsigned int *result, unsigned int *product)
 
tc_uECC_Curve tc_uECC_secp256r1 (void)
 
int tc_uECC_generate_random_int (tc_uECC_word_t *random, const tc_uECC_word_t *top, wordcount_t num_words)
 
void tc_uECC_set_rng (tc_uECC_RNG_Function rng_function)
 
tc_uECC_RNG_Function tc_uECC_get_rng (void)
 
int tc_uECC_curve_private_key_size (tc_uECC_Curve curve)
 
int tc_uECC_curve_public_key_size (tc_uECC_Curve curve)
 
int tc_uECC_compute_public_key (const uint8_t *private_key, uint8_t *public_key, tc_uECC_Curve curve)
 
tc_uECC_word_t EccPoint_compute_public_key (tc_uECC_word_t *result, tc_uECC_word_t *private_key, tc_uECC_Curve curve)
 
tc_uECC_word_t regularize_k (const tc_uECC_word_t *const k, tc_uECC_word_t *k0, tc_uECC_word_t *k1, tc_uECC_Curve curve)
 
void EccPoint_mult (tc_uECC_word_t *result, const tc_uECC_word_t *point, const tc_uECC_word_t *scalar, const tc_uECC_word_t *initial_Z, bitcount_t num_bits, tc_uECC_Curve curve)
 
tc_uECC_word_t tc_uECC_vli_isZero (const tc_uECC_word_t *vli, wordcount_t num_words)
 
tc_uECC_word_t EccPoint_isZero (const tc_uECC_word_t *point, tc_uECC_Curve curve)
 
cmpresult_t tc_uECC_vli_cmp (const tc_uECC_word_t *left, const tc_uECC_word_t *right, wordcount_t num_words)
 
cmpresult_t tc_uECC_vli_cmp_unsafe (const tc_uECC_word_t *left, const tc_uECC_word_t *right, wordcount_t num_words)
 
void tc_uECC_vli_modSub (tc_uECC_word_t *result, const tc_uECC_word_t *left, const tc_uECC_word_t *right, const tc_uECC_word_t *mod, wordcount_t num_words)
 
void XYcZ_add (tc_uECC_word_t *X1, tc_uECC_word_t *Y1, tc_uECC_word_t *X2, tc_uECC_word_t *Y2, tc_uECC_Curve curve)
 
void apply_z (tc_uECC_word_t *X1, tc_uECC_word_t *Y1, const tc_uECC_word_t *const Z, tc_uECC_Curve curve)
 
tc_uECC_word_t tc_uECC_vli_testBit (const tc_uECC_word_t *vli, bitcount_t bit)
 
void tc_uECC_vli_mmod (tc_uECC_word_t *result, tc_uECC_word_t *product, const tc_uECC_word_t *mod, wordcount_t num_words)
 
void tc_uECC_vli_modMult_fast (tc_uECC_word_t *result, const tc_uECC_word_t *left, const tc_uECC_word_t *right, tc_uECC_Curve curve)
 
tc_uECC_word_t tc_uECC_vli_sub (tc_uECC_word_t *result, const tc_uECC_word_t *left, const tc_uECC_word_t *right, wordcount_t num_words)
 
tc_uECC_word_t tc_uECC_vli_equal (const tc_uECC_word_t *left, const tc_uECC_word_t *right, wordcount_t num_words)
 
void tc_uECC_vli_modMult (tc_uECC_word_t *result, const tc_uECC_word_t *left, const tc_uECC_word_t *right, const tc_uECC_word_t *mod, wordcount_t num_words)
 
void tc_uECC_vli_modInv (tc_uECC_word_t *result, const tc_uECC_word_t *input, const tc_uECC_word_t *mod, wordcount_t num_words)
 
void tc_uECC_vli_set (tc_uECC_word_t *dest, const tc_uECC_word_t *src, wordcount_t num_words)
 
void tc_uECC_vli_modAdd (tc_uECC_word_t *result, const tc_uECC_word_t *left, const tc_uECC_word_t *right, const tc_uECC_word_t *mod, wordcount_t num_words)
 
bitcount_t tc_uECC_vli_numBits (const tc_uECC_word_t *vli, const wordcount_t max_words)
 
void tc_uECC_vli_clear (tc_uECC_word_t *vli, wordcount_t num_words)
 
int tc_uECC_valid_point (const tc_uECC_word_t *point, tc_uECC_Curve curve)
 
int tc_uECC_valid_public_key (const uint8_t *public_key, tc_uECC_Curve curve)
 
void tc_uECC_vli_nativeToBytes (uint8_t *bytes, int num_bytes, const unsigned int *native)
 
void tc_uECC_vli_bytesToNative (unsigned int *native, const uint8_t *bytes, int num_bytes)
 

Variables

static const struct tc_uECC_Curve_t curve_secp256r1
 

Detailed Description

– Interface to common ECC functions.

Overview: This software is an implementation of common functions necessary to elliptic curve cryptography. This implementation uses curve NIST p-256.

Security: The curve NIST p-256 provides approximately 128 bits of security.

Macro Definition Documentation

◆ BITS_TO_BYTES

#define BITS_TO_BYTES (   num_bits)    ((num_bits + 7) / 8)

◆ BITS_TO_WORDS

#define BITS_TO_WORDS (   num_bits)    ((num_bits + ((tc_uECC_WORD_SIZE * 8) - 1)) / (tc_uECC_WORD_SIZE * 8))

◆ BYTES_TO_WORDS_4

#define BYTES_TO_WORDS_4 (   a,
  b,
  c,
 
)    0x##d##c##b##a

◆ BYTES_TO_WORDS_8

#define BYTES_TO_WORDS_8 (   a,
  b,
  c,
  d,
  e,
  f,
  g,
 
)    0x##d##c##b##a, 0x##h##g##f##e

◆ HIGH_BIT_SET

#define HIGH_BIT_SET   0x80000000

◆ NUM_ECC_BYTES

#define NUM_ECC_BYTES   (tc_uECC_WORD_SIZE*NUM_ECC_WORDS)

◆ NUM_ECC_WORDS

#define NUM_ECC_WORDS   8

◆ tc_uECC_RNG_MAX_TRIES

#define tc_uECC_RNG_MAX_TRIES   64

◆ tc_uECC_WORD_BITS

#define tc_uECC_WORD_BITS   32

◆ tc_uECC_WORD_BITS_MASK

#define tc_uECC_WORD_BITS_MASK   0x01F

◆ tc_uECC_WORD_BITS_SHIFT

#define tc_uECC_WORD_BITS_SHIFT   5

◆ tc_uECC_WORD_SIZE

#define tc_uECC_WORD_SIZE   4

Typedef Documentation

◆ bitcount_t

typedef int16_t bitcount_t

◆ cmpresult_t

typedef int8_t cmpresult_t

◆ tc_uECC_Curve

typedef const struct tc_uECC_Curve_t* tc_uECC_Curve

◆ tc_uECC_dword_t

typedef uint64_t tc_uECC_dword_t

◆ tc_uECC_RNG_Function

typedef int(* tc_uECC_RNG_Function) (uint8_t *dest, unsigned int size)

◆ tc_uECC_word_t

typedef unsigned int tc_uECC_word_t

◆ wordcount_t

typedef int8_t wordcount_t

Function Documentation

◆ apply_z()

void apply_z ( tc_uECC_word_t X1,
tc_uECC_word_t Y1,
const tc_uECC_word_t *const  Z,
tc_uECC_Curve  curve 
)

◆ double_jacobian_default()

void double_jacobian_default ( tc_uECC_word_t X1,
tc_uECC_word_t Y1,
tc_uECC_word_t Z1,
tc_uECC_Curve  curve 
)

◆ EccPoint_compute_public_key()

tc_uECC_word_t EccPoint_compute_public_key ( tc_uECC_word_t result,
tc_uECC_word_t private_key,
tc_uECC_Curve  curve 
)

◆ EccPoint_isZero()

tc_uECC_word_t EccPoint_isZero ( const tc_uECC_word_t point,
tc_uECC_Curve  curve 
)

◆ EccPoint_mult()

void EccPoint_mult ( tc_uECC_word_t result,
const tc_uECC_word_t point,
const tc_uECC_word_t scalar,
const tc_uECC_word_t initial_Z,
bitcount_t  num_bits,
tc_uECC_Curve  curve 
)

◆ regularize_k()

tc_uECC_word_t regularize_k ( const tc_uECC_word_t *const  k,
tc_uECC_word_t k0,
tc_uECC_word_t k1,
tc_uECC_Curve  curve 
)

◆ tc_uECC_compute_public_key()

int tc_uECC_compute_public_key ( const uint8_t *  private_key,
uint8_t *  public_key,
tc_uECC_Curve  curve 
)

◆ tc_uECC_curve_private_key_size()

int tc_uECC_curve_private_key_size ( tc_uECC_Curve  curve)

◆ tc_uECC_curve_public_key_size()

int tc_uECC_curve_public_key_size ( tc_uECC_Curve  curve)

◆ tc_uECC_generate_random_int()

int tc_uECC_generate_random_int ( tc_uECC_word_t random,
const tc_uECC_word_t top,
wordcount_t  num_words 
)

◆ tc_uECC_get_rng()

tc_uECC_RNG_Function tc_uECC_get_rng ( void  )

◆ tc_uECC_secp256r1()

tc_uECC_Curve tc_uECC_secp256r1 ( void  )

◆ tc_uECC_set_rng()

void tc_uECC_set_rng ( tc_uECC_RNG_Function  rng_function)

◆ tc_uECC_valid_point()

int tc_uECC_valid_point ( const tc_uECC_word_t point,
tc_uECC_Curve  curve 
)

◆ tc_uECC_valid_public_key()

int tc_uECC_valid_public_key ( const uint8_t *  public_key,
tc_uECC_Curve  curve 
)

◆ tc_uECC_vli_bytesToNative()

void tc_uECC_vli_bytesToNative ( unsigned int *  native,
const uint8_t *  bytes,
int  num_bytes 
)

◆ tc_uECC_vli_clear()

void tc_uECC_vli_clear ( tc_uECC_word_t vli,
wordcount_t  num_words 
)

◆ tc_uECC_vli_cmp()

cmpresult_t tc_uECC_vli_cmp ( const tc_uECC_word_t left,
const tc_uECC_word_t right,
wordcount_t  num_words 
)

◆ tc_uECC_vli_cmp_unsafe()

cmpresult_t tc_uECC_vli_cmp_unsafe ( const tc_uECC_word_t left,
const tc_uECC_word_t right,
wordcount_t  num_words 
)

◆ tc_uECC_vli_equal()

tc_uECC_word_t tc_uECC_vli_equal ( const tc_uECC_word_t left,
const tc_uECC_word_t right,
wordcount_t  num_words 
)

◆ tc_uECC_vli_isZero()

tc_uECC_word_t tc_uECC_vli_isZero ( const tc_uECC_word_t vli,
wordcount_t  num_words 
)

◆ tc_uECC_vli_mmod()

void tc_uECC_vli_mmod ( tc_uECC_word_t result,
tc_uECC_word_t product,
const tc_uECC_word_t mod,
wordcount_t  num_words 
)

◆ tc_uECC_vli_modAdd()

void tc_uECC_vli_modAdd ( tc_uECC_word_t result,
const tc_uECC_word_t left,
const tc_uECC_word_t right,
const tc_uECC_word_t mod,
wordcount_t  num_words 
)

◆ tc_uECC_vli_modInv()

void tc_uECC_vli_modInv ( tc_uECC_word_t result,
const tc_uECC_word_t input,
const tc_uECC_word_t mod,
wordcount_t  num_words 
)

◆ tc_uECC_vli_modMult()

void tc_uECC_vli_modMult ( tc_uECC_word_t result,
const tc_uECC_word_t left,
const tc_uECC_word_t right,
const tc_uECC_word_t mod,
wordcount_t  num_words 
)

◆ tc_uECC_vli_modMult_fast()

void tc_uECC_vli_modMult_fast ( tc_uECC_word_t result,
const tc_uECC_word_t left,
const tc_uECC_word_t right,
tc_uECC_Curve  curve 
)

◆ tc_uECC_vli_modSub()

void tc_uECC_vli_modSub ( tc_uECC_word_t result,
const tc_uECC_word_t left,
const tc_uECC_word_t right,
const tc_uECC_word_t mod,
wordcount_t  num_words 
)

◆ tc_uECC_vli_nativeToBytes()

void tc_uECC_vli_nativeToBytes ( uint8_t *  bytes,
int  num_bytes,
const unsigned int *  native 
)

◆ tc_uECC_vli_numBits()

bitcount_t tc_uECC_vli_numBits ( const tc_uECC_word_t vli,
const wordcount_t  max_words 
)

◆ tc_uECC_vli_set()

void tc_uECC_vli_set ( tc_uECC_word_t dest,
const tc_uECC_word_t src,
wordcount_t  num_words 
)

◆ tc_uECC_vli_sub()

tc_uECC_word_t tc_uECC_vli_sub ( tc_uECC_word_t result,
const tc_uECC_word_t left,
const tc_uECC_word_t right,
wordcount_t  num_words 
)

◆ tc_uECC_vli_testBit()

tc_uECC_word_t tc_uECC_vli_testBit ( const tc_uECC_word_t vli,
bitcount_t  bit 
)

◆ vli_mmod_fast_secp256r1()

void vli_mmod_fast_secp256r1 ( unsigned int *  result,
unsigned int *  product 
)

◆ x_side_default()

void x_side_default ( tc_uECC_word_t result,
const tc_uECC_word_t x,
tc_uECC_Curve  curve 
)

◆ XYcZ_add()

void XYcZ_add ( tc_uECC_word_t X1,
tc_uECC_word_t Y1,
tc_uECC_word_t X2,
tc_uECC_word_t Y2,
tc_uECC_Curve  curve 
)

Variable Documentation

◆ curve_secp256r1

const struct tc_uECC_Curve_t curve_secp256r1
static