- Timestamp:
- Feb 7, 2019, 8:36:33 AM (5 years ago)
- Location:
- asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt
- Files:
-
- 1 added
- 38 edited
Legend:
- Unmodified
- Added
- Removed
-
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/aes.h
r352 r372 20 20 */ 21 21 22 /*! 23 \file wolfssl/wolfcrypt/aes.h 24 */ 25 22 26 23 27 #ifndef WOLF_CRYPT_AES_H … … 28 32 #ifndef NO_AES 29 33 34 #if defined(HAVE_FIPS) && \ 35 defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2) 36 #include <wolfssl/wolfcrypt/fips.h> 37 #endif /* HAVE_FIPS_VERSION >= 2 */ 38 30 39 /* included for fips @wc_fips */ 31 #ifdef HAVE_FIPS 40 #if defined(HAVE_FIPS) && \ 41 (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2)) 32 42 #include <cyassl/ctaocrypt/aes.h> 33 43 #if defined(CYASSL_AES_COUNTER) && !defined(WOLFSSL_AES_COUNTER) … … 39 49 #endif 40 50 41 #ifndef HAVE_FIPS /* to avoid redefinition of macros */ 51 #ifndef WC_NO_RNG 52 #include <wolfssl/wolfcrypt/random.h> 53 #endif 54 #ifdef STM32_CRYPTO 55 #include <wolfssl/wolfcrypt/port/st/stm32.h> 56 #endif 42 57 43 58 #ifdef WOLFSSL_AESNI … … 49 64 #endif /* WOLFSSL_AESNI */ 50 65 66 51 67 #ifdef WOLFSSL_XILINX_CRYPT 52 68 #include "xsecure_aes.h" 53 69 #endif 54 70 55 #endif /* HAVE_FIPS */ 71 #ifdef WOLFSSL_AFALG 72 /* included for struct msghdr */ 73 #include <sys/socket.h> 74 #endif 75 76 #if defined(WOLFSSL_DEVCRYPTO_AES) || defined(WOLFSSL_DEVCRYPTO_CBC) 77 #include <wolfssl/wolfcrypt/port/devcrypto/wc_devcrypto.h> 78 #endif 79 80 #if defined(HAVE_AESGCM) && !defined(WC_NO_RNG) 81 #include <wolfssl/wolfcrypt/random.h> 82 #endif 83 56 84 57 85 #ifdef __cplusplus … … 59 87 #endif 60 88 61 #ifndef HAVE_FIPS /* to avoid redefinition of structures */ 89 /* these are required for FIPS and non-FIPS */ 90 enum { 91 AES_128_KEY_SIZE = 16, /* for 128 bit */ 92 AES_192_KEY_SIZE = 24, /* for 192 bit */ 93 AES_256_KEY_SIZE = 32, /* for 256 bit */ 94 95 AES_IV_SIZE = 16, /* always block size */ 96 }; 97 98 99 /* avoid redefinition of structs */ 100 #if !defined(HAVE_FIPS) || \ 101 (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)) 62 102 63 103 #ifdef WOLFSSL_ASYNC_CRYPT … … 66 106 67 107 enum { 68 AES_ENC_TYPE = 1, /* cipher unique type */108 AES_ENC_TYPE = WC_CIPHER_AES, /* cipher unique type */ 69 109 AES_ENCRYPTION = 0, 70 110 AES_DECRYPTION = 1, 111 112 AES_BLOCK_SIZE = 16, 113 71 114 KEYWRAP_BLOCK_SIZE = 8, 72 AES_BLOCK_SIZE = 16 115 116 GCM_NONCE_MAX_SZ = 16, /* wolfCrypt's maximum nonce size allowed. */ 117 GCM_NONCE_MID_SZ = 12, /* The usual default nonce size for AES-GCM. */ 118 GCM_NONCE_MIN_SZ = 8, /* wolfCrypt's minimum nonce size allowed. */ 119 CCM_NONCE_MIN_SZ = 7, 120 CCM_NONCE_MAX_SZ = 13, 121 CTR_SZ = 4, 122 AES_IV_FIXED_SZ = 4, 123 124 #ifdef HAVE_PKCS11 125 AES_MAX_ID_LEN = 32, 126 #endif 73 127 }; 74 128 … … 83 137 ALIGN16 word32 tmp[AES_BLOCK_SIZE / sizeof(word32)]; /* same */ 84 138 139 #if defined(HAVE_AESGCM) || defined(HAVE_AESCCM) 140 word32 invokeCtr[2]; 141 word32 nonceSz; 142 #endif 85 143 #ifdef HAVE_AESGCM 86 144 ALIGN16 byte H[AES_BLOCK_SIZE]; … … 93 151 byte use_aesni; 94 152 #endif /* WOLFSSL_AESNI */ 153 #ifdef WOLF_CRYPTO_DEV 154 int devId; 155 #endif 156 #ifdef HAVE_PKCS11 157 byte id[AES_MAX_ID_LEN]; 158 int idLen; 159 #endif 95 160 #ifdef WOLFSSL_ASYNC_CRYPT 96 161 word32 asyncKey[AES_MAX_KEY_SIZE/8/sizeof(word32)]; /* raw key */ … … 98 163 WC_ASYNC_DEV asyncDev; 99 164 #endif /* WOLFSSL_ASYNC_CRYPT */ 100 #if def WOLFSSL_AES_COUNTER165 #if defined(WOLFSSL_AES_COUNTER) || defined(WOLFSSL_AES_CFB) 101 166 word32 left; /* unused bytes left from last call */ 102 167 #endif … … 106 171 word32 key_init[8]; 107 172 word32 kup; 173 #endif 174 #ifdef WOLFSSL_AFALG 175 int alFd; /* server socket to bind to */ 176 int rdFd; /* socket to read from */ 177 struct msghdr msg; 178 int dir; /* flag for encrpyt or decrypt */ 179 #endif 180 #if defined(WOLFSSL_DEVCRYPTO) && \ 181 (defined(WOLFSSL_DEVCRYPTO_AES) || defined(WOLFSSL_DEVCRYPTO_CBC)) 182 word32 devKey[AES_MAX_KEY_SIZE/WOLFSSL_BIT_SIZE/sizeof(word32)]; /* raw key */ 183 WC_CRYPTODEV ctx; 108 184 #endif 109 185 void* heap; /* memory hint to use */ … … 141 217 const byte* iv, int dir); 142 218 WOLFSSL_API int wc_AesSetIV(Aes* aes, const byte* iv); 219 220 #ifdef HAVE_AES_CBC 143 221 WOLFSSL_API int wc_AesCbcEncrypt(Aes* aes, byte* out, 144 222 const byte* in, word32 sz); 145 223 WOLFSSL_API int wc_AesCbcDecrypt(Aes* aes, byte* out, 146 224 const byte* in, word32 sz); 225 #endif 226 227 #ifdef WOLFSSL_AES_CFB 228 WOLFSSL_API int wc_AesCfbEncrypt(Aes* aes, byte* out, 229 const byte* in, word32 sz); 230 #ifdef HAVE_AES_DECRYPT 231 WOLFSSL_API int wc_AesCfbDecrypt(Aes* aes, byte* out, 232 const byte* in, word32 sz); 233 #endif /* HAVE_AES_DECRYPT */ 234 #endif /* WOLFSSL_AES_CFB */ 147 235 148 236 #ifdef HAVE_AES_ECB … … 165 253 const byte* iv, int dir); 166 254 #endif 255 167 256 #ifdef HAVE_AESGCM 168 257 #ifdef WOLFSSL_XILINX_CRYPT … … 182 271 const byte* authIn, word32 authInSz); 183 272 273 #ifndef WC_NO_RNG 274 WOLFSSL_API int wc_AesGcmSetExtIV(Aes* aes, const byte* iv, word32 ivSz); 275 WOLFSSL_API int wc_AesGcmSetIV(Aes* aes, word32 ivSz, 276 const byte* ivFixed, word32 ivFixedSz, 277 WC_RNG* rng); 278 WOLFSSL_API int wc_AesGcmEncrypt_ex(Aes* aes, byte* out, 279 const byte* in, word32 sz, 280 byte* ivOut, word32 ivOutSz, 281 byte* authTag, word32 authTagSz, 282 const byte* authIn, word32 authInSz); 283 #endif /* WC_NO_RNG */ 284 184 285 WOLFSSL_API int wc_GmacSetKey(Gmac* gmac, const byte* key, word32 len); 185 286 WOLFSSL_API int wc_GmacUpdate(Gmac* gmac, const byte* iv, word32 ivSz, 186 287 const byte* authIn, word32 authInSz, 187 288 byte* authTag, word32 authTagSz); 289 #ifndef WC_NO_RNG 290 WOLFSSL_API int wc_Gmac(const byte* key, word32 keySz, byte* iv, word32 ivSz, 291 const byte* authIn, word32 authInSz, 292 byte* authTag, word32 authTagSz, WC_RNG* rng); 293 WOLFSSL_API int wc_GmacVerify(const byte* key, word32 keySz, 294 const byte* iv, word32 ivSz, 295 const byte* authIn, word32 authInSz, 296 const byte* authTag, word32 authTagSz); 297 #endif /* WC_NO_RNG */ 188 298 WOLFSSL_LOCAL void GHASH(Aes* aes, const byte* a, word32 aSz, const byte* c, 189 299 word32 cSz, byte* s, word32 sSz); … … 200 310 const byte* nonce, word32 nonceSz, 201 311 const byte* authTag, word32 authTagSz, 312 const byte* authIn, word32 authInSz); 313 WOLFSSL_API int wc_AesCcmSetNonce(Aes* aes, 314 const byte* nonce, word32 nonceSz); 315 WOLFSSL_API int wc_AesCcmEncrypt_ex(Aes* aes, byte* out, 316 const byte* in, word32 sz, 317 byte* ivOut, word32 ivOutSz, 318 byte* authTag, word32 authTagSz, 202 319 const byte* authIn, word32 authInSz); 203 320 #endif /* HAVE_AESCCM */ … … 214 331 215 332 #ifdef WOLFSSL_AES_XTS 216 /*! 217 \ingroup AES 218 219 \brief This is to help with setting keys to correct encrypt or decrypt type. 220 221 \note Is up to user to call wc_AesXtsFree on aes key when done. 222 223 \return 0 Success 224 225 \param aes AES keys for encrypt/decrypt process 226 \param key buffer holding aes key | tweak key 227 \param len length of key buffer in bytes. Should be twice that of key size. 228 i.e. 32 for a 16 byte key. 229 \param dir direction, either AES_ENCRYPTION or AES_DECRYPTION 230 \param heap heap hint to use for memory. Can be NULL 231 \param devId id to use with async crypto. Can be 0 232 233 _Example_ 234 \code 235 XtsAes aes; 236 237 if(wc_AesXtsSetKey(&aes, key, sizeof(key), AES_ENCRYPTION, NULL, 0) != 0) 238 { 239 // Handle error 240 } 241 wc_AesXtsFree(&aes); 242 \endcode 243 244 \sa wc_AesXtsEncrypt 245 \sa wc_AesXtsDecrypt 246 \sa wc_AesXtsFree 247 */ 333 248 334 WOLFSSL_API int wc_AesXtsSetKey(XtsAes* aes, const byte* key, 249 335 word32 len, int dir, void* heap, int devId); 250 336 251 252 /*!253 \ingroup AES254 255 \brief Same process as wc_AesXtsEncrypt but uses a word64 type as the tweak256 value instead of a byte array. This just converts the word64 to a257 byte array and calls wc_AesXtsEncrypt.258 259 \return 0 Success260 261 \param aes AES keys to use for block encrypt/decrypt262 \param out output buffer to hold cipher text263 \param in input plain text buffer to encrypt264 \param sz size of both out and in buffers265 \param sector value to use for tweak266 267 _Example_268 \code269 XtsAes aes;270 unsigned char plain[SIZE];271 unsigned char cipher[SIZE];272 word64 s = VALUE;273 274 //set up keys with AES_ENCRYPTION as dir275 276 if(wc_AesXtsEncryptSector(&aes, cipher, plain, SIZE, s) != 0)277 {278 // Handle error279 }280 wc_AesXtsFree(&aes);281 \endcode282 283 \sa wc_AesXtsEncrypt284 \sa wc_AesXtsDecrypt285 \sa wc_AesXtsSetKey286 \sa wc_AesXtsFree287 */288 337 WOLFSSL_API int wc_AesXtsEncryptSector(XtsAes* aes, byte* out, 289 338 const byte* in, word32 sz, word64 sector); 290 339 291 292 /*!293 \ingroup AES294 295 \brief Same process as wc_AesXtsDecrypt but uses a word64 type as the tweak296 value instead of a byte array. This just converts the word64 to a297 byte array.298 299 \return 0 Success300 301 \param aes AES keys to use for block encrypt/decrypt302 \param out output buffer to hold plain text303 \param in input cipher text buffer to decrypt304 \param sz size of both out and in buffers305 \param sector value to use for tweak306 307 _Example_308 \code309 XtsAes aes;310 unsigned char plain[SIZE];311 unsigned char cipher[SIZE];312 word64 s = VALUE;313 314 //set up aes key with AES_DECRYPTION as dir and tweak with AES_ENCRYPTION315 316 if(wc_AesXtsDecryptSector(&aes, plain, cipher, SIZE, s) != 0)317 {318 // Handle error319 }320 wc_AesXtsFree(&aes);321 \endcode322 323 \sa wc_AesXtsEncrypt324 \sa wc_AesXtsDecrypt325 \sa wc_AesXtsSetKey326 \sa wc_AesXtsFree327 */328 340 WOLFSSL_API int wc_AesXtsDecryptSector(XtsAes* aes, byte* out, 329 341 const byte* in, word32 sz, word64 sector); 330 342 331 332 /*!333 \ingroup AES334 335 \brief AES with XTS mode. (XTS) XEX encryption with Tweak and cipher text336 Stealing.337 338 \return 0 Success339 340 \param aes AES keys to use for block encrypt/decrypt341 \param out output buffer to hold cipher text342 \param in input plain text buffer to encrypt343 \param sz size of both out and in buffers344 \param i value to use for tweak345 \param iSz size of i buffer, should always be AES_BLOCK_SIZE but having346 this input adds a sanity check on how the user calls the347 function.348 349 _Example_350 \code351 XtsAes aes;352 unsigned char plain[SIZE];353 unsigned char cipher[SIZE];354 unsigned char i[AES_BLOCK_SIZE];355 356 //set up key with AES_ENCRYPTION as dir357 358 if(wc_AesXtsEncrypt(&aes, cipher, plain, SIZE, i, sizeof(i)) != 0)359 {360 // Handle error361 }362 wc_AesXtsFree(&aes);363 \endcode364 365 \sa wc_AesXtsDecrypt366 \sa wc_AesXtsSetKey367 \sa wc_AesXtsFree368 */369 343 WOLFSSL_API int wc_AesXtsEncrypt(XtsAes* aes, byte* out, 370 344 const byte* in, word32 sz, const byte* i, word32 iSz); 371 345 372 373 /*!374 \ingroup AES375 376 \brief Same process as encryption but Aes key is AES_DECRYPTION type.377 378 \return 0 Success379 380 \param aes AES keys to use for block encrypt/decrypt381 \param out output buffer to hold plain text382 \param in input cipher text buffer to decrypt383 \param sz size of both out and in buffers384 \param i value to use for tweak385 \param iSz size of i buffer, should always be AES_BLOCK_SIZE but having386 this input adds a sanity check on how the user calls the387 function.388 _Example_389 \code390 XtsAes aes;391 unsigned char plain[SIZE];392 unsigned char cipher[SIZE];393 unsigned char i[AES_BLOCK_SIZE];394 395 //set up key with AES_DECRYPTION as dir and tweak with AES_ENCRYPTION396 397 if(wc_AesXtsDecrypt(&aes, plain, cipher, SIZE, i, sizeof(i)) != 0)398 {399 // Handle error400 }401 wc_AesXtsFree(&aes);402 \endcode403 404 \sa wc_AesXtsEncrypt405 \sa wc_AesXtsSetKey406 \sa wc_AesXtsFree407 */408 346 WOLFSSL_API int wc_AesXtsDecrypt(XtsAes* aes, byte* out, 409 347 const byte* in, word32 sz, const byte* i, word32 iSz); 410 348 411 412 /*!413 \ingroup AES414 415 \brief This is to free up any resources used by the XtsAes structure416 417 \return 0 Success418 419 \param aes AES keys to free420 421 _Example_422 \code423 XtsAes aes;424 425 if(wc_AesXtsSetKey(&aes, key, sizeof(key), AES_ENCRYPTION, NULL, 0) != 0)426 {427 // Handle error428 }429 wc_AesXtsFree(&aes);430 \endcode431 432 \sa wc_AesXtsEncrypt433 \sa wc_AesXtsDecrypt434 \sa wc_AesXtsSetKey435 */436 349 WOLFSSL_API int wc_AesXtsFree(XtsAes* aes); 437 350 #endif … … 439 352 WOLFSSL_API int wc_AesGetKeySize(Aes* aes, word32* keySize); 440 353 441 WOLFSSL_API int wc_AesInit(Aes*, void*, int); 442 WOLFSSL_API void wc_AesFree(Aes*); 354 WOLFSSL_API int wc_AesInit(Aes* aes, void* heap, int devId); 355 #ifdef HAVE_PKCS11 356 WOLFSSL_API int wc_AesInit_Id(Aes* aes, unsigned char* id, int len, void* heap, 357 int devId); 358 #endif 359 WOLFSSL_API void wc_AesFree(Aes* aes); 443 360 444 361 #ifdef __cplusplus -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/arc4.h
r352 r372 20 20 */ 21 21 22 22 /*! 23 \file wolfssl/wolfcrypt/arc4.h 24 */ 23 25 24 26 #ifndef WOLF_CRYPT_ARC4_H … … 37 39 enum { 38 40 ARC4_ENC_TYPE = 4, /* cipher unique type */ 39 ARC4_STATE_SIZE = 256 41 ARC4_STATE_SIZE = 256, 42 RC4_KEY_SIZE = 16, /* always 128bit */ 40 43 }; 41 44 -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/asn.h
r352 r372 20 20 */ 21 21 22 /*! 23 \file wolfssl/wolfcrypt/asn.h 24 */ 22 25 23 26 #ifndef WOLF_CRYPT_ASN_H … … 28 31 #ifndef NO_ASN 29 32 33 34 #if !defined(NO_ASN_TIME) && defined(NO_TIME_H) 35 #define NO_ASN_TIME /* backwards compatibility with NO_TIME_H */ 36 #endif 37 30 38 #include <wolfssl/wolfcrypt/integer.h> 31 39 32 40 /* fips declare of RsaPrivateKeyDecode @wc_fips */ 33 #if defined(HAVE_FIPS) && !defined(NO_RSA) 41 #if defined(HAVE_FIPS) && !defined(NO_RSA) && \ 42 (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2)) 34 43 #include <cyassl/ctaocrypt/rsa.h> 35 44 #endif … … 50 59 #include <wolfssl/wolfcrypt/asn_public.h> /* public interface */ 51 60 61 #if defined(NO_SHA) && defined(NO_SHA256) 62 #define WC_SHA256_DIGEST_SIZE 32 63 #endif 52 64 53 65 #ifdef __cplusplus … … 77 89 ASN_SEQUENCE = 0x10, 78 90 ASN_SET = 0x11, 91 ASN_PRINTABLE_STRING = 0x13, 79 92 ASN_UTC_TIME = 0x17, 80 93 ASN_OTHER_TYPE = 0x00, … … 82 95 ASN_DNS_TYPE = 0x02, 83 96 ASN_DIR_TYPE = 0x04, 97 ASN_URI_TYPE = 0x06, /* the value 6 is from GeneralName OID */ 84 98 ASN_GENERALIZED_TIME = 0x18, 85 99 CRL_EXTENSIONS = 0xa0, 86 100 ASN_EXTENSIONS = 0xa3, 87 ASN_LONG_LENGTH = 0x80 88 }; 89 90 enum ASN_Flags { 101 ASN_LONG_LENGTH = 0x80, 102 ASN_INDEF_LENGTH = 0x80, 103 104 /* ASN_Flags - Bitmask */ 91 105 ASN_CONSTRUCTED = 0x20, 92 ASN_CONTEXT_SPECIFIC = 0x80 93 }; 106 ASN_APPLICATION = 0x40, 107 ASN_CONTEXT_SPECIFIC = 0x80, 108 }; 109 110 #define ASN_UTC_TIME_SIZE 14 111 #define ASN_GENERALIZED_TIME_SIZE 16 112 #define ASN_GENERALIZED_TIME_MAX 68 94 113 95 114 enum DN_Tags { … … 101 120 ASN_STATE_NAME = 0x08, /* ST */ 102 121 ASN_ORG_NAME = 0x0a, /* O */ 103 ASN_ORGUNIT_NAME = 0x0b /* OU */ 104 }; 105 106 enum PBES { 107 PBE_MD5_DES = 0, 108 PBE_SHA1_DES = 1, 109 PBE_SHA1_DES3 = 2, 110 PBE_SHA1_RC4_128 = 3, 111 PBES2 = 13 /* algo ID */ 112 }; 113 114 enum ENCRYPTION_TYPES { 115 DES_TYPE = 0, 116 DES3_TYPE = 1, 117 RC4_TYPE = 2 118 }; 119 120 enum ECC_TYPES { 122 ASN_ORGUNIT_NAME = 0x0b, /* OU */ 123 ASN_BUS_CAT = 0x0f, /* businessCategory */ 124 ASN_EMAIL_NAME = 0x98, /* not oid number there is 97 in 2.5.4.0-97 */ 125 126 /* pilot attribute types 127 * OID values of 0.9.2342.19200300.100.1.* */ 128 ASN_USER_ID = 0x01, /* UID */ 129 ASN_DOMAIN_COMPONENT = 0x19 /* DC */ 130 }; 131 132 /* DN Tag Strings */ 133 #define WOLFSSL_COMMON_NAME "/CN=" 134 #define WOLFSSL_SUR_NAME "/SN=" 135 #define WOLFSSL_SERIAL_NUMBER "/serialNumber=" 136 #define WOLFSSL_COUNTRY_NAME "/C=" 137 #define WOLFSSL_LOCALITY_NAME "/L=" 138 #define WOLFSSL_STATE_NAME "/ST=" 139 #define WOLFSSL_ORG_NAME "/O=" 140 #define WOLFSSL_ORGUNIT_NAME "/OU=" 141 #define WOLFSSL_DOMAIN_COMPONENT "/DC=" 142 #define WOLFSSL_BUS_CAT "/businessCategory=" 143 #define WOLFSSL_JOI_C "/jurisdictionC=" 144 #define WOLFSSL_JOI_ST "/jurisdictionST=" 145 #define WOLFSSL_EMAIL_ADDR "/emailAddress=" 146 147 /* NIDs */ 148 enum 149 { 150 NID_undef = 0, 151 NID_des = 66, 152 NID_des3 = 67, 153 NID_sha256 = 672, 154 NID_sha384 = 673, 155 NID_sha512 = 674, 156 NID_hw_name_oid = 73, 157 NID_id_pkix_OCSP_basic = 74, 158 NID_any_policy = 75, 159 NID_anyExtendedKeyUsage = 76, 160 NID_basic_constraints = 133, 161 NID_key_usage = 129, /* 2.5.29.15 */ 162 NID_ext_key_usage = 151, /* 2.5.29.37 */ 163 NID_subject_key_identifier = 128, 164 NID_authority_key_identifier = 149, 165 NID_private_key_usage_period = 130, /* 2.5.29.16 */ 166 NID_subject_alt_name = 131, 167 NID_issuer_alt_name = 132, 168 NID_info_access = 69, 169 NID_sinfo_access = 79, /* id-pe 11 */ 170 NID_name_constraints = 144, /* 2.5.29.30 */ 171 NID_certificate_policies = 146, 172 NID_policy_mappings = 147, 173 NID_policy_constraints = 150, 174 NID_inhibit_any_policy = 168, /* 2.5.29.54 */ 175 NID_tlsfeature = 92, /* id-pe 24 */ 176 NID_commonName = 0x03, /* matchs ASN_COMMON_NAME in asn.h */ 177 NID_surname = 0x04, /* SN */ 178 NID_serialNumber = 0x05, /* serialNumber */ 179 NID_countryName = 0x06, /* C */ 180 NID_localityName = 0x07, /* L */ 181 NID_stateOrProvinceName = 0x08, /* ST */ 182 NID_organizationName = 0x0a, /* O */ 183 NID_organizationalUnitName = 0x0b, /* OU */ 184 NID_domainComponent = 0x19, /* matchs ASN_DOMAIN_COMPONENT in asn.h */ 185 NID_emailAddress = 0x30, /* emailAddress */ 186 }; 187 188 enum ECC_TYPES 189 { 121 190 ECC_PREFIX_0 = 160, 122 191 ECC_PREFIX_1 = 161 123 192 }; 124 193 194 #ifdef WOLFSSL_CERT_PIV 195 enum PIV_Tags { 196 ASN_PIV_CERT = 0x0A, 197 ASN_PIV_NONCE = 0x0B, 198 ASN_PIV_SIGNED_NONCE = 0x0C, 199 200 ASN_PIV_TAG_CERT = 0x70, 201 ASN_PIV_TAG_CERT_INFO = 0x71, 202 ASN_PIV_TAG_MSCUID = 0x72, 203 ASN_PIV_TAG_ERR_DET = 0xFE, 204 205 /* certificate info masks */ 206 ASN_PIV_CERT_INFO_COMPRESSED = 0x03, 207 ASN_PIV_CERT_INFO_ISX509 = 0x04, 208 }; 209 #endif /* WOLFSSL_CERT_PIV */ 210 211 212 #define ASN_JOI_PREFIX "\x2b\x06\x01\x04\x01\x82\x37\x3c\x02\x01" 213 #define ASN_JOI_C 0x3 214 #define ASN_JOI_ST 0x2 215 216 #ifndef WC_ASN_NAME_MAX 217 #define WC_ASN_NAME_MAX 256 218 #endif 219 125 220 enum Misc_ASN { 126 ASN_NAME_MAX = 256,221 ASN_NAME_MAX = WC_ASN_NAME_MAX, 127 222 MAX_SALT_SIZE = 64, /* MAX PKCS Salt length */ 128 223 MAX_IV_SIZE = 64, /* MAX PKCS Iv length */ 129 MAX_KEY_SIZE = 64, /* MAX PKCS Key length */130 PKCS5 = 5, /* PKCS oid tag */131 PKCS5v2 = 6, /* PKCS #5 v2.0 */132 PKCS8v0 = 0, /* default PKCS#8 version */133 PKCS12v1 = 12, /* PKCS #12 */134 MAX_UNICODE_SZ = 256,135 224 ASN_BOOL_SIZE = 2, /* including type */ 136 225 ASN_ECC_HEADER_SZ = 2, /* String type + 1 byte len */ … … 146 235 MAX_DATE_SIZE = 32, 147 236 ASN_GEN_TIME_SZ = 15, /* 7 numbers * 2 + Zulu tag */ 237 #ifndef NO_RSA 148 238 MAX_ENCODED_SIG_SZ = 512, 239 #elif defined(HAVE_ECC) 240 MAX_ENCODED_SIG_SZ = 140, 241 #else 242 MAX_ENCODED_SIG_SZ = 64, 243 #endif 149 244 MAX_SIG_SZ = 256, 150 245 MAX_ALGO_SZ = 20, 246 MAX_SHORT_SZ = 6, /* asn int + byte len + 4 byte length */ 151 247 MAX_SEQ_SZ = 5, /* enum(seq | con) + length(4) */ 152 248 MAX_SET_SZ = 5, /* enum(set | con) + length(4) */ … … 155 251 MAX_PRSTR_SZ = 5, /* enum(prstr) + length(4) */ 156 252 MAX_VERSION_SZ = 5, /* enum + id + version(byte) + (header(2))*/ 157 MAX_ENCODED_DIG_SZ = 73, /* sha512 + enum(bit or octet) + length(4) */ 253 MAX_ENCODED_DIG_ASN_SZ= 9, /* enum(bit or octet) + length(4) */ 254 MAX_ENCODED_DIG_SZ = 64 + MAX_ENCODED_DIG_ASN_SZ, /* asn header + sha512 */ 158 255 MAX_RSA_INT_SZ = 517, /* RSA raw sz 4096 for bits + tag + len(4) */ 159 256 MAX_NTRU_KEY_SZ = 610, /* NTRU 112 bit public key */ … … 163 260 MAX_CA_SZ = 32, /* Max encoded CA basic constraint length */ 164 261 MAX_SN_SZ = 35, /* Max encoded serial number (INT) length */ 165 MAX_DER_DIGEST_SZ = MAX_ENCODED_DIG_SZ + MAX_ALGO_SZ + MAX_SEQ_SZ, /* Maximum DER digest size */ 262 MAX_DER_DIGEST_SZ = MAX_ENCODED_DIG_SZ + MAX_ALGO_SZ + MAX_SEQ_SZ, 263 /* Maximum DER digest size */ 264 MAX_DER_DIGEST_ASN_SZ = MAX_ENCODED_DIG_ASN_SZ + MAX_ALGO_SZ + MAX_SEQ_SZ, 265 /* Maximum DER digest ASN header size */ 166 266 #ifdef WOLFSSL_CERT_GEN 167 267 #ifdef WOLFSSL_CERT_REQ … … 177 277 /* Max total extensions, id + len + others */ 178 278 #endif 279 #if defined(WOLFSSL_CERT_EXT) || defined(OPENSSL_EXTRA) || defined(HAVE_PKCS7) 280 MAX_OID_SZ = 32, /* Max DER length of OID*/ 281 MAX_OID_STRING_SZ = 64, /* Max string length representation of OID*/ 282 #endif 179 283 #ifdef WOLFSSL_CERT_EXT 180 284 MAX_KID_SZ = 45, /* Max encoded KID length (SHA-256 case) */ 181 285 MAX_KEYUSAGE_SZ = 18, /* Max encoded Key Usage length */ 182 MAX_EXTKEYUSAGE_SZ = 12 + (6 * (8 + 2)) , /* Max encoded ExtKeyUsage183 (SEQ/LEN + OBJID + OCTSTR/LEN + SEQ + (6 * (SEQ + OID))) */184 MAX_OID_SZ = 32, /* Max DER length of OID*/185 MAX_OID_STRING_SZ = 64, /* Max string length representation of OID*/286 MAX_EXTKEYUSAGE_SZ = 12 + (6 * (8 + 2)) + 287 CTC_MAX_EKU_OID_SZ, /* Max encoded ExtKeyUsage 288 (SEQ/LEN + OBJID + OCTSTR/LEN + SEQ + 289 (6 * (SEQ + OID))) */ 186 290 MAX_CERTPOL_NB = CTC_MAX_CERTPOL_NB,/* Max number of Cert Policy */ 187 291 MAX_CERTPOL_SZ = CTC_MAX_CERTPOL_SZ, 188 292 #endif 293 MAX_NAME_ENTRIES = 5, /* extra entries added to x509 name struct */ 189 294 OCSP_NONCE_EXT_SZ = 35, /* OCSP Nonce Extension size */ 190 295 MAX_OCSP_EXT_SZ = 58, /* Max OCSP Extension length */ … … 193 298 MAX_PUBLIC_KEY_SZ = MAX_NTRU_ENC_SZ + MAX_ALGO_SZ + MAX_SEQ_SZ * 2, 194 299 /* use bigger NTRU size */ 300 #ifdef WOLFSSL_ENCRYPTED_KEYS 195 301 HEADER_ENCRYPTED_KEY_SIZE = 88,/* Extra header size for encrypted key */ 302 #else 303 HEADER_ENCRYPTED_KEY_SIZE = 0, 304 #endif 196 305 TRAILING_ZERO = 1, /* Used for size of zero pad */ 306 ASN_TAG_SZ = 1, /* single byte ASN.1 tag */ 197 307 MIN_VERSION_SZ = 3, /* Min bytes needed for GetMyVersion */ 198 #if defined(WOLFSSL_MYSQL_COMPATIBLE) || defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY) 308 #if defined(OPENSSL_ALL) || defined(WOLFSSL_MYSQL_COMPATIBLE) || \ 309 defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY) || \ 310 defined(OPENSSL_EXTRA) || defined(HAVE_PKCS7) 199 311 MAX_TIME_STRING_SZ = 25, /* Max length of formatted time string */ 200 312 #endif 313 314 PKCS5_SALT_SZ = 8, 315 316 PEM_LINE_LEN = 80, /* PEM line max + fudge */ 201 317 }; 202 318 … … 217 333 oidKeyWrapType = 12, 218 334 oidCmsKeyAgreeType = 13, 335 oidPBEType = 14, 336 oidHmacType = 15, 337 oidCompressType = 16, 338 oidCertNameType = 17, 219 339 oidIgnoreType 220 340 }; … … 232 352 233 353 354 #if !defined(NO_DES3) || !defined(NO_AES) 234 355 enum Block_Sum { 356 #ifdef WOLFSSL_AES_128 235 357 AES128CBCb = 414, 358 AES128GCMb = 418, 359 AES128CCMb = 419, 360 #endif 361 #ifdef WOLFSSL_AES_192 236 362 AES192CBCb = 434, 363 AES192GCMb = 438, 364 AES192CCMb = 439, 365 #endif 366 #ifdef WOLFSSL_AES_256 237 367 AES256CBCb = 454, 368 AES256GCMb = 458, 369 AES256CCMb = 459, 370 #endif 371 #ifndef NO_DES3 238 372 DESb = 69, 239 373 DES3b = 652 240 }; 374 #endif 375 }; 376 #endif /* !NO_DES3 || !NO_AES */ 241 377 242 378 … … 250 386 251 387 388 #if !defined(NO_AES) || defined(HAVE_PKCS7) 252 389 enum KeyWrap_Sum { 390 #ifdef WOLFSSL_AES_128 253 391 AES128_WRAP = 417, 392 #endif 393 #ifdef WOLFSSL_AES_192 254 394 AES192_WRAP = 437, 255 AES256_WRAP = 457 256 }; 257 395 #endif 396 #ifdef WOLFSSL_AES_256 397 AES256_WRAP = 457, 398 #endif 399 #ifdef HAVE_PKCS7 400 PWRI_KEK_WRAP = 680 /*id-alg-PWRI-KEK, 1.2.840.113549.1.9.16.3.9 */ 401 #endif 402 }; 403 #endif /* !NO_AES || PKCS7 */ 258 404 259 405 enum Key_Agree { … … 304 450 305 451 452 enum HMAC_Sum { 453 HMAC_SHA224_OID = 652, 454 HMAC_SHA256_OID = 653, 455 HMAC_SHA384_OID = 654, 456 HMAC_SHA512_OID = 655 457 }; 458 459 306 460 enum Extensions_Sum { 307 461 BASIC_CA_OID = 133, … … 347 501 }; 348 502 503 #ifdef HAVE_LIBZ 504 enum CompressAlg_Sum { 505 ZLIBc = 679 /* 1.2.840.113549.1.9.16.3.8, id-alg-zlibCompress */ 506 }; 507 #endif 349 508 350 509 enum VerifyType { … … 352 511 VERIFY = 1, 353 512 VERIFY_CRL = 2, 354 VERIFY_OCSP = 3 513 VERIFY_OCSP = 3, 514 VERIFY_NAME = 4 355 515 }; 356 516 … … 374 534 375 535 /* Extended Key Usage bits (internal mapping only) */ 536 #define EXTKEYUSE_USER 0x80 376 537 #define EXTKEYUSE_OCSP_SIGN 0x40 377 538 #define EXTKEYUSE_TIMESTAMP 0x20 … … 386 547 struct DNS_entry { 387 548 DNS_entry* next; /* next on DNS list */ 549 int type; /* i.e. ASN_DNS_TYPE */ 550 int len; /* actual DNS len */ 388 551 char* name; /* actual DNS name */ 389 552 }; … … 399 562 }; 400 563 564 #define DOMAIN_COMPONENT_MAX 10 401 565 402 566 struct DecodedName { … … 406 570 int cnIdx; 407 571 int cnLen; 572 int cnNid; 408 573 int snIdx; 409 574 int snLen; 575 int snNid; 410 576 int cIdx; 411 577 int cLen; 578 int cNid; 412 579 int lIdx; 413 580 int lLen; 581 int lNid; 414 582 int stIdx; 415 583 int stLen; 584 int stNid; 416 585 int oIdx; 417 586 int oLen; 587 int oNid; 418 588 int ouIdx; 419 589 int ouLen; 590 #ifdef WOLFSSL_CERT_EXT 591 int bcIdx; 592 int bcLen; 593 int jcIdx; 594 int jcLen; 595 int jsIdx; 596 int jsLen; 597 #endif 598 int ouNid; 420 599 int emailIdx; 421 600 int emailLen; 601 int emailNid; 422 602 int uidIdx; 423 603 int uidLen; 604 int uidNid; 424 605 int serialIdx; 425 606 int serialLen; 607 int serialNid; 608 int dcIdx[DOMAIN_COMPONENT_MAX]; 609 int dcLen[DOMAIN_COMPONENT_MAX]; 610 int dcNum; 611 int dcMode; 426 612 }; 427 613 … … 433 619 SIG_STATE_CHECK, 434 620 }; 621 622 623 #ifdef HAVE_PK_CALLBACKS 624 #ifdef HAVE_ECC 625 typedef int (*wc_CallbackEccVerify)( 626 const unsigned char* sig, unsigned int sigSz, 627 const unsigned char* hash, unsigned int hashSz, 628 const unsigned char* keyDer, unsigned int keySz, 629 int* result, void* ctx); 630 #endif 631 #ifndef NO_RSA 632 typedef int (*wc_CallbackRsaVerify)( 633 unsigned char* sig, unsigned int sigSz, 634 unsigned char** out, 635 const unsigned char* keyDer, unsigned int keySz, 636 void* ctx); 637 #endif 638 #endif /* HAVE_PK_CALLBACKS */ 435 639 436 640 struct SignatureCtx { … … 465 669 void* asyncCtx; 466 670 #endif 671 672 #ifdef HAVE_PK_CALLBACKS 673 #ifdef HAVE_ECC 674 wc_CallbackEccVerify pkCbEcc; 675 void* pkCtxEcc; 676 #endif 677 #ifndef NO_RSA 678 wc_CallbackRsaVerify pkCbRsa; 679 void* pkCtxRsa; 680 #endif 681 #endif /* HAVE_PK_CALLBACKS */ 467 682 }; 468 683 … … 496 711 497 712 struct DecodedCert { 498 byte*publicKey;713 const byte* publicKey; 499 714 word32 pubKeySize; 500 715 int pubKeyStored; … … 516 731 byte issuerKeyHash[KEYID_SIZE]; /* hash of the public Key */ 517 732 #endif /* HAVE_OCSP */ 518 byte* signature;/* not owned, points into raw cert */733 const byte* signature; /* not owned, points into raw cert */ 519 734 char* subjectCN; /* CommonName */ 520 735 int subjectCNLen; /* CommonName Length */ 521 736 char subjectCNEnc; /* CommonName Encoding */ 522 int subjectCNStored; /* have we saved a copy we own */523 737 char issuer[ASN_NAME_MAX]; /* full name including common name */ 524 738 char subject[ASN_NAME_MAX]; /* full name including common name */ 525 739 int verify; /* Default to yes, but could be off */ 526 byte* source;/* byte buffer holder cert, NOT owner */740 const byte* source; /* byte buffer holder cert, NOT owner */ 527 741 word32 srcIdx; /* current offset into buffer */ 528 742 word32 maxIdx; /* max offset based on init size */ … … 530 744 byte serial[EXTERNAL_SERIAL_SIZE]; /* raw serial number */ 531 745 int serialSz; /* raw serial bytes stored */ 532 byte* extensions;/* not owned, points into raw cert */746 const byte* extensions; /* not owned, points into raw cert */ 533 747 int extensionsSz; /* length of cert extensions */ 534 748 word32 extensionsIdx; /* if want to go back and parse later */ 535 byte* extAuthInfo;/* Authority Information Access URI */749 const byte* extAuthInfo; /* Authority Information Access URI */ 536 750 int extAuthInfoSz; /* length of the URI */ 537 byte* extCrlInfo;/* CRL Distribution Points */751 const byte* extCrlInfo; /* CRL Distribution Points */ 538 752 int extCrlInfoSz; /* length of the URI */ 539 753 byte extSubjKeyId[KEYID_SIZE]; /* Subject Key ID */ 540 byte extSubjKeyIdSet; /* Set when the SKID was read from cert */541 754 byte extAuthKeyId[KEYID_SIZE]; /* Authority Key ID */ 542 byte extAuthKeyIdSet; /* Set when the AKID was read from cert */543 #ifndef IGNORE_NAME_CONSTRAINTS544 byte extNameConstraintSet;545 #endif /* IGNORE_NAME_CONSTRAINTS */546 byte isCA; /* CA basic constraint true */547 byte pathLengthSet; /* CA basic const path length set */548 755 byte pathLength; /* CA basic constraint path length */ 549 byte weOwnAltNames; /* altNames haven't been given to copy */550 byte extKeyUsageSet;551 756 word16 extKeyUsage; /* Key usage bitfield */ 552 byte extExtKeyUsageSet; /* Extended Key Usage */553 757 byte extExtKeyUsage; /* Extended Key usage bitfield */ 554 #ifdef OPENSSL_EXTRA 555 byte extCRLdistSet; 556 byte extCRLdistCrit; 557 byte extAuthInfoSet; 558 byte extAuthInfoCrit; 559 byte extBasicConstSet; 560 byte extBasicConstCrit; 561 byte extSubjAltNameSet; 562 byte extSubjAltNameCrit; 563 byte extAuthKeyIdCrit; 564 #ifndef IGNORE_NAME_CONSTRAINTS 565 byte extNameConstraintCrit; 566 #endif /* IGNORE_NAME_CONSTRAINTS */ 567 byte extSubjKeyIdCrit; 568 byte extKeyUsageCrit; 569 byte extExtKeyUsageCrit; 570 byte* extExtKeyUsageSrc; 758 759 #if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL) 760 const byte* extExtKeyUsageSrc; 571 761 word32 extExtKeyUsageSz; 572 762 word32 extExtKeyUsageCount; 573 byte*extAuthKeyIdSrc;763 const byte* extAuthKeyIdSrc; 574 764 word32 extAuthKeyIdSz; 575 byte*extSubjKeyIdSrc;765 const byte* extSubjKeyIdSrc; 576 766 word32 extSubjKeyIdSz; 577 767 #endif 768 578 769 #if defined(HAVE_ECC) || defined(HAVE_ED25519) 579 770 word32 pkCurveOID; /* Public Key's curve OID */ 580 771 #endif /* HAVE_ECC */ 581 byte*beforeDate;772 const byte* beforeDate; 582 773 int beforeDateLen; 583 byte*afterDate;774 const byte* afterDate; 584 775 int afterDateLen; 585 #if def HAVE_PKCS7586 byte* issuerRaw;/* pointer to issuer inside source */776 #if defined(HAVE_PKCS7) || defined(WOLFSSL_CERT_EXT) 777 const byte* issuerRaw; /* pointer to issuer inside source */ 587 778 int issuerRawLen; 588 779 #endif 589 780 #ifndef IGNORE_NAME_CONSTRAINT 590 byte* subjectRaw;/* pointer to subject inside source */781 const byte* subjectRaw; /* pointer to subject inside source */ 591 782 int subjectRawLen; 592 783 #endif 593 #if defined(WOLFSSL_CERT_GEN) 784 #if defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_CERT_EXT) 594 785 /* easy access to subject info for other sign */ 595 786 char* subjectSN; … … 611 802 int subjectOULen; 612 803 char subjectOUEnc; 804 char* subjectSND; 805 int subjectSNDLen; 806 char subjectSNDEnc; 807 #ifdef WOLFSSL_CERT_EXT 808 char* subjectBC; 809 int subjectBCLen; 810 char subjectBCEnc; 811 char* subjectJC; 812 int subjectJCLen; 813 char subjectJCEnc; 814 char* subjectJS; 815 int subjectJSLen; 816 char subjectJSEnc; 817 #endif 613 818 char* subjectEmail; 614 819 int subjectEmailLen; 615 820 #endif /* WOLFSSL_CERT_GEN */ 616 #if def OPENSSL_EXTRA821 #if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL) 617 822 DecodedName issuerName; 618 823 DecodedName subjectName; … … 625 830 int hwSerialNumSz; 626 831 byte* hwSerialNum; 627 #ifdef OPENSSL_EXTRA628 byte extCertPolicySet;629 byte extCertPolicyCrit;630 #endif /* OPENSSL_EXTRA */631 832 #endif /* WOLFSSL_SEP */ 632 833 #ifdef WOLFSSL_CERT_EXT 633 834 char extCertPolicies[MAX_CERTPOL_NB][MAX_CERTPOL_SZ]; 634 835 int extCertPoliciesNb; 635 #endif /* WOLFSSL_CERT_EXT*/836 #endif /* defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_CERT_EXT) */ 636 837 637 838 Signer* ca; 638 839 SignatureCtx sigCtx; 639 }; 640 641 642 struct WOLFSSL_ASN1_OBJECT { 643 void* heap; 644 byte* obj; 645 int type; /* oid */ 646 word32 objSz; 647 byte dynamic; /* if 1 then obj was dynamiclly created, 0 otherwise */ 648 }; 649 650 651 extern const char* BEGIN_CERT; 652 extern const char* END_CERT; 653 extern const char* BEGIN_CERT_REQ; 654 extern const char* END_CERT_REQ; 655 extern const char* BEGIN_DSA_PARAM; 656 extern const char* END_DSA_PARAM; 657 extern const char* BEGIN_DH_PARAM; 658 extern const char* END_DH_PARAM; 659 extern const char* BEGIN_X509_CRL; 660 extern const char* END_X509_CRL; 661 extern const char* BEGIN_RSA_PRIV; 662 extern const char* END_RSA_PRIV; 663 extern const char* BEGIN_PRIV_KEY; 664 extern const char* END_PRIV_KEY; 665 extern const char* BEGIN_ENC_PRIV_KEY; 666 extern const char* END_ENC_PRIV_KEY; 667 extern const char* BEGIN_EC_PRIV; 668 extern const char* END_EC_PRIV; 669 extern const char* BEGIN_DSA_PRIV; 670 extern const char* END_DSA_PRIV; 671 extern const char* BEGIN_PUB_KEY; 672 extern const char* END_PUB_KEY; 673 extern const char* BEGIN_EDDSA_PRIV; 674 extern const char* END_EDDSA_PRIV; 840 841 /* Option Bits */ 842 byte subjectCNStored : 1; /* have we saved a copy we own */ 843 byte extSubjKeyIdSet : 1; /* Set when the SKID was read from cert */ 844 byte extAuthKeyIdSet : 1; /* Set when the AKID was read from cert */ 845 #ifndef IGNORE_NAME_CONSTRAINTS 846 byte extNameConstraintSet : 1; 847 #endif 848 byte isCA : 1; /* CA basic constraint true */ 849 byte pathLengthSet : 1; /* CA basic const path length set */ 850 byte weOwnAltNames : 1; /* altNames haven't been given to copy */ 851 byte extKeyUsageSet : 1; 852 byte extExtKeyUsageSet : 1; /* Extended Key Usage set */ 853 byte extCRLdistSet : 1; 854 byte extAuthInfoSet : 1; 855 byte extBasicConstSet : 1; 856 byte extSubjAltNameSet : 1; 857 byte inhibitAnyOidSet : 1; 858 #ifdef WOLFSSL_SEP 859 byte extCertPolicySet : 1; 860 #endif 861 #if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL) 862 byte extCRLdistCrit : 1; 863 byte extAuthInfoCrit : 1; 864 byte extBasicConstCrit : 1; 865 byte extSubjAltNameCrit : 1; 866 byte extAuthKeyIdCrit : 1; 867 #ifndef IGNORE_NAME_CONSTRAINTS 868 byte extNameConstraintCrit : 1; 869 #endif 870 byte extSubjKeyIdCrit : 1; 871 byte extKeyUsageCrit : 1; 872 byte extExtKeyUsageCrit : 1; 873 #endif /* OPENSSL_EXTRA */ 874 #ifdef WOLFSSL_SEP 875 byte extCertPolicyCrit : 1; 876 #endif 877 878 }; 879 675 880 676 881 #ifdef NO_SHA … … 688 893 byte pathLength; 689 894 byte pathLengthSet; 690 byte*publicKey;895 const byte* publicKey; 691 896 int nameLen; 692 897 char* name; /* common name */ … … 701 906 /* sha hash of names in certificate */ 702 907 #endif 908 #ifdef WOLFSSL_SIGNER_DER_CERT 909 DerBuffer* derCert; 910 #endif 703 911 Signer* next; 704 912 }; … … 728 936 729 937 /* for testing or custom openssl wrappers */ 730 #if defined(WOLFSSL_TEST_CERT) || defined(OPENSSL_EXTRA) 938 #if defined(WOLFSSL_TEST_CERT) || defined(OPENSSL_EXTRA) || \ 939 defined(OPENSSL_EXTRA_X509_SMALL) 731 940 #define WOLFSSL_ASN_API WOLFSSL_API 732 941 #else 733 942 #define WOLFSSL_ASN_API WOLFSSL_LOCAL 734 943 #endif 944 945 /* Macro for calculating hashId */ 946 #if defined(NO_SHA) && defined(NO_SHA256) 947 #ifdef WOLF_CRYPTO_DEV 948 #define CalcHashId(data, len, hash) wc_CryptoDevSha256Hash(data, len, hash) 949 #else 950 #define CalcHashId(data, len, hash) NOT_COMPILED_IN 951 #endif 952 #elif defined(NO_SHA) 953 #define CalcHashId(data, len, hash) wc_Sha256Hash(data, len, hash) 954 #else 955 #define CalcHashId(data, len, hash) wc_ShaHash(data, len, hash) 956 #endif 957 958 959 WOLFSSL_ASN_API int wc_BerToDer(const byte* ber, word32 berSz, byte* der, 960 word32* derSz); 735 961 736 962 WOLFSSL_ASN_API void FreeAltNames(DNS_entry*, void*); … … 738 964 WOLFSSL_ASN_API void FreeNameSubtrees(Base_entry*, void*); 739 965 #endif /* IGNORE_NAME_CONSTRAINTS */ 740 WOLFSSL_ASN_API void InitDecodedCert(DecodedCert*, byte*, word32, void*);966 WOLFSSL_ASN_API void InitDecodedCert(DecodedCert*, const byte*, word32, void*); 741 967 WOLFSSL_ASN_API void FreeDecodedCert(DecodedCert*); 742 968 WOLFSSL_ASN_API int ParseCert(DecodedCert*, int type, int verify, void* cm); 743 969 970 WOLFSSL_LOCAL int DecodePolicyOID(char *o, word32 oSz, 971 const byte *in, word32 inSz); 972 WOLFSSL_API int CheckCertSignature(const byte*,word32,void*,void* cm); 744 973 WOLFSSL_LOCAL int ParseCertRelative(DecodedCert*,int type,int verify,void* cm); 745 974 WOLFSSL_LOCAL int DecodeToKey(DecodedCert*, int verify); 746 975 976 WOLFSSL_LOCAL const byte* OidFromId(word32 id, word32 type, word32* oidSz); 747 977 WOLFSSL_LOCAL Signer* MakeSigner(void*); 748 978 WOLFSSL_LOCAL void FreeSigner(Signer*, void*); … … 754 984 755 985 WOLFSSL_ASN_API int ToTraditional(byte* buffer, word32 length); 986 WOLFSSL_ASN_API int ToTraditional_ex(byte* buffer, word32 length, 987 word32* algId); 756 988 WOLFSSL_LOCAL int ToTraditionalInline(const byte* input, word32* inOutIdx, 757 989 word32 length); 758 WOLFSSL_LOCAL int ToTraditionalEnc(byte* buffer, word32 length,const char*,int); 990 WOLFSSL_LOCAL int ToTraditionalInline_ex(const byte* input, word32* inOutIdx, 991 word32 length, word32* algId); 992 WOLFSSL_LOCAL int ToTraditionalEnc(byte* buffer, word32 length,const char*,int, 993 word32* algId); 994 WOLFSSL_ASN_API int UnTraditionalEnc(byte* key, word32 keySz, byte* out, 995 word32* outSz, const char* password, int passwordSz, int vPKCS, 996 int vAlgo, byte* salt, word32 saltSz, int itt, WC_RNG* rng, void* heap); 997 WOLFSSL_ASN_API int TraditionalEnc(byte* key, word32 keySz, byte* out, 998 word32* outSz, const char* password, int passwordSz, int vPKCS, 999 int vAlgo, int encAlgId, byte* salt, word32 saltSz, int itt, 1000 WC_RNG* rng, void* heap); 759 1001 WOLFSSL_LOCAL int DecryptContent(byte* input, word32 sz,const char* psw,int pswSz); 1002 WOLFSSL_LOCAL int EncryptContent(byte* input, word32 sz, byte* out, word32* outSz, 1003 const char* password,int passwordSz, int vPKCS, int vAlgo, 1004 byte* salt, word32 saltSz, int itt, WC_RNG* rng, void* heap); 760 1005 WOLFSSL_LOCAL int wc_GetKeyOID(byte* key, word32 keySz, const byte** curveOID, 761 1006 word32* oidSz, int* algoID, void* heap); 762 1007 763 1008 typedef struct tm wolfssl_tm; 764 #if defined(WOLFSSL_MYSQL_COMPATIBLE) || defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY) 1009 #if defined(OPENSSL_ALL) || defined(WOLFSSL_MYSQL_COMPATIBLE) || defined(OPENSSL_EXTRA) || \ 1010 defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY) 765 1011 WOLFSSL_LOCAL int GetTimeString(byte* date, int format, char* buf, int len); 1012 #endif 1013 #if !defined(NO_ASN_TIME) && defined(HAVE_PKCS7) 1014 WOLFSSL_LOCAL int GetAsnTimeString(void* currTime, byte* buf, word32 len); 766 1015 #endif 767 1016 WOLFSSL_LOCAL int ExtractDate(const unsigned char* date, unsigned char format, 768 1017 wolfssl_tm* certTime, int* idx); 769 1018 WOLFSSL_LOCAL int ValidateDate(const byte* date, byte format, int dateType); 1019 WOLFSSL_LOCAL int OBJ_sn2nid(const char *sn); 770 1020 771 1021 /* ASN.1 helper functions */ … … 775 1025 WOLFSSL_LOCAL int GetShortInt(const byte* input, word32* inOutIdx, int* number, 776 1026 word32 maxIdx); 1027 WOLFSSL_LOCAL char* GetSigName(int oid); 777 1028 WOLFSSL_LOCAL int GetLength(const byte* input, word32* inOutIdx, int* len, 778 1029 word32 maxIdx); 1030 WOLFSSL_LOCAL int GetLength_ex(const byte* input, word32* inOutIdx, int* len, 1031 word32 maxIdx, int check); 779 1032 WOLFSSL_LOCAL int GetSequence(const byte* input, word32* inOutIdx, int* len, 780 1033 word32 maxIdx); 1034 WOLFSSL_LOCAL int GetSequence_ex(const byte* input, word32* inOutIdx, int* len, 1035 word32 maxIdx, int check); 781 1036 WOLFSSL_LOCAL int GetSet(const byte* input, word32* inOutIdx, int* len, 782 1037 word32 maxIdx); … … 793 1048 word16* out, word32* outSz); 794 1049 #endif 1050 WOLFSSL_LOCAL int GetASNObjectId(const byte* input, word32* inOutIdx, int* len, 1051 word32 maxIdx); 1052 WOLFSSL_LOCAL int SetObjectId(int len, byte* output); 795 1053 WOLFSSL_LOCAL int GetObjectId(const byte* input, word32* inOutIdx, word32* oid, 796 1054 word32 oidType, word32 maxIdx); … … 812 1070 int maxIdx); 813 1071 WOLFSSL_LOCAL int wc_CheckPrivateKey(byte* key, word32 keySz, DecodedCert* der); 1072 WOLFSSL_LOCAL int RsaPublicKeyDerSize(RsaKey* key, int with_header); 814 1073 815 1074 #ifdef HAVE_ECC … … 824 1083 WOLFSSL_LOCAL void FreeSignatureCtx(SignatureCtx* sigCtx); 825 1084 1085 #ifndef NO_CERTS 1086 1087 WOLFSSL_LOCAL int wc_EncryptedInfoParse(EncryptedInfo* info, char** pBuffer, 1088 size_t bufSz); 1089 1090 WOLFSSL_LOCAL int PemToDer(const unsigned char* buff, long sz, int type, 1091 DerBuffer** pDer, void* heap, EncryptedInfo* info, 1092 int* eccKey); 1093 WOLFSSL_LOCAL int AllocDer(DerBuffer** der, word32 length, int type, void* heap); 1094 WOLFSSL_LOCAL void FreeDer(DerBuffer** der); 1095 1096 #endif /* !NO_CERTS */ 826 1097 827 1098 #ifdef WOLFSSL_CERT_GEN 828 1099 829 1100 enum cert_enums { 830 NAME_ENTRIES = 8, 1101 #ifdef WOLFSSL_CERT_EXT 1102 NAME_ENTRIES = 10, 1103 #else 1104 NAME_ENTRIES = 9, 1105 #endif 831 1106 JOINT_LEN = 2, 832 1107 EMAIL_JOINT_LEN = 9, 1108 PILOT_JOINT_LEN = 10, 833 1109 RSA_KEY = 10, 834 1110 NTRU_KEY = 11, … … 836 1112 ED25519_KEY = 13 837 1113 }; 838 839 #ifndef WOLFSSL_PEMCERT_TODER_DEFINED840 #ifndef NO_FILESYSTEM841 /* forward from wolfSSL */842 WOLFSSL_API843 int wolfSSL_PemCertToDer(const char* fileName,unsigned char* derBuf,int derSz);844 #define WOLFSSL_PEMCERT_TODER_DEFINED845 #endif846 #endif847 1114 848 1115 #endif /* WOLFSSL_CERT_GEN */ … … 877 1144 }; 878 1145 1146 #ifdef OPENSSL_EXTRA 1147 enum Ocsp_Verify_Error { 1148 OCSP_VERIFY_ERROR_NONE = 0, 1149 OCSP_BAD_ISSUER = 1 1150 }; 1151 #endif 1152 879 1153 880 1154 typedef struct OcspRequest OcspRequest; … … 894 1168 byte thisDateFormat; 895 1169 byte nextDateFormat; 896 #if defined( WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY)1170 #if defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY) 897 1171 byte* thisDateAsn; 898 1172 byte* nextDateAsn; … … 930 1204 byte* source; /* pointer to source buffer, not owned */ 931 1205 word32 maxIdx; /* max offset based on init size */ 1206 1207 #ifdef OPENSSL_EXTRA 1208 int verifyError; 1209 #endif 932 1210 }; 933 1211 … … 1011 1289 1012 1290 #endif /* !NO_ASN */ 1291 1292 1293 #if !defined(NO_ASN) || !defined(NO_PWDBASED) 1294 1295 #ifndef MAX_KEY_SIZE 1296 #define MAX_KEY_SIZE 64 /* MAX PKCS Key length */ 1297 #endif 1298 #ifndef MAX_UNICODE_SZ 1299 #define MAX_UNICODE_SZ 256 1300 #endif 1301 1302 enum PBESTypes { 1303 PBE_MD5_DES = 0, 1304 PBE_SHA1_RC4_128 = 1, 1305 PBE_SHA1_DES = 2, 1306 PBE_SHA1_DES3 = 3, 1307 PBE_AES256_CBC = 4, 1308 1309 PBE_SHA1_RC4_128_SUM = 657, 1310 PBE_SHA1_DES3_SUM = 659, 1311 PBES2 = 13 /* algo ID */ 1312 }; 1313 1314 enum PKCSTypes { 1315 PKCS5v2 = 6, /* PKCS #5 v2.0 */ 1316 PKCS12v1 = 12, /* PKCS #12 */ 1317 PKCS5 = 5, /* PKCS oid tag */ 1318 PKCS8v0 = 0, /* default PKCS#8 version */ 1319 }; 1320 1321 #endif /* !NO_ASN || !NO_PWDBASED */ 1322 1013 1323 #endif /* WOLF_CRYPT_ASN_H */ -
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 -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/coding.h
r352 r372 20 20 */ 21 21 22 22 /*! 23 \file wolfssl/wolfcrypt/coding.h 24 */ 23 25 24 26 #ifndef WOLF_CRYPT_CODING_H … … 62 64 #endif 63 65 64 #if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER) || defined(HAVE_FIPS) \ 65 || defined(HAVE_ECC_CDH) 66 #if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL) || \ 67 defined(HAVE_WEBSERVER) || defined(HAVE_FIPS) || \ 68 defined(HAVE_ECC_CDH) || defined(HAVE_SELFTEST) || \ 69 defined(WOLFSSL_ENCRYPTED_KEYS) 70 #ifndef WOLFSSL_BASE16 71 #define WOLFSSL_BASE16 72 #endif 73 #endif 74 75 #ifdef WOLFSSL_BASE16 66 76 WOLFSSL_API 67 77 int Base16_Decode(const byte* in, word32 inLen, byte* out, word32* outLen); -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/curve25519.h
r352 r372 19 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA 20 20 */ 21 22 /*! 23 \file wolfssl/wolfcrypt/curve25519.h 24 */ 21 25 22 26 -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/des3.h
r352 r372 20 20 */ 21 21 22 /*! 23 \file wolfssl/wolfcrypt/des3.h 24 */ 22 25 23 26 #ifndef WOLF_CRYPT_DES3_H … … 28 31 #ifndef NO_DES3 29 32 30 #ifdef HAVE_FIPS 33 #if defined(HAVE_FIPS) && \ 34 defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2) 35 #include <wolfssl/wolfcrypt/fips.h> 36 #endif /* HAVE_FIPS_VERSION >= 2 */ 37 38 #if defined(HAVE_FIPS) && \ 39 (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2)) 31 40 /* included for fips @wc_fips */ 32 41 #include <cyassl/ctaocrypt/des3.h> … … 37 46 #endif 38 47 39 #ifndef HAVE_FIPS /* to avoid redefinition of macros */ 48 /* these are required for FIPS and non-FIPS */ 49 enum { 50 DES_KEY_SIZE = 8, /* des */ 51 DES3_KEY_SIZE = 24, /* 3 des ede */ 52 DES_IV_SIZE = 8, /* should be the same as DES_BLOCK_SIZE */ 53 }; 54 55 56 /* avoid redefinition of structs */ 57 #if !defined(HAVE_FIPS) || \ 58 (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)) 40 59 41 60 #ifdef WOLFSSL_ASYNC_CRYPT … … 44 63 45 64 enum { 46 DES_ENC_TYPE = 2, /* cipher unique type */ 47 DES3_ENC_TYPE = 3, /* cipher unique type */ 65 DES_ENC_TYPE = WC_CIPHER_DES, /* cipher unique type */ 66 DES3_ENC_TYPE = WC_CIPHER_DES3, /* cipher unique type */ 67 48 68 DES_BLOCK_SIZE = 8, 49 DES_KS_SIZE = 32, 69 DES_KS_SIZE = 32, /* internal DES key buffer size */ 50 70 51 71 DES_ENCRYPTION = 0, -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/dh.h
r352 r372 20 20 */ 21 21 22 /*! 23 \file wolfssl/wolfcrypt/dh.h 24 */ 22 25 23 26 #ifndef WOLF_CRYPT_DH_H … … 27 30 28 31 #ifndef NO_DH 32 33 #if defined(HAVE_FIPS) && \ 34 defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2) 35 #include <wolfssl/wolfcrypt/fips.h> 36 #endif /* HAVE_FIPS_VERSION >= 2 */ 29 37 30 38 #include <wolfssl/wolfcrypt/integer.h> … … 39 47 #endif 40 48 typedef struct DhParams { 49 #ifdef HAVE_FFDHE_Q 50 const byte* q; 51 word32 q_len; 52 #endif /* HAVE_FFDHE_Q */ 41 53 const byte* p; 42 54 word32 p_len; … … 47 59 /* Diffie-Hellman Key */ 48 60 typedef struct DhKey { 49 mp_int p, g ;/* group parameters */61 mp_int p, g, q; /* group parameters */ 50 62 void* heap; 51 63 #ifdef WOLFSSL_ASYNC_CRYPT … … 73 85 WOLFSSL_API int wc_InitDhKey(DhKey* key); 74 86 WOLFSSL_API int wc_InitDhKey_ex(DhKey* key, void* heap, int devId); 75 WOLFSSL_API voidwc_FreeDhKey(DhKey* key);87 WOLFSSL_API int wc_FreeDhKey(DhKey* key); 76 88 77 89 WOLFSSL_API int wc_DhGenerateKeyPair(DhKey* key, WC_RNG* rng, byte* priv, … … 85 97 WOLFSSL_API int wc_DhSetKey(DhKey* key, const byte* p, word32 pSz, const byte* g, 86 98 word32 gSz); 99 WOLFSSL_API int wc_DhSetKey_ex(DhKey* key, const byte* p, word32 pSz, 100 const byte* g, word32 gSz, const byte* q, word32 qSz); 101 WOLFSSL_API int wc_DhSetCheckKey(DhKey* key, const byte* p, word32 pSz, 102 const byte* g, word32 gSz, const byte* q, word32 qSz, 103 int trusted, WC_RNG* rng); 87 104 WOLFSSL_API int wc_DhParamsLoad(const byte* input, word32 inSz, byte* p, 88 105 word32* pInOutSz, byte* g, word32* gInOutSz); 89 106 WOLFSSL_API int wc_DhCheckPubKey(DhKey* key, const byte* pub, word32 pubSz); 107 WOLFSSL_API int wc_DhCheckPubKey_ex(DhKey* key, const byte* pub, word32 pubSz, 108 const byte* prime, word32 primeSz); 109 WOLFSSL_API int wc_DhCheckPrivKey(DhKey* key, const byte* priv, word32 pubSz); 110 WOLFSSL_API int wc_DhCheckPrivKey_ex(DhKey* key, const byte* priv, word32 pubSz, 111 const byte* prime, word32 primeSz); 112 WOLFSSL_API int wc_DhCheckKeyPair(DhKey* key, const byte* pub, word32 pubSz, 113 const byte* priv, word32 privSz); 114 WOLFSSL_API int wc_DhGenerateParams(WC_RNG *rng, int modSz, DhKey *dh); 115 WOLFSSL_API int wc_DhExportParamsRaw(DhKey* dh, byte* p, word32* pSz, 116 byte* q, word32* qSz, byte* g, word32* gSz); 117 90 118 91 119 #ifdef __cplusplus -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/dsa.h
r352 r372 20 20 */ 21 21 22 /*! 23 \file wolfssl/wolfcrypt/dsa.h 24 */ 22 25 23 26 #ifndef WOLF_CRYPT_DSA_H … … 75 78 #endif 76 79 80 /* raw export functions */ 81 WOLFSSL_API int wc_DsaImportParamsRaw(DsaKey* dsa, const char* p, 82 const char* q, const char* g); 83 WOLFSSL_API int wc_DsaImportParamsRawCheck(DsaKey* dsa, const char* p, 84 const char* q, const char* g, 85 int trusted, WC_RNG* rng); 86 WOLFSSL_API int wc_DsaExportParamsRaw(DsaKey* dsa, byte* p, word32* pSz, 87 byte* q, word32* qSz, byte* g, 88 word32* gSz); 89 WOLFSSL_API int wc_DsaExportKeyRaw(DsaKey* dsa, byte* x, word32* xSz, byte* y, 90 word32* ySz); 77 91 #ifdef __cplusplus 78 92 } /* extern "C" */ -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/ecc.h
r352 r372 20 20 */ 21 21 22 /*! 23 \file wolfssl/wolfcrypt/ecc.h 24 */ 25 22 26 23 27 #ifndef WOLF_CRYPT_ECC_H … … 27 31 28 32 #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 */ 29 37 30 38 #include <wolfssl/wolfcrypt/integer.h> … … 73 81 #elif defined(HAVE_ECC320) 74 82 #define MAX_ECC_BITS 320 83 #elif !defined(NO_ECC256) 84 #define MAX_ECC_BITS 256 75 85 #elif defined(HAVE_ECC239) 76 86 #define MAX_ECC_BITS 239 77 87 #elif defined(HAVE_ECC224) 78 88 #define MAX_ECC_BITS 224 79 #elif !defined(NO_ECC256)80 #define MAX_ECC_BITS 25681 89 #elif defined(HAVE_ECC192) 82 90 #define MAX_ECC_BITS 192 … … 110 118 ECC_MAX_PAD_SZ = 4, /* ECC maximum padding size */ 111 119 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 113 141 }; 114 142 … … 176 204 177 205 /* ECC set type defined a GF(p) curve */ 206 #ifndef USE_WINDOWS_API 178 207 typedef struct ecc_set_type { 179 208 int size; /* The size of the curve in octets */ … … 191 220 int cofactor; 192 221 } 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 231 typedef 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 193 247 194 248 … … 247 301 typedef struct alt_fp_int { 248 302 int used, sign, size; 249 fp_digit dp[FP_SIZE_ECC];303 mp_digit dp[FP_SIZE_ECC]; 250 304 } alt_fp_int; 251 305 #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 252 311 253 312 … … 265 324 alt_fp_int xyz[3]; 266 325 #endif 326 #ifdef WOLFSSL_SMALL_STACK_CACHE 327 ecc_key* key; 328 #endif 267 329 } ecc_point; 268 330 … … 285 347 const ecc_set_type* dp; /* domain parameters, either points to NIST 286 348 curves (idx >= 0) or user supplied */ 349 #ifdef WOLFSSL_CUSTOM_CURVES 350 int deallocSet; 351 #endif 287 352 void* heap; /* heap hint */ 353 ecc_point pubkey; /* public key */ 354 mp_int k; /* private key */ 288 355 #ifdef WOLFSSL_ATECC508A 289 356 int slot; /* Key Slot Number (-1 unknown) */ 290 byte pubkey [PUB_KEY_SIZE];291 #e lse292 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; 294 361 #endif 295 362 #ifdef WOLFSSL_ASYNC_CRYPT … … 297 364 mp_int* s; 298 365 WC_ASYNC_DEV asyncDev; 366 #ifdef HAVE_CAVIUM_V 367 mp_int* e; /* Sign, Verify and Shared Secret */ 368 mp_int* signK; 369 #endif 299 370 #ifdef WOLFSSL_CERT_GEN 300 371 CertSignCtx certSignCtx; /* context info for cert sign (MakeSignature) */ 301 372 #endif 302 373 #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 }; 309 388 310 389 … … 322 401 #define ECC_API WOLFSSL_LOCAL 323 402 #endif 403 404 ECC_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); 324 407 325 408 ECC_API int ecc_map(ecc_point*, mp_int*, mp_digit); … … 378 461 WOLFSSL_API 379 462 int 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 464 WOLFSSL_API 465 int wc_ecc_init_id(ecc_key* key, unsigned char* id, int len, void* heap, 466 int devId); 467 #endif 468 #ifdef WOLFSSL_CUSTOM_CURVES 469 WOLFSSL_LOCAL 470 void wc_ecc_free_curve(const ecc_set_type* curve, void* heap); 471 #endif 472 WOLFSSL_API 473 int wc_ecc_free(ecc_key* key); 382 474 WOLFSSL_API 383 475 int wc_ecc_set_flags(ecc_key* key, word32 flags); … … 410 502 const byte* Gx, word32 GxSz, const byte* Gy, word32 GySz, int cofactor); 411 503 504 WOLFSSL_API 505 int wc_ecc_get_curve_id_from_oid(const byte* oid, word32 len); 506 507 WOLFSSL_API 508 ecc_point* wc_ecc_new_point(void); 509 WOLFSSL_API 510 ecc_point* wc_ecc_new_point_h(void* h); 511 WOLFSSL_API 512 void wc_ecc_del_point(ecc_point* p); 513 WOLFSSL_API 514 void wc_ecc_del_point_h(ecc_point* p, void* h); 515 WOLFSSL_API 516 int wc_ecc_copy_point(ecc_point* p, ecc_point *r); 517 WOLFSSL_API 518 int wc_ecc_cmp_point(ecc_point* a, ecc_point *b); 519 WOLFSSL_API 520 int wc_ecc_point_is_at_infinity(ecc_point *p); 521 412 522 #ifndef WOLFSSL_ATECC508A 413 414 WOLFSSL_API415 ecc_point* wc_ecc_new_point(void);416 WOLFSSL_API417 ecc_point* wc_ecc_new_point_h(void* h);418 WOLFSSL_API419 void wc_ecc_del_point(ecc_point* p);420 WOLFSSL_API421 void wc_ecc_del_point_h(ecc_point* p, void* h);422 WOLFSSL_API423 int wc_ecc_copy_point(ecc_point* p, ecc_point *r);424 WOLFSSL_API425 int wc_ecc_cmp_point(ecc_point* a, ecc_point *b);426 WOLFSSL_API427 int wc_ecc_point_is_at_infinity(ecc_point *p);428 523 WOLFSSL_API 429 524 int wc_ecc_mulmod(mp_int* k, ecc_point *G, ecc_point *R, … … 459 554 int wc_ecc_rs_to_sig(const char* r, const char* s, byte* out, word32* outlen); 460 555 WOLFSSL_API 556 int wc_ecc_rs_raw_to_sig(const byte* r, word32 rSz, const byte* s, word32 sSz, 557 byte* out, word32* outlen); 558 WOLFSSL_API 461 559 int wc_ecc_sig_to_rs(const byte* sig, word32 sigLen, byte* r, word32* rLen, 462 560 byte* s, word32* sLen); … … 467 565 int wc_ecc_import_raw_ex(ecc_key* key, const char* qx, const char* qy, 468 566 const char* d, int curve_id); 567 WOLFSSL_API 568 int wc_ecc_import_unsigned(ecc_key* key, byte* qx, byte* qy, 569 byte* d, int curve_id); 469 570 #endif /* HAVE_ECC_KEY_IMPORT */ 470 571 471 572 #ifdef HAVE_ECC_KEY_EXPORT 573 WOLFSSL_API 574 int wc_ecc_export_ex(ecc_key* key, byte* qx, word32* qxLen, 575 byte* qy, word32* qyLen, byte* d, word32* dLen, 576 int encType); 472 577 WOLFSSL_API 473 578 int wc_ecc_export_private_only(ecc_key* key, byte* out, word32* outLen); … … 497 602 WOLFSSL_API 498 603 int wc_ecc_size(ecc_key* key); 604 WOLFSSL_API 605 int wc_ecc_sig_size_calc(int sz); 499 606 WOLFSSL_API 500 607 int wc_ecc_sig_size(ecc_key* key); -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/ed25519.h
r352 r372 19 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA 20 20 */ 21 22 /*! 23 \file wolfssl/wolfcrypt/ed25519.h 24 */ 21 25 22 26 … … 74 78 byte pointY[ED25519_KEY_SIZE]; /* Y coordinate is the public key with The most significant bit of the final octet always zero. */ 75 79 #endif 80 word16 pubKeySet:1; 76 81 #ifdef WOLFSSL_ASYNC_CRYPT 77 82 WC_ASYNC_DEV asyncDev; -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/error-crypt.h
r352 r372 20 20 */ 21 21 22 22 /*! 23 \file wolfssl/wolfcrypt/error-crypt.h 24 */ 23 25 24 26 #ifndef WOLF_CRYPT_ERROR_H … … 98 100 ASN_NTRU_KEY_E = -159, /* ASN ntru key decode error, invalid input */ 99 101 ASN_CRIT_EXT_E = -160, /* ASN unsupported critical extension */ 102 ASN_ALT_NAME_E = -161, /* ASN alternate name error */ 103 ASN_NO_PEM_HEADER = -162, /* ASN no PEM header found */ 100 104 101 105 ECC_BAD_ARG_E = -170, /* ECC input argument of wrong type */ … … 192 196 ECC_PRIVATEONLY_E = -246, /* Invalid use of private only ECC key*/ 193 197 EXTKEYUSAGE_E = -247, /* Bad Extended Key Usage value */ 194 195 WC_LAST_E = -247, /* Update this to indicate last error */ 198 WC_HW_E = -248, /* Error with hardware crypto use */ 199 WC_HW_WAIT_E = -249, /* Hardware waiting on resource */ 200 201 PSS_SALTLEN_E = -250, /* PSS length of salt is to long for hash */ 202 PRIME_GEN_E = -251, /* Failure finding a prime. */ 203 BER_INDEF_E = -252, /* Cannot decode indefinite length BER. */ 204 RSA_OUT_OF_RANGE_E = -253, /* Ciphertext to decrypt out of range. */ 205 RSAPSS_PAT_FIPS_E = -254, /* RSA-PSS PAT failure */ 206 ECDSA_PAT_FIPS_E = -255, /* ECDSA PAT failure */ 207 DH_KAT_FIPS_E = -256, /* DH KAT failure */ 208 AESCCM_KAT_FIPS_E = -257, /* AESCCM KAT failure */ 209 SHA3_KAT_FIPS_E = -258, /* SHA-3 KAT failure */ 210 ECDHE_KAT_FIPS_E = -259, /* ECDHE KAT failure */ 211 AES_GCM_OVERFLOW_E = -260, /* AES-GCM invocation counter overflow. */ 212 AES_CCM_OVERFLOW_E = -261, /* AES-CCM invocation counter overflow. */ 213 RSA_KEY_PAIR_E = -262, /* RSA Key Pair-Wise Consistency check fail. */ 214 DH_CHECK_PRIV_E = -263, /* DH Check Priv Key error */ 215 216 WC_AFALG_SOCK_E = -264, /* AF_ALG socket error */ 217 WC_DEVCRYPTO_E = -265, /* /dev/crypto error */ 218 219 ZLIB_INIT_ERROR = -266, /* zlib init error */ 220 ZLIB_COMPRESS_ERROR = -267, /* zlib compression error */ 221 ZLIB_DECOMPRESS_ERROR = -268, /* zlib decompression error */ 222 223 PKCS7_NO_SIGNER_E = -269, /* No signer in PKCS#7 signed data msg */ 224 WC_PKCS7_WANT_READ_E= -270, /* PKCS7 operations wants more input */ 225 226 WC_LAST_E = -270, /* Update this to indicate last error */ 196 227 MIN_CODE_E = -300 /* errors -101 - -299 */ 197 228 … … 201 232 202 233 234 #ifdef NO_ERROR_STRINGS 235 #define wc_GetErrorString(error) "no support for error strings built in" 236 #define wc_ErrorString(err, buf) \ 237 (void)err; XSTRNCPY((buf), wc_GetErrorString((err)), \ 238 WOLFSSL_MAX_ERROR_SZ); 239 240 #else 203 241 WOLFSSL_API void wc_ErrorString(int err, char* buff); 204 242 WOLFSSL_API const char* wc_GetErrorString(int error); 205 243 #endif 206 244 207 245 #ifdef __cplusplus -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/hash.h
r352 r372 20 20 */ 21 21 22 /*! 23 \file wolfssl/wolfcrypt/hash.h 24 */ 22 25 23 26 #ifndef WOLF_CRYPT_HASH_H … … 38 41 #include <wolfssl/wolfcrypt/sha512.h> 39 42 #endif 43 #ifdef HAVE_BLAKE2 44 #include <wolfssl/wolfcrypt/blake2.h> 45 #endif 46 #ifdef WOLFSSL_SHA3 47 #include <wolfssl/wolfcrypt/sha3.h> 48 #endif 49 #ifndef NO_MD4 50 #include <wolfssl/wolfcrypt/md4.h> 51 #endif 52 #ifdef WOLFSSL_MD2 53 #include <wolfssl/wolfcrypt/md2.h> 54 #endif 55 40 56 41 57 #ifdef __cplusplus … … 43 59 #endif 44 60 45 /* Hash types */ 46 enum wc_HashType { 47 WC_HASH_TYPE_NONE = 0, 48 WC_HASH_TYPE_MD2 = 1, 49 WC_HASH_TYPE_MD4 = 2, 50 WC_HASH_TYPE_MD5 = 3, 51 WC_HASH_TYPE_SHA = 4, /* SHA-1 (not old SHA-0) */ 52 WC_HASH_TYPE_SHA224 = 9, 53 WC_HASH_TYPE_SHA256 = 5, 54 WC_HASH_TYPE_SHA384 = 6, 55 WC_HASH_TYPE_SHA512 = 7, 56 WC_HASH_TYPE_MD5_SHA = 8, 57 }; 61 #if !defined(HAVE_FIPS) && !defined(NO_OLD_WC_NAMES) 62 #define MAX_DIGEST_SIZE WC_MAX_DIGEST_SIZE 63 #endif 64 58 65 59 66 typedef union { … … 80 87 /* Find largest possible digest size 81 88 Note if this gets up to the size of 80 or over check smallstack build */ 82 #if defined(WOLFSSL_SHA512) 89 #if defined(WOLFSSL_SHA3) 90 #define WC_MAX_DIGEST_SIZE WC_SHA3_512_DIGEST_SIZE 91 #define WC_MAX_BLOCK_SIZE WC_SHA3_224_BLOCK_SIZE /* 224 is the largest block size */ 92 #elif defined(WOLFSSL_SHA512) 83 93 #define WC_MAX_DIGEST_SIZE WC_SHA512_DIGEST_SIZE 94 #define WC_MAX_BLOCK_SIZE WC_SHA512_BLOCK_SIZE 95 #elif defined(HAVE_BLAKE2) 96 #define WC_MAX_DIGEST_SIZE BLAKE2B_OUTBYTES 97 #define WC_MAX_BLOCK_SIZE BLAKE2B_BLOCKBYTES 84 98 #elif defined(WOLFSSL_SHA384) 85 99 #define WC_MAX_DIGEST_SIZE WC_SHA384_DIGEST_SIZE 100 #define WC_MAX_BLOCK_SIZE WC_SHA384_BLOCK_SIZE 86 101 #elif !defined(NO_SHA256) 87 102 #define WC_MAX_DIGEST_SIZE WC_SHA256_DIGEST_SIZE 103 #define WC_MAX_BLOCK_SIZE WC_SHA256_BLOCK_SIZE 88 104 #elif defined(WOLFSSL_SHA224) 89 105 #define WC_MAX_DIGEST_SIZE WC_SHA224_DIGEST_SIZE 106 #define WC_MAX_BLOCK_SIZE WC_SHA224_BLOCK_SIZE 90 107 #elif !defined(NO_SHA) 91 108 #define WC_MAX_DIGEST_SIZE WC_SHA_DIGEST_SIZE 109 #define WC_MAX_BLOCK_SIZE WC_SHA_BLOCK_SIZE 92 110 #elif !defined(NO_MD5) 93 111 #define WC_MAX_DIGEST_SIZE WC_MD5_DIGEST_SIZE 112 #define WC_MAX_BLOCK_SIZE WC_MD5_BLOCK_SIZE 94 113 #else 95 114 #define WC_MAX_DIGEST_SIZE 64 /* default to max size of 64 */ 115 #define WC_MAX_BLOCK_SIZE 128 96 116 #endif 97 117 98 118 #if !defined(NO_ASN) || !defined(NO_DH) || defined(HAVE_ECC) 99 119 WOLFSSL_API int wc_HashGetOID(enum wc_HashType hash_type); 120 WOLFSSL_API enum wc_HashType wc_OidGetHash(int oid); 100 121 #endif 101 122 123 WOLFSSL_API enum wc_HashType wc_HashTypeConvert(int hashType); 124 102 125 WOLFSSL_API int wc_HashGetDigestSize(enum wc_HashType hash_type); 126 WOLFSSL_API int wc_HashGetBlockSize(enum wc_HashType hash_type); 103 127 WOLFSSL_API int wc_Hash(enum wc_HashType hash_type, 104 128 const byte* data, word32 data_len, … … 111 135 WOLFSSL_API int wc_HashFinal(wc_HashAlg* hash, enum wc_HashType type, 112 136 byte* out); 113 137 WOLFSSL_API int wc_HashFree(wc_HashAlg* hash, enum wc_HashType type); 114 138 115 139 #ifndef NO_MD5 … … 123 147 #endif 124 148 149 #ifdef WOLFSSL_SHA224 150 #include <wolfssl/wolfcrypt/sha256.h> 151 WOLFSSL_API int wc_Sha224Hash(const byte*, word32, byte*); 152 #endif /* defined(WOLFSSL_SHA224) */ 153 125 154 #ifndef NO_SHA256 126 155 #include <wolfssl/wolfcrypt/sha256.h> 127 156 WOLFSSL_API int wc_Sha256Hash(const byte*, word32, byte*); 157 #endif 128 158 129 #if defined(WOLFSSL_SHA224) 130 WOLFSSL_API int wc_Sha224Hash(const byte*, word32, byte*); 131 #endif /* defined(WOLFSSL_SHA224) */132 #endif 159 #ifdef WOLFSSL_SHA384 160 #include <wolfssl/wolfcrypt/sha512.h> 161 WOLFSSL_API int wc_Sha384Hash(const byte*, word32, byte*); 162 #endif /* defined(WOLFSSL_SHA384) */ 133 163 134 164 #ifdef WOLFSSL_SHA512 135 165 #include <wolfssl/wolfcrypt/sha512.h> 136 166 WOLFSSL_API int wc_Sha512Hash(const byte*, word32, byte*); 137 138 #if defined(WOLFSSL_SHA384)139 WOLFSSL_API int wc_Sha384Hash(const byte*, word32, byte*);140 #endif /* defined(WOLFSSL_SHA384) */141 167 #endif /* WOLFSSL_SHA512 */ 142 168 -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/hc128.h
r352 r372 20 20 */ 21 21 22 /*! 23 \file wolfssl/wolfcrypt/hc128.h 24 */ 25 22 26 23 27 #ifndef WOLF_CRYPT_HC128_H … … 33 37 34 38 enum { 35 HC128_ENC_TYPE = 6/* cipher unique type */39 HC128_ENC_TYPE = WC_CIPHER_HC128, /* cipher unique type */ 36 40 }; 37 41 -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/hmac.h
r352 r372 20 20 */ 21 21 22 22 /*! 23 \file wolfssl/wolfcrypt/hmac.h 24 */ 23 25 24 26 #ifndef NO_HMAC … … 27 29 #define WOLF_CRYPT_HMAC_H 28 30 29 #include <wolfssl/wolfcrypt/ types.h>31 #include <wolfssl/wolfcrypt/hash.h> 30 32 31 #ifndef NO_MD5 32 #include <wolfssl/wolfcrypt/md5.h> 33 #if defined(HAVE_FIPS) && \ 34 (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2)) 35 /* for fips @wc_fips */ 36 #include <cyassl/ctaocrypt/hmac.h> 37 #define WC_HMAC_BLOCK_SIZE HMAC_BLOCK_SIZE 33 38 #endif 34 39 35 #ifndef NO_SHA 36 #include <wolfssl/wolfcrypt/sha.h> 40 41 #if defined(HAVE_FIPS) && \ 42 defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2) 43 #include <wolfssl/wolfcrypt/fips.h> 37 44 #endif 38 39 #if !defined(NO_SHA256) || defined(WOLFSSL_SHA224)40 #include <wolfssl/wolfcrypt/sha256.h>41 #endif42 43 #ifdef WOLFSSL_SHA51244 #include <wolfssl/wolfcrypt/sha512.h>45 #endif46 47 #ifdef HAVE_BLAKE248 #include <wolfssl/wolfcrypt/blake2.h>49 #endif50 51 #ifdef HAVE_FIPS52 /* for fips */53 #include <cyassl/ctaocrypt/hmac.h>54 #endif55 56 45 57 46 #ifdef __cplusplus 58 47 extern "C" { 59 48 #endif 60 #ifndef HAVE_FIPS 49 50 /* avoid redefinition of structs */ 51 #if !defined(HAVE_FIPS) || \ 52 (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)) 61 53 62 54 #ifdef WOLFSSL_ASYNC_CRYPT 63 55 #include <wolfssl/wolfcrypt/async.h> 56 #endif 57 58 #ifndef NO_OLD_WC_NAMES 59 #define HMAC_BLOCK_SIZE WC_HMAC_BLOCK_SIZE 64 60 #endif 65 61 … … 72 68 /* If any hash is not enabled, add the ID here. */ 73 69 #ifdef NO_MD5 74 WC_MD5 = 0,70 WC_MD5 = WC_HASH_TYPE_MD5, 75 71 #endif 76 72 #ifdef NO_SHA 77 WC_SHA = 1,73 WC_SHA = WC_HASH_TYPE_SHA, 78 74 #endif 79 75 #ifdef NO_SHA256 80 WC_SHA256 = 2,76 WC_SHA256 = WC_HASH_TYPE_SHA256, 81 77 #endif 82 78 #ifndef WOLFSSL_SHA512 83 WC_SHA512 = 4,79 WC_SHA512 = WC_HASH_TYPE_SHA512, 84 80 #endif 85 81 #ifndef WOLFSSL_SHA384 86 WC_SHA384 = 5,82 WC_SHA384 = WC_HASH_TYPE_SHA384, 87 83 #endif 88 84 #ifndef HAVE_BLAKE2 89 BLAKE2B_ID = 7,85 BLAKE2B_ID = WC_HASH_TYPE_BLAKE2B, 90 86 #endif 91 87 #ifndef WOLFSSL_SHA224 92 WC_SHA224 = 8,88 WC_SHA224 = WC_HASH_TYPE_SHA224, 93 89 #endif 94 90 #ifndef WOLFSSL_SHA3 91 WC_SHA3_224 = WC_HASH_TYPE_SHA3_224, 92 WC_SHA3_256 = WC_HASH_TYPE_SHA3_256, 93 WC_SHA3_384 = WC_HASH_TYPE_SHA3_384, 94 WC_SHA3_512 = WC_HASH_TYPE_SHA3_512, 95 #endif 96 }; 95 97 96 98 /* Select the largest available hash for the buffer size. */ 97 #if defined(WOLFSSL_SHA512) 98 MAX_DIGEST_SIZE = WC_SHA512_DIGEST_SIZE, 99 HMAC_BLOCK_SIZE = WC_SHA512_BLOCK_SIZE, 100 #elif defined(HAVE_BLAKE2) 101 MAX_DIGEST_SIZE = BLAKE2B_OUTBYTES, 102 HMAC_BLOCK_SIZE = BLAKE2B_BLOCKBYTES, 103 #elif defined(WOLFSSL_SHA384) 104 MAX_DIGEST_SIZE = WC_SHA384_DIGEST_SIZE, 105 HMAC_BLOCK_SIZE = WC_SHA384_BLOCK_SIZE 106 #elif !defined(NO_SHA256) 107 MAX_DIGEST_SIZE = WC_SHA256_DIGEST_SIZE, 108 HMAC_BLOCK_SIZE = WC_SHA256_BLOCK_SIZE 109 #elif defined(WOLFSSL_SHA224) 110 MAX_DIGEST_SIZE = WC_SHA224_DIGEST_SIZE, 111 HMAC_BLOCK_SIZE = WC_SHA224_BLOCK_SIZE 112 #elif !defined(NO_SHA) 113 MAX_DIGEST_SIZE = WC_SHA_DIGEST_SIZE, 114 HMAC_BLOCK_SIZE = WC_SHA_BLOCK_SIZE, 115 #elif !defined(NO_MD5) 116 MAX_DIGEST_SIZE = WC_MD5_DIGEST_SIZE, 117 HMAC_BLOCK_SIZE = WC_MD5_BLOCK_SIZE, 118 #else 99 #define WC_HMAC_BLOCK_SIZE WC_MAX_BLOCK_SIZE 100 101 #if !defined(WOLFSSL_SHA3) && !defined(WOLFSSL_SHA512) && !defined(HAVE_BLAKE2) && \ 102 !defined(WOLFSSL_SHA384) && defined(NO_SHA256) && defined(WOLFSSL_SHA224) && \ 103 defined(NO_SHA) && defined(NO_MD5) 119 104 #error "You have to have some kind of hash if you want to use HMAC." 120 105 #endif 121 };122 106 123 107 … … 136 120 wc_Sha256 sha256; 137 121 #endif 138 #ifdef WOLFSSL_SHA512139 122 #ifdef WOLFSSL_SHA384 140 123 wc_Sha384 sha384; 141 124 #endif 125 #ifdef WOLFSSL_SHA512 142 126 wc_Sha512 sha512; 143 127 #endif 144 128 #ifdef HAVE_BLAKE2 145 129 Blake2b blake2b; 130 #endif 131 #ifdef WOLFSSL_SHA3 132 wc_Sha3 sha3; 146 133 #endif 147 134 } Hash; … … 150 137 typedef struct Hmac { 151 138 Hash hash; 152 word32 ipad[ HMAC_BLOCK_SIZE / sizeof(word32)]; /* same block size all*/153 word32 opad[ HMAC_BLOCK_SIZE / sizeof(word32)];154 word32 innerHash[ MAX_DIGEST_SIZE / sizeof(word32)];139 word32 ipad[WC_HMAC_BLOCK_SIZE / sizeof(word32)]; /* same block size all*/ 140 word32 opad[WC_HMAC_BLOCK_SIZE / sizeof(word32)]; 141 word32 innerHash[WC_MAX_DIGEST_SIZE / sizeof(word32)]; 155 142 void* heap; /* heap hint */ 156 143 byte macType; /* md5 sha or sha256 */ … … 160 147 WC_ASYNC_DEV asyncDev; 161 148 word16 keyLen; /* hmac key length (key in ipad) */ 162 #ifdef HAVE_CAVIUM163 byte* data; /* buffered input data for one call */164 word16 dataLen;165 #endif /* HAVE_CAVIUM */166 149 #endif /* WOLFSSL_ASYNC_CRYPT */ 167 150 } Hmac; … … 179 162 180 163 WOLFSSL_API int wolfSSL_GetHmacMaxSize(void); 164 165 WOLFSSL_LOCAL int _InitHmac(Hmac* hmac, int type, void* heap); 181 166 182 167 #ifdef HAVE_HKDF -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/idea.h
r352 r372 20 20 */ 21 21 22 /*! 23 \file wolfssl/wolfcrypt/idea.h 24 */ 22 25 23 26 #ifndef WOLF_CRYPT_IDEA_H -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/integer.h
r352 r372 34 34 */ 35 35 #include <wolfssl/wolfcrypt/types.h> /* will set MP_xxBIT if not default */ 36 #ifdef USE_FAST_MATH 36 #ifdef WOLFSSL_SP_MATH 37 #include <wolfssl/wolfcrypt/sp_int.h> 38 #elif defined(USE_FAST_MATH) 37 39 #include <wolfssl/wolfcrypt/tfm.h> 38 40 #else … … 68 70 69 71 /* C++ compilers don't like assigning void * to mp_digit * */ 72 #define OPT_CAST(x) (x *) 73 74 #elif defined(_SH3) 75 76 /* SuperH SH3 compiler doesn't like assigning voi* to mp_digit* */ 70 77 #define OPT_CAST(x) (x *) 71 78 … … 249 256 #define mp_tomag(mp, str) mp_to_unsigned_bin((mp), (str)) 250 257 251 #define mp_tobinary(M, S) mp_toradix((M), (S), 2) 252 #define mp_tooctal(M, S) mp_toradix((M), (S), 8) 253 #define mp_todecimal(M, S) mp_toradix((M), (S), 10) 254 #define mp_tohex(M, S) mp_toradix((M), (S), 16) 258 #define MP_RADIX_BIN 2 259 #define MP_RADIX_OCT 8 260 #define MP_RADIX_DEC 10 261 #define MP_RADIX_HEX 16 262 #define MP_RADIX_MAX 64 263 264 #define mp_tobinary(M, S) mp_toradix((M), (S), MP_RADIX_BIN) 265 #define mp_tooctal(M, S) mp_toradix((M), (S), MP_RADIX_OCT) 266 #define mp_todecimal(M, S) mp_toradix((M), (S), MP_RADIX_DEC) 267 #define mp_tohex(M, S) mp_toradix((M), (S), MP_RADIX_HEX) 255 268 256 269 #define s_mp_mul(a, b, c) s_mp_mul_digs(a, b, c, (a)->used + (b)->used + 1) 257 270 271 #if defined(HAVE_ECC) || defined(WOLFSSL_KEY_GEN) || defined(HAVE_COMP_KEY) || \ 272 defined(WOLFSSL_DEBUG_MATH) || defined(DEBUG_WOLFSSL) 258 273 extern const char *mp_s_rmap; 274 #endif 259 275 260 276 /* 6 functions needed by Rsa */ … … 267 283 MP_API int mp_to_unsigned_bin_at_pos(int x, mp_int *t, unsigned char *b); 268 284 MP_API int mp_to_unsigned_bin (mp_int * a, unsigned char *b); 285 MP_API int mp_to_unsigned_bin_len(mp_int * a, unsigned char *b, int c); 269 286 MP_API int mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y); 270 287 /* end functions needed by Rsa */ … … 353 370 #endif 354 371 355 #if defined(HAVE_ECC) || defined(WOLFSSL_KEY_GEN) 372 #if defined(HAVE_ECC) || defined(WOLFSSL_KEY_GEN) || !defined(NO_RSA) || \ 373 !defined(NO_DSA) || !defined(NO_DH) 356 374 MP_API int mp_sqrmod(mp_int* a, mp_int* b, mp_int* c); 357 375 #endif 358 #if defined(HAVE_ECC) || defined(WOLFSSL_KEY_GEN)376 #if !defined(NO_DSA) || defined(HAVE_ECC) 359 377 MP_API int mp_read_radix(mp_int* a, const char* str, int radix); 360 378 #endif 361 379 380 #if defined(WOLFSSL_KEY_GEN) || !defined(NO_RSA) || !defined(NO_DSA) || !defined(NO_DH) 381 MP_API int mp_prime_is_prime (mp_int * a, int t, int *result); 382 MP_API int mp_prime_is_prime_ex (mp_int * a, int t, int *result, WC_RNG*); 383 #endif /* WOLFSSL_KEY_GEN NO_RSA NO_DSA NO_DH */ 362 384 #ifdef WOLFSSL_KEY_GEN 363 MP_API int mp_prime_is_prime (mp_int * a, int t, int *result);364 385 MP_API int mp_gcd (mp_int * a, mp_int * b, mp_int * c); 365 386 MP_API int mp_lcm (mp_int * a, mp_int * b, mp_int * c); -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/logging.h
r352 r372 20 20 */ 21 21 22 /*! 23 \file wolfssl/wolfcrypt/logging.h 24 */ 25 22 26 23 27 /* submitted by eof */ … … 34 38 35 39 36 enum CYA_Log_Levels {40 enum wc_LogLevels { 37 41 ERROR_LOG = 0, 38 42 INFO_LOG, … … 42 46 }; 43 47 48 #ifdef WOLFSSL_FUNC_TIME 49 /* WARNING: This code is only to be used for debugging performance. 50 * The code is not thread-safe. 51 * Do not use WOLFSSL_FUNC_TIME in production code. 52 */ 53 enum wc_FuncNum { 54 WC_FUNC_HELLO_REQUEST_SEND = 0, 55 WC_FUNC_HELLO_REQUEST_DO, 56 WC_FUNC_CLIENT_HELLO_SEND, 57 WC_FUNC_CLIENT_HELLO_DO, 58 WC_FUNC_SERVER_HELLO_SEND, 59 WC_FUNC_SERVER_HELLO_DO, 60 WC_FUNC_ENCRYPTED_EXTENSIONS_SEND, 61 WC_FUNC_ENCRYPTED_EXTENSIONS_DO, 62 WC_FUNC_CERTIFICATE_REQUEST_SEND, 63 WC_FUNC_CERTIFICATE_REQUEST_DO, 64 WC_FUNC_CERTIFICATE_SEND, 65 WC_FUNC_CERTIFICATE_DO, 66 WC_FUNC_CERTIFICATE_VERIFY_SEND, 67 WC_FUNC_CERTIFICATE_VERIFY_DO, 68 WC_FUNC_FINISHED_SEND, 69 WC_FUNC_FINISHED_DO, 70 WC_FUNC_KEY_UPDATE_SEND, 71 WC_FUNC_KEY_UPDATE_DO, 72 WC_FUNC_EARLY_DATA_SEND, 73 WC_FUNC_EARLY_DATA_DO, 74 WC_FUNC_NEW_SESSION_TICKET_SEND, 75 WC_FUNC_NEW_SESSION_TICKET_DO, 76 WC_FUNC_SERVER_HELLO_DONE_SEND, 77 WC_FUNC_SERVER_HELLO_DONE_DO, 78 WC_FUNC_TICKET_SEND, 79 WC_FUNC_TICKET_DO, 80 WC_FUNC_CLIENT_KEY_EXCHANGE_SEND, 81 WC_FUNC_CLIENT_KEY_EXCHANGE_DO, 82 WC_FUNC_CERTIFICATE_STATUS_SEND, 83 WC_FUNC_CERTIFICATE_STATUS_DO, 84 WC_FUNC_SERVER_KEY_EXCHANGE_SEND, 85 WC_FUNC_SERVER_KEY_EXCHANGE_DO, 86 WC_FUNC_END_OF_EARLY_DATA_SEND, 87 WC_FUNC_END_OF_EARLY_DATA_DO, 88 WC_FUNC_COUNT 89 }; 90 #endif 91 44 92 typedef void (*wolfSSL_Logging_cb)(const int logLevel, 45 93 const char *const logMessage); 46 94 47 95 WOLFSSL_API int wolfSSL_SetLoggingCb(wolfSSL_Logging_cb log_function); 96 97 /* turn logging on, only if compiled in */ 98 WOLFSSL_API int wolfSSL_Debugging_ON(void); 99 /* turn logging off */ 100 WOLFSSL_API void wolfSSL_Debugging_OFF(void); 101 48 102 49 103 #if defined(OPENSSL_EXTRA) || defined(DEBUG_WOLFSSL_VERBOSE) … … 56 110 WOLFSSL_LOCAL void wc_RemoveErrorNode(int index); 57 111 WOLFSSL_LOCAL void wc_ClearErrorNodes(void); 112 WOLFSSL_LOCAL int wc_PullErrorNode(const char **file, const char **reason, 113 int *line); 58 114 WOLFSSL_API int wc_SetLoggingHeap(void* h); 115 WOLFSSL_API int wc_ERR_remove_state(void); 59 116 #if !defined(NO_FILESYSTEM) && !defined(NO_STDIO_FILESYSTEM) 60 WOLFSSL_API void wc_ERR_print_errors_fp( FILE*fp);117 WOLFSSL_API void wc_ERR_print_errors_fp(XFILE fp); 61 118 #endif 62 #endif /* defined(OPENSSL_EXTRA) || defined(DEBUG_WOLFSSL_VERBOSE)*/119 #endif /* OPENSSL_EXTRA || DEBUG_WOLFSSL_VERBOSE */ 63 120 64 #ifdef DEBUG_WOLFSSL 121 #ifdef WOLFSSL_FUNC_TIME 122 /* WARNING: This code is only to be used for debugging performance. 123 * The code is not thread-safe. 124 * Do not use WOLFSSL_FUNC_TIME in production code. 125 */ 126 WOLFSSL_API void WOLFSSL_START(int funcNum); 127 WOLFSSL_API void WOLFSSL_END(int funcNum); 128 WOLFSSL_API void WOLFSSL_TIME(int count); 129 #else 130 #define WOLFSSL_START(n) 131 #define WOLFSSL_END(n) 132 #define WOLFSSL_TIME(n) 133 #endif 134 135 #if defined(DEBUG_WOLFSSL) && !defined(WOLFSSL_DEBUG_ERRORS_ONLY) 65 136 #if defined(_WIN32) 66 137 #if defined(INTIME_RTOS) … … 74 145 #define WOLFSSL_LOG_CAT(a, m, b) #a " " m " " #b 75 146 76 void WOLFSSL_ENTER(const char* msg);77 void WOLFSSL_LEAVE(const char* msg, int ret);147 WOLFSSL_API void WOLFSSL_ENTER(const char* msg); 148 WOLFSSL_API void WOLFSSL_LEAVE(const char* msg, int ret); 78 149 #define WOLFSSL_STUB(m) \ 79 150 WOLFSSL_MSG(WOLFSSL_LOG_CAT(wolfSSL Stub, m, not implemented)) 80 151 81 void WOLFSSL_MSG(const char* msg);82 void WOLFSSL_BUFFER(const byte* buffer, word32 length);152 WOLFSSL_API void WOLFSSL_MSG(const char* msg); 153 WOLFSSL_API void WOLFSSL_BUFFER(const byte* buffer, word32 length); 83 154 84 #else /* DEBUG_WOLFSSL */155 #else 85 156 86 157 #define WOLFSSL_ENTER(m) … … 91 162 #define WOLFSSL_BUFFER(b, l) 92 163 93 #endif /* DEBUG_WOLFSSL */164 #endif /* DEBUG_WOLFSSL && !WOLFSSL_DEBUG_ERRORS_ONLY */ 94 165 95 #if (defined(DEBUG_WOLFSSL) || defined(WOLFSSL_NGINX)) || defined(WOLFSSL_HAPROXY) 96 #if (defined(OPENSSL_EXTRA) || defined(DEBUG_WOLFSSL_VERBOSE)) 97 void WOLFSSL_ERROR_LINE(int err, const char* func, unsigned int line, 166 #if defined(DEBUG_WOLFSSL) || defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY) 167 168 #if defined(OPENSSL_EXTRA) || defined(DEBUG_WOLFSSL_VERBOSE) 169 WOLFSSL_API void WOLFSSL_ERROR_LINE(int err, const char* func, unsigned int line, 98 170 const char* file, void* ctx); 99 #define WOLFSSL_ERROR(x) WOLFSSL_ERROR_LINE((x), __func__, __LINE__, __FILE__,NULL) 171 #define WOLFSSL_ERROR(x) \ 172 WOLFSSL_ERROR_LINE((x), __func__, __LINE__, __FILE__, NULL) 100 173 #else 101 void WOLFSSL_ERROR(int);174 WOLFSSL_API void WOLFSSL_ERROR(int err); 102 175 #endif 176 WOLFSSL_API void WOLFSSL_ERROR_MSG(const char* msg); 177 103 178 #else 104 179 #define WOLFSSL_ERROR(e) 180 #define WOLFSSL_ERROR_MSG(m) 105 181 #endif 106 182 -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/md2.h
r352 r372 20 20 */ 21 21 22 /*! 23 \file wolfssl/wolfcrypt/md2.h 24 */ 25 22 26 23 27 #ifndef WOLF_CRYPT_MD2_H … … 34 38 /* in bytes */ 35 39 enum { 36 MD2 = 6, /* hash type unique */40 MD2 = WC_HASH_TYPE_MD2, 37 41 MD2_BLOCK_SIZE = 16, 38 42 MD2_DIGEST_SIZE = 16, -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/md4.h
r352 r372 20 20 */ 21 21 22 /*! 23 \file wolfssl/wolfcrypt/md4.h 24 */ 22 25 23 26 #ifndef WOLF_CRYPT_MD4_H … … 34 37 /* in bytes */ 35 38 enum { 39 MD4 = WC_HASH_TYPE_MD4, 36 40 MD4_BLOCK_SIZE = 64, 37 41 MD4_DIGEST_SIZE = 16, -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/md5.h
r352 r372 19 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA 20 20 */ 21 22 /*! 23 \file wolfssl/wolfcrypt/md5.h 24 */ 21 25 22 26 … … 49 53 /* in bytes */ 50 54 enum { 51 WC_MD5 = 0, /* hash type unique */55 WC_MD5 = WC_HASH_TYPE_MD5, 52 56 WC_MD5_BLOCK_SIZE = 64, 53 57 WC_MD5_DIGEST_SIZE = 16, … … 55 59 }; 56 60 61 57 62 #ifdef WOLFSSL_MICROCHIP_PIC32MZ 58 63 #include <wolfssl/wolfcrypt/port/pic32/pic32mz-crypt.h> 64 #endif 65 #ifdef STM32_HASH 66 #include <wolfssl/wolfcrypt/port/st/stm32.h> 59 67 #endif 60 68 #ifdef WOLFSSL_ASYNC_CRYPT … … 64 72 #ifdef WOLFSSL_TI_HASH 65 73 #include "wolfssl/wolfcrypt/port/ti/ti-hash.h" 74 #elif defined(WOLFSSL_IMX6_CAAM) 75 #include "wolfssl/wolfcrypt/port/caam/wolfcaam_sha.h" 66 76 #else 67 77 68 78 /* MD5 digest */ 69 79 typedef struct wc_Md5 { 80 #ifdef STM32_HASH 81 STM32_HASH_Context stmCtx; 82 #else 70 83 word32 buffLen; /* in bytes */ 71 84 word32 loLen; /* length in bytes */ … … 81 94 hashUpdCache cache; /* cache for updates */ 82 95 #endif 83 #if defined(STM32_HASH) && defined(WOLFSSL_STM32_CUBEMX) 84 HASH_HandleTypeDef hashHandle; 85 #endif 96 #endif /* STM32_HASH */ 86 97 #ifdef WOLFSSL_ASYNC_CRYPT 87 98 WC_ASYNC_DEV asyncDev; -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/memory.h
r352 r372 23 23 /* submitted by eof */ 24 24 25 /*! 26 \file wolfssl/wolfcrypt/memory.h 27 */ 25 28 26 29 #ifndef WOLFSSL_MEMORY_H … … 32 35 #ifdef __cplusplus 33 36 extern "C" { 37 #endif 38 39 #ifdef WOLFSSL_FORCE_MALLOC_FAIL_TEST 40 WOLFSSL_API void wolfSSL_SetMemFailCount(int memFailCount); 34 41 #endif 35 42 … … 75 82 wolfSSL_Free_cb, 76 83 wolfSSL_Realloc_cb); 77 78 84 WOLFSSL_API int wolfSSL_GetAllocators(wolfSSL_Malloc_cb*, 79 85 wolfSSL_Free_cb*, … … 89 95 #endif 90 96 #define WOLFMEM_DEF_BUCKETS 9 /* number of default memory blocks */ 97 #ifndef WOLFMEM_IO_SZ 91 98 #define WOLFMEM_IO_SZ 16992 /* 16 byte aligned */ 99 #endif 92 100 #ifndef WOLFMEM_BUCKETS 93 /* default size of chunks of memory to seperate into94 * having session certs enabled makes a 21k SSL struct */95 101 #ifndef SESSION_CERTS 102 /* default size of chunks of memory to separate into */ 96 103 #define WOLFMEM_BUCKETS 64,128,256,512,1024,2432,3456,4544,16128 104 #elif defined (WOLFSSL_CERT_EXT) 105 /* certificate extensions requires 24k for the SSL struct */ 106 #define WOLFMEM_BUCKETS 64,128,256,512,1024,2432,3456,4544,24576 97 107 #else 98 #define WOLFMEM_BUCKETS 64,128,256,512,1024,2432,3456,4544,21056 108 /* increase 23k for object member of WOLFSSL_X509_NAME_ENTRY */ 109 #define WOLFMEM_BUCKETS 64,128,256,512,1024,2432,3456,4544,23440 99 110 #endif 100 111 #endif 101 112 #ifndef WOLFMEM_DIST 102 #define WOLFMEM_DIST 8,4,4,12,4,5,8,1,1113 #define WOLFMEM_DIST 49,10,6,14,5,6,9,1,1 103 114 #endif 104 115 -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/misc.h
r352 r372 92 92 word32 btoi(byte b); 93 93 94 95 WOLFSSL_LOCAL byte ctMaskGT(int a, int b); 96 WOLFSSL_LOCAL byte ctMaskGTE(int a, int b); 97 WOLFSSL_LOCAL byte ctMaskLT(int a, int b); 98 WOLFSSL_LOCAL byte ctMaskLTE(int a, int b); 99 WOLFSSL_LOCAL byte ctMaskEq(int a, int b); 100 WOLFSSL_LOCAL byte ctMaskNotEq(int a, int b); 101 WOLFSSL_LOCAL byte ctMaskSel(byte m, byte a, byte b); 102 WOLFSSL_LOCAL int ctMaskSelInt(byte m, int a, int b); 103 WOLFSSL_LOCAL byte ctSetLTE(int a, int b); 104 94 105 #endif /* NO_INLINE */ 95 106 -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/pkcs12.h
r352 r372 40 40 } WC_DerCertList; 41 41 42 42 /* default values for creating PKCS12 */ 43 enum { 44 WC_PKCS12_ITT_DEFAULT = 2048, 45 WC_PKCS12_MAC_DEFAULT = 1, 46 }; 43 47 44 48 WOLFSSL_API WC_PKCS12* wc_PKCS12_new(void); … … 48 52 byte** pkey, word32* pkeySz, byte** cert, word32* certSz, 49 53 WC_DerCertList** ca); 54 WOLFSSL_API WC_PKCS12* wc_PKCS12_create(char* pass, word32 passSz, 55 char* name, byte* key, word32 keySz, byte* cert, word32 certSz, 56 WC_DerCertList* ca, int nidKey, int nidCert, int iter, int macIter, 57 int keyType, void* heap); 58 50 59 51 60 WOLFSSL_LOCAL int wc_PKCS12_SetHeap(WC_PKCS12* pkcs12, void* heap); 52 61 WOLFSSL_LOCAL void* wc_PKCS12_GetHeap(WC_PKCS12* pkcs12); 53 62 63 WOLFSSL_LOCAL void wc_FreeCertList(WC_DerCertList* list, void* heap); 54 64 55 65 #ifdef __cplusplus -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/pwdbased.h
r352 r372 20 20 */ 21 21 22 /*! 23 \file wolfssl/wolfcrypt/pwdbased.h 24 */ 22 25 23 26 #ifndef WOLF_CRYPT_PWDBASED_H … … 28 31 #ifndef NO_PWDBASED 29 32 30 #ifndef NO_MD531 #include <wolfssl/wolfcrypt/md5.h> /* for hash type */32 #endif33 34 #include <wolfssl/wolfcrypt/sha.h>35 33 36 34 #ifdef __cplusplus … … 42 40 * wolfssl/wolfcrypt/asn.h line 173 in enum Oid_Types 43 41 */ 42 WOLFSSL_API int wc_PBKDF1_ex(byte* key, int keyLen, byte* iv, int ivLen, 43 const byte* passwd, int passwdLen, 44 const byte* salt, int saltLen, int iterations, 45 int hashType, void* heap); 44 46 WOLFSSL_API int wc_PBKDF1(byte* output, const byte* passwd, int pLen, 45 47 const byte* salt, int sLen, int iterations, int kLen, … … 61 63 #endif 62 64 63 /* helper functions */64 WOLFSSL_LOCAL int GetDigestSize(int typeH);65 WOLFSSL_LOCAL int GetPKCS12HashSizes(int typeH, word32* v, word32* u);66 WOLFSSL_LOCAL int DoPKCS12Hash(int typeH, byte* buffer, word32 totalLen,67 byte* Ai, word32 u, int iterations);68 69 65 70 66 #ifdef __cplusplus -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/rabbit.h
r352 r372 19 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA 20 20 */ 21 22 /*! 23 \file wolfssl/wolfcrypt/rabbit.h 24 */ 21 25 22 26 -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/random.h
r352 r372 20 20 */ 21 21 22 /*! 23 \file wolfssl/wolfcrypt/random.h 24 */ 25 22 26 23 27 … … 27 31 #include <wolfssl/wolfcrypt/types.h> 28 32 29 #ifdef HAVE_FIPS 30 /* for fips @wc_fips */ 33 #if defined(HAVE_FIPS) && \ 34 defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2) 35 #include <wolfssl/wolfcrypt/fips.h> 36 #endif /* HAVE_FIPS_VERSION >= 2 */ 37 38 /* included for fips @wc_fips */ 39 #if defined(HAVE_FIPS) && \ 40 (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2)) 31 41 #include <cyassl/ctaocrypt/random.h> 32 42 #endif … … 58 68 /* make sure Hash DRBG is enabled, unless WC_NO_HASHDRBG is defined 59 69 or CUSTOM_RAND_GENERATE_BLOCK is defined*/ 60 #if !defined(WC_NO_HASHDRBG) ||!defined(CUSTOM_RAND_GENERATE_BLOCK)70 #if !defined(WC_NO_HASHDRBG) && !defined(CUSTOM_RAND_GENERATE_BLOCK) 61 71 #undef HAVE_HASHDRBG 62 72 #define HAVE_HASHDRBG … … 67 77 68 78 69 #ifndef HAVE_FIPS /* avoid redefining structs and macros */ 79 /* avoid redefinition of structs */ 80 #if !defined(HAVE_FIPS) || \ 81 (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)) 70 82 71 83 /* RNG supports the following sources (in order): … … 95 107 #elif defined(HAVE_WNR) 96 108 /* allow whitewood as direct RNG source using wc_GenerateSeed directly */ 97 #else 109 #elif defined(HAVE_INTEL_RDRAND) 110 /* Intel RDRAND or RDSEED */ 111 #elif !defined(WC_NO_RNG) 98 112 #error No RNG source defined! 99 113 #endif … … 131 145 typedef struct WC_RNG WC_RNG; 132 146 #define WC_RNG_TYPE_DEFINED 133 #endif134 135 #ifdef HAVE_HASHDRBG136 /* Private DRBG state */137 struct DRBG;138 147 #endif 139 148 … … 153 162 }; 154 163 155 #endif /* HAVE_FIPS*/164 #endif /* NO FIPS or have FIPS v2*/ 156 165 157 166 /* NO_OLD_RNGNAME removes RNG struct name to prevent possible type conflicts, … … 172 181 #endif /* HAVE_WNR */ 173 182 174 183 #ifndef WC_NO_RNG 175 184 WOLFSSL_API int wc_InitRng(WC_RNG*); 176 185 WOLFSSL_API int wc_InitRng_ex(WC_RNG* rng, void* heap, int devId); 186 WOLFSSL_API int wc_InitRngNonce(WC_RNG* rng, byte* nonce, word32 nonceSz); 187 WOLFSSL_API int wc_InitRngNonce_ex(WC_RNG* rng, byte* nonce, word32 nonceSz, 188 void* heap, int devId); 177 189 WOLFSSL_API int wc_RNG_GenerateBlock(WC_RNG*, byte*, word32 sz); 178 190 WOLFSSL_API int wc_RNG_GenerateByte(WC_RNG*, byte*); 179 191 WOLFSSL_API int wc_FreeRng(WC_RNG*); 192 #else 193 #include <wolfssl/wolfcrypt/error-crypt.h> 194 #define wc_InitRng(rng) NOT_COMPILED_IN 195 #define wc_InitRng_ex(rng, h, d) NOT_COMPILED_IN 196 #define wc_InitRngNonce(rng, n, s) NOT_COMPILED_IN 197 #define wc_InitRngNonce_ex(rng, n, s, h, d) NOT_COMPILED_IN 198 #define wc_RNG_GenerateBlock(rng, b, s) NOT_COMPILED_IN 199 #define wc_RNG_GenerateByte(rng, b) NOT_COMPILED_IN 200 #define wc_FreeRng(rng) (void)NOT_COMPILED_IN 201 #endif 202 180 203 181 204 182 205 #ifdef HAVE_HASHDRBG 206 WOLFSSL_LOCAL int wc_RNG_DRBG_Reseed(WC_RNG* rng, const byte* entropy, 207 word32 entropySz); 208 WOLFSSL_API int wc_RNG_TestSeed(const byte* seed, word32 seedSz); 183 209 WOLFSSL_API int wc_RNG_HealthTest(int reseed, 184 210 const byte* entropyA, word32 entropyASz, 185 211 const byte* entropyB, word32 entropyBSz, 186 212 byte* output, word32 outputSz); 213 WOLFSSL_API int wc_RNG_HealthTest_ex(int reseed, 214 const byte* nonce, word32 nonceSz, 215 const byte* entropyA, word32 entropyASz, 216 const byte* entropyB, word32 entropyBSz, 217 byte* output, word32 outputSz, 218 void* heap, int devId); 187 219 #endif /* HAVE_HASHDRBG */ 188 220 -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/ripemd.h
r352 r372 20 20 */ 21 21 22 /*! 23 \file wolfssl/wolfcrypt/ripemd.h 24 */ 22 25 23 26 #ifndef WOLF_CRYPT_RIPEMD_H -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/rsa.h
r352 r372 20 20 */ 21 21 22 /*! 23 \file wolfssl/wolfcrypt/rsa.h 24 */ 25 22 26 23 27 #ifndef WOLF_CRYPT_RSA_H … … 27 31 28 32 #ifndef NO_RSA 33 34 35 /* RSA default exponent */ 36 #ifndef WC_RSA_EXPONENT 37 #define WC_RSA_EXPONENT 65537L 38 #endif 39 40 #if defined(WC_RSA_NONBLOCK) 41 /* enable support for fast math based non-blocking exptmod */ 42 /* this splits the RSA function into many smaller operations */ 43 #ifndef USE_FAST_MATH 44 #error RSA non-blocking mode only supported using fast math 45 #endif 46 #ifndef TFM_TIMING_RESISTANT 47 #error RSA non-blocking mode only supported with timing resistance enabled 48 #endif 49 50 /* RSA bounds check is not supported with RSA non-blocking mode */ 51 #undef NO_RSA_BOUNDS_CHECK 52 #define NO_RSA_BOUNDS_CHECK 53 #endif 29 54 30 55 /* allow for user to plug in own crypto */ … … 33 58 #else 34 59 35 #ifdef HAVE_FIPS 60 #if defined(HAVE_FIPS) && \ 61 (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2)) 36 62 /* for fips @wc_fips */ 37 63 #include <cyassl/ctaocrypt/rsa.h> … … 42 68 #include <wolfssl/wolfcrypt/integer.h> 43 69 #include <wolfssl/wolfcrypt/random.h> 44 #endif /* HAVE_FIPS */ 70 #endif /* HAVE_FIPS && HAVE_FIPS_VERION 1 */ 71 #if defined(HAVE_FIPS) && \ 72 defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2) 73 #include <wolfssl/wolfcrypt/fips.h> 74 #endif 45 75 46 76 /* header file needed for OAEP padding */ … … 55 85 #endif 56 86 87 enum { 88 RSA_MIN_SIZE = 512, 89 RSA_MAX_SIZE = 4096, 90 }; 91 57 92 /* avoid redefinition of structs */ 58 #if !defined(HAVE_FIPS) 93 #if !defined(HAVE_FIPS) || \ 94 (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)) 59 95 60 96 #ifdef WOLFSSL_ASYNC_CRYPT … … 78 114 RSA_BLOCK_TYPE_2 = 2, 79 115 80 RSA_MIN_SIZE = 512,81 RSA_MAX_SIZE = 4096,82 83 116 RSA_MIN_PAD_SZ = 11, /* separator + 0 + pad value + 8 pads */ 84 117 85 118 RSA_PSS_PAD_SZ = 8, 119 RSA_PSS_SALT_MAX_SZ = 62, 86 120 87 121 #ifdef OPENSSL_EXTRA 88 122 RSA_PKCS1_PADDING_SIZE = 11, 89 RSA_PKCS1_OAEP_PADDING_SIZE = 42 /* (2 * hashlen(SHA-1)) + 2 */ 123 RSA_PKCS1_OAEP_PADDING_SIZE = 42, /* (2 * hashlen(SHA-1)) + 2 */ 124 #endif 125 #ifdef WC_RSA_PSS 126 RSA_PSS_PAD_TERM = 0xBC, 127 #endif 128 129 #ifdef HAVE_PKCS11 130 RSA_MAX_ID_LEN = 32, 90 131 #endif 91 132 }; 92 133 134 #ifdef WC_RSA_NONBLOCK 135 typedef struct RsaNb { 136 exptModNb_t exptmod; /* non-block expt_mod */ 137 mp_int tmp; 138 } RsaNb; 139 #endif 93 140 94 141 /* RSA */ 95 142 struct RsaKey { 96 mp_int n, e, d, p, q, dP, dQ, u; 143 mp_int n, e; 144 #ifndef WOLFSSL_RSA_PUBLIC_ONLY 145 mp_int d, p, q; 146 #if defined(WOLFSSL_KEY_GEN) || defined(OPENSSL_EXTRA) || !defined(RSA_LOW_MEM) 147 mp_int dP, dQ, u; 148 #endif 149 #endif 97 150 void* heap; /* for user memory overrides */ 98 151 byte* data; /* temp buffer for async RSA */ … … 103 156 WC_RNG* rng; /* for PrivateDecrypt blinding */ 104 157 #endif 158 #ifdef WOLF_CRYPTO_DEV 159 int devId; 160 #endif 105 161 #ifdef WOLFSSL_ASYNC_CRYPT 106 162 WC_ASYNC_DEV asyncDev; … … 114 170 XSecure_Rsa xRsa; 115 171 #endif 172 #ifdef HAVE_PKCS11 173 byte id[RSA_MAX_ID_LEN]; 174 int idLen; 175 #endif 176 #if defined(WOLFSSL_ASYNC_CRYPT) || !defined(WOLFSSL_RSA_VERIFY_INLINE) 116 177 byte dataIsAlloc; 178 #endif 179 #ifdef WC_RSA_NONBLOCK 180 RsaNb* nb; 181 #endif 117 182 }; 118 183 … … 127 192 WOLFSSL_API int wc_InitRsaKey_ex(RsaKey* key, void* heap, int devId); 128 193 WOLFSSL_API int wc_FreeRsaKey(RsaKey* key); 194 #ifdef HAVE_PKCS11 195 WOLFSSL_API int wc_InitRsaKey_Id(RsaKey* key, unsigned char* id, int len, 196 void* heap, int devId); 197 #endif 198 WOLFSSL_API int wc_CheckRsaKey(RsaKey* key); 129 199 #ifdef WOLFSSL_XILINX_CRYPT 130 200 WOLFSSL_LOCAL int wc_InitRsaHw(RsaKey* key); 131 201 #endif /* WOLFSSL_XILINX_CRYPT */ 132 202 133 WOLFSSL_ LOCAL intwc_RsaFunction(const byte* in, word32 inLen, byte* out,203 WOLFSSL_API int wc_RsaFunction(const byte* in, word32 inLen, byte* out, 134 204 word32* outLen, int type, RsaKey* key, WC_RNG* rng); 135 205 … … 145 215 word32 outLen, enum wc_HashType hash, int mgf, 146 216 RsaKey* key, WC_RNG* rng); 217 WOLFSSL_API int wc_RsaPSS_Sign_ex(const byte* in, word32 inLen, byte* out, 218 word32 outLen, enum wc_HashType hash, 219 int mgf, int saltLen, RsaKey* key, 220 WC_RNG* rng); 147 221 WOLFSSL_API int wc_RsaSSL_VerifyInline(byte* in, word32 inLen, byte** out, 148 222 RsaKey* key); … … 152 226 enum wc_HashType hash, int mgf, 153 227 RsaKey* key); 228 WOLFSSL_API int wc_RsaPSS_VerifyInline_ex(byte* in, word32 inLen, byte** out, 229 enum wc_HashType hash, int mgf, 230 int saltLen, RsaKey* key); 231 WOLFSSL_API int wc_RsaPSS_Verify(byte* in, word32 inLen, byte* out, 232 word32 outLen, enum wc_HashType hash, int mgf, 233 RsaKey* key); 234 WOLFSSL_API int wc_RsaPSS_Verify_ex(byte* in, word32 inLen, byte* out, 235 word32 outLen, enum wc_HashType hash, 236 int mgf, int saltLen, RsaKey* key); 154 237 WOLFSSL_API int wc_RsaPSS_CheckPadding(const byte* in, word32 inLen, byte* sig, 155 238 word32 sigSz, 156 239 enum wc_HashType hashType); 240 WOLFSSL_API int wc_RsaPSS_CheckPadding_ex(const byte* in, word32 inLen, 241 byte* sig, word32 sigSz, 242 enum wc_HashType hashType, 243 int saltLen, int bits); 244 WOLFSSL_API int wc_RsaPSS_VerifyCheckInline(byte* in, word32 inLen, byte** out, 245 const byte* digest, word32 digentLen, 246 enum wc_HashType hash, int mgf, 247 RsaKey* key); 248 WOLFSSL_API int wc_RsaPSS_VerifyCheck(byte* in, word32 inLen, 249 byte* out, word32 outLen, 250 const byte* digest, word32 digestLen, 251 enum wc_HashType hash, int mgf, 252 RsaKey* key); 157 253 158 254 WOLFSSL_API int wc_RsaEncryptSize(RsaKey* key); 159 255 160 #ifndef HAVE_FIPS /* to avoid asn duplicate symbols @wc_fips */ 256 #if !defined(HAVE_FIPS) || \ 257 (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)) 258 /* to avoid asn duplicate symbols @wc_fips */ 161 259 WOLFSSL_API int wc_RsaPrivateKeyDecode(const byte* input, word32* inOutIdx, 162 260 RsaKey*, word32); … … 169 267 #endif 170 268 269 #ifdef WC_RSA_BLINDING 171 270 WOLFSSL_API int wc_RsaSetRNG(RsaKey* key, WC_RNG* rng); 271 #endif 272 #ifdef WC_RSA_NONBLOCK 273 WOLFSSL_API int wc_RsaSetNonBlock(RsaKey* key, RsaNb* nb); 274 #ifdef WC_RSA_NONBLOCK_TIME 275 WOLFSSL_API int wc_RsaSetNonBlockTime(RsaKey* key, word32 maxBlockUs, 276 word32 cpuMHz); 277 #endif 278 #endif 172 279 173 280 /* … … 187 294 #define WC_RSA_OAEP_PAD 1 188 295 #define WC_RSA_PSS_PAD 2 296 #define WC_RSA_NO_PAD 3 189 297 190 298 WOLFSSL_API int wc_RsaPublicEncrypt_ex(const byte* in, word32 inLen, byte* out, … … 197 305 byte** out, RsaKey* key, int type, enum wc_HashType hash, 198 306 int mgf, byte* label, word32 lableSz); 307 #if defined(WC_RSA_DIRECT) || defined(WC_RSA_NO_PADDING) 308 WOLFSSL_API int wc_RsaDirect(byte* in, word32 inLen, byte* out, word32* outSz, 309 RsaKey* key, int type, WC_RNG* rng); 310 #endif 311 199 312 #endif /* HAVE_FIPS*/ 313 200 314 WOLFSSL_API int wc_RsaFlattenPublicKey(RsaKey*, byte*, word32*, byte*, 201 315 word32*); 316 WOLFSSL_API int wc_RsaExportKey(RsaKey* key, 317 byte* e, word32* eSz, 318 byte* n, word32* nSz, 319 byte* d, word32* dSz, 320 byte* p, word32* pSz, 321 byte* q, word32* qSz); 322 323 WOLFSSL_API int wc_RsaKeyToPublicDer(RsaKey*, byte* output, word32 inLen); 202 324 203 325 #ifdef WOLFSSL_KEY_GEN 204 WOLFSSL_API int wc_RsaKeyToPublicDer(RsaKey*, byte* output, word32 inLen);205 326 WOLFSSL_API int wc_MakeRsaKey(RsaKey* key, int size, long e, WC_RNG* rng); 327 WOLFSSL_API int wc_CheckProbablePrime_ex(const byte* p, word32 pSz, 328 const byte* q, word32 qSz, 329 const byte* e, word32 eSz, 330 int nlen, int* isPrime, WC_RNG* rng); 331 WOLFSSL_API int wc_CheckProbablePrime(const byte* p, word32 pSz, 332 const byte* q, word32 qSz, 333 const byte* e, word32 eSz, 334 int nlen, int* isPrime); 206 335 #endif 207 336 -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/settings.h
r352 r372 77 77 /* #define WOLFSSL_LSR */ 78 78 79 /* Uncomment next line if building for Freescale Classic MQX version 4.0 */ 80 /* #define FREESCALE_MQX_4_0 */ 81 79 82 /* Uncomment next line if building for Freescale Classic MQX/RTCS/MFS */ 80 83 /* #define FREESCALE_MQX */ … … 86 89 /* #define FREESCALE_KSDK_BM */ 87 90 88 /* Uncomment next line if building for Freescale KSDK FreeRTOS (old name FREESCALE_FREE_RTOS) */ 91 /* Uncomment next line if building for Freescale KSDK FreeRTOS, */ 92 /* (old name FREESCALE_FREE_RTOS) */ 89 93 /* #define FREESCALE_KSDK_FREERTOS */ 90 94 … … 94 98 /* Uncomment next line if using STM32F4 */ 95 99 /* #define WOLFSSL_STM32F4 */ 100 101 /* Uncomment next line if using STM32FL */ 102 /* #define WOLFSSL_STM32FL */ 96 103 97 104 /* Uncomment next line if using STM32F7 */ … … 162 169 /* Uncomment next line if building for using XILINX */ 163 170 /* #define WOLFSSL_XILINX */ 171 172 /* Uncomment next line if building for Nucleus 1.2 */ 173 /* #define WOLFSSL_NUCLEUS_1_2 */ 174 175 /* Uncomment next line if building for using Apache mynewt */ 176 /* #define WOLFSSL_APACHE_MYNEWT */ 177 178 /* Uncomment next line if building for using ESP-IDF */ 179 /* #define WOLFSSL_ESPIDF */ 180 181 /* Uncomment next line if using Espressif ESP32-WROOM-32 */ 182 /* #define WOLFSSL_ESPWROOM32 */ 164 183 165 184 #include <wolfssl/wolfcrypt/visibility.h> … … 203 222 #include <nx_api.h> 204 223 #endif 224 225 #if defined(WOLFSSL_ESPIDF) 226 #define FREERTOS 227 #define WOLFSSL_LWIP 228 #define NO_WRITEV 229 #define SIZEOF_LONG_LONG 8 230 #define NO_WOLFSSL_DIR 231 #define WOLFSSL_NO_CURRDIR 232 233 #define TFM_TIMING_RESISTANT 234 #define ECC_TIMING_RESISTANT 235 #define WC_RSA_BLINDING 236 #if !defined(WOLFSSL_USER_SETTINGS) 237 #define HAVE_ECC 238 #endif /* !WOLFSSL_USER_SETTINGS */ 239 #endif /* WOLFSSL_ESPIDF */ 205 240 206 241 #if defined(HAVE_LWIP_NATIVE) /* using LwIP native TCP socket */ … … 210 245 #define WOLFSSL_USER_IO 211 246 #define NO_FILESYSTEM 247 #endif 248 249 #if defined(WOLFSSL_CONTIKI) 250 #include <contiki.h> 251 #define WOLFSSL_UIP 252 #define NO_WOLFSSL_MEMORY 253 #define NO_WRITEV 254 #define SINGLE_THREADED 255 #define WOLFSSL_USER_IO 256 #define NO_FILESYSTEM 257 #define CUSTOM_RAND_TYPE uint16_t 258 #define CUSTOM_RAND_GENERATE random_rand 259 static inline unsigned int LowResTimer(void) 260 { 261 return clock_seconds(); 262 } 212 263 #endif 213 264 … … 241 292 242 293 #ifdef WOLFSSL_MICROCHIP_PIC32MZ 294 #ifndef NO_PIC32MZ_CRYPT 243 295 #define WOLFSSL_PIC32MZ_CRYPT 296 #endif 297 #ifndef NO_PIC32MZ_RNG 244 298 #define WOLFSSL_PIC32MZ_RNG 299 #endif 300 #ifndef NO_PIC32MZ_HASH 245 301 #define WOLFSSL_PIC32MZ_HASH 302 #endif 246 303 #endif 247 304 … … 342 399 #define TFM_NO_ASM 343 400 #endif 344 #define WOLFSSL_PTHREADS 401 /* For VxWorks pthreads wrappers for mutexes uncomment the next line. */ 402 /* #define WOLFSSL_PTHREADS */ 345 403 #define WOLFSSL_HAVE_MIN 346 404 #define WOLFSSL_HAVE_MAX … … 441 499 #define NO_FILESYSTEM 442 500 #define USE_CERT_BUFFERS_2048 501 #endif 502 503 #ifdef WOLFSSL_CHIBIOS 504 /* ChibiOS definitions. This file is distributed with chibiOS. */ 505 #include "wolfssl_chibios.h" 506 #endif 507 508 #ifdef WOLFSSL_PB 509 /* PB is using older 1.2 version of Nucleus */ 510 #undef WOLFSSL_NUCLEUS 511 #define WOLFSSL_NUCLEUS_1_2 512 #endif 513 514 #ifdef WOLFSSL_NUCLEUS_1_2 515 #define NO_WRITEV 516 #define NO_WOLFSSL_DIR 517 518 #if !defined(NO_ASN_TIME) && !defined(USER_TIME) 519 #error User must define XTIME, see manual 520 #endif 521 522 #if !defined(XMALLOC_OVERRIDE) && !defined(XMALLOC_USER) 523 extern void* nucleus_malloc(unsigned long size, void* heap, int type); 524 extern void* nucleus_realloc(void* ptr, unsigned long size, void* heap, 525 int type); 526 extern void nucleus_free(void* ptr, void* heap, int type); 527 528 #define XMALLOC(s, h, type) nucleus_malloc((s), (h), (type)) 529 #define XREALLOC(p, n, h, t) nucleus_realloc((p), (n), (h), (t)) 530 #define XFREE(p, h, type) nucleus_free((p), (h), (type)) 531 #endif 443 532 #endif 444 533 … … 499 588 500 589 /* static char* gets(char *buff); */ 501 static char* fgets(char *buff, int sz, FILE *fp) {590 static char* fgets(char *buff, int sz, XFILE fp) { 502 591 char * p = buff; 503 592 *p = '\0'; … … 539 628 540 629 /* FreeRTOS pvPortRealloc() only in AVR32_UC3 port */ 541 #if !defined(XMALLOC_USER) && !defined(NO_WOLFSSL_MEMORY) 630 #if !defined(XMALLOC_USER) && !defined(NO_WOLFSSL_MEMORY) && \ 631 !defined(WOLFSSL_STATIC_MEMORY) 542 632 #define XMALLOC(s, h, type) pvPortMalloc((s)) 543 633 #define XFREE(p, h, type) vPortFree((p)) 544 634 #endif 545 635 #if defined(HAVE_ED25519) || defined(WOLFSSL_ESPIDF) 636 #define XREALLOC(p, n, h, t) wolfSSL_Realloc((p), (n)) 637 #endif 546 638 #ifndef NO_WRITEV 547 639 #define NO_WRITEV … … 570 662 571 663 #ifdef FREERTOS_TCP 572 573 #if !defined(NO_WOLFSSL_MEMORY) && !defined(XMALLOC_USER)664 #if !defined(NO_WOLFSSL_MEMORY) && !defined(XMALLOC_USER) && \ 665 !defined(WOLFSSL_STATIC_MEMORY) 574 666 #define XMALLOC(s, h, type) pvPortMalloc((s)) 575 667 #define XFREE(p, h, type) vPortFree((p)) … … 583 675 #define TFM_TIMING_RESISTANT 584 676 #define NO_MAIN_DRIVER 585 586 677 #endif 587 678 … … 592 683 #define USE_FAST_MATH 593 684 #define TFM_TIMING_RESISTANT 685 #define ECC_TIMING_RESISTANT 686 #define WC_RSA_BLINDING 594 687 #define NO_DEV_RANDOM 595 688 #define NO_FILESYSTEM … … 599 692 #define HAVE_ECC 600 693 #define HAVE_ALPN 694 #define USE_WOLF_STRTOK /* use with HAVE_ALPN */ 601 695 #define HAVE_TLS_EXTENSIONS 602 696 #define HAVE_AESGCM … … 702 796 #endif 703 797 798 #ifdef FREESCALE_MQX_4_0 799 /* use normal Freescale MQX port, but with minor changes for 4.0 */ 800 #define FREESCALE_MQX 801 #endif 802 704 803 #ifdef FREESCALE_MQX 705 804 #define FREESCALE_COMMON … … 718 817 #endif 719 818 819 #if !defined(XMALLOC_OVERRIDE) && !defined(XMALLOC_USER) 720 820 #define XMALLOC_OVERRIDE 721 821 #define XMALLOC(s, h, t) (void *)_mem_alloc_system((s)) 722 822 #define XFREE(p, h, t) {void* xp = (p); if ((xp)) _mem_free((xp));} 723 823 /* Note: MQX has no realloc, using fastmath above */ 824 #endif 724 825 #endif 725 826 … … 948 1049 #define HAVE_ECC384 949 1050 #endif 950 951 /* enable features */952 #undef HAVE_CURVE25519953 #define HAVE_CURVE25519954 #undef HAVE_ED25519955 #define HAVE_ED25519956 #undef WOLFSSL_SHA512957 #define WOLFSSL_SHA512958 1051 #endif 959 1052 #endif … … 979 1072 980 1073 #if defined(WOLFSSL_STM32F2) || defined(WOLFSSL_STM32F4) || \ 981 defined(WOLFSSL_STM32F7) 1074 defined(WOLFSSL_STM32F7) || defined(WOLFSSL_STM32F1) || \ 1075 defined(WOLFSSL_STM32L4) 982 1076 983 1077 #define SIZEOF_LONG_LONG 8 … … 986 1080 #undef NO_RABBIT 987 1081 #define NO_RABBIT 988 #undef NO_64BIT989 #define NO_64BIT990 1082 #ifndef NO_STM32_RNG 991 1083 #undef STM32_RNG 992 1084 #define STM32_RNG 1085 #ifdef WOLFSSL_STM32F427_RNG 1086 #include "stm32f427xx.h" 1087 #endif 993 1088 #endif 994 1089 #ifndef NO_STM32_CRYPTO 995 1090 #undef STM32_CRYPTO 996 1091 #define STM32_CRYPTO 1092 1093 #ifdef WOLFSSL_STM32L4 1094 #define NO_AES_192 /* hardware does not support 192-bit */ 1095 #endif 997 1096 #endif 998 1097 #ifndef NO_STM32_HASH … … 1007 1106 #if defined(WOLFSSL_STM32F2) 1008 1107 #include "stm32f2xx_hal.h" 1108 #elif defined(WOLFSSL_STM32L4) 1109 #include "stm32l4xx_hal.h" 1009 1110 #elif defined(WOLFSSL_STM32F4) 1010 1111 #include "stm32f4xx_hal.h" 1011 1112 #elif defined(WOLFSSL_STM32F7) 1012 1113 #include "stm32f7xx_hal.h" 1114 #elif defined(WOLFSSL_STM32F1) 1115 #include "stm32f1xx_hal.h" 1013 1116 #endif 1014 1117 … … 1033 1136 #include "stm32f4xx_hash.h" 1034 1137 #endif 1138 #elif defined(WOLFSSL_STM32L4) 1139 #include "stm32l4xx.h" 1140 #ifdef STM32_CRYPTO 1141 #include "stm32l4xx_cryp.h" 1142 #endif 1143 #ifdef STM32_HASH 1144 #include "stm32l4xx_hash.h" 1145 #endif 1035 1146 #elif defined(WOLFSSL_STM32F7) 1036 1147 #include "stm32f7xx.h" 1148 #elif defined(WOLFSSL_STM32F1) 1149 #include "stm32f1xx.h" 1037 1150 #endif 1038 1151 #endif /* WOLFSSL_STM32_CUBEMX */ 1039 #endif /* WOLFSSL_STM32F2 || WOLFSSL_STM32F4 || WOLFSSL_STM32 F7 */1152 #endif /* WOLFSSL_STM32F2 || WOLFSSL_STM32F4 || WOLFSSL_STM32L4 || WOLFSSL_STM32F7 */ 1040 1153 1041 1154 #ifdef MICRIUM … … 1074 1187 #define CUSTOM_RAND_GENERATE Math_Rand 1075 1188 #endif 1076 1077 #define WOLFSSL_TYPES1078 typedef CPU_INT08U byte;1079 typedef CPU_INT16U word16;1080 typedef CPU_INT32U word32;1081 1082 1189 #define STRING_USER 1083 1190 #define XSTRLEN(pstr) ((CPU_SIZE_T)Str_Len((CPU_CHAR *)(pstr))) … … 1176 1283 #endif /*(WOLFSSL_XILINX_CRYPT)*/ 1177 1284 1285 #if defined(WOLFSSL_APACHE_MYNEWT) 1286 #include "os/os_malloc.h" 1287 #if !defined(WOLFSSL_LWIP) 1288 #include <mn_socket/mn_socket.h> 1289 #endif 1290 1291 #if !defined(SIZEOF_LONG) 1292 #define SIZEOF_LONG 4 1293 #endif 1294 #if !defined(SIZEOF_LONG_LONG) 1295 #define SIZEOF_LONG_LONG 8 1296 #endif 1297 #if (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) 1298 #define BIG_ENDIAN_ORDER 1299 #else 1300 #undef BIG_ENDIAN_ORDER 1301 #define LITTLE_ENDIAN_ORDER 1302 #endif 1303 #define NO_WRITEV 1304 #define WOLFSSL_USER_IO 1305 #define SINGLE_THREADED 1306 #define NO_DEV_RANDOM 1307 #define NO_DH 1308 #define NO_WOLFSSL_DIR 1309 #define NO_ERROR_STRINGS 1310 #define HAVE_ECC 1311 #define NO_SESSION_CACHE 1312 #define NO_ERROR_STRINGS 1313 #define XMALLOC_USER 1314 #define XMALLOC(sz, heap, type) os_malloc(sz) 1315 #define XREALLOC(p, sz, heap, type) os_realloc(p, sz) 1316 #define XFREE(p, heap, type) os_free(p) 1317 1318 #endif /*(WOLFSSL_APACHE_MYNEWT)*/ 1319 1320 #ifdef WOLFSSL_IMX6 1321 #ifndef SIZEOF_LONG_LONG 1322 #define SIZEOF_LONG_LONG 8 1323 #endif 1324 #endif 1325 1326 /* if defined turn on all CAAM support */ 1327 #ifdef WOLFSSL_IMX6_CAAM 1328 #undef WOLFSSL_IMX6_CAAM_RNG 1329 #define WOLFSSL_IMX6_CAAM_RNG 1330 1331 #undef WOLFSSL_IMX6_CAAM_BLOB 1332 #define WOLFSSL_IMX6_CAAM_BLOB 1333 1334 #if defined(HAVE_AESGCM) || defined(WOLFSSL_AES_XTS) 1335 /* large performance gain with HAVE_AES_ECB defined */ 1336 #undef HAVE_AES_ECB 1337 #define HAVE_AES_ECB 1338 #endif 1339 #endif 1340 1178 1341 #if !defined(XMALLOC_USER) && !defined(MICRIUM_MALLOC) && \ 1179 1342 !defined(WOLFSSL_LEANPSK) && !defined(NO_WOLFSSL_MEMORY) && \ … … 1206 1369 #ifdef WOLFSSL_SGX 1207 1370 #ifdef _MSC_VER 1208 #define WOLFCRYPT_ONLY1209 1371 #define NO_RC4 1372 #ifndef HAVE_FIPS 1373 #define WOLFCRYPT_ONLY 1210 1374 #define NO_DES3 1211 1375 #define NO_SHA 1212 1376 #define NO_MD5 1213 1377 #else 1378 #define TFM_TIMING_RESISTANT 1379 #define NO_WOLFSSL_DIR 1380 #define NO_WRITEV 1381 #define NO_MAIN_DRIVER 1382 #define WOLFSSL_LOG_PRINTF 1383 #define WOLFSSL_DH_CONST 1384 #endif 1385 #else 1214 1386 #define HAVE_ECC 1215 #define ECC_TIMING_RESISTANT1216 #define TFM_TIMING_RESISTANT1217 #define NO_FILESYSTEM1218 1387 #define NO_WRITEV 1219 1388 #define NO_MAIN_DRIVER … … 1222 1391 #define WOLFSSL_DH_CONST 1223 1392 #endif /* _MSC_VER */ 1224 #if ndef NO_RSA1393 #if !defined(HAVE_FIPS) && !defined(NO_RSA) 1225 1394 #define WC_RSA_BLINDING 1226 1395 #endif 1396 1397 #define NO_FILESYSTEM 1398 #define ECC_TIMING_RESISTANT 1399 #define TFM_TIMING_RESISTANT 1227 1400 #define SINGLE_THREADED 1228 1401 #define NO_ASN_TIME /* can not use headers such as windows.h */ … … 1284 1457 * all curves are on by default for now */ 1285 1458 #ifndef ECC_USER_CURVES 1286 #if ndef HAVE_ALL_CURVES1459 #if !defined(WOLFSSL_SP_MATH) && !defined(HAVE_ALL_CURVES) 1287 1460 #define HAVE_ALL_CURVES 1288 1461 #endif … … 1300 1473 #define HAVE_ECC_VERIFY 1301 1474 #endif 1475 #ifndef NO_ECC_CHECK_KEY 1476 #undef HAVE_ECC_CHECK_KEY 1477 #define HAVE_ECC_CHECK_KEY 1478 #endif 1302 1479 #ifndef NO_ECC_DHE 1303 1480 #undef HAVE_ECC_DHE … … 1359 1536 #define AES_MAX_KEY_SIZE 256 1360 1537 #endif 1538 1539 #ifndef NO_AES_128 1540 #undef WOLFSSL_AES_128 1541 #define WOLFSSL_AES_128 1542 #endif 1543 #if !defined(NO_AES_192) && AES_MAX_KEY_SIZE >= 192 1544 #undef WOLFSSL_AES_192 1545 #define WOLFSSL_AES_192 1546 #endif 1547 #if !defined(NO_AES_256) && AES_MAX_KEY_SIZE >= 256 1548 #undef WOLFSSL_AES_256 1549 #define WOLFSSL_AES_256 1550 #endif 1551 #if !defined(WOLFSSL_AES_128) && defined(HAVE_ECC_ENCRYPT) 1552 #warning HAVE_ECC_ENCRYPT uses AES 128 bit keys 1553 #endif 1554 1361 1555 #ifndef NO_AES_DECRYPT 1362 1556 #undef HAVE_AES_DECRYPT … … 1366 1560 #undef HAVE_AES_CBC 1367 1561 #define HAVE_AES_CBC 1368 #else1369 #ifndef WOLFCRYPT_ONLY1370 #error "AES CBC is required for TLS and can only be disabled for WOLFCRYPT_ONLY builds"1371 #endif1372 1562 #endif 1373 1563 #ifdef WOLFSSL_AES_XTS … … 1377 1567 #endif 1378 1568 #endif 1569 #ifdef WOLFSSL_AES_CFB 1570 /* AES-CFB makes calls to AES direct functions */ 1571 #ifndef WOLFSSL_AES_DIRECT 1572 #define WOLFSSL_AES_DIRECT 1573 #endif 1574 #endif 1575 #endif 1576 1577 #if (defined(WOLFSSL_TLS13) && defined(WOLFSSL_NO_TLS12)) || \ 1578 (!defined(HAVE_AES_CBC) && defined(NO_DES3) && defined(NO_RC4) && \ 1579 !defined(HAVE_CAMELLIA) && !defined(HAVE_IDEA) && \ 1580 !defined(HAVE_NULL_CIPHER) && !defined(HAVE_HC128)) 1581 #define WOLFSSL_AEAD_ONLY 1379 1582 #endif 1380 1583 … … 1445 1648 1446 1649 #ifdef WOLFSSL_ASYNC_CRYPT_TEST 1447 #define WC_ASYNC_DEV_SIZE 32 0+241650 #define WC_ASYNC_DEV_SIZE 328+24 1448 1651 #else 1449 #define WC_ASYNC_DEV_SIZE 32 01652 #define WC_ASYNC_DEV_SIZE 328 1450 1653 #endif 1451 1654 … … 1491 1694 1492 1695 #ifdef HAVE_PKCS7 1696 #if defined(NO_AES) && defined(NO_DES3) 1697 #error PKCS7 needs either AES or 3DES enabled, please enable one 1698 #endif 1493 1699 #ifndef HAVE_AES_KEYWRAP 1494 1700 #error PKCS7 requires AES key wrap please define HAVE_AES_KEYWRAP 1495 1701 #endif 1496 #if ndef HAVE_X963_KDF1702 #if defined(HAVE_ECC) && !defined(HAVE_X963_KDF) 1497 1703 #error PKCS7 requires X963 KDF please define HAVE_X963_KDF 1498 1704 #endif … … 1517 1723 #endif /* WOLFSSL_MYSQL_COMPATIBLE */ 1518 1724 1519 #if defined( WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY)1725 #if defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY) 1520 1726 #define SSL_OP_NO_COMPRESSION SSL_OP_NO_COMPRESSION 1521 1727 #define OPENSSL_NO_ENGINE … … 1557 1763 #if (defined(USE_FAST_MATH) && !defined(TFM_TIMING_RESISTANT)) || \ 1558 1764 (defined(HAVE_ECC) && !defined(ECC_TIMING_RESISTANT)) || \ 1559 (!defined(NO_RSA) && !defined(WC_RSA_BLINDING) && !defined(HAVE_FIPS)) 1765 (!defined(NO_RSA) && !defined(WC_RSA_BLINDING) && !defined(HAVE_FIPS) && \ 1766 !defined(WC_NO_RNG)) 1560 1767 1561 1768 #ifndef _MSC_VER … … 1567 1774 #endif 1568 1775 1776 #if defined(NO_OLD_WC_NAMES) || defined(OPENSSL_EXTRA) 1777 /* added to have compatibility with SHA256() */ 1778 #if !defined(NO_OLD_SHA_NAMES) && !defined(HAVE_FIPS) 1779 #define NO_OLD_SHA_NAMES 1780 #endif 1781 #endif 1782 1783 /* switch for compatibility layer functionality. Has subparts i.e. BIO/X509 1784 * When opensslextra is enabled all subparts should be turned on. */ 1785 #ifdef OPENSSL_EXTRA 1786 #undef OPENSSL_EXTRA_X509_SMALL 1787 #define OPENSSL_EXTRA_X509_SMALL 1788 #endif /* OPENSSL_EXTRA */ 1789 1790 /* support for converting DER to PEM */ 1791 #if defined(WOLFSSL_KEY_GEN) || defined(WOLFSSL_CERT_GEN) || \ 1792 defined(OPENSSL_EXTRA) 1793 #undef WOLFSSL_DER_TO_PEM 1794 #define WOLFSSL_DER_TO_PEM 1795 #endif 1796 1797 /* keep backwards compatibility enabling encrypted private key */ 1798 #ifndef WOLFSSL_ENCRYPTED_KEYS 1799 #if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL) || \ 1800 defined(HAVE_WEBSERVER) 1801 #define WOLFSSL_ENCRYPTED_KEYS 1802 #endif 1803 #endif 1804 1805 /* support for disabling PEM to DER */ 1806 #if !defined(WOLFSSL_NO_PEM) 1807 #undef WOLFSSL_PEM_TO_DER 1808 #define WOLFSSL_PEM_TO_DER 1809 #endif 1810 1811 /* Parts of the openssl compatibility layer require peer certs */ 1812 #if defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY) 1813 #undef KEEP_PEER_CERT 1814 #define KEEP_PEER_CERT 1815 #endif 1816 1817 /* RAW hash function APIs are not implemented with ARMv8 hardware acceleration*/ 1818 #ifdef WOLFSSL_ARMASM 1819 #undef WOLFSSL_NO_HASH_RAW 1820 #define WOLFSSL_NO_HASH_RAW 1821 #endif 1822 1823 #if !defined(WOLFSSL_SHA384) && !defined(WOLFSSL_SHA512) && defined(NO_AES) && \ 1824 !defined(WOLFSSL_SHA3) 1825 #undef WOLFSSL_NO_WORD64_OPS 1826 #define WOLFSSL_NO_WORD64_OPS 1827 #endif 1828 1829 #if defined(NO_AES) && defined(NO_DES3) && !defined(HAVE_CAMELLIA) && \ 1830 defined(NO_PWDBASED) && !defined(HAVE_IDEA) 1831 #undef WOLFSSL_NO_XOR_OPS 1832 #define WOLFSSL_NO_XOR_OPS 1833 #endif 1834 1835 #if defined(NO_ASN) && defined(WOLFCRYPT_ONLY) 1836 #undef WOLFSSL_NO_INT_ENCODE 1837 #define WOLFSSL_NO_INT_ENCODE 1838 #undef WOLFSSL_NO_INT_DECODE 1839 #define WOLFSSL_NO_INT_DECODE 1840 #endif 1841 1842 #if defined(WOLFCRYPT_ONLY) && defined(WOLFSSL_RSA_VERIFY_ONLY) && \ 1843 defined(WC_NO_RSA_OAEP) 1844 #undef WOLFSSL_NO_CT_OPS 1845 #define WOLFSSL_NO_CT_OPS 1846 #endif 1847 1848 #if defined(WOLFCRYPT_ONLY) && defined(NO_AES) && !defined(HAVE_CURVE25519) && \ 1849 defined(WC_NO_RNG) && defined(WC_NO_RSA_OAEP) 1850 #undef WOLFSSL_NO_CONST_CMP 1851 #define WOLFSSL_NO_CONST_CMP 1852 #endif 1853 1854 #if defined(WOLFCRYPT_ONLY) && defined(NO_AES) && !defined(WOLFSSL_SHA384) && \ 1855 !defined(WOLFSSL_SHA512) && defined(WC_NO_RNG) && \ 1856 defined(WOLFSSL_SP_MATH) && defined(WOLFSSL_RSA_PUBLIC_ONLY) 1857 #undef WOLFSSL_NO_FORCE_ZERO 1858 #define WOLFSSL_NO_FORCE_ZERO 1859 #endif 1860 1569 1861 #ifdef __cplusplus 1570 1862 } /* extern "C" */ -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/sha.h
r352 r372 20 20 */ 21 21 22 /*! 23 \file wolfssl/wolfcrypt/sha.h 24 */ 25 22 26 23 27 #ifndef WOLF_CRYPT_SHA_H … … 28 32 #ifndef NO_SHA 29 33 30 #ifdef HAVE_FIPS 34 #if defined(HAVE_FIPS) && \ 35 defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2) 36 #include <wolfssl/wolfcrypt/fips.h> 37 #endif /* HAVE_FIPS_VERSION >= 2 */ 38 39 #if defined(HAVE_FIPS) && \ 40 (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2)) 31 41 #define wc_Sha Sha 32 42 #define WC_SHA SHA … … 47 57 #endif 48 58 49 #ifndef HAVE_FIPS /* avoid redefining structs */ 59 /* avoid redefinition of structs */ 60 #if !defined(HAVE_FIPS) || \ 61 (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)) 50 62 51 63 #ifdef WOLFSSL_MICROCHIP_PIC32MZ 52 64 #include <wolfssl/wolfcrypt/port/pic32/pic32mz-crypt.h> 65 #endif 66 #ifdef STM32_HASH 67 #include <wolfssl/wolfcrypt/port/st/stm32.h> 53 68 #endif 54 69 #ifdef WOLFSSL_ASYNC_CRYPT … … 56 71 #endif 57 72 73 #if !defined(NO_OLD_SHA_NAMES) 74 #define SHA WC_SHA 75 #endif 76 58 77 #ifndef NO_OLD_WC_NAMES 59 78 #define Sha wc_Sha 60 #define SHA WC_SHA61 79 #define SHA_BLOCK_SIZE WC_SHA_BLOCK_SIZE 62 80 #define SHA_DIGEST_SIZE WC_SHA_DIGEST_SIZE … … 66 84 /* in bytes */ 67 85 enum { 68 WC_SHA = 1, /* hash type unique */86 WC_SHA = WC_HASH_TYPE_SHA, 69 87 WC_SHA_BLOCK_SIZE = 64, 70 88 WC_SHA_DIGEST_SIZE = 20, … … 73 91 74 92 75 #ifndef WOLFSSL_TI_HASH 93 #if defined(WOLFSSL_TI_HASH) 94 #include "wolfssl/wolfcrypt/port/ti/ti-hash.h" 95 96 #elif defined(WOLFSSL_IMX6_CAAM) 97 #include "wolfssl/wolfcrypt/port/caam/wolfcaam_sha.h" 98 99 #else 76 100 /* Sha digest */ 77 101 typedef struct wc_Sha { 78 102 #ifdef FREESCALE_LTC_SHA 79 103 ltc_hash_ctx_t ctx; 104 #elif defined(STM32_HASH) 105 STM32_HASH_Context stmCtx; 80 106 #else 81 107 word32 buffLen; /* in bytes */ … … 95 121 WC_ASYNC_DEV asyncDev; 96 122 #endif /* WOLFSSL_ASYNC_CRYPT */ 97 #endif /* FREESCALE_LTC_SHA */123 #endif 98 124 } wc_Sha; 99 125 100 #else101 #include "wolfssl/wolfcrypt/port/ti/ti-hash.h"102 126 #endif /* WOLFSSL_TI_HASH */ 103 127 … … 108 132 WOLFSSL_API int wc_InitSha_ex(wc_Sha* sha, void* heap, int devId); 109 133 WOLFSSL_API int wc_ShaUpdate(wc_Sha*, const byte*, word32); 134 WOLFSSL_API int wc_ShaFinalRaw(wc_Sha*, byte*); 110 135 WOLFSSL_API int wc_ShaFinal(wc_Sha*, byte*); 111 136 WOLFSSL_API void wc_ShaFree(wc_Sha*); -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/sha256.h
r352 r372 20 20 */ 21 21 22 /*! 23 \file wolfssl/wolfcrypt/sha256.h 24 */ 25 22 26 23 27 /* code submitted by raphael.huck@efixo.com */ … … 30 34 #ifndef NO_SHA256 31 35 32 #ifdef HAVE_FIPS 36 #if defined(HAVE_FIPS) && \ 37 defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2) 38 #include <wolfssl/wolfcrypt/fips.h> 39 #endif /* HAVE_FIPS_VERSION >= 2 */ 40 41 #if defined(HAVE_FIPS) && \ 42 (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2)) 33 43 #define wc_Sha256 Sha256 34 44 #define WC_SHA256 SHA256 … … 58 68 #endif 59 69 60 #ifndef HAVE_FIPS /* avoid redefinition of structs */ 70 /* avoid redefinition of structs */ 71 #if !defined(HAVE_FIPS) || \ 72 (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)) 61 73 62 74 #ifdef WOLFSSL_MICROCHIP_PIC32MZ 63 75 #include <wolfssl/wolfcrypt/port/pic32/pic32mz-crypt.h> 64 76 #endif 77 #ifdef STM32_HASH 78 #include <wolfssl/wolfcrypt/port/st/stm32.h> 79 #endif 65 80 #ifdef WOLFSSL_ASYNC_CRYPT 66 81 #include <wolfssl/wolfcrypt/async.h> 67 82 #endif 83 #if defined(WOLFSSL_DEVCRYPTO) && defined(WOLFSSL_DEVCRYPTO_HASH) 84 #include <wolfssl/wolfcrypt/port/devcrypto/wc_devcrypto.h> 85 #endif 86 87 #if defined(_MSC_VER) 88 #define SHA256_NOINLINE __declspec(noinline) 89 #elif defined(__GNUC__) 90 #define SHA256_NOINLINE __attribute__((noinline)) 91 #else 92 #define SHA256_NOINLINE 93 #endif 94 95 #if !defined(NO_OLD_SHA_NAMES) 96 #define SHA256 WC_SHA256 97 #endif 68 98 69 99 #ifndef NO_OLD_WC_NAMES 70 100 #define Sha256 wc_Sha256 71 #define SHA256 WC_SHA25672 101 #define SHA256_BLOCK_SIZE WC_SHA256_BLOCK_SIZE 73 102 #define SHA256_DIGEST_SIZE WC_SHA256_DIGEST_SIZE … … 77 106 /* in bytes */ 78 107 enum { 79 WC_SHA256 = 2, /* hash type unique */108 WC_SHA256 = WC_HASH_TYPE_SHA256, 80 109 WC_SHA256_BLOCK_SIZE = 64, 81 110 WC_SHA256_DIGEST_SIZE = 32, … … 83 112 }; 84 113 85 #ifndef WOLFSSL_TI_HASH 86 114 115 #ifdef WOLFSSL_TI_HASH 116 #include "wolfssl/wolfcrypt/port/ti/ti-hash.h" 117 #elif defined(WOLFSSL_IMX6_CAAM) 118 #include "wolfssl/wolfcrypt/port/caam/wolfcaam_sha.h" 119 #elif defined(WOLFSSL_AFALG_HASH) 120 #include "wolfssl/wolfcrypt/port/af_alg/afalg_hash.h" 121 #else 87 122 /* wc_Sha256 digest */ 88 123 typedef struct wc_Sha256 { 89 124 #ifdef FREESCALE_LTC_SHA 90 125 ltc_hash_ctx_t ctx; 126 #elif defined(STM32_HASH) 127 STM32_HASH_Context stmCtx; 91 128 #else 92 129 /* alignment on digest and buffer speeds up ARMv8 crypto operations */ … … 97 134 word32 hiLen; /* length in bytes */ 98 135 void* heap; 136 #ifdef USE_INTEL_SPEEDUP 137 const byte* data; 138 #endif 99 139 #ifdef WOLFSSL_PIC32MZ_HASH 100 140 hashUpdCache cache; /* cache for updates */ 101 #endif102 #if defined(STM32_HASH) && defined(WOLFSSL_STM32_CUBEMX)103 HASH_HandleTypeDef hashHandle;104 141 #endif 105 142 #ifdef WOLFSSL_ASYNC_CRYPT 106 143 WC_ASYNC_DEV asyncDev; 107 144 #endif /* WOLFSSL_ASYNC_CRYPT */ 108 #endif /* FREESCALE_LTC_SHA */ 145 #ifdef WOLFSSL_SMALL_STACK_CACHE 146 word32* W; 147 #endif 148 #ifdef WOLFSSL_DEVCRYPTO_HASH 149 WC_CRYPTODEV ctx; 150 byte* msg; 151 word32 used; 152 word32 len; 153 #endif 154 #endif 109 155 } wc_Sha256; 110 156 111 #else112 #include "wolfssl/wolfcrypt/port/ti/ti-hash.h"113 157 #endif 114 158 … … 118 162 WOLFSSL_API int wc_InitSha256_ex(wc_Sha256*, void*, int); 119 163 WOLFSSL_API int wc_Sha256Update(wc_Sha256*, const byte*, word32); 164 WOLFSSL_API int wc_Sha256FinalRaw(wc_Sha256*, byte*); 120 165 WOLFSSL_API int wc_Sha256Final(wc_Sha256*, byte*); 121 166 WOLFSSL_API void wc_Sha256Free(wc_Sha256*); … … 129 174 130 175 #ifdef WOLFSSL_SHA224 131 #ifndef HAVE_FIPS /* avoid redefinition of structs */ 176 /* avoid redefinition of structs */ 177 #if !defined(HAVE_FIPS) || \ 178 (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)) 132 179 133 180 #ifndef NO_OLD_WC_NAMES … … 141 188 /* in bytes */ 142 189 enum { 143 WC_SHA224 = 8, /* hash type unique */190 WC_SHA224 = WC_HASH_TYPE_SHA224, 144 191 WC_SHA224_BLOCK_SIZE = WC_SHA256_BLOCK_SIZE, 145 192 WC_SHA224_DIGEST_SIZE = 28, 146 193 WC_SHA224_PAD_SIZE = WC_SHA256_PAD_SIZE 147 194 }; 195 148 196 149 197 typedef wc_Sha256 wc_Sha224; -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/sha512.h
r352 r372 1 1 /* sha512.h 2 2 * 3 * Copyright (C) 2006-201 7wolfSSL Inc.3 * Copyright (C) 2006-2018 wolfSSL Inc. 4 4 * 5 5 * This file is part of wolfSSL. … … 20 20 */ 21 21 22 /*! 23 \file wolfssl/wolfcrypt/sha512.h 24 */ 25 22 26 23 27 #ifndef WOLF_CRYPT_SHA512_H … … 26 30 #include <wolfssl/wolfcrypt/types.h> 27 31 28 #if def WOLFSSL_SHA51232 #if defined(WOLFSSL_SHA512) || defined(WOLFSSL_SHA384) 29 33 30 /* for fips @wc_fips */ 31 #ifdef HAVE_FIPS 34 #if defined(HAVE_FIPS) && \ 35 defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2) 36 #include <wolfssl/wolfcrypt/fips.h> 37 #endif /* HAVE_FIPS_VERSION >= 2 */ 38 39 #if defined(HAVE_FIPS) && \ 40 (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2)) 41 #ifdef WOLFSSL_SHA512 32 42 #define wc_Sha512 Sha512 33 43 #define WC_SHA512 SHA512 … … 35 45 #define WC_SHA512_DIGEST_SIZE SHA512_DIGEST_SIZE 36 46 #define WC_SHA512_PAD_SIZE SHA512_PAD_SIZE 47 #endif /* WOLFSSL_SHA512 */ 37 48 #ifdef WOLFSSL_SHA384 38 49 #define wc_Sha384 Sha384 … … 47 58 #define CYASSL_SHA384 48 59 #endif 60 /* for fips @wc_fips */ 49 61 #include <cyassl/ctaocrypt/sha512.h> 50 62 #endif … … 54 66 #endif 55 67 56 #ifndef HAVE_FIPS /* avoid redefinition of structs */ 68 /* avoid redefinition of structs */ 69 #if !defined(HAVE_FIPS) || \ 70 (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)) 57 71 58 72 #ifdef WOLFSSL_ASYNC_CRYPT … … 60 74 #endif 61 75 62 #ifndef NO_OLD_WC_NAMES 76 #if defined(_MSC_VER) 77 #define SHA512_NOINLINE __declspec(noinline) 78 #elif defined(__GNUC__) 79 #define SHA512_NOINLINE __attribute__((noinline)) 80 #else 81 #define SHA512_NOINLINE 82 #endif 83 84 #ifdef WOLFSSL_SHA512 85 86 #if !defined(NO_OLD_SHA_NAMES) 87 #define SHA512 WC_SHA512 88 #endif 89 90 #if !defined(NO_OLD_WC_NAMES) 63 91 #define Sha512 wc_Sha512 64 #define SHA512 WC_SHA51265 92 #define SHA512_BLOCK_SIZE WC_SHA512_BLOCK_SIZE 66 93 #define SHA512_DIGEST_SIZE WC_SHA512_DIGEST_SIZE … … 68 95 #endif 69 96 97 #endif /* WOLFSSL_SHA512 */ 98 70 99 /* in bytes */ 71 100 enum { 72 WC_SHA512 = 4, /* hash type unique */ 101 #ifdef WOLFSSL_SHA512 102 WC_SHA512 = WC_HASH_TYPE_SHA512, 103 #endif 73 104 WC_SHA512_BLOCK_SIZE = 128, 74 105 WC_SHA512_DIGEST_SIZE = 64, … … 77 108 78 109 110 #ifdef WOLFSSL_IMX6_CAAM 111 #include "wolfssl/wolfcrypt/port/caam/wolfcaam_sha.h" 112 #else 79 113 /* wc_Sha512 digest */ 80 114 typedef struct wc_Sha512 { 115 word64 digest[WC_SHA512_DIGEST_SIZE / sizeof(word64)]; 116 word64 buffer[WC_SHA512_BLOCK_SIZE / sizeof(word64)]; 81 117 word32 buffLen; /* in bytes */ 82 118 word64 loLen; /* length in bytes */ 83 119 word64 hiLen; /* length in bytes */ 84 word64 digest[WC_SHA512_DIGEST_SIZE / sizeof(word64)];85 word64 buffer[WC_SHA512_BLOCK_SIZE / sizeof(word64)];86 120 void* heap; 121 #ifdef USE_INTEL_SPEEDUP 122 const byte* data; 123 #endif 87 124 #ifdef WOLFSSL_ASYNC_CRYPT 88 125 WC_ASYNC_DEV asyncDev; 89 126 #endif /* WOLFSSL_ASYNC_CRYPT */ 127 #ifdef WOLFSSL_SMALL_STACK_CACHE 128 word64* W; 129 #endif 90 130 } wc_Sha512; 131 #endif 91 132 92 133 #endif /* HAVE_FIPS */ 134 135 #ifdef WOLFSSL_SHA512 93 136 94 137 WOLFSSL_API int wc_InitSha512(wc_Sha512*); 95 138 WOLFSSL_API int wc_InitSha512_ex(wc_Sha512*, void*, int); 96 139 WOLFSSL_API int wc_Sha512Update(wc_Sha512*, const byte*, word32); 140 WOLFSSL_API int wc_Sha512FinalRaw(wc_Sha512*, byte*); 97 141 WOLFSSL_API int wc_Sha512Final(wc_Sha512*, byte*); 98 142 WOLFSSL_API void wc_Sha512Free(wc_Sha512*); … … 101 145 WOLFSSL_API int wc_Sha512Copy(wc_Sha512* src, wc_Sha512* dst); 102 146 147 #endif /* WOLFSSL_SHA512 */ 148 103 149 #if defined(WOLFSSL_SHA384) 104 150 105 #ifndef HAVE_FIPS /* avoid redefinition of structs */ 151 /* avoid redefinition of structs */ 152 #if !defined(HAVE_FIPS) || \ 153 (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)) 106 154 107 #ifndef NO_OLD_WC_NAMES 155 #if !defined(NO_OLD_SHA_NAMES) 156 #define SHA384 WC_SHA384 157 #endif 158 159 #if !defined(NO_OLD_WC_NAMES) 108 160 #define Sha384 wc_Sha384 109 #define SHA384 WC_SHA384110 161 #define SHA384_BLOCK_SIZE WC_SHA384_BLOCK_SIZE 111 162 #define SHA384_DIGEST_SIZE WC_SHA384_DIGEST_SIZE … … 115 166 /* in bytes */ 116 167 enum { 117 WC_SHA384 = 5, /* hash type unique */168 WC_SHA384 = WC_HASH_TYPE_SHA384, 118 169 WC_SHA384_BLOCK_SIZE = WC_SHA512_BLOCK_SIZE, 119 170 WC_SHA384_DIGEST_SIZE = 48, 120 171 WC_SHA384_PAD_SIZE = WC_SHA512_PAD_SIZE 121 172 }; 173 122 174 123 175 typedef wc_Sha512 wc_Sha384; … … 127 179 WOLFSSL_API int wc_InitSha384_ex(wc_Sha384*, void*, int); 128 180 WOLFSSL_API int wc_Sha384Update(wc_Sha384*, const byte*, word32); 181 WOLFSSL_API int wc_Sha384FinalRaw(wc_Sha384*, byte*); 129 182 WOLFSSL_API int wc_Sha384Final(wc_Sha384*, byte*); 130 183 WOLFSSL_API void wc_Sha384Free(wc_Sha384*); … … 139 192 #endif 140 193 141 #endif /* WOLFSSL_SHA512 */194 #endif /* WOLFSSL_SHA512 || WOLFSSL_SHA384 */ 142 195 #endif /* WOLF_CRYPT_SHA512_H */ 143 196 -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/types.h
r352 r372 20 20 */ 21 21 22 22 /*! 23 \file wolfssl/wolfcrypt/types.h 24 */ 23 25 24 26 #ifndef WOLF_CRYPT_TYPES_H … … 52 54 53 55 /* try to set SIZEOF_LONG or LONG_LONG if user didn't */ 54 #if !defined(_MSC_VER) && !defined(__BCPLUSPLUS__)56 #if !defined(_MSC_VER) && !defined(__BCPLUSPLUS__) && !defined(__EMSCRIPTEN__) 55 57 #if !defined(SIZEOF_LONG_LONG) && !defined(SIZEOF_LONG) 56 #if (defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) \ 57 || defined(__mips64) || defined(__x86_64__) || \ 58 #if (defined(__alpha__) || defined(__ia64__) || \ 59 defined(_ARCH_PPC64) || defined(__mips64) || \ 60 defined(__x86_64__) || \ 58 61 ((defined(sun) || defined(__sun)) && \ 59 62 (defined(LP64) || defined(_LP64)))) … … 67 70 #endif 68 71 69 70 72 #if defined(_MSC_VER) || defined(__BCPLUSPLUS__) 71 73 #define WORD64_AVAILABLE 72 74 #define W64LIT(x) x##ui64 73 75 typedef unsigned __int64 word64; 76 #elif defined(__EMSCRIPTEN__) 77 #define WORD64_AVAILABLE 78 #define W64LIT(x) x##ull 79 typedef unsigned long long word64; 74 80 #elif defined(SIZEOF_LONG) && SIZEOF_LONG == 8 75 81 #define WORD64_AVAILABLE … … 84 90 #define W64LIT(x) x##LL 85 91 typedef unsigned long long word64; 86 #else 87 #define MP_16BIT /* for mp_int, mp_word needs to be twice as big as 88 mp_digit, no 64 bit type so make mp_digit 16 bit */ 89 #endif 90 91 92 #endif 93 94 #if !defined(NO_64BIT) && defined(WORD64_AVAILABLE) 92 95 /* These platforms have 64-bit CPU registers. */ 93 96 #if (defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || \ … … 100 103 /* LP64 with GNU GCC compiler is reserved for when long int is 64 bits 101 104 * and int uses 32 bits. When using Solaris Studio sparc and __sparc are 102 * av ialable for 32 bit detection but __sparc64__ could be missed. This105 * available for 32 bit detection but __sparc64__ could be missed. This 103 106 * uses LP64 for checking 64 bit CPU arch. */ 104 107 typedef word64 wolfssl_word; … … 110 113 #endif 111 114 #endif 112 115 #else 116 #undef WORD64_AVAILABLE 117 typedef word32 wolfssl_word; 118 #define MP_16BIT /* for mp_int, mp_word needs to be twice as big as 119 mp_digit, no 64 bit type so make mp_digit 16 bit */ 120 #endif 113 121 114 122 enum { … … 121 129 122 130 /* use inlining if compiler allows */ 123 #ifndefINLINE131 #ifndef WC_INLINE 124 132 #ifndef NO_INLINE 125 133 #ifdef _MSC_VER 126 #defineINLINE __inline134 #define WC_INLINE __inline 127 135 #elif defined(__GNUC__) 128 136 #ifdef WOLFSSL_VXWORKS 129 #define INLINE __inline__137 #define WC_INLINE __inline__ 130 138 #else 131 #define INLINE inline139 #define WC_INLINE inline 132 140 #endif 133 141 #elif defined(__IAR_SYSTEMS_ICC__) 134 #defineINLINE inline142 #define WC_INLINE inline 135 143 #elif defined(THREADX) 136 #defineINLINE _Inline144 #define WC_INLINE _Inline 137 145 #else 138 #defineINLINE146 #define WC_INLINE 139 147 #endif 140 148 #else 141 #define INLINE 142 #endif 149 #define WC_INLINE 150 #endif 151 #endif 152 153 #if defined(HAVE_FIPS) || defined(HAVE_SELFTEST) 154 #define INLINE WC_INLINE 143 155 #endif 144 156 … … 164 176 #define THREAD_LS_T __declspec(thread) 165 177 /* Thread local storage only in FreeRTOS v8.2.1 and higher */ 166 #elif defined(FREERTOS)178 #elif defined(FREERTOS) || defined(FREERTOS_TCP) 167 179 #define THREAD_LS_T 168 180 #else … … 176 188 #if defined(__GNUC__) 177 189 #if ((__GNUC__ > 7) || ((__GNUC__ == 7) && (__GNUC_MINOR__ >= 1))) 178 #define FALL_THROUGH __attribute__ ((fallthrough)) ;190 #define FALL_THROUGH __attribute__ ((fallthrough)) 179 191 #endif 180 192 #endif … … 194 206 /* default to libc stuff */ 195 207 /* XREALLOC is used once in normal math lib, not in fast math lib */ 196 /* XFREE on some embeded systems doesn't like free(0) so test */208 /* XFREE on some embedded systems doesn't like free(0) so test */ 197 209 #if defined(HAVE_IO_POOL) 198 210 WOLFSSL_API void* XMALLOC(size_t n, void* heap, int type); … … 217 229 extern void *XREALLOC(void *p, size_t n, void* heap, int type); 218 230 extern void XFREE(void *p, void* heap, int type); 231 #elif defined(WOLFSSL_MEMORY_LOG) 232 #define XMALLOC(n, h, t) xmalloc(n, h, t, __func__, __FILE__, __LINE__) 233 #define XREALLOC(p, n, h, t) xrealloc(p, n, h, t, __func__, __FILE__, __LINE__) 234 #define XFREE(p, h, t) xfree(p, h, t, __func__, __FILE__, __LINE__) 235 236 /* prototypes for user heap override functions */ 237 #include <stddef.h> /* for size_t */ 238 #include <stdlib.h> 239 extern void *xmalloc(size_t n, void* heap, int type, const char* func, 240 const char* file, unsigned int line); 241 extern void *xrealloc(void *p, size_t n, void* heap, int type, 242 const char* func, const char* file, unsigned int line); 243 extern void xfree(void *p, void* heap, int type, const char* func, 244 const char* file, unsigned int line); 219 245 #elif defined(XMALLOC_OVERRIDE) 220 246 /* override the XMALLOC, XFREE and XREALLOC macros */ … … 228 254 && !defined(WOLFSSL_SAFERTOS) && !defined(FREESCALE_MQX) \ 229 255 && !defined(FREESCALE_KSDK_MQX) && !defined(FREESCALE_FREE_RTOS) \ 230 && !defined(WOLFSSL_LEANPSK) && !defined(FREERTOS) && !defined(FREERTOS_TCP)\ 231 && !defined(WOLFSSL_uITRON4) 256 && !defined(WOLFSSL_LEANPSK) && !defined(WOLFSSL_uITRON4) 232 257 /* default C runtime, can install different routines at runtime via cbs */ 233 258 #include <wolfssl/wolfcrypt/memory.h> … … 242 267 #define XREALLOC(p, n, h, t) wolfSSL_Realloc((p), (n), (h), (t)) 243 268 #endif /* WOLFSSL_DEBUG_MEMORY */ 244 #el se269 #elif !defined(FREERTOS) && !defined(FREERTOS_TCP) 245 270 #ifdef WOLFSSL_DEBUG_MEMORY 246 271 #define XMALLOC(s, h, t) ((void)h, (void)t, wolfSSL_Malloc((s), __func__, __LINE__)) … … 258 283 #ifdef WOLFSSL_ASYNC_CRYPT 259 284 #define DECLARE_VAR(VAR_NAME, VAR_TYPE, VAR_SIZE, HEAP) \ 260 VAR_TYPE* VAR_NAME = (VAR_TYPE*)XMALLOC(sizeof(VAR_TYPE) * VAR_SIZE, HEAP, DYNAMIC_TYPE_WOLF_BIGINT);285 VAR_TYPE* VAR_NAME = (VAR_TYPE*)XMALLOC(sizeof(VAR_TYPE) * VAR_SIZE, (HEAP), DYNAMIC_TYPE_WOLF_BIGINT); 261 286 #define DECLARE_VAR_INIT(VAR_NAME, VAR_TYPE, VAR_SIZE, INIT_VALUE, HEAP) \ 262 287 VAR_TYPE* VAR_NAME = ({ \ 263 VAR_TYPE* ptr = (VAR_TYPE*)XMALLOC(sizeof(VAR_TYPE) * VAR_SIZE, HEAP, DYNAMIC_TYPE_WOLF_BIGINT); \288 VAR_TYPE* ptr = (VAR_TYPE*)XMALLOC(sizeof(VAR_TYPE) * VAR_SIZE, (HEAP), DYNAMIC_TYPE_WOLF_BIGINT); \ 264 289 if (ptr && INIT_VALUE) { \ 265 290 XMEMCPY(ptr, INIT_VALUE, sizeof(VAR_TYPE) * VAR_SIZE); \ … … 271 296 int idx##VAR_NAME; \ 272 297 for (idx##VAR_NAME=0; idx##VAR_NAME<VAR_ITEMS; idx##VAR_NAME++) { \ 273 VAR_NAME[idx##VAR_NAME] = (VAR_TYPE*)XMALLOC(VAR_SIZE, HEAP, DYNAMIC_TYPE_WOLF_BIGINT); \298 VAR_NAME[idx##VAR_NAME] = (VAR_TYPE*)XMALLOC(VAR_SIZE, (HEAP), DYNAMIC_TYPE_WOLF_BIGINT); \ 274 299 } 275 300 #define FREE_VAR(VAR_NAME, HEAP) \ 276 XFREE(VAR_NAME, HEAP, DYNAMIC_TYPE_WOLF_BIGINT);301 XFREE(VAR_NAME, (HEAP), DYNAMIC_TYPE_WOLF_BIGINT); 277 302 #define FREE_ARRAY(VAR_NAME, VAR_ITEMS, HEAP) \ 278 303 for (idx##VAR_NAME=0; idx##VAR_NAME<VAR_ITEMS; idx##VAR_NAME++) { \ 279 XFREE(VAR_NAME[idx##VAR_NAME], HEAP, DYNAMIC_TYPE_WOLF_BIGINT); \304 XFREE(VAR_NAME[idx##VAR_NAME], (HEAP), DYNAMIC_TYPE_WOLF_BIGINT); \ 280 305 } 281 306 #else … … 290 315 #endif 291 316 292 #ifndef WOLFSSL_LEANPSK 293 char* mystrnstr(const char* s1, const char* s2, unsigned int n); 317 #if !defined(USE_WOLF_STRTOK) && \ 318 ((defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)) || \ 319 defined(WOLFSSL_TIRTOS) || defined(WOLF_C99)) 320 #define USE_WOLF_STRTOK 321 #endif 322 #if !defined(USE_WOLF_STRSEP) && (defined(WOLF_C99)) 323 #define USE_WOLF_STRSEP 294 324 #endif 295 325 … … 310 340 #define XSTRNCAT(s1,s2,n) strncat((s1),(s2),(n)) 311 341 312 #ifdef MICROCHIP_PIC32 342 #ifdef USE_WOLF_STRSEP 343 #define XSTRSEP(s1,d) wc_strsep((s1),(d)) 344 #else 345 #define XSTRSEP(s1,d) strsep((s1),(d)) 346 #endif 347 348 #if defined(MICROCHIP_PIC32) || defined(WOLFSSL_TIRTOS) 313 349 /* XC32 does not support strncasecmp, so use case sensitive one */ 314 350 #define XSTRNCASECMP(s1,s2,n) strncmp((s1),(s2),(n)) 315 #elif defined(USE_WINDOWS_API) 351 #elif defined(USE_WINDOWS_API) || defined(FREERTOS_TCP_WINSIM) 316 352 #define XSTRNCASECMP(s1,s2,n) _strnicmp((s1),(s2),(n)) 317 353 #else 354 #if defined(HAVE_STRINGS_H) && defined(WOLF_C99) && \ 355 !defined(WOLFSSL_SGX) 356 #include <strings.h> 357 #endif 318 358 #define XSTRNCASECMP(s1,s2,n) strncasecmp((s1),(s2),(n)) 319 359 #endif 320 360 321 /* snprintf is used in asn.c for GetTimeString and PKCS7 test */ 361 /* snprintf is used in asn.c for GetTimeString, PKCS7 test, and when 362 debugging is turned on */ 322 363 #ifndef USE_WINDOWS_API 364 #if defined(NO_FILESYSTEM) && (defined(OPENSSL_EXTRA) || \ 365 defined(HAVE_PKCS7)) && !defined(NO_STDIO_FILESYSTEM) 366 /* case where stdio is not included else where but is needed for 367 * snprintf */ 368 #include <stdio.h> 369 #endif 323 370 #define XSNPRINTF snprintf 324 371 #else … … 328 375 #if defined(WOLFSSL_CERT_EXT) || defined(HAVE_ALPN) 329 376 /* use only Thread Safe version of strtok */ 330 #if !defined(USE_WINDOWS_API) && !defined(INTIME_RTOS) 331 #define XSTRTOK strtok_r 332 #elif defined(__MINGW32__) || defined(WOLFSSL_TIRTOS) || \ 333 defined(USE_WOLF_STRTOK) 334 #ifndef USE_WOLF_STRTOK 335 #define USE_WOLF_STRTOK 336 #endif 337 #define XSTRTOK wc_strtok 377 #if defined(USE_WOLF_STRTOK) 378 #define XSTRTOK(s1,d,ptr) wc_strtok((s1),(d),(ptr)) 379 #elif defined(USE_WINDOWS_API) || defined(INTIME_RTOS) 380 #define XSTRTOK(s1,d,ptr) strtok_s((s1),(d),(ptr)) 338 381 #else 339 #define XSTRTOK strtok_s382 #define XSTRTOK(s1,d,ptr) strtok_r((s1),(d),(ptr)) 340 383 #endif 341 384 #endif 342 #endif 385 #endif 386 387 #ifdef USE_WOLF_STRTOK 388 WOLFSSL_API char* wc_strtok(char *str, const char *delim, char **nextp); 389 #endif 390 #ifdef USE_WOLF_STRSEP 391 WOLFSSL_API char* wc_strsep(char **stringp, const char *delim); 392 #endif 393 394 #if !defined(NO_FILESYSTEM) && defined(OPENSSL_EXTRA) && \ 395 !defined(NO_STDIO_FILESYSTEM) 396 #ifndef XGETENV 397 #include <stdlib.h> 398 #define XGETENV getenv 399 #endif 400 #endif /* OPENSSL_EXTRA */ 343 401 344 402 #ifndef CTYPE_USER 345 403 #include <ctype.h> 346 #if defined(HAVE_ECC) || defined(HAVE_OCSP) || defined(WOLFSSL_KEY_GEN) 404 #if defined(HAVE_ECC) || defined(HAVE_OCSP) || \ 405 defined(WOLFSSL_KEY_GEN) || !defined(NO_DSA) 347 406 #define XTOUPPER(c) toupper((c)) 348 407 #define XISALPHA(c) isalpha((c)) … … 438 497 DYNAMIC_TYPE_HASHCTX = 82, 439 498 DYNAMIC_TYPE_SEED = 83, 440 DYNAMIC_TYPE_SYM ETRIC_KEY= 84,499 DYNAMIC_TYPE_SYMMETRIC_KEY= 84, 441 500 DYNAMIC_TYPE_ECC_BUFFER = 85, 442 501 DYNAMIC_TYPE_QSH = 86, 443 502 DYNAMIC_TYPE_SALT = 87, 444 503 DYNAMIC_TYPE_HASH_TMP = 88, 504 DYNAMIC_TYPE_BLOB = 89, 505 DYNAMIC_TYPE_NAME_ENTRY = 90, 445 506 }; 446 507 447 508 /* max error buffer string size */ 448 enum { 449 WOLFSSL_MAX_ERROR_SZ =80450 }; 509 #ifndef WOLFSSL_MAX_ERROR_SZ 510 #define WOLFSSL_MAX_ERROR_SZ 80 511 #endif 451 512 452 513 /* stack protection */ … … 455 516 }; 456 517 518 519 /* Algorithm Types */ 520 enum wc_AlgoType { 521 WC_ALGO_TYPE_NONE = 0, 522 WC_ALGO_TYPE_HASH = 1, 523 WC_ALGO_TYPE_CIPHER = 2, 524 WC_ALGO_TYPE_PK = 3, 525 526 WC_ALGO_TYPE_MAX = WC_ALGO_TYPE_PK 527 }; 528 529 /* hash types */ 530 enum wc_HashType { 531 #if defined(HAVE_SELFTEST) || defined(HAVE_FIPS) 532 /* In selftest build, WC_* types are not mapped to WC_HASH_TYPE types. 533 * Values here are based on old selftest hmac.h enum, with additions */ 534 WC_HASH_TYPE_NONE = 15, 535 WC_HASH_TYPE_MD2 = 16, 536 WC_HASH_TYPE_MD4 = 17, 537 WC_HASH_TYPE_MD5 = 0, 538 WC_HASH_TYPE_SHA = 1, /* SHA-1 (not old SHA-0) */ 539 WC_HASH_TYPE_SHA224 = 8, 540 WC_HASH_TYPE_SHA256 = 2, 541 WC_HASH_TYPE_SHA384 = 5, 542 WC_HASH_TYPE_SHA512 = 4, 543 WC_HASH_TYPE_MD5_SHA = 18, 544 WC_HASH_TYPE_SHA3_224 = 10, 545 WC_HASH_TYPE_SHA3_256 = 11, 546 WC_HASH_TYPE_SHA3_384 = 12, 547 WC_HASH_TYPE_SHA3_512 = 13, 548 WC_HASH_TYPE_BLAKE2B = 14, 549 550 WC_HASH_TYPE_MAX = WC_HASH_TYPE_MD5_SHA 551 #else 552 WC_HASH_TYPE_NONE = 0, 553 WC_HASH_TYPE_MD2 = 1, 554 WC_HASH_TYPE_MD4 = 2, 555 WC_HASH_TYPE_MD5 = 3, 556 WC_HASH_TYPE_SHA = 4, /* SHA-1 (not old SHA-0) */ 557 WC_HASH_TYPE_SHA224 = 5, 558 WC_HASH_TYPE_SHA256 = 6, 559 WC_HASH_TYPE_SHA384 = 7, 560 WC_HASH_TYPE_SHA512 = 8, 561 WC_HASH_TYPE_MD5_SHA = 9, 562 WC_HASH_TYPE_SHA3_224 = 10, 563 WC_HASH_TYPE_SHA3_256 = 11, 564 WC_HASH_TYPE_SHA3_384 = 12, 565 WC_HASH_TYPE_SHA3_512 = 13, 566 WC_HASH_TYPE_BLAKE2B = 14, 567 568 WC_HASH_TYPE_MAX = WC_HASH_TYPE_BLAKE2B 569 #endif /* HAVE_SELFTEST */ 570 }; 571 572 /* cipher types */ 573 enum wc_CipherType { 574 WC_CIPHER_NONE = 0, 575 WC_CIPHER_AES = 1, 576 WC_CIPHER_AES_CBC = 2, 577 WC_CIPHER_AES_GCM = 3, 578 WC_CIPHER_AES_CTR = 4, 579 WC_CIPHER_AES_XTS = 5, 580 WC_CIPHER_AES_CFB = 6, 581 WC_CIPHER_DES3 = 7, 582 WC_CIPHER_DES = 8, 583 WC_CIPHER_CHACHA = 9, 584 WC_CIPHER_HC128 = 10, 585 WC_CIPHER_IDEA = 11, 586 587 WC_CIPHER_MAX = WC_CIPHER_HC128 588 }; 589 590 /* PK=public key (asymmetric) based algorithms */ 591 enum wc_PkType { 592 WC_PK_TYPE_NONE = 0, 593 WC_PK_TYPE_RSA = 1, 594 WC_PK_TYPE_DH = 2, 595 WC_PK_TYPE_ECDH = 3, 596 WC_PK_TYPE_ECDSA_SIGN = 4, 597 WC_PK_TYPE_ECDSA_VERIFY = 5, 598 WC_PK_TYPE_ED25519 = 6, 599 WC_PK_TYPE_CURVE25519 = 7, 600 WC_PK_TYPE_RSA_KEYGEN = 8, 601 WC_PK_TYPE_EC_KEYGEN = 9, 602 603 WC_PK_TYPE_MAX = WC_PK_TYPE_EC_KEYGEN 604 }; 457 605 458 606 … … 582 730 #endif 583 731 732 733 #if defined(__GNUC__) 734 #define WOLFSSL_PACK __attribute__ ((packed)) 735 #else 736 #define WOLFSSL_PACK 737 #endif 738 739 #ifndef __GNUC_PREREQ 740 #if defined(__GNUC__) && defined(__GNUC_MINOR__) 741 #define __GNUC_PREREQ(maj, min) \ 742 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) 743 #else 744 #define __GNUC_PREREQ(maj, min) (0) /* not GNUC */ 745 #endif 746 #endif 747 748 #if defined(__GNUC__) 749 #define WC_NORETURN __attribute__((noreturn)) 750 #else 751 #define WC_NORETURN 752 #endif 753 754 #if defined(WOLFSSL_KEY_GEN) || defined(HAVE_COMP_KEY) || \ 755 defined(WOLFSSL_DEBUG_MATH) || defined(DEBUG_WOLFSSL) || \ 756 defined(WOLFSSL_PUBLIC_MP) || defined(OPENSSL_EXTRA) || \ 757 (defined(HAVE_ECC) && defined(HAVE_ECC_KEY_EXPORT)) 758 #undef WC_MP_TO_RADIX 759 #define WC_MP_TO_RADIX 760 #endif 761 584 762 #ifdef __cplusplus 585 763 } /* extern "C" */ -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/visibility.h
r352 r372 28 28 29 29 /* for compatibility and so that fips is using same name of macro @wc_fips */ 30 #ifdef HAVE_FIPS 30 /* The following visibility wrappers are for old FIPS. New FIPS should use 31 * the same as a non-FIPS build. */ 32 #if defined(HAVE_FIPS) && \ 33 (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2)) 31 34 #include <cyassl/ctaocrypt/visibility.h> 32 35 #define WOLFSSL_API CYASSL_API … … 41 44 42 45 #if defined(BUILDING_WOLFSSL) 43 #if defined(HAVE_VISIBILITY) && HAVE_VISIBILITY 44 #define WOLFSSL_API __attribute__ ((visibility("default"))) 45 #define WOLFSSL_LOCAL __attribute__ ((visibility("hidden"))) 46 #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550) 47 #define WOLFSSL_API __global 48 #define WOLFSSL_LOCAL __hidden 49 #elif defined(_MSC_VER) || defined(__MINGW32__) 46 #if defined(_MSC_VER) || defined(__MINGW32__) 50 47 #if defined(WOLFSSL_DLL) 51 48 #define WOLFSSL_API __declspec(dllexport) … … 54 51 #endif 55 52 #define WOLFSSL_LOCAL 53 #elif defined(HAVE_VISIBILITY) && HAVE_VISIBILITY 54 #define WOLFSSL_API __attribute__ ((visibility("default"))) 55 #define WOLFSSL_LOCAL __attribute__ ((visibility("hidden"))) 56 #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550) 57 #define WOLFSSL_API __global 58 #define WOLFSSL_LOCAL __hidden 56 59 #else 57 60 #define WOLFSSL_API -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/wc_encrypt.h
r352 r372 20 20 */ 21 21 22 /*! 23 \file wolfssl/wolfcrypt/wc_encrypt.h 24 */ 22 25 23 26 … … 26 29 27 30 #include <wolfssl/wolfcrypt/types.h> 31 #include <wolfssl/wolfcrypt/aes.h> 32 #include <wolfssl/wolfcrypt/chacha.h> 33 #include <wolfssl/wolfcrypt/des3.h> 34 #include <wolfssl/wolfcrypt/arc4.h> 28 35 29 36 #ifdef __cplusplus … … 31 38 #endif 32 39 40 /* determine max cipher key size */ 33 41 #ifndef NO_AES 42 #define WC_MAX_SYM_KEY_SIZE (AES_MAX_KEY_SIZE/8) 43 #elif defined(HAVE_CHACHA) 44 #define WC_MAX_SYM_KEY_SIZE CHACHA_MAX_KEY_SZ 45 #elif !defined(NO_DES3) 46 #define WC_MAX_SYM_KEY_SIZE DES3_KEY_SIZE 47 #elif !defined(NO_RC4) 48 #define WC_MAX_SYM_KEY_SIZE RC4_KEY_SIZE 49 #else 50 #define WC_MAX_SYM_KEY_SIZE 32 51 #endif 52 53 54 #if !defined(NO_AES) && defined(HAVE_AES_CBC) 34 55 WOLFSSL_API int wc_AesCbcEncryptWithKey(byte* out, const byte* in, word32 inSz, 35 56 const byte* key, word32 keySz, … … 56 77 #endif /* !NO_DES3 */ 57 78 79 80 81 82 #ifdef WOLFSSL_ENCRYPTED_KEYS 83 struct EncryptedInfo; 84 WOLFSSL_API int wc_BufferKeyDecrypt(struct EncryptedInfo* info, byte* der, word32 derSz, 85 const byte* password, int passwordSz, int hashType); 86 WOLFSSL_API int wc_BufferKeyEncrypt(struct EncryptedInfo* info, byte* der, word32 derSz, 87 const byte* password, int passwordSz, int hashType); 88 #endif /* WOLFSSL_ENCRYPTED_KEYS */ 89 90 #ifndef NO_PWDBASED 91 WOLFSSL_LOCAL int wc_CryptKey(const char* password, int passwordSz, 92 byte* salt, int saltSz, int iterations, int id, byte* input, int length, 93 int version, byte* cbcIv, int enc); 94 #endif 95 58 96 #ifdef __cplusplus 59 97 } /* extern "C" */ -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/wc_port.h
r352 r372 20 20 */ 21 21 22 22 /*! 23 \file wolfssl/wolfcrypt/wc_port.h 24 */ 23 25 24 26 #ifndef WOLF_CRYPT_PORT_H … … 32 34 #endif 33 35 36 /* Detect if compiler supports C99. "NO_WOLF_C99" can be defined in 37 * user_settings.h to disable checking for C99 support. */ 38 #if !defined(WOLF_C99) && defined(__STDC_VERSION__) && \ 39 !defined(WOLFSSL_ARDUINO) && !defined(NO_WOLF_C99) 40 #if __STDC_VERSION__ >= 199901L 41 #define WOLF_C99 42 #endif 43 #endif 34 44 35 45 #ifdef USE_WINDOWS_API … … 65 75 #elif defined(FREESCALE_FREE_RTOS) 66 76 #include "fsl_os_abstraction.h" 77 #elif defined(WOLFSSL_VXWORKS) 78 #include <semLib.h> 67 79 #elif defined(WOLFSSL_uITRON4) 68 80 #include "stddef.h" … … 70 82 #elif defined(WOLFSSL_uTKERNEL2) 71 83 #include "tk/tkernel.h" 84 #elif defined(WOLFSSL_CMSIS_RTOS) 85 #include "cmsis_os.h" 72 86 #elif defined(WOLFSSL_MDK_ARM) 73 87 #if defined(WOLFSSL_MDK5) … … 86 100 #include <rt.h> 87 101 #include <io.h> 102 #elif defined(WOLFSSL_NUCLEUS_1_2) 103 /* NU_DEBUG needed struct access in nucleus_realloc */ 104 #define NU_DEBUG 105 #include "plus/nucleus.h" 106 #include "nucleus.h" 107 #elif defined(WOLFSSL_APACHE_MYNEWT) 108 /* do nothing */ 88 109 #else 89 110 #ifndef SINGLE_THREADED … … 133 154 #elif defined(FREESCALE_FREE_RTOS) 134 155 typedef mutex_t wolfSSL_Mutex; 156 #elif defined(WOLFSSL_VXWORKS) 157 typedef SEM_ID wolfSSL_Mutex; 135 158 #elif defined(WOLFSSL_uITRON4) 136 159 typedef struct wolfSSL_Mutex { … … 157 180 #elif defined(INTIME_RTOS) 158 181 typedef RTHANDLE wolfSSL_Mutex; 182 #elif defined(WOLFSSL_NUCLEUS_1_2) 183 typedef NU_SEMAPHORE wolfSSL_Mutex; 159 184 #else 160 185 #error Need a mutex type in multithreaded mode … … 185 210 #define wolfSSL_CryptHwMutexInit() 0 /* Success */ 186 211 #define wolfSSL_CryptHwMutexLock() 0 /* Success */ 187 #define wolfSSL_CryptHwMutexUnLock() 0 /* Success */212 #define wolfSSL_CryptHwMutexUnLock() (void)0 /* Success */ 188 213 #endif /* WOLFSSL_CRYPT_HW_MUTEX */ 189 214 … … 194 219 WOLFSSL_API int wc_LockMutex(wolfSSL_Mutex*); 195 220 WOLFSSL_API int wc_UnLockMutex(wolfSSL_Mutex*); 221 #if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER) 222 /* dynamiclly set which mutex to use. unlock / lock is controlled by flag */ 223 typedef void (mutex_cb)(int flag, int type, const char* file, int line); 224 225 WOLFSSL_API int wc_LockMutex_ex(int flag, int type, const char* file, int line); 226 WOLFSSL_API int wc_SetMutexCb(mutex_cb* cb); 227 #endif 196 228 197 229 /* main crypto initialization function */ … … 255 287 #define XBADFILE NULL 256 288 #define XFGETS(b,s,f) -2 /* Not ported yet */ 289 #elif defined(WOLFSSL_NUCLEUS_1_2) 290 #include "fal/inc/fal.h" 291 #define XFILE FILE* 292 #define XFOPEN fopen 293 #define XFSEEK fseek 294 #define XFTELL ftell 295 #define XREWIND rewind 296 #define XFREAD fread 297 #define XFWRITE fwrite 298 #define XFCLOSE fclose 299 #define XSEEK_END PSEEK_END 300 #define XBADFILE NULL 301 #elif defined(WOLFSSL_APACHE_MYNEWT) 302 #include <fs/fs.h> 303 #define XFILE struct fs_file* 304 305 #define XFOPEN mynewt_fopen 306 #define XFSEEK mynewt_fseek 307 #define XFTELL mynewt_ftell 308 #define XREWIND mynewt_rewind 309 #define XFREAD mynewt_fread 310 #define XFWRITE mynewt_fwrite 311 #define XFCLOSE mynewt_fclose 312 #define XSEEK_END 2 313 #define XBADFILE NULL 314 #define XFGETS(b,s,f) -2 /* Not ported yet */ 315 #elif defined(WOLFSSL_USER_FILESYSTEM) 316 /* To be defined in user_settings.h */ 257 317 #else 258 318 /* stdio, default case */ … … 275 335 #define XFGETS fgets 276 336 277 #if !defined(USE_WINDOWS_API) && !defined(NO_WOLFSSL_DIR) 337 #if !defined(USE_WINDOWS_API) && !defined(NO_WOLFSSL_DIR)\ 338 && !defined(WOLFSSL_NUCLEUS) && !defined(WOLFSSL_NUCLEUS_1_2) 278 339 #include <dirent.h> 279 340 #include <unistd.h> … … 289 350 #endif 290 351 291 #if !defined(NO_WOLFSSL_DIR) 352 #if !defined(NO_WOLFSSL_DIR) && !defined(WOLFSSL_NUCLEUS) && \ 353 !defined(WOLFSSL_NUCLEUS_1_2) 292 354 typedef struct ReadDirCtx { 293 355 #ifdef USE_WINDOWS_API … … 302 364 } ReadDirCtx; 303 365 366 #define WC_READDIR_NOFILE -1 367 304 368 WOLFSSL_API int wc_ReadDirFirst(ReadDirCtx* ctx, const char* path, char** name); 305 369 WOLFSSL_API int wc_ReadDirNext(ReadDirCtx* ctx, const char* path, char** name); … … 308 372 309 373 #endif /* !NO_FILESYSTEM */ 310 311 #ifdef USE_WOLF_STRTOK312 WOLFSSL_LOCAL char* wc_strtok(char *str, const char *delim, char **nextp);313 #endif314 374 315 375 /* Windows API defines its own min() macro. */ … … 323 383 #endif /* USE_WINDOWS_API */ 324 384 385 /* Time functions */ 386 #ifndef NO_ASN_TIME 387 #if defined(USER_TIME) 388 /* Use our gmtime and time_t/struct tm types. 389 Only needs seconds since EPOCH using XTIME function. 390 time_t XTIME(time_t * timer) {} 391 */ 392 #define WOLFSSL_GMTIME 393 #define USE_WOLF_TM 394 #define USE_WOLF_TIME_T 395 396 #elif defined(TIME_OVERRIDES) 397 /* Override XTIME() and XGMTIME() functionality. 398 Requires user to provide these functions: 399 time_t XTIME(time_t * timer) {} 400 struct tm* XGMTIME(const time_t* timer, struct tm* tmp) {} 401 */ 402 #ifndef HAVE_TIME_T_TYPE 403 #define USE_WOLF_TIME_T 404 #endif 405 #ifndef HAVE_TM_TYPE 406 #define USE_WOLF_TM 407 #endif 408 #define NEED_TMP_TIME 409 410 #elif defined(HAVE_RTP_SYS) 411 #include "os.h" /* dc_rtc_api needs */ 412 #include "dc_rtc_api.h" /* to get current time */ 413 414 /* uses parital <time.h> structures */ 415 #define XTIME(tl) (0) 416 #define XGMTIME(c, t) rtpsys_gmtime((c)) 417 418 #elif defined(MICRIUM) 419 #include <clk.h> 420 #include <time.h> 421 #define XTIME(t1) micrium_time((t1)) 422 #define WOLFSSL_GMTIME 423 424 #elif defined(MICROCHIP_TCPIP_V5) || defined(MICROCHIP_TCPIP) 425 #include <time.h> 426 #define XTIME(t1) pic32_time((t1)) 427 #define XGMTIME(c, t) gmtime((c)) 428 429 #elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) 430 #ifdef FREESCALE_MQX_4_0 431 #include <time.h> 432 extern time_t mqx_time(time_t* timer); 433 #else 434 #define HAVE_GMTIME_R 435 #endif 436 #define XTIME(t1) mqx_time((t1)) 437 438 #elif defined(FREESCALE_KSDK_BM) || defined(FREESCALE_FREE_RTOS) || defined(FREESCALE_KSDK_FREERTOS) 439 #include <time.h> 440 #ifndef XTIME 441 /*extern time_t ksdk_time(time_t* timer);*/ 442 #define XTIME(t1) ksdk_time((t1)) 443 #endif 444 #define XGMTIME(c, t) gmtime((c)) 445 446 #elif defined(WOLFSSL_ATMEL) && defined(WOLFSSL_ATMEL_TIME) 447 #define XTIME(t1) atmel_get_curr_time_and_date((t1)) 448 #define WOLFSSL_GMTIME 449 #define USE_WOLF_TM 450 #define USE_WOLF_TIME_T 451 452 #elif defined(IDIRECT_DEV_TIME) 453 /*Gets the timestamp from cloak software owned by VT iDirect 454 in place of time() from <time.h> */ 455 #include <time.h> 456 #define XTIME(t1) idirect_time((t1)) 457 #define XGMTIME(c, t) gmtime((c)) 458 459 #elif defined(_WIN32_WCE) 460 #include <windows.h> 461 #define XTIME(t1) windows_time((t1)) 462 #define WOLFSSL_GMTIME 463 464 #elif defined(WOLFSSL_APACHE_MYNEWT) 465 #include "os/os_time.h" 466 #define XTIME(t1) mynewt_time((t1)) 467 #define WOLFSSL_GMTIME 468 #define USE_WOLF_TM 469 #define USE_WOLF_TIME_T 470 #else 471 /* default */ 472 /* uses complete <time.h> facility */ 473 #include <time.h> 474 #if defined(HAVE_SYS_TIME_H) 475 #include <sys/time.h> 476 #endif 477 478 /* PowerPC time_t is int */ 479 #ifdef __PPC__ 480 #define TIME_T_NOT_64BIT 481 #endif 482 #endif 483 484 #ifdef SIZEOF_TIME_T 485 /* check if size of time_t from autoconf is less than 8 bytes (64bits) */ 486 #if SIZEOF_TIME_T < 8 487 #undef TIME_T_NOT_64BIT 488 #define TIME_T_NOT_64BIT 489 #endif 490 #endif 491 #ifdef TIME_T_NOT_LONG 492 /* one old reference to TIME_T_NOT_LONG in GCC-ARM example README 493 * this keeps support for the old macro name */ 494 #undef TIME_T_NOT_64BIT 495 #define TIME_T_NOT_64BIT 496 #endif 497 498 /* Map default time functions */ 499 #if !defined(XTIME) && !defined(TIME_OVERRIDES) && !defined(USER_TIME) 500 #define XTIME(tl) time((tl)) 501 #endif 502 #if !defined(XGMTIME) && !defined(TIME_OVERRIDES) 503 #if defined(WOLFSSL_GMTIME) || !defined(HAVE_GMTIME_R) || defined(WOLF_C99) 504 #define XGMTIME(c, t) gmtime((c)) 505 #else 506 #define XGMTIME(c, t) gmtime_r((c), (t)) 507 #define NEED_TMP_TIME 508 #endif 509 #endif 510 #if !defined(XVALIDATE_DATE) && !defined(HAVE_VALIDATE_DATE) 511 #define USE_WOLF_VALIDDATE 512 #define XVALIDATE_DATE(d, f, t) ValidateDate((d), (f), (t)) 513 #endif 514 515 /* wolf struct tm and time_t */ 516 #if defined(USE_WOLF_TM) 517 struct tm { 518 int tm_sec; /* seconds after the minute [0-60] */ 519 int tm_min; /* minutes after the hour [0-59] */ 520 int tm_hour; /* hours since midnight [0-23] */ 521 int tm_mday; /* day of the month [1-31] */ 522 int tm_mon; /* months since January [0-11] */ 523 int tm_year; /* years since 1900 */ 524 int tm_wday; /* days since Sunday [0-6] */ 525 int tm_yday; /* days since January 1 [0-365] */ 526 int tm_isdst; /* Daylight Savings Time flag */ 527 long tm_gmtoff; /* offset from CUT in seconds */ 528 char *tm_zone; /* timezone abbreviation */ 529 }; 530 #endif /* USE_WOLF_TM */ 531 #if defined(USE_WOLF_TIME_T) 532 typedef long time_t; 533 #endif 534 #if defined(USE_WOLF_SUSECONDS_T) 535 typedef long suseconds_t; 536 #endif 537 #if defined(USE_WOLF_TIMEVAL_T) 538 struct timeval 539 { 540 time_t tv_sec; 541 suseconds_t tv_usec; 542 }; 543 #endif 544 545 /* forward declarations */ 546 #if defined(USER_TIME) 547 struct tm* gmtime(const time_t* timer); 548 extern time_t XTIME(time_t * timer); 549 550 #ifdef STACK_TRAP 551 /* for stack trap tracking, don't call os gmtime on OS X/linux, 552 uses a lot of stack spce */ 553 extern time_t time(time_t * timer); 554 #define XTIME(tl) time((tl)) 555 #endif /* STACK_TRAP */ 556 557 #elif defined(TIME_OVERRIDES) 558 extern time_t XTIME(time_t * timer); 559 extern struct tm* XGMTIME(const time_t* timer, struct tm* tmp); 560 #elif defined(WOLFSSL_GMTIME) 561 struct tm* gmtime(const time_t* timer); 562 #endif 563 #endif /* NO_ASN_TIME */ 564 565 #ifndef WOLFSSL_LEANPSK 566 char* mystrnstr(const char* s1, const char* s2, unsigned int n); 567 #endif 568 569 #ifndef FILE_BUFFER_SIZE 570 #define FILE_BUFFER_SIZE 1024 /* default static file buffer size for input, 571 will use dynamic buffer if not big enough */ 572 #endif 573 325 574 326 575 #ifdef __cplusplus -
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/wolfmath.h
r352 r372 52 52 int mp_rand(mp_int* a, int digits, WC_RNG* rng); 53 53 54 enum { 55 /* format type */ 56 WC_TYPE_HEX_STR = 1, 57 WC_TYPE_UNSIGNED_BIN = 2, 58 }; 59 60 WOLFSSL_API int wc_export_int(mp_int* mp, byte* buf, word32* len, 61 word32 keySz, int encType); 54 62 55 63 #ifdef HAVE_WOLF_BIGINT … … 62 70 63 71 int wc_mp_to_bigint(mp_int* src, WC_BIGINT* dst); 72 int wc_mp_to_bigint_sz(mp_int* src, WC_BIGINT* dst, word32 sz); 64 73 int wc_bigint_to_mp(WC_BIGINT* src, mp_int* dst); 65 74 #endif /* HAVE_WOLF_BIGINT */
Note:
See TracChangeset
for help on using the changeset viewer.