Ignore:
Timestamp:
Feb 7, 2019, 8:36:33 AM (5 years ago)
Author:
coas-nagasima
Message:

wolfsslを3.15.7にバージョンアップ

File:
1 edited

Legend:

Unmodified
Added
Removed
  • asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/ecc.h

    r352 r372  
    2020 */
    2121
     22/*!
     23    \file wolfssl/wolfcrypt/ecc.h
     24*/
     25
    2226
    2327#ifndef WOLF_CRYPT_ECC_H
     
    2731
    2832#ifdef HAVE_ECC
     33
     34#if defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)
     35    #include <wolfssl/wolfcrypt/fips.h>
     36#endif /* HAVE_FIPS_VERSION >= 2 */
    2937
    3038#include <wolfssl/wolfcrypt/integer.h>
     
    7381#elif defined(HAVE_ECC320)
    7482    #define MAX_ECC_BITS    320
     83#elif !defined(NO_ECC256)
     84    #define MAX_ECC_BITS    256
    7585#elif defined(HAVE_ECC239)
    7686    #define MAX_ECC_BITS    239
    7787#elif defined(HAVE_ECC224)
    7888    #define MAX_ECC_BITS    224
    79 #elif !defined(NO_ECC256)
    80     #define MAX_ECC_BITS    256
    8189#elif defined(HAVE_ECC192)
    8290    #define MAX_ECC_BITS    192
     
    110118    ECC_MAX_PAD_SZ  = 4,    /* ECC maximum padding size */
    111119    ECC_MAX_OID_LEN = 16,
    112     ECC_MAX_SIG_SIZE= ((MAX_ECC_BYTES * 2) + ECC_MAX_PAD_SZ + SIG_HEADER_SZ)
     120    ECC_MAX_SIG_SIZE= ((MAX_ECC_BYTES * 2) + ECC_MAX_PAD_SZ + SIG_HEADER_SZ),
     121
     122    /* max crypto hardware size */
     123#ifdef WOLFSSL_ATECC508A
     124    ECC_MAX_CRYPTO_HW_SIZE = ATECC_KEY_SIZE, /* from port/atmel/atmel.h */
     125    ECC_MAX_CRYPTO_HW_PUBKEY_SIZE = (ATECC_KEY_SIZE*2),
     126#elif defined(PLUTON_CRYPTO_ECC)
     127    ECC_MAX_CRYPTO_HW_SIZE = 32,
     128#endif
     129
     130    /* point compression type */
     131    ECC_POINT_COMP_EVEN = 0x02,
     132    ECC_POINT_COMP_ODD = 0x03,
     133    ECC_POINT_UNCOMP = 0x04,
     134
     135    /* Shamir's dual add constants */
     136    SHAMIR_PRECOMP_SZ = 16,
     137
     138#ifdef HAVE_PKCS11
     139    ECC_MAX_ID_LEN    = 32,
     140#endif
    113141};
    114142
     
    176204
    177205/* ECC set type defined a GF(p) curve */
     206#ifndef USE_WINDOWS_API
    178207typedef struct ecc_set_type {
    179208    int size;             /* The size of the curve in octets */
     
    191220    int         cofactor;
    192221} ecc_set_type;
     222#else
     223/* MSC does something different with the pointers to the arrays than GCC,
     224 * and it causes the FIPS checksum to fail. In the case of windows builds,
     225 * store everything as arrays instead of pointers to strings. */
     226
     227#define MAX_ECC_NAME 16
     228#define MAX_ECC_STRING ((MAX_ECC_BYTES * 2) + 1)
     229    /* The values are stored as text strings. */
     230
     231typedef struct ecc_set_type {
     232    int size;             /* The size of the curve in octets */
     233    int id;               /* id of this curve */
     234    const char name[MAX_ECC_NAME];     /* name of this curve */
     235    const char prime[MAX_ECC_STRING];    /* prime that defines the field, curve is in (hex) */
     236    const char Af[MAX_ECC_STRING];       /* fields A param (hex) */
     237    const char Bf[MAX_ECC_STRING];       /* fields B param (hex) */
     238    const char order[MAX_ECC_STRING];    /* order of the curve (hex) */
     239    const char Gx[MAX_ECC_STRING];       /* x coordinate of the base point on curve (hex) */
     240    const char Gy[MAX_ECC_STRING];       /* y coordinate of the base point on curve (hex) */
     241    const ecc_oid_t oid[10];
     242    word32      oidSz;
     243    word32      oidSum;    /* sum of encoded OID bytes */
     244    int         cofactor;
     245} ecc_set_type;
     246#endif
    193247
    194248
     
    247301typedef struct alt_fp_int {
    248302    int used, sign, size;
    249     fp_digit dp[FP_SIZE_ECC];
     303    mp_digit dp[FP_SIZE_ECC];
    250304} alt_fp_int;
    251305#endif /* ALT_ECC_SIZE */
     306
     307#ifndef WC_ECCKEY_TYPE_DEFINED
     308    typedef struct ecc_key ecc_key;
     309    #define WC_ECCKEY_TYPE_DEFINED
     310#endif
    252311
    253312
     
    265324    alt_fp_int xyz[3];
    266325#endif
     326#ifdef WOLFSSL_SMALL_STACK_CACHE
     327    ecc_key* key;
     328#endif
    267329} ecc_point;
    268330
     
    285347    const ecc_set_type* dp;     /* domain parameters, either points to NIST
    286348                                   curves (idx >= 0) or user supplied */
     349#ifdef WOLFSSL_CUSTOM_CURVES
     350    int deallocSet;
     351#endif
    287352    void* heap;         /* heap hint */
     353    ecc_point pubkey;   /* public key */
     354    mp_int    k;        /* private key */
    288355#ifdef WOLFSSL_ATECC508A
    289356    int  slot;        /* Key Slot Number (-1 unknown) */
    290     byte pubkey[PUB_KEY_SIZE];
    291 #else
    292     ecc_point pubkey;   /* public key */
    293     mp_int    k;        /* private key */
     357    byte pubkey_raw[ECC_MAX_CRYPTO_HW_PUBKEY_SIZE];
     358#endif
     359#if defined(PLUTON_CRYPTO_ECC) || defined(WOLF_CRYPTO_DEV)
     360    int devId;
    294361#endif
    295362#ifdef WOLFSSL_ASYNC_CRYPT
     
    297364    mp_int* s;
    298365    WC_ASYNC_DEV asyncDev;
     366    #ifdef HAVE_CAVIUM_V
     367        mp_int* e;      /* Sign, Verify and Shared Secret */
     368        mp_int* signK;
     369    #endif
    299370    #ifdef WOLFSSL_CERT_GEN
    300371        CertSignCtx certSignCtx; /* context info for cert sign (MakeSignature) */
    301372    #endif
    302373#endif /* WOLFSSL_ASYNC_CRYPT */
    303 };
    304 
    305 #ifndef WC_ECCKEY_TYPE_DEFINED
    306     typedef struct ecc_key ecc_key;
    307     #define WC_ECCKEY_TYPE_DEFINED
    308 #endif
     374#ifdef HAVE_PKCS11
     375    byte id[ECC_MAX_ID_LEN];
     376    int  idLen;
     377#endif
     378#ifdef WOLFSSL_SMALL_STACK_CACHE
     379    mp_int* t1;
     380    mp_int* t2;
     381#ifdef ALT_ECC_SIZE
     382    mp_int* x;
     383    mp_int* y;
     384    mp_int* z;
     385#endif
     386#endif
     387};
    309388
    310389
     
    322401    #define ECC_API    WOLFSSL_LOCAL
    323402#endif
     403
     404ECC_API int ecc_mul2add(ecc_point* A, mp_int* kA,
     405                ecc_point* B, mp_int* kB,
     406                ecc_point* C, mp_int* a, mp_int* modulus, void* heap);
    324407
    325408ECC_API int ecc_map(ecc_point*, mp_int*, mp_digit);
     
    378461WOLFSSL_API
    379462int wc_ecc_init_ex(ecc_key* key, void* heap, int devId);
    380 WOLFSSL_API
    381 void wc_ecc_free(ecc_key* key);
     463#ifdef HAVE_PKCS11
     464WOLFSSL_API
     465int wc_ecc_init_id(ecc_key* key, unsigned char* id, int len, void* heap,
     466                   int devId);
     467#endif
     468#ifdef WOLFSSL_CUSTOM_CURVES
     469WOLFSSL_LOCAL
     470void wc_ecc_free_curve(const ecc_set_type* curve, void* heap);
     471#endif
     472WOLFSSL_API
     473int wc_ecc_free(ecc_key* key);
    382474WOLFSSL_API
    383475int wc_ecc_set_flags(ecc_key* key, word32 flags);
     
    410502        const byte* Gx, word32 GxSz, const byte* Gy, word32 GySz, int cofactor);
    411503
     504WOLFSSL_API
     505int wc_ecc_get_curve_id_from_oid(const byte* oid, word32 len);
     506
     507WOLFSSL_API
     508ecc_point* wc_ecc_new_point(void);
     509WOLFSSL_API
     510ecc_point* wc_ecc_new_point_h(void* h);
     511WOLFSSL_API
     512void wc_ecc_del_point(ecc_point* p);
     513WOLFSSL_API
     514void wc_ecc_del_point_h(ecc_point* p, void* h);
     515WOLFSSL_API
     516int wc_ecc_copy_point(ecc_point* p, ecc_point *r);
     517WOLFSSL_API
     518int wc_ecc_cmp_point(ecc_point* a, ecc_point *b);
     519WOLFSSL_API
     520int wc_ecc_point_is_at_infinity(ecc_point *p);
     521
    412522#ifndef WOLFSSL_ATECC508A
    413 
    414 WOLFSSL_API
    415 ecc_point* wc_ecc_new_point(void);
    416 WOLFSSL_API
    417 ecc_point* wc_ecc_new_point_h(void* h);
    418 WOLFSSL_API
    419 void wc_ecc_del_point(ecc_point* p);
    420 WOLFSSL_API
    421 void wc_ecc_del_point_h(ecc_point* p, void* h);
    422 WOLFSSL_API
    423 int wc_ecc_copy_point(ecc_point* p, ecc_point *r);
    424 WOLFSSL_API
    425 int wc_ecc_cmp_point(ecc_point* a, ecc_point *b);
    426 WOLFSSL_API
    427 int wc_ecc_point_is_at_infinity(ecc_point *p);
    428523WOLFSSL_API
    429524int wc_ecc_mulmod(mp_int* k, ecc_point *G, ecc_point *R,
     
    459554int wc_ecc_rs_to_sig(const char* r, const char* s, byte* out, word32* outlen);
    460555WOLFSSL_API
     556int wc_ecc_rs_raw_to_sig(const byte* r, word32 rSz, const byte* s, word32 sSz,
     557    byte* out, word32* outlen);
     558WOLFSSL_API
    461559int wc_ecc_sig_to_rs(const byte* sig, word32 sigLen, byte* r, word32* rLen,
    462560                   byte* s, word32* sLen);
     
    467565int wc_ecc_import_raw_ex(ecc_key* key, const char* qx, const char* qy,
    468566                   const char* d, int curve_id);
     567WOLFSSL_API
     568int wc_ecc_import_unsigned(ecc_key* key, byte* qx, byte* qy,
     569                   byte* d, int curve_id);
    469570#endif /* HAVE_ECC_KEY_IMPORT */
    470571
    471572#ifdef HAVE_ECC_KEY_EXPORT
     573WOLFSSL_API
     574int wc_ecc_export_ex(ecc_key* key, byte* qx, word32* qxLen,
     575                     byte* qy, word32* qyLen, byte* d, word32* dLen,
     576                     int encType);
    472577WOLFSSL_API
    473578int wc_ecc_export_private_only(ecc_key* key, byte* out, word32* outLen);
     
    497602WOLFSSL_API
    498603int wc_ecc_size(ecc_key* key);
     604WOLFSSL_API
     605int wc_ecc_sig_size_calc(int sz);
    499606WOLFSSL_API
    500607int wc_ecc_sig_size(ecc_key* key);
Note: See TracChangeset for help on using the changeset viewer.