@annadata/capacitor-mqtt-quic 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (795) hide show
  1. package/AnnadataCapacitorMqttQuic.podspec +36 -0
  2. package/README.md +121 -12
  3. package/android/NGTCP2_BUILD_INSTRUCTIONS.md +65 -44
  4. package/android/build-openssl.sh +1 -1
  5. package/android/install/nghttp3-android/arm64-v8a/include/nghttp3/nghttp3.h +3295 -0
  6. package/android/install/nghttp3-android/arm64-v8a/include/nghttp3/version.h +46 -0
  7. package/android/install/nghttp3-android/arm64-v8a/lib/cmake/nghttp3/nghttp3Config.cmake +3 -0
  8. package/android/install/nghttp3-android/arm64-v8a/lib/cmake/nghttp3/nghttp3ConfigVersion.cmake +65 -0
  9. package/android/install/nghttp3-android/arm64-v8a/lib/cmake/nghttp3/nghttp3Targets-release.cmake +29 -0
  10. package/android/install/nghttp3-android/arm64-v8a/lib/cmake/nghttp3/nghttp3Targets.cmake +114 -0
  11. package/android/install/nghttp3-android/arm64-v8a/lib/libnghttp3.a +0 -0
  12. package/android/install/nghttp3-android/arm64-v8a/lib/libnghttp3.so +0 -0
  13. package/android/install/nghttp3-android/arm64-v8a/lib/pkgconfig/libnghttp3.pc +34 -0
  14. package/android/install/nghttp3-android/arm64-v8a/share/doc/nghttp3/README.rst +75 -0
  15. package/android/install/nghttp3-android/armeabi-v7a/include/nghttp3/nghttp3.h +3295 -0
  16. package/android/install/nghttp3-android/armeabi-v7a/include/nghttp3/version.h +46 -0
  17. package/android/install/nghttp3-android/armeabi-v7a/lib/cmake/nghttp3/nghttp3Config.cmake +3 -0
  18. package/android/install/nghttp3-android/armeabi-v7a/lib/cmake/nghttp3/nghttp3ConfigVersion.cmake +65 -0
  19. package/android/install/nghttp3-android/armeabi-v7a/lib/cmake/nghttp3/nghttp3Targets-release.cmake +29 -0
  20. package/android/install/nghttp3-android/armeabi-v7a/lib/cmake/nghttp3/nghttp3Targets.cmake +114 -0
  21. package/android/install/nghttp3-android/armeabi-v7a/lib/libnghttp3.a +0 -0
  22. package/android/install/nghttp3-android/armeabi-v7a/lib/libnghttp3.so +0 -0
  23. package/android/install/nghttp3-android/armeabi-v7a/lib/pkgconfig/libnghttp3.pc +34 -0
  24. package/android/install/nghttp3-android/armeabi-v7a/share/doc/nghttp3/README.rst +75 -0
  25. package/android/install/nghttp3-android/x86_64/include/nghttp3/nghttp3.h +3295 -0
  26. package/android/install/nghttp3-android/x86_64/include/nghttp3/version.h +46 -0
  27. package/android/install/nghttp3-android/x86_64/lib/cmake/nghttp3/nghttp3Config.cmake +3 -0
  28. package/android/install/nghttp3-android/x86_64/lib/cmake/nghttp3/nghttp3ConfigVersion.cmake +65 -0
  29. package/android/install/nghttp3-android/x86_64/lib/cmake/nghttp3/nghttp3Targets-release.cmake +29 -0
  30. package/android/install/nghttp3-android/x86_64/lib/cmake/nghttp3/nghttp3Targets.cmake +114 -0
  31. package/android/install/nghttp3-android/x86_64/lib/libnghttp3.a +0 -0
  32. package/android/install/nghttp3-android/x86_64/lib/libnghttp3.so +0 -0
  33. package/android/install/nghttp3-android/x86_64/lib/pkgconfig/libnghttp3.pc +34 -0
  34. package/android/install/nghttp3-android/x86_64/share/doc/nghttp3/README.rst +75 -0
  35. package/android/install/ngtcp2-android/arm64-v8a/include/ngtcp2/ngtcp2.h +6254 -0
  36. package/android/install/ngtcp2-android/arm64-v8a/include/ngtcp2/ngtcp2_crypto.h +1037 -0
  37. package/android/install/ngtcp2-android/arm64-v8a/include/ngtcp2/ngtcp2_crypto_wolfssl.h +106 -0
  38. package/android/install/ngtcp2-android/arm64-v8a/include/ngtcp2/version.h +51 -0
  39. package/android/install/ngtcp2-android/arm64-v8a/lib/cmake/ngtcp2/ngtcp2Config.cmake +6 -0
  40. package/android/install/ngtcp2-android/arm64-v8a/lib/cmake/ngtcp2/ngtcp2ConfigVersion.cmake +65 -0
  41. package/android/install/ngtcp2-android/arm64-v8a/lib/cmake/ngtcp2/ngtcp2Targets-release.cmake +29 -0
  42. package/android/install/ngtcp2-android/arm64-v8a/lib/cmake/ngtcp2/ngtcp2Targets.cmake +114 -0
  43. package/android/install/ngtcp2-android/arm64-v8a/lib/libngtcp2.a +0 -0
  44. package/android/install/ngtcp2-android/arm64-v8a/lib/libngtcp2.so +0 -0
  45. package/android/install/ngtcp2-android/arm64-v8a/lib/libngtcp2_crypto_wolfssl.a +0 -0
  46. package/android/install/ngtcp2-android/arm64-v8a/lib/libngtcp2_crypto_wolfssl.so +0 -0
  47. package/android/install/ngtcp2-android/arm64-v8a/lib/pkgconfig/libngtcp2.pc +33 -0
  48. package/android/install/ngtcp2-android/arm64-v8a/lib/pkgconfig/libngtcp2_crypto_wolfssl.pc +34 -0
  49. package/android/install/ngtcp2-android/arm64-v8a/share/doc/ngtcp2/README.rst +385 -0
  50. package/android/install/ngtcp2-android/armeabi-v7a/include/ngtcp2/ngtcp2.h +6254 -0
  51. package/android/install/ngtcp2-android/armeabi-v7a/include/ngtcp2/ngtcp2_crypto.h +1037 -0
  52. package/android/install/ngtcp2-android/armeabi-v7a/include/ngtcp2/ngtcp2_crypto_wolfssl.h +106 -0
  53. package/android/install/ngtcp2-android/armeabi-v7a/include/ngtcp2/version.h +51 -0
  54. package/android/install/ngtcp2-android/armeabi-v7a/lib/cmake/ngtcp2/ngtcp2Config.cmake +6 -0
  55. package/android/install/ngtcp2-android/armeabi-v7a/lib/cmake/ngtcp2/ngtcp2ConfigVersion.cmake +65 -0
  56. package/android/install/ngtcp2-android/armeabi-v7a/lib/cmake/ngtcp2/ngtcp2Targets-release.cmake +29 -0
  57. package/android/install/ngtcp2-android/armeabi-v7a/lib/cmake/ngtcp2/ngtcp2Targets.cmake +114 -0
  58. package/android/install/ngtcp2-android/armeabi-v7a/lib/libngtcp2.a +0 -0
  59. package/android/install/ngtcp2-android/armeabi-v7a/lib/libngtcp2.so +0 -0
  60. package/android/install/ngtcp2-android/armeabi-v7a/lib/libngtcp2_crypto_wolfssl.a +0 -0
  61. package/android/install/ngtcp2-android/armeabi-v7a/lib/libngtcp2_crypto_wolfssl.so +0 -0
  62. package/android/install/ngtcp2-android/armeabi-v7a/lib/pkgconfig/libngtcp2.pc +33 -0
  63. package/android/install/ngtcp2-android/armeabi-v7a/lib/pkgconfig/libngtcp2_crypto_wolfssl.pc +34 -0
  64. package/android/install/ngtcp2-android/armeabi-v7a/share/doc/ngtcp2/README.rst +385 -0
  65. package/android/install/ngtcp2-android/x86_64/include/ngtcp2/ngtcp2.h +6254 -0
  66. package/android/install/ngtcp2-android/x86_64/include/ngtcp2/ngtcp2_crypto.h +1037 -0
  67. package/android/install/ngtcp2-android/x86_64/include/ngtcp2/ngtcp2_crypto_wolfssl.h +106 -0
  68. package/android/install/ngtcp2-android/x86_64/include/ngtcp2/version.h +51 -0
  69. package/android/install/ngtcp2-android/x86_64/lib/cmake/ngtcp2/ngtcp2Config.cmake +6 -0
  70. package/android/install/ngtcp2-android/x86_64/lib/cmake/ngtcp2/ngtcp2ConfigVersion.cmake +65 -0
  71. package/android/install/ngtcp2-android/x86_64/lib/cmake/ngtcp2/ngtcp2Targets-release.cmake +29 -0
  72. package/android/install/ngtcp2-android/x86_64/lib/cmake/ngtcp2/ngtcp2Targets.cmake +114 -0
  73. package/android/install/ngtcp2-android/x86_64/lib/libngtcp2.a +0 -0
  74. package/android/install/ngtcp2-android/x86_64/lib/libngtcp2.so +0 -0
  75. package/android/install/ngtcp2-android/x86_64/lib/libngtcp2_crypto_wolfssl.a +0 -0
  76. package/android/install/ngtcp2-android/x86_64/lib/libngtcp2_crypto_wolfssl.so +0 -0
  77. package/android/install/ngtcp2-android/x86_64/lib/pkgconfig/libngtcp2.pc +33 -0
  78. package/android/install/ngtcp2-android/x86_64/lib/pkgconfig/libngtcp2_crypto_wolfssl.pc +34 -0
  79. package/android/install/ngtcp2-android/x86_64/share/doc/ngtcp2/README.rst +385 -0
  80. package/android/install/wolfssl-android/arm64-v8a/bin/wolfssl-config +117 -0
  81. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/callbacks.h +93 -0
  82. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/certs_test.h +7073 -0
  83. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/certs_test_sm.h +2913 -0
  84. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/crl.h +58 -0
  85. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/error-ssl.h +280 -0
  86. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/ocsp.h +191 -0
  87. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/aes.h +117 -0
  88. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/asn1.h +315 -0
  89. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/asn1t.h +30 -0
  90. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/bio.h +237 -0
  91. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/bn.h +332 -0
  92. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/buffer.h +57 -0
  93. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/camellia.h +27 -0
  94. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/cmac.h +66 -0
  95. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/cms.h +26 -0
  96. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/compat_types.h +70 -0
  97. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/conf.h +117 -0
  98. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/crypto.h +171 -0
  99. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/des.h +124 -0
  100. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/dh.h +144 -0
  101. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/dsa.h +164 -0
  102. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/ec.h +525 -0
  103. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/ec25519.h +46 -0
  104. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/ec448.h +46 -0
  105. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/ecdh.h +49 -0
  106. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/ecdsa.h +87 -0
  107. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/ed25519.h +49 -0
  108. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/ed448.h +49 -0
  109. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/engine.h +9 -0
  110. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/err.h +84 -0
  111. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/evp.h +1540 -0
  112. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/fips_rand.h +125 -0
  113. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/hmac.h +98 -0
  114. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/kdf.h +45 -0
  115. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/lhash.h +64 -0
  116. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/md4.h +66 -0
  117. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/md5.h +108 -0
  118. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/modes.h +45 -0
  119. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/obj_mac.h +92 -0
  120. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/objects.h +86 -0
  121. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/ocsp.h +108 -0
  122. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/opensslconf.h +8 -0
  123. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/opensslv.h +78 -0
  124. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/ossl_typ.h +32 -0
  125. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/pem.h +301 -0
  126. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/pkcs12.h +57 -0
  127. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/pkcs7.h +110 -0
  128. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/rand.h +38 -0
  129. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/rc4.h +64 -0
  130. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/ripemd.h +58 -0
  131. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/rsa.h +291 -0
  132. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/safestack.h +40 -0
  133. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/sha.h +331 -0
  134. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/sha3.h +158 -0
  135. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/srp.h +33 -0
  136. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/ssl.h +1923 -0
  137. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/ssl23.h +1 -0
  138. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/stack.h +61 -0
  139. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/tls1.h +64 -0
  140. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/txt_db.h +60 -0
  141. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/ui.h +2 -0
  142. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/x509.h +227 -0
  143. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/x509_vfy.h +50 -0
  144. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/openssl/x509v3.h +237 -0
  145. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/options.h +273 -0
  146. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/quic.h +310 -0
  147. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/sniffer.h +359 -0
  148. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/sniffer_error.h +151 -0
  149. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/ssl.h +6300 -0
  150. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/test.h +4989 -0
  151. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/version.h +40 -0
  152. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/aes.h +1074 -0
  153. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/arc4.h +69 -0
  154. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/ascon.h +109 -0
  155. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/asn.h +2855 -0
  156. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/asn_public.h +1009 -0
  157. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/blake2-impl.h +155 -0
  158. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/blake2-int.h +174 -0
  159. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/blake2.h +108 -0
  160. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/camellia.h +116 -0
  161. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/chacha.h +133 -0
  162. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/chacha20_poly1305.h +157 -0
  163. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/cmac.h +168 -0
  164. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/coding.h +107 -0
  165. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/compress.h +60 -0
  166. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/cpuid.h +153 -0
  167. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/cryptocb.h +770 -0
  168. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/curve25519.h +225 -0
  169. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/curve448.h +151 -0
  170. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/des3.h +167 -0
  171. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/dh.h +210 -0
  172. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/dilithium.h +1051 -0
  173. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/dsa.h +121 -0
  174. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/ecc.h +1074 -0
  175. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/eccsi.h +176 -0
  176. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/ed25519.h +239 -0
  177. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/ed448.h +214 -0
  178. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/error-crypt.h +368 -0
  179. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/ext_lms.h +62 -0
  180. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/ext_mlkem.h +74 -0
  181. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/ext_xmss.h +53 -0
  182. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/falcon.h +180 -0
  183. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/fe_448.h +122 -0
  184. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/fe_operations.h +189 -0
  185. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/fips_test.h +131 -0
  186. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/ge_448.h +84 -0
  187. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/ge_operations.h +134 -0
  188. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/hash.h +296 -0
  189. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/hmac.h +231 -0
  190. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/hpke.h +145 -0
  191. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/integer.h +449 -0
  192. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/kdf.h +199 -0
  193. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/lms.h +202 -0
  194. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/logging.h +588 -0
  195. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/md2.h +83 -0
  196. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/md4.h +77 -0
  197. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/md5.h +141 -0
  198. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/mem_track.h +968 -0
  199. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/memory.h +545 -0
  200. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/misc.h +214 -0
  201. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/mlkem.h +377 -0
  202. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/mpi_class.h +1021 -0
  203. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/mpi_superclass.h +96 -0
  204. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/oid_sum.h +1907 -0
  205. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/pkcs12.h +79 -0
  206. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/pkcs7.h +578 -0
  207. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/poly1305.h +207 -0
  208. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/pwdbased.h +81 -0
  209. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/random.h +300 -0
  210. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/rc2.h +68 -0
  211. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/ripemd.h +67 -0
  212. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/rsa.h +494 -0
  213. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/sakke.h +228 -0
  214. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/settings.h +4762 -0
  215. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/sha.h +237 -0
  216. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/sha256.h +360 -0
  217. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/sha3.h +274 -0
  218. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/sha512.h +372 -0
  219. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/signature.h +87 -0
  220. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/siphash.h +101 -0
  221. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/sm2.h +27 -0
  222. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/sm3.h +27 -0
  223. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/sm4.h +27 -0
  224. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/sp_int.h +1396 -0
  225. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/sphincs.h +167 -0
  226. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/srp.h +313 -0
  227. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/tfm.h +941 -0
  228. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/types.h +2383 -0
  229. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/visibility.h +97 -0
  230. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/wc_encrypt.h +126 -0
  231. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/wc_lms.h +506 -0
  232. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/wc_mlkem.h +370 -0
  233. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/wc_port.h +1764 -0
  234. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/wc_xmss.h +285 -0
  235. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/wolfevent.h +120 -0
  236. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/wolfmath.h +175 -0
  237. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfcrypt/xmss.h +203 -0
  238. package/android/install/wolfssl-android/arm64-v8a/include/wolfssl/wolfio.h +1035 -0
  239. package/android/install/wolfssl-android/arm64-v8a/lib/libwolfssl.a +0 -0
  240. package/android/install/wolfssl-android/arm64-v8a/lib/libwolfssl.la +41 -0
  241. package/android/install/wolfssl-android/arm64-v8a/lib/pkgconfig/wolfssl.pc +11 -0
  242. package/android/install/wolfssl-android/arm64-v8a/share/doc/wolfssl/QUIC.md +117 -0
  243. package/android/install/wolfssl-android/arm64-v8a/share/doc/wolfssl/README.txt +8 -0
  244. package/android/install/wolfssl-android/arm64-v8a/share/doc/wolfssl/example/async_client.c +245 -0
  245. package/android/install/wolfssl-android/arm64-v8a/share/doc/wolfssl/example/async_server.c +331 -0
  246. package/android/install/wolfssl-android/arm64-v8a/share/doc/wolfssl/example/client.c +4885 -0
  247. package/android/install/wolfssl-android/arm64-v8a/share/doc/wolfssl/example/echoclient.c +341 -0
  248. package/android/install/wolfssl-android/arm64-v8a/share/doc/wolfssl/example/echoserver.c +498 -0
  249. package/android/install/wolfssl-android/arm64-v8a/share/doc/wolfssl/example/sctp-client-dtls.c +135 -0
  250. package/android/install/wolfssl-android/arm64-v8a/share/doc/wolfssl/example/sctp-client.c +78 -0
  251. package/android/install/wolfssl-android/arm64-v8a/share/doc/wolfssl/example/sctp-server-dtls.c +134 -0
  252. package/android/install/wolfssl-android/arm64-v8a/share/doc/wolfssl/example/sctp-server.c +83 -0
  253. package/android/install/wolfssl-android/arm64-v8a/share/doc/wolfssl/example/server.c +4124 -0
  254. package/android/install/wolfssl-android/arm64-v8a/share/doc/wolfssl/example/tls_bench.c +2357 -0
  255. package/android/install/wolfssl-android/arm64-v8a/share/doc/wolfssl/taoCert.txt +176 -0
  256. package/android/install/wolfssl-android/armeabi-v7a/bin/wolfssl-config +117 -0
  257. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/callbacks.h +93 -0
  258. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/certs_test.h +7073 -0
  259. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/certs_test_sm.h +2913 -0
  260. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/crl.h +58 -0
  261. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/error-ssl.h +280 -0
  262. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/ocsp.h +191 -0
  263. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/aes.h +117 -0
  264. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/asn1.h +315 -0
  265. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/asn1t.h +30 -0
  266. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/bio.h +237 -0
  267. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/bn.h +332 -0
  268. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/buffer.h +57 -0
  269. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/camellia.h +27 -0
  270. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/cmac.h +66 -0
  271. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/cms.h +26 -0
  272. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/compat_types.h +70 -0
  273. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/conf.h +117 -0
  274. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/crypto.h +171 -0
  275. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/des.h +124 -0
  276. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/dh.h +144 -0
  277. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/dsa.h +164 -0
  278. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/ec.h +525 -0
  279. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/ec25519.h +46 -0
  280. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/ec448.h +46 -0
  281. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/ecdh.h +49 -0
  282. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/ecdsa.h +87 -0
  283. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/ed25519.h +49 -0
  284. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/ed448.h +49 -0
  285. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/engine.h +9 -0
  286. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/err.h +84 -0
  287. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/evp.h +1540 -0
  288. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/fips_rand.h +125 -0
  289. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/hmac.h +98 -0
  290. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/kdf.h +45 -0
  291. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/lhash.h +64 -0
  292. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/md4.h +66 -0
  293. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/md5.h +108 -0
  294. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/modes.h +45 -0
  295. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/obj_mac.h +92 -0
  296. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/objects.h +86 -0
  297. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/ocsp.h +108 -0
  298. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/opensslconf.h +8 -0
  299. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/opensslv.h +78 -0
  300. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/ossl_typ.h +32 -0
  301. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/pem.h +301 -0
  302. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/pkcs12.h +57 -0
  303. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/pkcs7.h +110 -0
  304. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/rand.h +38 -0
  305. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/rc4.h +64 -0
  306. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/ripemd.h +58 -0
  307. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/rsa.h +291 -0
  308. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/safestack.h +40 -0
  309. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/sha.h +331 -0
  310. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/sha3.h +158 -0
  311. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/srp.h +33 -0
  312. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/ssl.h +1923 -0
  313. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/ssl23.h +1 -0
  314. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/stack.h +61 -0
  315. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/tls1.h +64 -0
  316. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/txt_db.h +60 -0
  317. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/ui.h +2 -0
  318. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/x509.h +227 -0
  319. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/x509_vfy.h +50 -0
  320. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/openssl/x509v3.h +237 -0
  321. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/options.h +261 -0
  322. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/quic.h +310 -0
  323. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/sniffer.h +359 -0
  324. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/sniffer_error.h +151 -0
  325. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/ssl.h +6300 -0
  326. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/test.h +4989 -0
  327. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/version.h +40 -0
  328. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/aes.h +1074 -0
  329. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/arc4.h +69 -0
  330. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/ascon.h +109 -0
  331. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/asn.h +2855 -0
  332. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/asn_public.h +1009 -0
  333. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/blake2-impl.h +155 -0
  334. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/blake2-int.h +174 -0
  335. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/blake2.h +108 -0
  336. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/camellia.h +116 -0
  337. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/chacha.h +133 -0
  338. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/chacha20_poly1305.h +157 -0
  339. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/cmac.h +168 -0
  340. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/coding.h +107 -0
  341. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/compress.h +60 -0
  342. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/cpuid.h +153 -0
  343. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/cryptocb.h +770 -0
  344. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/curve25519.h +225 -0
  345. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/curve448.h +151 -0
  346. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/des3.h +167 -0
  347. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/dh.h +210 -0
  348. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/dilithium.h +1051 -0
  349. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/dsa.h +121 -0
  350. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/ecc.h +1074 -0
  351. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/eccsi.h +176 -0
  352. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/ed25519.h +239 -0
  353. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/ed448.h +214 -0
  354. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/error-crypt.h +368 -0
  355. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/ext_lms.h +62 -0
  356. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/ext_mlkem.h +74 -0
  357. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/ext_xmss.h +53 -0
  358. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/falcon.h +180 -0
  359. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/fe_448.h +122 -0
  360. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/fe_operations.h +189 -0
  361. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/fips_test.h +131 -0
  362. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/ge_448.h +84 -0
  363. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/ge_operations.h +134 -0
  364. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/hash.h +296 -0
  365. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/hmac.h +231 -0
  366. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/hpke.h +145 -0
  367. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/integer.h +449 -0
  368. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/kdf.h +199 -0
  369. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/lms.h +202 -0
  370. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/logging.h +588 -0
  371. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/md2.h +83 -0
  372. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/md4.h +77 -0
  373. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/md5.h +141 -0
  374. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/mem_track.h +968 -0
  375. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/memory.h +545 -0
  376. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/misc.h +214 -0
  377. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/mlkem.h +377 -0
  378. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/mpi_class.h +1021 -0
  379. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/mpi_superclass.h +96 -0
  380. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/oid_sum.h +1907 -0
  381. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/pkcs12.h +79 -0
  382. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/pkcs7.h +578 -0
  383. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/poly1305.h +207 -0
  384. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/pwdbased.h +81 -0
  385. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/random.h +300 -0
  386. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/rc2.h +68 -0
  387. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/ripemd.h +67 -0
  388. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/rsa.h +494 -0
  389. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/sakke.h +228 -0
  390. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/settings.h +4762 -0
  391. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/sha.h +237 -0
  392. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/sha256.h +360 -0
  393. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/sha3.h +274 -0
  394. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/sha512.h +372 -0
  395. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/signature.h +87 -0
  396. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/siphash.h +101 -0
  397. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/sm2.h +27 -0
  398. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/sm3.h +27 -0
  399. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/sm4.h +27 -0
  400. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/sp_int.h +1396 -0
  401. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/sphincs.h +167 -0
  402. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/srp.h +313 -0
  403. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/tfm.h +941 -0
  404. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/types.h +2383 -0
  405. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/visibility.h +97 -0
  406. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/wc_encrypt.h +126 -0
  407. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/wc_lms.h +506 -0
  408. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/wc_mlkem.h +370 -0
  409. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/wc_port.h +1764 -0
  410. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/wc_xmss.h +285 -0
  411. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/wolfevent.h +120 -0
  412. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/wolfmath.h +175 -0
  413. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfcrypt/xmss.h +203 -0
  414. package/android/install/wolfssl-android/armeabi-v7a/include/wolfssl/wolfio.h +1035 -0
  415. package/android/install/wolfssl-android/armeabi-v7a/lib/libwolfssl.a +0 -0
  416. package/android/install/wolfssl-android/armeabi-v7a/lib/libwolfssl.la +41 -0
  417. package/android/install/wolfssl-android/armeabi-v7a/lib/pkgconfig/wolfssl.pc +11 -0
  418. package/android/install/wolfssl-android/armeabi-v7a/share/doc/wolfssl/QUIC.md +117 -0
  419. package/android/install/wolfssl-android/armeabi-v7a/share/doc/wolfssl/README.txt +8 -0
  420. package/android/install/wolfssl-android/armeabi-v7a/share/doc/wolfssl/example/async_client.c +245 -0
  421. package/android/install/wolfssl-android/armeabi-v7a/share/doc/wolfssl/example/async_server.c +331 -0
  422. package/android/install/wolfssl-android/armeabi-v7a/share/doc/wolfssl/example/client.c +4885 -0
  423. package/android/install/wolfssl-android/armeabi-v7a/share/doc/wolfssl/example/echoclient.c +341 -0
  424. package/android/install/wolfssl-android/armeabi-v7a/share/doc/wolfssl/example/echoserver.c +498 -0
  425. package/android/install/wolfssl-android/armeabi-v7a/share/doc/wolfssl/example/sctp-client-dtls.c +135 -0
  426. package/android/install/wolfssl-android/armeabi-v7a/share/doc/wolfssl/example/sctp-client.c +78 -0
  427. package/android/install/wolfssl-android/armeabi-v7a/share/doc/wolfssl/example/sctp-server-dtls.c +134 -0
  428. package/android/install/wolfssl-android/armeabi-v7a/share/doc/wolfssl/example/sctp-server.c +83 -0
  429. package/android/install/wolfssl-android/armeabi-v7a/share/doc/wolfssl/example/server.c +4124 -0
  430. package/android/install/wolfssl-android/armeabi-v7a/share/doc/wolfssl/example/tls_bench.c +2357 -0
  431. package/android/install/wolfssl-android/armeabi-v7a/share/doc/wolfssl/taoCert.txt +176 -0
  432. package/android/install/wolfssl-android/x86_64/bin/wolfssl-config +117 -0
  433. package/android/install/wolfssl-android/x86_64/include/wolfssl/callbacks.h +93 -0
  434. package/android/install/wolfssl-android/x86_64/include/wolfssl/certs_test.h +7073 -0
  435. package/android/install/wolfssl-android/x86_64/include/wolfssl/certs_test_sm.h +2913 -0
  436. package/android/install/wolfssl-android/x86_64/include/wolfssl/crl.h +58 -0
  437. package/android/install/wolfssl-android/x86_64/include/wolfssl/error-ssl.h +280 -0
  438. package/android/install/wolfssl-android/x86_64/include/wolfssl/ocsp.h +191 -0
  439. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/aes.h +117 -0
  440. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/asn1.h +315 -0
  441. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/asn1t.h +30 -0
  442. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/bio.h +237 -0
  443. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/bn.h +332 -0
  444. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/buffer.h +57 -0
  445. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/camellia.h +27 -0
  446. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/cmac.h +66 -0
  447. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/cms.h +26 -0
  448. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/compat_types.h +70 -0
  449. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/conf.h +117 -0
  450. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/crypto.h +171 -0
  451. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/des.h +124 -0
  452. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/dh.h +144 -0
  453. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/dsa.h +164 -0
  454. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/ec.h +525 -0
  455. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/ec25519.h +46 -0
  456. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/ec448.h +46 -0
  457. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/ecdh.h +49 -0
  458. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/ecdsa.h +87 -0
  459. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/ed25519.h +49 -0
  460. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/ed448.h +49 -0
  461. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/engine.h +9 -0
  462. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/err.h +84 -0
  463. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/evp.h +1540 -0
  464. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/fips_rand.h +125 -0
  465. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/hmac.h +98 -0
  466. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/kdf.h +45 -0
  467. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/lhash.h +64 -0
  468. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/md4.h +66 -0
  469. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/md5.h +108 -0
  470. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/modes.h +45 -0
  471. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/obj_mac.h +92 -0
  472. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/objects.h +86 -0
  473. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/ocsp.h +108 -0
  474. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/opensslconf.h +8 -0
  475. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/opensslv.h +78 -0
  476. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/ossl_typ.h +32 -0
  477. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/pem.h +301 -0
  478. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/pkcs12.h +57 -0
  479. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/pkcs7.h +110 -0
  480. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/rand.h +38 -0
  481. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/rc4.h +64 -0
  482. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/ripemd.h +58 -0
  483. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/rsa.h +291 -0
  484. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/safestack.h +40 -0
  485. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/sha.h +331 -0
  486. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/sha3.h +158 -0
  487. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/srp.h +33 -0
  488. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/ssl.h +1923 -0
  489. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/ssl23.h +1 -0
  490. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/stack.h +61 -0
  491. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/tls1.h +64 -0
  492. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/txt_db.h +60 -0
  493. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/ui.h +2 -0
  494. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/x509.h +227 -0
  495. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/x509_vfy.h +50 -0
  496. package/android/install/wolfssl-android/x86_64/include/wolfssl/openssl/x509v3.h +237 -0
  497. package/android/install/wolfssl-android/x86_64/include/wolfssl/options.h +273 -0
  498. package/android/install/wolfssl-android/x86_64/include/wolfssl/quic.h +310 -0
  499. package/android/install/wolfssl-android/x86_64/include/wolfssl/sniffer.h +359 -0
  500. package/android/install/wolfssl-android/x86_64/include/wolfssl/sniffer_error.h +151 -0
  501. package/android/install/wolfssl-android/x86_64/include/wolfssl/ssl.h +6300 -0
  502. package/android/install/wolfssl-android/x86_64/include/wolfssl/test.h +4989 -0
  503. package/android/install/wolfssl-android/x86_64/include/wolfssl/version.h +40 -0
  504. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/aes.h +1074 -0
  505. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/arc4.h +69 -0
  506. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/ascon.h +109 -0
  507. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/asn.h +2855 -0
  508. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/asn_public.h +1009 -0
  509. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/blake2-impl.h +155 -0
  510. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/blake2-int.h +174 -0
  511. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/blake2.h +108 -0
  512. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/camellia.h +116 -0
  513. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/chacha.h +133 -0
  514. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/chacha20_poly1305.h +157 -0
  515. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/cmac.h +168 -0
  516. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/coding.h +107 -0
  517. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/compress.h +60 -0
  518. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/cpuid.h +153 -0
  519. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/cryptocb.h +770 -0
  520. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/curve25519.h +225 -0
  521. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/curve448.h +151 -0
  522. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/des3.h +167 -0
  523. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/dh.h +210 -0
  524. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/dilithium.h +1051 -0
  525. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/dsa.h +121 -0
  526. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/ecc.h +1074 -0
  527. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/eccsi.h +176 -0
  528. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/ed25519.h +239 -0
  529. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/ed448.h +214 -0
  530. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/error-crypt.h +368 -0
  531. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/ext_lms.h +62 -0
  532. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/ext_mlkem.h +74 -0
  533. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/ext_xmss.h +53 -0
  534. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/falcon.h +180 -0
  535. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/fe_448.h +122 -0
  536. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/fe_operations.h +189 -0
  537. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/fips_test.h +131 -0
  538. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/ge_448.h +84 -0
  539. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/ge_operations.h +134 -0
  540. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/hash.h +296 -0
  541. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/hmac.h +231 -0
  542. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/hpke.h +145 -0
  543. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/integer.h +449 -0
  544. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/kdf.h +199 -0
  545. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/lms.h +202 -0
  546. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/logging.h +588 -0
  547. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/md2.h +83 -0
  548. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/md4.h +77 -0
  549. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/md5.h +141 -0
  550. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/mem_track.h +968 -0
  551. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/memory.h +545 -0
  552. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/misc.h +214 -0
  553. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/mlkem.h +377 -0
  554. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/mpi_class.h +1021 -0
  555. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/mpi_superclass.h +96 -0
  556. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/oid_sum.h +1907 -0
  557. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/pkcs12.h +79 -0
  558. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/pkcs7.h +578 -0
  559. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/poly1305.h +207 -0
  560. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/pwdbased.h +81 -0
  561. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/random.h +300 -0
  562. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/rc2.h +68 -0
  563. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/ripemd.h +67 -0
  564. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/rsa.h +494 -0
  565. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/sakke.h +228 -0
  566. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/settings.h +4762 -0
  567. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/sha.h +237 -0
  568. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/sha256.h +360 -0
  569. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/sha3.h +274 -0
  570. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/sha512.h +372 -0
  571. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/signature.h +87 -0
  572. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/siphash.h +101 -0
  573. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/sm2.h +27 -0
  574. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/sm3.h +27 -0
  575. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/sm4.h +27 -0
  576. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/sp_int.h +1396 -0
  577. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/sphincs.h +167 -0
  578. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/srp.h +313 -0
  579. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/tfm.h +941 -0
  580. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/types.h +2383 -0
  581. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/visibility.h +97 -0
  582. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/wc_encrypt.h +126 -0
  583. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/wc_lms.h +506 -0
  584. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/wc_mlkem.h +370 -0
  585. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/wc_port.h +1764 -0
  586. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/wc_xmss.h +285 -0
  587. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/wolfevent.h +120 -0
  588. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/wolfmath.h +175 -0
  589. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfcrypt/xmss.h +203 -0
  590. package/android/install/wolfssl-android/x86_64/include/wolfssl/wolfio.h +1035 -0
  591. package/android/install/wolfssl-android/x86_64/lib/libwolfssl.a +0 -0
  592. package/android/install/wolfssl-android/x86_64/lib/libwolfssl.la +41 -0
  593. package/android/install/wolfssl-android/x86_64/lib/pkgconfig/wolfssl.pc +11 -0
  594. package/android/install/wolfssl-android/x86_64/share/doc/wolfssl/QUIC.md +117 -0
  595. package/android/install/wolfssl-android/x86_64/share/doc/wolfssl/README.txt +8 -0
  596. package/android/install/wolfssl-android/x86_64/share/doc/wolfssl/example/async_client.c +245 -0
  597. package/android/install/wolfssl-android/x86_64/share/doc/wolfssl/example/async_server.c +331 -0
  598. package/android/install/wolfssl-android/x86_64/share/doc/wolfssl/example/client.c +4885 -0
  599. package/android/install/wolfssl-android/x86_64/share/doc/wolfssl/example/echoclient.c +341 -0
  600. package/android/install/wolfssl-android/x86_64/share/doc/wolfssl/example/echoserver.c +498 -0
  601. package/android/install/wolfssl-android/x86_64/share/doc/wolfssl/example/sctp-client-dtls.c +135 -0
  602. package/android/install/wolfssl-android/x86_64/share/doc/wolfssl/example/sctp-client.c +78 -0
  603. package/android/install/wolfssl-android/x86_64/share/doc/wolfssl/example/sctp-server-dtls.c +134 -0
  604. package/android/install/wolfssl-android/x86_64/share/doc/wolfssl/example/sctp-server.c +83 -0
  605. package/android/install/wolfssl-android/x86_64/share/doc/wolfssl/example/server.c +4124 -0
  606. package/android/install/wolfssl-android/x86_64/share/doc/wolfssl/example/tls_bench.c +2357 -0
  607. package/android/install/wolfssl-android/x86_64/share/doc/wolfssl/taoCert.txt +176 -0
  608. package/android/src/main/cpp/CMakeLists.txt +19 -27
  609. package/android/src/main/cpp/ngtcp2_jni.cpp +30 -36
  610. package/android/src/main/kotlin/ai/annadata/mqttquic/MqttQuicPlugin.kt +15 -0
  611. package/android/src/main/kotlin/ai/annadata/mqttquic/client/MQTTClient.kt +6 -2
  612. package/build-native.sh +397 -0
  613. package/deps-versions.sh +25 -0
  614. package/dist/esm/definitions.d.ts +20 -0
  615. package/dist/esm/definitions.d.ts.map +1 -1
  616. package/dist/esm/web.d.ts +26 -3
  617. package/dist/esm/web.d.ts.map +1 -1
  618. package/dist/esm/web.js +230 -10
  619. package/dist/esm/web.js.map +1 -1
  620. package/dist/plugin.cjs.js +11363 -13
  621. package/dist/plugin.cjs.js.map +1 -1
  622. package/dist/plugin.js +11364 -14
  623. package/dist/plugin.js.map +1 -1
  624. package/docs/ARCHITECTURAL_ANALYSIS.md +710 -0
  625. package/docs/CAPACITOR_MQTT_QUIC_PRODUCTION_PLUGIN.md +190 -0
  626. package/docs/CAPACITOR_VERSION_SUPPORT.md +65 -0
  627. package/docs/IMPLEMENTATION_SUMMARY.md +246 -0
  628. package/docs/MQTT5_CLIENT_COMPLIANCE.md +48 -0
  629. package/docs/MQTT5_IMPLEMENTATION_COMPLETE.md +178 -0
  630. package/docs/MQTT_VERSION_ANALYSIS.md +233 -0
  631. package/docs/NGTCP2_IMPLEMENTATION_STATUS.md +214 -0
  632. package/docs/NGTCP2_INTEGRATION_PLAN.md +597 -0
  633. package/docs/P0_P1_CHANGELOG.md +79 -0
  634. package/docs/PRODUCTION_PUBLISH_STEPS.md +161 -0
  635. package/docs/PROJECT_OVERVIEW.md +193 -0
  636. package/ios/.swiftpm/xcode/xcuserdata/annadata.xcuserdatad/xcschemes/xcschememanagement.plist +1 -1
  637. package/ios/NGTCP2_BUILD_INSTRUCTIONS.md +12 -0
  638. package/ios/Sources/MqttQuicPlugin/MqttQuicPlugin.swift +6 -0
  639. package/ios/Sources/MqttQuicPlugin/QUIC/NGTCP2Bridge.mm +6 -0
  640. package/ios/build-openssl.sh +1 -1
  641. package/ios/libs/MqttQuicLibs.xcframework/ios-arm64/libmqttquic_native_device.a +0 -0
  642. package/ios/libs/MqttQuicLibs.xcframework/ios-arm64_x86_64-simulator/libmqttquic_native_simulator.a +0 -0
  643. package/ios/libs/libnghttp3.a +0 -0
  644. package/ios/libs/libngtcp2.a +0 -0
  645. package/ios/libs/libngtcp2_crypto_wolfssl.a +0 -0
  646. package/ios/libs/libwolfssl.a +0 -0
  647. package/ios/libs-simulator/libnghttp3.a +0 -0
  648. package/ios/libs-simulator/libngtcp2.a +0 -0
  649. package/ios/libs-simulator/libngtcp2_crypto_wolfssl.a +0 -0
  650. package/ios/libs-simulator/libwolfssl.a +0 -0
  651. package/ios/libs-simulator-x86_64/libnghttp3.a +0 -0
  652. package/ios/libs-simulator-x86_64/libngtcp2.a +0 -0
  653. package/ios/libs-simulator-x86_64/libngtcp2_crypto_wolfssl.a +0 -0
  654. package/ios/libs-simulator-x86_64/libwolfssl.a +0 -0
  655. package/package.json +22 -8
  656. package/ios/include/ngtcp2/ngtcp2_crypto_quictls.h +0 -147
  657. package/ios/include/openssl/aes.h +0 -111
  658. package/ios/include/openssl/asn1.h +0 -1131
  659. package/ios/include/openssl/asn1_mac.h +0 -10
  660. package/ios/include/openssl/asn1err.h +0 -140
  661. package/ios/include/openssl/asn1t.h +0 -946
  662. package/ios/include/openssl/async.h +0 -96
  663. package/ios/include/openssl/asyncerr.h +0 -29
  664. package/ios/include/openssl/bio.h +0 -887
  665. package/ios/include/openssl/bioerr.h +0 -65
  666. package/ios/include/openssl/blowfish.h +0 -78
  667. package/ios/include/openssl/bn.h +0 -584
  668. package/ios/include/openssl/bnerr.h +0 -47
  669. package/ios/include/openssl/buffer.h +0 -62
  670. package/ios/include/openssl/buffererr.h +0 -25
  671. package/ios/include/openssl/camellia.h +0 -117
  672. package/ios/include/openssl/cast.h +0 -71
  673. package/ios/include/openssl/cmac.h +0 -52
  674. package/ios/include/openssl/cmp.h +0 -597
  675. package/ios/include/openssl/cmp_util.h +0 -56
  676. package/ios/include/openssl/cmperr.h +0 -116
  677. package/ios/include/openssl/cms.h +0 -493
  678. package/ios/include/openssl/cmserr.h +0 -124
  679. package/ios/include/openssl/comp.h +0 -59
  680. package/ios/include/openssl/comperr.h +0 -31
  681. package/ios/include/openssl/conf.h +0 -214
  682. package/ios/include/openssl/conf_api.h +0 -46
  683. package/ios/include/openssl/conferr.h +0 -52
  684. package/ios/include/openssl/configuration.h +0 -149
  685. package/ios/include/openssl/conftypes.h +0 -44
  686. package/ios/include/openssl/core.h +0 -233
  687. package/ios/include/openssl/core_dispatch.h +0 -960
  688. package/ios/include/openssl/core_names.h +0 -561
  689. package/ios/include/openssl/core_object.h +0 -41
  690. package/ios/include/openssl/crmf.h +0 -227
  691. package/ios/include/openssl/crmferr.h +0 -50
  692. package/ios/include/openssl/crypto.h +0 -558
  693. package/ios/include/openssl/cryptoerr.h +0 -55
  694. package/ios/include/openssl/cryptoerr_legacy.h +0 -1466
  695. package/ios/include/openssl/ct.h +0 -573
  696. package/ios/include/openssl/cterr.h +0 -45
  697. package/ios/include/openssl/decoder.h +0 -133
  698. package/ios/include/openssl/decodererr.h +0 -28
  699. package/ios/include/openssl/des.h +0 -211
  700. package/ios/include/openssl/dh.h +0 -335
  701. package/ios/include/openssl/dherr.h +0 -58
  702. package/ios/include/openssl/dsa.h +0 -280
  703. package/ios/include/openssl/dsaerr.h +0 -44
  704. package/ios/include/openssl/dtls1.h +0 -57
  705. package/ios/include/openssl/e_os2.h +0 -308
  706. package/ios/include/openssl/ebcdic.h +0 -39
  707. package/ios/include/openssl/ec.h +0 -1572
  708. package/ios/include/openssl/ecdh.h +0 -10
  709. package/ios/include/openssl/ecdsa.h +0 -10
  710. package/ios/include/openssl/ecerr.h +0 -104
  711. package/ios/include/openssl/encoder.h +0 -124
  712. package/ios/include/openssl/encodererr.h +0 -28
  713. package/ios/include/openssl/engine.h +0 -833
  714. package/ios/include/openssl/engineerr.h +0 -63
  715. package/ios/include/openssl/err.h +0 -504
  716. package/ios/include/openssl/ess.h +0 -128
  717. package/ios/include/openssl/esserr.h +0 -32
  718. package/ios/include/openssl/evp.h +0 -2175
  719. package/ios/include/openssl/evperr.h +0 -134
  720. package/ios/include/openssl/fips_names.h +0 -77
  721. package/ios/include/openssl/fipskey.h +0 -36
  722. package/ios/include/openssl/hmac.h +0 -62
  723. package/ios/include/openssl/http.h +0 -109
  724. package/ios/include/openssl/httperr.h +0 -55
  725. package/ios/include/openssl/idea.h +0 -82
  726. package/ios/include/openssl/kdf.h +0 -138
  727. package/ios/include/openssl/kdferr.h +0 -16
  728. package/ios/include/openssl/lhash.h +0 -331
  729. package/ios/include/openssl/macros.h +0 -325
  730. package/ios/include/openssl/md2.h +0 -56
  731. package/ios/include/openssl/md4.h +0 -63
  732. package/ios/include/openssl/md5.h +0 -62
  733. package/ios/include/openssl/mdc2.h +0 -55
  734. package/ios/include/openssl/modes.h +0 -219
  735. package/ios/include/openssl/obj_mac.h +0 -5481
  736. package/ios/include/openssl/objects.h +0 -183
  737. package/ios/include/openssl/objectserr.h +0 -28
  738. package/ios/include/openssl/ocsp.h +0 -483
  739. package/ios/include/openssl/ocsperr.h +0 -53
  740. package/ios/include/openssl/opensslconf.h +0 -17
  741. package/ios/include/openssl/opensslv.h +0 -114
  742. package/ios/include/openssl/ossl_typ.h +0 -16
  743. package/ios/include/openssl/param_build.h +0 -63
  744. package/ios/include/openssl/params.h +0 -160
  745. package/ios/include/openssl/pem.h +0 -541
  746. package/ios/include/openssl/pem2.h +0 -19
  747. package/ios/include/openssl/pemerr.h +0 -58
  748. package/ios/include/openssl/pkcs12.h +0 -353
  749. package/ios/include/openssl/pkcs12err.h +0 -45
  750. package/ios/include/openssl/pkcs7.h +0 -430
  751. package/ios/include/openssl/pkcs7err.h +0 -63
  752. package/ios/include/openssl/prov_ssl.h +0 -34
  753. package/ios/include/openssl/proverr.h +0 -149
  754. package/ios/include/openssl/provider.h +0 -60
  755. package/ios/include/openssl/quic.h +0 -19
  756. package/ios/include/openssl/rand.h +0 -125
  757. package/ios/include/openssl/randerr.h +0 -69
  758. package/ios/include/openssl/rc2.h +0 -68
  759. package/ios/include/openssl/rc4.h +0 -47
  760. package/ios/include/openssl/rc5.h +0 -79
  761. package/ios/include/openssl/ripemd.h +0 -59
  762. package/ios/include/openssl/rsa.h +0 -610
  763. package/ios/include/openssl/rsaerr.h +0 -107
  764. package/ios/include/openssl/safestack.h +0 -297
  765. package/ios/include/openssl/seed.h +0 -113
  766. package/ios/include/openssl/self_test.h +0 -94
  767. package/ios/include/openssl/sha.h +0 -138
  768. package/ios/include/openssl/srp.h +0 -285
  769. package/ios/include/openssl/srtp.h +0 -56
  770. package/ios/include/openssl/ssl.h +0 -2671
  771. package/ios/include/openssl/ssl2.h +0 -30
  772. package/ios/include/openssl/ssl3.h +0 -347
  773. package/ios/include/openssl/sslerr.h +0 -348
  774. package/ios/include/openssl/sslerr_legacy.h +0 -468
  775. package/ios/include/openssl/stack.h +0 -90
  776. package/ios/include/openssl/store.h +0 -369
  777. package/ios/include/openssl/storeerr.h +0 -49
  778. package/ios/include/openssl/symhacks.h +0 -39
  779. package/ios/include/openssl/tls1.h +0 -1186
  780. package/ios/include/openssl/trace.h +0 -312
  781. package/ios/include/openssl/ts.h +0 -505
  782. package/ios/include/openssl/tserr.h +0 -67
  783. package/ios/include/openssl/txt_db.h +0 -63
  784. package/ios/include/openssl/types.h +0 -239
  785. package/ios/include/openssl/ui.h +0 -407
  786. package/ios/include/openssl/uierr.h +0 -38
  787. package/ios/include/openssl/whrlpool.h +0 -62
  788. package/ios/include/openssl/x509.h +0 -1279
  789. package/ios/include/openssl/x509_vfy.h +0 -894
  790. package/ios/include/openssl/x509err.h +0 -69
  791. package/ios/include/openssl/x509v3.h +0 -1453
  792. package/ios/include/openssl/x509v3err.h +0 -93
  793. package/ios/libs/libcrypto.a +0 -0
  794. package/ios/libs/libngtcp2_crypto_quictls.a +0 -0
  795. package/ios/libs/libssl.a +0 -0
