1111
1212enum {
1313 PK_PUBLIC = 0 ,
14- PK_PRIVATE = 1
14+ PK_PRIVATE = 1 ,
15+ PK_PUBLIC_COMPRESSED = 2 /* used only when exporting public ECC key */
1516};
1617
1718/* Indicates standard output formats that can be read e.g. by OpenSSL or GnuTLS */
@@ -242,6 +243,9 @@ typedef struct {
242243 /** The prime that defines the field the curve is in (encoded in hex) */
243244 char * prime ;
244245
246+ /** The fields A param (hex) */
247+ char * A ;
248+
245249 /** The fields B param (hex) */
246250 char * B ;
247251
@@ -253,6 +257,12 @@ typedef struct {
253257
254258 /** The y co-ordinate of the base point on the curve (hex) */
255259 char * Gy ;
260+
261+ /** The co-factor */
262+ unsigned long cofactor ;
263+
264+ /** The OID stucture */
265+ oid_st oid ;
256266} ltc_ecc_set_type ;
257267
258268/** A point on a ECC curve, stored in Jacbobian format such that (x,y,z) => (x/z^2, y/z^3, 1) when interpretted as affine */
@@ -292,13 +302,19 @@ int ecc_test(void);
292302void ecc_sizes (int * low , int * high );
293303int ecc_get_size (ecc_key * key );
294304
305+ ltc_ecc_set_type * ecc_dp_find_by_oid (unsigned long * oid , unsigned long oidsize );
306+ ltc_ecc_set_type * ecc_dp_find_by_name (char * curve_name );
307+ ltc_ecc_set_type * ecc_dp_find_by_params (char * hex_prime , char * hex_A , char * hex_B , char * hex_order , char * hex_Gx , char * hex_Gy , unsigned long cofactor );
308+
295309int ecc_make_key (prng_state * prng , int wprng , int keysize , ecc_key * key );
296310int ecc_make_key_ex (prng_state * prng , int wprng , ecc_key * key , const ltc_ecc_set_type * dp );
297311void ecc_free (ecc_key * key );
298312
299313int ecc_export (unsigned char * out , unsigned long * outlen , int type , ecc_key * key );
300314int ecc_import (const unsigned char * in , unsigned long inlen , ecc_key * key );
301315int ecc_import_ex (const unsigned char * in , unsigned long inlen , ecc_key * key , const ltc_ecc_set_type * dp );
316+ int ecc_export_raw (unsigned char * out , unsigned long * outlen , int type , ecc_key * key );
317+ int ecc_import_raw (const unsigned char * in , unsigned long inlen , ecc_key * key , ltc_ecc_set_type * dp );
302318
303319int ecc_ansi_x963_export (ecc_key * key , unsigned char * out , unsigned long * outlen );
304320int ecc_ansi_x963_import (const unsigned char * in , unsigned long inlen , ecc_key * key );
@@ -332,23 +348,32 @@ int ecc_verify_hash(const unsigned char *sig, unsigned long siglen,
332348 const unsigned char * hash , unsigned long hashlen ,
333349 int * stat , ecc_key * key );
334350
351+ int ecc_verify_key (ecc_key * key );
352+
353+ #ifdef LTC_SOURCE
354+ /* INTERNAL ONLY - it should be later moved to src/headers/tomcrypt_internal.h */
355+
335356/* low level functions */
336357ecc_point * ltc_ecc_new_point (void );
337358void ltc_ecc_del_point (ecc_point * p );
338359int ltc_ecc_is_valid_idx (int n );
360+ int ltc_ecc_is_point (const ltc_ecc_set_type * dp , void * x , void * y );
361+ int ltc_ecc_is_point_at_infinity (ecc_point * p , void * modulus );
362+ int ltc_ecc_import_point (const unsigned char * in , unsigned long inlen , void * prime , void * a , void * b , void * x , void * y );
363+ int ltc_ecc_export_point (unsigned char * out , unsigned long * outlen , void * x , void * y , unsigned long size , int compressed );
339364
340365/* point ops (mp == montgomery digit) */
341366#if !defined(LTC_MECC_ACCEL ) || defined(LTM_DESC ) || defined(GMP_DESC )
342367/* R = 2P */
343- int ltc_ecc_projective_dbl_point (ecc_point * P , ecc_point * R , void * modulus , void * mp );
368+ int ltc_ecc_projective_dbl_point (ecc_point * P , ecc_point * R , void * a , void * modulus , void * mp );
344369
345370/* R = P + Q */
346- int ltc_ecc_projective_add_point (ecc_point * P , ecc_point * Q , ecc_point * R , void * modulus , void * mp );
371+ int ltc_ecc_projective_add_point (ecc_point * P , ecc_point * Q , ecc_point * R , void * a , void * modulus , void * mp );
347372#endif
348373
349374#if defined(LTC_MECC_FP )
350375/* optimized point multiplication using fixed point cache (HAC algorithm 14.117) */
351- int ltc_ecc_fp_mulmod (void * k , ecc_point * G , ecc_point * R , void * modulus , int map );
376+ int ltc_ecc_fp_mulmod (void * k , ecc_point * G , ecc_point * R , void * a , void * modulus , int map );
352377
353378/* functions for saving/loading/freeing/adding to fixed point cache */
354379int ltc_ecc_fp_save_state (unsigned char * * out , unsigned long * outlen );
@@ -361,20 +386,23 @@ void ltc_ecc_fp_tablelock(int lock);
361386#endif
362387
363388/* R = kG */
364- int ltc_ecc_mulmod (void * k , ecc_point * G , ecc_point * R , void * modulus , int map );
389+ int ltc_ecc_mulmod (void * k , ecc_point * G , ecc_point * R , void * a , void * modulus , int map );
365390
366391#ifdef LTC_ECC_SHAMIR
367392/* kA*A + kB*B = C */
368393int ltc_ecc_mul2add (ecc_point * A , void * kA ,
369394 ecc_point * B , void * kB ,
370395 ecc_point * C ,
396+ void * a ,
371397 void * modulus );
372398
373399#ifdef LTC_MECC_FP
374400/* Shamir's trick with optimized point multiplication using fixed point cache */
375401int ltc_ecc_fp_mul2add (ecc_point * A , void * kA ,
376402 ecc_point * B , void * kB ,
377- ecc_point * C , void * modulus );
403+ ecc_point * C ,
404+ void * a ,
405+ void * modulus );
378406#endif
379407
380408#endif
@@ -383,6 +411,8 @@ int ltc_ecc_fp_mul2add(ecc_point *A, void *kA,
383411/* map P to affine from projective */
384412int ltc_ecc_map (ecc_point * P , void * modulus , void * mp );
385413
414+ #endif /* LTC_SOURCE */
415+
386416#endif
387417
388418#ifdef LTC_MDSA
0 commit comments