- Timestamp:
- Feb 7, 2019, 8:36:33 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/asn_public.h
r352 r372 20 20 */ 21 21 22 22 /*! 23 \file wolfssl/wolfcrypt/asn_public.h 24 */ 23 25 24 26 #ifndef WOLF_CRYPT_ASN_PUBLIC_H … … 48 50 #define WC_RNG_TYPE_DEFINED 49 51 #endif 52 50 53 51 54 /* Certificate file Type */ … … 68 71 TRUSTED_PEER_TYPE, 69 72 EDDSA_PRIVATEKEY_TYPE, 70 ED25519_TYPE 73 ED25519_TYPE, 74 PKCS12_TYPE, 75 PKCS8_PRIVATEKEY_TYPE, 76 PKCS8_ENC_PRIVATEKEY_TYPE 71 77 }; 72 78 … … 80 86 CTC_SHAwECDSA = 520, 81 87 CTC_SHA224wRSA = 658, 82 CTC_SHA224wECDSA = 52 7,88 CTC_SHA224wECDSA = 523, 83 89 CTC_SHA256wRSA = 655, 84 90 CTC_SHA256wECDSA = 524, … … 95 101 }; 96 102 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 97 110 enum Ctc_Misc { 98 111 CTC_COUNTRY_SIZE = 2, 99 CTC_NAME_SIZE = 64,112 CTC_NAME_SIZE = WC_CTC_NAME_SIZE, 100 113 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 */ 102 115 CTC_SERIAL_SIZE = 16, 103 116 #ifdef WOLFSSL_CERT_EXT … … 111 124 }; 112 125 126 /* DER buffer */ 127 typedef struct DerBuffer { 128 byte* buffer; 129 void* heap; 130 word32 length; 131 int type; /* enum CertType */ 132 int dynType; /* DYNAMIC_TYPE_* */ 133 } DerBuffer; 134 135 enum { 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 144 typedef int (pem_password_cb)(char* passwd, int sz, int rw, void* userdata); 145 146 typedef 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 */ 113 176 114 177 #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 */ 185 typedef 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 115 193 116 194 typedef struct CertName { … … 129 207 char commonName[CTC_NAME_SIZE]; 130 208 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 131 219 char email[CTC_NAME_SIZE]; /* !!!! email has to be last !!!! */ 220 #ifdef WOLFSSL_MULTI_ATTRIB 221 NameAttrib name[CTC_MAX_ATTRIB]; 222 #endif 132 223 } CertName; 133 224 … … 162 253 word16 keyUsage; /* Key Usage */ 163 254 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 164 260 char certPolicies[CTC_MAX_CERTPOL_NB][CTC_MAX_CERTPOL_SZ]; 165 261 word16 certPoliciesNb; /* Number of Cert Policy */ 262 byte issRaw[sizeof(CertName)]; /* raw issuer info */ 263 byte sbjRaw[sizeof(CertName)]; /* raw subject info */ 166 264 #endif 167 265 #ifdef WOLFSSL_CERT_REQ … … 170 268 void* heap; /* heap hint */ 171 269 } Cert; 270 172 271 173 272 … … 211 310 WOLFSSL_API int wc_SetDatesBuffer(Cert*, const byte*, int); 212 311 312 #ifndef NO_ASN_TIME 313 WOLFSSL_API int wc_GetCertDates(Cert* cert, struct tm* before, 314 struct tm* after); 315 #endif 316 213 317 #ifdef WOLFSSL_CERT_EXT 214 318 WOLFSSL_API int wc_SetAuthKeyIdFromPublicKey_ex(Cert *cert, int keyType, … … 223 327 ecc_key *eckey); 224 328 WOLFSSL_API int wc_SetSubjectKeyId(Cert *cert, const char* file); 329 WOLFSSL_API int wc_GetSubjectRaw(byte **subjectRaw, Cert *cert); 330 WOLFSSL_API int wc_SetSubjectRaw(Cert* cert, const byte* der, int derSz); 331 WOLFSSL_API int wc_SetIssuerRaw(Cert* cert, const byte* der, int derSz); 225 332 226 333 #ifdef HAVE_NTRU … … 244 351 WOLFSSL_API int wc_SetExtKeyUsage(Cert *cert, const char *value); 245 352 353 354 #ifdef WOLFSSL_EKU_OID 355 /* Set ExtendedKeyUsage with unique OID 356 * oid is expected to be in byte representation 357 */ 358 WOLFSSL_API int wc_SetExtKeyUsageOID(Cert *cert, const char *oid, word32 sz, 359 byte idx, void* heap); 360 #endif /* WOLFSSL_EKU_OID */ 246 361 #endif /* WOLFSSL_CERT_EXT */ 247 362 … … 254 369 #endif /* WOLFSSL_CERT_GEN */ 255 370 371 WOLFSSL_API int wc_GetDateInfo(const byte* certDate, int certDateSz, 372 const byte** date, byte* format, int* length); 373 #ifndef NO_ASN_TIME 374 WOLFSSL_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 385 WOLFSSL_API int wc_AllocDer(DerBuffer** pDer, word32 length, int type, void* heap); 386 WOLFSSL_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 256 398 #if defined(WOLFSSL_CERT_EXT) || defined(WOLFSSL_PUB_PEM_TO_DER) 257 #ifndef WOLFSSL_PEMPUBKEY_TODER_DEFINED258 399 #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, 261 401 unsigned char* derBuf, int derSz); 262 402 #endif 263 403 264 /* forward from wolfssl */ 265 WOLFSSL_API int wolfSSL_PubKeyPemToDer(const unsigned char*, int, 404 WOLFSSL_API int wc_PubKeyPemToDer(const unsigned char*, int, 266 405 unsigned char*, int); 267 #define WOLFSSL_PEMPUBKEY_TODER_DEFINED268 #endif /* WOLFSSL_PEMPUBKEY_TODER_DEFINED */269 406 #endif /* WOLFSSL_CERT_EXT || WOLFSSL_PUB_PEM_TO_DER */ 270 407 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 273 416 WOLFSSL_API int wc_DerToPem(const byte* der, word32 derSz, byte* output, 274 417 word32 outputSz, int type); 275 418 WOLFSSL_API int wc_DerToPemEx(const byte* der, word32 derSz, byte* output, 276 419 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); 277 425 #endif 278 426 … … 284 432 WOLFSSL_API int wc_EccPrivateKeyToDer(ecc_key* key, byte* output, 285 433 word32 inLen); 434 WOLFSSL_API int wc_EccPrivateKeyToPKCS8(ecc_key* key, byte* output, 435 word32* outLen); 286 436 287 437 /* public key helper */ 288 438 WOLFSSL_API int wc_EccPublicKeyDecode(const byte*, word32*, 289 439 ecc_key*, word32); 290 #if (defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_KEY_GEN))291 440 WOLFSSL_API int wc_EccPublicKeyToDer(ecc_key*, byte* output, 292 441 word32 inLen, int with_AlgCurve); 293 442 #endif 294 #endif295 443 296 444 #ifdef HAVE_ED25519 … … 322 470 byte* key, word32 keySz, int algoID, const byte* curveOID, word32 oidSz); 323 471 472 #ifndef NO_ASN_TIME 324 473 /* Time */ 325 474 /* Returns seconds (Epoch/UTC) … … 330 479 */ 331 480 WOLFSSL_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 491 typedef 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 507 WOLFSSL_API int wc_ParseCertPIV(wc_CertPIV* cert, const byte* buf, word32 totalSz); 508 #endif /* WOLFSSL_CERT_PIV */ 509 332 510 333 511 #ifdef __cplusplus
Note:
See TracChangeset
for help on using the changeset viewer.