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_rx/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/asn_public.h

    r337 r372  
    2020 */
    2121
    22 
     22/*!
     23    \file wolfssl/wolfcrypt/asn_public.h
     24*/
    2325
    2426#ifndef WOLF_CRYPT_ASN_PUBLIC_H
     
    4850    #define WC_RNG_TYPE_DEFINED
    4951#endif
     52
    5053
    5154/* Certificate file Type */
     
    6871    TRUSTED_PEER_TYPE,
    6972    EDDSA_PRIVATEKEY_TYPE,
    70     ED25519_TYPE
     73    ED25519_TYPE,
     74    PKCS12_TYPE,
     75    PKCS8_PRIVATEKEY_TYPE,
     76    PKCS8_ENC_PRIVATEKEY_TYPE
    7177};
    7278
     
    8086    CTC_SHAwECDSA    = 520,
    8187    CTC_SHA224wRSA   = 658,
    82     CTC_SHA224wECDSA = 527,
     88    CTC_SHA224wECDSA = 523,
    8389    CTC_SHA256wRSA   = 655,
    8490    CTC_SHA256wECDSA = 524,
     
    95101};
    96102
     103#ifndef WC_CTC_NAME_SIZE
     104    #define WC_CTC_NAME_SIZE 64
     105#endif
     106#ifndef WC_CTC_MAX_ALT_SIZE
     107    #define WC_CTC_MAX_ALT_SIZE 16384
     108#endif
     109
    97110enum Ctc_Misc {
    98111    CTC_COUNTRY_SIZE  =     2,
    99     CTC_NAME_SIZE     =    64,
     112    CTC_NAME_SIZE     = WC_CTC_NAME_SIZE,
    100113    CTC_DATE_SIZE     =    32,
    101     CTC_MAX_ALT_SIZE  = 16384,   /* may be huge */
     114    CTC_MAX_ALT_SIZE  = WC_CTC_MAX_ALT_SIZE, /* may be huge, default: 16384 */
    102115    CTC_SERIAL_SIZE   =    16,
    103116#ifdef WOLFSSL_CERT_EXT
     
    111124};
    112125
     126/* DER buffer */
     127typedef struct DerBuffer {
     128    byte*  buffer;
     129    void*  heap;
     130    word32 length;
     131    int    type;    /* enum CertType */
     132    int    dynType; /* DYNAMIC_TYPE_* */
     133} DerBuffer;
     134
     135enum {
     136    IV_SZ   = 32,                   /* max iv sz */
     137    NAME_SZ = 80,                   /* max one line */
     138
     139    PEM_PASS_READ  = 0,
     140    PEM_PASS_WRITE = 1,
     141};
     142
     143
     144typedef int (pem_password_cb)(char* passwd, int sz, int rw, void* userdata);
     145
     146typedef struct EncryptedInfo {
     147    pem_password_cb* passwd_cb;
     148    void*            passwd_userdata;
     149
     150    long     consumed;         /* tracks PEM bytes consumed */
     151
     152    int      cipherType;
     153    word32   keySz;
     154    word32   ivSz;             /* salt or encrypted IV size */
     155
     156    char     name[NAME_SZ];    /* cipher name, such as "DES-CBC" */
     157    byte     iv[IV_SZ];        /* salt or encrypted IV */
     158
     159    word16   set:1;            /* if encryption set */
     160} EncryptedInfo;
     161
     162
     163#if defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_CERT_EXT)
     164#ifdef WOLFSSL_EKU_OID
     165    #ifndef CTC_MAX_EKU_NB
     166        #define CTC_MAX_EKU_NB 1
     167    #endif
     168    #ifndef CTC_MAX_EKU_OID_SZ
     169        #define CTC_MAX_EKU_OID_SZ 30
     170    #endif
     171#else
     172    #undef CTC_MAX_EKU_OID_SZ
     173    #define CTC_MAX_EKU_OID_SZ 0
     174#endif
     175#endif /* WOLFSSL_CERT_GEN || WOLFSSL_CERT_EXT */
    113176
    114177#ifdef WOLFSSL_CERT_GEN
     178
     179#ifdef WOLFSSL_MULTI_ATTRIB
     180#ifndef CTC_MAX_ATTRIB
     181    #define CTC_MAX_ATTRIB 4
     182#endif
     183
     184/* ASN Encoded Name field */
     185typedef struct NameAttrib {
     186    int  sz;                     /* actual string value length */
     187    int  id;                     /* id of name */
     188    int  type;                   /* enc of name */
     189    char value[CTC_NAME_SIZE];   /* name */
     190} NameAttrib;
     191#endif /* WOLFSSL_MULTI_ATTRIB */
     192
    115193
    116194typedef struct CertName {
     
    129207    char commonName[CTC_NAME_SIZE];
    130208    char commonNameEnc;
     209    char serialDev[CTC_NAME_SIZE];
     210    char serialDevEnc;
     211#ifdef WOLFSSL_CERT_EXT
     212    char busCat[CTC_NAME_SIZE];
     213    char busCatEnc;
     214    char joiC[CTC_NAME_SIZE];
     215    char joiCEnc;
     216    char joiSt[CTC_NAME_SIZE];
     217    char joiStEnc;
     218#endif
    131219    char email[CTC_NAME_SIZE];  /* !!!! email has to be last !!!! */
     220#ifdef WOLFSSL_MULTI_ATTRIB
     221    NameAttrib name[CTC_MAX_ATTRIB];
     222#endif
    132223} CertName;
    133224
     
    162253    word16  keyUsage;                    /* Key Usage */
    163254    byte    extKeyUsage;                 /* Extended Key Usage */
     255#ifdef WOLFSSL_EKU_OID
     256    /* Extended Key Usage OIDs */
     257    byte    extKeyUsageOID[CTC_MAX_EKU_NB][CTC_MAX_EKU_OID_SZ];
     258    byte    extKeyUsageOIDSz[CTC_MAX_EKU_NB];
     259#endif
    164260    char    certPolicies[CTC_MAX_CERTPOL_NB][CTC_MAX_CERTPOL_SZ];
    165261    word16  certPoliciesNb;              /* Number of Cert Policy */
     262    byte     issRaw[sizeof(CertName)];   /* raw issuer info */
     263    byte     sbjRaw[sizeof(CertName)];   /* raw subject info */
    166264#endif
    167265#ifdef WOLFSSL_CERT_REQ
     
    170268    void*   heap; /* heap hint */
    171269} Cert;
     270
    172271
    173272
     
    211310WOLFSSL_API int  wc_SetDatesBuffer(Cert*, const byte*, int);
    212311
     312#ifndef NO_ASN_TIME
     313WOLFSSL_API int wc_GetCertDates(Cert* cert, struct tm* before,
     314    struct tm* after);
     315#endif
     316
    213317#ifdef WOLFSSL_CERT_EXT
    214318WOLFSSL_API int wc_SetAuthKeyIdFromPublicKey_ex(Cert *cert, int keyType,
     
    223327                                                ecc_key *eckey);
    224328WOLFSSL_API int wc_SetSubjectKeyId(Cert *cert, const char* file);
     329WOLFSSL_API int wc_GetSubjectRaw(byte **subjectRaw, Cert *cert);
     330WOLFSSL_API int wc_SetSubjectRaw(Cert* cert, const byte* der, int derSz);
     331WOLFSSL_API int wc_SetIssuerRaw(Cert* cert, const byte* der, int derSz);
    225332
    226333#ifdef HAVE_NTRU
     
    244351WOLFSSL_API int wc_SetExtKeyUsage(Cert *cert, const char *value);
    245352
     353
     354#ifdef WOLFSSL_EKU_OID
     355/* Set ExtendedKeyUsage with unique OID
     356 * oid is expected to be in byte representation
     357 */
     358WOLFSSL_API int wc_SetExtKeyUsageOID(Cert *cert, const char *oid, word32 sz,
     359                                     byte idx, void* heap);
     360#endif /* WOLFSSL_EKU_OID */
    246361#endif /* WOLFSSL_CERT_EXT */
    247362
     
    254369#endif /* WOLFSSL_CERT_GEN */
    255370
     371WOLFSSL_API int wc_GetDateInfo(const byte* certDate, int certDateSz,
     372    const byte** date, byte* format, int* length);
     373#ifndef NO_ASN_TIME
     374WOLFSSL_API int wc_GetDateAsCalendarTime(const byte* date, int length,
     375    byte format, struct tm* time);
     376#endif
     377
     378#if defined(WOLFSSL_PEM_TO_DER) || defined(WOLFSSL_DER_TO_PEM)
     379
     380    WOLFSSL_API int wc_PemGetHeaderFooter(int type, const char** header,
     381        const char** footer);
     382
     383#endif
     384
     385WOLFSSL_API  int wc_AllocDer(DerBuffer** pDer, word32 length, int type, void* heap);
     386WOLFSSL_API void wc_FreeDer(DerBuffer** pDer);
     387
     388#ifdef WOLFSSL_PEM_TO_DER
     389    WOLFSSL_API int wc_PemToDer(const unsigned char* buff, long longSz, int type,
     390              DerBuffer** pDer, void* heap, EncryptedInfo* info, int* eccKey);
     391
     392    WOLFSSL_API int wc_KeyPemToDer(const unsigned char*, int,
     393                                   unsigned char*, int, const char*);
     394    WOLFSSL_API int wc_CertPemToDer(const unsigned char*, int,
     395                                    unsigned char*, int, int);
     396#endif /* WOLFSSL_PEM_TO_DER */
     397
    256398#if defined(WOLFSSL_CERT_EXT) || defined(WOLFSSL_PUB_PEM_TO_DER)
    257     #ifndef WOLFSSL_PEMPUBKEY_TODER_DEFINED
    258399        #ifndef NO_FILESYSTEM
    259         /* forward from wolfssl */
    260         WOLFSSL_API int wolfSSL_PemPubKeyToDer(const char* fileName,
     400        WOLFSSL_API int wc_PemPubKeyToDer(const char* fileName,
    261401                                               unsigned char* derBuf, int derSz);
    262402        #endif
    263403
    264         /* forward from wolfssl */
    265         WOLFSSL_API int wolfSSL_PubKeyPemToDer(const unsigned char*, int,
     404    WOLFSSL_API int wc_PubKeyPemToDer(const unsigned char*, int,
    266405                                               unsigned char*, int);
    267         #define WOLFSSL_PEMPUBKEY_TODER_DEFINED
    268     #endif /* WOLFSSL_PEMPUBKEY_TODER_DEFINED */
    269406#endif /* WOLFSSL_CERT_EXT || WOLFSSL_PUB_PEM_TO_DER */
    270407
    271 #if defined(WOLFSSL_KEY_GEN) || defined(WOLFSSL_CERT_GEN) || !defined(NO_DSA) \
    272                              || defined(OPENSSL_EXTRA)
     408#ifdef WOLFSSL_CERT_GEN
     409    #ifndef NO_FILESYSTEM
     410        WOLFSSL_API int wc_PemCertToDer(const char* fileName,
     411                                        unsigned char* derBuf, int derSz);
     412    #endif
     413#endif /* WOLFSSL_CERT_GEN */
     414
     415#ifdef WOLFSSL_DER_TO_PEM
    273416    WOLFSSL_API int wc_DerToPem(const byte* der, word32 derSz, byte* output,
    274417                                word32 outputSz, int type);
    275418    WOLFSSL_API int wc_DerToPemEx(const byte* der, word32 derSz, byte* output,
    276419                                word32 outputSz, byte *cipherIno, int type);
     420#endif
     421
     422#if !defined(NO_RSA) && !defined(HAVE_USER_RSA)
     423    WOLFSSL_API int wc_RsaPublicKeyDecode_ex(const byte* input, word32* inOutIdx,
     424        word32 inSz, const byte** n, word32* nSz, const byte** e, word32* eSz);
    277425#endif
    278426
     
    284432    WOLFSSL_API int wc_EccPrivateKeyToDer(ecc_key* key, byte* output,
    285433                                          word32 inLen);
     434    WOLFSSL_API int wc_EccPrivateKeyToPKCS8(ecc_key* key, byte* output,
     435                                            word32* outLen);
    286436
    287437    /* public key helper */
    288438    WOLFSSL_API int wc_EccPublicKeyDecode(const byte*, word32*,
    289439                                              ecc_key*, word32);
    290     #if (defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_KEY_GEN))
    291440        WOLFSSL_API int wc_EccPublicKeyToDer(ecc_key*, byte* output,
    292441                                               word32 inLen, int with_AlgCurve);
    293442    #endif
    294 #endif
    295443
    296444#ifdef HAVE_ED25519
     
    322470       byte* key, word32 keySz, int algoID, const byte* curveOID, word32 oidSz);
    323471
     472#ifndef NO_ASN_TIME
    324473/* Time */
    325474/* Returns seconds (Epoch/UTC)
     
    330479*/
    331480WOLFSSL_API int wc_GetTime(void* timePtr, word32 timeSize);
     481#endif
     482
     483#ifdef WOLFSSL_ENCRYPTED_KEYS
     484    WOLFSSL_API int wc_EncryptedInfoGet(EncryptedInfo* info,
     485        const char* cipherInfo);
     486#endif
     487
     488
     489#ifdef WOLFSSL_CERT_PIV
     490
     491typedef struct _wc_CertPIV {
     492    const byte*  cert;
     493    word32       certSz;
     494    const byte*  certErrDet;
     495    word32       certErrDetSz;
     496    const byte*  nonce;         /* Identiv Only */
     497    word32       nonceSz;       /* Identiv Only */
     498    const byte*  signedNonce;   /* Identiv Only */
     499    word32       signedNonceSz; /* Identiv Only */
     500
     501    /* flags */
     502    word16       compression:2;
     503    word16       isX509:1;
     504    word16       isIdentiv:1;
     505} wc_CertPIV;
     506
     507WOLFSSL_API int wc_ParseCertPIV(wc_CertPIV* cert, const byte* buf, word32 totalSz);
     508#endif /* WOLFSSL_CERT_PIV */
     509
    332510
    333511#ifdef __cplusplus
Note: See TracChangeset for help on using the changeset viewer.