@@ -0,0 +1,4124 @@
1
+ /* server.c
2
+ *
3
+ * Copyright (C) 2006-2025 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 3 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
+ /* For simpler wolfSSL TLS server examples, visit
23
+ * https://github.com/wolfSSL/wolfssl-examples/tree/master/tls
24
+ */
25
+
26
+ #ifdef HAVE_CONFIG_H
27
+ #include <config.h>
28
+ #endif
29
+
30
+ #ifndef WOLFSSL_USER_SETTINGS
31
+ #include <wolfssl/options.h>
32
+ #endif
33
+ #include <wolfssl/wolfcrypt/settings.h>
34
+
35
+ #undef TEST_OPENSSL_COEXIST /* can't use this option with this example */
36
+ #undef OPENSSL_COEXIST /* can't use this option with this example */
37
+
38
+ /* Force enable the compatibility macros for this example */
39
+ #ifndef OPENSSL_EXTRA_X509_SMALL
40
+ #define OPENSSL_EXTRA_X509_SMALL
41
+ #endif
42
+ #include <wolfssl/openssl/ssl.h>
43
+
44
+ #undef OPENSSL_EXTRA_X509_SMALL
45
+ #include <wolfssl/ssl.h> /* name change portability layer */
46
+
47
+ #ifdef HAVE_ECC
48
+ #include <wolfssl/wolfcrypt/ecc.h> /* wc_ecc_fp_free */
49
+ #endif
50
+
51
+ #ifdef WOLFSSL_WOLFSENTRY_HOOKS
52
+ #include <wolfsentry/wolfsentry.h>
53
+ #if !defined(NO_FILESYSTEM) && !defined(WOLFSENTRY_NO_JSON)
54
+ static const char *wolfsentry_config_path = NULL;
55
+ #endif
56
+ #endif /* WOLFSSL_WOLFSENTRY_HOOKS */
57
+ #if defined(WOLFSSL_MDK_ARM) || defined(WOLFSSL_KEIL_TCP_NET)
58
+ #include <stdio.h>
59
+ #include <string.h>
60
+ #include "rl_fs.h"
61
+ #include "rl_net.h"
62
+ #endif
63
+
64
+ #ifdef NO_FILESYSTEM
65
+ #ifdef NO_RSA
66
+ #error currently the example only tries to load in a RSA buffer
67
+ #endif
68
+ #undef USE_CERT_BUFFERS_2048
69
+ #define USE_CERT_BUFFERS_2048
70
+ #include <wolfssl/certs_test.h>
71
+ #endif
72
+
73
+ #include <wolfssl/test.h>
74
+ #include <wolfssl/error-ssl.h>
75
+
76
+ #include "examples/server/server.h"
77
+
78
+ #if !defined(NO_WOLFSSL_SERVER) && !defined(NO_TLS)
79
+
80
+ #if defined(WOLFSSL_TLS13) && ( \
81
+ defined(HAVE_ECC) \
82
+ || defined(HAVE_CURVE25519) \
83
+ || defined(HAVE_CURVE448) \
84
+ || defined(HAVE_FFDHE_2048))
85
+ #define CAN_FORCE_CURVE
86
+ #endif
87
+ #if defined(CAN_FORCE_CURVE) && defined(HAVE_ECC)
88
+ struct group_info {
89
+ word16 group;
90
+ const char *name;
91
+ };
92
+ static struct group_info group_id_to_text[] = {
93
+ { WOLFSSL_ECC_SECP160K1, "SECP160K1" },
94
+ { WOLFSSL_ECC_SECP160R1, "SECP160R1" },
95
+ { WOLFSSL_ECC_SECP160R2, "SECP160R2" },
96
+ { WOLFSSL_ECC_SECP192K1, "SECP192K1" },
97
+ { WOLFSSL_ECC_SECP192R1, "SECP192R1" },
98
+ { WOLFSSL_ECC_SECP224K1, "SECP224K1" },
99
+ { WOLFSSL_ECC_SECP224R1, "SECP224R1" },
100
+ { WOLFSSL_ECC_SECP256K1, "SECP256K1" },
101
+ { WOLFSSL_ECC_SECP256R1, "SECP256R1" },
102
+ { WOLFSSL_ECC_SECP384R1, "SECP384R1" },
103
+ { WOLFSSL_ECC_SECP521R1, "SECP521R1" },
104
+ { WOLFSSL_ECC_BRAINPOOLP256R1, "BRAINPOOLP256R1" },
105
+ { WOLFSSL_ECC_BRAINPOOLP384R1, "BRAINPOOLP384R1" },
106
+ { WOLFSSL_ECC_BRAINPOOLP512R1, "BRAINPOOLP512R1" },
107
+ { 0, NULL }
108
+ };
109
+ #endif /* CAN_FORCE_CURVE && HAVE_ECC */
110
+
111
+ #ifdef WOLFSSL_ASYNC_CRYPT
112
+ static int devId = INVALID_DEVID;
113
+ #endif
114
+
115
+ #define DEFAULT_TIMEOUT_SEC 2
116
+
117
+ /* Note on using port 0: if the server uses port 0 to bind an ephemeral port
118
+ * number and is using the ready file for scripted testing, the code in
119
+ * test.h will write the actual port number into the ready file for use
120
+ * by the client. */
121
+
122
+ #ifndef WOLFSSL_ALT_TEST_STRINGS
123
+ static const char kReplyMsg[] = "I hear you fa shizzle!";
124
+ #else
125
+ static const char kReplyMsg[] = "I hear you fa shizzle!\n";
126
+ #endif
127
+
128
+ static const char kHttpServerMsg[] =
129
+ "HTTP/1.1 200 OK\r\n"
130
+ "Content-Type: text/html\r\n"
131
+ "Connection: close\r\n"
132
+ "Content-Length: 141\r\n"
133
+ "\r\n"
134
+ "<html>\r\n"
135
+ "<head>\r\n"
136
+ "<title>Welcome to wolfSSL!</title>\r\n"
137
+ "</head>\r\n"
138
+ "<body>\r\n"
139
+ "<p>wolfSSL has successfully performed handshake!</p>\r\n"
140
+ "</body>\r\n"
141
+ "</html>\r\n";
142
+
143
+ /* Read needs to be largest of the client.c message strings (29) */
144
+ #define SRV_READ_SZ 32
145
+
146
+
147
+ int runWithErrors = 0; /* Used with -x flag to run err_sys vs. print errors */
148
+ int catastrophic = 0; /* Use with -x flag to still exit when an error is
149
+ * considered catastrophic EG the servers own cert failing
150
+ * to load would be catastrophic since there would be no
151
+ * cert to send to clients attempting to connect. The
152
+ * server should error out completely in that case
153
+ */
154
+ static int quieter = 0; /* Print fewer messages. This is helpful with overly
155
+ * ambitious log parsers. */
156
+ static int lng_index = 0;
157
+
158
+ #define LOG_ERROR(...) \
159
+ do { \
160
+ if (!quieter) \
161
+ fprintf(stderr, __VA_ARGS__); \
162
+ } while(0)
163
+
164
+ #ifdef WOLFSSL_CALLBACKS
165
+ #if !defined(NO_OLD_TIMEVAL_NAME)
166
+ Timeval srvTo;
167
+ #else
168
+ WOLFSSL_TIMEVAL srvTo;
169
+ #endif
170
+ static int srvHandShakeCB(HandShakeInfo* info)
171
+ {
172
+ (void)info;
173
+ return 0;
174
+ }
175
+
176
+ static int srvTimeoutCB(TimeoutInfo* info)
177
+ {
178
+ (void)info;
179
+ return 0;
180
+ }
181
+
182
+ #endif
183
+
184
+ #ifndef NO_HANDSHAKE_DONE_CB
185
+ static int myHsDoneCb(WOLFSSL* ssl, void* user_ctx)
186
+ {
187
+ (void)user_ctx;
188
+ (void)ssl;
189
+
190
+ /* printf("Notified HandShake done\n"); */
191
+
192
+ /* return negative number to end TLS connection now */
193
+ return 0;
194
+ }
195
+ #endif
196
+
197
+ static void err_sys_ex(int out, const char* msg)
198
+ {
199
+ if (out == 1) { /* if server is running w/ -x flag, print error w/o exit */
200
+ LOG_ERROR("wolfSSL error: %s\n", msg);
201
+ LOG_ERROR("Continuing server execution...\n\n");
202
+ } else {
203
+ err_sys(msg);
204
+ }
205
+ }
206
+
207
+
208
+ #if defined(WOLFSSL_DTLS) && defined(USE_WOLFSSL_IO)
209
+
210
+ /* Translates return codes returned from
211
+ * send() and recv() if need be.
212
+ */
213
+ static WC_INLINE int TranslateReturnCode(int old, int sd)
214
+ {
215
+ (void)sd;
216
+
217
+ #if defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX)
218
+ if (old == 0) {
219
+ errno = SOCKET_EWOULDBLOCK;
220
+ return -1; /* convert to BSD style wouldblock as error */
221
+ }
222
+
223
+ if (old < 0) {
224
+ errno = RTCS_geterror(sd);
225
+ if (errno == RTCSERR_TCP_CONN_CLOSING)
226
+ return 0; /* convert to BSD style closing */
227
+ if (errno == RTCSERR_TCP_CONN_RLSD)
228
+ errno = SOCKET_ECONNRESET;
229
+ if (errno == RTCSERR_TCP_TIMED_OUT)
230
+ errno = SOCKET_EAGAIN;
231
+ }
232
+ #endif
233
+
234
+ return old;
235
+ }
236
+
237
+ static WC_INLINE int wolfSSL_LastError(void)
238
+ {
239
+ #ifdef USE_WINDOWS_API
240
+ return WSAGetLastError();
241
+ #elif defined(EBSNET)
242
+ return xn_getlasterror();
243
+ #else
244
+ return errno;
245
+ #endif
246
+ }
247
+
248
+ /* wolfSSL Sock Addr */
249
+ struct WOLFSSL_TEST_SOCKADDR {
250
+ unsigned int sz; /* sockaddr size */
251
+ SOCKADDR_IN_T sa; /* pointer to the sockaddr_in or sockaddr_in6 */
252
+ };
253
+
254
+ typedef struct WOLFSSL_TEST_DTLS_CTX {
255
+ struct WOLFSSL_TEST_SOCKADDR peer;
256
+ int rfd;
257
+ int wfd;
258
+ int failOnce;
259
+ word32 blockSeq;
260
+ } WOLFSSL_TEST_DTLS_CTX;
261
+
262
+
263
+ static WC_INLINE int PeekSeq(const char* buf, word32* seq)
264
+ {
265
+ const char* c = buf + 3;
266
+
267
+ if ((c[0] | c[1] | c[2] | c[3]) == 0) {
268
+ *seq = ((word32)c[4] << 24) | ((word32)c[5] << 16) |
269
+ ((word32)c[6] << 8) | (word32)c[7];
270
+ return 1;
271
+ }
272
+
273
+ return 0;
274
+ }
275
+
276
+ /* The send embedded callback
277
+ * return : nb bytes sent, or error
278
+ */
279
+ static int TestEmbedSendTo(WOLFSSL* ssl, char *buf, int sz, void *ctx)
280
+ {
281
+ WOLFSSL_TEST_DTLS_CTX* dtlsCtx = (WOLFSSL_TEST_DTLS_CTX*)ctx;
282
+ int sd = dtlsCtx->wfd;
283
+ int sent;
284
+
285
+ (void)ssl;
286
+
287
+ WOLFSSL_ENTER("TestEmbedSendTo");
288
+
289
+ if (dtlsCtx->failOnce) {
290
+ word32 seq = 0;
291
+
292
+ if (PeekSeq(buf, &seq) && seq == dtlsCtx->blockSeq) {
293
+ dtlsCtx->failOnce = 0;
294
+ WOLFSSL_MSG("Forcing WANT_WRITE");
295
+ return WOLFSSL_CBIO_ERR_WANT_WRITE;
296
+ }
297
+ }
298
+
299
+ sent = (int)sendto(sd, buf, (size_t)sz, 0,
300
+ (const SOCKADDR*)&dtlsCtx->peer.sa, dtlsCtx->peer.sz);
301
+
302
+ sent = TranslateReturnCode(sent, sd);
303
+
304
+ if (sent < 0) {
305
+ int err = wolfSSL_LastError();
306
+ WOLFSSL_MSG("Embed Send To error");
307
+
308
+ if (err == SOCKET_EWOULDBLOCK || err == SOCKET_EAGAIN) {
309
+ WOLFSSL_MSG("\tWould Block");
310
+ return WOLFSSL_CBIO_ERR_WANT_WRITE;
311
+ }
312
+ else if (err == SOCKET_ECONNRESET) {
313
+ WOLFSSL_MSG("\tConnection reset");
314
+ return WOLFSSL_CBIO_ERR_CONN_RST;
315
+ }
316
+ else if (err == SOCKET_EINTR) {
317
+ WOLFSSL_MSG("\tSocket interrupted");
318
+ return WOLFSSL_CBIO_ERR_ISR;
319
+ }
320
+ else if (err == SOCKET_EPIPE) {
321
+ WOLFSSL_MSG("\tSocket EPIPE");
322
+ return WOLFSSL_CBIO_ERR_CONN_CLOSE;
323
+ }
324
+ else {
325
+ WOLFSSL_MSG("\tGeneral error");
326
+ return WOLFSSL_CBIO_ERR_GENERAL;
327
+ }
328
+ }
329
+
330
+ return sent;
331
+ }
332
+ #endif /* WOLFSSL_DTLS && USE_WOLFSSL_IO */
333
+
334
+ static int NonBlockingSSL_Accept(SSL* ssl)
335
+ {
336
+ #ifndef WOLFSSL_CALLBACKS
337
+ int ret = SSL_accept(ssl);
338
+ #else
339
+ int ret = wolfSSL_accept_ex(ssl, srvHandShakeCB, srvTimeoutCB, srvTo);
340
+ #endif
341
+ int error = SSL_get_error(ssl, 0);
342
+ SOCKET_T sockfd = (SOCKET_T)SSL_get_fd(ssl);
343
+ int select_ret = 0;
344
+
345
+ while (ret != WOLFSSL_SUCCESS &&
346
+ (error == WOLFSSL_ERROR_WANT_READ || error == WOLFSSL_ERROR_WANT_WRITE
347
+ #ifdef WOLFSSL_ASYNC_CRYPT
348
+ || error == WC_NO_ERR_TRACE(WC_PENDING_E)
349
+ #endif
350
+ )) {
351
+ if (error == WOLFSSL_ERROR_WANT_READ) {
352
+ /* printf("... server would read block\n"); */
353
+ }
354
+ else if (error == WOLFSSL_ERROR_WANT_WRITE) {
355
+ /* printf("... server would write block\n"); */
356
+ }
357
+
358
+ #ifdef WOLFSSL_ASYNC_CRYPT
359
+ if (error == WC_NO_ERR_TRACE(WC_PENDING_E)) {
360
+ ret = wolfSSL_AsyncPoll(ssl, WOLF_POLL_FLAG_CHECK_HW);
361
+ if (ret < 0) break;
362
+ }
363
+ else
364
+ #endif
365
+ {
366
+ int currTimeout = 1;
367
+
368
+ if (error == WOLFSSL_ERROR_WANT_WRITE)
369
+ {
370
+ select_ret = tcp_select_tx(sockfd, currTimeout);
371
+ }
372
+ else {
373
+ #ifdef WOLFSSL_DTLS
374
+ if (wolfSSL_dtls(ssl))
375
+ currTimeout = wolfSSL_dtls_get_current_timeout(ssl);
376
+ #endif
377
+ select_ret = tcp_select(sockfd, currTimeout);
378
+ }
379
+ }
380
+
381
+ if ((select_ret == TEST_RECV_READY) || (select_ret == TEST_SEND_READY)
382
+ || (select_ret == TEST_ERROR_READY)
383
+ #ifdef WOLFSSL_ASYNC_CRYPT
384
+ || error == WC_NO_ERR_TRACE(WC_PENDING_E)
385
+ #endif
386
+ ) {
387
+ #ifndef WOLFSSL_CALLBACKS
388
+ ret = SSL_accept(ssl);
389
+ #else
390
+ ret = wolfSSL_accept_ex(ssl,
391
+ srvHandShakeCB, srvTimeoutCB, srvTo);
392
+ #endif
393
+ error = SSL_get_error(ssl, 0);
394
+ }
395
+ else if (select_ret == TEST_TIMEOUT && !wolfSSL_dtls(ssl)) {
396
+ error = WOLFSSL_ERROR_WANT_READ;
397
+ }
398
+ #ifdef WOLFSSL_DTLS
399
+ else if (select_ret == TEST_TIMEOUT && wolfSSL_dtls(ssl)) {
400
+ ret = wolfSSL_dtls_got_timeout(ssl);
401
+ if (ret != WOLFSSL_SUCCESS)
402
+ error = wolfSSL_get_error(ssl, ret);
403
+ else
404
+ error = WOLFSSL_ERROR_WANT_READ;
405
+ ret = WOLFSSL_FAILURE; /* Reset error so we loop */
406
+ }
407
+ #endif
408
+ else {
409
+ error = WOLFSSL_FATAL_ERROR;
410
+ }
411
+ }
412
+
413
+ return ret;
414
+ }
415
+
416
+ /* Echo number of bytes specified by -B arg */
417
+ int ServerEchoData(SSL* ssl, int clientfd, int echoData, int block,
418
+ size_t throughput)
419
+ {
420
+ int ret = 0, err;
421
+ double start = 0, rx_time = 0, tx_time = 0;
422
+ int len, rx_pos;
423
+ size_t xfer_bytes = 0;
424
+ char* buffer;
425
+
426
+ buffer = (char*)XMALLOC((size_t)block, NULL, DYNAMIC_TYPE_TMP_BUFFER);
427
+ if (!buffer) {
428
+ err_sys_ex(runWithErrors, "Server buffer malloc failed");
429
+ }
430
+
431
+ while ((echoData && throughput == 0) ||
432
+ (!echoData && xfer_bytes < throughput))
433
+ {
434
+ int select_ret = tcp_select(clientfd, 1); /* Timeout=1 second */
435
+ if (select_ret == TEST_RECV_READY) {
436
+
437
+ if (throughput)
438
+ len = (int)min((word32)block, (word32)(throughput - xfer_bytes));
439
+ else
440
+ len = block;
441
+ rx_pos = 0;
442
+
443
+ if (throughput) {
444
+ start = current_time(1);
445
+ }
446
+
447
+ /* Read data */
448
+ while (rx_pos < len) {
449
+ ret = SSL_read(ssl, &buffer[rx_pos], len - rx_pos);
450
+ if (ret <= 0) {
451
+ err = SSL_get_error(ssl, 0);
452
+ #ifdef WOLFSSL_ASYNC_CRYPT
453
+ if (err == WC_NO_ERR_TRACE(WC_PENDING_E)) {
454
+ ret = wolfSSL_AsyncPoll(ssl, WOLF_POLL_FLAG_CHECK_HW);
455
+ if (ret < 0) break;
456
+ }
457
+ else
458
+ #endif
459
+ if (err != WOLFSSL_ERROR_WANT_READ &&
460
+ err != WOLFSSL_ERROR_WANT_WRITE &&
461
+ err != WOLFSSL_ERROR_ZERO_RETURN &&
462
+ err != WC_NO_ERR_TRACE(APP_DATA_READY))
463
+ {
464
+ LOG_ERROR("SSL_read echo error %d\n", err);
465
+ err_sys_ex(runWithErrors, "SSL_read failed");
466
+ break;
467
+ }
468
+ if (err == WOLFSSL_ERROR_ZERO_RETURN) {
469
+ XFREE(buffer, NULL, DYNAMIC_TYPE_TMP_BUFFER);
470
+ return WOLFSSL_ERROR_ZERO_RETURN;
471
+ }
472
+ }
473
+ else {
474
+ rx_pos += ret;
475
+ if (!throughput)
476
+ break;
477
+ }
478
+ }
479
+ if (throughput) {
480
+ rx_time += current_time(0) - start;
481
+ start = current_time(1);
482
+ }
483
+
484
+ /* Write data */
485
+ WOLFSSL_ASYNC_WHILE_PENDING(
486
+ ret = SSL_write(ssl, buffer, (int)min((word32)len, (word32)rx_pos)),
487
+ ret <= 0);
488
+ if (ret != (int)min((word32)len, (word32)rx_pos)) {
489
+ LOG_ERROR("SSL_write echo error %d\n", err);
490
+ err_sys_ex(runWithErrors, "SSL_write failed");
491
+ }
492
+
493
+ if (throughput) {
494
+ tx_time += current_time(0) - start;
495
+ }
496
+
497
+ xfer_bytes += (size_t)len;
498
+ }
499
+ }
500
+
501
+ XFREE(buffer, NULL, DYNAMIC_TYPE_TMP_BUFFER);
502
+
503
+ if (throughput) {
504
+ #ifdef __MINGW32__
505
+ #define SIZE_FMT "%d"
506
+ #define SIZE_TYPE int
507
+ #else
508
+ #define SIZE_FMT "%zu"
509
+ #define SIZE_TYPE size_t
510
+ #endif
511
+ if (rx_time > 0.0 && tx_time > 0.0) {
512
+ printf(
513
+ "wolfSSL Server Benchmark " SIZE_FMT " bytes\n"
514
+ "\tRX %8.3f ms (%8.3f MBps)\n"
515
+ "\tTX %8.3f ms (%8.3f MBps)\n",
516
+ (SIZE_TYPE)throughput,
517
+ (double)rx_time * 1000, (double)throughput / rx_time / 1024 / 1024,
518
+ (double)tx_time * 1000, (double)throughput / tx_time / 1024 / 1024
519
+ );
520
+ }
521
+ else {
522
+ printf("Invalid rx_time: %f or tx_time: %f\n", rx_time, tx_time);
523
+ }
524
+ }
525
+
526
+ return 0;
527
+ }
528
+
529
+ static void ServerRead(WOLFSSL* ssl, char* input, int inputLen)
530
+ {
531
+ int ret, err;
532
+ char buffer[WOLFSSL_MAX_ERROR_SZ];
533
+
534
+ /* Read data */
535
+ do {
536
+ err = 0; /* reset error */
537
+ ret = SSL_read(ssl, input, inputLen);
538
+ if (ret < 0) {
539
+ err = SSL_get_error(ssl, ret);
540
+
541
+ #ifdef HAVE_SECURE_RENEGOTIATION
542
+ if (err == WC_NO_ERR_TRACE(APP_DATA_READY)) {
543
+ /* If we receive a message during renegotiation
544
+ * then just print it. We return the message sent
545
+ * after the renegotiation. */
546
+ ret = SSL_read(ssl, input, inputLen);
547
+ if (ret >= 0) {
548
+ /* null terminate message */
549
+ input[ret] = '\0';
550
+ printf("Client message received during "
551
+ "secure renegotiation: %s\n", input);
552
+ err = WOLFSSL_ERROR_WANT_READ;
553
+ }
554
+ else {
555
+ err = SSL_get_error(ssl, ret);
556
+ }
557
+ }
558
+ #endif
559
+ #ifdef WOLFSSL_ASYNC_CRYPT
560
+ if (err == WC_NO_ERR_TRACE(WC_PENDING_E)) {
561
+ ret = wolfSSL_AsyncPoll(ssl, WOLF_POLL_FLAG_CHECK_HW);
562
+ if (ret < 0) break;
563
+ }
564
+ else
565
+ #endif
566
+ #ifdef WOLFSSL_DTLS
567
+ if (wolfSSL_dtls(ssl) && err == WC_NO_ERR_TRACE(DECRYPT_ERROR)) {
568
+ LOG_ERROR("Dropped client's message due to a bad MAC\n");
569
+ }
570
+ else
571
+ #endif
572
+ if (err != WOLFSSL_ERROR_WANT_READ
573
+ && err != WOLFSSL_ERROR_WANT_WRITE /* Can happen during
574
+ * handshake */
575
+ #ifdef HAVE_SECURE_RENEGOTIATION
576
+ && err != WC_NO_ERR_TRACE(APP_DATA_READY)
577
+ #endif
578
+ ) {
579
+ LOG_ERROR("SSL_read input error %d, %s\n", err,
580
+ ERR_error_string((unsigned long)err, buffer));
581
+ err_sys_ex(runWithErrors, "SSL_read failed");
582
+ }
583
+ }
584
+ else if (SSL_get_error(ssl, 0) == 0 &&
585
+ tcp_select(SSL_get_fd(ssl), 0) == TEST_RECV_READY) {
586
+ /* do a peek and check for "pending" */
587
+ #ifdef WOLFSSL_ASYNC_CRYPT
588
+ err = 0;
589
+ #endif
590
+ do {
591
+ #ifdef WOLFSSL_ASYNC_CRYPT
592
+ if (err == WC_NO_ERR_TRACE(WC_PENDING_E)) {
593
+ ret = wolfSSL_AsyncPoll(ssl, WOLF_POLL_FLAG_CHECK_HW);
594
+ if (ret < 0) break;
595
+ }
596
+ #endif
597
+ ret = wolfSSL_peek(ssl, buffer, 0);
598
+ err = SSL_get_error(ssl, ret);
599
+ } while (err == WC_NO_ERR_TRACE(WC_PENDING_E)
600
+ || err == WOLFSSL_ERROR_WANT_READ
601
+ || err == WOLFSSL_ERROR_WANT_WRITE);
602
+ if (err < 0) {
603
+ err_sys_ex(runWithErrors, "wolfSSL_peek failed");
604
+ }
605
+ if (wolfSSL_pending(ssl))
606
+ err = WOLFSSL_ERROR_WANT_READ;
607
+ }
608
+ } while (err == WC_NO_ERR_TRACE(WC_PENDING_E)
609
+ || err == WOLFSSL_ERROR_WANT_READ
610
+ || err == WOLFSSL_ERROR_WANT_WRITE);
611
+ if (ret > 0) {
612
+ /* null terminate message */
613
+ input[ret] = '\0';
614
+ printf("Client message: %s\n", input);
615
+ }
616
+ }
617
+
618
+ static void ServerWrite(WOLFSSL* ssl, const char* output, int outputLen)
619
+ {
620
+ int ret, err;
621
+ int len;
622
+
623
+ #ifdef OPENSSL_ALL
624
+ /* Fuzz testing expects reply split over two msgs when TLSv1.0 or below */
625
+ if (wolfSSL_GetVersion(ssl) <= WOLFSSL_TLSV1)
626
+ len = outputLen / 2;
627
+ else
628
+ #endif
629
+ len = outputLen;
630
+
631
+ do {
632
+ err = 0; /* reset error */
633
+ ret = SSL_write(ssl, output, len);
634
+ if (ret <= 0) {
635
+ err = SSL_get_error(ssl, 0);
636
+
637
+ #ifdef WOLFSSL_ASYNC_CRYPT
638
+ if (err == WC_NO_ERR_TRACE(WC_PENDING_E)) {
639
+ ret = wolfSSL_AsyncPoll(ssl, WOLF_POLL_FLAG_CHECK_HW);
640
+ if (ret < 0) break;
641
+ }
642
+ #endif
643
+ }
644
+ else if (ret != outputLen) {
645
+ output += ret;
646
+ len = (outputLen -= ret);
647
+ err = WOLFSSL_ERROR_WANT_WRITE;
648
+ }
649
+ } while (err == WC_NO_ERR_TRACE(WC_PENDING_E) ||
650
+ err == WOLFSSL_ERROR_WANT_WRITE);
651
+ if (ret != outputLen) {
652
+ char buffer[WOLFSSL_MAX_ERROR_SZ];
653
+ LOG_ERROR("SSL_write msg error %d, %s\n", err,
654
+ ERR_error_string((unsigned long)err, buffer));
655
+ err_sys_ex(runWithErrors, "SSL_write failed");
656
+ }
657
+ }
658
+
659
+ #if defined(WOLFSSL_TLS13) && defined(HAVE_SUPPORTED_CURVES)
660
+ #define MAX_GROUP_NUMBER 4
661
+ static void SetKeyShare(WOLFSSL* ssl, int onlyKeyShare, int useX25519,
662
+ int useX448, int usePqc, char* pqcAlg)
663
+ {
664
+ int ret;
665
+ int groups[MAX_GROUP_NUMBER] = {0};
666
+ int count = 0;
667
+
668
+ (void)useX25519;
669
+ (void)useX448;
670
+ (void)usePqc;
671
+ (void)pqcAlg;
672
+
673
+ WOLFSSL_START(WC_FUNC_CLIENT_KEY_EXCHANGE_SEND);
674
+ if (onlyKeyShare == 2) {
675
+ if (useX25519) {
676
+ #ifdef HAVE_CURVE25519
677
+ do {
678
+ ret = wolfSSL_UseKeyShare(ssl, WOLFSSL_ECC_X25519);
679
+ if (ret == WOLFSSL_SUCCESS)
680
+ groups[count++] = WOLFSSL_ECC_X25519;
681
+ #ifdef WOLFSSL_ASYNC_CRYPT
682
+ else if (ret == WC_NO_ERR_TRACE(WC_PENDING_E))
683
+ wolfSSL_AsyncPoll(ssl, WOLF_POLL_FLAG_CHECK_HW);
684
+ #endif
685
+ else
686
+ err_sys("unable to use curve x25519");
687
+ } while (ret == WC_NO_ERR_TRACE(WC_PENDING_E));
688
+ #endif
689
+ }
690
+ else if (useX448) {
691
+ #ifdef HAVE_CURVE448
692
+ do {
693
+ ret = wolfSSL_UseKeyShare(ssl, WOLFSSL_ECC_X448);
694
+ if (ret == WOLFSSL_SUCCESS)
695
+ groups[count++] = WOLFSSL_ECC_X448;
696
+ #ifdef WOLFSSL_ASYNC_CRYPT
697
+ else if (ret == WC_NO_ERR_TRACE(WC_PENDING_E))
698
+ wolfSSL_AsyncPoll(ssl, WOLF_POLL_FLAG_CHECK_HW);
699
+ #endif
700
+ else
701
+ err_sys("unable to use curve x448");
702
+ } while (ret == WC_NO_ERR_TRACE(WC_PENDING_E));
703
+ #endif
704
+ }
705
+ else if (usePqc == 1) {
706
+ #ifdef HAVE_PQC
707
+ groups[count] = 0;
708
+ #ifndef WOLFSSL_NO_ML_KEM
709
+ #ifndef WOLFSSL_NO_ML_KEM_512
710
+ if (XSTRCMP(pqcAlg, "ML_KEM_512") == 0) {
711
+ groups[count] = WOLFSSL_ML_KEM_512;
712
+ }
713
+ else
714
+ #endif
715
+ #ifndef WOLFSSL_NO_ML_KEM_768
716
+ if (XSTRCMP(pqcAlg, "ML_KEM_768") == 0) {
717
+ groups[count] = WOLFSSL_ML_KEM_768;
718
+ }
719
+ else
720
+ #endif
721
+ #ifndef WOLFSSL_NO_ML_KEM_1024
722
+ if (XSTRCMP(pqcAlg, "ML_KEM_1024") == 0) {
723
+ groups[count] = WOLFSSL_ML_KEM_1024;
724
+ }
725
+ else
726
+ #endif
727
+ #ifndef WOLFSSL_NO_ML_KEM_512
728
+ if (XSTRCMP(pqcAlg, "SecP256r1MLKEM512") == 0) {
729
+ groups[count] = WOLFSSL_SECP256R1MLKEM512;
730
+ }
731
+ else
732
+ #endif
733
+ #ifndef WOLFSSL_NO_ML_KEM_768
734
+ if (XSTRCMP(pqcAlg, "SecP384r1MLKEM768") == 0) {
735
+ groups[count] = WOLFSSL_SECP384R1MLKEM768;
736
+ }
737
+ else if (XSTRCMP(pqcAlg, "SecP256r1MLKEM768") == 0) {
738
+ groups[count] = WOLFSSL_SECP256R1MLKEM768;
739
+ }
740
+ else
741
+ #endif
742
+ #ifndef WOLFSSL_NO_ML_KEM_1024
743
+ if (XSTRCMP(pqcAlg, "SecP521r1MLKEM1024") == 0) {
744
+ groups[count] = WOLFSSL_SECP521R1MLKEM1024;
745
+ }
746
+ else if (XSTRCMP(pqcAlg, "SecP384r1MLKEM1024") == 0) {
747
+ groups[count] = WOLFSSL_SECP384R1MLKEM1024;
748
+ }
749
+ else
750
+ #endif
751
+ #if !defined(WOLFSSL_NO_ML_KEM_512) && defined(HAVE_CURVE25519)
752
+ if (XSTRCMP(pqcAlg, "X25519MLKEM512") == 0) {
753
+ groups[count] = WOLFSSL_X25519MLKEM512;
754
+ }
755
+ else
756
+ #endif
757
+ #if !defined(WOLFSSL_NO_ML_KEM_768) && defined(HAVE_CURVE25519)
758
+ if (XSTRCMP(pqcAlg, "X25519MLKEM768") == 0) {
759
+ groups[count] = WOLFSSL_X25519MLKEM768;
760
+ }
761
+ else
762
+ #endif
763
+ #if !defined(WOLFSSL_NO_ML_KEM_768) && defined(HAVE_CURVE448)
764
+ if (XSTRCMP(pqcAlg, "X448MLKEM768") == 0) {
765
+ groups[count] = WOLFSSL_X448MLKEM768;
766
+ }
767
+ else
768
+ #endif
769
+ #endif /* WOLFSSL_NO_ML_KEM */
770
+ #ifdef WOLFSSL_MLKEM_KYBER
771
+ #ifndef WOLFSSL_NO_KYBER512
772
+ if (XSTRCMP(pqcAlg, "KYBER_LEVEL1") == 0) {
773
+ groups[count] = WOLFSSL_KYBER_LEVEL1;
774
+ }
775
+ else
776
+ #endif
777
+ #ifndef WOLFSSL_NO_KYBER768
778
+ if (XSTRCMP(pqcAlg, "KYBER_LEVEL3") == 0) {
779
+ groups[count] = WOLFSSL_KYBER_LEVEL3;
780
+ }
781
+ else
782
+ #endif
783
+ #ifndef WOLFSSL_NO_KYBER1024
784
+ if (XSTRCMP(pqcAlg, "KYBER_LEVEL5") == 0) {
785
+ groups[count] = WOLFSSL_KYBER_LEVEL5;
786
+ }
787
+ else
788
+ #endif
789
+ #ifndef WOLFSSL_NO_KYBER512
790
+ if (XSTRCMP(pqcAlg, "P256_KYBER_LEVEL1") == 0) {
791
+ groups[count] = WOLFSSL_P256_KYBER_LEVEL1;
792
+ }
793
+ else
794
+ #endif
795
+ #ifndef WOLFSSL_NO_KYBER768
796
+ if (XSTRCMP(pqcAlg, "P384_KYBER_LEVEL3") == 0) {
797
+ groups[count] = WOLFSSL_P384_KYBER_LEVEL3;
798
+ }
799
+ else if (XSTRCMP(pqcAlg, "P256_KYBER_LEVEL3") == 0) {
800
+ groups[count] = WOLFSSL_P256_KYBER_LEVEL3;
801
+ }
802
+ else
803
+ #endif
804
+ #ifndef WOLFSSL_NO_KYBER1024
805
+ if (XSTRCMP(pqcAlg, "P521_KYBER_LEVEL5") == 0) {
806
+ groups[count] = WOLFSSL_P521_KYBER_LEVEL5;
807
+ }
808
+ else
809
+ #endif
810
+ #if !defined(WOLFSSL_NO_KYBER512) && defined(HAVE_CURVE25519)
811
+ if (XSTRCMP(pqcAlg, "X25519_KYBER_LEVEL1") == 0) {
812
+ groups[count] = WOLFSSL_X25519_KYBER_LEVEL1;
813
+ }
814
+ else
815
+ #endif
816
+ #if !defined(WOLFSSL_NO_KYBER768) && defined(HAVE_CURVE25519)
817
+ if (XSTRCMP(pqcAlg, "X25519_KYBER_LEVEL3") == 0) {
818
+ groups[count] = WOLFSSL_X25519_KYBER_LEVEL3;
819
+ }
820
+ else
821
+ #endif
822
+ #if !defined(WOLFSSL_NO_KYBER768) && defined(HAVE_CURVE448)
823
+ if (XSTRCMP(pqcAlg, "X448_KYBER_LEVEL3") == 0) {
824
+ groups[count] = WOLFSSL_X448_KYBER_LEVEL3;
825
+ }
826
+ else
827
+ #endif
828
+ #endif
829
+ {
830
+ err_sys("invalid post-quantum KEM specified");
831
+ }
832
+
833
+ if (groups[count] == 0) {
834
+ err_sys("invalid post-quantum KEM specified");
835
+ }
836
+ else {
837
+ if (wolfSSL_UseKeyShare(ssl, groups[count]) == WOLFSSL_SUCCESS) {
838
+ printf("Using Post-Quantum KEM: %s\n", pqcAlg);
839
+ count++;
840
+ }
841
+ else {
842
+ groups[count] = 0;
843
+ err_sys("unable to use post-quantum algorithm");
844
+ }
845
+ }
846
+ #endif
847
+ }
848
+ else {
849
+ #ifdef HAVE_ECC
850
+ #if !defined(NO_ECC256) || defined(HAVE_ALL_CURVES)
851
+ do {
852
+ ret = wolfSSL_UseKeyShare(ssl, WOLFSSL_ECC_SECP256R1);
853
+ if (ret == WOLFSSL_SUCCESS)
854
+ groups[count++] = WOLFSSL_ECC_SECP256R1;
855
+ #ifdef WOLFSSL_ASYNC_CRYPT
856
+ else if (ret == WC_NO_ERR_TRACE(WC_PENDING_E))
857
+ wolfSSL_AsyncPoll(ssl, WOLF_POLL_FLAG_CHECK_HW);
858
+ #endif
859
+ else
860
+ err_sys("unable to use curve secp256r1");
861
+ } while (ret == WC_NO_ERR_TRACE(WC_PENDING_E));
862
+ #elif defined(WOLFSSL_SM2)
863
+ do {
864
+ ret = wolfSSL_UseKeyShare(ssl, WOLFSSL_ECC_SM2P256V1);
865
+ if (ret == WOLFSSL_SUCCESS)
866
+ groups[count++] = WOLFSSL_ECC_SM2P256V1;
867
+ #ifdef WOLFSSL_ASYNC_CRYPT
868
+ else if (ret == WC_NO_ERR_TRACE(WC_PENDING_E))
869
+ wolfSSL_AsyncPoll(ssl, WOLF_POLL_FLAG_CHECK_HW);
870
+ #endif
871
+ else
872
+ err_sys("unable to use curve sm2p256r1");
873
+ } while (ret == WC_NO_ERR_TRACE(WC_PENDING_E));
874
+ #endif
875
+ #endif
876
+ }
877
+ }
878
+ if (onlyKeyShare == 1) {
879
+ #ifdef HAVE_FFDHE_2048
880
+ do {
881
+ ret = wolfSSL_UseKeyShare(ssl, WOLFSSL_FFDHE_2048);
882
+ if (ret == WOLFSSL_SUCCESS)
883
+ groups[count++] = WOLFSSL_FFDHE_2048;
884
+ #ifdef WOLFSSL_ASYNC_CRYPT
885
+ else if (ret == WC_NO_ERR_TRACE(WC_PENDING_E))
886
+ wolfSSL_AsyncPoll(ssl, WOLF_POLL_FLAG_CHECK_HW);
887
+ #endif
888
+ else
889
+ err_sys("unable to use DH 2048-bit parameters");
890
+ } while (ret == WC_NO_ERR_TRACE(WC_PENDING_E));
891
+ #endif
892
+ }
893
+ if (count >= MAX_GROUP_NUMBER)
894
+ err_sys("example group array size error");
895
+ if (count > 0) {
896
+ if (wolfSSL_set_groups(ssl, groups, count) != WOLFSSL_SUCCESS)
897
+ err_sys("unable to set groups");
898
+ }
899
+ WOLFSSL_END(WC_FUNC_CLIENT_KEY_EXCHANGE_SEND);
900
+ }
901
+ #endif /* WOLFSSL_TLS13 && HAVE_SUPPORTED_CURVES */
902
+
903
+
904
+ /* when adding new option, please follow the steps below: */
905
+ /* 1. add new option message in English section */
906
+ /* 2. increase the number of the second column */
907
+ /* 3. increase the array dimension */
908
+ /* 4. add the same message into Japanese section */
909
+ /* (will be translated later) */
910
+ /* 5. add printf() into suitable position of Usage() */
911
+ static const char* server_usage_msg[][66] = {
912
+ /* English */
913
+ {
914
+ " NOTE: All files relative to wolfSSL home dir\n", /* 0 */
915
+ "-? <num> Help, print this usage\n"
916
+ " 0: English, 1: Japanese\n"
917
+ "--help Help, in English\n", /* 1 */
918
+ "-p <num> Port to listen on, not 0, default", /* 2 */
919
+ #ifndef WOLFSSL_TLS13
920
+ "-v <num> SSL version [0-3], SSLv3(0) - TLS1.2(3)), default", /* 3 */
921
+ #else
922
+ "-v <num> SSL version [0-4], SSLv3(0) - TLS1.3(4)), default", /* 3 */
923
+ #endif
924
+ "-l <str> Cipher suite list (: delimited)\n", /* 4 */
925
+ "-c <file> Certificate file, default", /* 5 */
926
+ "-k <file> Key file, default", /* 6 */
927
+ "-A <file> Certificate Authority file, default", /* 7 */
928
+ "-R <file> Create Ready file for external monitor"
929
+ " default none\n", /* 8 */
930
+ #ifndef NO_DH
931
+ "-D <file> Diffie-Hellman Params file, default", /* 9 */
932
+ "-Z <num> Minimum DH key bits, default", /* 10 */
933
+ #endif
934
+ #ifdef HAVE_ALPN
935
+ "-L <str> Application-Layer Protocol Negotiation"
936
+ " ({C,F}:<list>)\n", /* 11 */
937
+ #endif
938
+ "-d Disable client cert check\n", /* 12 */
939
+ "-b Bind to any interface instead of localhost only\n",/* 13 */
940
+ "-s Use pre Shared keys\n", /* 14 */
941
+ #ifndef WOLFSSL_DTLS13
942
+ "-u Use UDP DTLS, add -v 2 for DTLSv1, -v 3 for DTLSv1.2"
943
+ " (default)\n", /* 15 */
944
+ #else
945
+ "-u Use UDP DTLS, add -v 2 for DTLSv1, -v 3 for DTLSv1.2"
946
+ " (default), -v 4 for DTLSv1.3\n", /* 15 */
947
+ #endif /* !WOLFSSL_DTLS13 */
948
+ #ifdef WOLFSSL_SCTP
949
+ "-G Use SCTP DTLS,"
950
+ " add -v 2 for DTLSv1, -v 3 for DTLSv1.2 (default)\n", /* 16 */
951
+ #endif
952
+ "-f Fewer packets/group messages\n", /* 17 */
953
+ "-r Allow one client Resumption\n", /* 18 */
954
+ "-N Use Non-blocking sockets\n", /* 19 */
955
+ "-S <str> Use Host Name Indication\n", /* 20 */
956
+ "-w Wait for bidirectional shutdown\n", /* 21 */
957
+ #ifdef HAVE_OCSP
958
+ "-o Perform OCSP lookup on peer certificate\n", /* 22 */
959
+ "-O <url> Perform OCSP lookup using <url> as responder\n", /* 23 */
960
+ #endif
961
+ #ifdef HAVE_PK_CALLBACKS
962
+ "-P Public Key Callbacks\n", /* 24 */
963
+ #endif
964
+ #ifdef HAVE_ANON
965
+ "-a Anonymous server\n", /* 25 */
966
+ #endif
967
+ #ifndef NO_PSK
968
+ "-I Do not send PSK identity hint\n", /* 26 */
969
+ #endif
970
+ "-x Print server errors but do not close connection\n",/* 27 */
971
+ "-i Loop indefinitely (allow repeated connections)\n", /* 28 */
972
+ "-e Echo data mode (return raw bytes received)\n", /* 29 */
973
+ "-B <num> Benchmark throughput"
974
+ " using <num> bytes and print stats\n", /* 31 */
975
+ #ifdef HAVE_CRL
976
+ "-V Disable CRL\n", /* 32 */
977
+ #endif
978
+ #ifdef WOLFSSL_TRUST_PEER_CERT
979
+ "-E <file> Path to load trusted peer cert\n", /* 33 */
980
+ #endif
981
+ #ifdef HAVE_WNR
982
+ "-q <file> Whitewood config file, default", /* 34 */
983
+ #endif
984
+ "-g Return basic HTML web page\n", /* 35 */
985
+ "-C <num> The number of connections to accept, default: 1\n",/* 36 */
986
+ "-H <arg> Internal tests"
987
+ " [defCipherList, exitWithRet, verifyFail, useSupCurve,\n", /* 37 */
988
+ " loadSSL, disallowETM]\n", /* 38 */
989
+ #ifdef WOLFSSL_TLS13
990
+ "-U Update keys and IVs before sending\n", /* 39 */
991
+ "-K Key Exchange for PSK not using (EC)DHE\n", /* 40 */
992
+ #ifndef NO_DH
993
+ "-y Pre-generate Key Share using FFDHE_2048 only\n", /* 41 */
994
+ #endif
995
+ #ifdef HAVE_ECC
996
+ "-Y Pre-generate Key Share using P-256 only \n", /* 42 */
997
+ #endif
998
+ #ifdef HAVE_CURVE25519
999
+ "-t Pre-generate Key share using Curve25519 only\n", /* 43 */
1000
+ #endif
1001
+ #endif /* WOLFSSL_TLS13 */
1002
+ #ifdef HAVE_SESSION_TICKET
1003
+ #if defined(WOLFSSL_NO_TLS12) && defined(NO_OLD_TLS)
1004
+ "-T Do not generate session ticket\n", /* 44 */
1005
+ #else
1006
+ "-T [aon] Do not generate session ticket\n", /* 44 */
1007
+ " No option affects TLS 1.3 only, 'a' affects all"
1008
+ " protocol versions,\n", /* 45 */
1009
+ " 'o' affects TLS 1.2 and below only\n", /* 46 */
1010
+ " 'n' affects TLS 1.3 only\n", /* 47 */
1011
+ #endif
1012
+ #endif
1013
+ #ifdef WOLFSSL_TLS13
1014
+ "-F Send alert if no mutual authentication\n", /* 48 */
1015
+ #ifdef WOLFSSL_POST_HANDSHAKE_AUTH
1016
+ "-Q Request certificate from client post-handshake\n", /* 49 */
1017
+ #endif
1018
+ #ifdef WOLFSSL_SEND_HRR_COOKIE
1019
+ "-J [n] Server sends Cookie Extension containing state (n to "
1020
+ "disable)\n", /* 50 */
1021
+ #endif
1022
+ #endif /* WOLFSSL_TLS13 */
1023
+ #ifdef WOLFSSL_EARLY_DATA
1024
+ "-0 Early data read from client (0-RTT handshake)\n", /* 51 */
1025
+ #endif
1026
+ #ifdef WOLFSSL_MULTICAST
1027
+ "-3 <grpid> Multicast, grpid < 256\n", /* 52 */
1028
+ #endif
1029
+ "-1 <num> Display a result by specified language."
1030
+ "\n 0: English, 1: Japanese\n", /* 53 */
1031
+ #ifdef HAVE_TRUSTED_CA
1032
+ "-5 Use Trusted CA Key Indication\n", /* 54 */
1033
+ #endif
1034
+ "-6 Simulate WANT_WRITE errors on every other IO send\n",
1035
+ /* 55 */
1036
+ #ifdef HAVE_CURVE448
1037
+ "-8 Pre-generate Key share using Curve448 only\n", /* 56 */
1038
+ #endif
1039
+ #if defined(OPENSSL_ALL) && defined(WOLFSSL_CERT_GEN) && \
1040
+ (defined(WOLFSSL_CERT_REQ) || defined(WOLFSSL_CERT_EXT)) && \
1041
+ !defined(NO_FILESYSTEM) && !defined(NO_WOLFSSL_DIR)
1042
+ "-9 Use hash dir look up for certificate loading\n"
1043
+ " loading from <wolfSSL home>/certs folder\n"
1044
+ " files in the folder would have the form \"hash.N\" file name\n"
1045
+ " e.g symbolic link to the file at certs folder\n"
1046
+ " ln -s client-ca.pem `openssl x509 -in client-ca.pem -hash -noout`.0\n",
1047
+ /* 57 */
1048
+ #endif
1049
+ #if defined(WOLFSSL_WOLFSENTRY_HOOKS) && !defined(NO_FILESYSTEM) && !defined(WOLFSENTRY_NO_JSON)
1050
+ "--wolfsentry-config <file> Path for JSON wolfSentry config\n",
1051
+ /* 58 */
1052
+ #endif
1053
+ #ifndef WOLFSSL_TLS13
1054
+ "-7 Set minimum downgrade protocol version [0-3] "
1055
+ " SSLv3(0) - TLS1.2(3)\n",
1056
+ #else
1057
+ "-7 Set minimum downgrade protocol version [0-4] "
1058
+ " SSLv3(0) - TLS1.3(4)\n", /* 59 */
1059
+ #endif
1060
+ #ifdef HAVE_PQC
1061
+ "--pqc <alg> Key Share with specified post-quantum algorithm only:\n"
1062
+ #ifndef WOLFSSL_NO_ML_KEM
1063
+ " ML_KEM_512, ML_KEM_768, ML_KEM_1024,\n"
1064
+ " SecP256r1MLKEM512,\n"
1065
+ " SecP384r1MLKEM768,\n"
1066
+ " SecP521r1MLKEM1024,\n"
1067
+ " SecP256r1MLKEM768,\n"
1068
+ " SecP521r1MLKEM1024,\n"
1069
+ " SecP384r1MLKEM1024,\n"
1070
+ " X25519MLKEM512,\n"
1071
+ " X25519MLKEM768,\n"
1072
+ " X448MLKEM768\n"
1073
+ #endif
1074
+ #ifdef WOLFSSL_MLKEM_KYBER
1075
+ " KYBER_LEVEL1, KYBER_LEVEL3, KYBER_LEVEL5, "
1076
+ "P256_KYBER_LEVEL1,\n"
1077
+ " P384_KYBER_LEVEL3, P256_KYBER_LEVEL3, "
1078
+ "P521_KYBER_LEVEL5,\n"
1079
+ " X25519_KYBER_LEVEL1, X25519_KYBER_LEVEL3, "
1080
+ "X448_KYBER_LEVEL3\n"
1081
+ #endif
1082
+ "",
1083
+ /* 60 */
1084
+ #endif
1085
+ #ifdef WOLFSSL_SRTP
1086
+ "--srtp <profile> (default is SRTP_AES128_CM_SHA1_80)\n", /* 61 */
1087
+ #endif
1088
+ #if defined(WOLFSSL_TLS13) && defined(HAVE_SESSION_TICKET)
1089
+ "--send-ticket Send a new session ticket during application data\n",
1090
+ /* 62 */
1091
+ #endif
1092
+ #ifdef CAN_FORCE_CURVE
1093
+ "--force-curve [<curve>] Pre-generate a Key Share using <curve>.\n"
1094
+ " Leave <curve> blank to list all curves.\n"
1095
+ " Note: requires TLS1.3\n",
1096
+ /* 63 */
1097
+ #endif
1098
+ #ifdef HAVE_SUPPORTED_CURVES
1099
+ "--onlyPskDheKe Must use DHE key exchange with PSK\n", /* 64 */
1100
+ #endif
1101
+ #ifdef WOLFSSL_DUAL_ALG_CERTS
1102
+ "--altPrivKey <file> Generate alternative signature with this key.\n",
1103
+ /* 65 */
1104
+ #endif
1105
+ #ifdef WOLFSSL_SYS_CRYPTO_POLICY
1106
+ "--crypto-policy <path to crypto policy file>\n", /* 66 */
1107
+ #endif
1108
+ "\n"
1109
+ "For simpler wolfSSL TLS server examples, visit\n"
1110
+ "https://github.com/wolfSSL/wolfssl-examples/tree/master/tls\n",
1111
+ /* 67 */
1112
+ NULL,
1113
+ },
1114
+ #ifndef NO_MULTIBYTE_PRINT
1115
+ /* Japanese */
1116
+ {
1117
+ " 注意 : 全てのファイルは"
1118
+ " wolfSSL ホーム・ディレクトリからの相対です。\n", /* 0 */
1119
+ "-? <num> ヘルプ, 使い方を表示\n"
1120
+ " 0: 英語、 1: 日本語\n"
1121
+ "--ヘルプ 日本語で使い方を表示\n", /* 1 */
1122
+ "-p <num> 接続先ポート, 0は無効, 既定値", /* 2 */
1123
+ #ifndef WOLFSSL_TLS13
1124
+ "-v <num> SSL バージョン [0-3], SSLv3(0) - TLS1.2(3)),"
1125
+ " 既定値", /* 3 */
1126
+ #else
1127
+ "-v <num> SSL バージョン [0-4], SSLv3(0) - TLS1.3(4)),"
1128
+ " 既定値", /* 3 */
1129
+ #endif
1130
+ "-l <str> 暗号スイートリスト (区切り文字 :)\n", /* 4 */
1131
+ "-c <file> 証明書ファイル, 既定値", /* 5 */
1132
+ "-k <file> 鍵ファイル, 既定値", /* 6 */
1133
+ "-A <file> 認証局ファイル, 既定値", /* 7 */
1134
+ "-R <file> 外部モニタ用の準備完了ファイルを作成する。"
1135
+ "既定値 なし\n", /* 8 */
1136
+ #ifndef NO_DH
1137
+ "-D <file> ディフィー・ヘルマンのパラメータファイル,"
1138
+ " 既定値", /* 9 */
1139
+ "-Z <num> 最小 DH 鍵 ビット, 既定値", /* 10 */
1140
+ #endif
1141
+ #ifdef HAVE_ALPN
1142
+ "-L <str> アプリケーション層プロトコルネゴシエーションを行う"
1143
+ " ({C,F}:<list>)\n", /* 11 */
1144
+ #endif
1145
+ "-d クライアント認証を無効とする\n", /* 12 */
1146
+ "-b ローカルホスト以外のインターフェースへも"
1147
+ "バインドする\n", /* 13 */
1148
+ "-s 事前共有鍵を使用する\n", /* 14 */
1149
+ "-u UDP DTLSを使用する。\n"
1150
+
1151
+ #ifndef WOLFSSL_DTLS13
1152
+ " -v 2 を追加指定するとDTLSv1, "
1153
+ "-v 3 を追加指定すると DTLSv1.2 (既定値)\n", /* 15 */
1154
+ #else
1155
+ " -v 2 を追加指定するとDTLSv1, "
1156
+ "-v 3 を追加指定すると DTLSv1.2 (既定値),\n"
1157
+ " -v 4 を追加指定すると DTLSv1.3\n", /* 15 */
1158
+ #endif /* !WOLFSSL_DTLS13 */
1159
+ #ifdef WOLFSSL_SCTP
1160
+ "-G SCTP DTLSを使用する。-v 2 を追加指定すると"
1161
+ " DTLSv1, -v 3 を追加指定すると DTLSv1.2 (既定値)\n", /* 16 */
1162
+ #endif
1163
+ "-f より少ないパケット/グループメッセージを使用する\n",/* 17 */
1164
+ "-r クライアントの再開を許可する\n", /* 18 */
1165
+ "-N ノンブロッキング・ソケットを使用する\n", /* 19 */
1166
+ "-S <str> ホスト名表示を使用する\n", /* 20 */
1167
+ "-w 双方向シャットダウンを待つ\n", /* 21 */
1168
+ #ifdef HAVE_OCSP
1169
+ "-o OCSPルックアップをピア証明書で実施する\n", /* 22 */
1170
+ "-O <url> OCSPルックアップを、"
1171
+ "<url>を使用し応答者として実施する\n", /* 23 */
1172
+ #endif
1173
+ #ifdef HAVE_PK_CALLBACKS
1174
+ "-P 公開鍵コールバック\n", /* 24 */
1175
+ #endif
1176
+ #ifdef HAVE_ANON
1177
+ "-a 匿名サーバー\n", /* 25 */
1178
+ #endif
1179
+ #ifndef NO_PSK
1180
+ "-I PSKアイデンティティのヒントを送信しない\n", /* 26 */
1181
+ #endif
1182
+ "-x サーバーエラーを出力するが接続を切断しない\n", /* 27 */
1183
+ "-i 無期限にループする(繰り返し接続を許可)\n", /* 28 */
1184
+ "-e エコー・データモード"
1185
+ "(受け取ったバイトデータを返す)\n", /* 29 */
1186
+ "-B <num> <num> バイトを用いてのベンチマーク・スループット"
1187
+ "測定と結果を出力する\n", /* 31 */
1188
+ #ifdef HAVE_CRL
1189
+ "-V CRLを無効とする\n", /* 32 */
1190
+ #endif
1191
+ #ifdef WOLFSSL_TRUST_PEER_CERT
1192
+ "-E <file> 信頼出来るピアの証明書ロードの為のパス\n\n", /* 33 */
1193
+ #endif
1194
+ #ifdef HAVE_WNR
1195
+ "-q <file> Whitewood コンフィグファイル, 既定値", /* 34 */
1196
+ #endif
1197
+ "-g 基本的な Web ページを返す\n", /* 35 */
1198
+ "-C <num> アクセプト可能な接続数を指定する。既定値: 1\n", /* 36 */
1199
+ "-H <arg> 内部テスト"
1200
+ " [defCipherList, exitWithRet, verifyFail, useSupCurve,\n", /* 37 */
1201
+ " loadSSL, disallowETM]\n", /* 38 */
1202
+ #ifdef WOLFSSL_TLS13
1203
+ "-U データ送信前に、鍵とIVを更新する\n", /* 39 */
1204
+ "-K 鍵交換にPSKを使用、(EC)DHEは使用しない\n", /* 40 */
1205
+ #ifndef NO_DH
1206
+ "-y FFDHE_2048のみを使用して鍵共有を事前生成する\n", /* 41 */
1207
+ #endif
1208
+ #ifdef HAVE_ECC
1209
+ "-Y P-256のみを使用したキー共有の事前生成\n", /* 42 */
1210
+ #endif
1211
+ #ifdef HAVE_CURVE25519
1212
+ "-t Curve25519のみを使用して鍵共有を事前生成する\n", /* 43 */
1213
+ #endif
1214
+ #endif /* WOLFSSL_TLS13 */
1215
+ #if defined(WOLFSSL_NO_TLS12) && defined(NO_OLD_TLS)
1216
+ "-T セッションチケットを生成しない\n", /* 44 */
1217
+ #else
1218
+ "-T [aon] セッションチケットを生成しない\n", /* 44 */
1219
+ " オプション指定なしの場合、TLS 1.3 にだけ有効\n"
1220
+ " 'a' を指定した場合、"
1221
+ "全てのプロトコルバージョンに有効\n" /* 45 */
1222
+ " 'o' を指定した場合、TLS 1.2 及び"
1223
+ "それ以下のプロトコルバージョンに有効\n" /* 46 */
1224
+ " 'n' を指定した場合、TLS 1.3 にのみ有効\n", /* 47 */
1225
+
1226
+ #endif
1227
+ #ifdef WOLFSSL_TLS13
1228
+ "-F 相互認証が無い場合にalert を送信\n", /* 48 */
1229
+ #ifdef WOLFSSL_POST_HANDSHAKE_AUTH
1230
+ "-Q クライアントのポストハンドシェイクから"
1231
+ "証明書を要求する\n", /* 49 */
1232
+ #endif
1233
+ #ifdef WOLFSSL_SEND_HRR_COOKIE
1234
+ "-J サーバーの状態を含むTLS Cookie 拡張を送信する\n", /* 50 */
1235
+ #endif
1236
+ #endif /* WOLFSSL_TLS13 */
1237
+ #ifdef WOLFSSL_EARLY_DATA
1238
+ "-0 クライアントからの Early Data 読み取り"
1239
+ "(0-RTTハンドシェイク)\n", /* 51 */
1240
+ #endif
1241
+ #ifdef WOLFSSL_MULTICAST
1242
+ "-3 <grpid> マルチキャスト, grpid < 256\n", /* 52 */
1243
+ #endif
1244
+ "-1 <num> 指定された言語で結果を表示します。"
1245
+ "\n 0: 英語、 1: 日本語\n", /* 53 */
1246
+ #ifdef HAVE_TRUSTED_CA
1247
+ "-5 信頼できる認証局の鍵表示を使用する\n", /* 54 */
1248
+ #endif
1249
+ "-6 交互の IO 送信で WANT_WRITE エラー"
1250
+ "をシュミレート\n",
1251
+ /* 55 */
1252
+ #ifdef HAVE_CURVE448
1253
+ "-8 Curve448のみを使用して鍵共有を事前生成する\n", /* 56 */
1254
+ #endif
1255
+ #if defined(OPENSSL_ALL) && defined(WOLFSSL_CERT_GEN) && \
1256
+ (defined(WOLFSSL_CERT_REQ) || defined(WOLFSSL_CERT_EXT)) && \
1257
+ !defined(NO_FILESYSTEM) && !defined(NO_WOLFSSL_DIR)
1258
+ "-9 証明書の読み込みに hash dir 機能を使用する\n"
1259
+ " <wolfSSL home>/certs フォルダーからロードします\n"
1260
+ " フォルダー中のファイルは、\"hash.N\"[N:0-9]名である必要があります\n"
1261
+ " 以下の例ではca-cert.pemにシンボリックリンクを設定します\n"
1262
+ " ln -s client-ca.pem `openssl x509 -in client-ca.pem -hash -noout`.0\n",
1263
+ /* 57 */
1264
+ #endif
1265
+ #if defined(WOLFSSL_WOLFSENTRY_HOOKS) && !defined(NO_FILESYSTEM) && !defined(WOLFSENTRY_NO_JSON)
1266
+ "--wolfsentry-config <file> wolfSentry コンフィグファイル\n",
1267
+ /* 58 */
1268
+ #endif
1269
+ #ifndef WOLFSSL_TLS13
1270
+ "-7 最小ダウングレード可能なプロトコルバージョンを設定します [0-3] "
1271
+ " SSLv3(0) - TLS1.2(3)\n",
1272
+ #else
1273
+ "-7 最小ダウングレード可能なプロトコルバージョンを設定します [0-4] "
1274
+ " SSLv3(0) - TLS1.3(4)\n", /* 59 */
1275
+ #endif
1276
+ #ifdef HAVE_PQC
1277
+ "--pqc <alg> post-quantum 名前付きグループとの鍵共有のみ:\n"
1278
+ #ifndef WOLFSSL_NO_ML_KEM
1279
+ " ML_KEM_512, ML_KEM_768, ML_KEM_1024,"
1280
+ " SecP256r1MLKEM512,\n"
1281
+ " SecP384r1MLKEM768,\n"
1282
+ " SecP521r1MLKEM1024,\n"
1283
+ " SecP256r1MLKEM768,\n"
1284
+ " SecP521r1MLKEM1024,\n"
1285
+ " SecP384r1MLKEM1024,\n"
1286
+ " X25519MLKEM512,\n"
1287
+ " X25519MLKEM768,\n"
1288
+ " X448MLKEM768\n"
1289
+ #endif
1290
+ #ifdef WOLFSSL_MLKEM_KYBER
1291
+ " KYBER_LEVEL1, KYBER_LEVEL3, KYBER_LEVEL5, "
1292
+ "P256_KYBER_LEVEL1,\n"
1293
+ " P384_KYBER_LEVEL3, P521_KYBER_LEVEL5\n"
1294
+ #endif
1295
+ "",
1296
+ /* 60 */
1297
+ #endif
1298
+ #ifdef WOLFSSL_SRTP
1299
+ "--srtp <profile> (デフォルトはSRTP_AES128_CM_SHA1_80)\n", /* 61 */
1300
+ #endif
1301
+ #if defined(WOLFSSL_TLS13) && defined(HAVE_SESSION_TICKET)
1302
+ "--send-ticket Application data 中に新しい"
1303
+ "セッションチケットを送信します\n",
1304
+ /* 62 */
1305
+ #endif
1306
+ #ifdef CAN_FORCE_CURVE
1307
+ /* TODO: Need Japanese translation */
1308
+ "--force-curve [<curve>] Pre-generate a Key Share using <curve>.\n"
1309
+ " Leave <curve> blank to list all curves.\n"
1310
+ " Note: requires TLS1.3\n",
1311
+ /* 63 */
1312
+ #endif
1313
+ #ifdef HAVE_SUPPORTED_CURVES
1314
+ "--onlyPskDheKe Must use DHE key exchange with PSK\n", /* 64 */
1315
+ #endif
1316
+ #ifdef WOLFSSL_DUAL_ALG_CERTS
1317
+ "--altPrivKey <file> Generate alternative signature with this key.\n",
1318
+ /* 65 */
1319
+ #endif
1320
+ #ifdef WOLFSSL_SYS_CRYPTO_POLICY
1321
+ "--crypto-policy <path to crypto policy file>\n", /* 66 */
1322
+ #endif
1323
+ "\n"
1324
+ "より簡単なwolfSSL TSL クライアントの例については"
1325
+ "下記にアクセスしてください\n"
1326
+ "https://github.com/wolfSSL/wolfssl-examples/tree/master/tls\n",
1327
+ /* 67 */
1328
+ NULL,
1329
+ },
1330
+ #endif
1331
+ };
1332
+
1333
+ static void Usage(void)
1334
+ {
1335
+ int msgId = 0;
1336
+ const char** msg = server_usage_msg[lng_index];
1337
+
1338
+ printf("%s%s%s", "server ", LIBWOLFSSL_VERSION_STRING,
1339
+ msg[msgId]);
1340
+ printf("%s", msg[++msgId]); /* ? */
1341
+ printf("%s %d\n", msg[++msgId], wolfSSLPort); /* -p */
1342
+ #ifndef WOLFSSL_TLS13
1343
+ printf("%s %d\n", msg[++msgId], SERVER_DEFAULT_VERSION); /* -v */
1344
+ #else
1345
+ printf("%s %d\n", msg[++msgId], SERVER_DEFAULT_VERSION); /* -v */
1346
+ #endif
1347
+ printf("%s", msg[++msgId]); /* -l */
1348
+ printf("%s %s\n", msg[++msgId], svrCertFile); /* -c */
1349
+ printf("%s %s\n", msg[++msgId], svrKeyFile); /* -k */
1350
+ printf("%s %s\n", msg[++msgId], cliCertFile); /* -A */
1351
+ printf("%s", msg[++msgId]); /* -R */
1352
+ #ifndef NO_DH
1353
+ printf("%s %s\n", msg[++msgId], dhParamFile); /* -D */
1354
+ printf("%s %d\n", msg[++msgId], DEFAULT_MIN_DHKEY_BITS);/* -Z */
1355
+ #endif
1356
+ #ifdef HAVE_ALPN
1357
+ printf("%s", msg[++msgId]); /* -L */
1358
+ #endif
1359
+ printf("%s", msg[++msgId]); /* -d */
1360
+ printf("%s", msg[++msgId]); /* -b */
1361
+ printf("%s", msg[++msgId]); /* -s */
1362
+ printf("%s", msg[++msgId]); /* -u */
1363
+ #ifdef WOLFSSL_SCTP
1364
+ printf("%s", msg[++msgId]); /* -G */
1365
+ #endif
1366
+ printf("%s", msg[++msgId]); /* -f */
1367
+ printf("%s", msg[++msgId]); /* -r */
1368
+ printf("%s", msg[++msgId]); /* -N */
1369
+ printf("%s", msg[++msgId]); /* -S */
1370
+ printf("%s", msg[++msgId]); /* -w */
1371
+ #ifdef HAVE_SECURE_RENEGOTIATION
1372
+ printf("-M Allow Secure Renegotiation\n");
1373
+ printf("-m Force Server Initiated Secure Renegotiation\n");
1374
+ #endif /* HAVE_SECURE_RENEGOTIATION */
1375
+ #ifdef HAVE_OCSP
1376
+ printf("%s", msg[++msgId]); /* -o */
1377
+ printf("%s", msg[++msgId]); /* -O */
1378
+ #endif
1379
+ #ifdef HAVE_PK_CALLBACKS
1380
+ printf("%s", msg[++msgId]); /* -P */
1381
+ #endif
1382
+ #ifdef HAVE_ANON
1383
+ printf("%s", msg[++msgId]); /* -a */
1384
+ #endif
1385
+ #ifndef NO_PSK
1386
+ printf("%s", msg[++msgId]); /* -I */
1387
+ #endif
1388
+ printf("%s", msg[++msgId]); /* -x */
1389
+ printf("%s", msg[++msgId]); /* -i */
1390
+ printf("%s", msg[++msgId]); /* -e */
1391
+ printf("%s", msg[++msgId]); /* -B */
1392
+ #ifdef HAVE_CRL
1393
+ printf("%s", msg[++msgId]); /* -V */
1394
+ #endif
1395
+ #ifdef WOLFSSL_TRUST_PEER_CERT
1396
+ printf("%s", msg[++msgId]); /* -E */
1397
+ #endif
1398
+ #ifdef HAVE_WNR
1399
+ printf("%s %s\n", msg[++msgId], wnrConfig); /* -q */
1400
+ #endif
1401
+ printf("%s", msg[++msgId]); /* -g */
1402
+ printf("%s", msg[++msgId]); /* -C */
1403
+ printf("%s", msg[++msgId]); /* -H */
1404
+ printf("%s", msg[++msgId]); /* more -H options */
1405
+ #ifdef WOLFSSL_TLS13
1406
+ printf("%s", msg[++msgId]); /* -U */
1407
+ printf("%s", msg[++msgId]); /* -K */
1408
+ #ifndef NO_DH
1409
+ printf("%s", msg[++msgId]); /* -y */
1410
+ #endif
1411
+ #ifdef HAVE_ECC
1412
+ printf("%s", msg[++msgId]); /* -Y */
1413
+ #endif
1414
+ #ifdef HAVE_CURVE25519
1415
+ printf("%s", msg[++msgId]); /* -t */
1416
+ #endif
1417
+ #endif /* WOLFSSL_TLS13 */
1418
+ #ifdef HAVE_SESSION_TICKET
1419
+ printf("%s", msg[++msgId]); /* -T */
1420
+ #if !defined(WOLFSSL_NO_TLS12) || !defined(NO_OLD_TLS)
1421
+ printf("%s", msg[++msgId]); /* -T */
1422
+ printf("%s", msg[++msgId]); /* -T */
1423
+ printf("%s", msg[++msgId]); /* -T */
1424
+ #endif
1425
+ #endif
1426
+ #ifdef WOLFSSL_TLS13
1427
+ printf("%s", msg[++msgId]); /* -F */
1428
+ #ifdef WOLFSSL_POST_HANDSHAKE_AUTH
1429
+ printf("%s", msg[++msgId]); /* -Q */
1430
+ #endif
1431
+ #ifdef WOLFSSL_SEND_HRR_COOKIE
1432
+ printf("%s", msg[++msgId]); /* -J */
1433
+ #endif
1434
+ #endif /* WOLFSSL_TLS13 */
1435
+ #ifdef WOLFSSL_EARLY_DATA
1436
+ printf("%s", msg[++msgId]); /* -0 */
1437
+ #endif
1438
+ #if !defined(NO_DH) && !defined(HAVE_FIPS) && \
1439
+ !defined(HAVE_SELFTEST) && !defined(WOLFSSL_OLD_PRIME_CHECK)
1440
+ printf("-2 Disable DH Prime check\n");
1441
+ #endif
1442
+ #ifdef WOLFSSL_DTLS
1443
+ printf("-4 <seq> DTLS fake would-block for message seq\n");
1444
+ #endif
1445
+ #ifdef WOLFSSL_MULTICAST
1446
+ printf("%s", msg[++msgId]); /* -3 */
1447
+ #endif
1448
+ printf("%s", msg[++msgId]); /* -1 */
1449
+ #ifdef HAVE_TRUSTED_CA
1450
+ printf("%s", msg[++msgId]); /* -5 */
1451
+ #endif /* HAVE_TRUSTED_CA */
1452
+ printf("%s", msg[++msgId]); /* -6 */
1453
+ #ifdef HAVE_CURVE448
1454
+ printf("%s", msg[++msgId]); /* -8 */
1455
+ #endif
1456
+ #if defined(OPENSSL_ALL) && defined(WOLFSSL_CERT_GEN) && \
1457
+ (defined(WOLFSSL_CERT_REQ) || defined(WOLFSSL_CERT_EXT)) && \
1458
+ !defined(NO_FILESYSTEM) && !defined(NO_WOLFSSL_DIR)
1459
+ printf("%s", msg[++msgId]); /* -9 */
1460
+ #endif
1461
+ #if defined(WOLFSSL_WOLFSENTRY_HOOKS) && !defined(NO_FILESYSTEM) && \
1462
+ !defined(WOLFSENTRY_NO_JSON)
1463
+ printf("%s", msg[++msgId]); /* --wolfsentry-config */
1464
+ #endif
1465
+ printf("%s", msg[++msgId]); /* -7 */
1466
+ #ifdef HAVE_PQC
1467
+ printf("%s", msg[++msgId]); /* --pqc */
1468
+ printf("%s", msg[++msgId]); /* --pqc options */
1469
+ printf("%s", msg[++msgId]); /* more --pqc options */
1470
+ printf("%s", msg[++msgId]); /* more --pqc options */
1471
+ #endif
1472
+ #ifdef WOLFSSL_SRTP
1473
+ printf("%s", msg[++msgId]); /* dtls-srtp */
1474
+ #endif
1475
+ #if defined(WOLFSSL_TLS13) && defined(HAVE_SESSION_TICKET)
1476
+ printf("%s", msg[++msgId]); /* send-ticket */
1477
+ #endif
1478
+ #ifdef CAN_FORCE_CURVE
1479
+ printf("%s", msg[++msgId]); /* force-curve */
1480
+ #endif
1481
+ #ifdef HAVE_SUPPORTED_CURVES
1482
+ printf("%s", msg[++msgId]); /* --onlyPskDheKe */
1483
+ #endif
1484
+ #ifdef WOLFSSL_DUAL_ALG_CERTS
1485
+ printf("%s", msg[++msgId]); /* --altPrivKey */
1486
+ #endif
1487
+ printf("%s", msg[++msgId]); /* Examples repo link */
1488
+ }
1489
+
1490
+ #ifdef WOLFSSL_SRTP
1491
+ /**
1492
+ * server_srtp_test() - print the ekm and share it with the client
1493
+ * @ssl: ssl context
1494
+ * @srtp_helper: srtp_test_helper shared struct with the client
1495
+ *
1496
+ * if @srtp_helper is NULL the ekm isn't shared, but it is still printed.
1497
+ *
1498
+ * calls srtp_helper_set_ekm() to wake the client and share the ekm with
1499
+ * him. The client will check that the ekm matches the one computed by itself.
1500
+ */
1501
+ static int server_srtp_test(WOLFSSL *ssl, func_args *args)
1502
+ {
1503
+ size_t srtp_secret_length;
1504
+ byte *srtp_secret, *p;
1505
+ int ret;
1506
+ #ifdef WOLFSSL_COND
1507
+ srtp_test_helper *srtp_helper = args->srtp_helper;
1508
+ #else
1509
+ (void)args;
1510
+ #endif
1511
+
1512
+ ret = wolfSSL_export_dtls_srtp_keying_material(ssl, NULL,
1513
+ &srtp_secret_length);
1514
+ if (ret != WC_NO_ERR_TRACE(LENGTH_ONLY_E)) {
1515
+ LOG_ERROR("DTLS SRTP: Error getting key material length\n");
1516
+ return ret;
1517
+ }
1518
+
1519
+ srtp_secret = (byte*)XMALLOC(srtp_secret_length,
1520
+ NULL, DYNAMIC_TYPE_TMP_BUFFER);
1521
+ if (srtp_secret == NULL) {
1522
+ err_sys("DTLS SRTP: Memory error");
1523
+ }
1524
+
1525
+ ret = wolfSSL_export_dtls_srtp_keying_material(ssl, srtp_secret,
1526
+ &srtp_secret_length);
1527
+ if (ret != WOLFSSL_SUCCESS) {
1528
+ XFREE(srtp_secret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
1529
+ LOG_ERROR("DTLS SRTP: Error getting key material\n");
1530
+ return ret;
1531
+ }
1532
+
1533
+ printf("DTLS SRTP: Exported key material: ");
1534
+ for (p = srtp_secret; p < srtp_secret + srtp_secret_length; p++)
1535
+ printf("%02X", *p);
1536
+ printf("\n");
1537
+
1538
+ #ifdef WOLFSSL_COND
1539
+ if (srtp_helper != NULL) {
1540
+ srtp_helper_set_ekm(srtp_helper, srtp_secret, srtp_secret_length);
1541
+
1542
+ /* client code will free srtp_secret buffer after checking for
1543
+ correctness */
1544
+ return 0;
1545
+ }
1546
+ #endif /* WOLFSSL_COND */
1547
+
1548
+ XFREE(srtp_secret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
1549
+ return 0;
1550
+ }
1551
+ #endif
1552
+
1553
+
1554
+ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
1555
+ {
1556
+ SOCKET_T sockfd = WOLFSSL_SOCKET_INVALID;
1557
+ SOCKET_T clientfd = WOLFSSL_SOCKET_INVALID;
1558
+ SOCKADDR_IN_T client_addr;
1559
+ socklen_t client_len;
1560
+
1561
+ wolfSSL_method_func method = NULL;
1562
+ SSL_CTX* ctx = 0;
1563
+ SSL* ssl = 0;
1564
+ #ifdef WOLFSSL_WOLFSENTRY_HOOKS
1565
+ wolfsentry_errcode_t wolfsentry_ret;
1566
+ #endif
1567
+ int minVersion = SERVER_INVALID_VERSION;
1568
+ int useWebServerMsg = 0;
1569
+ char input[SRV_READ_SZ];
1570
+ #ifndef WOLFSSL_VXWORKS
1571
+ int ch;
1572
+ static const struct mygetopt_long_config long_options[] = {
1573
+ #if defined(WOLFSSL_WOLFSENTRY_HOOKS) && !defined(NO_FILESYSTEM) && \
1574
+ !defined(WOLFSENTRY_NO_JSON)
1575
+ { "wolfsentry-config", 1, 256 },
1576
+ #endif
1577
+ { "help", 0, 257 },
1578
+ #ifndef NO_MULTIBYTE_PRINT
1579
+ { "ヘルプ", 0, 258 },
1580
+ #endif
1581
+ #if defined(HAVE_PQC)
1582
+ { "pqc", 1, 259 },
1583
+ #endif
1584
+ #ifdef WOLFSSL_SRTP
1585
+ { "srtp", 2, 260 }, /* optional argument */
1586
+ #endif
1587
+ #if defined(WOLFSSL_TLS13) && defined(HAVE_SESSION_TICKET)
1588
+ { "send-ticket", 0, 261 },
1589
+ #endif
1590
+ #ifdef CAN_FORCE_CURVE
1591
+ { "force-curve", 2, 262},
1592
+ #endif
1593
+ #ifdef WOLFSSL_DTLS_CID
1594
+ {"cid", 2, 263},
1595
+ #endif /* WOLFSSL_DTLS_CID */
1596
+ #ifdef HAVE_SUPPORTED_CURVES
1597
+ {"onlyPskDheKe", 2, 264},
1598
+ #endif /* HAVE_SUPPORTED_CURVES */
1599
+ #ifdef HAVE_CRL
1600
+ {"crl-dir", 1, 265},
1601
+ #endif
1602
+ {"quieter", 0, 266},
1603
+ #ifdef WOLFSSL_DUAL_ALG_CERTS
1604
+ { "altPrivKey", 1, 267},
1605
+ #endif
1606
+ #if defined(WOLFSSL_SYS_CRYPTO_POLICY)
1607
+ { "crypto-policy", 1, 268 },
1608
+ #endif /* WOLFSSL_SYS_CRYPTO_POLICY */
1609
+ { 0, 0, 0 }
1610
+ };
1611
+ #endif
1612
+ int version = SERVER_DEFAULT_VERSION;
1613
+ #ifndef WOLFSSL_NO_CLIENT_AUTH
1614
+ int doCliCertCheck = 1;
1615
+ #else
1616
+ int doCliCertCheck = 0;
1617
+ #endif
1618
+ #if defined(HAVE_CRL) && !defined(NO_FILESYSTEM)
1619
+ int disableCRL = 0;
1620
+ #endif
1621
+ int useAnyAddr = 0;
1622
+ word16 port = wolfSSLPort;
1623
+ int usePsk = 0;
1624
+ int usePskPlus = 0;
1625
+ int useAnon = 0;
1626
+ int doDTLS = 0;
1627
+ int dtlsUDP = 0;
1628
+ #if (defined(WOLFSSL_SCTP) || defined(WOLFSSL_DTLS_MTU)) && \
1629
+ defined(WOLFSSL_DTLS)
1630
+ int dtlsMTU = 0;
1631
+ #endif
1632
+ int dtlsSCTP = 0;
1633
+ int doMcast = 0;
1634
+ #if defined(WOLFSSL_DTLS) && defined(USE_WOLFSSL_IO)
1635
+ int doBlockSeq = 0;
1636
+ WOLFSSL_TEST_DTLS_CTX dtlsCtx;
1637
+ #endif
1638
+ int needDH = 0;
1639
+ int nonBlocking = 0;
1640
+ int simulateWantWrite = 0;
1641
+ int fewerPackets = 0;
1642
+ #ifdef HAVE_PK_CALLBACKS
1643
+ int pkCallbacks = 0;
1644
+ PkCbInfo pkCbInfo;
1645
+ #endif
1646
+ int wc_shutdown = 0;
1647
+ int resume = 0;
1648
+ int resumeCount = 0;
1649
+ int loops = 1;
1650
+ int cnt = 0;
1651
+ int echoData = 0;
1652
+ int block = TEST_BUFFER_SIZE;
1653
+ size_t throughput = 0;
1654
+ int minDhKeyBits = DEFAULT_MIN_DHKEY_BITS;
1655
+ short minRsaKeyBits = DEFAULT_MIN_RSAKEY_BITS;
1656
+ short minEccKeyBits = DEFAULT_MIN_ECCKEY_BITS;
1657
+ int doListen = 1;
1658
+ int crlFlags = 0;
1659
+ int ret;
1660
+ int err = 0;
1661
+ char* serverReadyFile = NULL;
1662
+ char* alpnList = NULL;
1663
+ unsigned char alpn_opt = 0;
1664
+ char* cipherList = NULL;
1665
+ int useDefCipherList = 0;
1666
+ const char* verifyCert;
1667
+ const char* ourCert;
1668
+ const char* ourKey;
1669
+ const char* ourDhParam = dhParamFile;
1670
+ tcp_ready* readySignal = NULL;
1671
+ int argc = ((func_args*)args)->argc;
1672
+ char** argv = ((func_args*)args)->argv;
1673
+
1674
+ #ifdef WOLFSSL_TRUST_PEER_CERT
1675
+ const char* trustCert = NULL;
1676
+ #endif
1677
+
1678
+ #ifndef NO_PSK
1679
+ int sendPskIdentityHint = 1;
1680
+ #endif
1681
+
1682
+ #ifdef HAVE_SNI
1683
+ char* sniHostName = NULL;
1684
+ #endif
1685
+
1686
+ #ifdef HAVE_TRUSTED_CA
1687
+ int trustedCaKeyId = 0;
1688
+ #endif /* HAVE_TRUSTED_CA */
1689
+
1690
+ #ifdef HAVE_OCSP
1691
+ int useOcsp = 0;
1692
+ char* ocspUrl = NULL;
1693
+ #endif
1694
+
1695
+ #ifdef HAVE_WNR
1696
+ const char* wnrConfigFile = wnrConfig;
1697
+ #endif
1698
+ char buffer[WOLFSSL_MAX_ERROR_SZ];
1699
+ #ifdef WOLFSSL_TLS13
1700
+ int noPskDheKe = 0;
1701
+ #ifdef HAVE_SUPPORTED_CURVES
1702
+ int onlyPskDheKe = 0;
1703
+ #endif
1704
+ #endif
1705
+ int updateKeysIVs = 0;
1706
+ #ifndef NO_CERTS
1707
+ int mutualAuth = 0;
1708
+ #endif
1709
+ int postHandAuth = 0;
1710
+ int sendTicket = 0;
1711
+ #ifdef WOLFSSL_EARLY_DATA
1712
+ int earlyData = 0;
1713
+ #endif
1714
+ #ifdef HAVE_SECURE_RENEGOTIATION
1715
+ int scr = 0;
1716
+ int forceScr = 0;
1717
+ #endif /* HAVE_SECURE_RENEGOTIATION */
1718
+ #ifdef WOLFSSL_SEND_HRR_COOKIE
1719
+ int hrrCookie = 0;
1720
+ #endif
1721
+ byte mcastID = 0;
1722
+ #if !defined(NO_DH) && !defined(HAVE_FIPS) && \
1723
+ !defined(HAVE_SELFTEST) && !defined(WOLFSSL_OLD_PRIME_CHECK)
1724
+ int doDhKeyCheck = 1;
1725
+ #endif
1726
+ #ifdef WOLFSSL_DTLS_CID
1727
+ int useDtlsCID = 0;
1728
+ char dtlsCID[DTLS_CID_BUFFER_SIZE] = { 0 };
1729
+ #endif /* WOLFSSL_DTLS_CID */
1730
+ #if defined(HAVE_CRL) && !defined(NO_FILESYSTEM)
1731
+ char* crlDir = NULL;
1732
+ #endif
1733
+ #if defined(WOLFSSL_SYS_CRYPTO_POLICY)
1734
+ const char * policy = NULL;
1735
+ #endif /* WOLFSSL_SYS_CRYPTO_POLICY */
1736
+
1737
+ #ifdef WOLFSSL_STATIC_MEMORY
1738
+ /* Note: Actual memory used is much less, this is the entire buffer buckets,
1739
+ * which is partitioned into pools of common sizes. To adjust the buckets
1740
+ * sizes see WOLFMEM_BUCKETS in memory.h */
1741
+ #if (defined(HAVE_ECC) && !defined(ALT_ECC_SIZE)) \
1742
+ || defined(SESSION_CERTS)
1743
+ /* big enough to handle most cases including session certs */
1744
+ #if !defined(WOLFSSL_NO_CLIENT_AUTH) && \
1745
+ ((defined(HAVE_ED25519) && !defined(NO_ED25519_CLIENT_AUTH)) || \
1746
+ (defined(HAVE_ED448) && !defined(NO_ED448_CLIENT_AUTH)))
1747
+ /* increase is due to EdDSA_Update */
1748
+ byte memory[440000];
1749
+ #else
1750
+ byte memory[320000];
1751
+ #endif
1752
+ #else
1753
+ byte memory[80000];
1754
+ #endif
1755
+ byte memoryIO[34500]; /* max for IO buffer (TLS packet can be 16k) */
1756
+ #if !defined(WOLFSSL_STATIC_MEMORY_LEAN)
1757
+ WOLFSSL_MEM_CONN_STATS ssl_stats;
1758
+ #if defined(DEBUG_WOLFSSL)
1759
+ WOLFSSL_MEM_STATS mem_stats;
1760
+ #endif
1761
+ #endif
1762
+ #endif
1763
+ #if defined(WOLFSSL_TLS13) && defined(HAVE_SUPPORTED_CURVES)
1764
+ int onlyKeyShare = 0;
1765
+ #endif
1766
+ #if defined(HAVE_SESSION_TICKET)
1767
+ #ifdef WOLFSSL_TLS13
1768
+ int noTicketTls13 = 0;
1769
+ #endif
1770
+ #if !defined(WOLFSSL_NO_TLS12) || !defined(NO_OLD_TLS)
1771
+ int noTicketTls12 = 0;
1772
+ #endif
1773
+ #endif
1774
+ int useX25519 = 0;
1775
+ int useX448 = 0;
1776
+ int usePqc = 0;
1777
+ char* pqcAlg = NULL;
1778
+ char* altPrivKey = NULL;
1779
+ int exitWithRet = 0;
1780
+ int loadCertKeyIntoSSLObj = 0;
1781
+
1782
+ #ifdef HAVE_ENCRYPT_THEN_MAC
1783
+ int disallowETM = 0;
1784
+ #endif
1785
+ #if defined(OPENSSL_ALL) && defined(WOLFSSL_CERT_GEN) && \
1786
+ (defined(WOLFSSL_CERT_REQ) || defined(WOLFSSL_CERT_EXT)) && \
1787
+ !defined(NO_FILESYSTEM) && !defined(NO_WOLFSSL_DIR)
1788
+ int useCertFolder = 0;
1789
+ #endif
1790
+
1791
+ #ifdef WOLFSSL_SRTP
1792
+ const char* dtlsSrtpProfiles = NULL;
1793
+ #endif
1794
+
1795
+ #ifdef HAVE_TEST_SESSION_TICKET
1796
+ MyTicketCtx myTicketCtx;
1797
+ #endif
1798
+
1799
+ #ifdef CAN_FORCE_CURVE
1800
+ int force_curve_group_id = 0;
1801
+ #endif
1802
+
1803
+ ((func_args*)args)->return_code = -1; /* error state */
1804
+
1805
+ #ifndef NO_RSA
1806
+ verifyCert = cliCertFile;
1807
+ ourCert = svrCertFile;
1808
+ ourKey = svrKeyFile;
1809
+ #else
1810
+ #ifdef HAVE_ECC
1811
+ verifyCert = cliEccCertFile;
1812
+ ourCert = eccCertFile;
1813
+ ourKey = eccKeyFile;
1814
+ #elif defined(HAVE_ED25519)
1815
+ verifyCert = cliEdCertFile;
1816
+ ourCert = edCertFile;
1817
+ ourKey = edKeyFile;
1818
+ #elif defined(HAVE_ED448)
1819
+ verifyCert = cliEd448CertFile;
1820
+ ourCert = ed448CertFile;
1821
+ ourKey = ed448KeyFile;
1822
+ #else
1823
+ verifyCert = NULL;
1824
+ ourCert = NULL;
1825
+ ourKey = NULL;
1826
+ #endif
1827
+ #endif
1828
+
1829
+ (void)needDH;
1830
+ (void)ourKey;
1831
+ (void)ourCert;
1832
+ (void)ourDhParam;
1833
+ (void)verifyCert;
1834
+ (void)doCliCertCheck;
1835
+ (void)minDhKeyBits;
1836
+ (void)minRsaKeyBits;
1837
+ (void)minEccKeyBits;
1838
+ (void)alpnList;
1839
+ (void)alpn_opt;
1840
+ (void)crlFlags;
1841
+ (void)readySignal;
1842
+ (void)updateKeysIVs;
1843
+ #ifndef NO_CERTS
1844
+ (void)mutualAuth;
1845
+ #endif
1846
+ (void)postHandAuth;
1847
+ (void)sendTicket;
1848
+ (void)mcastID;
1849
+ (void)loadCertKeyIntoSSLObj;
1850
+ (void)nonBlocking;
1851
+ (void)pqcAlg;
1852
+ (void)usePqc;
1853
+ (void)altPrivKey;
1854
+
1855
+ #ifdef WOLFSSL_TIRTOS
1856
+ fdOpenSession(Task_self());
1857
+ #endif
1858
+
1859
+ #ifdef WOLFSSL_VXWORKS
1860
+ useAnyAddr = 1;
1861
+ #else
1862
+
1863
+ /* Reinitialize the global myVerifyAction. */
1864
+ myVerifyAction = VERIFY_OVERRIDE_ERROR;
1865
+
1866
+ /* Not Used: h, z, W, X */
1867
+ while ((ch = mygetopt_long(argc, argv, "?:"
1868
+ "abc:defgijk:l:mop:q:rstu;v:wxy"
1869
+ "A:B:C:D:E:FGH:IJ;KL:MNO:PQR:S:T;UVYZ:"
1870
+ "01:23:4:567:89"
1871
+ "@#", long_options, 0)) != -1) {
1872
+ switch (ch) {
1873
+ case '?' :
1874
+ if(myoptarg!=NULL) {
1875
+ lng_index = atoi(myoptarg);
1876
+ if(lng_index<0||lng_index>1){
1877
+ lng_index = 0;
1878
+ }
1879
+ }
1880
+ Usage();
1881
+ XEXIT_T(EXIT_SUCCESS);
1882
+
1883
+ case 257 :
1884
+ lng_index = 0;
1885
+ Usage();
1886
+ XEXIT_T(EXIT_SUCCESS);
1887
+
1888
+ case 258 :
1889
+ lng_index = 1;
1890
+ Usage();
1891
+ XEXIT_T(EXIT_SUCCESS);
1892
+
1893
+ case 'x' :
1894
+ runWithErrors = 1;
1895
+ break;
1896
+
1897
+ case 'd' :
1898
+ doCliCertCheck = 0;
1899
+ break;
1900
+
1901
+ case 'V' :
1902
+ #if defined(HAVE_CRL) && !defined(NO_FILESYSTEM)
1903
+ disableCRL = 1;
1904
+ #endif
1905
+ break;
1906
+
1907
+ case 'b' :
1908
+ useAnyAddr = 1;
1909
+ break;
1910
+
1911
+ case 's' :
1912
+ usePsk = 1;
1913
+ break;
1914
+
1915
+ case 'j' :
1916
+ usePskPlus = 1;
1917
+ break;
1918
+
1919
+ case 'u' :
1920
+ doDTLS = 1;
1921
+ dtlsUDP = 1;
1922
+ #if (defined(WOLFSSL_SCTP) || defined(WOLFSSL_DTLS_MTU)) && \
1923
+ defined(WOLFSSL_DTLS)
1924
+ dtlsMTU = atoi(myoptarg);
1925
+ #endif
1926
+ break;
1927
+
1928
+ #ifdef WOLFSSL_SRTP
1929
+ case 260:
1930
+ doDTLS = 1;
1931
+ dtlsUDP = 1;
1932
+ dtlsSrtpProfiles = myoptarg != NULL ? myoptarg :
1933
+ "SRTP_AES128_CM_SHA1_80";
1934
+ printf("Using SRTP Profile(s): %s\n", dtlsSrtpProfiles);
1935
+ break;
1936
+ #endif
1937
+
1938
+ case 'G' :
1939
+ #ifdef WOLFSSL_SCTP
1940
+ doDTLS = 1;
1941
+ dtlsUDP = 1;
1942
+ dtlsSCTP = 1;
1943
+ #endif
1944
+ break;
1945
+
1946
+ case 'f' :
1947
+ fewerPackets = 1;
1948
+ break;
1949
+
1950
+ case 'R' :
1951
+ serverReadyFile = myoptarg;
1952
+ break;
1953
+
1954
+ case 'r' :
1955
+ #ifndef NO_SESSION_CACHE
1956
+ resume = 1;
1957
+ #endif
1958
+ break;
1959
+
1960
+ case 'P' :
1961
+ #ifdef HAVE_PK_CALLBACKS
1962
+ pkCallbacks = 1;
1963
+ #endif
1964
+ break;
1965
+
1966
+ case 'p' :
1967
+ port = (word16)atoi(myoptarg);
1968
+ break;
1969
+
1970
+ case 'w' :
1971
+ wc_shutdown = 1;
1972
+ break;
1973
+
1974
+ case 'v' :
1975
+ if (myoptarg[0] == 'd') {
1976
+ version = SERVER_DOWNGRADE_VERSION;
1977
+ break;
1978
+ }
1979
+ #if defined(OPENSSL_EXTRA) || defined(WOLFSSL_EITHER_SIDE)
1980
+ else if (myoptarg[0] == 'e') {
1981
+ version = EITHER_DOWNGRADE_VERSION;
1982
+ #ifndef NO_CERTS
1983
+ loadCertKeyIntoSSLObj = 1;
1984
+ #endif
1985
+ break;
1986
+ }
1987
+ #endif
1988
+ version = atoi(myoptarg);
1989
+ if (version < 0 || version > 4) {
1990
+ Usage();
1991
+ XEXIT_T(MY_EX_USAGE);
1992
+ }
1993
+ break;
1994
+
1995
+ case 'l' :
1996
+ cipherList = myoptarg;
1997
+ break;
1998
+
1999
+ case 'H' :
2000
+ if (XSTRCMP(myoptarg, "defCipherList") == 0) {
2001
+ printf("Using default cipher list for testing\n");
2002
+ useDefCipherList = 1;
2003
+ }
2004
+ else if (XSTRCMP(myoptarg, "exitWithRet") == 0) {
2005
+ printf("Skip exit() for testing\n");
2006
+ exitWithRet = 1;
2007
+ }
2008
+ else if (XSTRCMP(myoptarg, "verifyFail") == 0) {
2009
+ printf("Verify should fail\n");
2010
+ myVerifyAction = VERIFY_FORCE_FAIL;
2011
+ }
2012
+ else if (XSTRCMP(myoptarg, "verifyInfo") == 0) {
2013
+ printf("Verify should use preverify (just show info)\n");
2014
+ myVerifyAction = VERIFY_USE_PREVERIFY;
2015
+ }
2016
+ else if (XSTRCMP(myoptarg, "loadSSL") == 0) {
2017
+ printf("Also load cert/key into wolfSSL object\n");
2018
+ #ifndef NO_CERTS
2019
+ loadCertKeyIntoSSLObj = 2;
2020
+ #endif
2021
+ }
2022
+ else if (XSTRCMP(myoptarg, "loadSSLOnly") == 0) {
2023
+ printf("Only load cert/key into wolfSSL object\n");
2024
+ #ifndef NO_CERTS
2025
+ loadCertKeyIntoSSLObj = 1;
2026
+ #endif
2027
+ }
2028
+ else if (XSTRCMP(myoptarg, "disallowETM") == 0) {
2029
+ printf("Disallow Encrypt-Then-MAC\n");
2030
+ #ifdef HAVE_ENCRYPT_THEN_MAC
2031
+ disallowETM = 1;
2032
+ #endif
2033
+ }
2034
+ else if (XSTRCMP(myoptarg, "overrideDateErr") == 0) {
2035
+ #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS)
2036
+ myVerifyAction = VERIFY_OVERRIDE_DATE_ERR;
2037
+ #endif
2038
+ }
2039
+ else {
2040
+ Usage();
2041
+ XEXIT_T(MY_EX_USAGE);
2042
+ }
2043
+ break;
2044
+
2045
+ case 'A' :
2046
+ verifyCert = myoptarg;
2047
+ break;
2048
+
2049
+ case 'c' :
2050
+ ourCert = myoptarg;
2051
+ break;
2052
+
2053
+ case 'k' :
2054
+ ourKey = myoptarg;
2055
+ break;
2056
+
2057
+ case 'D' :
2058
+ #ifndef NO_DH
2059
+ ourDhParam = myoptarg;
2060
+ #endif
2061
+ break;
2062
+
2063
+ case 'Z' :
2064
+ #ifndef NO_DH
2065
+ minDhKeyBits = atoi(myoptarg);
2066
+ if (minDhKeyBits <= 0 || minDhKeyBits > 16000) {
2067
+ Usage();
2068
+ XEXIT_T(MY_EX_USAGE);
2069
+ }
2070
+ #endif
2071
+ break;
2072
+
2073
+ case 'N':
2074
+ nonBlocking = 1;
2075
+ break;
2076
+
2077
+ case 'S' :
2078
+ #ifdef HAVE_SNI
2079
+ sniHostName = myoptarg;
2080
+ #endif
2081
+ break;
2082
+
2083
+ case 'o' :
2084
+ #ifdef HAVE_OCSP
2085
+ useOcsp = 1;
2086
+ #endif
2087
+ break;
2088
+
2089
+ case 'O' :
2090
+ #ifdef HAVE_OCSP
2091
+ useOcsp = 1;
2092
+ ocspUrl = myoptarg;
2093
+ #endif
2094
+ break;
2095
+
2096
+ case 'a' :
2097
+ #ifdef HAVE_ANON
2098
+ useAnon = 1;
2099
+ #endif
2100
+ break;
2101
+ case 'I':
2102
+ #ifndef NO_PSK
2103
+ sendPskIdentityHint = 0;
2104
+ #endif
2105
+ break;
2106
+
2107
+ case 'L' :
2108
+ #ifdef HAVE_ALPN
2109
+ alpnList = myoptarg;
2110
+
2111
+ if (alpnList[0] == 'C' && alpnList[1] == ':')
2112
+ alpn_opt = WOLFSSL_ALPN_CONTINUE_ON_MISMATCH;
2113
+ else if (alpnList[0] == 'F' && alpnList[1] == ':')
2114
+ alpn_opt = WOLFSSL_ALPN_FAILED_ON_MISMATCH;
2115
+ else {
2116
+ Usage();
2117
+ XEXIT_T(MY_EX_USAGE);
2118
+ }
2119
+
2120
+ alpnList += 2;
2121
+
2122
+ #endif
2123
+ break;
2124
+
2125
+ case 'i' :
2126
+ loops = -1;
2127
+ break;
2128
+
2129
+ case 'C' :
2130
+ loops = atoi(myoptarg);
2131
+ if (loops <= 0) {
2132
+ Usage();
2133
+ XEXIT_T(MY_EX_USAGE);
2134
+ }
2135
+ break;
2136
+
2137
+ case 'e' :
2138
+ echoData = 1;
2139
+ break;
2140
+
2141
+ case 'B':
2142
+ throughput = (size_t)atol(myoptarg);
2143
+ for (; *myoptarg != '\0'; myoptarg++) {
2144
+ if (*myoptarg == ',') {
2145
+ block = atoi(myoptarg + 1);
2146
+ break;
2147
+ }
2148
+ }
2149
+ if (throughput == 0 || block <= 0) {
2150
+ Usage();
2151
+ XEXIT_T(MY_EX_USAGE);
2152
+ }
2153
+ break;
2154
+
2155
+ #ifdef WOLFSSL_TRUST_PEER_CERT
2156
+ case 'E' :
2157
+ trustCert = myoptarg;
2158
+ break;
2159
+ #endif
2160
+
2161
+ case 'q' :
2162
+ #ifdef HAVE_WNR
2163
+ wnrConfigFile = myoptarg;
2164
+ #endif
2165
+ break;
2166
+
2167
+ case 'g' :
2168
+ useWebServerMsg = 1;
2169
+ break;
2170
+
2171
+ case 'y' :
2172
+ #if defined(WOLFSSL_TLS13) && defined(HAVE_SUPPORTED_CURVES) \
2173
+ && !defined(NO_DH)
2174
+ onlyKeyShare = 1;
2175
+ #endif
2176
+ break;
2177
+
2178
+ case 'Y' :
2179
+ #if defined(WOLFSSL_TLS13) && defined(HAVE_SUPPORTED_CURVES) \
2180
+ && defined(HAVE_ECC)
2181
+ onlyKeyShare = 2;
2182
+ #endif
2183
+ break;
2184
+
2185
+ case 't' :
2186
+ #ifdef HAVE_CURVE25519
2187
+ useX25519 = 1;
2188
+ #if defined(WOLFSSL_TLS13) && defined(HAVE_SUPPORTED_CURVES)
2189
+ onlyKeyShare = 2;
2190
+ #endif
2191
+ #endif
2192
+ break;
2193
+
2194
+ case 'K' :
2195
+ #ifdef WOLFSSL_TLS13
2196
+ noPskDheKe = 1;
2197
+ #endif
2198
+ break;
2199
+
2200
+ case 'T' :
2201
+ #if defined(HAVE_SESSION_TICKET)
2202
+ if (XSTRLEN(myoptarg) == 0) {
2203
+ #if defined(WOLFSSL_TLS13)
2204
+ noTicketTls13 = 1;
2205
+ #endif
2206
+ }
2207
+ #if !defined(WOLFSSL_NO_TLS12) || !defined(NO_OLD_TLS)
2208
+ else if (XSTRCMP(myoptarg, "a") == 0) {
2209
+ noTicketTls12 = 1;
2210
+ #if defined(WOLFSSL_TLS13)
2211
+ noTicketTls13 = 1;
2212
+ #endif
2213
+ }
2214
+ else if (XSTRCMP(myoptarg, "o") == 0) {
2215
+ noTicketTls12 = 1;
2216
+ }
2217
+ else if (XSTRCMP(myoptarg, "n") == 0) {
2218
+ #if defined(WOLFSSL_TLS13)
2219
+ noTicketTls13 = 1;
2220
+ #endif
2221
+ }
2222
+ #endif
2223
+ else {
2224
+ Usage();
2225
+ XEXIT_T(MY_EX_USAGE);
2226
+ }
2227
+ #endif
2228
+ break;
2229
+
2230
+ case 'U' :
2231
+ #ifdef WOLFSSL_TLS13
2232
+ updateKeysIVs = 1;
2233
+ #endif
2234
+ break;
2235
+
2236
+ #ifndef NO_CERTS
2237
+ case 'F' :
2238
+ mutualAuth = 1;
2239
+ break;
2240
+ #endif
2241
+
2242
+ case 'Q' :
2243
+ #if defined(WOLFSSL_TLS13) && defined(WOLFSSL_POST_HANDSHAKE_AUTH)
2244
+ postHandAuth = 1;
2245
+ doCliCertCheck = 0;
2246
+ #endif
2247
+ break;
2248
+
2249
+ case 'J' :
2250
+ #ifdef WOLFSSL_SEND_HRR_COOKIE
2251
+ hrrCookie = 1;
2252
+ if (XSTRCMP(myoptarg, "n") == 0)
2253
+ hrrCookie = -1;
2254
+ #endif
2255
+ break;
2256
+
2257
+ case 'M' :
2258
+ #ifdef HAVE_SECURE_RENEGOTIATION
2259
+ scr = 1;
2260
+ #endif /* HAVE_SECURE_RENEGOTIATION */
2261
+ break;
2262
+
2263
+ case 'm' :
2264
+ #ifdef HAVE_SECURE_RENEGOTIATION
2265
+ scr = 1;
2266
+ forceScr = 1;
2267
+ #endif /* HAVE_SECURE_RENEGOTIATION */
2268
+ break;
2269
+
2270
+ case '0' :
2271
+ #ifdef WOLFSSL_EARLY_DATA
2272
+ earlyData = 1;
2273
+ #endif
2274
+ break;
2275
+
2276
+ case '1' :
2277
+ lng_index = atoi(myoptarg);
2278
+ if(lng_index<0||lng_index>1){
2279
+ lng_index = 0;
2280
+ }
2281
+ break;
2282
+
2283
+ case '2' :
2284
+ #if !defined(NO_DH) && !defined(HAVE_FIPS) && \
2285
+ !defined(HAVE_SELFTEST) && !defined(WOLFSSL_OLD_PRIME_CHECK)
2286
+ doDhKeyCheck = 0;
2287
+ #endif
2288
+ break;
2289
+
2290
+ case '3' :
2291
+ #ifdef WOLFSSL_MULTICAST
2292
+ doMcast = 1;
2293
+ mcastID = (byte)(atoi(myoptarg) & 0xFF);
2294
+ #endif
2295
+ break;
2296
+
2297
+ case '4' :
2298
+ #if defined(WOLFSSL_DTLS) && defined(USE_WOLFSSL_IO)
2299
+ XMEMSET(&dtlsCtx, 0, sizeof(dtlsCtx));
2300
+ doBlockSeq = 1;
2301
+ dtlsCtx.blockSeq = (word32)atoi(myoptarg);
2302
+ #endif
2303
+ break;
2304
+
2305
+ case '5' :
2306
+ #ifdef HAVE_TRUSTED_CA
2307
+ trustedCaKeyId = 1;
2308
+ #endif /* HAVE_TRUSTED_CA */
2309
+ break;
2310
+
2311
+ case '6' :
2312
+ #ifdef WOLFSSL_ASYNC_IO
2313
+ nonBlocking = 1;
2314
+ simulateWantWrite = 1;
2315
+ #else
2316
+ LOG_ERROR("Ignoring -6 since async I/O support not "
2317
+ "compiled in.\n");
2318
+ #endif
2319
+ break;
2320
+ case '7' :
2321
+ minVersion = atoi(myoptarg);
2322
+ if (minVersion < 0 || minVersion > 4) {
2323
+ Usage();
2324
+ XEXIT_T(MY_EX_USAGE);
2325
+ }
2326
+ break;
2327
+ case '8' :
2328
+ #ifdef HAVE_CURVE448
2329
+ useX448 = 1;
2330
+ #if defined(WOLFSSL_TLS13) && defined(HAVE_SUPPORTED_CURVES)
2331
+ onlyKeyShare = 2;
2332
+ #endif
2333
+ #endif
2334
+ break;
2335
+ case '9' :
2336
+ #if defined(OPENSSL_ALL) && defined(WOLFSSL_CERT_GEN) && \
2337
+ (defined(WOLFSSL_CERT_REQ) || defined(WOLFSSL_CERT_EXT)) && \
2338
+ !defined(NO_FILESYSTEM) && !defined(NO_WOLFSSL_DIR)
2339
+ useCertFolder = 1;
2340
+ break;
2341
+ #endif
2342
+ case '@' :
2343
+ {
2344
+ #ifdef HAVE_WC_INTROSPECTION
2345
+ const char *conf_args = wolfSSL_configure_args();
2346
+ if (conf_args) {
2347
+ puts(conf_args);
2348
+ XEXIT_T(EXIT_SUCCESS);
2349
+ } else {
2350
+ fputs("configure args not compiled in.\n",stderr);
2351
+ XEXIT_T(MY_EX_USAGE);
2352
+ }
2353
+ #else
2354
+ fputs("compiled without BUILD_INTROSPECTION.\n",stderr);
2355
+ XEXIT_T(MY_EX_USAGE);
2356
+ #endif
2357
+ }
2358
+
2359
+ case '#' :
2360
+ {
2361
+ #ifdef HAVE_WC_INTROSPECTION
2362
+ const char *cflags = wolfSSL_global_cflags();
2363
+ if (cflags) {
2364
+ puts(cflags);
2365
+ XEXIT_T(EXIT_SUCCESS);
2366
+ } else {
2367
+ fputs("CFLAGS not compiled in.\n",stderr);
2368
+ XEXIT_T(MY_EX_USAGE);
2369
+ }
2370
+ #else
2371
+ fputs("compiled without BUILD_INTROSPECTION.\n",stderr);
2372
+ XEXIT_T(MY_EX_USAGE);
2373
+ #endif
2374
+ }
2375
+
2376
+ #ifdef WOLFSSL_WOLFSENTRY_HOOKS
2377
+ case 256:
2378
+ #if !defined(NO_FILESYSTEM) && !defined(WOLFSENTRY_NO_JSON)
2379
+ wolfsentry_config_path = myoptarg;
2380
+ #endif
2381
+ break;
2382
+ #endif
2383
+
2384
+ #ifdef HAVE_PQC
2385
+ case 259:
2386
+ {
2387
+ usePqc = 1;
2388
+ #if defined(WOLFSSL_TLS13) && defined(HAVE_SUPPORTED_CURVES)
2389
+ onlyKeyShare = 2;
2390
+ #endif
2391
+ pqcAlg = myoptarg;
2392
+ } break;
2393
+ #endif
2394
+
2395
+ #if defined(WOLFSSL_TLS13) && defined(HAVE_SESSION_TICKET)
2396
+ case 261:
2397
+ sendTicket = 1;
2398
+ break;
2399
+ #endif
2400
+ #ifdef CAN_FORCE_CURVE
2401
+ case 262: {
2402
+ /* Note: this requires TSL1.3 (version >= 4) */
2403
+ #ifdef HAVE_ECC
2404
+ int j = 0; /* our group index */
2405
+ #endif
2406
+ if (NULL == myoptarg) {
2407
+ #ifdef HAVE_ECC
2408
+ int idx = 0; /* ecc curve index */
2409
+ #endif
2410
+ Usage();
2411
+ if (lng_index == 1) {
2412
+ /* TODO: Need Japanese translation */
2413
+ printf("\nAvailable choices for --force-curve:\n");
2414
+ } else {
2415
+ printf("\nAvailable choices for --force-curve:\n");
2416
+ }
2417
+ #ifdef HAVE_ECC
2418
+ for (idx=0; ; ++idx) {
2419
+ int id = wc_ecc_get_curve_id(idx);
2420
+ if (ECC_CURVE_INVALID == id) {
2421
+ break;
2422
+ }
2423
+ for (j=0; group_id_to_text[j].group != 0; ++j) {
2424
+ if (XSTRCMP(group_id_to_text[j].name,
2425
+ wc_ecc_get_curve_name_from_id(id)) == 0) {
2426
+ printf("\t%s\n", group_id_to_text[j].name);
2427
+ }
2428
+ }
2429
+ }
2430
+ #endif
2431
+ #ifdef HAVE_CURVE25519
2432
+ printf("\tCURVE25519\n");
2433
+ #endif
2434
+ #ifdef HAVE_CURVE448
2435
+ printf("\tCURVE448\n");
2436
+ #endif
2437
+ printf("\n");
2438
+ XEXIT_T(EXIT_SUCCESS);
2439
+ }
2440
+ #ifdef HAVE_ECC
2441
+ for (j=0; group_id_to_text[j].group != 0; ++j) {
2442
+ if (XSTRCMP(group_id_to_text[j].name, myoptarg) == 0) {
2443
+ force_curve_group_id = group_id_to_text[j].group;
2444
+ }
2445
+ }
2446
+ #endif
2447
+ #ifdef HAVE_CURVE25519
2448
+ if (force_curve_group_id <= 0) {
2449
+ if (XSTRCMP(myoptarg, "CURVE25519") == 0) {
2450
+ force_curve_group_id = WOLFSSL_ECC_X25519;
2451
+ }
2452
+ }
2453
+ #endif
2454
+ #ifdef HAVE_CURVE448
2455
+ if (force_curve_group_id <= 0) {
2456
+ if (XSTRCMP(myoptarg, "CURVE448") == 0) {
2457
+ force_curve_group_id = WOLFSSL_ECC_X448;
2458
+ }
2459
+ }
2460
+ #endif
2461
+ if (force_curve_group_id <= 0) {
2462
+ if (lng_index == 1) {
2463
+ /* TODO: Need Japanese translation */
2464
+ LOG_ERROR("Invalid curve '%s'\n", myoptarg);
2465
+ } else {
2466
+ LOG_ERROR("Invalid curve '%s'\n", myoptarg);
2467
+ }
2468
+ XEXIT_T(EXIT_FAILURE);
2469
+ }
2470
+ }
2471
+ break;
2472
+ #endif /* CAN_FORCE_CURVE */
2473
+ #ifdef WOLFSSL_DTLS_CID
2474
+ case 263:
2475
+ useDtlsCID = 1;
2476
+ if (myoptarg != NULL) {
2477
+ if (XSTRLEN(myoptarg) >= DTLS_CID_BUFFER_SIZE) {
2478
+ err_sys("provided connection ID is too big");
2479
+ }
2480
+ else {
2481
+ XSTRLCPY(dtlsCID, myoptarg, DTLS_CID_BUFFER_SIZE);
2482
+ }
2483
+ }
2484
+ break;
2485
+ #endif /* WOLFSSL_CID */
2486
+ case 264:
2487
+ #ifdef HAVE_SUPPORTED_CURVES
2488
+ #ifdef WOLFSSL_TLS13
2489
+ onlyPskDheKe = 1;
2490
+ #endif
2491
+ #endif
2492
+ break;
2493
+ case 265:
2494
+ #if defined(HAVE_CRL) && !defined(NO_FILESYSTEM)
2495
+ crlDir = myoptarg;
2496
+ #endif
2497
+ break;
2498
+
2499
+ case 266:
2500
+ quieter = 1;
2501
+ break;
2502
+
2503
+ #ifdef WOLFSSL_DUAL_ALG_CERTS
2504
+ case 267:
2505
+ altPrivKey = myoptarg;
2506
+ break;
2507
+ #endif
2508
+ case 268:
2509
+ #if defined(WOLFSSL_SYS_CRYPTO_POLICY)
2510
+ policy = myoptarg;
2511
+ #endif /* WOLFSSL_SYS_CRYPTO_POLICY */
2512
+ break;
2513
+
2514
+ case -1:
2515
+ default:
2516
+ Usage();
2517
+ XEXIT_T(MY_EX_USAGE);
2518
+ }
2519
+ }
2520
+
2521
+ myoptind = 0; /* reset for test cases */
2522
+ #endif /* !WOLFSSL_VXWORKS */
2523
+
2524
+ /* Can only use DTLS over UDP or SCTP, can't do both. */
2525
+ if (dtlsUDP && dtlsSCTP) {
2526
+ err_sys_ex(runWithErrors, "Cannot use DTLS with both UDP and SCTP.");
2527
+ }
2528
+
2529
+ /* sort out DTLS versus TLS versions */
2530
+ if (version == CLIENT_INVALID_VERSION) {
2531
+ if (doDTLS)
2532
+ version = CLIENT_DTLS_DEFAULT_VERSION;
2533
+ else
2534
+ version = CLIENT_DEFAULT_VERSION;
2535
+ }
2536
+ else {
2537
+ if (doDTLS) {
2538
+ if (version == 3) {
2539
+ version = -2;
2540
+ }
2541
+ else if (version == 4) {
2542
+ #ifdef WOLFSSL_DTLS13
2543
+ version = -4;
2544
+ #else
2545
+ err_sys_ex(runWithErrors, "Bad DTLS version");
2546
+ #endif /* WOLFSSL_DTLS13 */
2547
+ }
2548
+ #if defined(OPENSSL_EXTRA) || defined(WOLFSSL_EITHER_SIDE)
2549
+ else if (version == EITHER_DOWNGRADE_VERSION) {
2550
+ version = -3;
2551
+ }
2552
+ #endif
2553
+ else if (version == 2)
2554
+ version = -1;
2555
+ }
2556
+ }
2557
+
2558
+ #ifndef HAVE_SESSION_TICKET
2559
+ if ((version >= 4) && resume) {
2560
+ LOG_ERROR("Can't do TLS 1.3 resumption; need session tickets!\n");
2561
+ }
2562
+ #endif
2563
+
2564
+ #ifdef HAVE_WNR
2565
+ if (wc_InitNetRandom(wnrConfigFile, NULL, 5000) != 0)
2566
+ err_sys_ex(runWithErrors, "can't load whitewood net random config "
2567
+ "file");
2568
+ #endif
2569
+
2570
+ #ifdef HAVE_PQC
2571
+ if (usePqc) {
2572
+ if (version == SERVER_DOWNGRADE_VERSION ||
2573
+ version == EITHER_DOWNGRADE_VERSION) {
2574
+ LOG_ERROR(
2575
+ "WARNING: If a TLS 1.3 connection is not negotiated, you "
2576
+ "will not be using a post-quantum group.\n");
2577
+ } else if (version != 4 && version != -4) {
2578
+ err_sys("can only use post-quantum groups with TLS 1.3 or DTLS 1.3");
2579
+ }
2580
+ }
2581
+ #endif
2582
+
2583
+ switch (version) {
2584
+ #ifndef NO_OLD_TLS
2585
+ #ifdef WOLFSSL_ALLOW_SSLV3
2586
+ case 0:
2587
+ method = wolfSSLv3_server_method_ex;
2588
+ break;
2589
+ #endif
2590
+
2591
+ #ifndef NO_TLS
2592
+ #ifdef WOLFSSL_ALLOW_TLSV10
2593
+ case 1:
2594
+ method = wolfTLSv1_server_method_ex;
2595
+ break;
2596
+ #endif
2597
+
2598
+ case 2:
2599
+ method = wolfTLSv1_1_server_method_ex;
2600
+ break;
2601
+ #endif /* !NO_TLS */
2602
+ #endif /* !NO_OLD_TLS */
2603
+
2604
+ #ifndef NO_TLS
2605
+ #ifndef WOLFSSL_NO_TLS12
2606
+ case 3:
2607
+ method = wolfTLSv1_2_server_method_ex;
2608
+ break;
2609
+ #endif
2610
+
2611
+ #ifdef WOLFSSL_TLS13
2612
+ case 4:
2613
+ method = wolfTLSv1_3_server_method_ex;
2614
+ break;
2615
+ #endif
2616
+
2617
+ case SERVER_DOWNGRADE_VERSION:
2618
+ if (!doDTLS) {
2619
+ method = wolfSSLv23_server_method_ex;
2620
+ }
2621
+ else {
2622
+ #ifdef WOLFSSL_DTLS
2623
+ method = wolfDTLS_server_method_ex;
2624
+ #else
2625
+ err_sys_ex(runWithErrors, "version not supported");
2626
+ #endif /* WOLFSSL_DTLS */
2627
+ }
2628
+ break;
2629
+ #if defined(OPENSSL_EXTRA) || defined(WOLFSSL_EITHER_SIDE)
2630
+ case EITHER_DOWNGRADE_VERSION:
2631
+ method = wolfSSLv23_method_ex;
2632
+ break;
2633
+ #endif
2634
+ #endif /* NO_TLS */
2635
+
2636
+ #ifdef WOLFSSL_DTLS
2637
+ #ifndef NO_OLD_TLS
2638
+ case -1:
2639
+ method = wolfDTLSv1_server_method_ex;
2640
+ break;
2641
+ #endif
2642
+
2643
+ #ifndef WOLFSSL_NO_TLS12
2644
+ case -2:
2645
+ method = wolfDTLSv1_2_server_method_ex;
2646
+ break;
2647
+ #endif
2648
+ #ifdef WOLFSSL_DTLS13
2649
+ case -4:
2650
+ method = wolfDTLSv1_3_server_method_ex;
2651
+ break;
2652
+ #endif
2653
+ #if defined(OPENSSL_EXTRA) || defined(WOLFSSL_EITHER_SIDE)
2654
+ case -3:
2655
+ method = wolfDTLSv1_2_method_ex;
2656
+ break;
2657
+ #endif
2658
+ #endif
2659
+
2660
+ default:
2661
+ err_sys_ex(runWithErrors, "Bad SSL version");
2662
+ }
2663
+
2664
+ if (method == NULL)
2665
+ err_sys_ex(runWithErrors, "unable to get method");
2666
+
2667
+ #if defined(WOLFSSL_SYS_CRYPTO_POLICY)
2668
+ if (policy != NULL) {
2669
+ if (wolfSSL_crypto_policy_enable(policy) != WOLFSSL_SUCCESS) {
2670
+ err_sys("wolfSSL_crypto_policy_enable failed");
2671
+ }
2672
+ }
2673
+ #endif /* WOLFSSL_SYS_CRYPTO_POLICY */
2674
+
2675
+ #ifdef WOLFSSL_STATIC_MEMORY
2676
+ #if defined(DEBUG_WOLFSSL) && !defined(WOLFSSL_STATIC_MEMORY_LEAN)
2677
+ /* print off helper buffer sizes for use with static memory
2678
+ * printing to stderr in case of debug mode turned on */
2679
+ LOG_ERROR("static memory management size = %d\n",
2680
+ wolfSSL_MemoryPaddingSz());
2681
+ LOG_ERROR("calculated optimum general buffer size = %d\n",
2682
+ wolfSSL_StaticBufferSz(memory, sizeof(memory), 0));
2683
+ LOG_ERROR("calculated optimum IO buffer size = %d\n",
2684
+ wolfSSL_StaticBufferSz(memoryIO, sizeof(memoryIO),
2685
+ WOLFMEM_IO_POOL_FIXED));
2686
+ #endif /* DEBUG_WOLFSSL */
2687
+
2688
+ if (wolfSSL_CTX_load_static_memory(&ctx, method, memory, sizeof(memory),0,1)
2689
+ != WOLFSSL_SUCCESS)
2690
+ err_sys_ex(catastrophic, "unable to load static memory and create ctx");
2691
+
2692
+ /* load in a buffer for IO */
2693
+ if (wolfSSL_CTX_load_static_memory(&ctx, NULL, memoryIO, sizeof(memoryIO),
2694
+ WOLFMEM_IO_POOL_FIXED | WOLFMEM_TRACK_STATS, 1)
2695
+ != WOLFSSL_SUCCESS)
2696
+ err_sys_ex(catastrophic, "unable to load static memory and create ctx");
2697
+ #else
2698
+ if (method != NULL) {
2699
+ ctx = SSL_CTX_new(method(NULL));
2700
+ }
2701
+ #ifdef WOLFSSL_CALLBACKS
2702
+ wolfSSL_CTX_set_msg_callback(ctx, msgDebugCb);
2703
+ #endif
2704
+ #endif /* WOLFSSL_STATIC_MEMORY */
2705
+ if (ctx == NULL)
2706
+ err_sys_ex(catastrophic, "unable to get ctx");
2707
+
2708
+ if (minVersion != SERVER_INVALID_VERSION) {
2709
+ #ifdef WOLFSSL_DTLS
2710
+ if (doDTLS) {
2711
+ switch (minVersion) {
2712
+ #ifdef WOLFSSL_DTLS13
2713
+ case 4:
2714
+ minVersion = WOLFSSL_DTLSV1_3;
2715
+ break;
2716
+ #endif /* WOLFSSL_DTLS13 */
2717
+ case 3:
2718
+ minVersion = WOLFSSL_DTLSV1_2;
2719
+ break;
2720
+ case 2:
2721
+ minVersion = WOLFSSL_DTLSV1;
2722
+ break;
2723
+ }
2724
+ }
2725
+ #endif /* WOLFSSL_DTLS13 */
2726
+ if (wolfSSL_CTX_SetMinVersion(ctx, minVersion) != WOLFSSL_SUCCESS)
2727
+ err_sys_ex(catastrophic, "can't set minimum downgrade version");
2728
+ }
2729
+
2730
+ #ifdef OPENSSL_COMPATIBLE_DEFAULTS
2731
+ /* Restore wolfSSL verify defaults */
2732
+ wolfSSL_CTX_set_verify(ctx, WOLFSSL_VERIFY_DEFAULT, NULL);
2733
+ #endif
2734
+
2735
+ #ifdef WOLFSSL_SRTP
2736
+ if (dtlsSrtpProfiles != NULL) {
2737
+ if (wolfSSL_CTX_set_tlsext_use_srtp(ctx, dtlsSrtpProfiles)
2738
+ != 0) {
2739
+ err_sys_ex(catastrophic, "unable to set DTLS SRTP profile");
2740
+ }
2741
+ }
2742
+ #endif
2743
+
2744
+ #ifdef WOLFSSL_WOLFSENTRY_HOOKS
2745
+ if (wolfsentry_setup(&wolfsentry, wolfsentry_config_path,
2746
+ WOLFSENTRY_ROUTE_FLAG_DIRECTION_IN) < 0) {
2747
+ err_sys("unable to initialize wolfSentry");
2748
+ }
2749
+
2750
+ if (wolfSSL_CTX_set_AcceptFilter(
2751
+ ctx,
2752
+ (NetworkFilterCallback_t)wolfSentry_NetworkFilterCallback,
2753
+ wolfsentry) < 0) {
2754
+ err_sys_ex(catastrophic,
2755
+ "unable to install wolfSentry_NetworkFilterCallback");
2756
+ }
2757
+ #endif
2758
+
2759
+ if (simulateWantWrite)
2760
+ {
2761
+ #ifdef USE_WOLFSSL_IO
2762
+ wolfSSL_CTX_SetIOSend(ctx, SimulateWantWriteIOSendCb);
2763
+ #endif
2764
+ }
2765
+
2766
+ #ifdef HAVE_TEST_SESSION_TICKET
2767
+ if (TicketInit() != 0)
2768
+ err_sys_ex(catastrophic, "unable to setup Session Ticket Key context");
2769
+ wolfSSL_CTX_set_TicketEncCb(ctx, myTicketEncCb);
2770
+ XMEMSET(&myTicketCtx, 0, sizeof(myTicketCtx));
2771
+ wolfSSL_CTX_set_TicketEncCtx(ctx, &myTicketCtx);
2772
+ #endif
2773
+
2774
+ #if defined(WOLFSSL_SNIFFER) && defined(WOLFSSL_STATIC_EPHEMERAL) && \
2775
+ defined(WOLFSSL_PEM_TO_DER)
2776
+ /* used for testing only to set a static/fixed ephemeral key
2777
+ for use with the sniffer */
2778
+ #if defined(HAVE_ECC) && !defined(NO_ECC_SECP) && \
2779
+ (!defined(NO_ECC256) || defined(HAVE_ALL_CURVES))
2780
+ ret = wolfSSL_CTX_set_ephemeral_key(ctx, WC_PK_TYPE_ECDH,
2781
+ "./certs/statickeys/ecc-secp256r1.pem", 0, WOLFSSL_FILETYPE_PEM);
2782
+ if (ret != 0) {
2783
+ err_sys_ex(runWithErrors, "error loading static ECDH key");
2784
+ }
2785
+ {
2786
+ const byte* key = NULL;
2787
+ word32 keySz = 0;
2788
+ /* example for getting pointer to loaded static ephemeral key */
2789
+ wolfSSL_CTX_get_ephemeral_key(ctx, WC_PK_TYPE_ECDH, &key, &keySz);
2790
+ (void)key;
2791
+ (void)keySz;
2792
+ }
2793
+ #endif
2794
+ #ifndef NO_DH
2795
+ ret = wolfSSL_CTX_set_ephemeral_key(ctx, WC_PK_TYPE_DH,
2796
+ "./certs/statickeys/dh-ffdhe2048.pem", 0, WOLFSSL_FILETYPE_PEM);
2797
+ if (ret != 0) {
2798
+ err_sys_ex(runWithErrors, "error loading static DH key");
2799
+ }
2800
+ #endif
2801
+ #ifdef HAVE_CURVE25519
2802
+ ret = wolfSSL_CTX_set_ephemeral_key(ctx, WC_PK_TYPE_CURVE25519,
2803
+ "./certs/statickeys/x25519.pem", 0, WOLFSSL_FILETYPE_PEM);
2804
+ if (ret != 0) {
2805
+ err_sys_ex(runWithErrors, "error loading static X25519 key");
2806
+ }
2807
+ #endif
2808
+ #endif /* WOLFSSL_SNIFFER && WOLFSSL_STATIC_EPHEMERAL && WOLFSSL_PEM_TO_DER */
2809
+
2810
+ if (cipherList && !useDefCipherList) {
2811
+ if (SSL_CTX_set_cipher_list(ctx, cipherList) != WOLFSSL_SUCCESS)
2812
+ err_sys_ex(runWithErrors, "server can't set custom cipher list");
2813
+ }
2814
+
2815
+ #ifdef WOLFSSL_LEANPSK
2816
+ if (!usePsk) {
2817
+ usePsk = 1;
2818
+ }
2819
+ #endif
2820
+
2821
+ #if defined(NO_RSA) && !defined(HAVE_ECC) && !defined(HAVE_ED25519) && \
2822
+ !defined(HAVE_ED448)
2823
+ if (!usePsk) {
2824
+ usePsk = 1;
2825
+ }
2826
+ #endif
2827
+
2828
+ if (fewerPackets)
2829
+ wolfSSL_CTX_set_group_messages(ctx);
2830
+ #if (defined(WOLFSSL_SCTP) || defined(WOLFSSL_DTLS_MTU)) && \
2831
+ defined(WOLFSSL_DTLS)
2832
+ if (dtlsMTU)
2833
+ wolfSSL_CTX_dtls_set_mtu(ctx, (unsigned short)dtlsMTU);
2834
+ #endif
2835
+
2836
+ #ifdef WOLFSSL_SCTP
2837
+ if (dtlsSCTP)
2838
+ wolfSSL_CTX_dtls_set_sctp(ctx);
2839
+ #endif
2840
+
2841
+ #ifdef WOLFSSL_ENCRYPTED_KEYS
2842
+ SSL_CTX_set_default_passwd_cb(ctx, PasswordCallBack);
2843
+ #endif
2844
+
2845
+ #if !defined(NO_CERTS)
2846
+ if ((!usePsk || usePskPlus) && !useAnon && !(loadCertKeyIntoSSLObj == 1)) {
2847
+ #if defined(NO_FILESYSTEM) && defined(USE_CERT_BUFFERS_2048)
2848
+ if (wolfSSL_CTX_use_certificate_chain_buffer_format(ctx,
2849
+ server_cert_der_2048, sizeof_server_cert_der_2048,
2850
+ WOLFSSL_FILETYPE_ASN1) != WOLFSSL_SUCCESS)
2851
+ err_sys_ex(catastrophic, "can't load server cert buffer");
2852
+ #elif !defined(TEST_LOAD_BUFFER)
2853
+ #if defined(WOLFSSL_PEM_TO_DER)
2854
+ if (SSL_CTX_use_certificate_chain_file(ctx, ourCert)
2855
+ != WOLFSSL_SUCCESS)
2856
+ #else
2857
+ if (wolfSSL_CTX_use_certificate_chain_file_format(ctx, ourCert,
2858
+ WOLFSSL_FILETYPE_ASN1) != WOLFSSL_SUCCESS)
2859
+ #endif
2860
+ err_sys_ex(catastrophic, "can't load server cert file, check file "
2861
+ "and run from wolfSSL home dir");
2862
+ #else
2863
+ /* loads cert chain file using buffer API */
2864
+ load_buffer(ctx, ourCert, WOLFSSL_CERT_CHAIN);
2865
+ #endif
2866
+ }
2867
+ #endif
2868
+
2869
+ #ifndef NO_DH
2870
+ if (wolfSSL_CTX_SetMinDhKey_Sz(ctx, (word16)minDhKeyBits)
2871
+ != WOLFSSL_SUCCESS) {
2872
+ err_sys_ex(runWithErrors, "Error setting minimum DH key size");
2873
+ }
2874
+ #endif
2875
+ #ifndef NO_RSA
2876
+ if (wolfSSL_CTX_SetMinRsaKey_Sz(ctx, minRsaKeyBits) != WOLFSSL_SUCCESS){
2877
+ err_sys_ex(runWithErrors, "Error setting minimum RSA key size");
2878
+ }
2879
+ #endif
2880
+ #ifdef HAVE_ECC
2881
+ if (wolfSSL_CTX_SetMinEccKey_Sz(ctx, minEccKeyBits) != WOLFSSL_SUCCESS){
2882
+ err_sys_ex(runWithErrors, "Error setting minimum ECC key size");
2883
+ }
2884
+ #endif
2885
+
2886
+ #if !defined(NO_CERTS)
2887
+ #ifdef HAVE_PK_CALLBACKS
2888
+ pkCbInfo.ourKey = ourKey;
2889
+ #endif
2890
+ if ((!usePsk || usePskPlus) && !useAnon
2891
+ && !(loadCertKeyIntoSSLObj == 1)
2892
+ #if defined(HAVE_PK_CALLBACKS) && defined(TEST_PK_PRIVKEY)
2893
+ && !pkCallbacks
2894
+ #endif /* HAVE_PK_CALLBACKS && TEST_PK_PRIVKEY */
2895
+ ) {
2896
+ #ifdef NO_FILESYSTEM
2897
+ if (wolfSSL_CTX_use_PrivateKey_buffer(ctx, server_key_der_2048,
2898
+ sizeof_server_key_der_2048, SSL_FILETYPE_ASN1) != WOLFSSL_SUCCESS)
2899
+ err_sys_ex(catastrophic, "can't load server private key buffer");
2900
+ #elif !defined(TEST_LOAD_BUFFER)
2901
+ #if defined(WOLFSSL_PEM_TO_DER)
2902
+ if (SSL_CTX_use_PrivateKey_file(ctx, ourKey, WOLFSSL_FILETYPE_PEM)
2903
+ != WOLFSSL_SUCCESS)
2904
+ #else
2905
+ if (SSL_CTX_use_PrivateKey_file(ctx, ourKey, WOLFSSL_FILETYPE_ASN1)
2906
+ != WOLFSSL_SUCCESS)
2907
+ #endif
2908
+ err_sys_ex(catastrophic, "can't load server private key file, "
2909
+ "check file and run from wolfSSL home dir");
2910
+ #ifdef WOLFSSL_DUAL_ALG_CERTS
2911
+ if ((altPrivKey != NULL) &&
2912
+ wolfSSL_CTX_use_AltPrivateKey_file(ctx, altPrivKey,
2913
+ WOLFSSL_FILETYPE_PEM)
2914
+ != WOLFSSL_SUCCESS)
2915
+ err_sys_ex(catastrophic, "can't load alt private key file, "
2916
+ "check file and run from wolfSSL home dir");
2917
+ #endif /* WOLFSSL_DUAL_ALG_CERTS */
2918
+ #else
2919
+ /* loads private key file using buffer API */
2920
+ load_buffer(ctx, ourKey, WOLFSSL_KEY);
2921
+ #endif
2922
+ }
2923
+ #endif
2924
+
2925
+ if (usePsk || usePskPlus) {
2926
+ #ifndef NO_PSK
2927
+ const char *defaultCipherList = cipherList;
2928
+
2929
+ SSL_CTX_set_psk_server_callback(ctx, my_psk_server_cb);
2930
+ #ifdef WOLFSSL_TLS13
2931
+ wolfSSL_CTX_set_psk_server_tls13_callback(ctx, my_psk_server_tls13_cb);
2932
+ #endif
2933
+ if (sendPskIdentityHint == 1)
2934
+ SSL_CTX_use_psk_identity_hint(ctx, "cyassl server");
2935
+
2936
+ if (defaultCipherList == NULL && !usePskPlus) {
2937
+ #if defined(HAVE_AESGCM) && !defined(NO_DH)
2938
+ #ifdef WOLFSSL_TLS13
2939
+ defaultCipherList = "TLS13-AES128-GCM-SHA256"
2940
+ #ifndef WOLFSSL_NO_TLS12
2941
+ ":DHE-PSK-AES128-GCM-SHA256"
2942
+ #endif
2943
+ ;
2944
+ #else
2945
+ defaultCipherList = "DHE-PSK-AES128-GCM-SHA256";
2946
+ #endif
2947
+ needDH = 1;
2948
+ #elif defined(HAVE_AESGCM) && defined(WOLFSSL_TLS13)
2949
+ defaultCipherList = "TLS13-AES128-GCM-SHA256"
2950
+ #ifndef WOLFSSL_NO_TLS12
2951
+ ":PSK-AES128-GCM-SHA256"
2952
+ #endif
2953
+ ;
2954
+ #elif defined(HAVE_NULL_CIPHER)
2955
+ defaultCipherList = "PSK-NULL-SHA256";
2956
+ #elif !defined(NO_AES_CBC)
2957
+ defaultCipherList = "PSK-AES128-CBC-SHA256";
2958
+ #else
2959
+ defaultCipherList = "PSK-AES128-GCM-SHA256";
2960
+ #endif
2961
+ if (SSL_CTX_set_cipher_list(ctx, defaultCipherList)
2962
+ != WOLFSSL_SUCCESS)
2963
+ err_sys_ex(runWithErrors, "server can't set cipher list 2");
2964
+ }
2965
+ wolfSSL_CTX_set_psk_callback_ctx(ctx, (void*)defaultCipherList);
2966
+ #endif /* !NO_PSK */
2967
+ }
2968
+ #ifndef NO_CERTS
2969
+ if (mutualAuth)
2970
+ wolfSSL_CTX_mutual_auth(ctx, 1);
2971
+ #endif
2972
+
2973
+
2974
+ #ifdef HAVE_ECC
2975
+ /* Use ECDHE key size that matches long term key.
2976
+ * Zero means use ctx->privateKeySz.
2977
+ * Default ECDHE_SIZE is 32 bytes
2978
+ */
2979
+ if (wolfSSL_CTX_SetTmpEC_DHE_Sz(ctx, 0) != WOLFSSL_SUCCESS){
2980
+ err_sys_ex(runWithErrors, "Error setting ECDHE size");
2981
+ }
2982
+ #endif
2983
+
2984
+ if (useAnon) {
2985
+ #ifdef HAVE_ANON
2986
+ wolfSSL_CTX_allow_anon_cipher(ctx);
2987
+ if (cipherList == NULL || (cipherList && useDefCipherList)) {
2988
+ const char* defaultCipherList;
2989
+ defaultCipherList = "ADH-AES256-GCM-SHA384:"
2990
+ "ADH-AES128-SHA";
2991
+ if (SSL_CTX_set_cipher_list(ctx, defaultCipherList)
2992
+ != WOLFSSL_SUCCESS)
2993
+ err_sys_ex(runWithErrors, "server can't set cipher list 4");
2994
+ }
2995
+ #endif
2996
+ }
2997
+
2998
+ #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS)
2999
+ /* if not using PSK, verify peer with certs
3000
+ if using PSK Plus then verify peer certs except PSK suites */
3001
+ if (doCliCertCheck && (usePsk == 0 || usePskPlus) && useAnon == 0) {
3002
+ unsigned int verify_flags = 0;
3003
+ SSL_CTX_set_verify(ctx, WOLFSSL_VERIFY_PEER |
3004
+ (usePskPlus ? WOLFSSL_VERIFY_FAIL_EXCEPT_PSK :
3005
+ WOLFSSL_VERIFY_FAIL_IF_NO_PEER_CERT),
3006
+ (myVerifyAction == VERIFY_OVERRIDE_DATE_ERR ||
3007
+ myVerifyAction == VERIFY_FORCE_FAIL) ? myVerify : NULL);
3008
+
3009
+ #ifdef TEST_BEFORE_DATE
3010
+ verify_flags |= WOLFSSL_LOAD_FLAG_DATE_ERR_OKAY;
3011
+ #endif
3012
+ #if defined(OPENSSL_ALL) && defined(WOLFSSL_CERT_GEN) && \
3013
+ (defined(WOLFSSL_CERT_REQ) || defined(WOLFSSL_CERT_EXT)) && \
3014
+ !defined(NO_FILESYSTEM) && !defined(NO_WOLFSSL_DIR)
3015
+ if (useCertFolder) {
3016
+ WOLFSSL_X509_STORE *store;
3017
+ WOLFSSL_X509_LOOKUP *lookup;
3018
+
3019
+ store = wolfSSL_CTX_get_cert_store(ctx);
3020
+ if (store == NULL) {
3021
+ wolfSSL_CTX_free(ctx); ctx = NULL;
3022
+ err_sys("can't get WOLFSSL_X509_STORE");
3023
+ }
3024
+ lookup = wolfSSL_X509_STORE_add_lookup(store, X509_LOOKUP_hash_dir());
3025
+ if (lookup == NULL) {
3026
+ wolfSSL_CTX_free(ctx); ctx = NULL;
3027
+ err_sys("can't add lookup");
3028
+ }
3029
+ if (wolfSSL_X509_LOOKUP_ctrl(lookup, WOLFSSL_X509_L_ADD_DIR, caCertFolder,
3030
+ X509_FILETYPE_PEM, NULL) != WOLFSSL_SUCCESS) {
3031
+ err_sys("X509_LOOKUP_ctrl w/ L_ADD_DIR failed");
3032
+ }
3033
+ } else {
3034
+ #endif
3035
+ if (wolfSSL_CTX_load_verify_locations_ex(ctx, verifyCert, 0,
3036
+ verify_flags) != WOLFSSL_SUCCESS) {
3037
+ err_sys_ex(catastrophic,
3038
+ "can't load ca file, Please run from wolfSSL home dir");
3039
+ }
3040
+ #ifdef WOLFSSL_TRUST_PEER_CERT
3041
+ if (trustCert) {
3042
+ if (wolfSSL_CTX_trust_peer_cert(ctx, trustCert,
3043
+ WOLFSSL_FILETYPE_PEM) != WOLFSSL_SUCCESS) {
3044
+ err_sys_ex(runWithErrors, "can't load trusted peer cert file");
3045
+ }
3046
+ }
3047
+ #endif /* WOLFSSL_TRUST_PEER_CERT */
3048
+ #if defined(OPENSSL_ALL) && defined(WOLFSSL_CERT_GEN) && \
3049
+ (defined(WOLFSSL_CERT_REQ) || defined(WOLFSSL_CERT_EXT)) && \
3050
+ !defined(NO_FILESYSTEM) && !defined(NO_WOLFSSL_DIR)
3051
+ }
3052
+ #endif
3053
+ }
3054
+ #endif
3055
+
3056
+ #ifdef WOLFSSL_SNIFFER
3057
+ if (cipherList == NULL && version < 4) {
3058
+ /* static RSA or static ECC cipher suites */
3059
+ const char* staticCipherList = "AES128-SHA:ECDH-ECDSA-AES128-SHA";
3060
+ if (SSL_CTX_set_cipher_list(ctx, staticCipherList) != WOLFSSL_SUCCESS) {
3061
+ err_sys_ex(runWithErrors, "server can't set cipher list 3");
3062
+ }
3063
+ }
3064
+ #endif
3065
+
3066
+ #ifdef HAVE_SNI
3067
+ if (sniHostName)
3068
+ if (wolfSSL_CTX_UseSNI(ctx, WOLFSSL_SNI_HOST_NAME, sniHostName,
3069
+ (word16) XSTRLEN(sniHostName)) != WOLFSSL_SUCCESS)
3070
+ err_sys_ex(runWithErrors, "UseSNI failed");
3071
+ #endif
3072
+
3073
+ #ifdef USE_WINDOWS_API
3074
+ if (port == 0) {
3075
+ /* Generate random port for testing */
3076
+ port = GetRandomPort();
3077
+ }
3078
+ #endif /* USE_WINDOWS_API */
3079
+
3080
+ #ifdef WOLFSSL_ASYNC_CRYPT
3081
+ ret = wolfAsync_DevOpen(&devId);
3082
+ if (ret < 0) {
3083
+ LOG_ERROR("Async device open failed\nRunning without async\n");
3084
+ }
3085
+ wolfSSL_CTX_SetDevId(ctx, devId);
3086
+ #endif /* WOLFSSL_ASYNC_CRYPT */
3087
+
3088
+ #ifdef WOLFSSL_TLS13
3089
+ if (noPskDheKe)
3090
+ wolfSSL_CTX_no_dhe_psk(ctx);
3091
+ #ifdef HAVE_SUPPORTED_CURVES
3092
+ if (onlyPskDheKe)
3093
+ wolfSSL_CTX_only_dhe_psk(ctx);
3094
+ #endif
3095
+ #endif
3096
+ #ifdef HAVE_SESSION_TICKET
3097
+ #ifdef WOLFSSL_TLS13
3098
+ if (noTicketTls13)
3099
+ wolfSSL_CTX_no_ticket_TLSv13(ctx);
3100
+ #endif
3101
+ #if !defined(WOLFSSL_NO_TLS12) || !defined(NO_OLD_TLS)
3102
+ if (noTicketTls12)
3103
+ wolfSSL_CTX_NoTicketTLSv12(ctx);
3104
+ #endif
3105
+ #endif
3106
+ #if defined(HAVE_CRL) && !defined(NO_FILESYSTEM)
3107
+ if (!disableCRL) {
3108
+ /* Need to load CA's to confirm CRL signatures */
3109
+ unsigned int verify_flags = 0;
3110
+ #ifdef TEST_BEFORE_DATE
3111
+ verify_flags |= WOLFSSL_LOAD_FLAG_DATE_ERR_OKAY;
3112
+ #endif
3113
+ if (wolfSSL_CTX_load_verify_locations_ex(ctx, verifyCert, 0,
3114
+ verify_flags) != WOLFSSL_SUCCESS) {
3115
+ err_sys_ex(catastrophic,
3116
+ "can't load ca file, Please run from wolfSSL home dir");
3117
+ }
3118
+ #ifdef HAVE_CRL_MONITOR
3119
+ crlFlags = WOLFSSL_CRL_MONITOR | WOLFSSL_CRL_START_MON;
3120
+ #endif
3121
+ if (wolfSSL_CTX_EnableCRL(ctx, 0) != WOLFSSL_SUCCESS)
3122
+ err_sys_ex(runWithErrors, "unable to enable CRL");
3123
+ if (wolfSSL_CTX_LoadCRL(ctx, crlDir != NULL ? crlDir : crlPemDir,
3124
+ WOLFSSL_FILETYPE_PEM, crlFlags) != WOLFSSL_SUCCESS)
3125
+ err_sys_ex(runWithErrors, "unable to load CRL");
3126
+ if (wolfSSL_CTX_SetCRL_Cb(ctx, CRL_CallBack) != WOLFSSL_SUCCESS)
3127
+ err_sys_ex(runWithErrors, "unable to set CRL callback url");
3128
+ }
3129
+ #endif
3130
+
3131
+
3132
+ while (1) {
3133
+ /* allow resume option */
3134
+ if (resumeCount > 1) {
3135
+ if (dtlsUDP == 0) {
3136
+ client_len = sizeof client_addr;
3137
+ clientfd = accept(sockfd, (struct sockaddr*)&client_addr,
3138
+ (ACCEPT_THIRD_T)&client_len);
3139
+ }
3140
+ else {
3141
+ tcp_listen(&sockfd, &port, useAnyAddr, dtlsUDP, dtlsSCTP);
3142
+ clientfd = sockfd;
3143
+ }
3144
+ if (WOLFSSL_SOCKET_IS_INVALID(clientfd)) {
3145
+ err_sys_ex(runWithErrors, "tcp accept failed");
3146
+ }
3147
+ }
3148
+ #if defined(WOLFSSL_STATIC_MEMORY) && defined(DEBUG_WOLFSSL) && \
3149
+ !defined(WOLFSSL_STATIC_MEMORY_LEAN)
3150
+ LOG_ERROR("Before creating SSL\n");
3151
+ if (wolfSSL_CTX_is_static_memory(ctx, &mem_stats) != 1)
3152
+ err_sys_ex(runWithErrors, "ctx not using static memory");
3153
+ if (wolfSSL_PrintStats(&mem_stats) != 1) /* function in test.h */
3154
+ err_sys_ex(runWithErrors, "error printing out memory stats");
3155
+ #endif
3156
+
3157
+ if (doMcast) {
3158
+ #ifdef WOLFSSL_MULTICAST
3159
+ wolfSSL_CTX_mcast_set_member_id(ctx, mcastID);
3160
+ if (wolfSSL_CTX_set_cipher_list(ctx, "WDM-NULL-SHA256")
3161
+ != WOLFSSL_SUCCESS)
3162
+ err_sys("Couldn't set multicast cipher list.");
3163
+ #endif
3164
+ }
3165
+
3166
+ if (doDTLS && dtlsUDP) {
3167
+ #if defined(WOLFSSL_DTLS) && defined(USE_WOLFSSL_IO)
3168
+ if (doBlockSeq) {
3169
+ wolfSSL_CTX_SetIOSend(ctx, TestEmbedSendTo);
3170
+ }
3171
+ #endif
3172
+ }
3173
+
3174
+ #ifdef HAVE_PK_CALLBACKS
3175
+ if (pkCallbacks)
3176
+ SetupPkCallbacks(ctx);
3177
+ #endif
3178
+
3179
+ ssl = SSL_new(ctx);
3180
+ if (ssl == NULL)
3181
+ err_sys_ex(catastrophic, "unable to create an SSL object");
3182
+
3183
+ #if defined(OPENSSL_EXTRA) || defined(HAVE_SECRET_CALLBACK)
3184
+ wolfSSL_KeepArrays(ssl);
3185
+ #endif
3186
+
3187
+ /* Support for loading private key and cert using WOLFSSL object */
3188
+ #if !defined(NO_CERTS)
3189
+ if ((!usePsk || usePskPlus) && !useAnon && loadCertKeyIntoSSLObj) {
3190
+ #if defined(NO_FILESYSTEM) && defined(USE_CERT_BUFFERS_2048)
3191
+ if (wolfSSL_use_certificate_chain_buffer_format(ssl,
3192
+ server_cert_der_2048, sizeof_server_cert_der_2048,
3193
+ WOLFSSL_FILETYPE_ASN1) != WOLFSSL_SUCCESS)
3194
+ err_sys_ex(catastrophic, "can't load server cert buffer");
3195
+ #elif !defined(TEST_LOAD_BUFFER)
3196
+ if (SSL_use_certificate_chain_file(ssl, ourCert)
3197
+ != WOLFSSL_SUCCESS)
3198
+ err_sys_ex(catastrophic, "can't load server cert file, check file "
3199
+ "and run from wolfSSL home dir");
3200
+ #else
3201
+ /* loads cert chain file using buffer API */
3202
+ load_ssl_buffer(ssl, ourCert, WOLFSSL_CERT_CHAIN);
3203
+ #endif
3204
+ }
3205
+
3206
+ if ((!usePsk || usePskPlus) && !useAnon &&
3207
+ loadCertKeyIntoSSLObj
3208
+ #if defined(HAVE_PK_CALLBACKS) && defined(TEST_PK_PRIVKEY)
3209
+ && !pkCallbacks
3210
+ #endif /* HAVE_PK_CALLBACKS && TEST_PK_PRIVKEY */
3211
+ ) {
3212
+ #if defined(NO_FILESYSTEM)
3213
+ if (wolfSSL_use_PrivateKey_buffer(ssl, server_key_der_2048,
3214
+ sizeof_server_key_der_2048, SSL_FILETYPE_ASN1) != WOLFSSL_SUCCESS)
3215
+ err_sys_ex(catastrophic, "can't load server private key buffer");
3216
+ #elif !defined(TEST_LOAD_BUFFER)
3217
+ if (SSL_use_PrivateKey_file(ssl, ourKey, WOLFSSL_FILETYPE_PEM)
3218
+ != WOLFSSL_SUCCESS)
3219
+ err_sys_ex(catastrophic, "can't load server private key file, check"
3220
+ "file and run from wolfSSL home dir");
3221
+ #else
3222
+ /* loads private key file using buffer API */
3223
+ load_ssl_buffer(ssl, ourKey, WOLFSSL_KEY);
3224
+ #endif
3225
+ }
3226
+ #endif /* !NO_CERTS */
3227
+
3228
+ #ifdef WOLFSSL_SEND_HRR_COOKIE
3229
+ if (hrrCookie == 1 && wolfSSL_send_hrr_cookie(ssl, NULL, 0)
3230
+ != WOLFSSL_SUCCESS) {
3231
+ err_sys("unable to set use of cookie with HRR msg");
3232
+ }
3233
+ else if (hrrCookie == -1) {
3234
+ wolfSSL_disable_hrr_cookie(ssl);
3235
+ }
3236
+ #endif
3237
+
3238
+ #if defined(WOLFSSL_STATIC_MEMORY) && defined(DEBUG_WOLFSSL) && \
3239
+ !defined(WOLFSSL_STATIC_MEMORY_LEAN)
3240
+ LOG_ERROR("After creating SSL\n");
3241
+ if (wolfSSL_CTX_is_static_memory(ctx, &mem_stats) != 1)
3242
+ err_sys_ex(runWithErrors, "ctx not using static memory");
3243
+ if (wolfSSL_PrintStats(&mem_stats) != 1) /* function in test.h */
3244
+ err_sys_ex(runWithErrors, "error printing out memory stats");
3245
+ #endif
3246
+
3247
+ if (doMcast) {
3248
+ #ifdef WOLFSSL_MULTICAST
3249
+ /* DTLS multicast secret for testing only */
3250
+ #define CLI_SRV_RANDOM_SZ 32 /* RAN_LEN (see internal.h) */
3251
+ #define PMS_SZ 512 /* ENCRYPT_LEN (see internal.h) */
3252
+ byte pms[PMS_SZ]; /* pre master secret */
3253
+ byte cr[CLI_SRV_RANDOM_SZ]; /* client random */
3254
+ byte sr[CLI_SRV_RANDOM_SZ]; /* server random */
3255
+ const byte suite[2] = {0, 0xfe}; /* WDM_WITH_NULL_SHA256 */
3256
+
3257
+ XMEMSET(pms, 0x23, sizeof(pms));
3258
+ XMEMSET(cr, 0xA5, sizeof(cr));
3259
+ XMEMSET(sr, 0x5A, sizeof(sr));
3260
+
3261
+ if (wolfSSL_set_secret(ssl, 1, pms, sizeof(pms), cr, sr, suite)
3262
+ != WOLFSSL_SUCCESS) {
3263
+ err_sys("unable to set mcast secret");
3264
+ }
3265
+ #endif
3266
+ }
3267
+
3268
+ #ifdef HAVE_SECURE_RENEGOTIATION
3269
+ if (scr) {
3270
+ if (wolfSSL_UseSecureRenegotiation(ssl) != WOLFSSL_SUCCESS) {
3271
+ err_sys_ex(runWithErrors, "can't enable secure renegotiation");
3272
+ }
3273
+ }
3274
+ #endif /* HAVE_SECURE_RENEGOTIATION */
3275
+
3276
+ #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS)
3277
+ #if defined(WOLFSSL_TLS13) && defined(WOLFSSL_POST_HANDSHAKE_AUTH)
3278
+ if (postHandAuth) {
3279
+ unsigned int verify_flags = 0;
3280
+
3281
+ #ifdef TEST_BEFORE_DATE
3282
+ verify_flags |= WOLFSSL_LOAD_FLAG_DATE_ERR_OKAY;
3283
+ #endif
3284
+
3285
+ if (wolfSSL_CTX_load_verify_locations_ex(ctx, verifyCert, 0,
3286
+ verify_flags)
3287
+ != WOLFSSL_SUCCESS) {
3288
+ err_sys_ex(runWithErrors, "can't load ca file, Please run from "
3289
+ "wolfSSL home dir");
3290
+ }
3291
+ #ifdef WOLFSSL_TRUST_PEER_CERT
3292
+ if (trustCert) {
3293
+ if (wolfSSL_trust_peer_cert(ssl, trustCert,
3294
+ WOLFSSL_FILETYPE_PEM) != WOLFSSL_SUCCESS) {
3295
+ err_sys_ex(runWithErrors, "can't load trusted peer cert "
3296
+ "file");
3297
+ }
3298
+ }
3299
+ #endif /* WOLFSSL_TRUST_PEER_CERT */
3300
+ }
3301
+ #endif
3302
+ #endif
3303
+
3304
+
3305
+ #ifndef NO_HANDSHAKE_DONE_CB
3306
+ wolfSSL_SetHsDoneCb(ssl, myHsDoneCb, NULL);
3307
+ #endif
3308
+ #ifdef HAVE_OCSP
3309
+ if (useOcsp) {
3310
+ if (ocspUrl != NULL) {
3311
+ wolfSSL_CTX_SetOCSP_OverrideURL(ctx, ocspUrl);
3312
+ wolfSSL_CTX_EnableOCSP(ctx, WOLFSSL_OCSP_NO_NONCE
3313
+ | WOLFSSL_OCSP_URL_OVERRIDE);
3314
+ }
3315
+ else
3316
+ wolfSSL_CTX_EnableOCSP(ctx, WOLFSSL_OCSP_NO_NONCE);
3317
+ }
3318
+ #ifndef NO_RSA
3319
+ /* All the OCSP Stapling test certs are RSA. */
3320
+ #if !defined(NO_FILESYSTEM) && (\
3321
+ defined(HAVE_CERTIFICATE_STATUS_REQUEST) \
3322
+ || defined(HAVE_CERTIFICATE_STATUS_REQUEST_V2))
3323
+ { /* scope start */
3324
+ const char* ca1 = "certs/ocsp/intermediate1-ca-cert.pem";
3325
+ const char* ca2 = "certs/ocsp/intermediate2-ca-cert.pem";
3326
+ const char* ca3 = "certs/ocsp/intermediate3-ca-cert.pem";
3327
+ int fails = 0;
3328
+
3329
+ if (wolfSSL_CTX_EnableOCSPStapling(ctx) != WOLFSSL_SUCCESS) {
3330
+ err_sys_ex(catastrophic, "can't enable OCSP Stapling "
3331
+ "Certificate Manager");
3332
+ }
3333
+ if (SSL_CTX_load_verify_locations(ctx, ca1, 0) != WOLFSSL_SUCCESS) {
3334
+ fails++;
3335
+ err_sys_ex(runWithErrors, "can't load ca file, Please run from "
3336
+ "wolfSSL home dir");
3337
+ }
3338
+ if (SSL_CTX_load_verify_locations(ctx, ca2, 0) != WOLFSSL_SUCCESS) {
3339
+ fails++;
3340
+ err_sys_ex(runWithErrors, "can't load ca file, Please run from "
3341
+ "wolfSSL home dir");
3342
+ }
3343
+ if (SSL_CTX_load_verify_locations(ctx, ca3, 0) != WOLFSSL_SUCCESS) {
3344
+ fails++;
3345
+ err_sys_ex(runWithErrors, "can't load ca file, Please run from "
3346
+ "wolfSSL home dir");
3347
+ }
3348
+ if (fails > 2) {
3349
+ err_sys_ex(catastrophic, "Failed to load any intermediates for "
3350
+ "OCSP stapling test");
3351
+ }
3352
+ } /* scope end */
3353
+ #endif /* HAVE_CERTIFICATE_STATUS_REQUEST HAVE_CERTIFICATE_STATUS_REQUEST_V2 */
3354
+ #endif /* NO_RSA */
3355
+ #endif /* HAVE_OCSP */
3356
+
3357
+ #ifdef HAVE_PK_CALLBACKS
3358
+ /* This must be before SetKeyShare */
3359
+ if (pkCallbacks) {
3360
+ SetupPkCallbackContexts(ssl, &pkCbInfo);
3361
+ }
3362
+ #endif
3363
+
3364
+ #if defined(WOLFSSL_TLS13) && defined(HAVE_SUPPORTED_CURVES)
3365
+ if (version >= 4 || version == -4) {
3366
+ #ifdef CAN_FORCE_CURVE
3367
+ if (force_curve_group_id > 0) {
3368
+ do {
3369
+ ret = wolfSSL_UseKeyShare(ssl, (word16)force_curve_group_id);
3370
+ if (ret == WOLFSSL_SUCCESS) {
3371
+
3372
+ }
3373
+ #ifdef WOLFSSL_ASYNC_CRYPT
3374
+ else if (ret == WC_NO_ERR_TRACE(WC_PENDING_E)) {
3375
+ wolfSSL_AsyncPoll(ssl, WOLF_POLL_FLAG_CHECK_HW);
3376
+ }
3377
+ #endif
3378
+ else {
3379
+ err_sys("Failed wolfSSL_UseKeyShare in force-curve");
3380
+ }
3381
+ } while (ret == WC_NO_ERR_TRACE(WC_PENDING_E));
3382
+ ret = wolfSSL_set_groups(ssl, &force_curve_group_id, 1);
3383
+ if (WOLFSSL_SUCCESS != ret) {
3384
+ err_sys("Failed wolfSSL_set_groups in force-curve");
3385
+ }
3386
+ }
3387
+ else
3388
+ #endif
3389
+ SetKeyShare(ssl, onlyKeyShare, useX25519, useX448, usePqc,
3390
+ pqcAlg);
3391
+ }
3392
+ #endif
3393
+
3394
+ #ifdef HAVE_ENCRYPT_THEN_MAC
3395
+ if (disallowETM)
3396
+ wolfSSL_AllowEncryptThenMac(ssl, 0);
3397
+ #endif
3398
+
3399
+
3400
+ /* do accept */
3401
+ readySignal = ((func_args*)args)->signal;
3402
+ if (readySignal) {
3403
+ readySignal->srfName = serverReadyFile;
3404
+ }
3405
+
3406
+ client_len = sizeof client_addr;
3407
+ tcp_accept(&sockfd, &clientfd, (func_args*)args, port, useAnyAddr,
3408
+ dtlsUDP, dtlsSCTP, serverReadyFile ? 1 : 0, doListen,
3409
+ &client_addr, &client_len);
3410
+
3411
+ doListen = 0; /* Don't listen next time */
3412
+
3413
+ if (port == 0) {
3414
+ port = readySignal->port;
3415
+ }
3416
+
3417
+ if (SSL_set_fd(ssl, clientfd) != WOLFSSL_SUCCESS) {
3418
+ err_sys_ex(catastrophic, "error in setting fd");
3419
+ }
3420
+
3421
+ #ifdef HAVE_TRUSTED_CA
3422
+ if (trustedCaKeyId) {
3423
+ if (wolfSSL_UseTrustedCA(ssl, WOLFSSL_TRUSTED_CA_PRE_AGREED,
3424
+ NULL, 0) != WOLFSSL_SUCCESS) {
3425
+ err_sys_ex(runWithErrors, "UseTrustedCA failed");
3426
+ }
3427
+ }
3428
+ #endif /* HAVE_TRUSTED_CA */
3429
+
3430
+ #ifdef HAVE_ALPN
3431
+ if (alpnList != NULL) {
3432
+ printf("ALPN accepted protocols list : %s\n", alpnList);
3433
+ wolfSSL_UseALPN(ssl, alpnList, (word32)XSTRLEN(alpnList), alpn_opt);
3434
+ }
3435
+ #endif
3436
+
3437
+ #if defined(WOLFSSL_DTLS) && defined(USE_WOLFSSL_IO)
3438
+ if (doDTLS && dtlsUDP) {
3439
+ byte b[1500];
3440
+ int isClientHello = 0;
3441
+
3442
+ while (!isClientHello) {
3443
+ int n;
3444
+
3445
+ client_len = sizeof client_addr;
3446
+
3447
+ /* For DTLS, peek at the next datagram so we can get the
3448
+ * client's address and set it into the ssl object later to
3449
+ * generate the cookie. */
3450
+ n = (int)recvfrom(clientfd, (char*)b, sizeof(b), MSG_PEEK,
3451
+ (struct sockaddr*)&client_addr, &client_len);
3452
+
3453
+ if (n <= 0)
3454
+ err_sys_ex(runWithErrors, "recvfrom failed");
3455
+
3456
+ /* when doing resumption, it may happen that we receive the
3457
+ alert used to shutdown the first connection as the first
3458
+ packet of the second accept:
3459
+
3460
+ Client | Server
3461
+ | WolfSSL_Shutdown()
3462
+ | <- Alert
3463
+ | recvfrom(peek)
3464
+ WolfSSL_Shutdown() |
3465
+ Alert-> |
3466
+ | wolfSSL_set_dtls_peer()
3467
+
3468
+ but this will set the wrong src port, making the test fail.
3469
+ Discard not-handshake message to avoid this.
3470
+ */
3471
+ if (b[0] != 0x16) {
3472
+ /* discard the packet */
3473
+ n = (int)recvfrom(clientfd, (char *)b, sizeof(b), 0,
3474
+ (struct sockaddr *)&client_addr, &client_len);
3475
+
3476
+ if (n <= 0)
3477
+ err_sys_ex(runWithErrors, "recvfrom failed");
3478
+ }
3479
+ else {
3480
+ isClientHello = 1;
3481
+ }
3482
+ }
3483
+
3484
+ if (doBlockSeq) {
3485
+ XMEMCPY(&dtlsCtx.peer.sa, &client_addr, client_len);
3486
+ dtlsCtx.peer.sz = client_len;
3487
+ dtlsCtx.wfd = clientfd;
3488
+ dtlsCtx.failOnce = 1;
3489
+
3490
+ wolfSSL_SetIOWriteCtx(ssl, &dtlsCtx);
3491
+ }
3492
+ else {
3493
+ wolfSSL_dtls_set_peer(ssl, &client_addr, client_len);
3494
+ }
3495
+ if (simulateWantWrite) {
3496
+ #ifdef USE_WOLFSSL_IO
3497
+ /* connect on a udp to associate peer with this fd to make it
3498
+ * simpler for SimulateWantWriteIOSendCb */
3499
+ if (connect(clientfd, (struct sockaddr*)&client_addr,
3500
+ client_len) != 0) {
3501
+ err_sys_ex(catastrophic, "error in connecting to peer");
3502
+ }
3503
+ wolfSSL_SetIOWriteCtx(ssl, (void*)&sockfd);
3504
+ #endif
3505
+ }
3506
+ }
3507
+ #endif
3508
+
3509
+ #ifdef WOLFSSL_WOLFSENTRY_HOOKS
3510
+ {
3511
+ SOCKADDR_IN_T local_addr;
3512
+ socklen_t local_len = sizeof(local_addr);
3513
+ getsockname(clientfd, (struct sockaddr *)&local_addr,
3514
+ (socklen_t *)&local_len);
3515
+
3516
+ if (((struct sockaddr *)&client_addr)->sa_family !=
3517
+ ((struct sockaddr *)&local_addr)->sa_family)
3518
+ err_sys_ex(catastrophic,
3519
+ "client_addr.sa_family != local_addr.sa_family");
3520
+
3521
+ if (wolfsentry_store_endpoints(
3522
+ ssl, &client_addr, &local_addr,
3523
+ dtlsUDP ? IPPROTO_UDP : IPPROTO_TCP,
3524
+ WOLFSENTRY_ROUTE_FLAG_DIRECTION_IN, NULL) != WOLFSSL_SUCCESS)
3525
+ err_sys_ex(catastrophic,
3526
+ "error in wolfsentry_store_endpoints()");
3527
+ }
3528
+ #endif /* WOLFSSL_WOLFSENTRY_HOOKS */
3529
+
3530
+ if ((usePsk == 0 || usePskPlus) || useAnon == 1 || cipherList != NULL
3531
+ || needDH == 1) {
3532
+ #if !defined(NO_FILESYSTEM) && !defined(NO_DH) && !defined(NO_ASN)
3533
+ wolfSSL_SetTmpDH_file(ssl, ourDhParam, WOLFSSL_FILETYPE_PEM);
3534
+ #elif !defined(NO_DH)
3535
+ SetDH(ssl); /* repick suites with DHE, higher priority than
3536
+ * PSK */
3537
+ #endif
3538
+ #if !defined(NO_DH) && !defined(WOLFSSL_OLD_PRIME_CHECK) && \
3539
+ !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST)
3540
+ if (!doDhKeyCheck)
3541
+ wolfSSL_SetEnableDhKeyTest(ssl, 0);
3542
+ #endif
3543
+ }
3544
+
3545
+ #ifdef WOLFSSL_DTLS_CID
3546
+ if (useDtlsCID) {
3547
+ ret = wolfSSL_dtls_cid_use(ssl);
3548
+ if (ret != WOLFSSL_SUCCESS)
3549
+ err_sys("Can't enable DTLS ConnectionID");
3550
+ ret = wolfSSL_dtls_cid_set(ssl, (byte*)dtlsCID,
3551
+ (word32)XSTRLEN(dtlsCID));
3552
+ if (ret != WOLFSSL_SUCCESS)
3553
+ err_sys("Can't set DTLS ConnectionID");
3554
+ }
3555
+ #endif /* WOLFSSL_DTLS_CID */
3556
+
3557
+ #ifdef WOLFSSL_DTLS_CH_FRAG
3558
+ if (doDTLS)
3559
+ wolfSSL_dtls13_allow_ch_frag(ssl, 1);
3560
+ #endif
3561
+
3562
+ #ifndef WOLFSSL_CALLBACKS
3563
+ if (nonBlocking) {
3564
+ #ifdef WOLFSSL_DTLS
3565
+ if (doDTLS) {
3566
+ wolfSSL_dtls_set_using_nonblock(ssl, 1);
3567
+ }
3568
+ #endif
3569
+ tcp_set_nonblocking(&clientfd);
3570
+
3571
+ ret = NonBlockingSSL_Accept(ssl);
3572
+ }
3573
+ else {
3574
+ #ifdef WOLFSSL_EARLY_DATA
3575
+ if (earlyData) {
3576
+ do {
3577
+ int len;
3578
+ err = 0; /* reset error */
3579
+ ret = wolfSSL_read_early_data(ssl, input, sizeof(input)-1,
3580
+ &len);
3581
+ if (ret <= 0) {
3582
+ err = SSL_get_error(ssl, 0);
3583
+ #ifdef WOLFSSL_ASYNC_CRYPT
3584
+ if (err == WC_NO_ERR_TRACE(WC_PENDING_E)) {
3585
+ /* returns the number of polled items or <0 for
3586
+ * error */
3587
+ ret = wolfSSL_AsyncPoll(ssl,
3588
+ WOLF_POLL_FLAG_CHECK_HW);
3589
+ if (ret < 0) break;
3590
+ }
3591
+ #endif
3592
+ }
3593
+ else if (ret > 0) {
3594
+ input[ret] = 0; /* null terminate message */
3595
+ printf("Early Data Client message: %s\n", input);
3596
+ }
3597
+ } while (err == WC_NO_ERR_TRACE(WC_PENDING_E) || ret > 0);
3598
+ }
3599
+ #endif
3600
+ WOLFSSL_ASYNC_WHILE_PENDING(ret = SSL_accept(ssl),
3601
+ ret != WOLFSSL_SUCCESS);
3602
+ }
3603
+ #else
3604
+ if (nonBlocking) {
3605
+ #ifdef WOLFSSL_DTLS
3606
+ if (doDTLS) {
3607
+ wolfSSL_dtls_set_using_nonblock(ssl, 1);
3608
+ }
3609
+ #endif
3610
+ tcp_set_nonblocking(&clientfd);
3611
+ }
3612
+ ret = NonBlockingSSL_Accept(ssl);
3613
+ #endif
3614
+ #ifdef WOLFSSL_EARLY_DATA
3615
+ EarlyDataStatus(ssl);
3616
+ #endif
3617
+ if (ret != WOLFSSL_SUCCESS) {
3618
+ err = SSL_get_error(ssl, 0);
3619
+ LOG_ERROR("SSL_accept error %d, %s\n", err,
3620
+ ERR_error_string((unsigned long)err, buffer));
3621
+ if (!exitWithRet) {
3622
+ err_sys_ex(runWithErrors, "SSL_accept failed");
3623
+ } else {
3624
+ /* cleanup */
3625
+ SSL_free(ssl); ssl = NULL;
3626
+ SSL_CTX_free(ctx); ctx = NULL;
3627
+ CloseSocket(clientfd);
3628
+ CloseSocket(sockfd);
3629
+ ((func_args*)args)->return_code = err;
3630
+ goto exit;
3631
+ }
3632
+ }
3633
+
3634
+ showPeerEx(ssl, lng_index);
3635
+ if (SSL_state(ssl) != 0) {
3636
+ err_sys_ex(runWithErrors, "SSL in error state");
3637
+ }
3638
+
3639
+ /* if the caller requested a particular cipher, check here that either
3640
+ * a canonical name of the established cipher matches the requested
3641
+ * cipher name, or the requested cipher name is marked as an alias
3642
+ * that matches the established cipher.
3643
+ */
3644
+ if (cipherList && !useDefCipherList && (! XSTRSTR(cipherList, ":"))) {
3645
+ WOLFSSL_CIPHER* established_cipher = wolfSSL_get_current_cipher(ssl);
3646
+ byte requested_cipherSuite0, requested_cipherSuite;
3647
+ int requested_cipherFlags;
3648
+ if (established_cipher &&
3649
+ /* don't test for pseudo-ciphers like "ALL" and "DEFAULT". */
3650
+ (wolfSSL_get_cipher_suite_from_name(cipherList,
3651
+ &requested_cipherSuite0,
3652
+ &requested_cipherSuite,
3653
+ &requested_cipherFlags) == 0)) {
3654
+ word32 established_cipher_id = wolfSSL_CIPHER_get_id(established_cipher);
3655
+ byte established_cipherSuite0 = (established_cipher_id >> 8) & 0xff;
3656
+ byte established_cipherSuite = established_cipher_id & 0xff;
3657
+ const char *established_cipher_name =
3658
+ wolfSSL_get_cipher_name_from_suite(established_cipherSuite0,
3659
+ established_cipherSuite);
3660
+ const char *established_cipher_name_iana =
3661
+ wolfSSL_get_cipher_name_iana_from_suite(established_cipherSuite0,
3662
+ established_cipherSuite);
3663
+
3664
+ if (established_cipher_name == NULL)
3665
+ err_sys_ex(catastrophic, "error looking up name of established cipher");
3666
+
3667
+ if (strcmp(cipherList, established_cipher_name) &&
3668
+ ((established_cipher_name_iana == NULL) ||
3669
+ strcmp(cipherList, established_cipher_name_iana))) {
3670
+ if (! (requested_cipherFlags & WOLFSSL_CIPHER_SUITE_FLAG_NAMEALIAS))
3671
+ err_sys_ex(
3672
+ catastrophic,
3673
+ "Unexpected mismatch between names of requested and established ciphers.");
3674
+ else if ((requested_cipherSuite0 != established_cipherSuite0) ||
3675
+ (requested_cipherSuite != established_cipherSuite))
3676
+ err_sys_ex(
3677
+ catastrophic,
3678
+ "Mismatch between IDs of requested and established ciphers.");
3679
+ }
3680
+ }
3681
+ }
3682
+
3683
+ #if defined(OPENSSL_EXTRA) || defined(HAVE_SECRET_CALLBACK)
3684
+ {
3685
+ byte* rnd = NULL;
3686
+ size_t size;
3687
+
3688
+ /* get size of buffer then print */
3689
+ size = wolfSSL_get_server_random(NULL, NULL, 0);
3690
+ if (size == 0) {
3691
+ err_sys_ex(runWithErrors, "error getting server random buffer "
3692
+ "size");
3693
+ }
3694
+ else {
3695
+ rnd = (byte*)XMALLOC(size, NULL, DYNAMIC_TYPE_TMP_BUFFER);
3696
+ }
3697
+
3698
+ if (rnd == NULL) {
3699
+ err_sys_ex(runWithErrors, "error creating server random buffer");
3700
+ }
3701
+
3702
+ size = wolfSSL_get_server_random(ssl, rnd, size);
3703
+ if (size == 0) {
3704
+ XFREE(rnd, NULL, DYNAMIC_TYPE_TMP_BUFFER);
3705
+ rnd = NULL;
3706
+ err_sys_ex(runWithErrors, "error getting server random buffer");
3707
+ }
3708
+
3709
+ if (rnd) {
3710
+ byte* pt;
3711
+ printf("Server Random : ");
3712
+ for (pt = rnd; pt < rnd + size; pt++) printf("%02X", *pt);
3713
+ printf("\n");
3714
+
3715
+ XFREE(rnd, NULL, DYNAMIC_TYPE_TMP_BUFFER);
3716
+ rnd = NULL;
3717
+ }
3718
+ }
3719
+ #endif
3720
+
3721
+ #ifdef WOLFSSL_SRTP
3722
+ if (dtlsSrtpProfiles != NULL) {
3723
+ err = server_srtp_test(ssl, (func_args*)args);
3724
+ if (err != 0) {
3725
+ if (exitWithRet) {
3726
+ ((func_args*)args)->return_code = err;
3727
+ wolfSSL_free(ssl); ssl = NULL;
3728
+ wolfSSL_CTX_free(ctx); ctx = NULL;
3729
+ goto exit;
3730
+ }
3731
+ /* else */
3732
+ err_sys("SRTP check failed");
3733
+ }
3734
+ }
3735
+ #endif /* WOLFSSL_SRTP */
3736
+
3737
+ #ifdef WOLFSSL_DTLS_CID
3738
+ if (useDtlsCID && wolfSSL_dtls_cid_is_enabled(ssl)) {
3739
+ byte receivedCID[DTLS_CID_BUFFER_SIZE];
3740
+ unsigned int receivedCIDSz;
3741
+ printf("CID extension was negotiated\n");
3742
+ ret = wolfSSL_dtls_cid_get_tx_size(ssl, &receivedCIDSz);
3743
+ if (ret == WOLFSSL_SUCCESS && receivedCIDSz > 0) {
3744
+ ret = wolfSSL_dtls_cid_get_tx(ssl, receivedCID,
3745
+ DTLS_CID_BUFFER_SIZE - 1);
3746
+ if (ret != WOLFSSL_SUCCESS)
3747
+ err_sys("Can't get negotiated DTLS CID\n");
3748
+
3749
+ printf("Sending CID is ");
3750
+ printBuffer(receivedCID, receivedCIDSz);
3751
+ printf("\n");
3752
+ }
3753
+ else {
3754
+ printf("other peer provided empty CID\n");
3755
+ }
3756
+ }
3757
+ #endif
3758
+
3759
+ #ifdef HAVE_ALPN
3760
+ if (alpnList != NULL) {
3761
+ char *protocol_name = NULL, *list = NULL;
3762
+ word16 protocol_nameSz = 0, listSz = 0;
3763
+
3764
+ err = wolfSSL_ALPN_GetProtocol(ssl, &protocol_name,
3765
+ &protocol_nameSz);
3766
+ if (err == WOLFSSL_SUCCESS)
3767
+ printf("Sent ALPN protocol : %s (%d)\n",
3768
+ protocol_name, protocol_nameSz);
3769
+ else if (err == WC_NO_ERR_TRACE(WOLFSSL_ALPN_NOT_FOUND))
3770
+ printf("No ALPN response sent (no match)\n");
3771
+ else
3772
+ printf("Getting ALPN protocol name failed\n");
3773
+
3774
+ err = wolfSSL_ALPN_GetPeerProtocol(ssl, &list, &listSz);
3775
+ if (err == WOLFSSL_SUCCESS)
3776
+ printf("List of protocol names sent by Client: %s (%d)\n",
3777
+ list, listSz);
3778
+ else
3779
+ printf("Get list of client's protocol name failed\n");
3780
+
3781
+ (void)wolfSSL_ALPN_FreePeerProtocol(ssl, &list);
3782
+ }
3783
+ #endif
3784
+
3785
+ if (echoData == 0 && throughput == 0) {
3786
+ ServerRead(ssl, input, sizeof(input)-1);
3787
+ err = SSL_get_error(ssl, 0);
3788
+ }
3789
+
3790
+ #if defined(HAVE_SECURE_RENEGOTIATION) && \
3791
+ defined(HAVE_SERVER_RENEGOTIATION_INFO)
3792
+ if (scr && forceScr) {
3793
+ if (nonBlocking) {
3794
+ if (wolfSSL_Rehandshake(ssl) != WOLFSSL_SUCCESS) {
3795
+ err = wolfSSL_get_error(ssl, 0);
3796
+ if (err == WOLFSSL_ERROR_WANT_READ ||
3797
+ err == WOLFSSL_ERROR_WANT_WRITE) {
3798
+ do {
3799
+ #ifdef WOLFSSL_ASYNC_CRYPT
3800
+ if (err == WC_NO_ERR_TRACE(WC_PENDING_E)) {
3801
+ ret = wolfSSL_AsyncPoll(ssl, WOLF_POLL_FLAG_CHECK_HW);
3802
+ if (ret < 0) break;
3803
+ }
3804
+ #endif
3805
+ if (err == WC_NO_ERR_TRACE(APP_DATA_READY)) {
3806
+ if (wolfSSL_read(ssl, input, sizeof(input)-1) < 0) {
3807
+ err_sys("APP DATA should be present but error returned");
3808
+ }
3809
+ printf("Received message: %s\n", input);
3810
+ }
3811
+ err = 0;
3812
+ if ((ret = wolfSSL_accept(ssl)) != WOLFSSL_SUCCESS) {
3813
+ err = wolfSSL_get_error(ssl, ret);
3814
+ }
3815
+ } while (ret != WOLFSSL_SUCCESS &&
3816
+ (err == WOLFSSL_ERROR_WANT_READ ||
3817
+ err == WOLFSSL_ERROR_WANT_WRITE ||
3818
+ err == WC_NO_ERR_TRACE(APP_DATA_READY) ||
3819
+ err == WC_NO_ERR_TRACE(WC_PENDING_E)));
3820
+
3821
+ if (ret == WOLFSSL_SUCCESS) {
3822
+ printf("NON-BLOCKING RENEGOTIATION SUCCESSFUL\n");
3823
+ err = 0;
3824
+ }
3825
+ }
3826
+ if (ret != WOLFSSL_SUCCESS) {
3827
+ err = wolfSSL_get_error(ssl, 0);
3828
+ LOG_ERROR(
3829
+ "wolfSSL_Rehandshake error %d, %s\n", err,
3830
+ wolfSSL_ERR_error_string(err, buffer));
3831
+ wolfSSL_free(ssl); ssl = NULL;
3832
+ wolfSSL_CTX_free(ctx); ctx = NULL;
3833
+ err_sys("non-blocking wolfSSL_Rehandshake failed");
3834
+ }
3835
+ }
3836
+ } else {
3837
+ if (wolfSSL_Rehandshake(ssl) != WOLFSSL_SUCCESS) {
3838
+ #ifdef WOLFSSL_ASYNC_CRYPT
3839
+ err = wolfSSL_get_error(ssl, 0);
3840
+ while (err == WC_NO_ERR_TRACE(WC_PENDING_E)) {
3841
+ err = 0;
3842
+ ret = wolfSSL_negotiate(ssl);
3843
+ if (ret != WOLFSSL_SUCCESS) {
3844
+ err = wolfSSL_get_error(ssl, 0);
3845
+ if (err == WC_NO_ERR_TRACE(WC_PENDING_E)) {
3846
+ ret = wolfSSL_AsyncPoll(ssl, WOLF_POLL_FLAG_CHECK_HW);
3847
+ if (ret < 0) break;
3848
+ }
3849
+ }
3850
+ }
3851
+ if (ret != WOLFSSL_SUCCESS)
3852
+ #endif
3853
+ printf("not doing secure renegotiation\n");
3854
+ }
3855
+ else {
3856
+ printf("RENEGOTIATION SUCCESSFUL\n");
3857
+ }
3858
+ }
3859
+ }
3860
+ #endif /* HAVE_SECURE_RENEGOTIATION */
3861
+
3862
+ if (err == 0 && echoData == 0 && throughput == 0) {
3863
+ const char* write_msg;
3864
+ int write_msg_sz;
3865
+
3866
+ #ifdef WOLFSSL_TLS13
3867
+ if (updateKeysIVs)
3868
+ wolfSSL_update_keys(ssl);
3869
+ #endif
3870
+
3871
+ #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS)
3872
+ #if defined(WOLFSSL_TLS13) && defined(WOLFSSL_POST_HANDSHAKE_AUTH)
3873
+ if (postHandAuth) {
3874
+
3875
+ SSL_set_verify(ssl, WOLFSSL_VERIFY_PEER |
3876
+ ((usePskPlus) ? WOLFSSL_VERIFY_FAIL_EXCEPT_PSK :
3877
+ WOLFSSL_VERIFY_FAIL_IF_NO_PEER_CERT), 0);
3878
+
3879
+ if (wolfSSL_request_certificate(ssl) != WOLFSSL_SUCCESS) {
3880
+ LOG_ERROR("Request for post-hs certificate failed\n");
3881
+ }
3882
+ else {
3883
+ LOG_ERROR("Successfully requested post-hs certificate\n");
3884
+ }
3885
+ }
3886
+
3887
+ #endif
3888
+ #endif
3889
+ #if defined(WOLFSSL_TLS13) && defined(HAVE_SESSION_TICKET)
3890
+ if (sendTicket) {
3891
+ if (wolfSSL_send_SessionTicket(ssl) != WOLFSSL_SUCCESS) {
3892
+ LOG_ERROR("Sending new session ticket failed\n");
3893
+ }
3894
+ else {
3895
+ LOG_ERROR("New session ticket sent\n");
3896
+ }
3897
+ }
3898
+ #endif
3899
+
3900
+ /* Write data */
3901
+ if (!useWebServerMsg) {
3902
+ write_msg = kReplyMsg;
3903
+ write_msg_sz = (int)XSTRLEN(kReplyMsg);
3904
+ }
3905
+ else {
3906
+ write_msg = kHttpServerMsg;
3907
+ write_msg_sz = (int)XSTRLEN(kHttpServerMsg);
3908
+ }
3909
+ ServerWrite(ssl, write_msg, write_msg_sz);
3910
+
3911
+ #ifdef WOLFSSL_TLS13
3912
+ if (updateKeysIVs || postHandAuth)
3913
+ ServerRead(ssl, input, sizeof(input)-1);
3914
+ #endif
3915
+ }
3916
+ else if (err == 0 ||
3917
+ err == WOLFSSL_ERROR_ZERO_RETURN)
3918
+ {
3919
+ err = ServerEchoData(ssl, clientfd, echoData, block, throughput);
3920
+ /* Got close notify. Ignore it if not expecting a failure. */
3921
+ if (err == WOLFSSL_ERROR_ZERO_RETURN &&
3922
+ exitWithRet == 0)
3923
+ {
3924
+ err = 0;
3925
+ }
3926
+ if (err != 0) {
3927
+ SSL_free(ssl); ssl = NULL;
3928
+ SSL_CTX_free(ctx); ctx = NULL;
3929
+ CloseSocket(clientfd);
3930
+ CloseSocket(sockfd);
3931
+ ((func_args*)args)->return_code = err;
3932
+ goto exit;
3933
+ }
3934
+ }
3935
+
3936
+ #if defined(WOLFSSL_MDK_SHELL) && defined(HAVE_MDK_RTX)
3937
+ os_dly_wait(500) ;
3938
+ #elif defined (WOLFSSL_TIRTOS)
3939
+ Task_yield();
3940
+ #endif
3941
+
3942
+ #if defined(WOLFSSL_DTLS13)
3943
+ if (wolfSSL_dtls(ssl) && version == -4) {
3944
+ int zero_return = 0;
3945
+ while (wolfSSL_dtls13_has_pending_msg(ssl)) {
3946
+ err =
3947
+ process_handshake_messages(ssl, !nonBlocking, &zero_return);
3948
+ if (err < 0) {
3949
+ /* other peer closes the connection, non fatal */
3950
+ if (zero_return)
3951
+ break;
3952
+
3953
+ err_sys("Error while processing pending DTLSv1.3 messages");
3954
+ }
3955
+ }
3956
+ }
3957
+ #endif /* WOLFSSL_DTLS13 */
3958
+
3959
+ ret = SSL_shutdown(ssl);
3960
+ if (wc_shutdown && ret == WOLFSSL_SHUTDOWN_NOT_DONE) {
3961
+ while (tcp_select(wolfSSL_get_fd(ssl), DEFAULT_TIMEOUT_SEC) ==
3962
+ TEST_RECV_READY) {
3963
+ ret = wolfSSL_shutdown(ssl); /* bidirectional shutdown */
3964
+ if (ret == WOLFSSL_SUCCESS) {
3965
+ printf("Bidirectional shutdown complete\n");
3966
+ break;
3967
+ }
3968
+ else if (ret != WOLFSSL_SHUTDOWN_NOT_DONE) {
3969
+ LOG_ERROR("Bidirectional shutdown failed\n");
3970
+ break;
3971
+ }
3972
+ }
3973
+ if (ret != WOLFSSL_SUCCESS)
3974
+ LOG_ERROR("Bidirectional shutdown failed\n");
3975
+ }
3976
+
3977
+ /* display collected statistics */
3978
+ #if defined(WOLFSSL_STATIC_MEMORY) && !defined(WOLFSSL_STATIC_MEMORY_LEAN)
3979
+ if (wolfSSL_is_static_memory(ssl, &ssl_stats) != 1)
3980
+ err_sys_ex(runWithErrors, "static memory was not used with ssl");
3981
+
3982
+ LOG_ERROR("\nprint off SSL memory stats\n");
3983
+ LOG_ERROR("*** This is memory state before wolfSSL_free is "
3984
+ "called\n");
3985
+ wolfSSL_PrintStatsConn(&ssl_stats);
3986
+
3987
+ #endif
3988
+ SSL_free(ssl); ssl = NULL;
3989
+
3990
+ CloseSocket(clientfd);
3991
+
3992
+ if (resume == 1 && resumeCount == 0) {
3993
+ resumeCount++; /* only do one resume for testing */
3994
+ continue;
3995
+ }
3996
+ resumeCount = 0;
3997
+
3998
+ cnt++;
3999
+ if (loops > 0) {
4000
+ if (--loops == 0) {
4001
+ break; /* out of while loop, done with normal and resume
4002
+ * option
4003
+ */
4004
+ }
4005
+ }
4006
+ } /* while(1) */
4007
+
4008
+ WOLFSSL_TIME(cnt);
4009
+ (void)cnt;
4010
+
4011
+ #if defined(HAVE_CERTIFICATE_STATUS_REQUEST) \
4012
+ || defined(HAVE_CERTIFICATE_STATUS_REQUEST_V2)
4013
+ wolfSSL_CTX_DisableOCSPStapling(ctx);
4014
+ #endif
4015
+
4016
+ CloseSocket(sockfd);
4017
+ SSL_CTX_free(ctx); ctx = NULL;
4018
+
4019
+ ((func_args*)args)->return_code = 0;
4020
+
4021
+ exit:
4022
+
4023
+ #ifdef WOLFSSL_WOLFSENTRY_HOOKS
4024
+ wolfsentry_ret =
4025
+ wolfsentry_shutdown(WOLFSENTRY_CONTEXT_ARGS_OUT_EX4(&wolfsentry, NULL));
4026
+ if (wolfsentry_ret < 0) {
4027
+ LOG_ERROR(
4028
+ "wolfsentry_shutdown() returned " WOLFSENTRY_ERROR_FMT "\n",
4029
+ WOLFSENTRY_ERROR_FMT_ARGS(wolfsentry_ret));
4030
+ }
4031
+ #endif
4032
+
4033
+ #if defined(HAVE_ECC) && defined(FP_ECC) && defined(HAVE_THREAD_LS) \
4034
+ && (defined(NO_MAIN_DRIVER) || defined(HAVE_STACK_SIZE))
4035
+ wc_ecc_fp_free(); /* free per thread cache */
4036
+ #endif
4037
+
4038
+ #ifdef WOLFSSL_TIRTOS
4039
+ fdCloseSession(Task_self());
4040
+ #endif
4041
+
4042
+ #ifdef HAVE_TEST_SESSION_TICKET
4043
+ TicketCleanup();
4044
+ #endif
4045
+
4046
+ #ifdef WOLFSSL_ASYNC_CRYPT
4047
+ wolfAsync_DevClose(&devId);
4048
+ #endif
4049
+
4050
+ /* There are use cases when these assignments are not read. To avoid
4051
+ * potential confusion those warnings have been handled here.
4052
+ */
4053
+ (void) ourKey;
4054
+ (void) verifyCert;
4055
+ (void) doCliCertCheck;
4056
+ (void) ourDhParam;
4057
+ (void) ourCert;
4058
+ (void) useX25519;
4059
+ (void) useX448;
4060
+ #ifdef HAVE_SECURE_RENEGOTIATION
4061
+ (void) forceScr;
4062
+ #endif
4063
+ #if defined(WOLFSSL_CALLBACKS) && defined(WOLFSSL_EARLY_DATA)
4064
+ (void) earlyData;
4065
+ #endif
4066
+ WOLFSSL_RETURN_FROM_THREAD(0);
4067
+ }
4068
+
4069
+ #endif /* !NO_WOLFSSL_SERVER && !NO_TLS */
4070
+
4071
+
4072
+ /* so overall tests can pull in test function */
4073
+ #ifndef NO_MAIN_DRIVER
4074
+
4075
+ int main(int argc, char** argv)
4076
+ {
4077
+ func_args args;
4078
+ tcp_ready ready;
4079
+
4080
+ StartTCP();
4081
+
4082
+ args.argc = argc;
4083
+ args.argv = argv;
4084
+ args.signal = &ready;
4085
+ args.return_code = 0;
4086
+ #if defined(WOLFSSL_SRTP) && defined(WOLFSSL_COND)
4087
+ args.srtp_helper = NULL;
4088
+ #endif
4089
+ InitTcpReady(&ready);
4090
+
4091
+ #if defined(DEBUG_WOLFSSL) && !defined(WOLFSSL_MDK_SHELL)
4092
+ wolfSSL_Debugging_ON();
4093
+ #endif
4094
+ wolfSSL_Init();
4095
+ #ifdef WC_RNG_SEED_CB
4096
+ wc_SetSeed_Cb(WC_GENERATE_SEED_DEFAULT);
4097
+ #endif
4098
+ ChangeToWolfRoot();
4099
+
4100
+ #if !defined(NO_WOLFSSL_SERVER) && !defined(NO_TLS)
4101
+ #ifdef HAVE_STACK_SIZE
4102
+ StackSizeCheck(&args, server_test);
4103
+ #else
4104
+ server_test(&args);
4105
+ #endif
4106
+ #else
4107
+ fprintf(stderr, "Server not compiled in!\n");
4108
+ #endif
4109
+
4110
+ wolfSSL_Cleanup();
4111
+ FreeTcpReady(&ready);
4112
+
4113
+ #ifdef HAVE_WNR
4114
+ if (wc_FreeNetRandom() < 0)
4115
+ err_sys_ex(runWithErrors, "Failed to free netRandom context");
4116
+ #endif /* HAVE_WNR */
4117
+
4118
+ return args.return_code;
4119
+ }
4120
+
4121
+ int myoptind = 0;
4122
+ char* myoptarg = NULL;
4123
+
4124
+ #endif /* NO_MAIN_DRIVER */