settings.h 106 KB

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