My Project
ecc.h
Go to the documentation of this file.
1 
53 int wc_ecc_make_key(WC_RNG* rng, int keysize, ecc_key* key);
54 
114 int wc_ecc_make_key_ex(WC_RNG* rng, int keysize, ecc_key* key, int curve_id);
115 
150 int wc_ecc_check_key(ecc_key* key);
151 
171 void wc_ecc_key_free(ecc_key* key);
172 
246 int wc_ecc_shared_secret(ecc_key* private_key, ecc_key* public_key, byte* out,
247  word32* outlen);
248 
292 int wc_ecc_shared_secret_ex(ecc_key* private_key, ecc_point* point,
293  byte* out, word32 *outlen);
294 
361 int wc_ecc_sign_hash(const byte* in, word32 inlen, byte* out, word32 *outlen,
362  WC_RNG* rng, ecc_key* key);
363 
432 int wc_ecc_sign_hash_ex(const byte* in, word32 inlen, WC_RNG* rng,
433  ecc_key* key, mp_int *r, mp_int *s);
434 
500 int wc_ecc_verify_hash(const byte* sig, word32 siglen, const byte* hash,
501  word32 hashlen, int* stat, ecc_key* key);
502 
539 int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
540  word32 hashlen, int* stat, ecc_key* key);
541 
563 int wc_ecc_init(ecc_key* key);
564 
589 int wc_ecc_init_ex(ecc_key* key, void* heap, int devId);
590 
611 ecc_key* wc_ecc_key_new(void* heap);
612 
632 int wc_ecc_free(ecc_key* key);
633 
657 void wc_ecc_fp_free(void);
658 
691 int wc_ecc_is_valid_idx(int n);
692 
719 ecc_point* wc_ecc_new_point(void);
720 
747 void wc_ecc_del_point(ecc_point* p);
748 
780 int wc_ecc_copy_point(ecc_point* p, ecc_point *r);
781 
823 int wc_ecc_cmp_point(ecc_point* a, ecc_point *b);
824 
864 int wc_ecc_point_is_at_infinity(ecc_point *p);
865 
898 int wc_ecc_mulmod(mp_int* k, ecc_point *G, ecc_point *R,
899  mp_int* a, mp_int* modulus, int map);
900 
964 int wc_ecc_export_x963(ecc_key* key, byte* out, word32* outLen);
965 
1035 int wc_ecc_export_x963_ex(ecc_key* key, byte* out, word32* outLen, int compressed);
1036 
1098 int wc_ecc_import_x963(const byte* in, word32 inLen, ecc_key* key);
1099 
1167 int wc_ecc_import_private_key(const byte* priv, word32 privSz, const byte* pub,
1168  word32 pubSz, ecc_key* key);
1169 
1233 int wc_ecc_rs_to_sig(const char* r, const char* s, byte* out, word32* outlen);
1234 
1298 int wc_ecc_import_raw(ecc_key* key, const char* qx, const char* qy,
1299  const char* d, const char* curveName);
1300 
1361 int wc_ecc_export_private_only(ecc_key* key, byte* out, word32* outLen);
1362 
1393 int wc_ecc_export_point_der(const int curve_idx, ecc_point* point,
1394  byte* out, word32* outLen);
1395 
1425 int wc_ecc_import_point_der(byte* in, word32 inLen, const int curve_idx,
1426  ecc_point* point);
1427 
1453 int wc_ecc_size(ecc_key* key);
1454 
1479 int wc_ecc_sig_size_calc(int sz);
1480 
1481 
1512 int wc_ecc_sig_size(ecc_key* key);
1513 
1514 
1546 ecEncCtx* wc_ecc_ctx_new(int flags, WC_RNG* rng);
1547 
1572 void wc_ecc_ctx_free(ecEncCtx*);
1573 
1603 int wc_ecc_ctx_reset(ecEncCtx* ctx, WC_RNG* rng); /* reset for use again w/o alloc/free */
1604 
1634 int wc_ecc_ctx_set_algo(ecEncCtx* ctx, byte encAlgo, byte kdfAlgo,
1635  byte macAlgo);
1636 
1669 const byte* wc_ecc_ctx_get_own_salt(ecEncCtx*);
1670 
1707 int wc_ecc_ctx_set_peer_salt(ecEncCtx* ctx, const byte* salt);
1708 
1738 int wc_ecc_ctx_set_info(ecEncCtx* ctx, const byte* info, int sz);
1739 
1799 int wc_ecc_encrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
1800  word32 msgSz, byte* out, word32* outSz, ecEncCtx* ctx);
1801 
1863 int wc_ecc_encrypt_ex(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
1864  word32 msgSz, byte* out, word32* outSz, ecEncCtx* ctx, int compressed);
1865 
1926 int wc_ecc_decrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
1927  word32 msgSz, byte* out, word32* outSz, ecEncCtx* ctx);
1928 
1929 
1970 int wc_ecc_set_nonblock(ecc_key *key, ecc_nb_ctx_t* ctx);
wc_ecc_import_raw
int wc_ecc_import_raw(ecc_key *key, const char *qx, const char *qy, const char *d, const char *curveName)
This function fills an ecc_key structure with the raw components of an ECC signature.
wc_ecc_ctx_set_peer_salt
int wc_ecc_ctx_set_peer_salt(ecEncCtx *ctx, const byte *salt)
This function sets the peer salt of an ecEncCtx object.
wc_ecc_ctx_set_algo
int wc_ecc_ctx_set_algo(ecEncCtx *ctx, byte encAlgo, byte kdfAlgo, byte macAlgo)
This function can optionally be called after wc_ecc_ctx_new. It sets the encryption,...
wc_ecc_ctx_get_own_salt
const byte * wc_ecc_ctx_get_own_salt(ecEncCtx *)
This function returns the salt of an ecEncCtx object. This function should only be called when the ec...
wc_ecc_init
int wc_ecc_init(ecc_key *key)
This function initializes an ecc_key object for future use with message verification or key negotiati...
wc_ecc_sig_size
int wc_ecc_sig_size(ecc_key *key)
This function returns the worst case size for an ECC signature, given by: (keySz * 2) + SIG_HEADER_SZ...
wc_ecc_ctx_set_info
int wc_ecc_ctx_set_info(ecEncCtx *ctx, const byte *info, int sz)
This function can optionally be called before or after wc_ecc_ctx_set_peer_salt. It sets optional inf...
wc_ecc_shared_secret
int wc_ecc_shared_secret(ecc_key *private_key, ecc_key *public_key, byte *out, word32 *outlen)
This function generates a new secret key using a local private key and a received public key....
wc_ecc_export_x963
int wc_ecc_export_x963(ecc_key *key, byte *out, word32 *outLen)
This function exports the ECC key from the ecc_key structure, storing the result in out....
wc_ecc_check_key
int wc_ecc_check_key(ecc_key *key)
Perform sanity checks on ecc key validity.
wc_ecc_cmp_point
int wc_ecc_cmp_point(ecc_point *a, ecc_point *b)
Compare the value of a point with another one.
wc_ecc_copy_point
int wc_ecc_copy_point(ecc_point *p, ecc_point *r)
Copy the value of one point to another one.
wc_ecc_import_private_key
int wc_ecc_import_private_key(const byte *priv, word32 privSz, const byte *pub, word32 pubSz, ecc_key *key)
This function imports a public/private ECC key pair from a buffer containing the raw private key,...
wc_ecc_del_point
void wc_ecc_del_point(ecc_point *p)
Free an ECC point from memory.
wc_ecc_encrypt_ex
int wc_ecc_encrypt_ex(ecc_key *privKey, ecc_key *pubKey, const byte *msg, word32 msgSz, byte *out, word32 *outSz, ecEncCtx *ctx, int compressed)
This function encrypts the given input message from msg to out. This function takes an optional ctx o...
wc_ecc_encrypt
int wc_ecc_encrypt(ecc_key *privKey, ecc_key *pubKey, const byte *msg, word32 msgSz, byte *out, word32 *outSz, ecEncCtx *ctx)
This function encrypts the given input message from msg to out. This function takes an optional ctx o...
wc_ecc_rs_to_sig
int wc_ecc_rs_to_sig(const char *r, const char *s, byte *out, word32 *outlen)
This function converts the R and S portions of an ECC signature into a DER-encoded ECDSA signature....
wc_ecc_init_ex
int wc_ecc_init_ex(ecc_key *key, void *heap, int devId)
This function initializes an ecc_key object for future use with message verification or key negotiati...
wc_ecc_sign_hash_ex
int wc_ecc_sign_hash_ex(const byte *in, word32 inlen, WC_RNG *rng, ecc_key *key, mp_int *r, mp_int *s)
Sign a message digest.
wc_ecc_import_x963
int wc_ecc_import_x963(const byte *in, word32 inLen, ecc_key *key)
This function imports a public ECC key from a buffer containing the key stored in ANSI X9....
wc_ecc_new_point
ecc_point * wc_ecc_new_point(void)
Allocate a new ECC point.
wc_ecc_import_point_der
int wc_ecc_import_point_der(byte *in, word32 inLen, const int curve_idx, ecc_point *point)
Import point from der format.
wc_ecc_is_valid_idx
int wc_ecc_is_valid_idx(int n)
Checks if an ECC idx is valid.
wc_ecc_verify_hash_ex
int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte *hash, word32 hashlen, int *stat, ecc_key *key)
Verify an ECC signature. Result is written to stat. 1 is valid, 0 is invalid. Note: Do not use the re...
wc_ecc_export_point_der
int wc_ecc_export_point_der(const int curve_idx, ecc_point *point, byte *out, word32 *outLen)
Export point to der.
wc_ecc_ctx_reset
int wc_ecc_ctx_reset(ecEncCtx *ctx, WC_RNG *rng)
This function resets an ecEncCtx structure to avoid having to free and allocate a new context object.
wc_ecc_size
int wc_ecc_size(ecc_key *key)
This function returns the key size of an ecc_key structure in octets.
wc_ecc_sign_hash
int wc_ecc_sign_hash(const byte *in, word32 inlen, byte *out, word32 *outlen, WC_RNG *rng, ecc_key *key)
This function signs a message digest using an ecc_key object to guarantee authenticity.
wc_ecc_key_free
void wc_ecc_key_free(ecc_key *key)
This function frees an ecc_key key after it has been used.
wc_ecc_mulmod
int wc_ecc_mulmod(mp_int *k, ecc_point *G, ecc_point *R, mp_int *a, mp_int *modulus, int map)
Perform ECC Fixed Point multiplication.
wc_ecc_sig_size_calc
int wc_ecc_sig_size_calc(int sz)
This function returns the worst case size for an ECC signature, given by: (keySz * 2) + SIG_HEADER_SZ...
wc_ecc_ctx_new
ecEncCtx * wc_ecc_ctx_new(int flags, WC_RNG *rng)
This function allocates and initializes space for a new ECC context object to allow secure message ex...
wc_ecc_verify_hash
int wc_ecc_verify_hash(const byte *sig, word32 siglen, const byte *hash, word32 hashlen, int *stat, ecc_key *key)
This function verifies the ECC signature of a hash to ensure authenticity. It returns the answer thro...
wc_ecc_free
int wc_ecc_free(ecc_key *key)
This function frees an ecc_key object after it has been used.
wc_ecc_point_is_at_infinity
int wc_ecc_point_is_at_infinity(ecc_point *p)
Checks if a point is at infinity. Returns 1 if point is at infinity, 0 if not, < 0 on error.
wc_ecc_ctx_free
void wc_ecc_ctx_free(ecEncCtx *)
This function frees the ecEncCtx object used for encrypting and decrypting messages.
wc_ecc_shared_secret_ex
int wc_ecc_shared_secret_ex(ecc_key *private_key, ecc_point *point, byte *out, word32 *outlen)
Create an ECC shared secret between private key and public point.
wc_ecc_make_key
int wc_ecc_make_key(WC_RNG *rng, int keysize, ecc_key *key)
This function generates a new ecc_key and stores it in key.
wc_ecc_make_key_ex
int wc_ecc_make_key_ex(WC_RNG *rng, int keysize, ecc_key *key, int curve_id)
This function generates a new ecc_key and stores it in key.
wc_ecc_export_private_only
int wc_ecc_export_private_only(ecc_key *key, byte *out, word32 *outLen)
This function exports only the private key from an ecc_key structure. It stores the private key in th...
wc_ecc_fp_free
void wc_ecc_fp_free(void)
This function frees the fixed-point cache, which can be used with ecc to speed up computation times....
wc_ecc_export_x963_ex
int wc_ecc_export_x963_ex(ecc_key *key, byte *out, word32 *outLen, int compressed)
This function exports the ECC key from the ecc_key structure, storing the result in out....
wc_ecc_key_new
ecc_key * wc_ecc_key_new(void *heap)
This function uses a user defined heap and allocates space for the key structure.
wc_ecc_decrypt
int wc_ecc_decrypt(ecc_key *privKey, ecc_key *pubKey, const byte *msg, word32 msgSz, byte *out, word32 *outSz, ecEncCtx *ctx)
This function decrypts the ciphertext from msg to out. This function takes an optional ctx object as ...
wc_ecc_set_nonblock
int wc_ecc_set_nonblock(ecc_key *key, ecc_nb_ctx_t *ctx)
Enable ECC support for non-blocking operations. Supported for Single Precision (SP) math with the fol...
b
WC_RNG byte * b
Definition: random.h:210