Hi,
I want to use TinyECC in Eclipse.
Where do I have to include the TinyECC-Folder that I can use it correctly?

I included it in the run configurations, in the global tinyOS-Settings and in the project preferences. the plugin finds the files from ECC, but it throws me errors in ECC.h which i included in the first row.
the error is:
(in included file; see ECC.h: 72) data object declaration: expected a 'field declarations', common missing tokens at this place: '}', to complete expression, insert one of: '}', 'typedef', 'extern', 'static', 'auto', 'register', 'void', 'char', 'short', 'int', 'long', 'float', 'double', 'signed', 'unsigned', '_BOOL', '_Complex', 'struct', 'union', 'enum', 'const', 'restrict', 'volatile', 'inline', 'default', 'nx_struct',
 'nx_union', 'command', 'event', 'async', 'norace', 'task', 'typedef name'

This error is dislpayed for other rows in ECC.h, too.
When I open ECC.h, there is no error showen.
I attached the ECC.h and the in ECC.h included NN.h

Thanks for your help!
Markus
/**
 * $Id: ECC.h,v 1.13 2007/11/02 22:36:39 aliu3 Exp $
 * Ecc.h
 * define the data structure for ECC operation
 */

#ifndef _ECC_H_
#define _ECC_H_

#include "NN.h"


#ifndef PROJECTIVE
	#define AFFINE
#endif

#ifdef PROJECTIVE
	//enable mixed projective coordinate addition
	#define ADD_MIX
	//enable repeated point doubling
	#define REPEAT_DOUBLE
#endif


#ifdef SLIDING_WIN
	//The size of sliding window, must be power of 2 (change this if you
	//want to use other window size, for example: 2 or 4)
	#define W_BITS 4
	
	//basic mask used to generate mask array (you need to change this if
	//you want to change window size)
	//For example: if W_BITS is 2, BASIC_MASK must be 0x03;
	//             if W_BITS is 4, BASIC_MASK must be 0x0f
	//			   if W_BITS is 8, BASIC_MASK must be 0xff
	#define BASIC_MASK 0xf
	
	//number of windows in one digit, NUM_MASKS = NN_DIGIT_BITS/W_BITS
	#define NUM_MASKS (NN_DIGIT_BITS/W_BITS)
	
	//number of points for precomputed points, NN_POINTS = 2^W_BITS - 1
	#define NUM_POINTS ((1 << W_BITS) - 1)

#endif

//the data structure define the elliptic curve
struct Curve
{
  // curve's coefficients
  NN_DIGIT a[NUMWORDS];
  NN_DIGIT b[NUMWORDS];
  
  //whether a is -3
  uint8_t a_minus3;
  
  //whether a is zero
  uint8_t a_zero;
  
  uint8_t a_one;
};
typedef struct Curve Curve;

struct Point
{
  // point's coordinates
  NN_DIGIT x[NUMWORDS];
  NN_DIGIT y[NUMWORDS];
};
typedef struct Point Point;

struct ZCoordinate
{
  NN_DIGIT z[NUMWORDS];
};
typedef struct ZCoordinate ZCoordinate;

//all the parameters needed for elliptic curve operation
struct Params
{
    // prime modulus
    NN_DIGIT p[NUMWORDS];

    // Omega, p = 2^m -omega
    NN_DIGIT omega[NUMWORDS];

    // curve over which ECC will be performed
    Curve E;

    // base point, a point on E of order r
    Point G;

    // a positive, prime integer dividing the number of points on E
    NN_DIGIT r[NUMWORDS];

    // a positive prime integer, s.t. k = #E/r
//    NN_DIGIT k[NUMWORDS];
};
typedef struct Params Params;

//all the parameters needed for elliptic curve operations of Tate Pairing
struct TPParams
{
  // prime modulus
  NN_DIGIT p[NUMWORDS];
  
  // curve over which ECC will be performed
  Curve E;
  
  // group order m
  NN_DIGIT m[NUMWORDS];
  
  // c = ((p^k)-1)/m
  NN_DIGIT c[NUMWORDS];
  
  // point P
  Point P;
};
typedef struct TPParams TPParams;

//structure for precomputed points and slope
struct PointSlope {
  uint8_t dbl;  //TRUE for double, FALSE for add
  Point P;
  NN_DIGIT slope[NUMWORDS];
  struct PointSlope * next;
};
typedef struct PointSlope PointSlope;

#endif
/**
 * $Id: NN.h,v 1.9 2007/09/12 18:17:06 aliu3 Exp $
 */

#ifndef _NN_H_
#define _NN_H_

// frequency (in MHz) of the imote2 processor
#if CORE_FREQ == 13
	#define CORE_BUS 13
#elif CORE_FREQ == 104
	#define CORE_BUS 104
#elif CORE_FREQ == 208
	#define CORE_BUS 208
#elif CORE_FREQ == 416
	#define CORE_BUS 208
#endif

//#define BARRETT_REDUCTION
//#define HYBRID_MULT  //hybrid multiplication
//#define HYBRID_SQR //hybrd squaring
//#define CURVE_OPT  //optimization for SECG curves


#define MODINVOPT

#ifdef TEST_VECTOR
	#define KEY_BIT_LEN 160
	#define HYBRID_MUL_WIDTH5
