settings.h 93 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104
  1. /* settings.h
  2. *
  3. * Copyright (C) 2006-2023 wolfSSL Inc.
  4. *
  5. * This file is part of wolfSSL.
  6. *
  7. * wolfSSL is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * wolfSSL is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  20. */
  21. /*
  22. * ************************************************************************
  23. *
  24. * ******************************** NOTICE ********************************
  25. *
  26. * ************************************************************************
  27. *
  28. * This method of uncommenting a line in settings.h is outdated.
  29. *
  30. * Please use user_settings.h / WOLFSSL_USER_SETTINGS
  31. *
  32. * or
  33. *
  34. * ./configure CFLAGS="-DFLAG"
  35. *
  36. * For more information see:
  37. *
  38. * https://www.wolfssl.com/how-do-i-manage-the-build-configuration-of-wolfssl/
  39. *
  40. */
  41. /* Place OS specific preprocessor flags, defines, includes here, will be
  42. included into every file because types.h includes it */
  43. #ifndef WOLF_CRYPT_SETTINGS_H
  44. #define WOLF_CRYPT_SETTINGS_H
  45. #ifdef __cplusplus
  46. extern "C" {
  47. #endif
  48. /* This flag allows wolfSSL to include options.h instead of having client
  49. * projects do it themselves. This should *NEVER* be defined when building
  50. * wolfSSL as it can cause hard to debug problems. */
  51. #ifdef EXTERNAL_OPTS_OPENVPN
  52. #include <wolfssl/options.h>
  53. #endif
  54. /* Uncomment next line if using IPHONE */
  55. /* #define IPHONE */
  56. /* Uncomment next line if using ThreadX */
  57. /* #define THREADX */
  58. /* Uncomment next line if using Micrium uC/OS-III */
  59. /* #define MICRIUM */
  60. /* Uncomment next line if using Deos RTOS*/
  61. /* #define WOLFSSL_DEOS*/
  62. /* Uncomment next line if using Mbed */
  63. /* #define MBED */
  64. /* Uncomment next line if using Microchip PIC32 ethernet starter kit */
  65. /* #define MICROCHIP_PIC32 */
  66. /* Uncomment next line if using Microchip TCP/IP stack, version 5 */
  67. /* #define MICROCHIP_TCPIP_V5 */
  68. /* Uncomment next line if using Microchip TCP/IP stack, version 6 or later */
  69. /* #define MICROCHIP_TCPIP */
  70. /* Uncomment next line if using above Microchip TCP/IP defines with BSD API */
  71. /* #define MICROCHIP_TCPIP_BSD_API */
  72. /* Uncomment next line if using PIC32MZ Crypto Engine */
  73. /* #define WOLFSSL_MICROCHIP_PIC32MZ */
  74. /* Uncomment next line if using FreeRTOS */
  75. /* #define FREERTOS */
  76. /* Uncomment next line if using FreeRTOS+ TCP */
  77. /* #define FREERTOS_TCP */
  78. /* Uncomment next line if using FreeRTOS Windows Simulator */
  79. /* #define FREERTOS_WINSIM */
  80. /* Uncomment next line if using RTIP */
  81. /* #define EBSNET */
  82. /* Uncomment next line if using lwip */
  83. /* #define WOLFSSL_LWIP */
  84. /* Uncomment next line if building wolfSSL for a game console */
  85. /* #define WOLFSSL_GAME_BUILD */
  86. /* Uncomment next line if building wolfSSL for LSR */
  87. /* #define WOLFSSL_LSR */
  88. /* Uncomment next line if building for Freescale Classic MQX version 5.0 */
  89. /* #define FREESCALE_MQX_5_0 */
  90. /* Uncomment next line if building for Freescale Classic MQX version 4.0 */
  91. /* #define FREESCALE_MQX_4_0 */
  92. /* Uncomment next line if building for Freescale Classic MQX/RTCS/MFS */
  93. /* #define FREESCALE_MQX */
  94. /* Uncomment next line if building for Freescale KSDK MQX/RTCS/MFS */
  95. /* #define FREESCALE_KSDK_MQX */
  96. /* Uncomment next line if building for Freescale KSDK Bare Metal */
  97. /* #define FREESCALE_KSDK_BM */
  98. /* Uncomment next line if building for Freescale KSDK FreeRTOS, */
  99. /* (old name FREESCALE_FREE_RTOS) */
  100. /* #define FREESCALE_KSDK_FREERTOS */
  101. /* Uncomment next line if using STM32F2 */
  102. /* #define WOLFSSL_STM32F2 */
  103. /* Uncomment next line if using STM32F4 */
  104. /* #define WOLFSSL_STM32F4 */
  105. /* Uncomment next line if using STM32FL */
  106. /* #define WOLFSSL_STM32FL */
  107. /* Uncomment next line if using STM32F7 */
  108. /* #define WOLFSSL_STM32F7 */
  109. /* Uncomment next line if using QL SEP settings */
  110. /* #define WOLFSSL_QL */
  111. /* Uncomment next line if building for EROAD */
  112. /* #define WOLFSSL_EROAD */
  113. /* Uncomment next line if building for IAR EWARM */
  114. /* #define WOLFSSL_IAR_ARM */
  115. /* Uncomment next line if building for Rowley CrossWorks ARM */
  116. /* #define WOLFSSL_ROWLEY_ARM */
  117. /* Uncomment next line if using TI-RTOS settings */
  118. /* #define WOLFSSL_TIRTOS */
  119. /* Uncomment next line if building with PicoTCP */
  120. /* #define WOLFSSL_PICOTCP */
  121. /* Uncomment next line if building for PicoTCP demo bundle */
  122. /* #define WOLFSSL_PICOTCP_DEMO */
  123. /* Uncomment next line if building for uITRON4 */
  124. /* #define WOLFSSL_uITRON4 */
  125. /* Uncomment next line if building for uT-Kernel */
  126. /* #define WOLFSSL_uTKERNEL2 */
  127. /* Uncomment next line if using Max Strength build */
  128. /* #define WOLFSSL_MAX_STRENGTH */
  129. /* Uncomment next line if building for VxWorks */
  130. /* #define WOLFSSL_VXWORKS */
  131. /* Uncomment next line if building for Nordic nRF5x platform */
  132. /* #define WOLFSSL_NRF5x */
  133. /* Uncomment next line to enable deprecated less secure static DH suites */
  134. /* #define WOLFSSL_STATIC_DH */
  135. /* Uncomment next line to enable deprecated less secure static RSA suites */
  136. /* #define WOLFSSL_STATIC_RSA */
  137. /* Uncomment next line if building for ARDUINO */
  138. /* Uncomment both lines if building for ARDUINO on INTEL_GALILEO */
  139. /* #define WOLFSSL_ARDUINO */
  140. /* #define INTEL_GALILEO */
  141. /* Uncomment next line to enable asynchronous crypto WC_PENDING_E */
  142. /* #define WOLFSSL_ASYNC_CRYPT */
  143. /* Uncomment next line if building for uTasker */
  144. /* #define WOLFSSL_UTASKER */
  145. /* Uncomment next line if building for embOS */
  146. /* #define WOLFSSL_EMBOS */
  147. /* Uncomment next line if building for RIOT-OS */
  148. /* #define WOLFSSL_RIOT_OS */
  149. /* Uncomment next line if building for using XILINX hardened crypto */
  150. /* #define WOLFSSL_XILINX_CRYPT */
  151. /* Uncomment next line if building for using XILINX */
  152. /* #define WOLFSSL_XILINX */
  153. /* Uncomment next line if building for WICED Studio. */
  154. /* #define WOLFSSL_WICED */
  155. /* Uncomment next line if building for Nucleus 1.2 */
  156. /* #define WOLFSSL_NUCLEUS_1_2 */
  157. /* Uncomment next line if building for using Apache mynewt */
  158. /* #define WOLFSSL_APACHE_MYNEWT */
  159. /* For Espressif chips see example user_settings.h
  160. *
  161. * https://github.com/wolfSSL/wolfssl/blob/master/IDE/Espressif/ESP-IDF/user_settings.h
  162. */
  163. /* Uncomment next line if building for using ESP-IDF */
  164. /* #define WOLFSSL_ESPIDF */
  165. /* Uncomment next line if using Espressif ESP32-WROOM-32 */
  166. /* #define WOLFSSL_ESPWROOM32 */
  167. /* Uncomment next line if using Espressif ESP32-WROOM-32SE */
  168. /* #define WOLFSSL_ESPWROOM32SE */
  169. /* Uncomment next line if using ARM CRYPTOCELL*/
  170. /* #define WOLFSSL_CRYPTOCELL */
  171. /* Uncomment next line if using RENESAS TSIP */
  172. /* #define WOLFSSL_RENESAS_TSIP */
  173. /* Uncomment next line if using RENESAS RX64N */
  174. /* #define WOLFSSL_RENESAS_RX65N */
  175. /* Uncomment next line if using RENESAS SCE Protected Mode */
  176. /* #define WOLFSSL_RENESAS_SCEPROTECT */
  177. /* Uncomment next line if using RENESAS RA6M4 */
  178. /* #define WOLFSSL_RENESAS_RA6M4 */
  179. /* Uncomment next line if using RENESAS RX64 hardware acceleration */
  180. /* #define WOLFSSL_RENESAS_RX64_HASH */
  181. /* Uncomment next line if using Solaris OS*/
  182. /* #define WOLFSSL_SOLARIS */
  183. /* Uncomment next line if building for Linux Kernel Module */
  184. /* #define WOLFSSL_LINUXKM */
  185. /* Uncomment next line if building for devkitPro */
  186. /* #define DEVKITPRO */
  187. /* Uncomment next line if building for Dolphin Emulator */
  188. /* #define DOLPHIN_EMULATOR */
  189. /* Uncomment next line if using MAXQ1065 */
  190. /* #define WOLFSSL_MAXQ1065 */
  191. /* Uncomment next line if using MAXQ108x */
  192. /* #define WOLFSSL_MAXQ108X */
  193. #ifdef WOLFSSL_USER_SETTINGS
  194. #include "user_settings.h"
  195. #elif defined(USE_HAL_DRIVER) && !defined(HAVE_CONFIG_H)
  196. /* STM Configuration File (generated by CubeMX) */
  197. #include "wolfSSL.I-CUBE-wolfSSL_conf.h"
  198. #endif
  199. #include <wolfssl/wolfcrypt/visibility.h>
  200. #define WOLFSSL_MAKE_FIPS_VERSION(major, minor) (((major) * 256) + (minor))
  201. #if !defined(HAVE_FIPS)
  202. #define WOLFSSL_FIPS_VERSION_CODE WOLFSSL_MAKE_FIPS_VERSION(0,0)
  203. #elif !defined(HAVE_FIPS_VERSION)
  204. #define WOLFSSL_FIPS_VERSION_CODE WOLFSSL_MAKE_FIPS_VERSION(1,0)
  205. #elif !defined(HAVE_FIPS_VERSION_MINOR)
  206. #define WOLFSSL_FIPS_VERSION_CODE WOLFSSL_MAKE_FIPS_VERSION(HAVE_FIPS_VERSION,0)
  207. #else
  208. #define WOLFSSL_FIPS_VERSION_CODE WOLFSSL_MAKE_FIPS_VERSION(HAVE_FIPS_VERSION,HAVE_FIPS_VERSION_MINOR)
  209. #endif
  210. #define FIPS_VERSION_LT(major,minor) (WOLFSSL_FIPS_VERSION_CODE < WOLFSSL_MAKE_FIPS_VERSION(major,minor))
  211. #define FIPS_VERSION_LE(major,minor) (WOLFSSL_FIPS_VERSION_CODE <= WOLFSSL_MAKE_FIPS_VERSION(major,minor))
  212. #define FIPS_VERSION_EQ(major,minor) (WOLFSSL_FIPS_VERSION_CODE == WOLFSSL_MAKE_FIPS_VERSION(major,minor))
  213. #define FIPS_VERSION_GE(major,minor) (WOLFSSL_FIPS_VERSION_CODE >= WOLFSSL_MAKE_FIPS_VERSION(major,minor))
  214. #define FIPS_VERSION_GT(major,minor) (WOLFSSL_FIPS_VERSION_CODE > WOLFSSL_MAKE_FIPS_VERSION(major,minor))
  215. /* make sure old RNG name is used with CTaoCrypt FIPS */
  216. #ifdef HAVE_FIPS
  217. #if FIPS_VERSION_LT(2,0)
  218. #define WC_RNG RNG
  219. #else
  220. #ifndef WOLFSSL_STM32L4
  221. #define RNG WC_RNG
  222. #endif
  223. #endif
  224. /* blinding adds API not available yet in FIPS mode */
  225. #undef WC_RSA_BLINDING
  226. #endif
  227. #ifdef WOLFSSL_HARDEN_TLS
  228. #if WOLFSSL_HARDEN_TLS != 112 && WOLFSSL_HARDEN_TLS != 128
  229. #error "WOLFSSL_HARDEN_TLS must be defined either to 112 or 128 bits of security."
  230. #endif
  231. #endif
  232. #if defined(_WIN32) && !defined(_M_X64) && \
  233. defined(HAVE_AESGCM) && defined(WOLFSSL_AESNI)
  234. /* The _M_X64 macro is what's used in the headers for MSC to tell if it
  235. * has the 64-bit versions of the 128-bit integers available. If one is
  236. * building on 32-bit Windows with AES-NI, turn off the AES-GCMloop
  237. * unrolling. */
  238. #define AES_GCM_AESNI_NO_UNROLL
  239. #endif
  240. #ifdef IPHONE
  241. #define SIZEOF_LONG_LONG 8
  242. #endif
  243. #ifdef THREADX
  244. #define SIZEOF_LONG_LONG 8
  245. #endif
  246. #ifdef HAVE_NETX
  247. #ifdef NEED_THREADX_TYPES
  248. #include <types.h>
  249. #endif
  250. #include <nx_api.h>
  251. #endif
  252. #if defined(WOLFSSL_ESPIDF)
  253. #define FREERTOS
  254. #define WOLFSSL_LWIP
  255. #define NO_WRITEV
  256. #define SIZEOF_LONG_LONG 8
  257. #define NO_WOLFSSL_DIR
  258. #define WOLFSSL_NO_CURRDIR
  259. #define TFM_TIMING_RESISTANT
  260. #define ECC_TIMING_RESISTANT
  261. #define WC_RSA_BLINDING
  262. #if defined(WOLFSSL_ESPWROOM32) || defined(WOLFSSL_ESPWROOM32SE)
  263. #ifndef NO_ESP32WROOM32_CRYPT
  264. #define WOLFSSL_ESP32WROOM32_CRYPT
  265. #if defined(ESP32_USE_RSA_PRIMITIVE) && \
  266. !defined(NO_WOLFSSL_ESP32WROOM32_CRYPT_RSA_PRI)
  267. #define WOLFSSL_ESP32WROOM32_CRYPT_RSA_PRI
  268. #define WOLFSSL_SMALL_STACK
  269. #endif
  270. #endif
  271. #endif
  272. #endif /* WOLFSSL_ESPIDF */
  273. #if defined(WOLFCRYPT_ONLY)
  274. #undef WOLFSSL_RENESAS_TSIP
  275. #endif /* WOLFCRYPT_ONLY */
  276. #if defined(WOLFSSL_RENESAS_TSIP)
  277. #define TSIP_TLS_HMAC_KEY_INDEX_WORDSIZE 64
  278. #define TSIP_TLS_MASTERSECRET_SIZE 80 /* 20 words */
  279. #define TSIP_TLS_ENCPUBKEY_SZ_BY_CERTVRFY 560 /* in byte */
  280. #if !defined(NO_RENESAS_TSIP_CRYPT) && defined(WOLFSSL_RENESAS_RX65N)
  281. #define WOLFSSL_RENESAS_TSIP_CRYPT
  282. #define WOLFSSL_RENESAS_TSIP_TLS
  283. #define WOLFSSL_RENESAS_TSIP_TLS_AES_CRYPT
  284. #endif
  285. #endif /* WOLFSSL_RENESAS_TSIP */
  286. #if !defined(WOLFSSL_NO_HASH_RAW) && defined(WOLFSSL_RENESAS_RX64_HASH)
  287. /* RAW hash function APIs are not implemented with RX64 hardware acceleration */
  288. #define WOLFSSL_NO_HASH_RAW
  289. #endif
  290. #if defined(WOLFSSL_RENESAS_SCEPROTECT)
  291. #define SCE_TLS_MASTERSECRET_SIZE 80 /* 20 words */
  292. #define TSIP_TLS_HMAC_KEY_INDEX_WORDSIZE 64
  293. #define TSIP_TLS_ENCPUBKEY_SZ_BY_CERTVRFY 560 /* in bytes */
  294. #define SCE_TLS_CLIENTRANDOM_SZ 36 /* in bytes */
  295. #define SCE_TLS_SERVERRANDOM_SZ 36 /* in bytes */
  296. #define SCE_TLS_ENCRYPTED_ECCPUBKEY_SZ 96 /* in bytes */
  297. #define WOLFSSL_RENESAS_SCEPROTECT_ECC
  298. #if defined(WOLFSSL_RENESAS_SCEPROTECT_ECC)
  299. #define HAVE_PK_CALLBACKS
  300. /* #define DEBUG_PK_CB */
  301. #endif
  302. #endif
  303. #if defined(WOLFSSL_RENESAS_RA6M3G) || defined(WOLFSSL_RENESAS_RA6M3) ||\
  304. defined(WOLFSSL_RENESAS_RA6M4)
  305. /* settings in user_settings.h */
  306. #endif
  307. #if defined(WOLFSSL_LWIP_NATIVE) || \
  308. defined(HAVE_LWIP_NATIVE) /* using LwIP native TCP socket */
  309. #undef WOLFSSL_USER_IO
  310. #define WOLFSSL_USER_IO
  311. #if defined(HAVE_LWIP_NATIVE)
  312. #define WOLFSSL_LWIP
  313. #define NO_WRITEV
  314. #define SINGLE_THREADED
  315. #define NO_FILESYSTEM
  316. #endif
  317. #endif
  318. #if defined(WOLFSSL_CONTIKI)
  319. #include <contiki.h>
  320. #define WOLFSSL_UIP
  321. #define NO_WOLFSSL_MEMORY
  322. #define NO_WRITEV
  323. #define SINGLE_THREADED
  324. #define WOLFSSL_USER_IO
  325. #define NO_FILESYSTEM
  326. #ifndef CUSTOM_RAND_GENERATE
  327. #define CUSTOM_RAND_TYPE uint16_t
  328. #define CUSTOM_RAND_GENERATE random_rand
  329. #endif
  330. static inline word32 LowResTimer(void)
  331. {
  332. return clock_seconds();
  333. }
  334. #endif
  335. #if defined(WOLFSSL_IAR_ARM) || defined(WOLFSSL_ROWLEY_ARM)
  336. #define NO_MAIN_DRIVER
  337. #define SINGLE_THREADED
  338. #if !defined(USE_CERT_BUFFERS_2048) && !defined(USE_CERT_BUFFERS_4096)
  339. #define USE_CERT_BUFFERS_1024
  340. #endif
  341. #define BENCH_EMBEDDED
  342. #define NO_FILESYSTEM
  343. #define NO_WRITEV
  344. #define WOLFSSL_USER_IO
  345. #define BENCH_EMBEDDED
  346. #endif
  347. #ifdef MICROCHIP_PIC32
  348. /* #define WOLFSSL_MICROCHIP_PIC32MZ */
  349. #define SIZEOF_LONG_LONG 8
  350. #define SINGLE_THREADED
  351. #ifndef MICROCHIP_TCPIP_BSD_API
  352. #define WOLFSSL_USER_IO
  353. #endif
  354. #define NO_WRITEV
  355. #define NO_DEV_RANDOM
  356. #define NO_FILESYSTEM
  357. #define TFM_TIMING_RESISTANT
  358. #define NO_BIG_INT
  359. #endif
  360. #ifdef WOLFSSL_MICROCHIP_PIC32MZ
  361. #define WOLFSSL_HAVE_MIN
  362. #define WOLFSSL_HAVE_MAX
  363. #ifndef NO_PIC32MZ_CRYPT
  364. #define WOLFSSL_PIC32MZ_CRYPT
  365. #endif
  366. #ifndef NO_PIC32MZ_RNG
  367. #define WOLFSSL_PIC32MZ_RNG
  368. #endif
  369. #ifndef NO_PIC32MZ_HASH
  370. #define WOLFSSL_PIC32MZ_HASH
  371. #endif
  372. #endif
  373. #ifdef MICROCHIP_TCPIP_V5
  374. /* include timer functions */
  375. #include "TCPIP Stack/TCPIP.h"
  376. #endif
  377. #ifdef MICROCHIP_TCPIP
  378. /* include timer, NTP functions */
  379. #ifdef MICROCHIP_MPLAB_HARMONY
  380. #include "tcpip/tcpip.h"
  381. #else
  382. #include "system/system_services.h"
  383. #include "tcpip/sntp.h"
  384. #endif
  385. #endif
  386. #ifdef WOLFSSL_ATECC508A
  387. /* backwards compatibility */
  388. #ifndef WOLFSSL_ATECC_NO_ECDH_ENC
  389. #define WOLFSSL_ATECC_ECDH_ENC
  390. #endif
  391. #ifdef WOLFSSL_ATECC508A_DEBUG
  392. #define WOLFSSL_ATECC_DEBUG
  393. #endif
  394. #endif
  395. #ifdef MBED
  396. #define WOLFSSL_USER_IO
  397. #define NO_FILESYSTEM
  398. #define NO_CERTS
  399. #if !defined(USE_CERT_BUFFERS_2048) && !defined(USE_CERT_BUFFERS_4096)
  400. #define USE_CERT_BUFFERS_1024
  401. #endif
  402. #define NO_WRITEV
  403. #define NO_DEV_RANDOM
  404. #define NO_SHA512
  405. #define NO_DH
  406. /* Allows use of DH with fixed points if uncommented and NO_DH is removed */
  407. /* WOLFSSL_DH_CONST */
  408. #define NO_DSA
  409. #define HAVE_ECC
  410. #define NO_SESSION_CACHE
  411. #define WOLFSSL_CMSIS_RTOS
  412. #endif
  413. #ifdef WOLFSSL_EROAD
  414. #define FREESCALE_MQX
  415. #define FREESCALE_MMCAU
  416. #define SINGLE_THREADED
  417. #define NO_STDIO_FILESYSTEM
  418. #define WOLFSSL_LEANPSK
  419. #define HAVE_NULL_CIPHER
  420. #define NO_OLD_TLS
  421. #define NO_ASN
  422. #define NO_BIG_INT
  423. #define NO_RSA
  424. #define NO_DSA
  425. #define NO_DH
  426. /* Allows use of DH with fixed points if uncommented and NO_DH is removed */
  427. /* WOLFSSL_DH_CONST */
  428. #define NO_CERTS
  429. #define NO_PWDBASED
  430. #define NO_DES3
  431. #define NO_MD4
  432. #define NO_RC4
  433. #define NO_MD5
  434. #define NO_SESSION_CACHE
  435. #define NO_MAIN_DRIVER
  436. #endif
  437. #ifdef WOLFSSL_PICOTCP
  438. #ifndef errno
  439. #define errno pico_err
  440. #endif
  441. #include "pico_defines.h"
  442. #include "pico_stack.h"
  443. #include "pico_constants.h"
  444. #include "pico_protocol.h"
  445. #ifndef CUSTOM_RAND_GENERATE
  446. #define CUSTOM_RAND_GENERATE pico_rand
  447. #endif
  448. #endif
  449. #ifdef WOLFSSL_PICOTCP_DEMO
  450. #define WOLFSSL_STM32
  451. #define TFM_TIMING_RESISTANT
  452. #define XMALLOC(s, h, type) PICO_ZALLOC((s))
  453. #define XFREE(p, h, type) PICO_FREE((p))
  454. #define SINGLE_THREADED
  455. #define NO_WRITEV
  456. #define WOLFSSL_USER_IO
  457. #define NO_DEV_RANDOM
  458. #define NO_FILESYSTEM
  459. #endif
  460. #ifdef FREERTOS_WINSIM
  461. #define FREERTOS
  462. #define USE_WINDOWS_API
  463. #endif
  464. #ifdef WOLFSSL_VXWORKS
  465. /* VxWorks simulator incorrectly detects building for i386 */
  466. #ifdef VXWORKS_SIM
  467. #define TFM_NO_ASM
  468. #endif
  469. /* For VxWorks pthreads wrappers for mutexes uncomment the next line. */
  470. /* #define WOLFSSL_PTHREADS */
  471. #define WOLFSSL_HAVE_MIN
  472. #define WOLFSSL_HAVE_MAX
  473. #define NO_MAIN_DRIVER
  474. #define NO_DEV_RANDOM
  475. #define NO_WRITEV
  476. #define HAVE_STRINGS_H
  477. #endif
  478. #ifdef WOLFSSL_ARDUINO
  479. #define NO_WRITEV
  480. #define NO_WOLFSSL_DIR
  481. #define SINGLE_THREADED
  482. #define NO_DEV_RANDOM
  483. #ifndef INTEL_GALILEO /* Galileo has time.h compatibility */
  484. #define TIME_OVERRIDES
  485. #ifndef XTIME
  486. #error "Must define XTIME externally see porting guide"
  487. #error "https://www.wolfssl.com/docs/porting-guide/"
  488. #endif
  489. #ifndef XGMTIME
  490. #error "Must define XGMTIME externally see porting guide"
  491. #error "https://www.wolfssl.com/docs/porting-guide/"
  492. #endif
  493. #endif
  494. #define WOLFSSL_USER_IO
  495. #define HAVE_ECC
  496. #define NO_DH
  497. #define NO_SESSION_CACHE
  498. #endif
  499. #ifdef WOLFSSL_UTASKER
  500. /* uTasker configuration - used for fnRandom() */
  501. #include "config.h"
  502. #define SINGLE_THREADED
  503. #define NO_WOLFSSL_DIR
  504. #define WOLFSSL_HAVE_MIN
  505. #define NO_WRITEV
  506. #define HAVE_ECC
  507. #define ALT_ECC_SIZE
  508. #define TFM_TIMING_RESISTANT
  509. #define ECC_TIMING_RESISTANT
  510. /* used in wolfCrypt test */
  511. #define NO_MAIN_DRIVER
  512. #define USE_CERT_BUFFERS_2048
  513. /* uTasker port uses RAW sockets, use I/O callbacks
  514. * See wolfSSL uTasker example for sample callbacks */
  515. #define WOLFSSL_USER_IO
  516. /* uTasker filesystem not ported */
  517. #define NO_FILESYSTEM
  518. /* uTasker RNG is abstracted, calls HW RNG when available */
  519. #define CUSTOM_RAND_GENERATE fnRandom
  520. #define CUSTOM_RAND_TYPE unsigned short
  521. /* user needs to define XTIME to function that provides
  522. * seconds since Unix epoch */
  523. #ifndef XTIME
  524. #error XTIME must be defined in wolfSSL settings.h
  525. /* #define XTIME fnSecondsSinceEpoch */
  526. #endif
  527. /* use uTasker std library replacements where available */
  528. #define STRING_USER
  529. #define XMEMCPY(d,s,l) uMemcpy((d),(s),(l))
  530. #define XMEMSET(b,c,l) uMemset((b),(c),(l))
  531. #define XMEMCMP(s1,s2,n) uMemcmp((s1),(s2),(n))
  532. #define XMEMMOVE(d,s,l) memmove((d),(s),(l))
  533. #define XSTRLEN(s1) uStrlen((s1))
  534. #define XSTRNCPY(s1,s2,n) strncpy((s1),(s2),(n))
  535. #define XSTRSTR(s1,s2) strstr((s1),(s2))
  536. #define XSTRNSTR(s1,s2,n) mystrnstr((s1),(s2),(n))
  537. #define XSTRNCMP(s1,s2,n) strncmp((s1),(s2),(n))
  538. #define XSTRNCAT(s1,s2,n) strncat((s1),(s2),(n))
  539. #define XSTRNCASECMP(s1,s2,n) _strnicmp((s1),(s2),(n))
  540. #if defined(WOLFSSL_CERT_EXT) || defined(OPENSSL_EXTRA) \
  541. || defined(HAVE_ALPN)
  542. #define XSTRTOK strtok_r
  543. #endif
  544. #endif
  545. #ifdef WOLFSSL_EMBOS
  546. #define NO_FILESYSTEM /* Not ported at this time */
  547. #define USE_CERT_BUFFERS_2048 /* use when NO_FILESYSTEM */
  548. #define NO_MAIN_DRIVER
  549. #define NO_RC4
  550. #endif
  551. #ifdef WOLFSSL_RIOT_OS
  552. #define TFM_NO_ASM
  553. #define NO_FILESYSTEM
  554. #define USE_CERT_BUFFERS_2048
  555. #if defined(WOLFSSL_GNRC) && !defined(WOLFSSL_DTLS)
  556. #define WOLFSSL_DTLS
  557. #endif
  558. #endif
  559. #ifdef WOLFSSL_CHIBIOS
  560. /* ChibiOS definitions. This file is distributed with chibiOS. */
  561. #include "wolfssl_chibios.h"
  562. #endif
  563. #ifdef WOLFSSL_PB
  564. /* PB is using older 1.2 version of Nucleus */
  565. #undef WOLFSSL_NUCLEUS
  566. #define WOLFSSL_NUCLEUS_1_2
  567. #endif
  568. #ifdef WOLFSSL_NUCLEUS_1_2
  569. #define NO_WRITEV
  570. #define NO_WOLFSSL_DIR
  571. #if !defined(NO_ASN_TIME) && !defined(USER_TIME)
  572. #error User must define XTIME, see manual
  573. #endif
  574. #if !defined(XMALLOC_OVERRIDE) && !defined(XMALLOC_USER)
  575. extern void* nucleus_malloc(unsigned long size, void* heap, int type);
  576. extern void* nucleus_realloc(void* ptr, unsigned long size, void* heap,
  577. int type);
  578. extern void nucleus_free(void* ptr, void* heap, int type);
  579. #define XMALLOC(s, h, type) nucleus_malloc((s), (h), (type))
  580. #define XREALLOC(p, n, h, t) nucleus_realloc((p), (n), (h), (t))
  581. #define XFREE(p, h, type) nucleus_free((p), (h), (type))
  582. #endif
  583. #endif
  584. #ifdef WOLFSSL_NRF5x
  585. #define SIZEOF_LONG 4
  586. #define SIZEOF_LONG_LONG 8
  587. #define NO_DEV_RANDOM
  588. #define NO_FILESYSTEM
  589. #define NO_MAIN_DRIVER
  590. #define NO_WRITEV
  591. #define SINGLE_THREADED
  592. #define TFM_TIMING_RESISTANT
  593. #define WOLFSSL_NRF51
  594. #define WOLFSSL_USER_IO
  595. #define NO_SESSION_CACHE
  596. #endif
  597. /* Micrium will use Visual Studio for compilation but not the Win32 API */
  598. #if defined(_WIN32) && !defined(MICRIUM) && !defined(FREERTOS) && \
  599. !defined(FREERTOS_TCP) && !defined(EBSNET) && !defined(WOLFSSL_EROAD) && \
  600. !defined(WOLFSSL_UTASKER) && !defined(INTIME_RTOS)
  601. #define USE_WINDOWS_API
  602. #endif
  603. #if defined(WOLFSSL_uITRON4)
  604. #define XMALLOC_USER
  605. #include <stddef.h>
  606. #define ITRON_POOL_SIZE 1024*20
  607. extern int uITRON4_minit(size_t poolsz) ;
  608. extern void *uITRON4_malloc(size_t sz) ;
  609. extern void *uITRON4_realloc(void *p, size_t sz) ;
  610. extern void uITRON4_free(void *p) ;
  611. #define XMALLOC(sz, heap, type) uITRON4_malloc(sz)
  612. #define XREALLOC(p, sz, heap, type) uITRON4_realloc(p, sz)
  613. #define XFREE(p, heap, type) uITRON4_free(p)
  614. #endif
  615. #if defined(WOLFSSL_uTKERNEL2)
  616. #ifndef NO_TKERNEL_MEM_POOL
  617. #define XMALLOC_OVERRIDE
  618. int uTKernel_init_mpool(unsigned int sz); /* initializing malloc pool */
  619. void* uTKernel_malloc(unsigned int sz);
  620. void* uTKernel_realloc(void *p, unsigned int sz);
  621. void uTKernel_free(void *p);
  622. #define XMALLOC(s, h, type) uTKernel_malloc((s))
  623. #define XREALLOC(p, n, h, t) uTKernel_realloc((p), (n))
  624. #define XFREE(p, h, type) uTKernel_free((p))
  625. #endif
  626. #ifndef NO_STDIO_FGETS_REMAP
  627. #include <stdio.h>
  628. #include "tm/tmonitor.h"
  629. /* static char* gets(char *buff); */
  630. static char* fgets(char *buff, int sz, XFILE fp) {
  631. char * s = buff;
  632. *s = '\0';
  633. while (1) {
  634. *s = tm_getchar(-1);
  635. tm_putchar(*s);
  636. if (*s == '\r') {
  637. tm_putchar('\n');
  638. *s = '\0';
  639. break;
  640. }
  641. s++;
  642. }
  643. return buff;
  644. }
  645. #endif /* !NO_STDIO_FGETS_REMAP */
  646. #endif
  647. #if defined(WOLFSSL_LEANPSK) && !defined(XMALLOC_USER) && \
  648. !defined(NO_WOLFSSL_MEMORY)
  649. #include <stdlib.h>
  650. #define XMALLOC(s, h, type) malloc((s))
  651. #define XFREE(p, h, type) free((p))
  652. #define XREALLOC(p, n, h, t) realloc((p), (n))
  653. #endif
  654. #if defined(XMALLOC_USER) && defined(SSN_BUILDING_LIBYASSL)
  655. #undef XMALLOC
  656. #define XMALLOC yaXMALLOC
  657. #undef XFREE
  658. #define XFREE yaXFREE
  659. #undef XREALLOC
  660. #define XREALLOC yaXREALLOC
  661. #endif
  662. #ifdef FREERTOS
  663. #include "FreeRTOS.h"
  664. #include <task.h>
  665. #if !defined(XMALLOC_USER) && !defined(NO_WOLFSSL_MEMORY) && \
  666. !defined(WOLFSSL_STATIC_MEMORY) && !defined(WOLFSSL_TRACK_MEMORY)
  667. #define XMALLOC(s, h, type) pvPortMalloc((s))
  668. #define XFREE(p, h, type) vPortFree((p))
  669. #if defined(WOLFSSL_ESPIDF)
  670. /* In IDF, realloc(p, n) is equivalent to
  671. * heap_caps_realloc(p, s, MALLOC_CAP_8BIT) */
  672. #define XREALLOC(p, n, h, t) realloc((p), (n))
  673. /* FreeRTOS pvPortRealloc() implementation can be found here:
  674. * https://github.com/wolfSSL/wolfssl-freertos/pull/3/files */
  675. #elif defined(USE_INTEGER_HEAP_MATH) || defined(OPENSSL_EXTRA)
  676. #define XREALLOC(p, n, h, t) pvPortRealloc((p), (n))
  677. #endif
  678. #endif
  679. #ifndef NO_WRITEV
  680. #define NO_WRITEV
  681. #endif
  682. #ifndef HAVE_SHA512
  683. #ifndef NO_SHA512
  684. #define NO_SHA512
  685. #endif
  686. #endif
  687. #ifndef HAVE_DH
  688. #ifndef NO_DH
  689. #define NO_DH
  690. #endif
  691. #endif
  692. #ifndef NO_DSA
  693. #define NO_DSA
  694. #endif
  695. #ifndef SINGLE_THREADED
  696. #include "semphr.h"
  697. #endif
  698. #endif
  699. #ifdef FREERTOS_TCP
  700. #if !defined(NO_WOLFSSL_MEMORY) && !defined(XMALLOC_USER) && \
  701. !defined(WOLFSSL_STATIC_MEMORY)
  702. #define XMALLOC(s, h, type) pvPortMalloc((s))
  703. #define XFREE(p, h, type) vPortFree((p))
  704. #endif
  705. #define WOLFSSL_GENSEED_FORTEST
  706. #define NO_WOLFSSL_DIR
  707. #define NO_WRITEV
  708. #define TFM_TIMING_RESISTANT
  709. #define NO_MAIN_DRIVER
  710. #endif
  711. #ifdef WOLFSSL_TI_CRYPT
  712. #define NO_GCM_ENCRYPT_EXTRA
  713. #define NO_PUBLIC_GCM_SET_IV
  714. #define NO_PUBLIC_CCM_SET_NONCE
  715. #endif
  716. #ifdef WOLFSSL_TIRTOS
  717. #define SIZEOF_LONG_LONG 8
  718. #define NO_WRITEV
  719. #define NO_WOLFSSL_DIR
  720. /* Enable SP math by default, unless fast math
  721. * specified in user_settings.
  722. */
  723. #ifndef USE_FAST_MATH
  724. #define WOLFSSL_HAVE_SP_ECC
  725. #define SP_WORD_SIZE 32
  726. #define WOLFSSL_HAVE_SP_RSA
  727. #define WOLFSSL_SP_4096
  728. #endif
  729. #define TFM_TIMING_RESISTANT
  730. #define ECC_TIMING_RESISTANT
  731. #define WC_RSA_BLINDING
  732. #define NO_DEV_RANDOM
  733. #define NO_FILESYSTEM
  734. #define NO_SIG_WRAPPER
  735. #define NO_MAIN_DRIVER
  736. #define USE_CERT_BUFFERS_2048
  737. #define NO_ERROR_STRINGS
  738. /* Uncomment this setting if your toolchain does not offer time.h header */
  739. /* #define USER_TIME */
  740. #define HAVE_ECC
  741. #define HAVE_ALPN
  742. #define USE_WOLF_STRTOK /* use with HAVE_ALPN */
  743. #define HAVE_TLS_EXTENSIONS
  744. #define HAVE_AESGCM
  745. #define HAVE_SUPPORTED_CURVES
  746. #ifdef __IAR_SYSTEMS_ICC__
  747. #pragma diag_suppress=Pa089
  748. #elif !defined(__GNUC__)
  749. /* Suppress the sslpro warning */
  750. #pragma diag_suppress=11
  751. #endif
  752. #include <ti/sysbios/hal/Seconds.h>
  753. #endif
  754. #ifdef EBSNET
  755. #include "rtip.h"
  756. /* #define DEBUG_WOLFSSL */
  757. #define NO_WOLFSSL_DIR /* tbd */
  758. #if (POLLOS)
  759. #define SINGLE_THREADED
  760. #endif
  761. #if (defined(RTPLATFORM) && (RTPLATFORM != 0))
  762. #if (!RTP_LITTLE_ENDIAN)
  763. #define BIG_ENDIAN_ORDER
  764. #endif
  765. #else
  766. #if (!KS_LITTLE_ENDIAN)
  767. #define BIG_ENDIAN_ORDER
  768. #endif
  769. #endif
  770. #if (WINMSP3)
  771. #undef SIZEOF_LONG
  772. #define SIZEOF_LONG_LONG 8
  773. #else
  774. #if !defined(SIZEOF_LONG) && !defined(SIZEOF_LONG_LONG)
  775. #error settings.h - please implement SIZEOF_LONG and SIZEOF_LONG_LONG
  776. #endif
  777. #endif
  778. #if (WINMSP3)
  779. #define strtok_r strtok_s
  780. #endif
  781. #define XMALLOC(s, h, type) ((void *)rtp_malloc((s), SSL_PRO_MALLOC))
  782. #define XFREE(p, h, type) (rtp_free(p))
  783. #define XREALLOC(p, n, h, t) (rtp_realloc((p), (n), (t)))
  784. #if (WINMSP3)
  785. #define XSTRNCASECMP(s1,s2,n) _strnicmp((s1),(s2),(n))
  786. #else
  787. #ifndef XSTRNCASECMP
  788. #error settings.h - please implement XSTRNCASECMP - needed for HAVE_ECC
  789. #endif
  790. #endif
  791. #define WOLFSSL_HAVE_MAX
  792. #define WOLFSSL_HAVE_MIN
  793. #define TFM_TIMING_RESISTANT
  794. #define WC_RSA_BLINDING
  795. #define ECC_TIMING_RESISTANT
  796. #define HAVE_ECC
  797. #endif /* EBSNET */
  798. #ifdef WOLFSSL_GAME_BUILD
  799. #define SIZEOF_LONG_LONG 8
  800. #endif
  801. #ifdef WOLFSSL_LSR
  802. #define HAVE_WEBSERVER
  803. #define SIZEOF_LONG_LONG 8
  804. #define WOLFSSL_LOW_MEMORY
  805. #define NO_WRITEV
  806. #define NO_SHA512
  807. #define NO_DH
  808. /* Allows use of DH with fixed points if uncommented and NO_DH is removed */
  809. /* WOLFSSL_DH_CONST */
  810. #define NO_DSA
  811. #define NO_DEV_RANDOM
  812. #define NO_WOLFSSL_DIR
  813. #ifndef NO_FILESYSTEM
  814. #define LSR_FS
  815. #include "inc/hw_types.h"
  816. #include "fs.h"
  817. #endif
  818. #define WOLFSSL_LWIP
  819. #include <errno.h> /* for tcp errno */
  820. #define WOLFSSL_SAFERTOS
  821. #if defined(__IAR_SYSTEMS_ICC__)
  822. /* enum uses enum */
  823. #pragma diag_suppress=Pa089
  824. #endif
  825. #endif
  826. #ifdef WOLFSSL_SAFERTOS
  827. #ifndef SINGLE_THREADED
  828. #include "SafeRTOS/semphr.h"
  829. #endif
  830. #ifndef WOLFSSL_NO_MALLOC
  831. #include "SafeRTOS/heap.h"
  832. #endif
  833. #if !defined(XMALLOC_USER) && !defined(NO_WOLFSSL_MEMORY) && \
  834. !defined(WOLFSSL_STATIC_MEMORY)
  835. #define XMALLOC(s, h, type) pvPortMalloc((s))
  836. #define XFREE(p, h, type) vPortFree((p))
  837. /* FreeRTOS pvPortRealloc() implementation can be found here:
  838. https://github.com/wolfSSL/wolfssl-freertos/pull/3/files */
  839. #if !defined(USE_FAST_MATH) || defined(HAVE_ED25519) || \
  840. defined(HAVE_ED448)
  841. #define XREALLOC(p, n, h, t) pvPortRealloc((p), (n))
  842. #endif
  843. #endif
  844. #endif
  845. #ifdef WOLFSSL_LOW_MEMORY
  846. #undef RSA_LOW_MEM
  847. #define RSA_LOW_MEM
  848. #undef WOLFSSL_SMALL_STACK
  849. #define WOLFSSL_SMALL_STACK
  850. #undef TFM_TIMING_RESISTANT
  851. #define TFM_TIMING_RESISTANT
  852. #endif
  853. /* To support storing some of the large constant tables in flash memory rather than SRAM.
  854. Useful for processors that have limited SRAM, such as the AVR family of microtrollers. */
  855. #ifdef WOLFSSL_USE_FLASHMEM
  856. /* This is supported on the avr-gcc compiler, for more information see:
  857. https://gcc.gnu.org/onlinedocs/gcc/Named-Address-Spaces.html */
  858. #define FLASH_QUALIFIER __flash
  859. /* Copy data out of flash memory and into SRAM */
  860. #define XMEMCPY_P(pdest, psrc, size) memcpy_P((pdest), (psrc), (size))
  861. #else
  862. #define FLASH_QUALIFIER
  863. #endif
  864. #ifdef FREESCALE_MQX_5_0
  865. /* use normal Freescale MQX port, but with minor changes for 5.0 */
  866. #define FREESCALE_MQX
  867. #endif
  868. #ifdef FREESCALE_MQX_4_0
  869. /* use normal Freescale MQX port, but with minor changes for 4.0 */
  870. #define FREESCALE_MQX
  871. #endif
  872. #ifdef FREESCALE_MQX
  873. #define FREESCALE_COMMON
  874. #include "mqx.h"
  875. #ifndef NO_FILESYSTEM
  876. #include "mfs.h"
  877. #if (defined(MQX_USE_IO_OLD) && MQX_USE_IO_OLD) || \
  878. defined(FREESCALE_MQX_5_0)
  879. #include "fio.h"
  880. #define NO_STDIO_FILESYSTEM
  881. #else
  882. #include "nio.h"
  883. #endif
  884. #endif
  885. #ifndef SINGLE_THREADED
  886. #include "mutex.h"
  887. #endif
  888. #if !defined(XMALLOC_OVERRIDE) && !defined(XMALLOC_USER)
  889. #define XMALLOC_OVERRIDE
  890. #define XMALLOC(s, h, t) (void *)_mem_alloc_system((s))
  891. #define XFREE(p, h, t) {void* xp = (p); if ((xp)) _mem_free((xp));}
  892. /* Note: MQX has no realloc, using fastmath above */
  893. #endif
  894. #ifdef USE_FAST_MATH
  895. /* Undef first to avoid re-definition if user_settings.h defines */
  896. #undef TFM_TIMING_RESISTANT
  897. #define TFM_TIMING_RESISTANT
  898. #undef ECC_TIMING_RESISTANT
  899. #define ECC_TIMING_RESISTANT
  900. #undef WC_RSA_BLINDING
  901. #define WC_RSA_BLINDING
  902. #endif
  903. #endif
  904. #ifdef FREESCALE_KSDK_MQX
  905. #define FREESCALE_COMMON
  906. #include <mqx.h>
  907. #ifndef NO_FILESYSTEM
  908. #if (defined(MQX_USE_IO_OLD) && MQX_USE_IO_OLD) || \
  909. defined(FREESCALE_MQX_5_0)
  910. #include <fio.h>
  911. #else
  912. #include <stdio.h>
  913. #include <nio.h>
  914. #endif
  915. #endif
  916. #ifndef SINGLE_THREADED
  917. #include <mutex.h>
  918. #endif
  919. #define XMALLOC(s, h, t) (void *)_mem_alloc_system((s))
  920. #define XFREE(p, h, t) {void* xp = (p); if ((xp)) _mem_free((xp));}
  921. #define XREALLOC(p, n, h, t) _mem_realloc((p), (n)) /* since MQX 4.1.2 */
  922. #define MQX_FILE_PTR FILE *
  923. #define IO_SEEK_SET SEEK_SET
  924. #define IO_SEEK_END SEEK_END
  925. #endif /* FREESCALE_KSDK_MQX */
  926. #if defined(FREESCALE_FREE_RTOS) || defined(FREESCALE_KSDK_FREERTOS)
  927. #define NO_FILESYSTEM
  928. #define WOLFSSL_CRYPT_HW_MUTEX 1
  929. #if !defined(XMALLOC_USER) && !defined(NO_WOLFSSL_MEMORY)
  930. #define XMALLOC(s, h, type) pvPortMalloc((s))
  931. #define XFREE(p, h, type) vPortFree((p))
  932. #endif
  933. /* #define USER_TICKS */
  934. /* Allows use of DH with fixed points if uncommented and NO_DH is removed */
  935. /* WOLFSSL_DH_CONST */
  936. #define WOLFSSL_LWIP
  937. #define FREERTOS_TCP
  938. #define FREESCALE_FREE_RTOS
  939. #define FREERTOS_SOCKET_ERROR ( -1 )
  940. #define FREERTOS_EWOULDBLOCK ( -2 )
  941. #define FREERTOS_EINVAL ( -4 )
  942. #define FREERTOS_EADDRNOTAVAIL ( -5 )
  943. #define FREERTOS_EADDRINUSE ( -6 )
  944. #define FREERTOS_ENOBUFS ( -7 )
  945. #define FREERTOS_ENOPROTOOPT ( -8 )
  946. #endif /* FREESCALE_FREE_RTOS || FREESCALE_KSDK_FREERTOS */
  947. #ifdef FREESCALE_KSDK_BM
  948. #define FREESCALE_COMMON
  949. #define WOLFSSL_USER_IO
  950. #define SINGLE_THREADED
  951. #define NO_FILESYSTEM
  952. #ifndef TIME_OVERRIDES
  953. #define USER_TICKS
  954. #endif
  955. #endif /* FREESCALE_KSDK_BM */
  956. #ifdef FREESCALE_COMMON
  957. #define SIZEOF_LONG_LONG 8
  958. /* disable features */
  959. #undef NO_WRITEV
  960. #define NO_WRITEV
  961. #undef NO_DEV_RANDOM
  962. #define NO_DEV_RANDOM
  963. #undef NO_WOLFSSL_DIR
  964. #define NO_WOLFSSL_DIR
  965. #undef NO_RC4
  966. #define NO_RC4
  967. /* enable features */
  968. #define USE_CERT_BUFFERS_2048
  969. #define BENCH_EMBEDDED
  970. #define TFM_TIMING_RESISTANT
  971. #define ECC_TIMING_RESISTANT
  972. #undef HAVE_ECC
  973. #ifndef WOLFCRYPT_FIPS_RAND
  974. #define HAVE_ECC
  975. #endif
  976. #ifndef NO_AES
  977. #undef HAVE_AESCCM
  978. #define HAVE_AESCCM
  979. #undef HAVE_AESGCM
  980. #define HAVE_AESGCM
  981. #undef WOLFSSL_AES_COUNTER
  982. #define WOLFSSL_AES_COUNTER
  983. #undef WOLFSSL_AES_DIRECT
  984. #define WOLFSSL_AES_DIRECT
  985. #endif
  986. #ifdef FREESCALE_KSDK_1_3
  987. #include "fsl_device_registers.h"
  988. #elif !defined(FREESCALE_MQX)
  989. /* Classic MQX does not have fsl_common.h */
  990. #include "fsl_common.h"
  991. #endif
  992. /* random seed */
  993. #define NO_OLD_RNGNAME
  994. #if defined(FREESCALE_NO_RNG)
  995. /* nothing to define */
  996. #elif defined(FSL_FEATURE_SOC_TRNG_COUNT) && (FSL_FEATURE_SOC_TRNG_COUNT > 0)
  997. #define FREESCALE_KSDK_2_0_TRNG
  998. #elif defined(FSL_FEATURE_SOC_RNG_COUNT) && (FSL_FEATURE_SOC_RNG_COUNT > 0)
  999. #ifdef FREESCALE_KSDK_1_3
  1000. #include "fsl_rnga_driver.h"
  1001. #define FREESCALE_RNGA
  1002. #define RNGA_INSTANCE (0)
  1003. #else
  1004. #define FREESCALE_KSDK_2_0_RNGA
  1005. #endif
  1006. #elif !defined(FREESCALE_KSDK_BM) && !defined(FREESCALE_FREE_RTOS) && !defined(FREESCALE_KSDK_FREERTOS)
  1007. #define FREESCALE_RNGA
  1008. #define RNGA_INSTANCE (0)
  1009. /* defaulting to K70 RNGA, user should change if different */
  1010. /* #define FREESCALE_K53_RNGB */
  1011. #define FREESCALE_K70_RNGA
  1012. #endif
  1013. /* HW crypto */
  1014. /* automatic enable based on Kinetis feature */
  1015. /* if case manual selection is required, for example for benchmarking purposes,
  1016. * just define FREESCALE_USE_MMCAU or FREESCALE_USE_LTC or none of these two macros (for software only)
  1017. * both can be enabled simultaneously as LTC has priority over MMCAU in source code.
  1018. */
  1019. /* #define FSL_HW_CRYPTO_MANUAL_SELECTION */
  1020. #ifndef FSL_HW_CRYPTO_MANUAL_SELECTION
  1021. #if defined(FSL_FEATURE_SOC_MMCAU_COUNT) && FSL_FEATURE_SOC_MMCAU_COUNT
  1022. #define FREESCALE_USE_MMCAU
  1023. #endif
  1024. #if defined(FSL_FEATURE_SOC_LTC_COUNT) && FSL_FEATURE_SOC_LTC_COUNT
  1025. #define FREESCALE_USE_LTC
  1026. #endif
  1027. #else
  1028. /* #define FREESCALE_USE_MMCAU */
  1029. /* #define FREESCALE_USE_LTC */
  1030. #endif
  1031. #endif /* FREESCALE_COMMON */
  1032. /* Classic pre-KSDK mmCAU library */
  1033. #ifdef FREESCALE_USE_MMCAU_CLASSIC
  1034. #define FREESCALE_USE_MMCAU
  1035. #define FREESCALE_MMCAU_CLASSIC
  1036. #define FREESCALE_MMCAU_CLASSIC_SHA
  1037. #endif
  1038. /* KSDK mmCAU library */
  1039. #ifdef FREESCALE_USE_MMCAU
  1040. /* AES and DES */
  1041. #define FREESCALE_MMCAU
  1042. /* MD5, SHA-1 and SHA-256 */
  1043. #define FREESCALE_MMCAU_SHA
  1044. #endif /* FREESCALE_USE_MMCAU */
  1045. #ifdef FREESCALE_USE_LTC
  1046. #if defined(FSL_FEATURE_SOC_LTC_COUNT) && FSL_FEATURE_SOC_LTC_COUNT
  1047. #define FREESCALE_LTC
  1048. #define LTC_BASE LTC0
  1049. #if defined(FSL_FEATURE_LTC_HAS_DES) && FSL_FEATURE_LTC_HAS_DES
  1050. #define FREESCALE_LTC_DES
  1051. #endif
  1052. #if defined(FSL_FEATURE_LTC_HAS_GCM) && FSL_FEATURE_LTC_HAS_GCM
  1053. #define FREESCALE_LTC_AES_GCM
  1054. #endif
  1055. #if defined(FSL_FEATURE_LTC_HAS_SHA) && FSL_FEATURE_LTC_HAS_SHA
  1056. #define FREESCALE_LTC_SHA
  1057. #endif
  1058. #if defined(FSL_FEATURE_LTC_HAS_PKHA) && FSL_FEATURE_LTC_HAS_PKHA
  1059. #ifndef WOLFCRYPT_FIPS_RAND
  1060. #define FREESCALE_LTC_ECC
  1061. #endif
  1062. #define FREESCALE_LTC_TFM
  1063. /* the LTC PKHA hardware limit is 2048 bits (256 bytes) for integer arithmetic.
  1064. the LTC_MAX_INT_BYTES defines the size of local variables that hold big integers. */
  1065. /* size is multiplication of 2 big ints */
  1066. #if !defined(NO_RSA) || !defined(NO_DH)
  1067. #define LTC_MAX_INT_BYTES (256*2)
  1068. #else
  1069. #define LTC_MAX_INT_BYTES (48*2)
  1070. #endif
  1071. /* This FREESCALE_LTC_TFM_RSA_4096_ENABLE macro can be defined.
  1072. * In such a case both software and hardware algorithm
  1073. * for TFM is linked in. The decision for which algorithm is used is determined at runtime
  1074. * from size of inputs. If inputs and result can fit into LTC (see LTC_MAX_INT_BYTES)
  1075. * then we call hardware algorithm, otherwise we call software algorithm.
  1076. *
  1077. * Chinese reminder theorem is used to break RSA 4096 exponentiations (both public and private key)
  1078. * into several computations with 2048-bit modulus and exponents.
  1079. */
  1080. /* #define FREESCALE_LTC_TFM_RSA_4096_ENABLE */
  1081. /* ECC-384, ECC-256, ECC-224 and ECC-192 have been enabled with LTC PKHA acceleration */
  1082. #ifdef HAVE_ECC
  1083. #undef ECC_TIMING_RESISTANT
  1084. #define ECC_TIMING_RESISTANT
  1085. /* the LTC PKHA hardware limit is 512 bits (64 bytes) for ECC.
  1086. the LTC_MAX_ECC_BITS defines the size of local variables that hold ECC parameters
  1087. and point coordinates */
  1088. #ifndef LTC_MAX_ECC_BITS
  1089. #define LTC_MAX_ECC_BITS (384)
  1090. #endif
  1091. /* Enable curves up to 384 bits */
  1092. #if !defined(ECC_USER_CURVES) && !defined(HAVE_ALL_CURVES)
  1093. #define ECC_USER_CURVES
  1094. #define HAVE_ECC192
  1095. #define HAVE_ECC224
  1096. #undef NO_ECC256
  1097. #define HAVE_ECC384
  1098. #endif
  1099. #endif
  1100. #endif
  1101. #endif
  1102. #endif /* FREESCALE_USE_LTC */
  1103. #ifdef FREESCALE_LTC_TFM_RSA_4096_ENABLE
  1104. #undef USE_CERT_BUFFERS_4096
  1105. #define USE_CERT_BUFFERS_4096
  1106. #undef FP_MAX_BITS
  1107. #define FP_MAX_BITS (8192)
  1108. #undef SP_INT_BITS
  1109. #define SP_INT_BITS (4096)
  1110. #undef NO_DH
  1111. #define NO_DH
  1112. #undef NO_DSA
  1113. #define NO_DSA
  1114. #endif /* FREESCALE_LTC_TFM_RSA_4096_ENABLE */
  1115. /* if LTC has AES engine but doesn't have GCM, use software with LTC AES ECB mode */
  1116. #if defined(FREESCALE_USE_LTC) && !defined(FREESCALE_LTC_AES_GCM)
  1117. #define GCM_TABLE
  1118. #endif
  1119. #if defined(WOLFSSL_MAXQ1065) || defined(WOLFSSL_MAXQ108X)
  1120. #define MAXQ10XX_MODULE_INIT
  1121. #define HAVE_PK_CALLBACKS
  1122. #define WOLFSSL_STATIC_PSK
  1123. /* Server side support to be added at a later date. */
  1124. #define NO_WOLFSSL_SERVER
  1125. /* Need WOLFSSL_PUBLIC_ASN to use ProcessPeerCert callback. */
  1126. #define WOLFSSL_PUBLIC_ASN
  1127. #ifdef HAVE_PTHREAD
  1128. #define WOLFSSL_CRYPT_HW_MUTEX 1
  1129. #define MAXQ10XX_MUTEX
  1130. #endif
  1131. #define WOLFSSL_MAXQ10XX_CRYPTO
  1132. #define WOLFSSL_MAXQ10XX_TLS
  1133. #if defined(WOLFSSL_MAXQ1065)
  1134. #define MAXQ_DEVICE_ID 1065
  1135. #elif defined(WOLFSSL_MAXQ108X)
  1136. #define MAXQ_DEVICE_ID 1080
  1137. #else
  1138. #error "There is only support for MAXQ1065 or MAXQ1080"
  1139. #endif
  1140. #if defined(WOLFSSL_TICKET_NONCE_MALLOC)
  1141. #error "WOLFSSL_TICKET_NONCE_MALLOC disables the HKDF expand callbacks."
  1142. #endif
  1143. #endif /* WOLFSSL_MAXQ1065 || WOLFSSL_MAXQ108X */
  1144. #if defined(WOLFSSL_STM32F2) || defined(WOLFSSL_STM32F4) || \
  1145. defined(WOLFSSL_STM32F7) || defined(WOLFSSL_STM32F1) || \
  1146. defined(WOLFSSL_STM32L4) || defined(WOLFSSL_STM32L5) || \
  1147. defined(WOLFSSL_STM32WB) || defined(WOLFSSL_STM32H7) || \
  1148. defined(WOLFSSL_STM32G0) || defined(WOLFSSL_STM32U5) || \
  1149. defined(WOLFSSL_STM32H5)
  1150. #define SIZEOF_LONG_LONG 8
  1151. #ifndef CHAR_BIT
  1152. #define CHAR_BIT 8
  1153. #endif
  1154. #define NO_DEV_RANDOM
  1155. #define NO_WOLFSSL_DIR
  1156. #ifndef NO_STM32_RNG
  1157. #undef STM32_RNG
  1158. #define STM32_RNG
  1159. #ifdef WOLFSSL_STM32F427_RNG
  1160. #include "stm32f427xx.h"
  1161. #endif
  1162. #endif
  1163. #ifndef NO_STM32_CRYPTO
  1164. #undef STM32_CRYPTO
  1165. #define STM32_CRYPTO
  1166. #if defined(WOLFSSL_STM32L4) || defined(WOLFSSL_STM32L5) || \
  1167. defined(WOLFSSL_STM32WB) || defined(WOLFSSL_STM32U5)
  1168. #define NO_AES_192 /* hardware does not support 192-bit */
  1169. #endif
  1170. #endif
  1171. #ifndef NO_STM32_HASH
  1172. #undef STM32_HASH
  1173. #define STM32_HASH
  1174. #endif
  1175. #if !defined(__GNUC__) && !defined(__ICCARM__)
  1176. #define KEIL_INTRINSICS
  1177. #endif
  1178. #define NO_OLD_RNGNAME
  1179. #ifdef WOLFSSL_STM32_CUBEMX
  1180. #if defined(WOLFSSL_STM32F1)
  1181. #include "stm32f1xx_hal.h"
  1182. #elif defined(WOLFSSL_STM32F2)
  1183. #include "stm32f2xx_hal.h"
  1184. #elif defined(WOLFSSL_STM32L5)
  1185. #include "stm32l5xx_hal.h"
  1186. #elif defined(WOLFSSL_STM32L4)
  1187. #include "stm32l4xx_hal.h"
  1188. #elif defined(WOLFSSL_STM32F4)
  1189. #include "stm32f4xx_hal.h"
  1190. #elif defined(WOLFSSL_STM32F7)
  1191. #include "stm32f7xx_hal.h"
  1192. #elif defined(WOLFSSL_STM32F1)
  1193. #include "stm32f1xx_hal.h"
  1194. #elif defined(WOLFSSL_STM32H7)
  1195. #include "stm32h7xx_hal.h"
  1196. #elif defined(WOLFSSL_STM32WB)
  1197. #include "stm32wbxx_hal.h"
  1198. #elif defined(WOLFSSL_STM32G0)
  1199. #include "stm32g0xx_hal.h"
  1200. #elif defined(WOLFSSL_STM32U5)
  1201. #include "stm32u5xx_hal.h"
  1202. #elif defined(WOLFSSL_STM32H5)
  1203. #include "stm32h5xx_hal.h"
  1204. #endif
  1205. #if defined(WOLFSSL_CUBEMX_USE_LL) && defined(WOLFSSL_STM32L4)
  1206. #include "stm32l4xx_ll_rng.h"
  1207. #endif
  1208. #ifndef STM32_HAL_TIMEOUT
  1209. #define STM32_HAL_TIMEOUT 0xFF
  1210. #endif
  1211. #else
  1212. #if defined(WOLFSSL_STM32F2)
  1213. #include "stm32f2xx.h"
  1214. #ifdef STM32_CRYPTO
  1215. #include "stm32f2xx_cryp.h"
  1216. #endif
  1217. #ifdef STM32_HASH
  1218. #include "stm32f2xx_hash.h"
  1219. #endif
  1220. #elif defined(WOLFSSL_STM32F4)
  1221. #include "stm32f4xx.h"
  1222. #ifdef STM32_CRYPTO
  1223. #include "stm32f4xx_cryp.h"
  1224. #endif
  1225. #ifdef STM32_HASH
  1226. #include "stm32f4xx_hash.h"
  1227. #endif
  1228. #elif defined(WOLFSSL_STM32L5)
  1229. #include "stm32l5xx.h"
  1230. #ifdef STM32_CRYPTO
  1231. #include "stm32l5xx_cryp.h"
  1232. #endif
  1233. #ifdef STM32_HASH
  1234. #include "stm32l5xx_hash.h"
  1235. #endif
  1236. #elif defined(WOLFSSL_STM32L4)
  1237. #include "stm32l4xx.h"
  1238. #ifdef STM32_CRYPTO
  1239. #include "stm32l4xx_cryp.h"
  1240. #endif
  1241. #ifdef STM32_HASH
  1242. #include "stm32l4xx_hash.h"
  1243. #endif
  1244. #elif defined(WOLFSSL_STM32F7)
  1245. #include "stm32f7xx.h"
  1246. #elif defined(WOLFSSL_STM32H7)
  1247. #include "stm32h7xx.h"
  1248. #elif defined(WOLFSSL_STM32F1)
  1249. #include "stm32f1xx.h"
  1250. #endif
  1251. #endif /* WOLFSSL_STM32_CUBEMX */
  1252. #endif /* WOLFSSL_STM32F2 || WOLFSSL_STM32F4 || WOLFSSL_STM32L4 ||
  1253. WOLFSSL_STM32L5 || WOLFSSL_STM32F7 || WOLFSSL_STMWB ||
  1254. WOLFSSL_STM32H7 || WOLFSSL_STM32G0 || WOLFSSL_STM32U5 ||
  1255. WOLFSSL_STM32H5 */
  1256. #ifdef WOLFSSL_DEOS
  1257. #include <deos.h>
  1258. #include <timeout.h>
  1259. #include <socketapi.h>
  1260. #include <lwip-socket.h>
  1261. #include <mem.h>
  1262. #include <string.h>
  1263. #include <stdlib.h> /* for rand_r: pseudo-random number generator */
  1264. #include <stdio.h> /* for snprintf */
  1265. /* use external memory XMALLOC, XFREE and XREALLOC functions */
  1266. #define XMALLOC_USER
  1267. /* disable fall-back case, malloc, realloc and free are unavailable */
  1268. #define WOLFSSL_NO_MALLOC
  1269. /* file system has not been ported since it is a separate product. */
  1270. #define NO_FILESYSTEM
  1271. #ifdef NO_FILESYSTEM
  1272. #define NO_WOLFSSL_DIR
  1273. #define NO_WRITEV
  1274. #endif
  1275. #define TFM_TIMING_RESISTANT
  1276. #define ECC_TIMING_RESISTANT
  1277. #define WC_RSA_BLINDING
  1278. #define HAVE_ECC
  1279. #define TFM_ECC192
  1280. #define TFM_ECC224
  1281. #define TFM_ECC256
  1282. #define TFM_ECC384
  1283. #define TFM_ECC521
  1284. #define HAVE_TLS_EXTENSIONS
  1285. #define HAVE_SUPPORTED_CURVES
  1286. #define HAVE_EXTENDED_MASTER
  1287. #if (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
  1288. #define BIG_ENDIAN_ORDER
  1289. #else
  1290. #undef BIG_ENDIAN_ORDER
  1291. #define LITTLE_ENDIAN_ORDER
  1292. #endif
  1293. #endif /* WOLFSSL_DEOS*/
  1294. #ifdef MICRIUM
  1295. #include <stdlib.h>
  1296. #include <os.h>
  1297. #if defined(RTOS_MODULE_NET_AVAIL) || (APP_CFG_TCPIP_EN == DEF_ENABLED)
  1298. #include <net_cfg.h>
  1299. #include <net_sock.h>
  1300. #if (OS_VERSION < 50000)
  1301. #include <net_err.h>
  1302. #endif
  1303. #endif
  1304. #include <lib_mem.h>
  1305. #include <lib_math.h>
  1306. #include <lib_str.h>
  1307. #include <stdio.h>
  1308. #include <string.h>
  1309. #define TFM_TIMING_RESISTANT
  1310. #define ECC_TIMING_RESISTANT
  1311. #define WC_RSA_BLINDING
  1312. #define HAVE_HASHDRBG
  1313. #define HAVE_ECC
  1314. #if !defined(WOLFSSL_STATIC_MEMORY) && !defined(WOLFSSL_NO_MALLOC)
  1315. #define ALT_ECC_SIZE
  1316. #endif
  1317. #define TFM_ECC192
  1318. #define TFM_ECC224
  1319. #define TFM_ECC256
  1320. #define TFM_ECC384
  1321. #define TFM_ECC521
  1322. #define NO_RC4
  1323. #define HAVE_TLS_EXTENSIONS
  1324. #define HAVE_SUPPORTED_CURVES
  1325. #define HAVE_EXTENDED_MASTER
  1326. #define NO_WOLFSSL_DIR
  1327. #define NO_WRITEV
  1328. #if !defined(WOLFSSL_SILABS_SE_ACCEL) && !defined(STM32_RNG) && \
  1329. !defined(CUSTOM_RAND_GENERATE)
  1330. #define CUSTOM_RAND_TYPE RAND_NBR
  1331. #define CUSTOM_RAND_GENERATE Math_Rand
  1332. #endif
  1333. #define STRING_USER
  1334. #define XSTRCASECMP(s1,s2) strcasecmp((s1),(s2))
  1335. #define XSTRCMP(s1,s2) strcmp((s1),(s2))
  1336. #define XSTRLEN(pstr) ((CPU_SIZE_T)Str_Len((CPU_CHAR *)(pstr)))
  1337. #define XSTRNCPY(pstr_dest, pstr_src, len_max) \
  1338. ((CPU_CHAR *)Str_Copy_N((CPU_CHAR *)(pstr_dest), \
  1339. (CPU_CHAR *)(pstr_src), (CPU_SIZE_T)(len_max)))
  1340. #define XSTRNCMP(pstr_1, pstr_2, len_max) \
  1341. ((CPU_INT16S)Str_Cmp_N((CPU_CHAR *)(pstr_1), \
  1342. (CPU_CHAR *)(pstr_2), (CPU_SIZE_T)(len_max)))
  1343. #define XSTRNCASECMP(pstr_1, pstr_2, len_max) \
  1344. ((CPU_INT16S)Str_CmpIgnoreCase_N((CPU_CHAR *)(pstr_1), \
  1345. (CPU_CHAR *)(pstr_2), (CPU_SIZE_T)(len_max)))
  1346. #define XSTRSTR(pstr, pstr_srch) \
  1347. ((CPU_CHAR *)Str_Str((CPU_CHAR *)(pstr), \
  1348. (CPU_CHAR *)(pstr_srch)))
  1349. #define XSTRNSTR(pstr, pstr_srch, len_max) \
  1350. ((CPU_CHAR *)Str_Str_N((CPU_CHAR *)(pstr), \
  1351. (CPU_CHAR *)(pstr_srch),(CPU_SIZE_T)(len_max)))
  1352. #define XSTRNCAT(pstr_dest, pstr_cat, len_max) \
  1353. ((CPU_CHAR *)Str_Cat_N((CPU_CHAR *)(pstr_dest), \
  1354. (const CPU_CHAR *)(pstr_cat),(CPU_SIZE_T)(len_max)))
  1355. #ifndef XATOI /* if custom XATOI is not already defined */
  1356. #define XATOI(s) atoi((s))
  1357. #endif
  1358. #if defined(USE_WOLF_STRTOK)
  1359. #define XSTRTOK(s1, d, ptr) wc_strtok((s1), (d), (ptr))
  1360. #else
  1361. #define XSTRTOK(s1, d, ptr) strtok_r((s1), (d), (ptr))
  1362. #endif
  1363. #define XMEMSET(pmem, data_val, size) \
  1364. ((void)Mem_Set((void *)(pmem), \
  1365. (CPU_INT08U) (data_val), \
  1366. (CPU_SIZE_T)(size)))
  1367. #define XMEMCPY(pdest, psrc, size) ((void)Mem_Copy((void *)(pdest), \
  1368. (void *)(psrc), (CPU_SIZE_T)(size)))
  1369. #if (OS_VERSION < 50000)
  1370. #define XMEMCMP(pmem_1, pmem_2, size) \
  1371. (((CPU_BOOLEAN)Mem_Cmp((void *)(pmem_1), \
  1372. (void *)(pmem_2), \
  1373. (CPU_SIZE_T)(size))) ? DEF_NO : DEF_YES)
  1374. #else
  1375. /* Work around for Micrium OS version 5.8 change in behavior
  1376. * that returns DEF_NO for 0 size compare
  1377. */
  1378. #define XMEMCMP(pmem_1, pmem_2, size) \
  1379. (( (size < 1 ) || \
  1380. ((CPU_BOOLEAN)Mem_Cmp((void *)(pmem_1), \
  1381. (void *)(pmem_2), \
  1382. (CPU_SIZE_T)(size)) == DEF_YES)) \
  1383. ? 0 : 1)
  1384. #define XSNPRINTF snprintf
  1385. #endif
  1386. #define XMEMMOVE(pdest, psrc, size) ((void)Mem_Move((void *)(pdest), \
  1387. (void *)(psrc), (CPU_SIZE_T)(size)))
  1388. #if (OS_CFG_MUTEX_EN == DEF_DISABLED)
  1389. #define SINGLE_THREADED
  1390. #endif
  1391. #if (CPU_CFG_ENDIAN_TYPE == CPU_ENDIAN_TYPE_BIG)
  1392. #define BIG_ENDIAN_ORDER
  1393. #else
  1394. #undef BIG_ENDIAN_ORDER
  1395. #define LITTLE_ENDIAN_ORDER
  1396. #endif
  1397. #endif /* MICRIUM */
  1398. #if defined(sun) || defined(__sun)
  1399. # if defined(__SVR4) || defined(__svr4__)
  1400. /* Solaris */
  1401. #ifndef WOLFSSL_SOLARIS
  1402. #define WOLFSSL_SOLARIS
  1403. #endif
  1404. # else
  1405. /* SunOS */
  1406. # endif
  1407. #endif
  1408. #ifdef WOLFSSL_SOLARIS
  1409. /* Avoid naming clash with fp_zero from math.h > ieefp.h */
  1410. #define WOLFSSL_DH_CONST
  1411. #endif
  1412. #ifdef WOLFSSL_MCF5441X
  1413. #define BIG_ENDIAN_ORDER
  1414. #ifndef SIZEOF_LONG
  1415. #define SIZEOF_LONG 4
  1416. #endif
  1417. #ifndef SIZEOF_LONG_LONG
  1418. #define SIZEOF_LONG_LONG 8
  1419. #endif
  1420. #endif
  1421. #ifdef WOLFSSL_QL
  1422. #ifndef WOLFSSL_SEP
  1423. #define WOLFSSL_SEP
  1424. #endif
  1425. #ifndef OPENSSL_EXTRA
  1426. #define OPENSSL_EXTRA
  1427. #endif
  1428. #ifndef SESSION_CERTS
  1429. #define SESSION_CERTS
  1430. #endif
  1431. #ifndef HAVE_AESCCM
  1432. #define HAVE_AESCCM
  1433. #endif
  1434. #ifndef ATOMIC_USER
  1435. #define ATOMIC_USER
  1436. #endif
  1437. #ifndef WOLFSSL_DER_LOAD
  1438. #define WOLFSSL_DER_LOAD
  1439. #endif
  1440. #ifndef KEEP_PEER_CERT
  1441. #define KEEP_PEER_CERT
  1442. #endif
  1443. #ifndef HAVE_ECC
  1444. #define HAVE_ECC
  1445. #endif
  1446. #ifndef SESSION_INDEX
  1447. #define SESSION_INDEX
  1448. #endif
  1449. #endif /* WOLFSSL_QL */
  1450. #if defined(WOLFSSL_XILINX)
  1451. #if !defined(WOLFSSL_XILINX_CRYPT_VERSAL)
  1452. #define NO_DEV_RANDOM
  1453. #endif
  1454. #define NO_WOLFSSL_DIR
  1455. #define HAVE_AESGCM
  1456. #endif
  1457. #if defined(WOLFSSL_XILINX_CRYPT) || defined(WOLFSSL_AFALG_XILINX)
  1458. #if defined(WOLFSSL_ARMASM)
  1459. #error can not use both ARMv8 instructions and XILINX hardened crypto
  1460. #endif
  1461. #if defined(WOLFSSL_SHA3)
  1462. /* only SHA3-384 is supported */
  1463. #undef WOLFSSL_NOSHA3_224
  1464. #undef WOLFSSL_NOSHA3_256
  1465. #undef WOLFSSL_NOSHA3_512
  1466. #define WOLFSSL_NOSHA3_224
  1467. #define WOLFSSL_NOSHA3_256
  1468. #define WOLFSSL_NOSHA3_512
  1469. #endif
  1470. #ifdef WOLFSSL_AFALG_XILINX_AES
  1471. #undef WOLFSSL_AES_DIRECT
  1472. #define WOLFSSL_AES_DIRECT
  1473. #endif
  1474. #endif /*(WOLFSSL_XILINX_CRYPT)*/
  1475. #ifdef WOLFSSL_KCAPI_AES
  1476. #define WOLFSSL_AES_GCM_FIXED_IV_AAD
  1477. #endif
  1478. #ifdef WOLFSSL_KCAPI_ECC
  1479. #undef ECC_USER_CURVES
  1480. #define ECC_USER_CURVES
  1481. #undef NO_ECC256
  1482. #undef HAVE_ECC384
  1483. #define HAVE_ECC384
  1484. #undef HAVE_ECC521
  1485. #define HAVE_ECC521
  1486. #endif
  1487. #if defined(WOLFSSL_APACHE_MYNEWT)
  1488. #include "os/os_malloc.h"
  1489. #if !defined(WOLFSSL_LWIP)
  1490. #include <mn_socket/mn_socket.h>
  1491. #endif
  1492. #if !defined(SIZEOF_LONG)
  1493. #define SIZEOF_LONG 4
  1494. #endif
  1495. #if !defined(SIZEOF_LONG_LONG)
  1496. #define SIZEOF_LONG_LONG 8
  1497. #endif
  1498. #if (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
  1499. #define BIG_ENDIAN_ORDER
  1500. #else
  1501. #undef BIG_ENDIAN_ORDER
  1502. #define LITTLE_ENDIAN_ORDER
  1503. #endif
  1504. #define NO_WRITEV
  1505. #define WOLFSSL_USER_IO
  1506. #define SINGLE_THREADED
  1507. #define NO_DEV_RANDOM
  1508. #define NO_DH
  1509. #define NO_WOLFSSL_DIR
  1510. #define NO_ERROR_STRINGS
  1511. #define HAVE_ECC
  1512. #define NO_SESSION_CACHE
  1513. #define NO_ERROR_STRINGS
  1514. #define XMALLOC_USER
  1515. #define XMALLOC(sz, heap, type) os_malloc(sz)
  1516. #define XREALLOC(p, sz, heap, type) os_realloc(p, sz)
  1517. #define XFREE(p, heap, type) os_free(p)
  1518. #endif /*(WOLFSSL_APACHE_MYNEWT)*/
  1519. #ifdef WOLFSSL_ZEPHYR
  1520. #include <zephyr/kernel.h>
  1521. #include <zephyr/sys/printk.h>
  1522. #include <zephyr/sys/util.h>
  1523. #include <stdlib.h>
  1524. #define WOLFSSL_DH_CONST
  1525. #define WOLFSSL_HAVE_MAX
  1526. #define NO_WRITEV
  1527. #define USE_FLAT_BENCHMARK_H
  1528. #define USE_FLAT_TEST_H
  1529. #define EXIT_FAILURE 1
  1530. #define MAIN_NO_ARGS
  1531. void *z_realloc(void *ptr, size_t size);
  1532. #define realloc z_realloc
  1533. #ifndef CONFIG_NET_SOCKETS_POSIX_NAMES
  1534. #define CONFIG_NET_SOCKETS_POSIX_NAMES
  1535. #endif
  1536. #endif
  1537. #ifdef WOLFSSL_IMX6
  1538. #ifndef SIZEOF_LONG_LONG
  1539. #define SIZEOF_LONG_LONG 8
  1540. #endif
  1541. #endif
  1542. /* Setting supported CAAM algorithms */
  1543. #ifdef WOLFSSL_IMX6Q_CAAM
  1544. #undef WOLFSSL_CAAM
  1545. #define WOLFSSL_CAAM
  1546. /* hardware does not support AES-GCM and ECC
  1547. * has the low power AES module only (no high power with GCM) */
  1548. #define WOLFSSL_LP_ONLY_CAAM_AES
  1549. #define WOLFSSL_NO_CAAM_ECC
  1550. #endif
  1551. #ifdef WOLFSSL_SECO_CAAM
  1552. #define WOLFSSL_CAAM
  1553. #define WOLFSSL_HASH_KEEP
  1554. #define WOLFSSL_NO_CAAM_BLOB
  1555. #endif
  1556. #ifdef WOLFSSL_IMXRT1170_CAAM
  1557. #define WOLFSSL_CAAM
  1558. #endif
  1559. /* OS specific support so far */
  1560. #ifdef WOLFSSL_QNX_CAAM
  1561. /* shim layer for QNX hashing not yet implemented */
  1562. #define WOLFSSL_NO_CAAM_HASH
  1563. #endif
  1564. #ifdef WOLFSSL_CAAM
  1565. /* switch for all AES type algos */
  1566. #undef WOLFSSL_CAAM_CIPHER
  1567. #define WOLFSSL_CAAM_CIPHER
  1568. #ifdef WOLFSSL_CAAM_CIPHER
  1569. #ifndef WOLFSSL_LP_ONLY_CAAM_AES
  1570. /* GCM and XTS mode are only available in the high power module */
  1571. #define WOLFSSL_CAAM_AESGCM
  1572. #define WOLFSSL_CAAM_AESXTS
  1573. #endif
  1574. #define WOLFSSL_CAAM_AESCCM
  1575. #define WOLFSSL_CAAM_AESCTR
  1576. #define WOLFSSL_CAAM_AESCBC
  1577. #define WOLFSSL_CAAM_CMAC
  1578. #endif /* WOLFSSL_CAAM_CIPHER */
  1579. #if defined(HAVE_AESGCM) || defined(WOLFSSL_AES_XTS) || \
  1580. defined(WOLFSSL_CMAC)
  1581. /* large performance gain with HAVE_AES_ECB defined */
  1582. #undef HAVE_AES_ECB
  1583. #define HAVE_AES_ECB
  1584. /* @TODO used for now until plugging in caam aes use with qnx */
  1585. #undef WOLFSSL_AES_DIRECT
  1586. #define WOLFSSL_AES_DIRECT
  1587. #endif
  1588. /* switch for all hashing algos */
  1589. #ifndef WOLFSSL_NO_CAAM_HASH
  1590. #define WOLFSSL_CAAM_HASH
  1591. #endif
  1592. #if defined(WOLFSSL_DEVCRYPTO_HMAC)
  1593. /* HMAC is through the devcrypto calls */
  1594. #define WOLFSSL_CAAM_HMAC
  1595. #endif
  1596. /* public key operations */
  1597. #ifndef WOLFSSL_NO_CAAM_ECC
  1598. #undef WOLFSSL_CAAM_ECC
  1599. #define WOLFSSL_CAAM_ECC
  1600. #endif
  1601. /* so far curve25519 support was only done with the SECO */
  1602. #ifdef WOLFSSL_SECO_CAAM
  1603. #define WOLFSSL_CAAM_CURVE25519
  1604. #endif
  1605. /* Blob support */
  1606. #ifndef WOLFSSL_NO_CAAM_BLOB
  1607. #define WOLFSSL_CAAM_BLOB
  1608. #endif
  1609. #endif
  1610. #ifdef _MSC_VER
  1611. #ifndef HAVE_SSIZE_T
  1612. #include <BaseTsd.h>
  1613. typedef SSIZE_T ssize_t;
  1614. #endif
  1615. #endif
  1616. /* If DCP is used without SINGLE_THREADED, enforce WOLFSSL_CRYPT_HW_MUTEX */
  1617. #if defined(WOLFSSL_IMXRT_DCP) && !defined(SINGLE_THREADED)
  1618. #undef WOLFSSL_CRYPT_HW_MUTEX
  1619. #define WOLFSSL_CRYPT_HW_MUTEX 1
  1620. #endif
  1621. #if !defined(XMALLOC_USER) && !defined(MICRIUM_MALLOC) && \
  1622. !defined(WOLFSSL_LEANPSK) && !defined(NO_WOLFSSL_MEMORY) && \
  1623. !defined(XMALLOC_OVERRIDE)
  1624. #define USE_WOLFSSL_MEMORY
  1625. #endif
  1626. #ifdef WOLFSSL_EMBOS
  1627. #include "RTOS.h"
  1628. #if !defined(XMALLOC_USER) && !defined(NO_WOLFSSL_MEMORY) && \
  1629. !defined(WOLFSSL_STATIC_MEMORY)
  1630. #define XMALLOC(s, h, type) OS_HEAP_malloc((s))
  1631. #define XFREE(p, h, type) OS_HEAP_free((p))
  1632. #define XREALLOC(p, n, h, t) OS_HEAP_realloc(((p), (n))
  1633. #endif
  1634. #endif
  1635. #if defined(OPENSSL_EXTRA) && !defined(NO_CERTS)
  1636. #undef KEEP_PEER_CERT
  1637. #define KEEP_PEER_CERT
  1638. #endif
  1639. /* stream ciphers except arc4 need 32bit alignment, intel ok without */
  1640. #ifndef XSTREAM_ALIGN
  1641. #if defined(__x86_64__) || defined(__ia64__) || defined(__i386__)
  1642. #define NO_XSTREAM_ALIGN
  1643. #else
  1644. #define XSTREAM_ALIGN
  1645. #endif
  1646. #endif
  1647. /* write dup cannot be used with secure renegotiation because write dup
  1648. * make write side write only and read side read only */
  1649. #if defined(HAVE_WRITE_DUP) && defined(HAVE_SECURE_RENEGOTIATION)
  1650. #error "WRITE DUP and SECURE RENEGOTIATION cannot both be on"
  1651. #endif
  1652. #ifdef WOLFSSL_SGX
  1653. #ifdef _MSC_VER
  1654. #define NO_RC4
  1655. #ifndef HAVE_FIPS
  1656. #define WOLFCRYPT_ONLY
  1657. #define NO_DES3
  1658. #define NO_SHA
  1659. #define NO_MD5
  1660. #else
  1661. #define TFM_TIMING_RESISTANT
  1662. #define NO_WOLFSSL_DIR
  1663. #define NO_WRITEV
  1664. #define NO_MAIN_DRIVER
  1665. #define WOLFSSL_LOG_PRINTF
  1666. #define WOLFSSL_DH_CONST
  1667. #endif
  1668. #else
  1669. #define HAVE_ECC
  1670. #define NO_WRITEV
  1671. #define NO_MAIN_DRIVER
  1672. #define USER_TICKS
  1673. #define WOLFSSL_LOG_PRINTF
  1674. #define WOLFSSL_DH_CONST
  1675. #endif /* _MSC_VER */
  1676. #if !defined(HAVE_FIPS) && !defined(NO_RSA)
  1677. #define WC_RSA_BLINDING
  1678. #endif
  1679. #define NO_FILESYSTEM
  1680. #define ECC_TIMING_RESISTANT
  1681. #define TFM_TIMING_RESISTANT
  1682. #define SINGLE_THREADED
  1683. #define NO_ASN_TIME /* can not use headers such as windows.h */
  1684. #define HAVE_AESGCM
  1685. #define USE_CERT_BUFFERS_2048
  1686. #endif /* WOLFSSL_SGX */
  1687. /* FreeScale MMCAU hardware crypto has 4 byte alignment.
  1688. However, KSDK fsl_mmcau.h gives API with no alignment
  1689. requirements (4 byte alignment is managed internally by fsl_mmcau.c) */
  1690. #ifdef FREESCALE_MMCAU
  1691. #ifdef FREESCALE_MMCAU_CLASSIC
  1692. #define WOLFSSL_MMCAU_ALIGNMENT 4
  1693. #else
  1694. #define WOLFSSL_MMCAU_ALIGNMENT 0
  1695. #endif
  1696. #endif
  1697. /* if using hardware crypto and have alignment requirements, specify the
  1698. requirement here. The record header of SSL/TLS will prevent easy alignment.
  1699. This hint tries to help as much as possible. */
  1700. #ifndef WOLFSSL_GENERAL_ALIGNMENT
  1701. #ifdef WOLFSSL_AESNI
  1702. #define WOLFSSL_GENERAL_ALIGNMENT 16
  1703. #elif defined(XSTREAM_ALIGN)
  1704. #define WOLFSSL_GENERAL_ALIGNMENT 4
  1705. #elif defined(FREESCALE_MMCAU) || defined(FREESCALE_MMCAU_CLASSIC)
  1706. #define WOLFSSL_GENERAL_ALIGNMENT WOLFSSL_MMCAU_ALIGNMENT
  1707. #else
  1708. #define WOLFSSL_GENERAL_ALIGNMENT 0
  1709. #endif
  1710. #endif
  1711. #if defined(WOLFSSL_GENERAL_ALIGNMENT) && (WOLFSSL_GENERAL_ALIGNMENT > 0)
  1712. #if defined(_MSC_VER)
  1713. #define XGEN_ALIGN __declspec(align(WOLFSSL_GENERAL_ALIGNMENT))
  1714. #elif defined(__GNUC__)
  1715. #define XGEN_ALIGN __attribute__((aligned(WOLFSSL_GENERAL_ALIGNMENT)))
  1716. #else
  1717. #define XGEN_ALIGN
  1718. #endif
  1719. #else
  1720. #define XGEN_ALIGN
  1721. #endif
  1722. #if defined(__mips) || defined(__mips64) || \
  1723. defined(WOLFSSL_SP_MIPS64) || defined(WOLFSSL_SP_MIPS)
  1724. #undef WOLFSSL_SP_INT_DIGIT_ALIGN
  1725. #define WOLFSSL_SP_INT_DIGIT_ALIGN
  1726. #endif
  1727. #ifdef __APPLE__
  1728. #define WOLFSSL_SP_NO_DYN_STACK
  1729. #endif
  1730. #ifdef __INTEL_COMPILER
  1731. #pragma warning(disable:2259) /* explicit casts to smaller sizes, disable */
  1732. #endif
  1733. /* ---------------------------------------------------------------------------
  1734. * Math Library Selection (in order of preference)
  1735. * ---------------------------------------------------------------------------
  1736. */
  1737. #if !defined(HAVE_FIPS_VERSION) || \
  1738. (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 5))
  1739. #if defined(WOLFSSL_SP_MATH_ALL)
  1740. /* 1) SP Math: wolfSSL proprietary math implementation (sp_int.c).
  1741. * Constant time: Always
  1742. * Enable: WOLFSSL_SP_MATH_ALL
  1743. */
  1744. #elif defined(WOLFSSL_SP_MATH)
  1745. /* 2) SP Math with restricted key sizes: wolfSSL proprietary math
  1746. * implementation (sp_*.c).
  1747. * Constant time: Always
  1748. * Enable: WOLFSSL_SP_MATH
  1749. */
  1750. #elif defined(USE_FAST_MATH)
  1751. /* 3) Tom's Fast Math: Stack based (tfm.c)
  1752. * Constant time: Only with TFM_TIMING_RESISTANT
  1753. * Enable: USE_FAST_MATH
  1754. */
  1755. #elif defined(USE_INTEGER_HEAP_MATH)
  1756. /* 4) Integer Heap Math: Heap based (integer.c)
  1757. * Constant time: Not supported
  1758. * Enable: USE_INTEGER_HEAP_MATH
  1759. */
  1760. #elif defined(NO_BIG_INT)
  1761. /* 5) No big integer math libraries
  1762. */
  1763. #else
  1764. /* default is SP Math. */
  1765. #define WOLFSSL_SP_MATH_ALL
  1766. #endif
  1767. #else
  1768. /* FIPS 140-2 or older */
  1769. /* Default to fast math (tfm.c), but allow heap math (integer.c) */
  1770. #if !defined(USE_INTEGER_HEAP_MATH)
  1771. #undef USE_FAST_MATH
  1772. #define USE_FAST_MATH
  1773. #ifndef FP_MAX_BITS
  1774. #define FP_MAX_BITS 8192
  1775. #endif
  1776. #endif
  1777. #endif
  1778. /* Verify that only one of the above multi-precision math libraries is enabled */
  1779. #if (defined(WOLFSSL_SP_MATH_ALL) && \
  1780. (defined(USE_FAST_MATH) || defined(USE_INTEGER_HEAP_MATH))) || \
  1781. (defined(USE_FAST_MATH) && defined(USE_INTEGER_HEAP_MATH))
  1782. #error Cannot enable more than one multiple precision math library!
  1783. #endif
  1784. /*----------------------------------------------------------------------------*/
  1785. /* user can specify what curves they want with ECC_USER_CURVES otherwise
  1786. * all curves are on by default for now */
  1787. #ifndef ECC_USER_CURVES
  1788. #ifdef WOLFSSL_SP_MATH
  1789. /* for single precision math only make sure the enabled key sizes are
  1790. * included in the ECC curve table */
  1791. #if defined(WOLFSSL_SP_384) && !defined(HAVE_ECC384)
  1792. #define HAVE_ECC384
  1793. #endif
  1794. #if defined(WOLFSSL_SP_521) && !defined(HAVE_ECC521)
  1795. #define HAVE_ECC521
  1796. #endif
  1797. #elif !defined(HAVE_ALL_CURVES)
  1798. #define HAVE_ALL_CURVES
  1799. #endif
  1800. #endif
  1801. /* The minimum allowed ECC key size */
  1802. /* Note: 224-bits is equivalent to 2048-bit RSA */
  1803. #ifndef ECC_MIN_KEY_SZ
  1804. #ifdef WOLFSSL_MIN_ECC_BITS
  1805. #define ECC_MIN_KEY_SZ WOLFSSL_MIN_ECC_BITS
  1806. #else
  1807. #if defined(WOLFSSL_HARDEN_TLS) && \
  1808. !defined(WOLFSSL_HARDEN_TLS_NO_PKEY_CHECK)
  1809. /* Using guidance from section 5.6.1
  1810. * https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r5.pdf */
  1811. #if WOLFSSL_HARDEN_TLS >= 128
  1812. #define ECC_MIN_KEY_SZ 256
  1813. #elif WOLFSSL_HARDEN_TLS >= 112
  1814. #define ECC_MIN_KEY_SZ 224
  1815. #endif
  1816. #elif FIPS_VERSION_GE(2,0)
  1817. /* FIPSv2 and ready (for now) includes 192-bit support */
  1818. #define ECC_MIN_KEY_SZ 192
  1819. #else
  1820. #define ECC_MIN_KEY_SZ 224
  1821. #endif
  1822. #endif
  1823. #endif
  1824. #if defined(WOLFSSL_HARDEN_TLS) && ECC_MIN_KEY_SZ < 224 && \
  1825. !defined(WOLFSSL_HARDEN_TLS_NO_PKEY_CHECK)
  1826. /* Implementations MUST NOT negotiate cipher suites offering less than
  1827. * 112 bits of security.
  1828. * https://www.rfc-editor.org/rfc/rfc9325#section-4.1
  1829. * Using guidance from section 5.6.1
  1830. * https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r5.pdf */
  1831. #error "For 112 bits of security ECC needs at least 224 bit keys"
  1832. #endif
  1833. /* ECC Configs */
  1834. #ifdef HAVE_ECC
  1835. /* By default enable Sign, Verify, DHE, Key Import and Key Export unless
  1836. * explicitly disabled */
  1837. #if !defined(NO_ECC_SIGN) && \
  1838. (!defined(ECC_TIMING_RESISTANT) || \
  1839. (defined(ECC_TIMING_RESISTANT) && !defined(WC_NO_RNG)))
  1840. #undef HAVE_ECC_SIGN
  1841. #define HAVE_ECC_SIGN
  1842. #endif
  1843. #ifndef NO_ECC_VERIFY
  1844. #undef HAVE_ECC_VERIFY
  1845. #define HAVE_ECC_VERIFY
  1846. #endif
  1847. #ifndef NO_ECC_CHECK_KEY
  1848. #undef HAVE_ECC_CHECK_KEY
  1849. #define HAVE_ECC_CHECK_KEY
  1850. #endif
  1851. #if !defined(NO_ECC_DHE) && !defined(WC_NO_RNG)
  1852. #undef HAVE_ECC_DHE
  1853. #define HAVE_ECC_DHE
  1854. #endif
  1855. #ifndef NO_ECC_KEY_IMPORT
  1856. #undef HAVE_ECC_KEY_IMPORT
  1857. #define HAVE_ECC_KEY_IMPORT
  1858. #endif
  1859. /* The ECC key export requires mp_int or SP */
  1860. #if (!defined(NO_ECC_KEY_EXPORT) && defined(WOLFSSL_SP_MATH)) || \
  1861. (!defined(NO_ECC_KEY_EXPORT) && !defined(NO_BIG_INT))
  1862. #undef HAVE_ECC_KEY_EXPORT
  1863. #define HAVE_ECC_KEY_EXPORT
  1864. #endif
  1865. #endif /* HAVE_ECC */
  1866. #if defined(OPENSSL_EXTRA) && defined(HAVE_ECC) && \
  1867. !defined(WOLFSSL_ATECC508A) && !defined(WOLFSSL_ATECC608A) && \
  1868. !defined(WOLFSSL_CRYPTOCELL) && !defined(WOLFSSL_SE050) && \
  1869. !defined(WOLF_CRYPTO_CB_ONLY_ECC) && !defined(WOLFSSL_STM32_PKA)
  1870. #undef USE_ECC_B_PARAM
  1871. #define USE_ECC_B_PARAM
  1872. #endif
  1873. /* Curve25519 Configs */
  1874. #ifdef HAVE_CURVE25519
  1875. /* By default enable shared secret, key export and import */
  1876. #ifndef NO_CURVE25519_SHARED_SECRET
  1877. #undef HAVE_CURVE25519_SHARED_SECRET
  1878. #define HAVE_CURVE25519_SHARED_SECRET
  1879. #endif
  1880. #ifndef NO_CURVE25519_KEY_EXPORT
  1881. #undef HAVE_CURVE25519_KEY_EXPORT
  1882. #define HAVE_CURVE25519_KEY_EXPORT
  1883. #endif
  1884. #ifndef NO_CURVE25519_KEY_IMPORT
  1885. #undef HAVE_CURVE25519_KEY_IMPORT
  1886. #define HAVE_CURVE25519_KEY_IMPORT
  1887. #endif
  1888. #endif /* HAVE_CURVE25519 */
  1889. /* Ed25519 Configs */
  1890. #ifdef HAVE_ED25519
  1891. /* By default enable sign, verify, key export and import */
  1892. #ifndef NO_ED25519_SIGN
  1893. #undef HAVE_ED25519_SIGN
  1894. #define HAVE_ED25519_SIGN
  1895. #endif
  1896. #ifndef NO_ED25519_VERIFY
  1897. #undef HAVE_ED25519_VERIFY
  1898. #define HAVE_ED25519_VERIFY
  1899. #ifdef WOLFSSL_ED25519_STREAMING_VERIFY
  1900. #undef WOLFSSL_ED25519_PERSISTENT_SHA
  1901. #define WOLFSSL_ED25519_PERSISTENT_SHA
  1902. #endif
  1903. #endif
  1904. #ifndef NO_ED25519_KEY_EXPORT
  1905. #undef HAVE_ED25519_KEY_EXPORT
  1906. #define HAVE_ED25519_KEY_EXPORT
  1907. #endif
  1908. #ifndef NO_ED25519_KEY_IMPORT
  1909. #undef HAVE_ED25519_KEY_IMPORT
  1910. #define HAVE_ED25519_KEY_IMPORT
  1911. #endif
  1912. #endif /* HAVE_ED25519 */
  1913. /* Curve448 Configs */
  1914. #ifdef HAVE_CURVE448
  1915. /* By default enable shared secret, key export and import */
  1916. #ifndef NO_CURVE448_SHARED_SECRET
  1917. #undef HAVE_CURVE448_SHARED_SECRET
  1918. #define HAVE_CURVE448_SHARED_SECRET
  1919. #endif
  1920. #ifndef NO_CURVE448_KEY_EXPORT
  1921. #undef HAVE_CURVE448_KEY_EXPORT
  1922. #define HAVE_CURVE448_KEY_EXPORT
  1923. #endif
  1924. #ifndef NO_CURVE448_KEY_IMPORT
  1925. #undef HAVE_CURVE448_KEY_IMPORT
  1926. #define HAVE_CURVE448_KEY_IMPORT
  1927. #endif
  1928. #endif /* HAVE_CURVE448 */
  1929. /* Ed448 Configs */
  1930. #ifdef HAVE_ED448
  1931. /* By default enable sign, verify, key export and import */
  1932. #ifndef NO_ED448_SIGN
  1933. #undef HAVE_ED448_SIGN
  1934. #define HAVE_ED448_SIGN
  1935. #endif
  1936. #ifndef NO_ED448_VERIFY
  1937. #undef HAVE_ED448_VERIFY
  1938. #define HAVE_ED448_VERIFY
  1939. #ifdef WOLFSSL_ED448_STREAMING_VERIFY
  1940. #undef WOLFSSL_ED448_PERSISTENT_SHA
  1941. #define WOLFSSL_ED448_PERSISTENT_SHA
  1942. #endif
  1943. #endif
  1944. #ifndef NO_ED448_KEY_EXPORT
  1945. #undef HAVE_ED448_KEY_EXPORT
  1946. #define HAVE_ED448_KEY_EXPORT
  1947. #endif
  1948. #ifndef NO_ED448_KEY_IMPORT
  1949. #undef HAVE_ED448_KEY_IMPORT
  1950. #define HAVE_ED448_KEY_IMPORT
  1951. #endif
  1952. #endif /* HAVE_ED448 */
  1953. /* AES Config */
  1954. #ifndef NO_AES
  1955. /* By default enable all AES key sizes, decryption and CBC */
  1956. #ifndef AES_MAX_KEY_SIZE
  1957. #undef AES_MAX_KEY_SIZE
  1958. #define AES_MAX_KEY_SIZE 256
  1959. #endif
  1960. #ifndef NO_AES_128
  1961. #undef WOLFSSL_AES_128
  1962. #define WOLFSSL_AES_128
  1963. #endif
  1964. #if !defined(NO_AES_192) && AES_MAX_KEY_SIZE >= 192
  1965. #undef WOLFSSL_AES_192
  1966. #define WOLFSSL_AES_192
  1967. #endif
  1968. #if !defined(NO_AES_256) && AES_MAX_KEY_SIZE >= 256
  1969. #undef WOLFSSL_AES_256
  1970. #define WOLFSSL_AES_256
  1971. #endif
  1972. #if !defined(WOLFSSL_AES_128) && !defined(WOLFSSL_AES_256) && \
  1973. defined(HAVE_ECC_ENCRYPT)
  1974. #warning HAVE_ECC_ENCRYPT uses AES 128/256 bit keys
  1975. #endif
  1976. #ifndef NO_AES_DECRYPT
  1977. #undef HAVE_AES_DECRYPT
  1978. #define HAVE_AES_DECRYPT
  1979. #endif
  1980. #ifndef NO_AES_CBC
  1981. #undef HAVE_AES_CBC
  1982. #define HAVE_AES_CBC
  1983. #endif
  1984. #ifdef WOLFSSL_AES_XTS
  1985. /* AES-XTS makes calls to AES direct functions */
  1986. #ifndef WOLFSSL_AES_DIRECT
  1987. #define WOLFSSL_AES_DIRECT
  1988. #endif
  1989. #endif
  1990. #ifdef WOLFSSL_AES_CFB
  1991. /* AES-CFB makes calls to AES direct functions */
  1992. #ifndef WOLFSSL_AES_DIRECT
  1993. #define WOLFSSL_AES_DIRECT
  1994. #endif
  1995. #endif
  1996. #endif
  1997. #if (defined(WOLFSSL_TLS13) && defined(WOLFSSL_NO_TLS12)) || \
  1998. (!defined(HAVE_AES_CBC) && defined(NO_DES3) && defined(NO_RC4) && \
  1999. !defined(HAVE_CAMELLIA) & !defined(HAVE_NULL_CIPHER))
  2000. #define WOLFSSL_AEAD_ONLY
  2001. #endif
  2002. #if !defined(HAVE_PUBLIC_FFDHE) && !defined(NO_DH) && \
  2003. !defined(WOLFSSL_NO_PUBLIC_FFDHE) && \
  2004. (defined(HAVE_SELFTEST) || FIPS_VERSION_LE(2,0))
  2005. /* This should only be enabled for FIPS v2 or older. It enables use of the
  2006. * older wc_Dh_ffdhe####_Get() API's */
  2007. #define HAVE_PUBLIC_FFDHE
  2008. #endif
  2009. #if !defined(NO_DH) && !defined(HAVE_FFDHE)
  2010. #if defined(HAVE_FFDHE_2048) || defined(HAVE_FFDHE_3072) || \
  2011. defined(HAVE_FFDHE_4096) || defined(HAVE_FFDHE_6144) || \
  2012. defined(HAVE_FFDHE_8192)
  2013. #define HAVE_FFDHE
  2014. #endif
  2015. #endif
  2016. #if defined(HAVE_FFDHE_8192)
  2017. #define MIN_FFDHE_BITS 8192
  2018. #elif defined(HAVE_FFDHE_6144)
  2019. #define MIN_FFDHE_BITS 6144
  2020. #elif defined(HAVE_FFDHE_4096)
  2021. #define MIN_FFDHE_BITS 4096
  2022. #elif defined(HAVE_FFDHE_3072)
  2023. #define MIN_FFDHE_BITS 3072
  2024. #elif defined(HAVE_FFDHE_2048)
  2025. #define MIN_FFDHE_BITS 2048
  2026. #else
  2027. #define MIN_FFDHE_BITS 0
  2028. #endif
  2029. #define MIN_FFDHE_FP_MAX_BITS (MIN_FFDHE_BITS * 2)
  2030. #if defined(HAVE_FFDHE) && defined(FP_MAX_BITS)
  2031. #if MIN_FFDHE_FP_MAX_BITS > FP_MAX_BITS
  2032. #error "FFDHE parameters are too large for FP_MAX_BIT as set"
  2033. #endif
  2034. #endif
  2035. #if defined(HAVE_FFDHE) && defined(SP_INT_BITS)
  2036. #if MIN_FFDHE_BITS > SP_INT_BITS
  2037. #error "FFDHE parameters are too large for SP_INT_BIT as set"
  2038. #endif
  2039. #endif
  2040. /* if desktop type system and fastmath increase default max bits */
  2041. #if defined(WOLFSSL_X86_64_BUILD) || defined(WOLFSSL_AARCH64_BUILD)
  2042. #if defined(USE_FAST_MATH) && !defined(FP_MAX_BITS)
  2043. #if MIN_FFDHE_FP_MAX_BITS <= 8192
  2044. #define FP_MAX_BITS 8192
  2045. #else
  2046. #define FP_MAX_BITS MIN_FFDHE_FP_MAX_BITS
  2047. #endif
  2048. #endif
  2049. #if defined(WOLFSSL_SP_MATH_ALL) && !defined(SP_INT_BITS)
  2050. #ifdef WOLFSSL_MYSQL_COMPATIBLE
  2051. #define SP_INT_BITS 8192
  2052. #elif MIN_FFDHE_BITS <= 4096
  2053. #define SP_INT_BITS 4096
  2054. #else
  2055. #define SP_INT_BITS MIN_FFDHE_BITS
  2056. #endif
  2057. #endif
  2058. #endif
  2059. /* If using the max strength build, ensure OLD TLS is disabled. */
  2060. #ifdef WOLFSSL_MAX_STRENGTH
  2061. #undef NO_OLD_TLS
  2062. #define NO_OLD_TLS
  2063. #endif
  2064. /* Default AES minimum auth tag sz, allow user to override */
  2065. #ifndef WOLFSSL_MIN_AUTH_TAG_SZ
  2066. #define WOLFSSL_MIN_AUTH_TAG_SZ 12
  2067. #endif
  2068. /* sniffer requires:
  2069. * static RSA cipher suites
  2070. * session stats and peak stats
  2071. */
  2072. #ifdef WOLFSSL_SNIFFER
  2073. #ifndef WOLFSSL_STATIC_RSA
  2074. #define WOLFSSL_STATIC_RSA
  2075. #endif
  2076. #ifndef WOLFSSL_STATIC_DH
  2077. #define WOLFSSL_STATIC_DH
  2078. #endif
  2079. /* Allow option to be disabled. */
  2080. #ifndef WOLFSSL_NO_SESSION_STATS
  2081. #ifndef WOLFSSL_SESSION_STATS
  2082. #define WOLFSSL_SESSION_STATS
  2083. #endif
  2084. #ifndef WOLFSSL_PEAK_SESSIONS
  2085. #define WOLFSSL_PEAK_SESSIONS
  2086. #endif
  2087. #endif
  2088. #endif
  2089. /* Decode Public Key extras on by default, user can turn off with
  2090. * WOLFSSL_NO_DECODE_EXTRA */
  2091. #ifndef WOLFSSL_NO_DECODE_EXTRA
  2092. #ifndef RSA_DECODE_EXTRA
  2093. #define RSA_DECODE_EXTRA
  2094. #endif
  2095. #ifndef ECC_DECODE_EXTRA
  2096. #define ECC_DECODE_EXTRA
  2097. #endif
  2098. #endif
  2099. /* C Sharp wrapper defines */
  2100. #ifdef HAVE_CSHARP
  2101. #ifndef WOLFSSL_DTLS
  2102. #define WOLFSSL_DTLS
  2103. #endif
  2104. #undef NO_PSK
  2105. #undef NO_SHA256
  2106. #undef NO_DH
  2107. #endif
  2108. /* Asynchronous Crypto */
  2109. #ifdef WOLFSSL_ASYNC_CRYPT
  2110. #if !defined(HAVE_CAVIUM) && !defined(HAVE_INTEL_QA) && \
  2111. !defined(WOLFSSL_ASYNC_CRYPT_SW)
  2112. #error No async backend defined with WOLFSSL_ASYNC_CRYPT!
  2113. #endif
  2114. /* Make sure wolf events are enabled */
  2115. #undef HAVE_WOLF_EVENT
  2116. #define HAVE_WOLF_EVENT
  2117. #ifdef WOLFSSL_ASYNC_CRYPT_SW
  2118. #define WC_ASYNC_DEV_SIZE 168
  2119. #else
  2120. #define WC_ASYNC_DEV_SIZE 336
  2121. #endif
  2122. /* Enable ECC_CACHE_CURVE for ASYNC */
  2123. #if !defined(ECC_CACHE_CURVE)
  2124. #define ECC_CACHE_CURVE
  2125. #endif
  2126. #endif /* WOLFSSL_ASYNC_CRYPT */
  2127. #ifndef WC_ASYNC_DEV_SIZE
  2128. #define WC_ASYNC_DEV_SIZE 0
  2129. #endif
  2130. #ifdef HAVE_INTEL_QA /* Disable SHA512/224 and SHA512/256 support for QAT */
  2131. #define WOLFSSL_NOSHA512_224
  2132. #define WOLFSSL_NOSHA512_256
  2133. #endif
  2134. /* leantls checks */
  2135. #ifdef WOLFSSL_LEANTLS
  2136. #ifndef HAVE_ECC
  2137. #error leantls build needs ECC
  2138. #endif
  2139. #endif /* WOLFSSL_LEANTLS*/
  2140. /* restriction with static memory */
  2141. #ifdef WOLFSSL_STATIC_MEMORY
  2142. #if defined(HAVE_IO_POOL) || defined(XMALLOC_USER) || defined(NO_WOLFSSL_MEMORY)
  2143. #error static memory cannot be used with HAVE_IO_POOL, XMALLOC_USER or NO_WOLFSSL_MEMORY
  2144. #endif
  2145. #if !defined(WOLFSSL_SP_MATH_ALL) && !defined(USE_FAST_MATH) && \
  2146. !defined(WOLFSSL_SP_MATH) && !defined(NO_BIG_INT)
  2147. #error The static memory option is only supported for fast math or SP Math
  2148. #endif
  2149. #ifdef WOLFSSL_SMALL_STACK
  2150. #error static memory does not support small stack please undefine
  2151. #endif
  2152. #endif /* WOLFSSL_STATIC_MEMORY */
  2153. #ifdef HAVE_AES_KEYWRAP
  2154. #ifndef WOLFSSL_AES_DIRECT
  2155. #error AES key wrap requires AES direct please define WOLFSSL_AES_DIRECT
  2156. #endif
  2157. #endif
  2158. #ifdef HAVE_PKCS7
  2159. #if defined(NO_AES) && defined(NO_DES3)
  2160. #error PKCS7 needs either AES or 3DES enabled, please enable one
  2161. #endif
  2162. #ifndef HAVE_AES_KEYWRAP
  2163. #error PKCS7 requires AES key wrap please define HAVE_AES_KEYWRAP
  2164. #endif
  2165. #if defined(HAVE_ECC) && !defined(HAVE_X963_KDF)
  2166. #error PKCS7 requires X963 KDF please define HAVE_X963_KDF
  2167. #endif
  2168. #endif
  2169. #ifndef NO_PKCS12
  2170. #undef HAVE_PKCS12
  2171. #define HAVE_PKCS12
  2172. #endif
  2173. #if !defined(NO_PKCS8) || defined(HAVE_PKCS12)
  2174. #undef HAVE_PKCS8
  2175. #define HAVE_PKCS8
  2176. #endif
  2177. #if !defined(NO_PBKDF1) || defined(WOLFSSL_ENCRYPTED_KEYS) || \
  2178. defined(HAVE_PKCS8) || defined(HAVE_PKCS12)
  2179. #undef HAVE_PBKDF1
  2180. #define HAVE_PBKDF1
  2181. #endif
  2182. #if !defined(NO_PBKDF2) || defined(HAVE_PKCS7) || defined(HAVE_SCRYPT)
  2183. #undef HAVE_PBKDF2
  2184. #define HAVE_PBKDF2
  2185. #endif
  2186. #if !defined(WOLFCRYPT_ONLY) && !defined(NO_OLD_TLS) && \
  2187. (defined(NO_SHA) || defined(NO_MD5))
  2188. #error old TLS requires MD5 and SHA
  2189. #endif
  2190. /* for backwards compatibility */
  2191. #if defined(TEST_IPV6) && !defined(WOLFSSL_IPV6)
  2192. #define WOLFSSL_IPV6
  2193. #endif
  2194. #ifdef WOLFSSL_LINUXKM
  2195. #ifdef HAVE_CONFIG_H
  2196. #include <config.h>
  2197. #undef HAVE_CONFIG_H
  2198. #endif
  2199. #ifndef NO_DEV_RANDOM
  2200. #define NO_DEV_RANDOM
  2201. #endif
  2202. #ifndef NO_WRITEV
  2203. #define NO_WRITEV
  2204. #endif
  2205. #ifndef NO_FILESYSTEM
  2206. #define NO_FILESYSTEM
  2207. #endif
  2208. #ifndef NO_STDIO_FILESYSTEM
  2209. #define NO_STDIO_FILESYSTEM
  2210. #endif
  2211. #ifndef WOLFSSL_NO_SOCK
  2212. #define WOLFSSL_NO_SOCK
  2213. #endif
  2214. #ifndef WOLFSSL_DH_CONST
  2215. #define WOLFSSL_DH_CONST
  2216. #endif
  2217. #ifndef WOLFSSL_USER_IO
  2218. #define WOLFSSL_USER_IO
  2219. #endif
  2220. #ifndef USE_WOLF_STRTOK
  2221. #define USE_WOLF_STRTOK
  2222. #endif
  2223. #ifndef WOLFSSL_OLD_PRIME_CHECK
  2224. #define WOLFSSL_OLD_PRIME_CHECK
  2225. #endif
  2226. #ifndef WOLFSSL_TEST_SUBROUTINE
  2227. #define WOLFSSL_TEST_SUBROUTINE static
  2228. #endif
  2229. #undef HAVE_STRINGS_H
  2230. #undef HAVE_ERRNO_H
  2231. #undef HAVE_THREAD_LS
  2232. #undef WOLFSSL_HAVE_MIN
  2233. #undef WOLFSSL_HAVE_MAX
  2234. #define SIZEOF_LONG 8
  2235. #define SIZEOF_LONG_LONG 8
  2236. #define CHAR_BIT 8
  2237. #ifndef WOLFSSL_SP_DIV_64
  2238. #define WOLFSSL_SP_DIV_64
  2239. #endif
  2240. #ifndef WOLFSSL_SP_DIV_WORD_HALF
  2241. #define WOLFSSL_SP_DIV_WORD_HALF
  2242. #endif
  2243. #endif
  2244. /* Place any other flags or defines here */
  2245. #if defined(WOLFSSL_MYSQL_COMPATIBLE) && defined(_WIN32) \
  2246. && defined(HAVE_GMTIME_R)
  2247. #undef HAVE_GMTIME_R /* don't trust macro with windows */
  2248. #endif /* WOLFSSL_MYSQL_COMPATIBLE */
  2249. #if (defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY) \
  2250. || defined(HAVE_LIGHTY)) && !defined(NO_TLS)
  2251. #define OPENSSL_NO_ENGINE
  2252. #ifndef OPENSSL_EXTRA
  2253. #define OPENSSL_EXTRA
  2254. #endif
  2255. /* Session Tickets will be enabled when --enable-opensslall is used.
  2256. * Time is required for ticket expiration checking */
  2257. #if !defined(HAVE_SESSION_TICKET) && !defined(NO_ASN_TIME)
  2258. #define HAVE_SESSION_TICKET
  2259. #endif
  2260. /* OCSP will be enabled in configure.ac when --enable-opensslall is used,
  2261. * but do not force all users to have it enabled. */
  2262. #ifndef HAVE_OCSP
  2263. /*#define HAVE_OCSP*/
  2264. #endif
  2265. #ifndef KEEP_OUR_CERT
  2266. #define KEEP_OUR_CERT
  2267. #endif
  2268. #ifndef HAVE_SNI
  2269. #define HAVE_SNI
  2270. #endif
  2271. #endif
  2272. #ifdef HAVE_SNI
  2273. #define SSL_CTRL_SET_TLSEXT_HOSTNAME 55
  2274. #endif
  2275. /* Disable time checking if no timer */
  2276. #if defined(NO_ASN_TIME)
  2277. #define NO_ASN_TIME_CHECK
  2278. #endif
  2279. /* both CURVE and ED small math should be enabled */
  2280. #ifdef CURVED25519_SMALL
  2281. #define CURVE25519_SMALL
  2282. #define ED25519_SMALL
  2283. #endif
  2284. /* both CURVE and ED small math should be enabled */
  2285. #ifdef CURVED448_SMALL
  2286. #define CURVE448_SMALL
  2287. #define ED448_SMALL
  2288. #endif
  2289. #ifndef WOLFSSL_ALERT_COUNT_MAX
  2290. #define WOLFSSL_ALERT_COUNT_MAX 5
  2291. #endif
  2292. /* warning for not using harden build options (default with ./configure) */
  2293. /* do not warn if big integer support is disabled */
  2294. #if !defined(WC_NO_HARDEN) && !defined(NO_BIG_INT)
  2295. #if (defined(USE_FAST_MATH) && !defined(TFM_TIMING_RESISTANT)) || \
  2296. (defined(HAVE_ECC) && !defined(ECC_TIMING_RESISTANT)) || \
  2297. (!defined(NO_RSA) && !defined(WC_RSA_BLINDING) && !defined(HAVE_FIPS) && \
  2298. !defined(WC_NO_RNG))
  2299. #ifndef _MSC_VER
  2300. #warning "For timing resistance / side-channel attack prevention consider using harden options"
  2301. #else
  2302. #pragma message("Warning: For timing resistance / side-channel attack prevention consider using harden options")
  2303. #endif
  2304. #endif
  2305. #endif
  2306. #ifdef OPENSSL_COEXIST
  2307. /* make sure old names are disabled */
  2308. #ifndef NO_OLD_SSL_NAMES
  2309. #define NO_OLD_SSL_NAMES
  2310. #endif
  2311. #ifndef NO_OLD_WC_NAMES
  2312. #define NO_OLD_WC_NAMES
  2313. #endif
  2314. #endif
  2315. #if defined(NO_OLD_WC_NAMES) || defined(OPENSSL_EXTRA)
  2316. /* added to have compatibility with SHA256() */
  2317. #if !defined(NO_OLD_SHA_NAMES) && (!defined(HAVE_FIPS) || \
  2318. FIPS_VERSION_GT(2,0))
  2319. #define NO_OLD_SHA_NAMES
  2320. #endif
  2321. #if !defined(NO_OLD_MD5_NAME) && (!defined(HAVE_FIPS) || \
  2322. FIPS_VERSION_GT(2,0))
  2323. #define NO_OLD_MD5_NAME
  2324. #endif
  2325. #endif
  2326. /* switch for compatibility layer functionality. Has subparts i.e. BIO/X509
  2327. * When opensslextra is enabled all subparts should be turned on. */
  2328. #ifdef OPENSSL_EXTRA
  2329. #undef OPENSSL_EXTRA_X509_SMALL
  2330. #define OPENSSL_EXTRA_X509_SMALL
  2331. #endif /* OPENSSL_EXTRA */
  2332. /* support for converting DER to PEM */
  2333. #if (defined(WOLFSSL_KEY_GEN) && !defined(WOLFSSL_NO_DER_TO_PEM)) || \
  2334. defined(WOLFSSL_CERT_GEN) || defined(OPENSSL_EXTRA)
  2335. #undef WOLFSSL_DER_TO_PEM
  2336. #define WOLFSSL_DER_TO_PEM
  2337. #endif
  2338. /* keep backwards compatibility enabling encrypted private key */
  2339. #ifndef WOLFSSL_ENCRYPTED_KEYS
  2340. #if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL) || \
  2341. defined(HAVE_WEBSERVER)
  2342. #define WOLFSSL_ENCRYPTED_KEYS
  2343. #endif
  2344. #endif
  2345. /* support for disabling PEM to DER */
  2346. #if !defined(WOLFSSL_NO_PEM) && !defined(NO_CODING)
  2347. #undef WOLFSSL_PEM_TO_DER
  2348. #define WOLFSSL_PEM_TO_DER
  2349. #endif
  2350. /* Parts of the openssl compatibility layer require peer certs */
  2351. #if defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY) \
  2352. || defined(HAVE_LIGHTY)
  2353. #undef KEEP_PEER_CERT
  2354. #define KEEP_PEER_CERT
  2355. #endif
  2356. /*
  2357. * Keeps the "Finished" messages after a TLS handshake for use as the so-called
  2358. * "tls-unique" channel binding. See comment in internal.h around clientFinished
  2359. * and serverFinished for more information.
  2360. */
  2361. #if defined(OPENSSL_ALL) || defined(WOLFSSL_HAPROXY) || defined(WOLFSSL_WPAS)
  2362. #undef WOLFSSL_HAVE_TLS_UNIQUE
  2363. #define WOLFSSL_HAVE_TLS_UNIQUE
  2364. #endif
  2365. /* RAW hash function APIs are not implemented */
  2366. #if defined(WOLFSSL_ARMASM) || defined(WOLFSSL_AFALG_HASH)
  2367. #undef WOLFSSL_NO_HASH_RAW
  2368. #define WOLFSSL_NO_HASH_RAW
  2369. #endif
  2370. /* XChacha not implemented with ARM assembly ChaCha */
  2371. #if defined(WOLFSSL_ARMASM)
  2372. #undef HAVE_XCHACHA
  2373. #endif
  2374. #if !defined(WOLFSSL_SHA384) && !defined(WOLFSSL_SHA512) && defined(NO_AES) && \
  2375. !defined(WOLFSSL_SHA3)
  2376. #undef WOLFSSL_NO_WORD64_OPS
  2377. #define WOLFSSL_NO_WORD64_OPS
  2378. #endif
  2379. #if !defined(WOLFCRYPT_ONLY) && \
  2380. (!defined(WOLFSSL_NO_TLS12) || defined(HAVE_KEYING_MATERIAL))
  2381. #undef WOLFSSL_HAVE_PRF
  2382. #define WOLFSSL_HAVE_PRF
  2383. #endif
  2384. #if defined(NO_ASN) && defined(WOLFCRYPT_ONLY) && !defined(WOLFSSL_WOLFSSH)
  2385. #undef WOLFSSL_NO_INT_ENCODE
  2386. #define WOLFSSL_NO_INT_ENCODE
  2387. #endif
  2388. #if defined(NO_ASN) && defined(WOLFCRYPT_ONLY)
  2389. #undef WOLFSSL_NO_INT_DECODE
  2390. #define WOLFSSL_NO_INT_DECODE
  2391. #endif
  2392. #if defined(WOLFCRYPT_ONLY) && defined(WOLFSSL_RSA_VERIFY_ONLY) && \
  2393. defined(WC_NO_RSA_OAEP)
  2394. #undef WOLFSSL_NO_CT_OPS
  2395. #define WOLFSSL_NO_CT_OPS
  2396. #endif
  2397. #if defined(WOLFCRYPT_ONLY) && defined(NO_AES) && !defined(HAVE_CURVE25519) && \
  2398. !defined(HAVE_CURVE448) && defined(WC_NO_RNG) && defined(WC_NO_RSA_OAEP)
  2399. #undef WOLFSSL_NO_CONST_CMP
  2400. #define WOLFSSL_NO_CONST_CMP
  2401. #endif
  2402. #if defined(WOLFCRYPT_ONLY) && defined(NO_AES) && !defined(WOLFSSL_SHA384) && \
  2403. !defined(WOLFSSL_SHA512) && defined(WC_NO_RNG) && \
  2404. !defined(WOLFSSL_SP_MATH) && !defined(WOLFSSL_SP_MATH_ALL) \
  2405. && !defined(USE_FAST_MATH)
  2406. #undef WOLFSSL_NO_FORCE_ZERO
  2407. #define WOLFSSL_NO_FORCE_ZERO
  2408. #endif
  2409. /* Detect old cryptodev name */
  2410. #if defined(WOLF_CRYPTO_DEV) && !defined(WOLF_CRYPTO_CB)
  2411. #define WOLF_CRYPTO_CB
  2412. #endif
  2413. #if defined(WOLFSSL_TLS13) && defined(WOLFSSL_NO_SIGALG)
  2414. #error TLS 1.3 requires the Signature Algorithms extension to be enabled
  2415. #endif
  2416. #ifndef NO_WOLFSSL_BASE64_DECODE
  2417. #define WOLFSSL_BASE64_DECODE
  2418. #endif
  2419. #if defined(HAVE_EX_DATA) || defined(FORTRESS)
  2420. #if defined(FORTRESS) && !defined(HAVE_EX_DATA)
  2421. #define HAVE_EX_DATA
  2422. #endif
  2423. #ifndef MAX_EX_DATA
  2424. #define MAX_EX_DATA 5 /* allow for five items of ex_data */
  2425. #endif
  2426. #endif
  2427. #ifdef NO_WOLFSSL_SMALL_STACK
  2428. #undef WOLFSSL_SMALL_STACK
  2429. #endif
  2430. #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_SMALL_STACK_STATIC) && \
  2431. !defined(NO_WOLFSSL_SMALL_STACK_STATIC)
  2432. #define WOLFSSL_SMALL_STACK_STATIC
  2433. #endif
  2434. #ifdef WOLFSSL_SMALL_STACK_STATIC
  2435. #undef WOLFSSL_SMALL_STACK_STATIC
  2436. #define WOLFSSL_SMALL_STACK_STATIC static
  2437. #else
  2438. #define WOLFSSL_SMALL_STACK_STATIC
  2439. #endif
  2440. /* The client session cache requires time for timeout */
  2441. #if defined(NO_ASN_TIME) && !defined(NO_SESSION_CACHE)
  2442. #define NO_SESSION_CACHE
  2443. #endif
  2444. #if defined(NO_ASN_TIME) && !defined(WOLFSSL_NO_DEF_TICKET_ENC_CB)
  2445. #define WOLFSSL_NO_DEF_TICKET_ENC_CB
  2446. #endif
  2447. #if defined(NO_ASN_TIME) && defined(HAVE_SESSION_TICKET)
  2448. #undef HAVE_SESSION_TICKET
  2449. #endif
  2450. /* Use static ECC structs for Position Independent Code (PIC) */
  2451. #if defined(__IAR_SYSTEMS_ICC__) && defined(__ROPI__)
  2452. #define WOLFSSL_ECC_CURVE_STATIC
  2453. #define WOLFSSL_NAMES_STATIC
  2454. #define WOLFSSL_NO_CONSTCHARCONST
  2455. #endif
  2456. /* FIPS v1 does not support TLS v1.3 (requires RSA PSS and HKDF) */
  2457. #if FIPS_VERSION_EQ(1,0)
  2458. #undef WC_RSA_PSS
  2459. #undef WOLFSSL_TLS13
  2460. #endif
  2461. /* FIPS v2 does not support WOLFSSL_PSS_LONG_SALT */
  2462. #if FIPS_VERSION_EQ(2,0)
  2463. #ifdef WOLFSSL_PSS_LONG_SALT
  2464. #undef WOLFSSL_PSS_LONG_SALT
  2465. #endif
  2466. #endif
  2467. /* For FIPSv2 make sure the ECDSA encoding allows extra bytes
  2468. * but make sure users consider enabling it */
  2469. #if !defined(NO_STRICT_ECDSA_LEN) && FIPS_VERSION_GE(2,0)
  2470. /* ECDSA length checks off by default for CAVP testing
  2471. * consider enabling strict checks in production */
  2472. #define NO_STRICT_ECDSA_LEN
  2473. #endif
  2474. /* Do not allow using small stack with no malloc */
  2475. #if defined(WOLFSSL_NO_MALLOC) && \
  2476. (defined(WOLFSSL_SMALL_STACK) || defined(WOLFSSL_SMALL_STACK_CACHE))
  2477. #error Small stack cannot be used with no malloc (WOLFSSL_NO_MALLOC)
  2478. #endif
  2479. /* Enable DH Extra for QT, openssl all, openssh and static ephemeral */
  2480. /* Allows export/import of DH key and params as DER */
  2481. #if !defined(NO_DH) && !defined(WOLFSSL_DH_EXTRA) && \
  2482. (defined(WOLFSSL_QT) || defined(OPENSSL_ALL) || defined(WOLFSSL_OPENSSH) || \
  2483. defined(WOLFSSL_STATIC_EPHEMERAL))
  2484. #define WOLFSSL_DH_EXTRA
  2485. #endif
  2486. /* DH Extra is not supported on FIPS v1 or v2 (is missing DhKey .pub/.priv) */
  2487. #if defined(WOLFSSL_DH_EXTRA) && defined(HAVE_FIPS) && FIPS_VERSION_LE(2,0)
  2488. #undef WOLFSSL_DH_EXTRA
  2489. #endif
  2490. /* wc_Sha512.devId isn't available before FIPS 5.1 */
  2491. #if defined(HAVE_FIPS) && FIPS_VERSION_LT(5,1)
  2492. #define NO_SHA2_CRYPTO_CB
  2493. #endif
  2494. /* Enable HAVE_ONE_TIME_AUTH by default for use with TLS cipher suites
  2495. * when poly1305 is enabled
  2496. */
  2497. #if defined(HAVE_POLY1305) && !defined(HAVE_ONE_TIME_AUTH)
  2498. #define HAVE_ONE_TIME_AUTH
  2499. #endif
  2500. /* Check for insecure build combination:
  2501. * secure renegotiation [enabled]
  2502. * extended master secret [disabled]
  2503. * session resumption [enabled]
  2504. */
  2505. #if defined(HAVE_SECURE_RENEGOTIATION) && !defined(HAVE_EXTENDED_MASTER) && \
  2506. (defined(HAVE_SESSION_TICKET) || !defined(NO_SESSION_CACHE))
  2507. /* secure renegotiation requires extended master secret with resumption */
  2508. #ifndef _MSC_VER
  2509. #warning Extended master secret must be enabled with secure renegotiation and session resumption
  2510. #else
  2511. #pragma message("Warning: Extended master secret must be enabled with secure renegotiation and session resumption")
  2512. #endif
  2513. /* Note: "--enable-renegotiation-indication" ("HAVE_RENEGOTIATION_INDICATION")
  2514. * only sends the secure renegotiation extension, but is not actually supported.
  2515. * This was added because some TLS peers required it even if not used, so we call
  2516. * this "(FAKE Secure Renegotiation)"
  2517. */
  2518. #endif
  2519. /* if secure renegotiation is enabled, make sure server info is enabled */
  2520. #if !defined(HAVE_RENEGOTIATION_INDICATION) && \
  2521. !defined(HAVE_SERVER_RENEGOTIATION_INFO) && \
  2522. defined(HAVE_SECURE_RENEGOTIATION) && \
  2523. !defined(NO_WOLFSSL_SERVER)
  2524. #define HAVE_SERVER_RENEGOTIATION_INFO
  2525. #endif
  2526. /* Crypto callbacks should enable hash flag support */
  2527. #if defined(WOLF_CRYPTO_CB) && !defined(WOLFSSL_HASH_FLAGS)
  2528. /* FIPS v1 and v2 do not support hash flags, so do not allow it with
  2529. * crypto callbacks */
  2530. #if !defined(HAVE_FIPS) || (defined(HAVE_FIPS) && \
  2531. defined(HAVE_FIPS_VERSION) && HAVE_FIPS_VERSION >= 3)
  2532. #define WOLFSSL_HASH_FLAGS
  2533. #endif
  2534. #endif
  2535. #ifdef WOLFSSL_HAVE_KYBER
  2536. #define HAVE_PQC
  2537. #endif
  2538. /* Enable Post-Quantum Cryptography if we have liboqs from the OpenQuantumSafe
  2539. * group */
  2540. #ifdef HAVE_LIBOQS
  2541. #define HAVE_PQC
  2542. #define HAVE_FALCON
  2543. #define HAVE_DILITHIUM
  2544. #define HAVE_SPHINCS
  2545. #ifndef WOLFSSL_HAVE_KYBER
  2546. #define WOLFSSL_HAVE_KYBER
  2547. #define WOLFSSL_KYBER512
  2548. #define WOLFSSL_KYBER768
  2549. #define WOLFSSL_KYBER1024
  2550. #endif
  2551. #endif
  2552. #ifdef HAVE_PQM4
  2553. #define HAVE_PQC
  2554. #define WOLFSSL_HAVE_KYBER
  2555. #define WOLFSSL_KYBER512
  2556. #define WOLFSSL_NO_KYBER768
  2557. #define WOLFSSL_NO_KYBER1024
  2558. #endif
  2559. #if defined(HAVE_PQC) && !defined(HAVE_LIBOQS) && !defined(HAVE_PQM4) && \
  2560. !defined(WOLFSSL_HAVE_KYBER)
  2561. #error Please do not define HAVE_PQC yourself.
  2562. #endif
  2563. #if defined(HAVE_PQC) && defined(HAVE_LIBOQS) && defined(HAVE_PQM4)
  2564. #error Please do not define both HAVE_LIBOQS and HAVE_PQM4.
  2565. #endif
  2566. /* SRTP requires DTLS */
  2567. #if defined(WOLFSSL_SRTP) && !defined(WOLFSSL_DTLS)
  2568. #error The SRTP extension requires DTLS
  2569. #endif
  2570. /* Are we using an external private key store like:
  2571. * PKCS11 / HSM / crypto callback / PK callback */
  2572. #if !defined(WOLF_PRIVATE_KEY_ID) && !defined(NO_WOLF_PRIVATE_KEY_ID) && \
  2573. (defined(HAVE_PKCS11) || defined(HAVE_PK_CALLBACKS) || \
  2574. defined(WOLF_CRYPTO_CB) || defined(WOLFSSL_KCAPI))
  2575. /* Enables support for using wolfSSL_CTX_use_PrivateKey_Id and
  2576. * wolfSSL_CTX_use_PrivateKey_Label */
  2577. #define WOLF_PRIVATE_KEY_ID
  2578. #endif
  2579. /* With titan cache size there is too many sessions to fit with the default
  2580. * multiplier of 8 */
  2581. #if defined(TITAN_SESSION_CACHE) && !defined(NO_SESSION_CACHE_REF)
  2582. #define NO_SESSION_CACHE_REF
  2583. #endif
  2584. /* (D)TLS v1.3 requires 64-bit number wrappers */
  2585. #if defined(WOLFSSL_TLS13) || defined(WOLFSSL_DTLS_DROP_STATS)
  2586. #undef WOLFSSL_W64_WRAPPER
  2587. #define WOLFSSL_W64_WRAPPER
  2588. #endif
  2589. /* DTLS v1.3 requires AES ECB if using AES */
  2590. #if defined(WOLFSSL_DTLS13) && !defined(NO_AES) && \
  2591. !defined(WOLFSSL_AES_DIRECT)
  2592. #define WOLFSSL_AES_DIRECT
  2593. #endif
  2594. #if defined(WOLFSSL_DTLS13) && (!defined(WOLFSSL_DTLS) || \
  2595. !defined(WOLFSSL_TLS13))
  2596. #error "DTLS v1.3 requires both WOLFSSL_TLS13 and WOLFSSL_DTLS"
  2597. #endif
  2598. #if defined(WOLFSSL_DTLS_CID) && !defined(WOLFSSL_DTLS13)
  2599. #error "ConnectionID is supported for DTLSv1.3 only"
  2600. #endif
  2601. /* RSA Key Checking is disabled by default unless WOLFSSL_RSA_KEY_CHECK is
  2602. * defined or FIPS v2 3389, FIPS v5 or later.
  2603. * Not allowed for:
  2604. * RSA public only, CAVP selftest, fast RSA, user RSA, QAT or CryptoCell */
  2605. #if (defined(WOLFSSL_RSA_KEY_CHECK) || (defined(HAVE_FIPS) && FIPS_VERSION_GE(2,0))) && \
  2606. !defined(WOLFSSL_NO_RSA_KEY_CHECK) && !defined(WOLFSSL_RSA_PUBLIC_ONLY) && \
  2607. !defined(HAVE_USER_RSA) && !defined(HAVE_FAST_RSA) && \
  2608. !defined(HAVE_INTEL_QA) && !defined(WOLFSSL_CRYPTOCELL) && \
  2609. !defined(HAVE_SELFTEST)
  2610. #undef WOLFSSL_RSA_KEY_CHECK
  2611. #define WOLFSSL_RSA_KEY_CHECK
  2612. #endif
  2613. /* SHAKE - Not allowed in FIPS */
  2614. #if defined(WOLFSSL_SHA3) && !defined(HAVE_SELFTEST) && !defined(HAVE_FIPS)
  2615. #ifndef WOLFSSL_NO_SHAKE128
  2616. #undef WOLFSSL_SHAKE128
  2617. #define WOLFSSL_SHAKE128
  2618. #endif
  2619. #ifndef WOLFSSL_NO_SHAKE256
  2620. #undef WOLFSSL_SHAKE256
  2621. #define WOLFSSL_SHAKE256
  2622. #endif
  2623. #else
  2624. #undef WOLFSSL_NO_SHAKE128
  2625. #define WOLFSSL_NO_SHAKE128
  2626. #undef WOLFSSL_NO_SHAKE256
  2627. #define WOLFSSL_NO_SHAKE256
  2628. #endif
  2629. /* Encrypted Client Hello - requires HPKE */
  2630. #if defined(HAVE_ECH) && !defined(HAVE_HPKE)
  2631. #define HAVE_HPKE
  2632. #endif
  2633. /* Provide way to forcefully disable use of XREALLOC */
  2634. #ifdef WOLFSSL_NO_REALLOC
  2635. #undef XREALLOC
  2636. #endif
  2637. /* ---------------------------------------------------------------------------
  2638. * Deprecated Algorithm Handling
  2639. * Unless allowed via a build macro, disable support
  2640. * ---------------------------------------------------------------------------*/
  2641. /* RC4: Per RFC7465 Feb 2015, the cipher suite has been deprecated due to a
  2642. * number of exploits capable of decrypting portions of encrypted messages. */
  2643. #ifndef WOLFSSL_ALLOW_RC4
  2644. #undef NO_RC4
  2645. #define NO_RC4
  2646. #endif
  2647. #if !defined(WOLFSSL_NO_ASYNC_IO) || defined(WOLFSSL_ASYNC_CRYPT) || \
  2648. defined(WOLFSSL_NONBLOCK_OCSP)
  2649. /* Enable asynchronous support in TLS functions to support one or more of
  2650. * the following:
  2651. * - re-entry after a network blocking return
  2652. * - re-entry after OCSP blocking return
  2653. * - asynchronous cryptography */
  2654. #undef WOLFSSL_ASYNC_IO
  2655. #define WOLFSSL_ASYNC_IO
  2656. #endif
  2657. #ifdef WOLFSSL_SYS_CA_CERTS
  2658. #ifdef NO_FILESYSTEM
  2659. /* Turning off WOLFSSL_SYS_CA_CERTS b/c NO_FILESYSTEM is defined */
  2660. #undef WOLFSSL_SYS_CA_CERTS
  2661. #endif
  2662. #ifdef NO_CERTS
  2663. /* Turning off WOLFSSL_SYS_CA_CERTS b/c NO_CERTS is defined */
  2664. #undef WOLFSSL_SYS_CA_CERTS
  2665. #endif
  2666. #if defined(__APPLE__) && !defined(HAVE_SECURITY_SECTRUSTSETTINGS_H)
  2667. /* Turning off WOLFSSL_SYS_CA_CERTS b/c no Security/SecTrustSettings.h header */
  2668. #undef WOLFSSL_SYS_CA_CERTS
  2669. #endif
  2670. #endif /* WOLFSSL_SYS_CA_CERTS */
  2671. #if defined(SESSION_CACHE_DYNAMIC_MEM) && defined(PERSIST_SESSION_CACHE)
  2672. #error "Dynamic session cache currently does not support persistent session cache."
  2673. #endif
  2674. #ifdef WOLFSSL_HARDEN_TLS
  2675. #if defined(HAVE_TRUNCATED_HMAC) && !defined(WOLFSSL_HARDEN_TLS_ALLOW_TRUNCATED_HMAC)
  2676. #error "Truncated HMAC Extension not allowed https://www.rfc-editor.org/rfc/rfc9325#section-4.6"
  2677. #endif
  2678. #if !defined(NO_OLD_TLS) && !defined(WOLFSSL_HARDEN_TLS_ALLOW_OLD_TLS)
  2679. #error "TLS < 1.2 protocol versions not allowed https://www.rfc-editor.org/rfc/rfc9325#section-3.1.1"
  2680. #endif
  2681. #if !defined(WOLFSSL_NO_TLS12) && !defined(HAVE_SECURE_RENEGOTIATION) && \
  2682. !defined(HAVE_SERVER_RENEGOTIATION_INFO) && !defined(WOLFSSL_HARDEN_TLS_NO_SCR_CHECK)
  2683. #error "TLS 1.2 requires at least HAVE_SERVER_RENEGOTIATION_INFO to send the secure renegotiation extension https://www.rfc-editor.org/rfc/rfc9325#section-3.5"
  2684. #endif
  2685. #if !defined(WOLFSSL_EXTRA_ALERTS) || !defined(WOLFSSL_CHECK_ALERT_ON_ERR)
  2686. #error "RFC9325 requires some additional alerts to be sent"
  2687. #endif
  2688. /* Ciphersuite check done in internal.h */
  2689. #endif
  2690. #ifdef __cplusplus
  2691. } /* extern "C" */
  2692. #endif
  2693. #endif