ndn-lite
Functions | Variables
tc_ecc_dsa.c File Reference
#include "tc_constants.h"
#include "tc_ecc.h"
#include "tc_ecc_dsa.h"

Functions

static void bits2int (tc_uECC_word_t *native, const uint8_t *bits, unsigned bits_size, tc_uECC_Curve curve)
 
int tc_uECC_sign_with_k (const uint8_t *private_key, const uint8_t *message_hash, unsigned hash_size, tc_uECC_word_t *k, uint8_t *signature, tc_uECC_Curve curve)
 
int tc_uECC_sign (const uint8_t *private_key, const uint8_t *message_hash, unsigned hash_size, uint8_t *signature, tc_uECC_Curve curve)
 Generate an ECDSA signature for a given hash value. More...
 
static bitcount_t smax (bitcount_t a, bitcount_t b)
 
int tc_uECC_verify (const uint8_t *public_key, const uint8_t *message_hash, unsigned hash_size, const uint8_t *signature, tc_uECC_Curve curve)
 

Variables

static tc_uECC_RNG_Function g_rng_function = 0
 

Function Documentation

◆ bits2int()

static void bits2int ( tc_uECC_word_t native,
const uint8_t *  bits,
unsigned  bits_size,
tc_uECC_Curve  curve 
)
static

◆ smax()

static bitcount_t smax ( bitcount_t  a,
bitcount_t  b 
)
static

◆ tc_uECC_sign()

int tc_uECC_sign ( const uint8_t *  p_private_key,
const uint8_t *  p_message_hash,
unsigned  p_hash_size,
uint8_t *  p_signature,
tc_uECC_Curve  curve 
)

Generate an ECDSA signature for a given hash value.

Returns
returns TC_CRYPTO_SUCCESS (1) if the signature generated successfully returns TC_CRYPTO_FAIL (0) if an error occurred.
Parameters
p_private_keyIN – Your private key.
p_message_hashIN – The hash of the message to sign.
p_hash_sizeIN – The size of p_message_hash in bytes.
p_signatureOUT – Will be filled in with the signature value. Must be at least 2 * curve size long (for secp256r1, signature must be 64 bytes long).
Warning
A cryptographically-secure PRNG function must be set (using tc_uECC_set_rng()) before calling tc_uECC_sign().
Note
Usage: Compute a hash of the data you wish to sign (SHA-2 is recommended) and pass it in to this function along with your private key.
side-channel countermeasure: algorithm strengthened against timing attack.

◆ tc_uECC_sign_with_k()

int tc_uECC_sign_with_k ( const uint8_t *  private_key,
const uint8_t *  message_hash,
unsigned  hash_size,
tc_uECC_word_t k,
uint8_t *  signature,
tc_uECC_Curve  curve 
)

◆ tc_uECC_verify()

int tc_uECC_verify ( const uint8_t *  public_key,
const uint8_t *  message_hash,
unsigned  hash_size,
const uint8_t *  signature,
tc_uECC_Curve  curve 
)

Variable Documentation

◆ g_rng_function

tc_uECC_RNG_Function g_rng_function = 0
static