#else
#if defined (SECP128R1) || defined (SECP128R2)
	#define KEY_BIT_LEN 128
	#define HYBRID_MUL_WIDTH4
#else
#if defined (SECP160K1) || defined (SECP160R1) || defined (SECP160R2)
	#define KEY_BIT_LEN 160
	#define HYBRID_MUL_WIDTH5  //column width=5 for hybrid multiplication
#else
#if defined (SECP192K1) || defined (SECP192R1) || defined (SS192K2) || defined (SS192K2S)
	#define KEY_BIT_LEN 192
	#define HYBRID_MUL_WIDTH4
#else
#if defined (SS512K2) || defined (SS512K2S)
	#define BARRETT_REDUCTION
	#define KEY_BIT_LEN 512
	#define HYBRID_MUL_WIDTH5
#endif // end of 512
#endif  //end of 192
#endif  //end of 160
#endif  //end of 128
#endif  //TEST_VECTOR


//mica, mica2, micaz
#ifdef PLATFORM_MICAZ
	#define EIGHT_BIT_PROCESSOR
	#define INLINE_ASM
#endif

//telosb
#ifdef PLATFORM_TELOSB
	#define SIXTEEN_BIT_PROCESSOR
	#define INLINE_ASM
#endif

//imote2
#ifdef PLATFORM_IMOTE2
	#define THIRTYTWO_BIT_PROCESSOR
	#define INLINE_ASM
#endif


#ifdef EIGHT_BIT_PROCESSOR
	/* Type definitions */
	typedef uint8_t NN_DIGIT;
	typedef uint16_t NN_DOUBLE_DIGIT;
	
	/* Types for length */
	typedef uint8_t NN_UINT;
	typedef uint16_t NN_UINT2;
	
	/* Length of digit in bits */
	#define NN_DIGIT_BITS 8
	
	/* Length of digit in bytes */
	#define NN_DIGIT_LEN (NN_DIGIT_BITS/8)
	
	/* Maximum value of digit */
	#define MAX_NN_DIGIT 0xff
	
	/* Number of digits in key
	 * used by optimized mod multiplication (ModMultOpt) and optimized mod square (ModSqrOpt)
	 *
	 */
	#define KEYDIGITS (KEY_BIT_LEN/NN_DIGIT_BITS) //20
	
	/* Maximum length in digits */
	#define MAX_NN_DIGITS (KEYDIGITS+1)
	
	/* buffer size
	 *should be large enough to hold order of base point
	 */
	#define NUMWORDS MAX_NN_DIGITS
#endif  //EIGHT_BIT_PROCESSOR



#ifdef SIXTEEN_BIT_PROCESSOR
	/* Type definitions */
	typedef uint16_t NN_DIGIT;
	typedef uint32_t NN_DOUBLE_DIGIT;
	
	/* Types for length */
	typedef uint8_t NN_UINT;
	typedef uint16_t NN_UINT2;
	
	/* Length of digit in bits */
	#define NN_DIGIT_BITS 16
	
	/* Length of digit in bytes */
	#define NN_DIGIT_LEN (NN_DIGIT_BITS/8)
	
	/* Maximum value of digit */
	#define MAX_NN_DIGIT 0xffff
	
	/* Number of digits in key
	 * used by optimized mod multiplication (ModMultOpt) and optimized mod square (ModSqrOpt)
	 *
	 */
	#define KEYDIGITS (KEY_BIT_LEN/NN_DIGIT_BITS) //10
	
	/* Maximum length in digits */
	#define MAX_NN_DIGITS (KEYDIGITS+1)
	
	/* buffer size
	 *should be large enough to hold order of base point
	 */
	#define NUMWORDS MAX_NN_DIGITS
#endif  //SIXTEEN_BIT_PROCESSOR



#ifdef THIRTYTWO_BIT_PROCESSOR
	/* Type definitions */
	typedef uint32_t NN_DIGIT;
	typedef uint64_t NN_DOUBLE_DIGIT;
	
	/* Types for length */
	typedef uint8_t NN_UINT;
	typedef uint16_t NN_UINT2;
	
	/* Length of digit in bits */
	#define NN_DIGIT_BITS 32
	
	/* Length of digit in bytes */
	#define NN_DIGIT_LEN (NN_DIGIT_BITS/8)
	
	/* Maximum value of digit */
	#define MAX_NN_DIGIT 0xffffffff
	
	/* Number of digits in key
	 * used by optimized mod multiplication (ModMultOpt) and optimized mod square (ModSqrOpt)
	 *
	 */
	#define KEYDIGITS (KEY_BIT_LEN/NN_DIGIT_BITS) //5
	
	/* Maximum length in digits */
	#define MAX_NN_DIGITS (KEYDIGITS+1)
	
	/* buffer size
	 *should be large enough to hold order of base point
	 */
	#define NUMWORDS MAX_NN_DIGITS
#endif  //THIRTYTWO_BIT_PROCESSOR


struct Barrett{
  NN_DIGIT mu[2*MAX_NN_DIGITS+1];
  NN_UINT mu_len;
  NN_UINT km;  //length of moduli m, m_{k-1} != 0
};
typedef struct Barrett Barrett;

#endif
_______________________________________________
Tinyos-help mailing list
Tinyos-help@millennium.berkeley.edu
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to