cjson
fuzzing
inputs
test1 test10 test11 test2 test3 test3.bu test3.uf test3.uu test4 test5 test6 test7 test8 test9library_config
cJSONConfig.cmake.in cJSONConfigVersion.cmake.in libcjson.pc.in libcjson_utils.pc.in uninstall.cmaketests
inputs
test1 test1.expected test10 test10.expected test11 test11.expected test2 test2.expected test3 test3.expected test4 test4.expected test5 test5.expected test6 test7 test7.expected test8 test8.expected test9 test9.expectedjson-patch-tests
.editorconfig .gitignore .npmignore README.md cjson-utils-tests.json package.json spec_tests.json tests.jsonunity
auto
colour_prompt.rb colour_reporter.rb generate_config.yml generate_module.rb generate_test_runner.rb parse_output.rb stylize_as_junit.rb test_file_filter.rb type_sanitizer.rb unity_test_summary.py unity_test_summary.rb unity_to_junit.pydocs
ThrowTheSwitchCodingStandard.md UnityAssertionsCheatSheetSuitableforPrintingandPossiblyFraming.pdf UnityAssertionsReference.md UnityConfigurationGuide.md UnityGettingStartedGuide.md UnityHelperScriptsGuide.md license.txtexamples
unity_config.hcurl
.github
scripts
cleancmd.pl cmp-config.pl cmp-pkg-config.sh codespell-ignore.words codespell.sh distfiles.sh pyspelling.words pyspelling.yaml randcurl.pl requirements-docs.txt requirements-proselint.txt requirements.txt shellcheck-ci.sh shellcheck.sh spellcheck.curl trimmarkdownheader.pl typos.sh typos.toml verify-examples.pl verify-synopsis.pl yamlcheck.sh yamlcheck.yamlworkflows
appveyor-status.yml checkdocs.yml checksrc.yml checkurls.yml codeql.yml configure-vs-cmake.yml curl-for-win.yml distcheck.yml fuzz.yml http3-linux.yml label.yml linux-old.yml linux.yml macos.yml non-native.yml windows.ymlCMake
CurlSymbolHiding.cmake CurlTests.c FindBrotli.cmake FindCares.cmake FindGSS.cmake FindGnuTLS.cmake FindLDAP.cmake FindLibbacktrace.cmake FindLibgsasl.cmake FindLibidn2.cmake FindLibpsl.cmake FindLibssh.cmake FindLibssh2.cmake FindLibuv.cmake FindMbedTLS.cmake FindNGHTTP2.cmake FindNGHTTP3.cmake FindNGTCP2.cmake FindNettle.cmake FindQuiche.cmake FindRustls.cmake FindWolfSSL.cmake FindZstd.cmake Macros.cmake OtherTests.cmake PickyWarnings.cmake Utilities.cmake cmake_uninstall.in.cmake curl-config.in.cmake unix-cache.cmake win32-cache.cmakedocs
cmdline-opts
.gitignore CMakeLists.txt MANPAGE.md Makefile.am Makefile.inc _AUTHORS.md _BUGS.md _DESCRIPTION.md _ENVIRONMENT.md _EXITCODES.md _FILES.md _GLOBBING.md _NAME.md _OPTIONS.md _OUTPUT.md _PROGRESS.md _PROTOCOLS.md _PROXYPREFIX.md _SEEALSO.md _SYNOPSIS.md _URL.md _VARIABLES.md _VERSION.md _WWW.md abstract-unix-socket.md alt-svc.md anyauth.md append.md aws-sigv4.md basic.md ca-native.md cacert.md capath.md cert-status.md cert-type.md cert.md ciphers.md compressed-ssh.md compressed.md config.md connect-timeout.md connect-to.md continue-at.md cookie-jar.md cookie.md create-dirs.md create-file-mode.md crlf.md crlfile.md curves.md data-ascii.md data-binary.md data-raw.md data-urlencode.md data.md delegation.md digest.md disable-eprt.md disable-epsv.md disable.md disallow-username-in-url.md dns-interface.md dns-ipv4-addr.md dns-ipv6-addr.md dns-servers.md doh-cert-status.md doh-insecure.md doh-url.md dump-ca-embed.md dump-header.md ech.md egd-file.md engine.md etag-compare.md etag-save.md expect100-timeout.md fail-early.md fail-with-body.md fail.md false-start.md follow.md form-escape.md form-string.md form.md ftp-account.md ftp-alternative-to-user.md ftp-create-dirs.md ftp-method.md ftp-pasv.md ftp-port.md ftp-pret.md ftp-skip-pasv-ip.md ftp-ssl-ccc-mode.md ftp-ssl-ccc.md ftp-ssl-control.md get.md globoff.md happy-eyeballs-timeout-ms.md haproxy-clientip.md haproxy-protocol.md head.md header.md help.md hostpubmd5.md hostpubsha256.md hsts.md http0.9.md http1.0.md http1.1.md http2-prior-knowledge.md http2.md http3-only.md http3.md ignore-content-length.md insecure.md interface.md ip-tos.md ipfs-gateway.md ipv4.md ipv6.md json.md junk-session-cookies.md keepalive-cnt.md keepalive-time.md key-type.md key.md knownhosts.md krb.md libcurl.md limit-rate.md list-only.md local-port.md location-trusted.md location.md login-options.md mail-auth.md mail-from.md mail-rcpt-allowfails.md mail-rcpt.md mainpage.idx manual.md max-filesize.md max-redirs.md max-time.md metalink.md mptcp.md negotiate.md netrc-file.md netrc-optional.md netrc.md next.md no-alpn.md no-buffer.md no-clobber.md no-keepalive.md no-npn.md no-progress-meter.md no-sessionid.md noproxy.md ntlm-wb.md ntlm.md oauth2-bearer.md out-null.md output-dir.md output.md parallel-immediate.md parallel-max-host.md parallel-max.md parallel.md pass.md path-as-is.md pinnedpubkey.md post301.md post302.md post303.md preproxy.md progress-bar.md proto-default.md proto-redir.md proto.md proxy-anyauth.md proxy-basic.md proxy-ca-native.md proxy-cacert.md proxy-capath.md proxy-cert-type.md proxy-cert.md proxy-ciphers.md proxy-crlfile.md proxy-digest.md proxy-header.md proxy-http2.md proxy-insecure.md proxy-key-type.md proxy-key.md proxy-negotiate.md proxy-ntlm.md proxy-pass.md proxy-pinnedpubkey.md proxy-service-name.md proxy-ssl-allow-beast.md proxy-ssl-auto-client-cert.md proxy-tls13-ciphers.md proxy-tlsauthtype.md proxy-tlspassword.md proxy-tlsuser.md proxy-tlsv1.md proxy-user.md proxy.md proxy1.0.md proxytunnel.md pubkey.md quote.md random-file.md range.md rate.md raw.md referer.md remote-header-name.md remote-name-all.md remote-name.md remote-time.md remove-on-error.md request-target.md request.md resolve.md retry-all-errors.md retry-connrefused.md retry-delay.md retry-max-time.md retry.md sasl-authzid.md sasl-ir.md service-name.md show-error.md show-headers.md sigalgs.md silent.md skip-existing.md socks4.md socks4a.md socks5-basic.md socks5-gssapi-nec.md socks5-gssapi-service.md socks5-gssapi.md socks5-hostname.md socks5.md speed-limit.md speed-time.md ssl-allow-beast.md ssl-auto-client-cert.md ssl-no-revoke.md ssl-reqd.md ssl-revoke-best-effort.md ssl-sessions.md ssl.md sslv2.md sslv3.md stderr.md styled-output.md suppress-connect-headers.md tcp-fastopen.md tcp-nodelay.md telnet-option.md tftp-blksize.md tftp-no-options.md time-cond.md tls-earlydata.md tls-max.md tls13-ciphers.md tlsauthtype.md tlspassword.md tlsuser.md tlsv1.0.md tlsv1.1.md tlsv1.2.md tlsv1.3.md tlsv1.md tr-encoding.md trace-ascii.md trace-config.md trace-ids.md trace-time.md trace.md unix-socket.md upload-file.md upload-flags.md url-query.md url.md use-ascii.md user-agent.md user.md variable.md verbose.md version.md vlan-priority.md write-out.md xattr.mdexamples
.checksrc .gitignore 10-at-a-time.c CMakeLists.txt Makefile.am Makefile.example Makefile.inc README.md adddocsref.pl address-scope.c altsvc.c anyauthput.c block_ip.c cacertinmem.c certinfo.c chkspeed.c connect-to.c cookie_interface.c crawler.c debug.c default-scheme.c ephiperfifo.c evhiperfifo.c externalsocket.c fileupload.c ftp-delete.c ftp-wildcard.c ftpget.c ftpgetinfo.c ftpgetresp.c ftpsget.c ftpupload.c ftpuploadfrommem.c ftpuploadresume.c getinfo.c getinmemory.c getredirect.c getreferrer.c ghiper.c headerapi.c hiperfifo.c hsts-preload.c htmltidy.c htmltitle.cpp http-options.c http-post.c http2-download.c http2-pushinmemory.c http2-serverpush.c http2-upload.c http3-present.c http3.c httpcustomheader.c httpput-postfields.c httpput.c https.c imap-append.c imap-authzid.c imap-copy.c imap-create.c imap-delete.c imap-examine.c imap-fetch.c imap-list.c imap-lsub.c imap-multi.c imap-noop.c imap-search.c imap-ssl.c imap-store.c imap-tls.c interface.c ipv6.c keepalive.c localport.c log_failed_transfers.c maxconnects.c multi-app.c multi-debugcallback.c multi-double.c multi-event.c multi-formadd.c multi-legacy.c multi-post.c multi-single.c multi-uv.c netrc.c parseurl.c persistent.c pop3-authzid.c pop3-dele.c pop3-list.c pop3-multi.c pop3-noop.c pop3-retr.c pop3-ssl.c pop3-stat.c pop3-tls.c pop3-top.c pop3-uidl.c post-callback.c postinmemory.c postit2-formadd.c postit2.c progressfunc.c protofeats.c range.c resolve.c rtsp-options.c sendrecv.c sepheaders.c sessioninfo.c sftpget.c sftpuploadresume.c shared-connection-cache.c simple.c simplepost.c simplessl.c smooth-gtk-thread.c smtp-authzid.c smtp-expn.c smtp-mail.c smtp-mime.c smtp-multi.c smtp-ssl.c smtp-tls.c smtp-vrfy.c sslbackend.c synctime.c threaded.c unixsocket.c url2file.c urlapi.c usercertinmem.c version-check.pl websocket-cb.c websocket-updown.c websocket.c xmlstream.cinternals
BUFQ.md BUFREF.md CHECKSRC.md CLIENT-READERS.md CLIENT-WRITERS.md CODE_STYLE.md CONNECTION-FILTERS.md CREDENTIALS.md CURLX.md DYNBUF.md HASH.md LLIST.md MID.md MQTT.md MULTI-EV.md NEW-PROTOCOL.md PEERS.md PORTING.md RATELIMITS.md README.md SCORECARD.md SPLAY.md STRPARSE.md THRDPOOL-AND-QUEUE.md TIME-KEEPING.md TLS-SESSIONS.md UINT_SETS.md WEBSOCKET.mdlibcurl
opts
CMakeLists.txt CURLINFO_ACTIVESOCKET.md CURLINFO_APPCONNECT_TIME.md CURLINFO_APPCONNECT_TIME_T.md CURLINFO_CAINFO.md CURLINFO_CAPATH.md CURLINFO_CERTINFO.md CURLINFO_CONDITION_UNMET.md CURLINFO_CONNECT_TIME.md CURLINFO_CONNECT_TIME_T.md CURLINFO_CONN_ID.md CURLINFO_CONTENT_LENGTH_DOWNLOAD.md CURLINFO_CONTENT_LENGTH_DOWNLOAD_T.md CURLINFO_CONTENT_LENGTH_UPLOAD.md CURLINFO_CONTENT_LENGTH_UPLOAD_T.md CURLINFO_CONTENT_TYPE.md CURLINFO_COOKIELIST.md CURLINFO_EARLYDATA_SENT_T.md CURLINFO_EFFECTIVE_METHOD.md CURLINFO_EFFECTIVE_URL.md CURLINFO_FILETIME.md CURLINFO_FILETIME_T.md CURLINFO_FTP_ENTRY_PATH.md CURLINFO_HEADER_SIZE.md CURLINFO_HTTPAUTH_AVAIL.md CURLINFO_HTTPAUTH_USED.md CURLINFO_HTTP_CONNECTCODE.md CURLINFO_HTTP_VERSION.md CURLINFO_LASTSOCKET.md CURLINFO_LOCAL_IP.md CURLINFO_LOCAL_PORT.md CURLINFO_NAMELOOKUP_TIME.md CURLINFO_NAMELOOKUP_TIME_T.md CURLINFO_NUM_CONNECTS.md CURLINFO_OS_ERRNO.md CURLINFO_POSTTRANSFER_TIME_T.md CURLINFO_PRETRANSFER_TIME.md CURLINFO_PRETRANSFER_TIME_T.md CURLINFO_PRIMARY_IP.md CURLINFO_PRIMARY_PORT.md CURLINFO_PRIVATE.md CURLINFO_PROTOCOL.md CURLINFO_PROXYAUTH_AVAIL.md CURLINFO_PROXYAUTH_USED.md CURLINFO_PROXY_ERROR.md CURLINFO_PROXY_SSL_VERIFYRESULT.md CURLINFO_QUEUE_TIME_T.md CURLINFO_REDIRECT_COUNT.md CURLINFO_REDIRECT_TIME.md CURLINFO_REDIRECT_TIME_T.md CURLINFO_REDIRECT_URL.md CURLINFO_REFERER.md CURLINFO_REQUEST_SIZE.md CURLINFO_RESPONSE_CODE.md CURLINFO_RETRY_AFTER.md CURLINFO_RTSP_CLIENT_CSEQ.md CURLINFO_RTSP_CSEQ_RECV.md CURLINFO_RTSP_SERVER_CSEQ.md CURLINFO_RTSP_SESSION_ID.md CURLINFO_SCHEME.md CURLINFO_SIZE_DELIVERED.md CURLINFO_SIZE_DOWNLOAD.md CURLINFO_SIZE_DOWNLOAD_T.md CURLINFO_SIZE_UPLOAD.md CURLINFO_SIZE_UPLOAD_T.md CURLINFO_SPEED_DOWNLOAD.md CURLINFO_SPEED_DOWNLOAD_T.md CURLINFO_SPEED_UPLOAD.md CURLINFO_SPEED_UPLOAD_T.md CURLINFO_SSL_ENGINES.md CURLINFO_SSL_VERIFYRESULT.md CURLINFO_STARTTRANSFER_TIME.md CURLINFO_STARTTRANSFER_TIME_T.md CURLINFO_TLS_SESSION.md CURLINFO_TLS_SSL_PTR.md CURLINFO_TOTAL_TIME.md CURLINFO_TOTAL_TIME_T.md CURLINFO_USED_PROXY.md CURLINFO_XFER_ID.md CURLMINFO_XFERS_ADDED.md CURLMINFO_XFERS_CURRENT.md CURLMINFO_XFERS_DONE.md CURLMINFO_XFERS_PENDING.md CURLMINFO_XFERS_RUNNING.md CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE.md CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE.md CURLMOPT_MAXCONNECTS.md CURLMOPT_MAX_CONCURRENT_STREAMS.md CURLMOPT_MAX_HOST_CONNECTIONS.md CURLMOPT_MAX_PIPELINE_LENGTH.md CURLMOPT_MAX_TOTAL_CONNECTIONS.md CURLMOPT_NETWORK_CHANGED.md CURLMOPT_NOTIFYDATA.md CURLMOPT_NOTIFYFUNCTION.md CURLMOPT_PIPELINING.md CURLMOPT_PIPELINING_SERVER_BL.md CURLMOPT_PIPELINING_SITE_BL.md CURLMOPT_PUSHDATA.md CURLMOPT_PUSHFUNCTION.md CURLMOPT_QUICK_EXIT.md CURLMOPT_RESOLVE_THREADS_MAX.md CURLMOPT_SOCKETDATA.md CURLMOPT_SOCKETFUNCTION.md CURLMOPT_TIMERDATA.md CURLMOPT_TIMERFUNCTION.md CURLOPT_ABSTRACT_UNIX_SOCKET.md CURLOPT_ACCEPTTIMEOUT_MS.md CURLOPT_ACCEPT_ENCODING.md CURLOPT_ADDRESS_SCOPE.md CURLOPT_ALTSVC.md CURLOPT_ALTSVC_CTRL.md CURLOPT_APPEND.md CURLOPT_AUTOREFERER.md CURLOPT_AWS_SIGV4.md CURLOPT_BUFFERSIZE.md CURLOPT_CAINFO.md CURLOPT_CAINFO_BLOB.md CURLOPT_CAPATH.md CURLOPT_CA_CACHE_TIMEOUT.md CURLOPT_CERTINFO.md CURLOPT_CHUNK_BGN_FUNCTION.md CURLOPT_CHUNK_DATA.md CURLOPT_CHUNK_END_FUNCTION.md CURLOPT_CLOSESOCKETDATA.md CURLOPT_CLOSESOCKETFUNCTION.md CURLOPT_CONNECTTIMEOUT.md CURLOPT_CONNECTTIMEOUT_MS.md CURLOPT_CONNECT_ONLY.md CURLOPT_CONNECT_TO.md CURLOPT_CONV_FROM_NETWORK_FUNCTION.md CURLOPT_CONV_FROM_UTF8_FUNCTION.md CURLOPT_CONV_TO_NETWORK_FUNCTION.md CURLOPT_COOKIE.md CURLOPT_COOKIEFILE.md CURLOPT_COOKIEJAR.md CURLOPT_COOKIELIST.md CURLOPT_COOKIESESSION.md CURLOPT_COPYPOSTFIELDS.md CURLOPT_CRLF.md CURLOPT_CRLFILE.md CURLOPT_CURLU.md CURLOPT_CUSTOMREQUEST.md CURLOPT_DEBUGDATA.md CURLOPT_DEBUGFUNCTION.md CURLOPT_DEFAULT_PROTOCOL.md CURLOPT_DIRLISTONLY.md CURLOPT_DISALLOW_USERNAME_IN_URL.md CURLOPT_DNS_CACHE_TIMEOUT.md CURLOPT_DNS_INTERFACE.md CURLOPT_DNS_LOCAL_IP4.md CURLOPT_DNS_LOCAL_IP6.md CURLOPT_DNS_SERVERS.md CURLOPT_DNS_SHUFFLE_ADDRESSES.md CURLOPT_DNS_USE_GLOBAL_CACHE.md CURLOPT_DOH_SSL_VERIFYHOST.md CURLOPT_DOH_SSL_VERIFYPEER.md CURLOPT_DOH_SSL_VERIFYSTATUS.md CURLOPT_DOH_URL.md CURLOPT_ECH.md CURLOPT_EGDSOCKET.md CURLOPT_ERRORBUFFER.md CURLOPT_EXPECT_100_TIMEOUT_MS.md CURLOPT_FAILONERROR.md CURLOPT_FILETIME.md CURLOPT_FNMATCH_DATA.md CURLOPT_FNMATCH_FUNCTION.md CURLOPT_FOLLOWLOCATION.md CURLOPT_FORBID_REUSE.md CURLOPT_FRESH_CONNECT.md CURLOPT_FTPPORT.md CURLOPT_FTPSSLAUTH.md CURLOPT_FTP_ACCOUNT.md CURLOPT_FTP_ALTERNATIVE_TO_USER.md CURLOPT_FTP_CREATE_MISSING_DIRS.md CURLOPT_FTP_FILEMETHOD.md CURLOPT_FTP_SKIP_PASV_IP.md CURLOPT_FTP_SSL_CCC.md CURLOPT_FTP_USE_EPRT.md CURLOPT_FTP_USE_EPSV.md CURLOPT_FTP_USE_PRET.md CURLOPT_GSSAPI_DELEGATION.md CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS.md CURLOPT_HAPROXYPROTOCOL.md CURLOPT_HAPROXY_CLIENT_IP.md CURLOPT_HEADER.md CURLOPT_HEADERDATA.md CURLOPT_HEADERFUNCTION.md CURLOPT_HEADEROPT.md CURLOPT_HSTS.md CURLOPT_HSTSREADDATA.md CURLOPT_HSTSREADFUNCTION.md CURLOPT_HSTSWRITEDATA.md CURLOPT_HSTSWRITEFUNCTION.md CURLOPT_HSTS_CTRL.md CURLOPT_HTTP09_ALLOWED.md CURLOPT_HTTP200ALIASES.md CURLOPT_HTTPAUTH.md CURLOPT_HTTPGET.md CURLOPT_HTTPHEADER.md CURLOPT_HTTPPOST.md CURLOPT_HTTPPROXYTUNNEL.md CURLOPT_HTTP_CONTENT_DECODING.md CURLOPT_HTTP_TRANSFER_DECODING.md CURLOPT_HTTP_VERSION.md CURLOPT_IGNORE_CONTENT_LENGTH.md CURLOPT_INFILESIZE.md CURLOPT_INFILESIZE_LARGE.md CURLOPT_INTERFACE.md CURLOPT_INTERLEAVEDATA.md CURLOPT_INTERLEAVEFUNCTION.md CURLOPT_IOCTLDATA.md CURLOPT_IOCTLFUNCTION.md CURLOPT_IPRESOLVE.md CURLOPT_ISSUERCERT.md CURLOPT_ISSUERCERT_BLOB.md CURLOPT_KEEP_SENDING_ON_ERROR.md CURLOPT_KEYPASSWD.md CURLOPT_KRBLEVEL.md CURLOPT_LOCALPORT.md CURLOPT_LOCALPORTRANGE.md CURLOPT_LOGIN_OPTIONS.md CURLOPT_LOW_SPEED_LIMIT.md CURLOPT_LOW_SPEED_TIME.md CURLOPT_MAIL_AUTH.md CURLOPT_MAIL_FROM.md CURLOPT_MAIL_RCPT.md CURLOPT_MAIL_RCPT_ALLOWFAILS.md CURLOPT_MAXAGE_CONN.md CURLOPT_MAXCONNECTS.md CURLOPT_MAXFILESIZE.md CURLOPT_MAXFILESIZE_LARGE.md CURLOPT_MAXLIFETIME_CONN.md CURLOPT_MAXREDIRS.md CURLOPT_MAX_RECV_SPEED_LARGE.md CURLOPT_MAX_SEND_SPEED_LARGE.md CURLOPT_MIMEPOST.md CURLOPT_MIME_OPTIONS.md CURLOPT_NETRC.md CURLOPT_NETRC_FILE.md CURLOPT_NEW_DIRECTORY_PERMS.md CURLOPT_NEW_FILE_PERMS.md CURLOPT_NOBODY.md CURLOPT_NOPROGRESS.md CURLOPT_NOPROXY.md CURLOPT_NOSIGNAL.md CURLOPT_OPENSOCKETDATA.md CURLOPT_OPENSOCKETFUNCTION.md CURLOPT_PASSWORD.md CURLOPT_PATH_AS_IS.md CURLOPT_PINNEDPUBLICKEY.md CURLOPT_PIPEWAIT.md CURLOPT_PORT.md CURLOPT_POST.md CURLOPT_POSTFIELDS.md CURLOPT_POSTFIELDSIZE.md CURLOPT_POSTFIELDSIZE_LARGE.md CURLOPT_POSTQUOTE.md CURLOPT_POSTREDIR.md CURLOPT_PREQUOTE.md CURLOPT_PREREQDATA.md CURLOPT_PREREQFUNCTION.md CURLOPT_PRE_PROXY.md CURLOPT_PRIVATE.md CURLOPT_PROGRESSDATA.md CURLOPT_PROGRESSFUNCTION.md CURLOPT_PROTOCOLS.md CURLOPT_PROTOCOLS_STR.md CURLOPT_PROXY.md CURLOPT_PROXYAUTH.md CURLOPT_PROXYHEADER.md CURLOPT_PROXYPASSWORD.md CURLOPT_PROXYPORT.md CURLOPT_PROXYTYPE.md CURLOPT_PROXYUSERNAME.md CURLOPT_PROXYUSERPWD.md CURLOPT_PROXY_CAINFO.md CURLOPT_PROXY_CAINFO_BLOB.md CURLOPT_PROXY_CAPATH.md CURLOPT_PROXY_CRLFILE.md CURLOPT_PROXY_ISSUERCERT.md CURLOPT_PROXY_ISSUERCERT_BLOB.md CURLOPT_PROXY_KEYPASSWD.md CURLOPT_PROXY_PINNEDPUBLICKEY.md CURLOPT_PROXY_SERVICE_NAME.md CURLOPT_PROXY_SSLCERT.md CURLOPT_PROXY_SSLCERTTYPE.md CURLOPT_PROXY_SSLCERT_BLOB.md CURLOPT_PROXY_SSLKEY.md CURLOPT_PROXY_SSLKEYTYPE.md CURLOPT_PROXY_SSLKEY_BLOB.md CURLOPT_PROXY_SSLVERSION.md CURLOPT_PROXY_SSL_CIPHER_LIST.md CURLOPT_PROXY_SSL_OPTIONS.md CURLOPT_PROXY_SSL_VERIFYHOST.md CURLOPT_PROXY_SSL_VERIFYPEER.md CURLOPT_PROXY_TLS13_CIPHERS.md CURLOPT_PROXY_TLSAUTH_PASSWORD.md CURLOPT_PROXY_TLSAUTH_TYPE.md CURLOPT_PROXY_TLSAUTH_USERNAME.md CURLOPT_PROXY_TRANSFER_MODE.md CURLOPT_PUT.md CURLOPT_QUICK_EXIT.md CURLOPT_QUOTE.md CURLOPT_RANDOM_FILE.md CURLOPT_RANGE.md CURLOPT_READDATA.md CURLOPT_READFUNCTION.md CURLOPT_REDIR_PROTOCOLS.md CURLOPT_REDIR_PROTOCOLS_STR.md CURLOPT_REFERER.md CURLOPT_REQUEST_TARGET.md CURLOPT_RESOLVE.md CURLOPT_RESOLVER_START_DATA.md CURLOPT_RESOLVER_START_FUNCTION.md CURLOPT_RESUME_FROM.md CURLOPT_RESUME_FROM_LARGE.md CURLOPT_RTSP_CLIENT_CSEQ.md CURLOPT_RTSP_REQUEST.md CURLOPT_RTSP_SERVER_CSEQ.md CURLOPT_RTSP_SESSION_ID.md CURLOPT_RTSP_STREAM_URI.md CURLOPT_RTSP_TRANSPORT.md CURLOPT_SASL_AUTHZID.md CURLOPT_SASL_IR.md CURLOPT_SEEKDATA.md CURLOPT_SEEKFUNCTION.md CURLOPT_SERVER_RESPONSE_TIMEOUT.md CURLOPT_SERVER_RESPONSE_TIMEOUT_MS.md CURLOPT_SERVICE_NAME.md CURLOPT_SHARE.md CURLOPT_SOCKOPTDATA.md CURLOPT_SOCKOPTFUNCTION.md CURLOPT_SOCKS5_AUTH.md CURLOPT_SOCKS5_GSSAPI_NEC.md CURLOPT_SOCKS5_GSSAPI_SERVICE.md CURLOPT_SSH_AUTH_TYPES.md CURLOPT_SSH_COMPRESSION.md CURLOPT_SSH_HOSTKEYDATA.md CURLOPT_SSH_HOSTKEYFUNCTION.md CURLOPT_SSH_HOST_PUBLIC_KEY_MD5.md CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256.md CURLOPT_SSH_KEYDATA.md CURLOPT_SSH_KEYFUNCTION.md CURLOPT_SSH_KNOWNHOSTS.md CURLOPT_SSH_PRIVATE_KEYFILE.md CURLOPT_SSH_PUBLIC_KEYFILE.md CURLOPT_SSLCERT.md CURLOPT_SSLCERTTYPE.md CURLOPT_SSLCERT_BLOB.md CURLOPT_SSLENGINE.md CURLOPT_SSLENGINE_DEFAULT.md CURLOPT_SSLKEY.md CURLOPT_SSLKEYTYPE.md CURLOPT_SSLKEY_BLOB.md CURLOPT_SSLVERSION.md CURLOPT_SSL_CIPHER_LIST.md CURLOPT_SSL_CTX_DATA.md CURLOPT_SSL_CTX_FUNCTION.md CURLOPT_SSL_EC_CURVES.md CURLOPT_SSL_ENABLE_ALPN.md CURLOPT_SSL_ENABLE_NPN.md CURLOPT_SSL_FALSESTART.md CURLOPT_SSL_OPTIONS.md CURLOPT_SSL_SESSIONID_CACHE.md CURLOPT_SSL_SIGNATURE_ALGORITHMS.md CURLOPT_SSL_VERIFYHOST.md CURLOPT_SSL_VERIFYPEER.md CURLOPT_SSL_VERIFYSTATUS.md CURLOPT_STDERR.md CURLOPT_STREAM_DEPENDS.md CURLOPT_STREAM_DEPENDS_E.md CURLOPT_STREAM_WEIGHT.md CURLOPT_SUPPRESS_CONNECT_HEADERS.md CURLOPT_TCP_FASTOPEN.md CURLOPT_TCP_KEEPALIVE.md CURLOPT_TCP_KEEPCNT.md CURLOPT_TCP_KEEPIDLE.md CURLOPT_TCP_KEEPINTVL.md CURLOPT_TCP_NODELAY.md CURLOPT_TELNETOPTIONS.md CURLOPT_TFTP_BLKSIZE.md CURLOPT_TFTP_NO_OPTIONS.md CURLOPT_TIMECONDITION.md CURLOPT_TIMEOUT.md CURLOPT_TIMEOUT_MS.md CURLOPT_TIMEVALUE.md CURLOPT_TIMEVALUE_LARGE.md CURLOPT_TLS13_CIPHERS.md CURLOPT_TLSAUTH_PASSWORD.md CURLOPT_TLSAUTH_TYPE.md CURLOPT_TLSAUTH_USERNAME.md CURLOPT_TRAILERDATA.md CURLOPT_TRAILERFUNCTION.md CURLOPT_TRANSFERTEXT.md CURLOPT_TRANSFER_ENCODING.md CURLOPT_UNIX_SOCKET_PATH.md CURLOPT_UNRESTRICTED_AUTH.md CURLOPT_UPKEEP_INTERVAL_MS.md CURLOPT_UPLOAD.md CURLOPT_UPLOAD_BUFFERSIZE.md CURLOPT_UPLOAD_FLAGS.md CURLOPT_URL.md CURLOPT_USERAGENT.md CURLOPT_USERNAME.md CURLOPT_USERPWD.md CURLOPT_USE_SSL.md CURLOPT_VERBOSE.md CURLOPT_WILDCARDMATCH.md CURLOPT_WRITEDATA.md CURLOPT_WRITEFUNCTION.md CURLOPT_WS_OPTIONS.md CURLOPT_XFERINFODATA.md CURLOPT_XFERINFOFUNCTION.md CURLOPT_XOAUTH2_BEARER.md CURLSHOPT_LOCKFUNC.md CURLSHOPT_SHARE.md CURLSHOPT_UNLOCKFUNC.md CURLSHOPT_UNSHARE.md CURLSHOPT_USERDATA.md Makefile.am Makefile.incinclude
curl
Makefile.am curl.h curlver.h easy.h header.h mprintf.h multi.h options.h stdcheaders.h system.h typecheck-gcc.h urlapi.h websockets.hlib
curlx
base64.c base64.h basename.c basename.h dynbuf.c dynbuf.h fopen.c fopen.h inet_ntop.c inet_ntop.h inet_pton.c inet_pton.h multibyte.c multibyte.h nonblock.c nonblock.h snprintf.c snprintf.h strcopy.c strcopy.h strdup.c strdup.h strerr.c strerr.h strparse.c strparse.h timediff.c timediff.h timeval.c timeval.h version_win32.c version_win32.h wait.c wait.h warnless.c warnless.h winapi.c winapi.hvauth
cleartext.c cram.c digest.c digest.h digest_sspi.c gsasl.c krb5_gssapi.c krb5_sspi.c ntlm.c ntlm_sspi.c oauth2.c spnego_gssapi.c spnego_sspi.c vauth.c vauth.hvquic
curl_ngtcp2.c curl_ngtcp2.h curl_quiche.c curl_quiche.h vquic-tls.c vquic-tls.h vquic.c vquic.h vquic_int.hvtls
apple.c apple.h cipher_suite.c cipher_suite.h gtls.c gtls.h hostcheck.c hostcheck.h keylog.c keylog.h mbedtls.c mbedtls.h openssl.c openssl.h rustls.c rustls.h schannel.c schannel.h schannel_int.h schannel_verify.c vtls.c vtls.h vtls_int.h vtls_scache.c vtls_scache.h vtls_spack.c vtls_spack.h wolfssl.c wolfssl.h x509asn1.c x509asn1.hm4
.gitignore curl-amissl.m4 curl-apple-sectrust.m4 curl-compilers.m4 curl-confopts.m4 curl-functions.m4 curl-gnutls.m4 curl-mbedtls.m4 curl-openssl.m4 curl-override.m4 curl-reentrant.m4 curl-rustls.m4 curl-schannel.m4 curl-sysconfig.m4 curl-wolfssl.m4 xc-am-iface.m4 xc-cc-check.m4 xc-lt-iface.m4 xc-val-flgs.m4 zz40-xc-ovr.m4 zz50-xc-ovr.m4projects
OS400
.checksrc README.OS400 ccsidcurl.c ccsidcurl.h config400.default curl.cmd curl.inc.in curlcl.c curlmain.c initscript.sh make-docs.sh make-include.sh make-lib.sh make-src.sh make-tests.sh makefile.sh os400sys.c os400sys.hWindows
tmpl
.gitattributes README.txt curl-all.sln curl.sln curl.vcxproj curl.vcxproj.filters libcurl.sln libcurl.vcxproj libcurl.vcxproj.filtersvms
Makefile.am backup_gnv_curl_src.com build_curl-config_script.com build_gnv_curl.com build_gnv_curl_pcsi_desc.com build_gnv_curl_pcsi_text.com build_gnv_curl_release_notes.com build_libcurl_pc.com build_vms.com clean_gnv_curl.com compare_curl_source.com config_h.com curl_crtl_init.c curl_gnv_build_steps.txt curl_release_note_start.txt curl_startup.com curlmsg.h curlmsg.msg curlmsg.sdl curlmsg_vms.h generate_config_vms_h_curl.com generate_vax_transfer.com gnv_conftest.c_first gnv_curl_configure.sh gnv_libcurl_symbols.opt gnv_link_curl.com macro32_exactcase.patch make_gnv_curl_install.sh make_pcsi_curl_kit_name.com pcsi_gnv_curl_file_list.txt pcsi_product_gnv_curl.com readme report_openssl_version.c setup_gnv_curl_build.com stage_curl_install.com vms_eco_level.hscripts
.checksrc CMakeLists.txt Makefile.am badwords badwords-all badwords.txt cd2cd cd2nroff cdall checksrc-all.pl checksrc.pl cmakelint.sh completion.pl contributors.sh contrithanks.sh coverage.sh delta dmaketgz extract-unit-protos firefox-db2pem.sh installcheck.sh maketgz managen mdlinkcheck mk-ca-bundle.pl mk-unity.pl nroff2cd perlcheck.sh pythonlint.sh randdisable release-notes.pl release-tools.sh schemetable.c singleuse.pl spacecheck.pl top-complexity top-length verify-release wcurlsrc
.checksrc .gitignore CMakeLists.txt Makefile.am Makefile.inc config2setopts.c config2setopts.h curl.rc curlinfo.c mk-file-embed.pl mkhelp.pl slist_wc.c slist_wc.h terminal.c terminal.h tool_cb_dbg.c tool_cb_dbg.h tool_cb_hdr.c tool_cb_hdr.h tool_cb_prg.c tool_cb_prg.h tool_cb_rea.c tool_cb_rea.h tool_cb_see.c tool_cb_see.h tool_cb_soc.c tool_cb_soc.h tool_cb_wrt.c tool_cb_wrt.h tool_cfgable.c tool_cfgable.h tool_dirhie.c tool_dirhie.h tool_doswin.c tool_doswin.h tool_easysrc.c tool_easysrc.h tool_filetime.c tool_filetime.h tool_findfile.c tool_findfile.h tool_formparse.c tool_formparse.h tool_getparam.c tool_getparam.h tool_getpass.c tool_getpass.h tool_help.c tool_help.h tool_helpers.c tool_helpers.h tool_hugehelp.h tool_ipfs.c tool_ipfs.h tool_libinfo.c tool_libinfo.h tool_listhelp.c tool_main.c tool_main.h tool_msgs.c tool_msgs.h tool_operate.c tool_operate.h tool_operhlp.c tool_operhlp.h tool_paramhlp.c tool_paramhlp.h tool_parsecfg.c tool_parsecfg.h tool_progress.c tool_progress.h tool_sdecls.h tool_setopt.c tool_setopt.h tool_setup.h tool_ssls.c tool_ssls.h tool_stderr.c tool_stderr.h tool_urlglob.c tool_urlglob.h tool_util.c tool_util.h tool_version.h tool_vms.c tool_vms.h tool_writeout.c tool_writeout.h tool_writeout_json.c tool_writeout_json.h tool_xattr.c tool_xattr.h var.c var.htests
certs
.gitignore CMakeLists.txt Makefile.am Makefile.inc genserv.pl srp-verifier-conf srp-verifier-db test-ca.cnf test-ca.prm test-client-cert.prm test-client-eku-only.prm test-localhost-san-first.prm test-localhost-san-last.prm test-localhost.nn.prm test-localhost.prm test-localhost0h.prmdata
.gitignore DISABLED Makefile.am data-xml1 data1400.c data1401.c data1402.c data1403.c data1404.c data1405.c data1406.c data1407.c data1420.c data1461.txt data1463.txt data1465.c data1481.c data1705-1.md data1705-2.md data1705-3.md data1705-4.md data1705-stdout.1 data1706-1.md data1706-2.md data1706-3.md data1706-4.md data1706-stdout.txt data320.html test1 test10 test100 test1000 test1001 test1002 test1003 test1004 test1005 test1006 test1007 test1008 test1009 test101 test1010 test1011 test1012 test1013 test1014 test1015 test1016 test1017 test1018 test1019 test102 test1020 test1021 test1022 test1023 test1024 test1025 test1026 test1027 test1028 test1029 test103 test1030 test1031 test1032 test1033 test1034 test1035 test1036 test1037 test1038 test1039 test104 test1040 test1041 test1042 test1043 test1044 test1045 test1046 test1047 test1048 test1049 test105 test1050 test1051 test1052 test1053 test1054 test1055 test1056 test1057 test1058 test1059 test106 test1060 test1061 test1062 test1063 test1064 test1065 test1066 test1067 test1068 test1069 test107 test1070 test1071 test1072 test1073 test1074 test1075 test1076 test1077 test1078 test1079 test108 test1080 test1081 test1082 test1083 test1084 test1085 test1086 test1087 test1088 test1089 test109 test1090 test1091 test1092 test1093 test1094 test1095 test1096 test1097 test1098 test1099 test11 test110 test1100 test1101 test1102 test1103 test1104 test1105 test1106 test1107 test1108 test1109 test111 test1110 test1111 test1112 test1113 test1114 test1115 test1116 test1117 test1118 test1119 test112 test1120 test1121 test1122 test1123 test1124 test1125 test1126 test1127 test1128 test1129 test113 test1130 test1131 test1132 test1133 test1134 test1135 test1136 test1137 test1138 test1139 test114 test1140 test1141 test1142 test1143 test1144 test1145 test1146 test1147 test1148 test1149 test115 test1150 test1151 test1152 test1153 test1154 test1155 test1156 test1157 test1158 test1159 test116 test1160 test1161 test1162 test1163 test1164 test1165 test1166 test1167 test1168 test1169 test117 test1170 test1171 test1172 test1173 test1174 test1175 test1176 test1177 test1178 test1179 test118 test1180 test1181 test1182 test1183 test1184 test1185 test1186 test1187 test1188 test1189 test119 test1190 test1191 test1192 test1193 test1194 test1195 test1196 test1197 test1198 test1199 test12 test120 test1200 test1201 test1202 test1203 test1204 test1205 test1206 test1207 test1208 test1209 test121 test1210 test1211 test1212 test1213 test1214 test1215 test1216 test1217 test1218 test1219 test122 test1220 test1221 test1222 test1223 test1224 test1225 test1226 test1227 test1228 test1229 test123 test1230 test1231 test1232 test1233 test1234 test1235 test1236 test1237 test1238 test1239 test124 test1240 test1241 test1242 test1243 test1244 test1245 test1246 test1247 test1248 test1249 test125 test1250 test1251 test1252 test1253 test1254 test1255 test1256 test1257 test1258 test1259 test126 test1260 test1261 test1262 test1263 test1264 test1265 test1266 test1267 test1268 test1269 test127 test1270 test1271 test1272 test1273 test1274 test1275 test1276 test1277 test1278 test1279 test128 test1280 test1281 test1282 test1283 test1284 test1285 test1286 test1287 test1288 test1289 test129 test1290 test1291 test1292 test1293 test1294 test1295 test1296 test1297 test1298 test1299 test13 test130 test1300 test1301 test1302 test1303 test1304 test1305 test1306 test1307 test1308 test1309 test131 test1310 test1311 test1312 test1313 test1314 test1315 test1316 test1317 test1318 test1319 test132 test1320 test1321 test1322 test1323 test1324 test1325 test1326 test1327 test1328 test1329 test133 test1330 test1331 test1332 test1333 test1334 test1335 test1336 test1337 test1338 test1339 test134 test1340 test1341 test1342 test1343 test1344 test1345 test1346 test1347 test1348 test1349 test135 test1350 test1351 test1352 test1353 test1354 test1355 test1356 test1357 test1358 test1359 test136 test1360 test1361 test1362 test1363 test1364 test1365 test1366 test1367 test1368 test1369 test137 test1370 test1371 test1372 test1373 test1374 test1375 test1376 test1377 test1378 test1379 test138 test1380 test1381 test1382 test1383 test1384 test1385 test1386 test1387 test1388 test1389 test139 test1390 test1391 test1392 test1393 test1394 test1395 test1396 test1397 test1398 test1399 test14 test140 test1400 test1401 test1402 test1403 test1404 test1405 test1406 test1407 test1408 test1409 test141 test1410 test1411 test1412 test1413 test1414 test1415 test1416 test1417 test1418 test1419 test142 test1420 test1421 test1422 test1423 test1424 test1425 test1426 test1427 test1428 test1429 test143 test1430 test1431 test1432 test1433 test1434 test1435 test1436 test1437 test1438 test1439 test144 test1440 test1441 test1442 test1443 test1444 test1445 test1446 test1447 test1448 test1449 test145 test1450 test1451 test1452 test1453 test1454 test1455 test1456 test1457 test1458 test1459 test146 test1460 test1461 test1462 test1463 test1464 test1465 test1466 test1467 test1468 test1469 test147 test1470 test1471 test1472 test1473 test1474 test1475 test1476 test1477 test1478 test1479 test148 test1480 test1481 test1482 test1483 test1484 test1485 test1486 test1487 test1488 test1489 test149 test1490 test1491 test1492 test1493 test1494 test1495 test1496 test1497 test1498 test1499 test15 test150 test1500 test1501 test1502 test1503 test1504 test1505 test1506 test1507 test1508 test1509 test151 test1510 test1511 test1512 test1513 test1514 test1515 test1516 test1517 test1518 test1519 test152 test1520 test1521 test1522 test1523 test1524 test1525 test1526 test1527 test1528 test1529 test153 test1530 test1531 test1532 test1533 test1534 test1535 test1536 test1537 test1538 test1539 test154 test1540 test1541 test1542 test1543 test1544 test1545 test1546 test1547 test1548 test1549 test155 test1550 test1551 test1552 test1553 test1554 test1555 test1556 test1557 test1558 test1559 test156 test1560 test1561 test1562 test1563 test1564 test1565 test1566 test1567 test1568 test1569 test157 test1570 test1571 test1572 test1573 test1574 test1575 test1576 test1577 test1578 test1579 test158 test1580 test1581 test1582 test1583 test1584 test1585 test1586 test1587 test1588 test1589 test159 test1590 test1591 test1592 test1593 test1594 test1595 test1596 test1597 test1598 test1599 test16 test160 test1600 test1601 test1602 test1603 test1604 test1605 test1606 test1607 test1608 test1609 test161 test1610 test1611 test1612 test1613 test1614 test1615 test1616 test1617 test1618 test1619 test162 test1620 test1621 test1622 test1623 test1624 test1625 test1626 test1627 test1628 test1629 test163 test1630 test1631 test1632 test1633 test1634 test1635 test1636 test1637 test1638 test1639 test164 test1640 test1641 test1642 test1643 test1644 test1645 test165 test1650 test1651 test1652 test1653 test1654 test1655 test1656 test1657 test1658 test1659 test166 test1660 test1661 test1662 test1663 test1664 test1665 test1666 test1667 test1668 test1669 test167 test1670 test1671 test1672 test1673 test1674 test1675 test1676 test168 test1680 test1681 test1682 test1683 test1684 test1685 test169 test17 test170 test1700 test1701 test1702 test1703 test1704 test1705 test1706 test1707 test1708 test1709 test171 test1710 test1711 test1712 test1713 test1714 test1715 test172 test1720 test1721 test173 test174 test175 test176 test177 test178 test179 test18 test180 test1800 test1801 test1802 test181 test182 test183 test184 test1847 test1848 test1849 test185 test1850 test1851 test186 test187 test188 test189 test19 test190 test1900 test1901 test1902 test1903 test1904 test1905 test1906 test1907 test1908 test1909 test191 test1910 test1911 test1912 test1913 test1914 test1915 test1916 test1917 test1918 test1919 test192 test1920 test1921 test193 test1933 test1934 test1935 test1936 test1937 test1938 test1939 test194 test1940 test1941 test1942 test1943 test1944 test1945 test1946 test1947 test1948 test195 test1955 test1956 test1957 test1958 test1959 test196 test1960 test1964 test1965 test1966 test197 test1970 test1971 test1972 test1973 test1974 test1975 test1976 test1977 test1978 test1979 test198 test1980 test1981 test1982 test1983 test1984 test199 test2 test20 test200 test2000 test2001 test2002 test2003 test2004 test2005 test2006 test2007 test2008 test2009 test201 test2010 test2011 test2012 test2013 test2014 test202 test2023 test2024 test2025 test2026 test2027 test2028 test2029 test203 test2030 test2031 test2032 test2033 test2034 test2035 test2037 test2038 test2039 test204 test2040 test2041 test2042 test2043 test2044 test2045 test2046 test2047 test2048 test2049 test205 test2050 test2051 test2052 test2053 test2054 test2055 test2056 test2057 test2058 test2059 test206 test2060 test2061 test2062 test2063 test2064 test2065 test2066 test2067 test2068 test2069 test207 test2070 test2071 test2072 test2073 test2074 test2075 test2076 test2077 test2078 test2079 test208 test2080 test2081 test2082 test2083 test2084 test2085 test2086 test2087 test2088 test2089 test209 test2090 test2091 test2092 test21 test210 test2100 test2101 test2102 test2103 test2104 test211 test212 test213 test214 test215 test216 test217 test218 test219 test22 test220 test2200 test2201 test2202 test2203 test2204 test2205 test2206 test2207 test221 test222 test223 test224 test225 test226 test227 test228 test229 test23 test230 test2300 test2301 test2302 test2303 test2304 test2306 test2307 test2308 test2309 test231 test232 test233 test234 test235 test236 test237 test238 test239 test24 test240 test2400 test2401 test2402 test2403 test2404 test2405 test2406 test2407 test2408 test2409 test241 test2410 test2411 test242 test243 test244 test245 test246 test247 test248 test249 test25 test250 test2500 test2501 test2502 test2503 test2504 test2505 test2506 test251 test252 test253 test254 test255 test256 test257 test258 test259 test26 test260 test2600 test2601 test2602 test2603 test2604 test2605 test261 test262 test263 test264 test265 test266 test267 test268 test269 test27 test270 test2700 test2701 test2702 test2703 test2704 test2705 test2706 test2707 test2708 test2709 test271 test2710 test2711 test2712 test2713 test2714 test2715 test2716 test2717 test2718 test2719 test272 test2720 test2721 test2722 test2723 test273 test274 test275 test276 test277 test278 test279 test28 test280 test281 test282 test283 test284 test285 test286 test287 test288 test289 test29 test290 test291 test292 test293 test294 test295 test296 test297 test298 test299 test3 test30 test300 test3000 test3001 test3002 test3003 test3004 test3005 test3006 test3007 test3008 test3009 test301 test3010 test3011 test3012 test3013 test3014 test3015 test3016 test3017 test3018 test3019 test302 test3020 test3021 test3022 test3023 test3024 test3025 test3026 test3027 test3028 test3029 test303 test3030 test3031 test3032 test3033 test3034 test3035 test3036 test304 test305 test306 test307 test308 test309 test31 test310 test3100 test3101 test3102 test3103 test3104 test3105 test3106 test311 test312 test313 test314 test315 test316 test317 test318 test319 test32 test320 test3200 test3201 test3202 test3203 test3204 test3205 test3206 test3207 test3208 test3209 test321 test3210 test3211 test3212 test3213 test3214 test3215 test3216 test3217 test3218 test3219 test322 test3220 test323 test324 test325 test326 test327 test328 test329 test33 test330 test3300 test3301 test3302 test331 test332 test333 test334 test335 test336 test337 test338 test339 test34 test340 test341 test342 test343 test344 test345 test346 test347 test348 test349 test35 test350 test351 test352 test353 test354 test355 test356 test357 test358 test359 test36 test360 test361 test362 test363 test364 test365 test366 test367 test368 test369 test37 test370 test371 test372 test373 test374 test375 test376 test378 test379 test38 test380 test381 test383 test384 test385 test386 test387 test388 test389 test39 test390 test391 test392 test393 test394 test395 test396 test397 test398 test399 test4 test40 test400 test4000 test4001 test401 test402 test403 test404 test405 test406 test407 test408 test409 test41 test410 test411 test412 test413 test414 test415 test416 test417 test418 test419 test42 test420 test421 test422 test423 test424 test425 test426 test427 test428 test429 test43 test430 test431 test432 test433 test434 test435 test436 test437 test438 test439 test44 test440 test441 test442 test443 test444 test445 test446 test447 test448 test449 test45 test450 test451 test452 test453 test454 test455 test456 test457 test458 test459 test46 test460 test461 test462 test463 test467 test468 test469 test47 test470 test471 test472 test473 test474 test475 test476 test477 test478 test479 test48 test480 test481 test482 test483 test484 test485 test486 test487 test488 test489 test49 test490 test491 test492 test493 test494 test495 test496 test497 test498 test499 test5 test50 test500 test501 test502 test503 test504 test505 test506 test507 test508 test509 test51 test510 test511 test512 test513 test514 test515 test516 test517 test518 test519 test52 test520 test521 test522 test523 test524 test525 test526 test527 test528 test529 test53 test530 test531 test532 test533 test534 test535 test536 test537 test538 test539 test54 test540 test541 test542 test543 test544 test545 test546 test547 test548 test549 test55 test550 test551 test552 test553 test554 test555 test556 test557 test558 test559 test56 test560 test561 test562 test563 test564 test565 test566 test567 test568 test569 test57 test570 test571 test572 test573 test574 test575 test576 test577 test578 test579 test58 test580 test581 test582 test583 test584 test585 test586 test587 test588 test589 test59 test590 test591 test592 test593 test594 test595 test596 test597 test598 test599 test6 test60 test600 test601 test602 test603 test604 test605 test606 test607 test608 test609 test61 test610 test611 test612 test613 test614 test615 test616 test617 test618 test619 test62 test620 test621 test622 test623 test624 test625 test626 test627 test628 test629 test63 test630 test631 test632 test633 test634 test635 test636 test637 test638 test639 test64 test640 test641 test642 test643 test644 test645 test646 test647 test648 test649 test65 test650 test651 test652 test653 test654 test655 test656 test658 test659 test66 test660 test661 test662 test663 test664 test665 test666 test667 test668 test669 test67 test670 test671 test672 test673 test674 test675 test676 test677 test678 test679 test68 test680 test681 test682 test683 test684 test685 test686 test687 test688 test689 test69 test690 test691 test692 test693 test694 test695 test696 test697 test698 test699 test7 test70 test700 test701 test702 test703 test704 test705 test706 test707 test708 test709 test71 test710 test711 test712 test713 test714 test715 test716 test717 test718 test719 test72 test720 test721 test722 test723 test724 test725 test726 test727 test728 test729 test73 test730 test731 test732 test733 test734 test735 test736 test737 test738 test739 test74 test740 test741 test742 test743 test744 test745 test746 test747 test748 test749 test75 test750 test751 test752 test753 test754 test755 test756 test757 test758 test759 test76 test760 test761 test762 test763 test764 test765 test766 test767 test768 test769 test77 test770 test771 test772 test773 test774 test775 test776 test777 test778 test779 test78 test780 test781 test782 test783 test784 test785 test786 test787 test788 test789 test79 test790 test791 test792 test793 test794 test795 test796 test797 test798 test799 test8 test80 test800 test801 test802 test803 test804 test805 test806 test807 test808 test809 test81 test810 test811 test812 test813 test814 test815 test816 test817 test818 test819 test82 test820 test821 test822 test823 test824 test825 test826 test827 test828 test829 test83 test830 test831 test832 test833 test834 test835 test836 test837 test838 test839 test84 test840 test841 test842 test843 test844 test845 test846 test847 test848 test849 test85 test850 test851 test852 test853 test854 test855 test856 test857 test858 test859 test86 test860 test861 test862 test863 test864 test865 test866 test867 test868 test869 test87 test870 test871 test872 test873 test874 test875 test876 test877 test878 test879 test88 test880 test881 test882 test883 test884 test885 test886 test887 test888 test889 test89 test890 test891 test892 test893 test894 test895 test896 test897 test898 test899 test9 test90 test900 test901 test902 test903 test904 test905 test906 test907 test908 test909 test91 test910 test911 test912 test913 test914 test915 test916 test917 test918 test919 test92 test920 test921 test922 test923 test924 test925 test926 test927 test928 test929 test93 test930 test931 test932 test933 test934 test935 test936 test937 test938 test939 test94 test940 test941 test942 test943 test944 test945 test946 test947 test948 test949 test95 test950 test951 test952 test953 test954 test955 test956 test957 test958 test959 test96 test960 test961 test962 test963 test964 test965 test966 test967 test968 test969 test97 test970 test971 test972 test973 test974 test975 test976 test977 test978 test979 test98 test980 test981 test982 test983 test984 test985 test986 test987 test988 test989 test99 test990 test991 test992 test993 test994 test995 test996 test997 test998 test999http
testenv
__init__.py caddy.py certs.py client.py curl.py dante.py dnsd.py env.py httpd.py nghttpx.py ports.py sshd.py vsftpd.py ws_echo_server.pylibtest
.gitignore CMakeLists.txt Makefile.am Makefile.inc cli_ftp_upload.c cli_h2_pausing.c cli_h2_serverpush.c cli_h2_upgrade_extreme.c cli_hx_download.c cli_hx_upload.c cli_tls_session_reuse.c cli_upload_pausing.c cli_ws_data.c cli_ws_pingpong.c first.c first.h lib1156.c lib1301.c lib1308.c lib1485.c lib1500.c lib1501.c lib1502.c lib1506.c lib1507.c lib1508.c lib1509.c lib1510.c lib1511.c lib1512.c lib1513.c lib1514.c lib1515.c lib1517.c lib1518.c lib1520.c lib1522.c lib1523.c lib1525.c lib1526.c lib1527.c lib1528.c lib1529.c lib1530.c lib1531.c lib1532.c lib1533.c lib1534.c lib1535.c lib1536.c lib1537.c lib1538.c lib1540.c lib1541.c lib1542.c lib1545.c lib1549.c lib1550.c lib1551.c lib1552.c lib1553.c lib1554.c lib1555.c lib1556.c lib1557.c lib1558.c lib1559.c lib1560.c lib1564.c lib1565.c lib1567.c lib1568.c lib1569.c lib1571.c lib1576.c lib1582.c lib1587.c lib1588.c lib1589.c lib1591.c lib1592.c lib1593.c lib1594.c lib1597.c lib1598.c lib1599.c lib1662.c lib1900.c lib1901.c lib1902.c lib1903.c lib1905.c lib1906.c lib1907.c lib1908.c lib1910.c lib1911.c lib1912.c lib1913.c lib1915.c lib1916.c lib1918.c lib1919.c lib1920.c lib1921.c lib1933.c lib1934.c lib1935.c lib1936.c lib1937.c lib1938.c lib1939.c lib1940.c lib1945.c lib1947.c lib1948.c lib1955.c lib1956.c lib1957.c lib1958.c lib1959.c lib1960.c lib1964.c lib1965.c lib1970.c lib1971.c lib1972.c lib1973.c lib1974.c lib1975.c lib1977.c lib1978.c lib2023.c lib2032.c lib2082.c lib2301.c lib2302.c lib2304.c lib2306.c lib2308.c lib2309.c lib2402.c lib2404.c lib2405.c lib2502.c lib2504.c lib2505.c lib2506.c lib2700.c lib3010.c lib3025.c lib3026.c lib3027.c lib3033.c lib3034.c lib3100.c lib3101.c lib3102.c lib3103.c lib3104.c lib3105.c lib3207.c lib3208.c lib500.c lib501.c lib502.c lib503.c lib504.c lib505.c lib506.c lib507.c lib508.c lib509.c lib510.c lib511.c lib512.c lib513.c lib514.c lib515.c lib516.c lib517.c lib518.c lib519.c lib520.c lib521.c lib523.c lib524.c lib525.c lib526.c lib530.c lib533.c lib536.c lib537.c lib539.c lib540.c lib541.c lib542.c lib543.c lib544.c lib547.c lib549.c lib552.c lib553.c lib554.c lib555.c lib556.c lib557.c lib558.c lib559.c lib560.c lib562.c lib564.c lib566.c lib567.c lib568.c lib569.c lib570.c lib571.c lib572.c lib573.c lib574.c lib575.c lib576.c lib578.c lib579.c lib582.c lib583.c lib586.c lib589.c lib590.c lib591.c lib597.c lib598.c lib599.c lib643.c lib650.c lib651.c lib652.c lib653.c lib654.c lib655.c lib658.c lib659.c lib661.c lib666.c lib667.c lib668.c lib670.c lib674.c lib676.c lib677.c lib678.c lib694.c lib695.c lib751.c lib753.c lib757.c lib758.c lib766.c memptr.c mk-lib1521.pl test1013.pl test1022.pl test307.pl test610.pl test613.pl testtrace.c testtrace.h testutil.c testutil.h unitcheck.hserver
.checksrc .gitignore CMakeLists.txt Makefile.am Makefile.inc dnsd.c first.c first.h getpart.c mqttd.c resolve.c rtspd.c sockfilt.c socksd.c sws.c tftpd.c util.ctunit
.gitignore CMakeLists.txt Makefile.am Makefile.inc README.md tool1394.c tool1604.c tool1621.c tool1622.c tool1623.c tool1720.cunit
.gitignore CMakeLists.txt Makefile.am Makefile.inc README.md unit1300.c unit1302.c unit1303.c unit1304.c unit1305.c unit1307.c unit1309.c unit1323.c unit1330.c unit1395.c unit1396.c unit1397.c unit1398.c unit1399.c unit1600.c unit1601.c unit1602.c unit1603.c unit1605.c unit1606.c unit1607.c unit1608.c unit1609.c unit1610.c unit1611.c unit1612.c unit1614.c unit1615.c unit1616.c unit1620.c unit1625.c unit1626.c unit1627.c unit1636.c unit1650.c unit1651.c unit1652.c unit1653.c unit1654.c unit1655.c unit1656.c unit1657.c unit1658.c unit1660.c unit1661.c unit1663.c unit1664.c unit1666.c unit1667.c unit1668.c unit1669.c unit1674.c unit1675.c unit1676.c unit1979.c unit1980.c unit2600.c unit2601.c unit2602.c unit2603.c unit2604.c unit2605.c unit3200.c unit3205.c unit3211.c unit3212.c unit3213.c unit3214.c unit3216.c unit3219.c unit3300.c unit3301.c unit3302.cexamples
.env config.ini crypto_test.lua env_test.lua fs_example.lua http_server.lua https_test.lua ini_example.lua json.lua log.lua path_fs_example.lua process_example.lua request_download.lua request_test.lua run_all.lua sqlite_example.lua sqlite_http_template.lua stash_test.lua template_test.lua timer.lua websocket.luainiparser
example
iniexample.c iniwrite.c parse.c twisted-errors.ini twisted-genhuge.py twisted-ofkey.ini twisted-ofval.ini twisted.initest
CMakeLists.txt test_dictionary.c test_iniparser.c unity-config.yml unity_config.hjinjac
libjinjac
src
CMakeLists.txt ast.c ast.h block_statement.c block_statement.h buffer.c buffer.h buildin.c buildin.h common.h convert.c convert.h flex_decl.h jfunction.c jfunction.h jinja_expression.l jinja_expression.y jinjac_parse.c jinjac_parse.h jinjac_stream.c jinjac_stream.h jlist.c jlist.h jobject.c jobject.h parameter.c parameter.h str_obj.c str_obj.h trace.c trace.htest
.gitignore CMakeLists.txt autotest.rb test_01.expected test_01.jinja test_01b.expected test_01b.jinja test_01c.expected test_01c.jinja test_01d.expected test_01d.jinja test_02.expected test_02.jinja test_03.expected test_03.jinja test_04.expected test_04.jinja test_05.expected test_05.jinja test_06.expected test_06.jinja test_07.expected test_07.jinja test_08.expected test_08.jinja test_08b.expected test_08b.jinja test_09.expected test_09.jinja test_10.expected test_10.jinja test_11.expected test_11.jinja test_12.expected test_12.jinja test_13.expected test_13.jinja test_14.expected test_14.jinja test_15.expected test_15.jinja test_16.expected test_16.jinja test_17.expected test_17.jinja test_18.expected test_18.jinja test_18b.expected test_18b.jinja test_18c.expected test_18c.jinja test_19.expected test_19.jinja test_19b.expected test_19b.jinja test_19c.expected test_19c.jinja test_19d.expected test_19d.jinja test_19e.expected test_19e.jinja test_19f.expected test_19f.jinja test_20.expected test_20.jinja test_21.expected test_21.jinja test_22.expected test_22.jinja test_22a.expected test_22a.jinja test_22b.expected test_22b.jinja test_23.expected test_23.jinja test_24.expected test_24.jinjalibev
Changes LICENSE Makefile Makefile.am Makefile.in README Symbols.ev Symbols.event aclocal.m4 autogen.sh compile config.guess config.h config.h.in config.status config.sub configure configure.ac depcomp ev++.h ev.3 ev.c ev.h ev.pod ev_epoll.c ev_kqueue.c ev_poll.c ev_port.c ev_select.c ev_vars.h ev_win32.c ev_wrap.h event.c event.h install-sh libev.m4 libtool ltmain.sh missing mkinstalldirs stamp-h1luajit
doc
bluequad-print.css bluequad.css contact.html ext_buffer.html ext_c_api.html ext_ffi.html ext_ffi_api.html ext_ffi_semantics.html ext_ffi_tutorial.html ext_jit.html ext_profiler.html extensions.html install.html luajit.html running.htmldynasm
dasm_arm.h dasm_arm.lua dasm_arm64.h dasm_arm64.lua dasm_mips.h dasm_mips.lua dasm_mips64.lua dasm_ppc.h dasm_ppc.lua dasm_proto.h dasm_x64.lua dasm_x86.h dasm_x86.lua dynasm.luasrc
host
.gitignore README buildvm.c buildvm.h buildvm_asm.c buildvm_fold.c buildvm_lib.c buildvm_libbc.h buildvm_peobj.c genlibbc.lua genminilua.lua genversion.lua minilua.cjit
.gitignore bc.lua bcsave.lua dis_arm.lua dis_arm64.lua dis_arm64be.lua dis_mips.lua dis_mips64.lua dis_mips64el.lua dis_mips64r6.lua dis_mips64r6el.lua dis_mipsel.lua dis_ppc.lua dis_x64.lua dis_x86.lua dump.lua p.lua v.lua zone.luawolfssl
.github
workflows
ada.yml arduino.yml async-examples.yml async.yml atecc608-sim.yml bind.yml cmake-autoconf.yml cmake.yml codespell.yml coverity-scan-fixes.yml cryptocb-only.yml curl.yml cyrus-sasl.yml disable-pk-algs.yml docker-Espressif.yml docker-OpenWrt.yml emnet-nonblock.yml fil-c.yml freertos-mem-track.yml gencertbuf.yml grpc.yml haproxy.yml hostap-vm.yml intelasm-c-fallback.yml ipmitool.yml jwt-cpp.yml krb5.yml libspdm.yml libssh2.yml libvncserver.yml linuxkm.yml macos-apple-native-cert-validation.yml mbedtls.sh mbedtls.yml membrowse-comment.yml membrowse-onboard.yml membrowse-report.yml memcached.sh memcached.yml mono.yml mosquitto.yml msmtp.yml msys2.yml multi-arch.yml multi-compiler.yml net-snmp.yml nginx.yml no-malloc.yml no-tls.yml nss.sh nss.yml ntp.yml ocsp.yml openldap.yml openssh.yml openssl-ech.yml opensslcoexist.yml openvpn.yml os-check.yml packaging.yml pam-ipmi.yml pq-all.yml pr-commit-check.yml psk.yml puf.yml python.yml rng-tools.yml rust-wrapper.yml se050-sim.yml smallStackSize.yml socat.yml softhsm.yml sssd.yml stm32-sim.yml stsafe-a120-sim.yml stunnel.yml symbol-prefixes.yml threadx.yml tls-anvil.yml trackmemory.yml watcomc.yml win-csharp-test.yml wolfCrypt-Wconversion.yml wolfboot-integration.yml wolfsm.yml xcode.yml zephyr-4.x.yml zephyr.ymlIDE
ARDUINO
Arduino_README_prepend.md README.md include.am keywords.txt library.properties.template wolfssl-arduino.cpp wolfssl-arduino.sh wolfssl.hECLIPSE
Espressif
ESP-IDF
examples
template
CMakeLists.txt Makefile README.md partitions_singleapp_large.csv sdkconfig.defaults sdkconfig.defaults.esp8266wolfssl_benchmark
VisualGDB
wolfssl_benchmark_IDF_v4.4_ESP32.sln wolfssl_benchmark_IDF_v4.4_ESP32.vgdbproj wolfssl_benchmark_IDF_v5_ESP32.sln wolfssl_benchmark_IDF_v5_ESP32.vgdbproj wolfssl_benchmark_IDF_v5_ESP32C3.sln wolfssl_benchmark_IDF_v5_ESP32C3.vgdbproj wolfssl_benchmark_IDF_v5_ESP32S3.sln wolfssl_benchmark_IDF_v5_ESP32S3.vgdbprojwolfssl_client
CMakeLists.txt Makefile README.md README_server_sm.md partitions_singleapp_large.csv sdkconfig.defaults sdkconfig.defaults.esp32c2 sdkconfig.defaults.esp8266 wolfssl_client_ESP8266.vgdbprojwolfssl_server
CMakeLists.txt Makefile README.md README_server_sm.md partitions_singleapp_large.csv sdkconfig.defaults sdkconfig.defaults.esp32c2 sdkconfig.defaults.esp8266 wolfssl_server_ESP8266.vgdbprojwolfssl_test
VisualGDB
wolfssl_test-IDF_v5_ESP32.sln wolfssl_test-IDF_v5_ESP32.vgdbproj wolfssl_test-IDF_v5_ESP32C3.sln wolfssl_test-IDF_v5_ESP32C3.vgdbproj wolfssl_test-IDF_v5_ESP32C6.sln wolfssl_test-IDF_v5_ESP32C6.vgdbproj wolfssl_test_IDF_v5_ESP32S3.sln wolfssl_test_IDF_v5_ESP32S3.vgdbprojGCC-ARM
Makefile Makefile.bench Makefile.client Makefile.common Makefile.server Makefile.static Makefile.test README.md include.am linker.ld linker_fips.ldIAR-EWARM
embOS
SAMV71_XULT
embOS_SAMV71_XULT_user_settings
user_settings.h user_settings_simple_example.h user_settings_verbose_example.hembOS_wolfcrypt_benchmark_SAMV71_XULT
README_wolfcrypt_benchmark wolfcrypt_benchmark.ewd wolfcrypt_benchmark.ewpINTIME-RTOS
Makefile README.md include.am libwolfssl.c libwolfssl.vcxproj user_settings.h wolfExamples.c wolfExamples.h wolfExamples.sln wolfExamples.vcxproj wolfssl-lib.sln wolfssl-lib.vcxprojMQX
Makefile README-jp.md README.md client-tls.c include.am server-tls.c user_config.h user_settings.hMSVS-2019-AZSPHERE
wolfssl_new_azsphere
.gitignore CMakeLists.txt CMakeSettings.json app_manifest.json applibs_versions.h launch.vs.json main.cNETOS
Makefile.wolfcrypt.inc README.md include.am user_settings.h user_settings.h-cert2425 user_settings.h-cert3389 wolfssl_netos_custom.cPlatformIO
examples
wolfssl_benchmark
CMakeLists.txt README.md platformio.ini sdkconfig.defaults wolfssl_benchmark.code-workspaceROWLEY-CROSSWORKS-ARM
Kinetis_FlashPlacement.xml README.md arm_startup.c benchmark_main.c hw.h include.am kinetis_hw.c retarget.c test_main.c user_settings.h wolfssl.hzp wolfssl_ltc.hzpRenesas
e2studio
RA6M3
README.md README_APRA6M_en.md README_APRA6M_jp.md include.amRX72N
EnvisionKit
Simple
README_EN.md README_JP.mdwolfssl_demo
key_data.c key_data.h user_settings.h wolfssl_demo.c wolfssl_demo.h wolfssl_tsip_unit_test.cSTM32Cube
README.md STM32_Benchmarks.md default_conf.ftl include.am main.c wolfssl_example.c wolfssl_example.hWIN
README.txt include.am test.vcxproj user_settings.h user_settings_dtls.h wolfssl-fips.sln wolfssl-fips.vcxprojWIN-SRTP-KDF-140-3
README.txt include.am resource.h test.vcxproj user_settings.h wolfssl-fips.rc wolfssl-fips.sln wolfssl-fips.vcxprojWIN10
README.txt include.am resource.h test.vcxproj user_settings.h wolfssl-fips.rc wolfssl-fips.sln wolfssl-fips.vcxprojXCODE
Benchmark
include.amXilinxSDK
README.md bench.sh combine.sh eclipse_formatter_profile.xml graph.sh include.am user_settings.h wolfssl_example.capple-universal
wolfssl-multiplatform
iotsafe
Makefile README.md ca-cert.c devices.c devices.h include.am main.c memory-tls.c startup.c target.ld user_settings.hmynewt
README.md apps.wolfcrypttest.pkg.yml crypto.wolfssl.pkg.yml crypto.wolfssl.syscfg.yml include.am setup.shcerts
1024
ca-cert.der ca-cert.pem ca-key.der ca-key.pem client-cert.der client-cert.pem client-key.der client-key.pem client-keyPub.der dh1024.der dh1024.pem dsa-pub-1024.pem dsa1024.der dsa1024.pem include.am rsa1024.der server-cert.der server-cert.pem server-key.der server-key.pemcrl
extra-crls
ca-int-cert-revoked.pem claim-root.pem crl_critical_entry.pem crlnum_57oct.pem crlnum_64oct.pem general-server-crl.pem large_crlnum.pem large_crlnum2.pemdilithium
bench_dilithium_level2_key.der bench_dilithium_level3_key.der bench_dilithium_level5_key.der include.amecc
bp256r1-key.der bp256r1-key.pem ca-secp256k1-cert.pem ca-secp256k1-key.pem client-bp256r1-cert.der client-bp256r1-cert.pem client-secp256k1-cert.der client-secp256k1-cert.pem genecc.sh include.am secp256k1-key.der secp256k1-key.pem secp256k1-param.pem secp256k1-privkey.der secp256k1-privkey.pem server-bp256r1-cert.der server-bp256r1-cert.pem server-secp256k1-cert.der server-secp256k1-cert.pem server2-secp256k1-cert.der server2-secp256k1-cert.pem wolfssl.cnf wolfssl_384.cnfed25519
ca-ed25519-key.der ca-ed25519-key.pem ca-ed25519-priv.der ca-ed25519-priv.pem ca-ed25519.der ca-ed25519.pem client-ed25519-key.der client-ed25519-key.pem client-ed25519-priv.der client-ed25519-priv.pem client-ed25519.der client-ed25519.pem eddsa-ed25519.der eddsa-ed25519.pem gen-ed25519-certs.sh gen-ed25519-keys.sh gen-ed25519.sh include.am root-ed25519-key.der root-ed25519-key.pem root-ed25519-priv.der root-ed25519-priv.pem root-ed25519.der root-ed25519.pem server-ed25519-cert.pem server-ed25519-key.der server-ed25519-key.pem server-ed25519-priv.der server-ed25519-priv.pem server-ed25519.der server-ed25519.pemed448
ca-ed448-key.der ca-ed448-key.pem ca-ed448-priv.der ca-ed448-priv.pem ca-ed448.der ca-ed448.pem client-ed448-key.der client-ed448-key.pem client-ed448-priv.der client-ed448-priv.pem client-ed448.der client-ed448.pem gen-ed448-certs.sh gen-ed448-keys.sh include.am root-ed448-key.der root-ed448-key.pem root-ed448-priv.der root-ed448-priv.pem root-ed448.der root-ed448.pem server-ed448-cert.pem server-ed448-key.der server-ed448-key.pem server-ed448-priv.der server-ed448-priv.pem server-ed448.der server-ed448.pemexternal
DigiCertGlobalRootCA.pem README.txt ca-digicert-ev.pem ca-globalsign-root.pem ca-google-root.pem ca_collection.pem include.amintermediate
ca_false_intermediate
gentestcert.sh int_ca.key server.key test_ca.key test_ca.pem test_int_not_cacert.pem test_sign_bynoca_srv.pem wolfssl_base.conf wolfssl_srv.conflms
bc_hss_L2_H5_W8_root.der bc_hss_L3_H5_W4_root.der bc_lms_chain_ca.der bc_lms_chain_leaf.der bc_lms_native_bc_root.der bc_lms_sha256_h10_w8_root.der bc_lms_sha256_h5_w4_root.der include.ammldsa
README.txt include.am mldsa44-cert.der mldsa44-cert.pem mldsa44-key.pem mldsa44_bare-priv.der mldsa44_bare-seed.der mldsa44_oqskeypair.der mldsa44_priv-only.der mldsa44_pub-spki.der mldsa44_seed-only.der mldsa44_seed-priv.der mldsa65-cert.der mldsa65-cert.pem mldsa65-key.pem mldsa65_bare-priv.der mldsa65_bare-seed.der mldsa65_oqskeypair.der mldsa65_priv-only.der mldsa65_pub-spki.der mldsa65_seed-only.der mldsa65_seed-priv.der mldsa87-cert.der mldsa87-cert.pem mldsa87-key.pem mldsa87_bare-priv.der mldsa87_bare-seed.der mldsa87_oqskeypair.der mldsa87_priv-only.der mldsa87_pub-spki.der mldsa87_seed-only.der mldsa87_seed-priv.derocsp
imposter-root-ca-cert.der imposter-root-ca-cert.pem imposter-root-ca-key.der imposter-root-ca-key.pem include.am index-ca-and-intermediate-cas.txt index-ca-and-intermediate-cas.txt.attr index-intermediate1-ca-issued-certs.txt index-intermediate1-ca-issued-certs.txt.attr index-intermediate2-ca-issued-certs.txt index-intermediate2-ca-issued-certs.txt.attr index-intermediate3-ca-issued-certs.txt index-intermediate3-ca-issued-certs.txt.attr intermediate1-ca-cert.der intermediate1-ca-cert.pem intermediate1-ca-key.der intermediate1-ca-key.pem intermediate2-ca-cert.der intermediate2-ca-cert.pem intermediate2-ca-key.der intermediate2-ca-key.pem intermediate3-ca-cert.der intermediate3-ca-cert.pem intermediate3-ca-key.der intermediate3-ca-key.pem ocsp-responder-cert.der ocsp-responder-cert.pem ocsp-responder-key.der ocsp-responder-key.pem openssl.cnf renewcerts-for-test.sh renewcerts.sh root-ca-cert.der root-ca-cert.pem root-ca-crl.pem root-ca-key.der root-ca-key.pem server1-cert.der server1-cert.pem server1-chain-noroot.pem server1-key.der server1-key.pem server2-cert.der server2-cert.pem server2-key.der server2-key.pem server3-cert.der server3-cert.pem server3-key.der server3-key.pem server4-cert.der server4-cert.pem server4-key.der server4-key.pem server5-cert.der server5-cert.pem server5-key.der server5-key.pem test-leaf-response.der test-multi-response.der test-response-nointern.der test-response-rsapss.der test-response.derp521
ca-p521-key.der ca-p521-key.pem ca-p521-priv.der ca-p521-priv.pem ca-p521.der ca-p521.pem client-p521-key.der client-p521-key.pem client-p521-priv.der client-p521-priv.pem client-p521.der client-p521.pem gen-p521-certs.sh gen-p521-keys.sh include.am root-p521-key.der root-p521-key.pem root-p521-priv.der root-p521-priv.pem root-p521.der root-p521.pem server-p521-cert.pem server-p521-key.der server-p521-key.pem server-p521-priv.der server-p521-priv.pem server-p521.der server-p521.pemrpk
client-cert-rpk.der client-ecc-cert-rpk.der include.am server-cert-rpk.der server-ecc-cert-rpk.derrsapss
ca-3072-rsapss-key.der ca-3072-rsapss-key.pem ca-3072-rsapss-priv.der ca-3072-rsapss-priv.pem ca-3072-rsapss.der ca-3072-rsapss.pem ca-rsapss-key.der ca-rsapss-key.pem ca-rsapss-priv.der ca-rsapss-priv.pem ca-rsapss.der ca-rsapss.pem client-3072-rsapss-key.der client-3072-rsapss-key.pem client-3072-rsapss-priv.der client-3072-rsapss-priv.pem client-3072-rsapss.der client-3072-rsapss.pem client-rsapss-key.der client-rsapss-key.pem client-rsapss-priv.der client-rsapss-priv.pem client-rsapss.der client-rsapss.pem gen-rsapss-keys.sh include.am renew-rsapss-certs.sh root-3072-rsapss-key.der root-3072-rsapss-key.pem root-3072-rsapss-priv.der root-3072-rsapss-priv.pem root-3072-rsapss.der root-3072-rsapss.pem root-rsapss-key.der root-rsapss-key.pem root-rsapss-priv.der root-rsapss-priv.pem root-rsapss.der root-rsapss.pem server-3072-rsapss-cert.pem server-3072-rsapss-key.der server-3072-rsapss-key.pem server-3072-rsapss-priv.der server-3072-rsapss-priv.pem server-3072-rsapss.der server-3072-rsapss.pem server-mix-rsapss-cert.pem server-rsapss-cert.pem server-rsapss-key.der server-rsapss-key.pem server-rsapss-priv.der server-rsapss-priv.pem server-rsapss.der server-rsapss.pemslhdsa
bench_slhdsa_sha2_128f_key.der bench_slhdsa_sha2_128s_key.der bench_slhdsa_sha2_192f_key.der bench_slhdsa_sha2_192s_key.der bench_slhdsa_sha2_256f_key.der bench_slhdsa_sha2_256s_key.der bench_slhdsa_shake128f_key.der bench_slhdsa_shake128s_key.der bench_slhdsa_shake192f_key.der bench_slhdsa_shake192s_key.der bench_slhdsa_shake256f_key.der bench_slhdsa_shake256s_key.der client-mldsa44-priv.pem client-mldsa44-sha2.der client-mldsa44-sha2.pem client-mldsa44-shake.der client-mldsa44-shake.pem gen-slhdsa-mldsa-certs.sh include.am root-slhdsa-sha2-128s-priv.der root-slhdsa-sha2-128s-priv.pem root-slhdsa-sha2-128s.der root-slhdsa-sha2-128s.pem root-slhdsa-shake-128s-priv.der root-slhdsa-shake-128s-priv.pem root-slhdsa-shake-128s.der root-slhdsa-shake-128s.pem server-mldsa44-priv.pem server-mldsa44-sha2.der server-mldsa44-sha2.pem server-mldsa44-shake.der server-mldsa44-shake.pemsm2
ca-sm2-key.der ca-sm2-key.pem ca-sm2-priv.der ca-sm2-priv.pem ca-sm2.der ca-sm2.pem client-sm2-key.der client-sm2-key.pem client-sm2-priv.der client-sm2-priv.pem client-sm2.der client-sm2.pem fix_sm2_spki.py gen-sm2-certs.sh gen-sm2-keys.sh include.am root-sm2-key.der root-sm2-key.pem root-sm2-priv.der root-sm2-priv.pem root-sm2.der root-sm2.pem self-sm2-cert.pem self-sm2-key.pem self-sm2-priv.pem server-sm2-cert.der server-sm2-cert.pem server-sm2-key.der server-sm2-key.pem server-sm2-priv.der server-sm2-priv.pem server-sm2.der server-sm2.pemstatickeys
dh-ffdhe2048-params.pem dh-ffdhe2048-pub.der dh-ffdhe2048-pub.pem dh-ffdhe2048.der dh-ffdhe2048.pem ecc-secp256r1.der ecc-secp256r1.pem gen-static.sh include.am x25519-pub.der x25519-pub.pem x25519.der x25519.pemtest
catalog.txt cert-bad-neg-int.der cert-bad-oid.der cert-bad-utf8.der cert-ext-ia.cfg cert-ext-ia.der cert-ext-ia.pem cert-ext-joi.cfg cert-ext-joi.der cert-ext-joi.pem cert-ext-mnc.der cert-ext-multiple.cfg cert-ext-multiple.der cert-ext-multiple.pem cert-ext-nc-combined.der cert-ext-nc-combined.pem cert-ext-nc.cfg cert-ext-nc.der cert-ext-nc.pem cert-ext-ncdns.der cert-ext-ncdns.pem cert-ext-ncip.der cert-ext-ncip.pem cert-ext-ncmixed.der cert-ext-ncmulti.der cert-ext-ncmulti.pem cert-ext-ncrid.der cert-ext-ncrid.pem cert-ext-nct.cfg cert-ext-nct.der cert-ext-nct.pem cert-ext-ndir-exc.cfg cert-ext-ndir-exc.der cert-ext-ndir-exc.pem cert-ext-ndir.cfg cert-ext-ndir.der cert-ext-ndir.pem cert-ext-ns.der cert-over-max-altnames.cfg cert-over-max-altnames.der cert-over-max-altnames.pem cert-over-max-nc.cfg cert-over-max-nc.der cert-over-max-nc.pem client-ecc-cert-ski.hex cn-ip-literal.der cn-ip-wildcard.der crit-cert.pem crit-key.pem dh1024.der dh1024.pem dh512.der dh512.pem digsigku.pem encrypteddata.msg gen-badsig.sh gen-ext-certs.sh gen-testcerts.sh include.am kari-keyid-cms.msg ktri-keyid-cms.msg ossl-trusted-cert.pem server-badaltname.der server-badaltname.pem server-badaltnull.der server-badaltnull.pem server-badcn.der server-badcn.pem server-badcnnull.der server-badcnnull.pem server-cert-ecc-badsig.der server-cert-ecc-badsig.pem server-cert-rsa-badsig.der server-cert-rsa-badsig.pem server-duplicate-policy.pem server-garbage.der server-garbage.pem server-goodalt.der server-goodalt.pem server-goodaltwild.der server-goodaltwild.pem server-goodcn.der server-goodcn.pem server-goodcnwild.der server-goodcnwild.pem server-localhost.der server-localhost.pem smime-test-canon.p7s smime-test-multipart-badsig.p7s smime-test-multipart.p7s smime-test.p7stest-pathlen
assemble-chains.sh chainA-ICA1-key.pem chainA-ICA1-pathlen0.pem chainA-assembled.pem chainA-entity-key.pem chainA-entity.pem chainB-ICA1-key.pem chainB-ICA1-pathlen0.pem chainB-ICA2-key.pem chainB-ICA2-pathlen1.pem chainB-assembled.pem chainB-entity-key.pem chainB-entity.pem chainC-ICA1-key.pem chainC-ICA1-pathlen1.pem chainC-assembled.pem chainC-entity-key.pem chainC-entity.pem chainD-ICA1-key.pem chainD-ICA1-pathlen127.pem chainD-assembled.pem chainD-entity-key.pem chainD-entity.pem chainE-ICA1-key.pem chainE-ICA1-pathlen128.pem chainE-assembled.pem chainE-entity-key.pem chainE-entity.pem chainF-ICA1-key.pem chainF-ICA1-pathlen1.pem chainF-ICA2-key.pem chainF-ICA2-pathlen0.pem chainF-assembled.pem chainF-entity-key.pem chainF-entity.pem chainG-ICA1-key.pem chainG-ICA1-pathlen0.pem chainG-ICA2-key.pem chainG-ICA2-pathlen1.pem chainG-ICA3-key.pem chainG-ICA3-pathlen99.pem chainG-ICA4-key.pem chainG-ICA4-pathlen5.pem chainG-ICA5-key.pem chainG-ICA5-pathlen20.pem chainG-ICA6-key.pem chainG-ICA6-pathlen10.pem chainG-ICA7-key.pem chainG-ICA7-pathlen100.pem chainG-assembled.pem chainG-entity-key.pem chainG-entity.pem chainH-ICA1-key.pem chainH-ICA1-pathlen0.pem chainH-ICA2-key.pem chainH-ICA2-pathlen2.pem chainH-ICA3-key.pem chainH-ICA3-pathlen2.pem chainH-ICA4-key.pem chainH-ICA4-pathlen2.pem chainH-assembled.pem chainH-entity-key.pem chainH-entity.pem chainI-ICA1-key.pem chainI-ICA1-no_pathlen.pem chainI-ICA2-key.pem chainI-ICA2-no_pathlen.pem chainI-ICA3-key.pem chainI-ICA3-pathlen2.pem chainI-assembled.pem chainI-entity-key.pem chainI-entity.pem chainJ-ICA1-key.pem chainJ-ICA1-no_pathlen.pem chainJ-ICA2-key.pem chainJ-ICA2-no_pathlen.pem chainJ-ICA3-key.pem chainJ-ICA3-no_pathlen.pem chainJ-ICA4-key.pem chainJ-ICA4-pathlen2.pem chainJ-assembled.pem chainJ-entity-key.pem chainJ-entity.pem include.am refreshkeys.shtest-serial0
ee_normal.pem ee_serial0.pem generate_certs.sh include.am intermediate_serial0.pem root_serial0.pem root_serial0_key.pem selfsigned_nonca_serial0.pemxmss
bc_xmss_chain_ca.der bc_xmss_chain_leaf.der bc_xmss_sha2_10_256_root.der bc_xmss_sha2_16_256_root.der bc_xmssmt_sha2_20_2_256_root.der bc_xmssmt_sha2_20_4_256_root.der bc_xmssmt_sha2_40_8_256_root.der include.amcmake
Config.cmake.in README.md config.in functions.cmake include.am options.h.in wolfssl-config-version.cmake.in wolfssl-targets.cmake.indebian
changelog.in control.in copyright include.am libwolfssl-dev.install libwolfssl.install rules.indoc
dox_comments
header_files
aes.h arc4.h ascon.h asn.h asn_public.h blake2.h bn.h camellia.h chacha.h chacha20_poly1305.h cmac.h coding.h compress.h cryptocb.h curve25519.h curve448.h des3.h dh.h doxygen_groups.h doxygen_pages.h dsa.h ecc.h eccsi.h ed25519.h ed448.h error-crypt.h evp.h hash.h hmac.h iotsafe.h kdf.h logging.h md2.h md4.h md5.h memory.h ocsp.h pem.h pkcs11.h pkcs7.h poly1305.h psa.h puf.h pwdbased.h quic.h random.h ripemd.h rsa.h sakke.h sha.h sha256.h sha3.h sha512.h signature.h siphash.h srp.h ssl.h tfm.h types.h wc_encrypt.h wc_port.h wc_she.h wc_slhdsa.h wolfio.hheader_files-ja
aes.h arc4.h ascon.h asn.h asn_public.h blake2.h bn.h camellia.h chacha.h chacha20_poly1305.h cmac.h coding.h compress.h cryptocb.h curve25519.h curve448.h des3.h dh.h doxygen_groups.h doxygen_pages.h dsa.h ecc.h eccsi.h ed25519.h ed448.h error-crypt.h evp.h hash.h hmac.h iotsafe.h kdf.h logging.h md2.h md4.h md5.h memory.h ocsp.h pem.h pkcs11.h pkcs7.h poly1305.h psa.h pwdbased.h quic.h random.h ripemd.h rsa.h sakke.h sha.h sha256.h sha3.h sha512.h signature.h siphash.h srp.h ssl.h tfm.h types.h wc_encrypt.h wc_port.h wolfio.hexamples
async
Makefile README.md async_client.c async_server.c async_tls.c async_tls.h include.am user_settings.hconfigs
README.md include.am user_settings_EBSnet.h user_settings_all.h user_settings_arduino.h user_settings_baremetal.h user_settings_ca.h user_settings_curve25519nonblock.h user_settings_dtls13.h user_settings_eccnonblock.h user_settings_espressif.h user_settings_fipsv2.h user_settings_fipsv5.h user_settings_min_ecc.h user_settings_openssl_compat.h user_settings_pkcs7.h user_settings_platformio.h user_settings_pq.h user_settings_rsa_only.h user_settings_stm32.h user_settings_template.h user_settings_tls12.h user_settings_tls13.h user_settings_wolfboot_keytools.h user_settings_wolfssh.h user_settings_wolftpm.hechoclient
echoclient.c echoclient.h echoclient.sln echoclient.vcproj echoclient.vcxproj include.am quitlinuxkm
Kbuild Makefile README.md get_thread_size.c include.am linuxkm-fips-hash-wrapper.sh linuxkm-fips-hash.c linuxkm_memory.c linuxkm_memory.h linuxkm_wc_port.h lkcapi_aes_glue.c lkcapi_dh_glue.c lkcapi_ecdh_glue.c lkcapi_ecdsa_glue.c lkcapi_glue.c lkcapi_rsa_glue.c lkcapi_sha_glue.c module_exports.c.template module_hooks.c pie_redirect_table.c wolfcrypt.lds x86_vector_register_glue.cm4
ax_add_am_macro.m4 ax_am_jobserver.m4 ax_am_macros.m4 ax_append_compile_flags.m4 ax_append_flag.m4 ax_append_link_flags.m4 ax_append_to_file.m4 ax_atomic.m4 ax_bsdkm.m4 ax_check_compile_flag.m4 ax_check_link_flag.m4 ax_compiler_version.m4 ax_count_cpus.m4 ax_create_generic_config.m4 ax_debug.m4 ax_file_escapes.m4 ax_harden_compiler_flags.m4 ax_linuxkm.m4 ax_print_to_file.m4 ax_pthread.m4 ax_require_defined.m4 ax_tls.m4 ax_vcs_checkout.m4 hexversion.m4 lib_socket_nsl.m4 visibility.m4mqx
wolfcrypt_benchmark
ReferencedRSESystems.xml wolfcrypt_benchmark_twrk70f120m_Int_Flash_DDRData_Debug_PnE_U-MultiLink.launch wolfcrypt_benchmark_twrk70f120m_Int_Flash_DDRData_Release_PnE_U-MultiLink.launch wolfcrypt_benchmark_twrk70f120m_Int_Flash_SramData_Debug_JTrace.jlink wolfcrypt_benchmark_twrk70f120m_Int_Flash_SramData_Debug_JTrace.launch wolfcrypt_benchmark_twrk70f120m_Int_Flash_SramData_Debug_PnE_U-MultiLink.launch wolfcrypt_benchmark_twrk70f120m_Int_Flash_SramData_Release_PnE_U-MultiLink.launchwolfcrypt_test
ReferencedRSESystems.xml wolfcrypt_test_twrk70f120m_Int_Flash_DDRData_Debug_PnE_U-MultiLink.launch wolfcrypt_test_twrk70f120m_Int_Flash_DDRData_Release_PnE_U-MultiLink.launch wolfcrypt_test_twrk70f120m_Int_Flash_SramData_Debug_JTrace.jlink wolfcrypt_test_twrk70f120m_Int_Flash_SramData_Debug_JTrace.launch wolfcrypt_test_twrk70f120m_Int_Flash_SramData_Debug_PnE_U-MultiLink.launch wolfcrypt_test_twrk70f120m_Int_Flash_SramData_Release_PnE_U-MultiLink.launchwolfssl_client
ReferencedRSESystems.xml wolfssl_client_twrk70f120m_Int_Flash_DDRData_Debug_PnE_U-MultiLink.launch wolfssl_client_twrk70f120m_Int_Flash_DDRData_Release_PnE_U-MultiLink.launch wolfssl_client_twrk70f120m_Int_Flash_SramData_Debug_JTrace.jlink wolfssl_client_twrk70f120m_Int_Flash_SramData_Debug_JTrace.launch wolfssl_client_twrk70f120m_Int_Flash_SramData_Debug_PnE_U-MultiLink.launch wolfssl_client_twrk70f120m_Int_Flash_SramData_Release_PnE_U-MultiLink.launchscripts
aria-cmake-build-test.sh asn1_oid_sum.pl benchmark.test benchmark_compare.sh cleanup_testfiles.sh crl-gen-openssl.test crl-revoked.test dertoc.pl dtls.test dtlscid.test external.test google.test include.am makedistsmall.sh memtest.sh ocsp-responder-openssl-interop.test ocsp-stapling-with-ca-as-responder.test ocsp-stapling-with-wolfssl-responder.test ocsp-stapling.test ocsp-stapling2.test ocsp-stapling_tls13multi.test ocsp.test openssl.test openssl_srtp.test pem.test ping.test pkcallbacks.test psk.test resume.test rsapss.test sniffer-gen.sh sniffer-ipv6.pcap sniffer-static-rsa.pcap sniffer-testsuite.test sniffer-tls12-keylog.out sniffer-tls12-keylog.pcap sniffer-tls12-keylog.sslkeylog sniffer-tls13-dh-resume.pcap sniffer-tls13-dh.pcap sniffer-tls13-ecc-resume.pcap sniffer-tls13-ecc.pcap sniffer-tls13-hrr.pcap sniffer-tls13-keylog.out sniffer-tls13-keylog.pcap sniffer-tls13-keylog.sslkeylog sniffer-tls13-x25519-resume.pcap sniffer-tls13-x25519.pcap stm32l4-v4_0_1_build.sh tls13.test trusted_peer.test unit.test.in user_settings_asm.shsrc
bio.c conf.c crl.c dtls.c dtls13.c include.am internal.c keys.c ocsp.c pk.c pk_ec.c pk_rsa.c quic.c sniffer.c ssl.c ssl_api_cert.c ssl_api_crl_ocsp.c ssl_api_pk.c ssl_asn1.c ssl_bn.c ssl_certman.c ssl_crypto.c ssl_ech.c ssl_load.c ssl_misc.c ssl_p7p12.c ssl_sess.c ssl_sk.c tls.c tls13.c wolfio.c x509.c x509_str.ctests
api
api.h api_decl.h create_ocsp_test_blobs.py include.am test_aes.c test_aes.h test_arc4.c test_arc4.h test_ascon.c test_ascon.h test_ascon_kats.h test_asn.c test_asn.h test_blake2.c test_blake2.h test_camellia.c test_camellia.h test_certman.c test_certman.h test_chacha.c test_chacha.h test_chacha20_poly1305.c test_chacha20_poly1305.h test_cmac.c test_cmac.h test_curve25519.c test_curve25519.h test_curve448.c test_curve448.h test_des3.c test_des3.h test_dh.c test_dh.h test_digest.h test_dsa.c test_dsa.h test_dtls.c test_dtls.h test_ecc.c test_ecc.h test_ed25519.c test_ed25519.h test_ed448.c test_ed448.h test_evp.c test_evp.h test_evp_cipher.c test_evp_cipher.h test_evp_digest.c test_evp_digest.h test_evp_pkey.c test_evp_pkey.h test_hash.c test_hash.h test_hmac.c test_hmac.h test_md2.c test_md2.h test_md4.c test_md4.h test_md5.c test_md5.h test_mldsa.c test_mldsa.h test_mlkem.c test_mlkem.h test_ocsp.c test_ocsp.h test_ocsp_test_blobs.h test_ossl_asn1.c test_ossl_asn1.h test_ossl_bio.c test_ossl_bio.h test_ossl_bn.c test_ossl_bn.h test_ossl_cipher.c test_ossl_cipher.h test_ossl_dgst.c test_ossl_dgst.h test_ossl_dh.c test_ossl_dh.h test_ossl_dsa.c test_ossl_dsa.h test_ossl_ec.c test_ossl_ec.h test_ossl_ecx.c test_ossl_ecx.h test_ossl_mac.c test_ossl_mac.h test_ossl_obj.c test_ossl_obj.h test_ossl_p7p12.c test_ossl_p7p12.h test_ossl_pem.c test_ossl_pem.h test_ossl_rand.c test_ossl_rand.h test_ossl_rsa.c test_ossl_rsa.h test_ossl_sk.c test_ossl_sk.h test_ossl_x509.c test_ossl_x509.h test_ossl_x509_acert.c test_ossl_x509_acert.h test_ossl_x509_crypto.c test_ossl_x509_crypto.h test_ossl_x509_ext.c test_ossl_x509_ext.h test_ossl_x509_info.c test_ossl_x509_info.h test_ossl_x509_io.c test_ossl_x509_io.h test_ossl_x509_lu.c test_ossl_x509_lu.h test_ossl_x509_name.c test_ossl_x509_name.h test_ossl_x509_pk.c test_ossl_x509_pk.h test_ossl_x509_str.c test_ossl_x509_str.h test_ossl_x509_vp.c test_ossl_x509_vp.h test_pkcs12.c test_pkcs12.h test_pkcs7.c test_pkcs7.h test_poly1305.c test_poly1305.h test_random.c test_random.h test_rc2.c test_rc2.h test_ripemd.c test_ripemd.h test_rsa.c test_rsa.h test_sha.c test_sha.h test_sha256.c test_sha256.h test_sha3.c test_sha3.h test_sha512.c test_sha512.h test_she.c test_she.h test_signature.c test_signature.h test_slhdsa.c test_slhdsa.h test_sm2.c test_sm2.h test_sm3.c test_sm3.h test_sm4.c test_sm4.h test_tls.c test_tls.h test_tls13.c test_tls13.h test_tls_ext.c test_tls_ext.h test_wc_encrypt.c test_wc_encrypt.h test_wolfmath.c test_wolfmath.h test_x509.c test_x509.hwolfcrypt
benchmark
README.md benchmark-VS2022.sln benchmark-VS2022.vcxproj benchmark-VS2022.vcxproj.user benchmark.c benchmark.h benchmark.sln benchmark.vcproj benchmark.vcxproj include.amsrc
port
Espressif
esp_crt_bundle
README.md cacrt_all.pem cacrt_deprecated.pem cacrt_local.pem esp_crt_bundle.c gen_crt_bundle.py pio_install_cryptography.pyRenesas
README.md renesas_common.c renesas_fspsm_aes.c renesas_fspsm_rsa.c renesas_fspsm_sha.c renesas_fspsm_util.c renesas_rx64_hw_sha.c renesas_rx64_hw_util.c renesas_tsip_aes.c renesas_tsip_rsa.c renesas_tsip_sha.c renesas_tsip_util.carm
armv8-32-aes-asm.S armv8-32-aes-asm_c.c armv8-32-chacha-asm.S armv8-32-chacha-asm_c.c armv8-32-curve25519.S armv8-32-curve25519_c.c armv8-32-mlkem-asm.S armv8-32-mlkem-asm_c.c armv8-32-poly1305-asm.S armv8-32-poly1305-asm_c.c armv8-32-sha256-asm.S armv8-32-sha256-asm_c.c armv8-32-sha3-asm.S armv8-32-sha3-asm_c.c armv8-32-sha512-asm.S armv8-32-sha512-asm_c.c armv8-aes-asm.S armv8-aes-asm_c.c armv8-aes.c armv8-chacha-asm.S armv8-chacha-asm_c.c armv8-curve25519.S armv8-curve25519_c.c armv8-mlkem-asm.S armv8-mlkem-asm_c.c armv8-poly1305-asm.S armv8-poly1305-asm_c.c armv8-sha256-asm.S armv8-sha256-asm_c.c armv8-sha256.c armv8-sha3-asm.S armv8-sha3-asm_c.c armv8-sha512-asm.S armv8-sha512-asm_c.c armv8-sha512.c cryptoCell.c cryptoCellHash.c thumb2-aes-asm.S thumb2-aes-asm_c.c thumb2-chacha-asm.S thumb2-chacha-asm_c.c thumb2-curve25519.S thumb2-curve25519_c.c thumb2-mlkem-asm.S thumb2-mlkem-asm_c.c thumb2-poly1305-asm.S thumb2-poly1305-asm_c.c thumb2-sha256-asm.S thumb2-sha256-asm_c.c thumb2-sha3-asm.S thumb2-sha3-asm_c.c thumb2-sha512-asm.S thumb2-sha512-asm_c.ccaam
README.md caam_aes.c caam_doc.pdf caam_driver.c caam_error.c caam_integrity.c caam_qnx.c caam_sha.c wolfcaam_aes.c wolfcaam_cmac.c wolfcaam_ecdsa.c wolfcaam_fsl_nxp.c wolfcaam_hash.c wolfcaam_hmac.c wolfcaam_init.c wolfcaam_qnx.c wolfcaam_rsa.c wolfcaam_seco.c wolfcaam_x25519.cdevcrypto
README.md devcrypto_aes.c devcrypto_ecdsa.c devcrypto_hash.c devcrypto_hmac.c devcrypto_rsa.c devcrypto_x25519.c wc_devcrypto.criscv
riscv-64-aes.c riscv-64-chacha.c riscv-64-poly1305.c riscv-64-sha256.c riscv-64-sha3.c riscv-64-sha512.cwolfssl
openssl
aes.h asn1.h asn1t.h bio.h bn.h buffer.h camellia.h cmac.h cms.h compat_types.h conf.h crypto.h des.h dh.h dsa.h ec.h ec25519.h ec448.h ecdh.h ecdsa.h ed25519.h ed448.h engine.h err.h evp.h fips_rand.h hmac.h include.am kdf.h lhash.h md4.h md5.h modes.h obj_mac.h objects.h ocsp.h opensslconf.h opensslv.h ossl_typ.h pem.h pkcs12.h pkcs7.h rand.h rc4.h ripemd.h rsa.h safestack.h sha.h sha3.h srp.h ssl.h ssl23.h stack.h tls1.h txt_db.h ui.h x509.h x509_vfy.h x509v3.hwolfcrypt
port
Renesas
renesas-fspsm-crypt.h renesas-fspsm-types.h renesas-rx64-hw-crypt.h renesas-tsip-crypt.h renesas_cmn.h renesas_fspsm_internal.h renesas_sync.h renesas_tsip_internal.h renesas_tsip_types.hcaam
caam_driver.h caam_error.h caam_qnx.h wolfcaam.h wolfcaam_aes.h wolfcaam_cmac.h wolfcaam_ecdsa.h wolfcaam_fsl_nxp.h wolfcaam_hash.h wolfcaam_qnx.h wolfcaam_rsa.h wolfcaam_seco.h wolfcaam_sha.h wolfcaam_x25519.hwrapper
Ada
examples
src
aes_verify_main.adb rsa_verify_main.adb sha256_main.adb spark_sockets.adb spark_sockets.ads spark_terminal.adb spark_terminal.ads tls_client.adb tls_client.ads tls_client_main.adb tls_server.adb tls_server.ads tls_server_main.adbtests
src
aes_bindings_tests.adb aes_bindings_tests.ads rsa_verify_bindings_tests.adb rsa_verify_bindings_tests.ads sha256_bindings_tests.adb sha256_bindings_tests.ads tests.adbCSharp
wolfSSL-Example-IOCallbacks
App.config wolfSSL-Example-IOCallbacks.cs wolfSSL-Example-IOCallbacks.csprojwolfSSL-TLS-ServerThreaded
App.config wolfSSL-TLS-ServerThreaded.cs wolfSSL-TLS-ServerThreaded.csprojrust
wolfssl-wolfcrypt
src
aes.rs blake2.rs chacha20_poly1305.rs cmac.rs cmac_mac.rs curve25519.rs dh.rs dilithium.rs ecc.rs ecdsa.rs ed25519.rs ed448.rs fips.rs hkdf.rs hmac.rs hmac_mac.rs kdf.rs lib.rs lms.rs mlkem.rs mlkem_kem.rs pbkdf2_password_hash.rs prf.rs random.rs rsa.rs rsa_pkcs1v15.rs sha.rs sha_digest.rs sys.rstests
test_aes.rs test_blake2.rs test_chacha20_poly1305.rs test_cmac.rs test_cmac_mac.rs test_curve25519.rs test_dh.rs test_dilithium.rs test_ecc.rs test_ecdsa.rs test_ed25519.rs test_ed448.rs test_hkdf.rs test_hmac.rs test_hmac_mac.rs test_kdf.rs test_lms.rs test_mlkem.rs test_mlkem_kem.rs test_pbkdf2_password_hash.rs test_prf.rs test_random.rs test_rsa.rs test_rsa_pkcs1v15.rs test_sha.rs test_sha_digest.rs test_wolfcrypt.rszephyr
samples
wolfssl_benchmark
CMakeLists.txt README install_test.sh prj.conf sample.yaml zephyr_legacy.conf zephyr_v4.1.confwolfssl_test
CMakeLists.txt README install_test.sh prj-no-malloc.conf prj.conf sample.yaml zephyr_legacy.conf zephyr_v4.1.conf
wolfssl/wolfcrypt/src/wc_port.c
raw
1/* port.c
2 *
3 * Copyright (C) 2006-2026 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#if (defined(__linux__) || defined(__ANDROID__)) && \
23 !defined(WOLFSSL_LINUXKM) && !defined(WOLFSSL_ZEPHYR) && \
24 !defined(_GNU_SOURCE)
25 #define _GNU_SOURCE 1
26#elif defined(__FreeBSD__)
27 /* for __FreeBSD_version */
28 #include <sys/param.h>
29#endif
30
31/*
32wolfCrypt Porting Build Options:
33
34Threading/Mutex options:
35 * SINGLE_THREADED: No-op mutex/threading implementations default: off
36 * WOLFSSL_PTHREADS: Use pthread-based mutex/threading default: off
37 * (auto-detected on most POSIX systems)
38 * WOLFSSL_MUTEX_INITIALIZER: Use static mutex initialization default: off
39 * WC_MUTEX_OPS_INLINE: Use inlined mutex operations default: off
40 * WOLFSSL_USER_MUTEX: User-provided mutex implementation default: off
41 * WOLFSSL_COND: Enable condition variable support default: off
42 * WOLFSSL_USE_RWLOCK: Enable reader-writer lock support default: off
43 * WOLFSSL_THREAD_NO_JOIN: Create threads without join default: off
44 * WOLFSSL_ALGO_HW_MUTEX: Per-algorithm hardware mutex locks default: off
45 * Controls AES, hash, PK, and RNG mutexes.
46 * WOLFSSL_CRYPT_HW_MUTEX: Cryptography hardware mutex default: off
47 * Master control for all HW mutex init.
48 * NO_AES_MUTEX: Disable AES hardware mutex default: off
49 * NO_HASH_MUTEX: Disable hash hardware mutex default: off
50 * NO_PK_MUTEX: Disable public-key hardware mutex default: off
51 * NO_RNG_MUTEX: Disable RNG hardware mutex default: off
52 *
53 * Memory options:
54 * USE_WOLFSSL_MEMORY: Enable custom memory allocation hooks default: on
55 * WOLFSSL_STATIC_MEMORY: Use static memory pools instead of default: off
56 * dynamic allocation.
57 * WOLFSSL_TRACK_MEMORY: Enable memory allocation tracking default: off
58 * WOLFSSL_TRACK_MEMORY_VERBOSE: Verbose memory tracking output default: off
59 * WOLFSSL_FORCE_MALLOC_FAIL_TEST: Force malloc failures for default: off
60 * testing error handling paths.
61 * WOLFSSL_MEM_FAIL_COUNT: Count malloc failures for testing default: off
62 * WOLFSSL_CHECK_MEM_ZERO: Verify sensitive memory is zeroed default: off
63 * on free. Debug tool for key material.
64 *
65 * Filesystem options:
66 * NO_FILESYSTEM: Disable all filesystem operations default: off
67 * NO_WOLFSSL_DIR: Disable directory listing/iteration default: off
68 *
69 * Time options:
70 * WOLFSSL_GMTIME: Provide custom gmtime implementation default: off
71 * HAVE_TIME_T_TYPE: Platform provides time_t default: auto
72 * TIME_OVERRIDES: Application provides custom time funcs default: off
73 * USER_TICKS: Application provides tick counter default: off
74 * USE_WOLF_TM: Use wolfSSL struct tm definition default: off
75 *
76 * String function options:
77 * STRING_USER: User provides all string functions default: off
78 * USE_WOLF_STRTOK: Use wolfSSL strtok implementation default: off
79 * USE_WOLF_STRSEP: Use wolfSSL strsep implementation default: off
80 * USE_WOLF_STRLCPY: Use wolfSSL strlcpy implementation default: off
81 * USE_WOLF_STRLCAT: Use wolfSSL strlcat implementation default: off
82 * USE_WOLF_STRCASECMP: Use wolfSSL strcasecmp implementation default: off
83 * USE_WOLF_STRNCASECMP:Use wolfSSL strncasecmp implementation default: off
84 * USE_WOLF_STRDUP: Use wolfSSL strdup implementation default: off
85 *
86 * Atomic operation options:
87 * WOLFSSL_ATOMIC_OPS: Enable atomic operations for thread default: off
88 * safety without full mutexes.
89 * WOLFSSL_USER_DEFINED_ATOMICS: User-provided atomic impl default: off
90 * WOLFSSL_HAVE_ATOMIC_H: Has C11 atomic.h header default: off
91 *
92 * General options:
93 * WOLFCRYPT_ONLY: Exclude TLS/SSL, wolfCrypt only build default: off
94 * WOLFSSL_LEANPSK: Lean PSK build, minimal features default: off
95 * WOLF_C89: C89 compatibility mode default: off
96 * WOLFSSL_SMALL_STACK: Reduce stack usage by allocating from default: off
97 * heap instead. Slower but needed for
98 * constrained environments.
99 * DEBUG_WOLFSSL_VERBOSE: Enable verbose debug logging default: off
100 */
101
102#include <wolfssl/wolfcrypt/libwolfssl_sources.h>
103
104#ifdef __APPLE__
105 #include <AvailabilityMacros.h>
106#endif
107
108#include <wolfssl/wolfcrypt/cpuid.h>
109#ifdef HAVE_ENTROPY_MEMUSE
110 #include <wolfssl/wolfcrypt/wolfentropy.h>
111#endif
112#ifdef HAVE_ECC
113 #include <wolfssl/wolfcrypt/ecc.h>
114#endif
115#ifdef WOLFSSL_ASYNC_CRYPT
116 #include <wolfssl/wolfcrypt/async.h>
117#endif
118#if defined(HAVE_HASHDRBG) && !defined(WC_NO_RNG)
119 #include <wolfssl/wolfcrypt/random.h>
120#endif
121
122#ifdef FREESCALE_LTC_TFM
123 #include <wolfssl/wolfcrypt/port/nxp/ksdk_port.h>
124#endif
125
126#if defined(WOLFSSL_MAX3266X) || defined(WOLFSSL_MAX3266X_OLD)
127 #include <wolfssl/wolfcrypt/port/maxim/max3266x.h>
128#ifdef WOLF_CRYPTO_CB
129 #include <wolfssl/wolfcrypt/port/maxim/max3266x-cryptocb.h>
130#endif
131#endif
132
133#ifdef WOLFSSL_PSOC6_CRYPTO
134 #include <wolfssl/wolfcrypt/port/cypress/psoc6_crypto.h>
135#endif
136
137#ifdef MAXQ10XX_MODULE_INIT
138 #include <wolfssl/wolfcrypt/port/maxim/maxq10xx.h>
139#endif
140
141#if defined(WOLFSSL_ATMEL) || defined(WOLFSSL_ATECC508A) || \
142 defined(WOLFSSL_ATECC608A) || \
143 defined(WOLFSSL_MICROCHIP_TA100)
144 #include <wolfssl/wolfcrypt/port/atmel/atmel.h>
145#endif
146#if defined(WOLFSSL_RENESAS_TSIP)
147 #include <wolfssl/wolfcrypt/port/Renesas/renesas_tsip_internal.h>
148#endif
149#if defined(WOLFSSL_RENESAS_FSPSM)
150 #include <wolfssl/wolfcrypt/port/Renesas/renesas_fspsm_internal.h>
151#endif
152#if defined(WOLFSSL_RENESAS_RX64_HASH)
153 #include <wolfssl/wolfcrypt/port/Renesas/renesas-rx64-hw-crypt.h>
154#endif
155#ifdef WOLFSSL_STSAFE
156 #include <wolfssl/wolfcrypt/port/st/stsafe.h>
157#endif
158
159#if defined(WOLFSSL_TROPIC01)
160 #include <wolfssl/wolfcrypt/port/tropicsquare/tropic01.h>
161#endif
162
163#if (defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER)) \
164 && !defined(WOLFCRYPT_ONLY)
165 #include <wolfssl/openssl/evp.h>
166#endif
167
168#include <wolfssl/wolfcrypt/memory.h>
169#if defined(USE_WOLFSSL_MEMORY) && defined(WOLFSSL_TRACK_MEMORY)
170 #include <wolfssl/wolfcrypt/mem_track.h>
171#endif
172
173#if defined(WOLFSSL_CAAM)
174 #include <wolfssl/wolfcrypt/port/caam/wolfcaam.h>
175#endif
176#if defined(HAVE_ARIA)
177 #include <wolfssl/wolfcrypt/port/aria/aria-cryptocb.h>
178#endif
179#if defined(WOLFSSL_DEVCRYPTO)
180 #include <wolfssl/wolfcrypt/port/devcrypto/wc_devcrypto.h>
181#endif
182#ifdef WOLFSSL_IMXRT_DCP
183 #include <wolfssl/wolfcrypt/port/nxp/dcp_port.h>
184#endif
185
186#ifdef WOLFSSL_NXP_CASPER
187 #include <wolfssl/wolfcrypt/port/nxp/casper_port.h>
188#endif
189#ifdef WOLFSSL_NXP_HASHCRYPT
190 #include <wolfssl/wolfcrypt/port/nxp/hashcrypt_port.h>
191#endif
192
193#ifdef WOLF_CRYPTO_CB
194 #include <wolfssl/wolfcrypt/cryptocb.h>
195#endif
196
197#ifdef HAVE_INTEL_QA_SYNC
198 #include <wolfssl/wolfcrypt/port/intel/quickassist_sync.h>
199#endif
200
201#ifdef HAVE_CAVIUM_OCTEON_SYNC
202 #include <wolfssl/wolfcrypt/port/cavium/cavium_octeon_sync.h>
203#endif
204
205#if defined(WOLFSSL_SE050) && defined(WOLFSSL_SE050_INIT)
206#include <wolfssl/wolfcrypt/port/nxp/se050_port.h>
207#endif
208
209#ifdef WOLFSSL_SCE
210 #include "hal_data.h"
211#endif
212
213#if defined(WOLFSSL_DSP) && !defined(WOLFSSL_DSP_BUILD)
214 #include "rpcmem.h"
215#endif
216
217#ifdef _MSC_VER
218 /* 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy */
219 #pragma warning(disable: 4996)
220#endif
221
222#if defined(WOLFSSL_HAVE_PSA)
223 #include <wolfssl/wolfcrypt/port/psa/psa.h>
224#endif
225
226#if defined(HAVE_LIBOQS)
227 #include <wolfssl/wolfcrypt/port/liboqs/liboqs.h>
228#endif
229
230#if defined(FREERTOS) && defined(WOLFSSL_ESPIDF)
231 #include <freertos/FreeRTOS.h>
232 #include <freertos/task.h>
233 /* The Espressif-specific platform include: */
234 #include <pthread.h>
235#endif
236
237#if defined(WOLFSSL_ZEPHYR)
238#if defined(CONFIG_BOARD_NATIVE_POSIX) || defined(CONFIG_BOARD_NATIVE_SIM)
239#include "native_rtc.h"
240#define CONFIG_RTC
241#endif
242#endif
243
244/* prevent multiple mutex initializations */
245#ifdef WOLFSSL_ATOMIC_OPS
246 wolfSSL_Atomic_Int initRefCount = WOLFSSL_ATOMIC_INITIALIZER(0);
247#else
248 static int initRefCount = 0;
249#endif
250
251#if defined(__aarch64__) && defined(WOLFSSL_ARMASM_BARRIER_DETECT)
252int aarch64_use_sb = 0;
253#endif
254
255/* Used to initialize state for wolfcrypt
256 return 0 on success
257 */
258WOLFSSL_ABI
259int wolfCrypt_Init(void)
260{
261 int ret = 0;
262 int my_initRefCount = wolfSSL_Atomic_Int_FetchAdd(&initRefCount, 1);
263 if (my_initRefCount == 0) {
264 WOLFSSL_ENTER("wolfCrypt_Init");
265
266 #if defined(__aarch64__) && defined(WOLFSSL_ARMASM_BARRIER_DETECT)
267 aarch64_use_sb = IS_AARCH64_SB(cpuid_get_flags());
268 #endif
269
270 #ifdef WOLFSSL_CHECK_MEM_ZERO
271 /* Initialize the mutex for access to the list of memory locations that
272 * must be freed. */
273 wc_MemZero_Init();
274 #endif
275 #ifdef WOLFSSL_MEM_FAIL_COUNT
276 wc_MemFailCount_Init();
277 #endif
278
279 #ifdef WOLFSSL_FORCE_MALLOC_FAIL_TEST
280 {
281 word32 rngMallocFail;
282 time_t seed = time(NULL);
283 srand((word32)seed);
284 rngMallocFail = rand() % 2000; /* max 2000 */
285 fprintf(stderr, "\n--- RNG MALLOC FAIL AT %u ---\n", rngMallocFail);
286 wolfSSL_SetMemFailCount(rngMallocFail);
287 }
288 #endif
289
290 #ifdef WOLF_CRYPTO_CB
291 wc_CryptoCb_Init();
292 #endif
293
294 #ifdef WOLFSSL_ASYNC_CRYPT
295 ret = wolfAsync_HardwareStart();
296 if (ret != 0) {
297 WOLFSSL_MSG("Async hardware start failed");
298 /* don't return failure, allow operation to continue */
299 }
300 #endif
301
302 #if defined(WOLFSSL_RENESAS_TSIP)
303 ret = tsip_Open( );
304 if( ret != TSIP_SUCCESS ) {
305 WOLFSSL_MSG("RENESAS TSIP Open failed");
306 /* not return 1 since WOLFSSL_SUCCESS=1*/
307 ret = -1;/* FATAL ERROR */
308 return ret;
309 }
310 #endif
311
312 #if defined(WOLFSSL_RENESAS_RX64_HASH)
313 ret = rx64_hw_Open();
314 if( ret != 0 ) {
315 WOLFSSL_MSG("Renesas RX64 HW Open failed");
316 /* not return 1 since WOLFSSL_SUCCESS=1*/
317 ret = -1;/* FATAL ERROR */
318 return ret;
319 }
320 #endif
321
322 #if defined(WOLFSSL_RENESAS_FSPSM)
323 ret = wc_fspsm_Open( );
324 if( ret != FSP_SUCCESS ) {
325 WOLFSSL_MSG("RENESAS SCE Open failed");
326 /* not return 1 since WOLFSSL_SUCCESS=1*/
327 ret = -1;/* FATAL ERROR */
328 return ret;
329 }
330 #endif
331
332 #if defined(WOLFSSL_TRACK_MEMORY) && !defined(WOLFSSL_STATIC_MEMORY)
333 ret = InitMemoryTracker();
334 if (ret != 0) {
335 WOLFSSL_MSG("InitMemoryTracker failed");
336 return ret;
337 }
338 #endif
339
340 #if defined(WOLFSSL_USE_SAVE_VECTOR_REGISTERS) && defined(WOLFSSL_LINUXKM)
341 ret = allocate_wolfcrypt_linuxkm_fpu_states();
342 if (ret != 0) {
343 WOLFSSL_MSG("allocate_wolfcrypt_linuxkm_fpu_states failed");
344 return ret;
345 }
346 #endif
347
348 #if WOLFSSL_CRYPT_HW_MUTEX
349 /* If crypto hardware mutex protection is enabled, then initialize it */
350 ret = wolfSSL_CryptHwMutexInit();
351 if (ret != 0) {
352 WOLFSSL_MSG("Hw crypt mutex init failed");
353 return ret;
354 }
355 #endif
356
357 #if defined(HAVE_HASHDRBG) && !defined(WC_NO_RNG) && \
358 !defined(HAVE_SELFTEST) && \
359 (!defined(HAVE_FIPS) || FIPS_VERSION3_GE(7,0,0))
360 ret = wc_DrbgState_MutexInit();
361 if (ret != 0) {
362 WOLFSSL_MSG("DRBG state mutex init failed");
363 return ret;
364 }
365 #endif
366
367 #if defined(FREESCALE_LTC_TFM) || defined(FREESCALE_LTC_ECC)
368 ret = ksdk_port_init();
369 if (ret != 0) {
370 WOLFSSL_MSG("KSDK port init failed");
371 return ret;
372 }
373 #endif
374
375 /* Crypto Callbacks only works on AES for MAX32666/5 HW */
376 #if defined(MAX3266X_AES) && defined(WOLF_CRYPTO_CB)
377 ret = wc_CryptoCb_RegisterDevice(WOLFSSL_MAX3266X_DEVID, wc_MxcCryptoCb,
378 NULL);
379 if(ret != 0) {
380 return ret;
381 }
382 #endif
383 #if defined(MAX3266X_RTC)
384 ret = wc_MXC_RTC_Init();
385 if (ret != 0) {
386 WOLFSSL_MSG("MXC RTC Init Failed");
387 return WC_HW_E;
388 }
389 #endif
390
391 #if defined(WOLFSSL_ATMEL) || defined(WOLFSSL_ATECC508A) || \
392 defined(WOLFSSL_ATECC608A) || defined(WOLFSSL_MICROCHIP_TA100)
393 ret = atmel_init();
394 if (ret != 0) {
395 WOLFSSL_MSG("CryptoAuthLib init failed");
396 return ret;
397 }
398 #endif
399 #if defined(WOLFSSL_CRYPTOCELL)
400 /* enable and initialize the ARM CryptoCell 3xx runtime library */
401 ret = cc310_Init();
402 if (ret != 0) {
403 WOLFSSL_MSG("CRYPTOCELL init failed");
404 return ret;
405 }
406 #endif
407 #ifdef WOLFSSL_STSAFE
408 ret = stsafe_interface_init();
409 if (ret != 0) {
410 WOLFSSL_MSG("STSAFE init failed");
411 return ret;
412 }
413 #endif
414 #if defined(WOLFSSL_TROPIC01)
415 ret = Tropic01_Init();
416 if (ret != 0) {
417 WOLFSSL_MSG("Tropic01 init failed");
418 return ret;
419 }
420 #endif
421 #if defined(WOLFSSL_PSOC6_CRYPTO)
422 ret = psoc6_crypto_port_init();
423 if (ret != 0) {
424 WOLFSSL_MSG("PSoC6 crypto engine init failed");
425 return ret;
426 }
427 #endif
428
429 #ifdef MAXQ10XX_MODULE_INIT
430 ret = maxq10xx_port_init();
431 if (ret != 0) {
432 WOLFSSL_MSG("MAXQ10xx port init failed");
433 return ret;
434 }
435 #endif
436
437 #ifdef WOLFSSL_SILABS_SE_ACCEL
438 /* init handles if it is already initialized */
439 ret = sl_se_init();
440 #endif
441
442 #if defined(WOLFSSL_SE050) && defined(WOLFSSL_SE050_INIT)
443 ret = wc_se050_init(NULL);
444 if (ret != 0) {
445 WOLFSSL_MSG("SE050 init failed");
446 return ret;
447 }
448 #endif
449
450 #ifdef WOLFSSL_ARMASM
451 WOLFSSL_MSG("Using ARM hardware acceleration");
452 #endif
453
454 #ifdef WOLFSSL_AFALG
455 WOLFSSL_MSG("Using AF_ALG for crypto acceleration");
456 #endif
457
458 #if !defined(WOLFCRYPT_ONLY) && defined(OPENSSL_EXTRA)
459 wolfSSL_EVP_init();
460 #endif
461
462 #if defined(OPENSSL_EXTRA) || defined(DEBUG_WOLFSSL_VERBOSE)
463 if ((ret = wc_LoggingInit()) != 0) {
464 WOLFSSL_MSG("Error creating logging mutex");
465 return ret;
466 }
467 #endif
468
469 #if defined(WOLFSSL_HAVE_PSA)
470 if ((ret = wc_psa_init()) != 0)
471 return ret;
472 #endif
473
474 #if defined(USE_WINDOWS_API) && defined(WIN_REUSE_CRYPT_HANDLE)
475 /* A failure here should not happen, but if it does the actual RNG seed
476 * call will fail. This init is for a shared crypt provider handle for
477 * RNG */
478 (void)wc_WinCryptHandleInit();
479 #endif
480
481 #ifdef HAVE_ENTROPY_MEMUSE
482 ret = Entropy_Init();
483 if (ret != 0) {
484 WOLFSSL_MSG("Error initializing entropy");
485 return ret;
486 }
487 #endif
488
489#ifdef HAVE_ECC
490 #ifdef FP_ECC
491 wc_ecc_fp_init();
492 #endif
493 #ifdef ECC_CACHE_CURVE
494 if ((ret = wc_ecc_curve_cache_init()) != 0) {
495 WOLFSSL_MSG("Error creating curve cache");
496 return ret;
497 }
498 #endif
499 #if defined(HAVE_OID_ENCODING) && (!defined(HAVE_FIPS) || \
500 (defined(FIPS_VERSION_GE) && FIPS_VERSION_GE(6,0)))
501 if ((ret = wc_ecc_oid_cache_init()) != 0) {
502 WOLFSSL_MSG("Error creating ECC oid cache");
503 return ret;
504 }
505 #endif
506#endif
507
508#ifdef WOLFSSL_SCE
509 ret = (int)WOLFSSL_SCE_GSCE_HANDLE.p_api->open(
510 WOLFSSL_SCE_GSCE_HANDLE.p_ctrl, WOLFSSL_SCE_GSCE_HANDLE.p_cfg);
511 if (ret == SSP_ERR_CRYPTO_SCE_ALREADY_OPEN) {
512 WOLFSSL_MSG("SCE already open");
513 ret = 0;
514 }
515 if (ret != SSP_SUCCESS) {
516 WOLFSSL_MSG("Error opening SCE");
517 return -1; /* FATAL_ERROR */
518 }
519#endif
520
521#if defined(WOLFSSL_DEVCRYPTO)
522 if ((ret = wc_DevCryptoInit()) != 0) {
523 return ret;
524 }
525#endif
526
527#if defined(WOLFSSL_CAAM)
528 if ((ret = wc_caamInit()) != 0) {
529 return ret;
530 }
531#endif
532
533#if defined(HAVE_ARIA)
534 if ((ret = wc_AriaInit()) != 0) {
535 return ret;
536 }
537#endif
538
539#ifdef WOLFSSL_IMXRT_DCP
540 if ((ret = wc_dcp_init()) != 0) {
541 return ret;
542 }
543#endif
544
545#ifdef WOLFSSL_NXP_CASPER
546 if ((ret = wc_casper_init()) != 0) {
547 return ret;
548 }
549#endif
550#ifdef WOLFSSL_NXP_HASHCRYPT
551 if ((ret = wc_hashcrypt_init()) != 0) {
552 return ret;
553 }
554#endif
555
556#if defined(WOLFSSL_DSP) && !defined(WOLFSSL_DSP_BUILD)
557 if ((ret = wolfSSL_InitHandle()) != 0) {
558 return ret;
559 }
560 rpcmem_init();
561#endif
562
563#if defined(HAVE_LIBOQS)
564 if ((ret = wolfSSL_liboqsInit()) != 0) {
565 return ret;
566 }
567#endif
568
569 /* increment to 2, to signify successful initialization: */
570 (void)wolfSSL_Atomic_Int_FetchAdd(&initRefCount, 1);
571 }
572 else {
573 if (my_initRefCount < 2) {
574 (void)wolfSSL_Atomic_Int_FetchSub(&initRefCount, 1);
575 ret = BUSY_E;
576 }
577 }
578
579 return ret;
580}
581
582#if defined(WOLFSSL_TRACK_MEMORY_VERBOSE) && !defined(WOLFSSL_STATIC_MEMORY)
583long wolfCrypt_heap_peakAllocs_checkpoint(void) {
584 long ret = ourMemStats.peakAllocsTripOdometer;
585 ourMemStats.peakAllocsTripOdometer = ourMemStats.totalAllocs -
586 ourMemStats.totalDeallocs;
587 return ret;
588}
589long wolfCrypt_heap_peakBytes_checkpoint(void) {
590 long ret = ourMemStats.peakBytesTripOdometer;
591 ourMemStats.peakBytesTripOdometer = ourMemStats.currentBytes;
592 return ret;
593}
594#endif
595
596/* return success value is the same as wolfCrypt_Init */
597WOLFSSL_ABI
598int wolfCrypt_Cleanup(void)
599{
600 int ret = 0;
601 int my_initRefCount = wolfSSL_Atomic_Int_SubFetch(&initRefCount, 1);
602
603 if (my_initRefCount == 1) {
604 WOLFSSL_ENTER("wolfCrypt_Cleanup");
605
606#ifdef HAVE_ECC
607 #ifdef FP_ECC
608 wc_ecc_fp_free();
609 #endif
610 #ifdef ECC_CACHE_CURVE
611 wc_ecc_curve_cache_free();
612 #endif
613 #if defined(HAVE_OID_ENCODING) && (!defined(HAVE_FIPS) || \
614 (defined(FIPS_VERSION_GE) && FIPS_VERSION_GE(6,0)))
615 wc_ecc_oid_cache_free();
616 #endif
617#endif /* HAVE_ECC */
618
619 #if defined(OPENSSL_EXTRA) || defined(DEBUG_WOLFSSL_VERBOSE)
620 ret = wc_LoggingCleanup();
621 #endif
622
623 #if defined(WOLFSSL_TRACK_MEMORY) && !defined(WOLFSSL_STATIC_MEMORY)
624 ShowMemoryTracker();
625 #endif
626
627 #ifdef WOLFSSL_ASYNC_CRYPT
628 wolfAsync_HardwareStop();
629 #endif
630
631 #ifdef WOLFSSL_RENESAS_TSIP
632 tsip_Close();
633 #endif
634
635 #if defined(WOLFSSL_RENESAS_RX64_HASH)
636 rx64_hw_Close();
637 #endif
638
639 #if defined(WOLFSSL_RENESAS_FSPSM)
640 wc_fspsm_Close();
641 #endif
642
643 #ifdef WOLFSSL_SCE
644 WOLFSSL_SCE_GSCE_HANDLE.p_api->close(WOLFSSL_SCE_GSCE_HANDLE.p_ctrl);
645 #endif
646
647 #if defined(WOLFSSL_CAAM)
648 wc_caamFree();
649 #endif
650 #if defined(WOLFSSL_CRYPTOCELL)
651 cc310_Free();
652 #endif
653 #ifdef WOLFSSL_SILABS_SE_ACCEL
654 ret = sl_se_deinit();
655 #endif
656 #if defined(WOLFSSL_TROPIC01)
657 Tropic01_Deinit();
658 #endif
659 #if defined(WOLFSSL_RENESAS_TSIP)
660 tsip_Close();
661 #endif
662 #if defined(WOLFSSL_DEVCRYPTO)
663 wc_DevCryptoCleanup();
664 #endif
665 #if defined(WOLFSSL_DSP) && !defined(WOLFSSL_DSP_BUILD)
666 rpcmem_deinit();
667 wolfSSL_CleanupHandle();
668 #endif
669 #if defined(WOLFSSL_USE_SAVE_VECTOR_REGISTERS) && defined(WOLFSSL_LINUXKM)
670 free_wolfcrypt_linuxkm_fpu_states();
671 #endif
672
673 #ifdef HAVE_ENTROPY_MEMUSE
674 Entropy_Final();
675 #endif
676
677 #if defined(USE_WINDOWS_API) && defined(WIN_REUSE_CRYPT_HANDLE)
678 wc_WinCryptHandleCleanup();
679 #endif
680
681 #ifdef WOLF_CRYPTO_CB
682 wc_CryptoCb_Cleanup();
683 #endif
684
685 #if defined(HAVE_HASHDRBG) && !defined(WC_NO_RNG) && \
686 !defined(HAVE_SELFTEST) && \
687 (!defined(HAVE_FIPS) || FIPS_VERSION3_GE(7,0,0))
688 wc_DrbgState_MutexFree();
689 #endif
690
691 #if defined(WOLFSSL_MEM_FAIL_COUNT) && defined(WOLFCRYPT_ONLY)
692 wc_MemFailCount_Free();
693 #endif
694 #ifdef WOLFSSL_CHECK_MEM_ZERO
695 /* Free the mutex for access to the list of memory locations that
696 * must be freed. */
697 wc_MemZero_Free();
698 #endif
699
700 (void)wolfSSL_Atomic_Int_SubFetch(&initRefCount, 1);
701
702#if defined(HAVE_LIBOQS)
703 wolfSSL_liboqsClose();
704#endif
705 }
706 else if (my_initRefCount < 0) {
707 (void)wolfSSL_Atomic_Int_AddFetch(&initRefCount, 1);
708 WOLFSSL_MSG("wolfCrypt_Cleanup() called with initRefCount <= 0.");
709 ret = ALREADY_E;
710 }
711
712 return ret;
713}
714
715#ifndef NO_FILESYSTEM
716
717/* Helpful function to load file into allocated buffer */
718int wc_FileLoad(const char* fname, unsigned char** buf, size_t* bufLen,
719 void* heap)
720{
721 int ret;
722 ssize_t fileSz;
723 XFILE f;
724
725 if (fname == NULL || buf == NULL || bufLen == NULL) {
726 return BAD_FUNC_ARG;
727 }
728
729 /* set defaults */
730 *buf = NULL;
731 *bufLen = 0;
732
733 /* open file (read-only binary) */
734 f = XFOPEN(fname, "rb");
735 if (!f) {
736 WOLFSSL_MSG("wc_LoadFile file load error");
737 return BAD_PATH_ERROR;
738 }
739
740 if (XFSEEK(f, 0, XSEEK_END) != 0) {
741 WOLFSSL_MSG("wc_LoadFile file seek error");
742 XFCLOSE(f);
743 return BAD_PATH_ERROR;
744 }
745 fileSz = XFTELL(f);
746 if (fileSz < 0) {
747 WOLFSSL_MSG("wc_LoadFile ftell error");
748 XFCLOSE(f);
749 return BAD_PATH_ERROR;
750 }
751 if (XFSEEK(f, 0, XSEEK_SET) != 0) {
752 WOLFSSL_MSG("wc_LoadFile file seek error");
753 XFCLOSE(f);
754 return BAD_PATH_ERROR;
755 }
756 if (fileSz > 0) {
757 *bufLen = (size_t)fileSz;
758 *buf = (byte*)XMALLOC(*bufLen, heap, DYNAMIC_TYPE_TMP_BUFFER);
759 if (*buf == NULL) {
760 WOLFSSL_MSG("wc_LoadFile memory error");
761 ret = MEMORY_E;
762 }
763 else {
764 size_t readLen = XFREAD(*buf, 1, *bufLen, f);
765
766 /* check response code */
767 ret = (readLen == *bufLen) ? 0 : -1;
768 }
769 }
770 else {
771 ret = BUFFER_E;
772 }
773 XFCLOSE(f);
774
775 (void)heap;
776
777 return ret;
778}
779
780#if !defined(NO_WOLFSSL_DIR) && \
781 !defined(WOLFSSL_NUCLEUS) && !defined(WOLFSSL_NUCLEUS_1_2)
782/* File Handling Helper */
783/* returns 0 if file exists, WC_ISFILEEXIST_NOFILE if file doesn't exist */
784int wc_FileExists(const char* fname)
785{
786 struct ReadDirCtx ctx;
787
788 XMEMSET(&ctx, 0, sizeof(ctx));
789
790 if (fname == NULL)
791 return 0;
792
793 if (XSTAT(fname, &ctx.s) != 0) {
794 WOLFSSL_MSG("stat on name failed");
795 return BAD_PATH_ERROR;
796 } else {
797#if defined(USE_WINDOWS_API)
798 if (XS_ISREG(ctx.s.st_mode)) {
799 return 0;
800 }
801#elif defined(WOLFSSL_ZEPHYR)
802 if (XS_ISREG(ctx.s.type)) {
803 return 0;
804 }
805#elif defined(WOLFSSL_TELIT_M2MB)
806 if (XS_ISREG(ctx.s.st_mode)) {
807 return 0;
808 }
809#else
810 if (XS_ISREG(ctx.s.st_mode)) {
811 return 0;
812 }
813#endif
814 }
815 return WC_ISFILEEXIST_NOFILE;
816}
817
818/* File Handling Helpers */
819/* returns 0 if file found, WC_READDIR_NOFILE if no files or negative error */
820int wc_ReadDirFirst(ReadDirCtx* ctx, const char* path, char** name)
821{
822 int ret = WC_READDIR_NOFILE; /* default to no files found */
823 int pathLen = 0;
824
825 if (name)
826 *name = NULL;
827
828 if (ctx != NULL)
829 XMEMSET(ctx, 0, sizeof(ReadDirCtx));
830
831 if (ctx == NULL || path == NULL) {
832 return BAD_FUNC_ARG;
833 }
834
835 pathLen = (int)XSTRLEN(path);
836
837#ifdef USE_WINDOWS_API
838 if (pathLen > MAX_FILENAME_SZ - 3)
839 return BAD_PATH_ERROR;
840
841 XSTRNCPY(ctx->name, path, MAX_FILENAME_SZ - 3);
842 XSTRNCPY(ctx->name + pathLen, "\\*", (size_t)(MAX_FILENAME_SZ - pathLen));
843
844 ctx->hFind = FindFirstFileA(ctx->name, &ctx->FindFileData);
845 if (ctx->hFind == INVALID_HANDLE_VALUE) {
846 WOLFSSL_MSG("FindFirstFile for path verify locations failed");
847 return BAD_PATH_ERROR;
848 }
849
850 do {
851 if (!(ctx->FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
852 int dnameLen = (int)XSTRLEN(ctx->FindFileData.cFileName);
853
854 if (pathLen + dnameLen + 2 > MAX_FILENAME_SZ) {
855 return BAD_PATH_ERROR;
856 }
857 XSTRNCPY(ctx->name, path, (size_t)pathLen + 1);
858 ctx->name[pathLen] = '\\';
859 XSTRNCPY(ctx->name + pathLen + 1,
860 ctx->FindFileData.cFileName,
861 (size_t)(MAX_FILENAME_SZ - pathLen - 1));
862 if (name)
863 *name = ctx->name;
864 return 0;
865 }
866 } while (FindNextFileA(ctx->hFind, &ctx->FindFileData));
867
868#elif defined(INTIME_RTOS)
869 if (pathLen > MAX_FILENAME_SZ - 3)
870 return BAD_PATH_ERROR;
871
872 XSTRNCPY(ctx->name, path, MAX_FILENAME_SZ - 3);
873 XSTRNCPY(ctx->name + pathLen, "\\*", MAX_FILENAME_SZ - pathLen);
874
875 if (!IntimeFindFirst(ctx->name, &ctx->FindFileData)) {
876 WOLFSSL_MSG("FindFirstFile for path verify locations failed");
877 return BAD_PATH_ERROR;
878 }
879
880 do {
881 int dnameLen = (int)XSTRLEN(IntimeFilename(ctx));
882
883 if (pathLen + dnameLen + 2 > MAX_FILENAME_SZ) {
884 return BAD_PATH_ERROR;
885 }
886 XSTRNCPY(ctx->name, path, pathLen + 1);
887 ctx->name[pathLen] = '\\';
888 XSTRNCPY(ctx->name + pathLen + 1,
889 IntimeFilename(ctx),
890 MAX_FILENAME_SZ - pathLen - 1);
891 if (0 == wc_FileExists(ctx->name)) {
892 if (name)
893 *name = ctx->name;
894 return 0;
895 }
896 } while (IntimeFindNext(&ctx->FindFileData));
897
898#elif defined(WOLFSSL_ZEPHYR)
899 if (fs_opendir(&ctx->dir, path) != 0) {
900 WOLFSSL_MSG("opendir path verify locations failed");
901 return BAD_PATH_ERROR;
902 }
903 ctx->dirp = &ctx->dir;
904
905 while ((fs_readdir(&ctx->dir, &ctx->entry)) != 0) {
906 int dnameLen = (int)XSTRLEN(ctx->entry.name);
907
908 if (pathLen + dnameLen + 2 >= MAX_FILENAME_SZ) {
909 ret = BAD_PATH_ERROR;
910 break;
911 }
912 XSTRNCPY(ctx->name, path, pathLen + 1);
913 ctx->name[pathLen] = '/';
914
915 /* Use dnameLen + 1 for GCC 8 warnings of truncating d_name. Because
916 * of earlier check it is known that dnameLen is less than
917 * MAX_FILENAME_SZ - (pathLen + 2) so dnameLen +1 will fit */
918 XSTRNCPY(ctx->name + pathLen + 1, ctx->entry.name, dnameLen + 1);
919 if ((ret = wc_FileExists(ctx->name)) == 0) {
920 if (name)
921 *name = ctx->name;
922 return 0;
923 }
924 }
925#elif defined(WOLFSSL_TELIT_M2MB)
926 ctx->dir = m2mb_fs_opendir((const CHAR*)path);
927 if (ctx->dir == NULL) {
928 WOLFSSL_MSG("opendir path verify locations failed");
929 return BAD_PATH_ERROR;
930 }
931
932 while ((ctx->entry = m2mb_fs_readdir(ctx->dir)) != NULL) {
933 int dnameLen = (int)XSTRLEN(ctx->entry->d_name);
934
935 if (pathLen + dnameLen + 2 >= MAX_FILENAME_SZ) {
936 ret = BAD_PATH_ERROR;
937 break;
938 }
939 XSTRNCPY(ctx->name, path, pathLen + 1);
940 ctx->name[pathLen] = '/';
941
942 /* Use dnameLen + 1 for GCC 8 warnings of truncating d_name. Because
943 * of earlier check it is known that dnameLen is less than
944 * MAX_FILENAME_SZ - (pathLen + 2) so dnameLen +1 will fit */
945 XSTRNCPY(ctx->name + pathLen + 1, ctx->entry->d_name, dnameLen + 1);
946
947 if ((ret = wc_FileExists(ctx->name)) == 0) {
948 if (name)
949 *name = ctx->name;
950 return 0;
951 }
952 }
953#else
954 ctx->dir = opendir(path);
955 if (ctx->dir == NULL) {
956 WOLFSSL_MSG("opendir path verify locations failed");
957 return BAD_PATH_ERROR;
958 }
959
960 while ((ctx->entry = readdir(ctx->dir)) != NULL) {
961 int dnameLen = (int)XSTRLEN(ctx->entry->d_name);
962
963 if (pathLen + dnameLen + 2 >= MAX_FILENAME_SZ) {
964 ret = BAD_PATH_ERROR;
965 break;
966 }
967 XSTRNCPY(ctx->name, path, (size_t)pathLen + 1);
968 ctx->name[pathLen] = '/';
969
970 /* Use dnameLen + 1 for GCC 8 warnings of truncating d_name. Because
971 * of earlier check it is known that dnameLen is less than
972 * MAX_FILENAME_SZ - (pathLen + 2) so dnameLen +1 will fit */
973 XSTRNCPY(ctx->name + pathLen + 1, ctx->entry->d_name, (size_t)dnameLen + 1);
974 if ((ret = wc_FileExists(ctx->name)) == 0) {
975 if (name)
976 *name = ctx->name;
977 return 0;
978 }
979 }
980#endif
981 wc_ReadDirClose(ctx);
982
983 return ret;
984}
985
986/* returns 0 if file found, WC_READDIR_NOFILE if no more files */
987int wc_ReadDirNext(ReadDirCtx* ctx, const char* path, char** name)
988{
989 int ret = WC_READDIR_NOFILE; /* default to no file found */
990 int pathLen = 0;
991
992 if (name)
993 *name = NULL;
994
995 if (ctx == NULL || path == NULL) {
996 return BAD_FUNC_ARG;
997 }
998
999 XMEMSET(ctx->name, 0, MAX_FILENAME_SZ);
1000 pathLen = (int)XSTRLEN(path);
1001
1002#ifdef USE_WINDOWS_API
1003 while (FindNextFileA(ctx->hFind, &ctx->FindFileData)) {
1004 if (!(ctx->FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
1005 int dnameLen = (int)XSTRLEN(ctx->FindFileData.cFileName);
1006
1007 if (pathLen + dnameLen + 2 > MAX_FILENAME_SZ) {
1008 return BAD_PATH_ERROR;
1009 }
1010 XSTRNCPY(ctx->name, path, (size_t)pathLen + 1);
1011 ctx->name[pathLen] = '\\';
1012 XSTRNCPY(ctx->name + pathLen + 1,
1013 ctx->FindFileData.cFileName,
1014 (size_t)(MAX_FILENAME_SZ - pathLen - 1));
1015 if (name)
1016 *name = ctx->name;
1017 return 0;
1018 }
1019 }
1020
1021#elif defined(INTIME_RTOS)
1022 while (IntimeFindNext(&ctx->FindFileData)) {
1023 int dnameLen = (int)XSTRLEN(IntimeFilename(ctx));
1024
1025 if (pathLen + dnameLen + 2 > MAX_FILENAME_SZ) {
1026 return BAD_PATH_ERROR;
1027 }
1028 XSTRNCPY(ctx->name, path, pathLen + 1);
1029 ctx->name[pathLen] = '\\';
1030 XSTRNCPY(ctx->name + pathLen + 1,
1031 IntimeFilename(ctx),
1032 MAX_FILENAME_SZ - pathLen - 1);
1033 if (0 == wc_FileExists(ctx->name)) {
1034 if (name)
1035 *name = ctx->name;
1036 return 0;
1037 }
1038 }
1039
1040#elif defined(WOLFSSL_ZEPHYR)
1041 while ((fs_readdir(&ctx->dir, &ctx->entry)) != 0) {
1042 int dnameLen = (int)XSTRLEN(ctx->entry.name);
1043
1044 if (pathLen + dnameLen + 2 >= MAX_FILENAME_SZ) {
1045 ret = BAD_PATH_ERROR;
1046 break;
1047 }
1048 XSTRNCPY(ctx->name, path, pathLen + 1);
1049 ctx->name[pathLen] = '/';
1050 /* Use dnameLen + 1 for GCC 8 warnings of truncating d_name. Because
1051 * of earlier check it is known that dnameLen is less than
1052 * MAX_FILENAME_SZ - (pathLen + 2) so that dnameLen +1 will fit */
1053 XSTRNCPY(ctx->name + pathLen + 1, ctx->entry.name, dnameLen + 1);
1054
1055 if ((ret = wc_FileExists(ctx->name)) == 0) {
1056 if (name)
1057 *name = ctx->name;
1058 return 0;
1059 }
1060 }
1061#elif defined(WOLFSSL_TELIT_M2MB)
1062 while ((ctx->entry = m2mb_fs_readdir(ctx->dir)) != NULL) {
1063 int dnameLen = (int)XSTRLEN(ctx->entry->d_name);
1064
1065 if (pathLen + dnameLen + 2 >= MAX_FILENAME_SZ) {
1066 ret = BAD_PATH_ERROR;
1067 break;
1068 }
1069 XSTRNCPY(ctx->name, path, pathLen + 1);
1070 ctx->name[pathLen] = '/';
1071
1072 /* Use dnameLen + 1 for GCC 8 warnings of truncating d_name. Because
1073 * of earlier check it is known that dnameLen is less than
1074 * MAX_FILENAME_SZ - (pathLen + 2) so dnameLen +1 will fit */
1075 XSTRNCPY(ctx->name + pathLen + 1, ctx->entry->d_name, dnameLen + 1);
1076
1077 if ((ret = wc_FileExists(ctx->name)) == 0) {
1078 if (name)
1079 *name = ctx->name;
1080 return 0;
1081 }
1082 }
1083#else
1084 while ((ctx->entry = readdir(ctx->dir)) != NULL) {
1085 int dnameLen = (int)XSTRLEN(ctx->entry->d_name);
1086
1087 if (pathLen + dnameLen + 2 >= MAX_FILENAME_SZ) {
1088 ret = BAD_PATH_ERROR;
1089 break;
1090 }
1091 XSTRNCPY(ctx->name, path, (size_t)pathLen + 1);
1092 ctx->name[pathLen] = '/';
1093 /* Use dnameLen + 1 for GCC 8 warnings of truncating d_name. Because
1094 * of earlier check it is known that dnameLen is less than
1095 * MAX_FILENAME_SZ - (pathLen + 2) so that dnameLen +1 will fit */
1096 XSTRNCPY(ctx->name + pathLen + 1, ctx->entry->d_name, (size_t)dnameLen + 1);
1097
1098 if ((ret = wc_FileExists(ctx->name)) == 0) {
1099 if (name)
1100 *name = ctx->name;
1101 return 0;
1102 }
1103 }
1104#endif
1105
1106 wc_ReadDirClose(ctx);
1107
1108 return ret;
1109}
1110
1111void wc_ReadDirClose(ReadDirCtx* ctx)
1112{
1113 if (ctx == NULL) {
1114 return;
1115 }
1116
1117#ifdef USE_WINDOWS_API
1118 if (ctx->hFind != INVALID_HANDLE_VALUE) {
1119 FindClose(ctx->hFind);
1120 ctx->hFind = INVALID_HANDLE_VALUE;
1121 }
1122
1123#elif defined(INTIME_RTOS)
1124 IntimeFindClose(&ctx->FindFileData);
1125
1126#elif defined(WOLFSSL_ZEPHYR)
1127 if (ctx->dirp) {
1128 fs_closedir(ctx->dirp);
1129 ctx->dirp = NULL;
1130 }
1131#elif defined(WOLFSSL_TELIT_M2MB)
1132 if (ctx->dir) {
1133 m2mb_fs_closedir(ctx->dir);
1134 ctx->dir = NULL;
1135 }
1136#else
1137 if (ctx->dir) {
1138 if (closedir(ctx->dir) < 0)
1139 WOLFSSL_MSG("closedir() failed");
1140 ctx->dir = NULL;
1141 }
1142#endif
1143}
1144
1145#endif /* !NO_WOLFSSL_DIR */
1146#endif /* !NO_FILESYSTEM */
1147
1148#if !defined(NO_FILESYSTEM) && defined(WOLFSSL_ZEPHYR)
1149XFILE z_fs_open(const char* filename, const char* mode)
1150{
1151 XFILE file;
1152 fs_mode_t flags = 0;
1153
1154 if (mode == NULL)
1155 return NULL;
1156
1157 /* Parse mode */
1158 switch (*mode++) {
1159 case 'r':
1160 flags |= FS_O_READ;
1161 break;
1162 case 'w':
1163 flags |= FS_O_WRITE|FS_O_CREATE;
1164 break;
1165 case 'a':
1166 flags |= FS_O_APPEND|FS_O_CREATE;
1167 break;
1168 default:
1169 return NULL;
1170 }
1171
1172 /* Ignore binary flag */
1173 if (*mode == 'b')
1174 mode++;
1175 if (*mode == '+') {
1176 flags |= FS_O_READ;
1177 /* Don't add write flag if already appending */
1178 if (!(flags & FS_O_APPEND))
1179 flags |= FS_O_RDWR;
1180 }
1181 /* Ignore binary flag */
1182 if (*mode == 'b')
1183 mode++;
1184 /* Incorrect mode string */
1185 if (*mode != '\0')
1186 return NULL;
1187
1188 file = (XFILE)XMALLOC(sizeof(*file), NULL, DYNAMIC_TYPE_FILE);
1189 if (file != NULL) {
1190 fs_file_t_init(file);
1191 if (fs_open(file, filename, flags) != 0) {
1192 XFREE(file, NULL, DYNAMIC_TYPE_FILE);
1193 file = NULL;
1194 }
1195 }
1196
1197 return file;
1198}
1199
1200int z_fs_close(XFILE file)
1201{
1202 int ret;
1203
1204 if (file == NULL)
1205 return -1;
1206 ret = (fs_close(file) == 0) ? 0 : -1;
1207
1208 XFREE(file, NULL, DYNAMIC_TYPE_FILE);
1209
1210 return ret;
1211}
1212
1213/* Rewind the file pointer to the beginning of the file */
1214/* This is not a 'rewind' is not supported in Zephyr so */
1215/* use fs_seek to move the file pointer to the beginning of the file */
1216/* calling it z_fs_rewind to avoid future conflicts if rewind is added */
1217int z_fs_rewind(XFILE file)
1218{
1219 return fs_seek(file, 0, FS_SEEK_SET);
1220}
1221
1222#endif /* !NO_FILESYSTEM && !WOLFSSL_ZEPHYR */
1223
1224#if !defined(WOLFSSL_USER_MUTEX)
1225wolfSSL_Mutex* wc_InitAndAllocMutex(void)
1226{
1227 wolfSSL_Mutex* m = (wolfSSL_Mutex*) XMALLOC(sizeof(wolfSSL_Mutex), NULL,
1228 DYNAMIC_TYPE_MUTEX);
1229 if (m != NULL) {
1230 if (wc_InitMutex(m) != 0) {
1231 WOLFSSL_MSG("Init Mutex failed");
1232 XFREE(m, NULL, DYNAMIC_TYPE_MUTEX);
1233 m = NULL;
1234 }
1235 }
1236 else {
1237 WOLFSSL_MSG("Memory error with Mutex allocation");
1238 }
1239
1240 return m;
1241}
1242#endif
1243
1244#ifdef USE_WOLF_STRTOK
1245/* String token (delim) search. If str is null use nextp. */
1246char* wc_strtok(char *str, const char *delim, char **nextp)
1247{
1248 char* ret;
1249 int i, j;
1250
1251 /* Use next if str is NULL */
1252 if (str == NULL && nextp)
1253 str = *nextp;
1254
1255 /* verify str input */
1256 if (str == NULL || *str == '\0')
1257 return NULL;
1258
1259 /* match on entire delim */
1260 for (i = 0; str[i]; i++) {
1261 for (j = 0; delim[j]; j++) {
1262 if (delim[j] == str[i])
1263 break;
1264 }
1265 if (!delim[j])
1266 break;
1267 }
1268 str += i;
1269 /* if end of string, not found so return NULL */
1270 if (*str == '\0')
1271 return NULL;
1272
1273 ret = str;
1274
1275 /* match on first delim */
1276 for (i = 0; str[i]; i++) {
1277 for (j = 0; delim[j]; j++) {
1278 if (delim[j] == str[i])
1279 break;
1280 }
1281 if (delim[j] == str[i])
1282 break;
1283 }
1284 str += i;
1285
1286 /* null terminate found string */
1287 if (*str)
1288 *str++ = '\0';
1289
1290 /* return pointer to next */
1291 if (nextp)
1292 *nextp = str;
1293
1294 return ret;
1295}
1296#endif /* USE_WOLF_STRTOK */
1297
1298#ifdef USE_WOLF_STRSEP
1299char* wc_strsep(char **stringp, const char *delim)
1300{
1301 char *s, *tok;
1302 const char *spanp;
1303
1304 /* null check */
1305 if (stringp == NULL || *stringp == NULL)
1306 return NULL;
1307
1308 s = *stringp;
1309 for (tok = s; *tok; ++tok) {
1310 for (spanp = delim; *spanp; ++spanp) {
1311 /* found delimiter */
1312 if (*tok == *spanp) {
1313 *tok = '\0'; /* replace delim with null term */
1314 *stringp = tok + 1; /* return past delim */
1315 return s;
1316 }
1317 }
1318 }
1319
1320 *stringp = NULL;
1321 return s;
1322}
1323#endif /* USE_WOLF_STRSEP */
1324
1325#ifdef USE_WOLF_STRLCPY
1326size_t wc_strlcpy(char *dst, const char *src, size_t dstSize)
1327{
1328 size_t i;
1329
1330 if (!dstSize)
1331 return 0;
1332
1333 /* Always have to leave a space for NULL */
1334 for (i = 0; i < (dstSize - 1) && *src != '\0'; i++) {
1335 *dst++ = *src++;
1336 }
1337 *dst = '\0';
1338
1339 return i; /* return length without NULL */
1340}
1341#endif /* USE_WOLF_STRLCPY */
1342
1343#ifdef USE_WOLF_STRLCAT
1344size_t wc_strlcat(char *dst, const char *src, size_t dstSize)
1345{
1346 size_t dstLen;
1347
1348 if (!dstSize)
1349 return 0;
1350
1351 dstLen = XSTRLEN(dst);
1352
1353 if (dstSize < dstLen)
1354 return dstLen + XSTRLEN(src);
1355
1356 return dstLen + wc_strlcpy(dst + dstLen, src, dstSize - dstLen);
1357}
1358#endif /* USE_WOLF_STRLCAT */
1359
1360#ifdef USE_WOLF_STRCASECMP
1361int wc_strcasecmp(const char *s1, const char *s2)
1362{
1363 char c1, c2;
1364 for (;;++s1, ++s2) {
1365 c1 = *s1;
1366 if ((c1 >= 'a') && (c1 <= 'z'))
1367 c1 = (char)(c1 - ('a' - 'A'));
1368 c2 = *s2;
1369 if ((c2 >= 'a') && (c2 <= 'z'))
1370 c2 = (char)(c2 - ('a' - 'A'));
1371 if ((c1 != c2) || (c1 == 0))
1372 break;
1373 }
1374 return (c1 - c2);
1375}
1376#endif /* USE_WOLF_STRCASECMP */
1377
1378#ifdef USE_WOLF_STRNCASECMP
1379int wc_strncasecmp(const char *s1, const char *s2, size_t n)
1380{
1381 char c1, c2;
1382 for (c1 = 0, c2 = 0; n > 0; --n, ++s1, ++s2) {
1383 c1 = *s1;
1384 if ((c1 >= 'a') && (c1 <= 'z'))
1385 c1 = (char)(c1 - ('a' - 'A'));
1386 c2 = *s2;
1387 if ((c2 >= 'a') && (c2 <= 'z'))
1388 c2 = (char)(c2 - ('a' - 'A'));
1389 if ((c1 != c2) || (c1 == 0))
1390 break;
1391 }
1392 return (c1 - c2);
1393}
1394#endif /* USE_WOLF_STRNCASECMP */
1395
1396#ifdef USE_WOLF_STRDUP
1397char* wc_strdup_ex(const char *src, int memType) {
1398 char *ret = NULL;
1399 word32 len = 0;
1400
1401 if (src) {
1402 len = (word32)XSTRLEN(src) + 1; /* Add one for null terminator */
1403 ret = (char*)XMALLOC(len, NULL, memType);
1404 if (ret != NULL) {
1405 XMEMCPY(ret, src, len);
1406 }
1407 }
1408
1409 return ret;
1410}
1411#endif
1412
1413#ifdef WOLFSSL_ATOMIC_OPS
1414
1415#if defined(WOLFSSL_USER_DEFINED_ATOMICS)
1416
1417#elif defined(SINGLE_THREADED)
1418
1419#elif defined(WOLFSSL_BSDKM)
1420/* Note: using compiler built-ins like __atomic_fetch_add will technically
1421 * build in FreeBSD kernel, but are not commonly used in FreeBSD kernel and
1422 * might not be safe or portable.
1423 * */
1424void wolfSSL_Atomic_Int_Init(wolfSSL_Atomic_Int* c, int i)
1425{
1426 *c = i;
1427}
1428
1429void wolfSSL_Atomic_Uint_Init(wolfSSL_Atomic_Uint* c, unsigned int i)
1430{
1431 *c = i;
1432}
1433
1434int wolfSSL_Atomic_Int_FetchAdd(wolfSSL_Atomic_Int* c, int i)
1435{
1436 return atomic_fetchadd_int(c, i);
1437}
1438
1439int wolfSSL_Atomic_Int_FetchSub(wolfSSL_Atomic_Int* c, int i)
1440{
1441 return atomic_fetchadd_int(c, -i);
1442}
1443
1444int wolfSSL_Atomic_Int_AddFetch(wolfSSL_Atomic_Int* c, int i)
1445{
1446 int val = atomic_fetchadd_int(c, i);
1447 return val + i;
1448}
1449
1450int wolfSSL_Atomic_Int_SubFetch(wolfSSL_Atomic_Int* c, int i)
1451{
1452 int val = atomic_fetchadd_int(c, -i);
1453 return val - i;
1454}
1455
1456unsigned int wolfSSL_Atomic_Uint_FetchAdd(wolfSSL_Atomic_Uint* c,
1457 unsigned int i)
1458{
1459 return atomic_fetchadd_int(c, i);
1460}
1461
1462unsigned int wolfSSL_Atomic_Uint_FetchSub(wolfSSL_Atomic_Uint* c,
1463 unsigned int i)
1464{
1465 return atomic_fetchadd_int(c, -i);
1466}
1467
1468unsigned int wolfSSL_Atomic_Uint_AddFetch(wolfSSL_Atomic_Uint* c,
1469 unsigned int i)
1470{
1471 unsigned int val = atomic_fetchadd_int(c, i);
1472 return val + i;
1473}
1474
1475unsigned int wolfSSL_Atomic_Uint_SubFetch(wolfSSL_Atomic_Uint* c,
1476 unsigned int i)
1477{
1478 unsigned int val = atomic_fetchadd_int(c, -i);
1479 return val - i;
1480}
1481
1482int wolfSSL_Atomic_Int_Exchange(wolfSSL_Atomic_Int* c, int new_i)
1483{
1484 return atomic_swap_int(c, new_i);
1485}
1486
1487int wolfSSL_Atomic_Int_CompareExchange(wolfSSL_Atomic_Int* c, int *expected_i,
1488 int new_i)
1489{
1490 u_int exp = (u_int) *expected_i;
1491 int ret = atomic_fcmpset_int(c, &exp, new_i);
1492 *expected_i = (int)exp;
1493 return ret;
1494}
1495
1496int wolfSSL_Atomic_Uint_CompareExchange(
1497 wolfSSL_Atomic_Uint* c, unsigned int *expected_i, unsigned int new_i)
1498{
1499 u_int exp = (u_int)*expected_i;
1500 int ret = atomic_fcmpset_int(c, &exp, new_i);
1501 *expected_i = (unsigned int)exp;
1502 return ret;
1503}
1504
1505int wolfSSL_Atomic_Ptr_CompareExchange(
1506 void * volatile *c, void **expected_ptr, void *new_ptr)
1507{
1508 uintptr_t exp = (uintptr_t)*expected_ptr;
1509 int ret = atomic_fcmpset_ptr((uintptr_t *)c, &exp, (uintptr_t)new_ptr);
1510 *expected_ptr = (void *)exp;
1511 return ret;
1512}
1513
1514#elif defined(HAVE_C___ATOMIC) && defined(WOLFSSL_HAVE_ATOMIC_H) && \
1515 !defined(__cplusplus)
1516
1517/* Default C Implementation */
1518void wolfSSL_Atomic_Int_Init(wolfSSL_Atomic_Int* c, int i)
1519{
1520 atomic_init(c, i);
1521}
1522
1523void wolfSSL_Atomic_Uint_Init(wolfSSL_Atomic_Uint* c, unsigned int i)
1524{
1525 atomic_init(c, i);
1526}
1527
1528int wolfSSL_Atomic_Int_FetchAdd(wolfSSL_Atomic_Int* c, int i)
1529{
1530 return atomic_fetch_add_explicit(c, i, memory_order_relaxed);
1531}
1532
1533int wolfSSL_Atomic_Int_FetchSub(wolfSSL_Atomic_Int* c, int i)
1534{
1535 return atomic_fetch_sub_explicit(c, i, memory_order_relaxed);
1536}
1537
1538int wolfSSL_Atomic_Int_AddFetch(wolfSSL_Atomic_Int* c, int i)
1539{
1540 int ret = atomic_fetch_add_explicit(c, i, memory_order_relaxed);
1541 return ret + i;
1542}
1543
1544int wolfSSL_Atomic_Int_SubFetch(wolfSSL_Atomic_Int* c, int i)
1545{
1546 int ret = atomic_fetch_sub_explicit(c, i, memory_order_relaxed);
1547 return ret - i;
1548}
1549
1550int wolfSSL_Atomic_Int_Exchange(wolfSSL_Atomic_Int* c, int new_i)
1551{
1552 return atomic_exchange_explicit(c, new_i, memory_order_seq_cst);
1553}
1554
1555int wolfSSL_Atomic_Int_CompareExchange(
1556 wolfSSL_Atomic_Int* c, int *expected_i, int new_i)
1557{
1558 /* For the success path, use full synchronization with barriers --
1559 * "Sequentially-consistent ordering" -- so that all threads see the same
1560 * "single total modification order of all atomic operations" -- but on
1561 * failure we just need to be sure we acquire the value that changed out
1562 * from under us.
1563 */
1564 return atomic_compare_exchange_strong_explicit(
1565 c, expected_i, new_i, memory_order_seq_cst, memory_order_acquire);
1566}
1567
1568unsigned int wolfSSL_Atomic_Uint_FetchAdd(wolfSSL_Atomic_Uint* c,
1569 unsigned int i)
1570{
1571 return atomic_fetch_add_explicit(c, i, memory_order_relaxed);
1572}
1573
1574unsigned int wolfSSL_Atomic_Uint_FetchSub(wolfSSL_Atomic_Uint* c,
1575 unsigned int i)
1576{
1577 return atomic_fetch_sub_explicit(c, i, memory_order_relaxed);
1578}
1579
1580unsigned int wolfSSL_Atomic_Uint_AddFetch(wolfSSL_Atomic_Uint* c,
1581 unsigned int i)
1582{
1583 unsigned int ret = atomic_fetch_add_explicit(c, i, memory_order_relaxed);
1584 return ret + i;
1585}
1586
1587unsigned int wolfSSL_Atomic_Uint_SubFetch(wolfSSL_Atomic_Uint* c,
1588 unsigned int i)
1589{
1590 unsigned int ret = atomic_fetch_sub_explicit(c, i, memory_order_relaxed);
1591 return ret - i;
1592}
1593
1594int wolfSSL_Atomic_Uint_CompareExchange(
1595 wolfSSL_Atomic_Uint* c, unsigned int *expected_i, unsigned int new_i)
1596{
1597 /* For the success path, use full synchronization with barriers --
1598 * "Sequentially-consistent ordering" -- so that all threads see the same
1599 * "single total modification order of all atomic operations" -- but on
1600 * failure we just need to be sure we acquire the value that changed out
1601 * from under us.
1602 */
1603 return atomic_compare_exchange_strong_explicit(
1604 c, expected_i, new_i, memory_order_seq_cst, memory_order_acquire);
1605}
1606
1607int wolfSSL_Atomic_Ptr_CompareExchange(
1608 void * volatile *c, void **expected_ptr, void *new_ptr)
1609{
1610 /* use gcc-built-in __atomic_compare_exchange_n(), not
1611 * atomic_compare_exchange_strong_explicit(), to sidestep _Atomic type
1612 * requirements.
1613 */
1614 if (__atomic_compare_exchange_n(
1615 c, expected_ptr, new_ptr,
1616#ifdef WOLF_C89
1617 0 /* weak */,
1618#else
1619 (_Bool)0 /* weak */,
1620#endif
1621 __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE))
1622 return 1;
1623 else
1624 return 0;
1625}
1626
1627#elif defined(__GNUC__) && defined(__ATOMIC_RELAXED)
1628/* direct calls using gcc-style compiler built-ins */
1629
1630void wolfSSL_Atomic_Int_Init(wolfSSL_Atomic_Int* c, int i)
1631{
1632 *c = i;
1633}
1634
1635void wolfSSL_Atomic_Uint_Init(wolfSSL_Atomic_Uint* c, unsigned int i)
1636{
1637 *c = i;
1638}
1639
1640int wolfSSL_Atomic_Int_FetchAdd(wolfSSL_Atomic_Int* c, int i)
1641{
1642 return __atomic_fetch_add(c, i, __ATOMIC_RELAXED);
1643}
1644
1645int wolfSSL_Atomic_Int_FetchSub(wolfSSL_Atomic_Int* c, int i)
1646{
1647 return __atomic_fetch_sub(c, i, __ATOMIC_RELAXED);
1648}
1649
1650int wolfSSL_Atomic_Int_AddFetch(wolfSSL_Atomic_Int* c, int i)
1651{
1652 return __atomic_add_fetch(c, i, __ATOMIC_RELAXED);
1653}
1654
1655int wolfSSL_Atomic_Int_SubFetch(wolfSSL_Atomic_Int* c, int i)
1656{
1657 return __atomic_sub_fetch(c, i, __ATOMIC_RELAXED);
1658}
1659
1660int wolfSSL_Atomic_Int_Exchange(wolfSSL_Atomic_Int* c, int new_i)
1661{
1662 return __atomic_exchange_n(c, new_i, __ATOMIC_SEQ_CST);
1663}
1664
1665int wolfSSL_Atomic_Int_CompareExchange(wolfSSL_Atomic_Int* c, int *expected_i,
1666 int new_i)
1667{
1668 /* For the success path, use full synchronization with barriers --
1669 * "Sequentially-consistent ordering" -- so that all threads see the same
1670 * "single total modification order of all atomic operations" -- but on
1671 * failure we just need to be sure we acquire the value that changed out
1672 * from under us.
1673 */
1674 return __atomic_compare_exchange_n(c, expected_i, new_i, 0 /* weak */,
1675 __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE);
1676}
1677
1678unsigned int wolfSSL_Atomic_Uint_FetchAdd(wolfSSL_Atomic_Uint* c,
1679 unsigned int i)
1680{
1681 return __atomic_fetch_add(c, i, __ATOMIC_RELAXED);
1682}
1683
1684unsigned int wolfSSL_Atomic_Uint_FetchSub(wolfSSL_Atomic_Uint* c,
1685 unsigned int i)
1686{
1687 return __atomic_fetch_sub(c, i, __ATOMIC_RELAXED);
1688}
1689
1690unsigned int wolfSSL_Atomic_Uint_AddFetch(wolfSSL_Atomic_Uint* c,
1691 unsigned int i)
1692{
1693 return __atomic_add_fetch(c, i, __ATOMIC_RELAXED);
1694}
1695
1696unsigned int wolfSSL_Atomic_Uint_SubFetch(wolfSSL_Atomic_Uint* c,
1697 unsigned int i)
1698{
1699 return __atomic_sub_fetch(c, i, __ATOMIC_RELAXED);
1700}
1701
1702int wolfSSL_Atomic_Uint_CompareExchange(
1703 wolfSSL_Atomic_Uint* c, unsigned int *expected_i, unsigned int new_i)
1704{
1705 /* For the success path, use full synchronization with barriers --
1706 * "Sequentially-consistent ordering" -- so that all threads see the same
1707 * "single total modification order of all atomic operations" -- but on
1708 * failure we just need to be sure we acquire the value that changed out
1709 * from under us.
1710 */
1711 return __atomic_compare_exchange_n(
1712 c, expected_i, new_i, 0 /* weak */, __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE);
1713}
1714
1715int wolfSSL_Atomic_Ptr_CompareExchange(
1716 void * volatile *c, void **expected_ptr, void *new_ptr)
1717{
1718 return __atomic_compare_exchange_n(
1719 c, expected_ptr, new_ptr, 0 /* weak */,
1720 __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE);
1721}
1722
1723#elif defined(_MSC_VER) && !defined(WOLFSSL_NOT_WINDOWS_API)
1724
1725void wolfSSL_Atomic_Int_Init(wolfSSL_Atomic_Int* c, int i)
1726{
1727 *c = i;
1728}
1729
1730void wolfSSL_Atomic_Uint_Init(wolfSSL_Atomic_Uint* c, unsigned int i)
1731{
1732 *c = i;
1733}
1734
1735int wolfSSL_Atomic_Int_FetchAdd(wolfSSL_Atomic_Int* c, int i)
1736{
1737 return (int)_InterlockedExchangeAdd(c, (long)i);
1738}
1739
1740int wolfSSL_Atomic_Int_FetchSub(wolfSSL_Atomic_Int* c, int i)
1741{
1742 return (int)_InterlockedExchangeAdd(c, (long)-i);
1743}
1744
1745int wolfSSL_Atomic_Int_AddFetch(wolfSSL_Atomic_Int* c, int i)
1746{
1747 int ret = (int)_InterlockedExchangeAdd(c, (long)i);
1748 return ret + i;
1749}
1750
1751int wolfSSL_Atomic_Int_SubFetch(wolfSSL_Atomic_Int* c, int i)
1752{
1753 int ret = (int)_InterlockedExchangeAdd(c, (long)-i);
1754 return ret - i;
1755}
1756
1757int wolfSSL_Atomic_Int_Exchange(wolfSSL_Atomic_Int* c, int new_i)
1758{
1759 long actual_i = InterlockedExchange(c, (long)new_i);
1760 return (int)actual_i;
1761}
1762
1763int wolfSSL_Atomic_Int_CompareExchange(wolfSSL_Atomic_Int* c, int *expected_i,
1764 int new_i)
1765{
1766 long actual_i = InterlockedCompareExchange(c, (long)new_i,
1767 (long)*expected_i);
1768 if (actual_i == (long)*expected_i) {
1769 return 1;
1770 }
1771 else {
1772 *expected_i = (int)actual_i;
1773 return 0;
1774 }
1775}
1776
1777unsigned int wolfSSL_Atomic_Uint_FetchAdd(wolfSSL_Atomic_Uint* c,
1778 unsigned int i)
1779{
1780 return (unsigned int)_InterlockedExchangeAdd((wolfSSL_Atomic_Int *)c,
1781 (long)i);
1782}
1783
1784unsigned int wolfSSL_Atomic_Uint_FetchSub(wolfSSL_Atomic_Uint* c,
1785 unsigned int i)
1786{
1787 return (unsigned int)_InterlockedExchangeAdd((wolfSSL_Atomic_Int *)c,
1788 -(long)i);
1789}
1790
1791unsigned int wolfSSL_Atomic_Uint_AddFetch(wolfSSL_Atomic_Uint* c,
1792 unsigned int i)
1793{
1794 unsigned int ret = (unsigned int)_InterlockedExchangeAdd
1795 ((wolfSSL_Atomic_Int *)c, (long)i);
1796 return ret + i;
1797}
1798
1799unsigned int wolfSSL_Atomic_Uint_SubFetch(wolfSSL_Atomic_Uint* c,
1800 unsigned int i)
1801{
1802 unsigned int ret = (unsigned int)_InterlockedExchangeAdd
1803 ((wolfSSL_Atomic_Int *)c, -(long)i);
1804 return ret - i;
1805}
1806
1807int wolfSSL_Atomic_Uint_CompareExchange(
1808 wolfSSL_Atomic_Uint* c, unsigned int *expected_i, unsigned int new_i)
1809{
1810 long actual_i = InterlockedCompareExchange(
1811 (wolfSSL_Atomic_Int *)c, (long)new_i, (long)*expected_i);
1812 if (actual_i == (long)*expected_i) {
1813 return 1;
1814 }
1815 else {
1816 *expected_i = (unsigned int)actual_i;
1817 return 0;
1818 }
1819}
1820
1821int wolfSSL_Atomic_Ptr_CompareExchange(
1822 void * volatile * c, void **expected_ptr, void *new_ptr)
1823{
1824#ifdef _WIN64
1825 LONG64 actual_ptr = InterlockedCompareExchange64(
1826 (LONG64 *)c, (LONG64)new_ptr, (LONG64)*expected_ptr);
1827 if (actual_ptr == (LONG64)*expected_ptr) {
1828 return 1;
1829 }
1830 else {
1831 *expected_ptr = (void *)actual_ptr;
1832 return 0;
1833 }
1834#else /* !_WIN64 */
1835 LONG actual_ptr = InterlockedCompareExchange(
1836 (LONG *)c, (LONG)new_ptr, (LONG)*expected_ptr);
1837 if (actual_ptr == (LONG)*expected_ptr) {
1838 return 1;
1839 }
1840 else {
1841 *expected_ptr = (void *)actual_ptr;
1842 return 0;
1843 }
1844#endif /* !_WIN64 */
1845}
1846
1847#endif
1848
1849#endif /* WOLFSSL_ATOMIC_OPS */
1850
1851#if !defined(SINGLE_THREADED)
1852
1853void wolfSSL_RefWithMutexInit(wolfSSL_RefWithMutex* ref, int* err)
1854{
1855 int ret = wc_InitMutex(&ref->mutex);
1856 if (ret != 0) {
1857 WOLFSSL_MSG("Failed to create mutex for reference counting!");
1858 }
1859 ref->count = 1;
1860
1861 *err = ret;
1862}
1863
1864void wolfSSL_RefWithMutexFree(wolfSSL_RefWithMutex* ref)
1865{
1866 if (wc_FreeMutex(&ref->mutex) != 0) {
1867 WOLFSSL_MSG("Failed to free mutex of reference counting!");
1868 }
1869 ref->count = 0;
1870}
1871
1872void wolfSSL_RefWithMutexInc(wolfSSL_RefWithMutex* ref, int* err)
1873{
1874 int ret = wc_LockMutex(&ref->mutex);
1875 if (ret != 0) {
1876 WOLFSSL_MSG("Failed to lock mutex for reference increment!");
1877 }
1878 else {
1879 ref->count++;
1880 wc_UnLockMutex(&ref->mutex);
1881 }
1882 *err = ret;
1883}
1884
1885void wolfSSL_RefWithMutexInc2(wolfSSL_RefWithMutex* ref, int *new_count,
1886 int* err)
1887{
1888 int ret = wc_LockMutex(&ref->mutex);
1889 if (ret != 0) {
1890 WOLFSSL_MSG("Failed to lock mutex for reference increment!");
1891 *new_count = -1;
1892 }
1893 else {
1894 *new_count = ++ref->count;
1895 wc_UnLockMutex(&ref->mutex);
1896 }
1897 *err = ret;
1898}
1899
1900int wolfSSL_RefWithMutexLock(wolfSSL_RefWithMutex* ref)
1901{
1902 return wc_LockMutex(&ref->mutex);
1903}
1904
1905int wolfSSL_RefWithMutexUnlock(wolfSSL_RefWithMutex* ref)
1906{
1907 return wc_UnLockMutex(&ref->mutex);
1908}
1909
1910void wolfSSL_RefWithMutexDec(wolfSSL_RefWithMutex* ref, int* isZero, int* err)
1911{
1912 int ret = wc_LockMutex(&ref->mutex);
1913 if (ret != 0) {
1914 WOLFSSL_MSG("Failed to lock mutex for reference decrement!");
1915 /* Can't say count is zero. */
1916 *isZero = 0;
1917 }
1918 else {
1919 if (ref->count > 0) {
1920 ref->count--;
1921 }
1922 *isZero = (ref->count == 0);
1923 wc_UnLockMutex(&ref->mutex);
1924 }
1925 *err = ret;
1926}
1927
1928void wolfSSL_RefWithMutexDec2(wolfSSL_RefWithMutex* ref, int* new_count,
1929 int* err)
1930{
1931 int ret = wc_LockMutex(&ref->mutex);
1932 if (ret != 0) {
1933 WOLFSSL_MSG("Failed to lock mutex for reference decrement!");
1934 *new_count = -1;
1935 }
1936 else {
1937 if (ref->count > 0) {
1938 ref->count--;
1939 }
1940 *new_count = ref->count;
1941 wc_UnLockMutex(&ref->mutex);
1942 }
1943 *err = ret;
1944}
1945#endif /* ! SINGLE_THREADED */
1946
1947#if WOLFSSL_CRYPT_HW_MUTEX
1948/* Mutex for protection of cryptography hardware */
1949static wolfSSL_Mutex wcCryptHwMutex
1950 WOLFSSL_MUTEX_INITIALIZER_CLAUSE(wcCryptHwMutex);
1951#ifndef WOLFSSL_MUTEX_INITIALIZER
1952static int wcCryptHwMutexInit = 0;
1953#endif
1954
1955int wolfSSL_CryptHwMutexInit(void)
1956{
1957 int ret = 0;
1958#ifndef WOLFSSL_MUTEX_INITIALIZER
1959 if (wcCryptHwMutexInit == 0) {
1960 ret = wc_InitMutex(&wcCryptHwMutex);
1961 if (ret == 0) {
1962 wcCryptHwMutexInit = 1;
1963 }
1964 }
1965#endif
1966 return ret;
1967}
1968int wolfSSL_CryptHwMutexLock(void)
1969{
1970 /* Make sure HW Mutex has been initialized */
1971 int ret = wolfSSL_CryptHwMutexInit();
1972 if (ret == 0) {
1973 ret = wc_LockMutex(&wcCryptHwMutex);
1974 }
1975 return ret;
1976}
1977int wolfSSL_CryptHwMutexUnLock(void)
1978{
1979 if (wcCryptHwMutexInit) {
1980 return wc_UnLockMutex(&wcCryptHwMutex);
1981 }
1982 else {
1983 return BAD_MUTEX_E;
1984 }
1985}
1986#endif /* WOLFSSL_CRYPT_HW_MUTEX */
1987
1988
1989#if WOLFSSL_CRYPT_HW_MUTEX && defined(WOLFSSL_ALGO_HW_MUTEX)
1990/* Mutex for protection of cryptography hardware */
1991#ifndef NO_RNG_MUTEX
1992static wolfSSL_Mutex wcCryptHwRngMutex
1993 WOLFSSL_MUTEX_INITIALIZER_CLAUSE(wcCryptHwRngMutex);
1994#endif /* NO_RNG_MUTEX */
1995#ifndef NO_AES_MUTEX
1996static wolfSSL_Mutex wcCryptHwAesMutex
1997 WOLFSSL_MUTEX_INITIALIZER_CLAUSE(wcCryptHwAesMutex);
1998#endif /* NO_AES_MUTEX */
1999#ifndef NO_HASH_MUTEX
2000static wolfSSL_Mutex wcCryptHwHashMutex
2001 WOLFSSL_MUTEX_INITIALIZER_CLAUSE(wcCryptHwHashMutex);
2002#endif /* NO_HASH_MUTEX */
2003#ifndef NO_PK_MUTEX
2004static wolfSSL_Mutex wcCryptHwPkMutex
2005 WOLFSSL_MUTEX_INITIALIZER_CLAUSE(wcCryptHwPkMutex);
2006#endif /* NO_PK_MUTEX */
2007
2008#ifndef WOLFSSL_MUTEX_INITIALIZER
2009#ifndef NO_RNG_MUTEX
2010static int wcCryptHwRngMutexInit = 0;
2011#endif /* NO_RNG_MUTEX */
2012#ifndef NO_AES_MUTEX
2013static int wcCryptHwAesMutexInit = 0;
2014#endif /* NO_AES_MUTEX */
2015#ifndef NO_HASH_MUTEX
2016static int wcCryptHwHashMutexInit = 0;
2017#endif /* NO_HASH_MUTEX */
2018#ifndef NO_PK_MUTEX
2019static int wcCryptHwPkMutexInit = 0;
2020#endif /* NO_PK_MUTEX */
2021#endif /* WOLFSSL_MUTEX_INITIALIZER */
2022
2023
2024/* Allows ability to switch to different mutex based on enum type */
2025/* hw_mutex_algo, expects the dereferenced Ptrs to be set to NULL */
2026static int hwAlgoPtrSet(hw_mutex_algo hwAlgo, wolfSSL_Mutex** wcHwAlgoMutexPtr,
2027 int** wcHwAlgoInitPtr)
2028{
2029 if (*wcHwAlgoMutexPtr != NULL || *wcHwAlgoInitPtr != NULL) {
2030 return BAD_FUNC_ARG;
2031 }
2032 switch (hwAlgo) {
2033 #ifndef NO_RNG_MUTEX
2034 case rng_mutex:
2035 *wcHwAlgoMutexPtr = &wcCryptHwRngMutex;
2036 *wcHwAlgoInitPtr = &wcCryptHwRngMutexInit;
2037 break;
2038 #endif
2039 #ifndef NO_AES_MUTEX
2040 case aes_mutex:
2041 *wcHwAlgoMutexPtr = &wcCryptHwAesMutex;
2042 *wcHwAlgoInitPtr = &wcCryptHwAesMutexInit;
2043 break;
2044 #endif
2045 #ifndef NO_HASH_MUTEX
2046 case hash_mutex:
2047 *wcHwAlgoMutexPtr = &wcCryptHwHashMutex;
2048 *wcHwAlgoInitPtr = &wcCryptHwHashMutexInit;
2049 break;
2050 #endif
2051 #ifndef NO_PK_MUTEX
2052 case pk_mutex:
2053 *wcHwAlgoMutexPtr = &wcCryptHwPkMutex;
2054 *wcHwAlgoInitPtr = &wcCryptHwPkMutexInit;
2055 break;
2056 #endif
2057 default:
2058 return BAD_FUNC_ARG;
2059 }
2060 return 0;
2061}
2062
2063static int hwAlgoMutexInit(hw_mutex_algo hwAlgo)
2064{
2065 int ret = 0;
2066#ifndef WOLFSSL_MUTEX_INITIALIZER
2067 wolfSSL_Mutex* wcHwAlgoMutexPtr = NULL;
2068 int* wcHwAlgoInitPtr = NULL;
2069 ret = hwAlgoPtrSet(hwAlgo, &wcHwAlgoMutexPtr, &wcHwAlgoInitPtr);
2070 if (ret != 0) {
2071 return ret;
2072 }
2073 if (*wcHwAlgoInitPtr == 0) {
2074 ret = wc_InitMutex(wcHwAlgoMutexPtr);
2075 if (ret == 0) {
2076 *wcHwAlgoInitPtr = 1;
2077 }
2078 }
2079#endif
2080 return ret;
2081}
2082
2083static int hwAlgoMutexLock(hw_mutex_algo hwAlgo)
2084{
2085 /* Make sure HW Mutex has been initialized */
2086 int ret = 0;
2087 wolfSSL_Mutex* wcHwAlgoMutexPtr = NULL;
2088 int* wcHwAlgoInitPtr = NULL;
2089 ret = hwAlgoPtrSet(hwAlgo, &wcHwAlgoMutexPtr, &wcHwAlgoInitPtr);
2090 if (ret != 0) {
2091 return ret;
2092 }
2093 ret = hwAlgoMutexInit(hwAlgo);
2094 if (ret == 0) {
2095 ret = wc_LockMutex(wcHwAlgoMutexPtr);
2096 }
2097 return ret;
2098}
2099
2100static int hwAlgoMutexUnLock(hw_mutex_algo hwAlgo)
2101{
2102 wolfSSL_Mutex* wcHwAlgoMutexPtr = NULL;
2103 int* wcHwAlgoInitPtr = NULL;
2104 if (hwAlgoPtrSet(hwAlgo, &wcHwAlgoMutexPtr, &wcHwAlgoInitPtr) != 0) {
2105 return BAD_FUNC_ARG;
2106 }
2107 if (*wcHwAlgoInitPtr) {
2108 return wc_UnLockMutex(wcHwAlgoMutexPtr);
2109 }
2110 else {
2111 return BAD_MUTEX_E;
2112 }
2113}
2114
2115/* Wrap around generic hwAlgo* functions and use correct */
2116/* global mutex to determine if it can be unlocked/locked */
2117#ifndef NO_RNG_MUTEX
2118int wolfSSL_HwRngMutexInit(void)
2119{
2120 return hwAlgoMutexInit(rng_mutex);
2121}
2122int wolfSSL_HwRngMutexLock(void)
2123{
2124 return hwAlgoMutexLock(rng_mutex);
2125}
2126int wolfSSL_HwRngMutexUnLock(void)
2127{
2128 return hwAlgoMutexUnLock(rng_mutex);
2129}
2130#endif /* NO_RNG_MUTEX */
2131
2132#ifndef NO_AES_MUTEX
2133int wolfSSL_HwAesMutexInit(void)
2134{
2135 return hwAlgoMutexInit(aes_mutex);
2136}
2137int wolfSSL_HwAesMutexLock(void)
2138{
2139 return hwAlgoMutexLock(aes_mutex);
2140}
2141int wolfSSL_HwAesMutexUnLock(void)
2142{
2143 return hwAlgoMutexUnLock(aes_mutex);
2144}
2145#endif /* NO_AES_MUTEX */
2146
2147#ifndef NO_HASH_MUTEX
2148int wolfSSL_HwHashMutexInit(void)
2149{
2150 return hwAlgoMutexInit(hash_mutex);
2151}
2152int wolfSSL_HwHashMutexLock(void)
2153{
2154 return hwAlgoMutexLock(hash_mutex);
2155}
2156int wolfSSL_HwHashMutexUnLock(void)
2157{
2158 return hwAlgoMutexUnLock(hash_mutex);
2159}
2160#endif /* NO_HASH_MUTEX */
2161
2162#ifndef NO_PK_MUTEX
2163int wolfSSL_HwPkMutexInit(void)
2164{
2165 return hwAlgoMutexInit(pk_mutex);
2166}
2167int wolfSSL_HwPkMutexLock(void)
2168{
2169 return hwAlgoMutexLock(pk_mutex);
2170}
2171int wolfSSL_HwPkMutexUnLock(void)
2172{
2173 return hwAlgoMutexUnLock(pk_mutex);
2174}
2175#endif /* NO_PK_MUTEX */
2176
2177#endif /* WOLFSSL_CRYPT_HW_MUTEX && defined(WOLFSSL_ALGO_HW_MUTEX) */
2178
2179/* ---------------------------------------------------------------------------*/
2180/* Mutex Ports */
2181/* ---------------------------------------------------------------------------*/
2182#if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER)
2183 static mutex_cb* compat_mutex_cb = NULL;
2184
2185 /* Function that locks or unlocks a mutex based on the flag passed in.
2186 *
2187 * flag lock or unlock i.e. CRYPTO_LOCK
2188 * type the type of lock to unlock or lock
2189 * file name of the file calling
2190 * line the line number from file calling
2191 */
2192 int wc_LockMutex_ex(int flag, int type, const char* file, int line)
2193 {
2194 if (compat_mutex_cb != NULL) {
2195 compat_mutex_cb(flag, type, file, line);
2196 return 0;
2197 }
2198 else {
2199 WOLFSSL_MSG("Mutex call back function not set. Call wc_SetMutexCb");
2200 return BAD_STATE_E;
2201 }
2202 }
2203
2204
2205 /* Set the callback function to use for locking/unlocking mutex
2206 *
2207 * cb callback function to use
2208 */
2209 int wc_SetMutexCb(mutex_cb* cb)
2210 {
2211 compat_mutex_cb = cb;
2212 return 0;
2213 }
2214
2215 /* Gets the current callback function in use for locking/unlocking mutex
2216 *
2217 */
2218 mutex_cb* wc_GetMutexCb(void)
2219 {
2220 return compat_mutex_cb;
2221 }
2222#endif /* defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER) */
2223
2224#if defined(WC_MUTEX_OPS_INLINE)
2225
2226 /* defined in headers */
2227
2228#elif defined(SINGLE_THREADED)
2229
2230 int wc_InitMutex(wolfSSL_Mutex* m)
2231 {
2232 (void)m;
2233 return 0;
2234 }
2235
2236 int wc_FreeMutex(wolfSSL_Mutex *m)
2237 {
2238 (void)m;
2239 return 0;
2240 }
2241
2242
2243 int wc_LockMutex(wolfSSL_Mutex *m)
2244 {
2245 (void)m;
2246 return 0;
2247 }
2248
2249
2250 int wc_UnLockMutex(wolfSSL_Mutex *m)
2251 {
2252 (void)m;
2253 return 0;
2254 }
2255
2256#elif defined(__WATCOMC__)
2257
2258 int wc_InitMutex(wolfSSL_Mutex* m)
2259 {
2260 #ifdef __OS2__
2261 DosCreateMutexSem( NULL, m, 0, FALSE );
2262 #elif defined(__NT__)
2263 InitializeCriticalSection(m);
2264 #elif defined(__LINUX__)
2265 if (pthread_mutex_init(m, NULL) )
2266 return BAD_MUTEX_E;
2267 #endif
2268 return 0;
2269 }
2270
2271 int wc_FreeMutex(wolfSSL_Mutex* m)
2272 {
2273 #ifdef __OS2__
2274 DosCloseMutexSem(*m);
2275 #elif defined(__NT__)
2276 DeleteCriticalSection(m);
2277 #elif defined(__LINUX__)
2278 if (pthread_mutex_destroy(m) )
2279 return BAD_MUTEX_E;
2280 #endif
2281 return 0;
2282 }
2283
2284 int wc_LockMutex(wolfSSL_Mutex* m)
2285 {
2286 #ifdef __OS2__
2287 DosRequestMutexSem(*m, SEM_INDEFINITE_WAIT);
2288 #elif defined(__NT__)
2289 EnterCriticalSection(m);
2290 #elif defined(__LINUX__)
2291 if (pthread_mutex_lock(m) )
2292 return BAD_MUTEX_E;
2293 #endif
2294 return 0;
2295 }
2296
2297 int wc_UnLockMutex(wolfSSL_Mutex* m)
2298 {
2299 #ifdef __OS2__
2300 DosReleaseMutexSem(*m);
2301 #elif defined(__NT__)
2302 LeaveCriticalSection(m);
2303 #elif defined(__LINUX__)
2304 if (pthread_mutex_unlock(m) )
2305 return BAD_MUTEX_E;
2306 #endif
2307 return 0;
2308 }
2309
2310 #if defined(WOLFSSL_USE_RWLOCK) && defined(__LINUX__)
2311
2312 int wc_InitRwLock(wolfSSL_RwLock* m)
2313 {
2314 if (pthread_rwlock_init(m, NULL) )
2315 return BAD_MUTEX_E;
2316 return 0;
2317 }
2318
2319 int wc_FreeRwLock(wolfSSL_RwLock* m)
2320 {
2321 if (pthread_rwlock_destroy(m) )
2322 return BAD_MUTEX_E;
2323 return 0;
2324 }
2325
2326 int wc_LockRwLock_Wr(wolfSSL_RwLock* m)
2327 {
2328 if (pthread_rwlock_wrlock(m) )
2329 return BAD_MUTEX_E;
2330 return 0;
2331 }
2332
2333 int wc_LockRwLock_Rd(wolfSSL_RwLock* m)
2334 {
2335 if (pthread_rwlock_rdlock(m) )
2336 return BAD_MUTEX_E;
2337 return 0;
2338 }
2339
2340 int wc_UnLockRwLock(wolfSSL_RwLock* m)
2341 {
2342 if (pthread_rwlock_unlock(m) == 0)
2343 return BAD_MUTEX_E;
2344 return 0;
2345 }
2346
2347 #endif
2348
2349#elif defined(FREERTOS) || defined(FREERTOS_TCP) || \
2350 defined(FREESCALE_FREE_RTOS)
2351
2352 int wc_InitMutex(wolfSSL_Mutex* m)
2353 {
2354 int iReturn;
2355
2356 *m = ( wolfSSL_Mutex ) xSemaphoreCreateMutex();
2357 if( *m != NULL )
2358 iReturn = 0;
2359 else
2360 iReturn = BAD_MUTEX_E;
2361
2362 return iReturn;
2363 }
2364
2365 int wc_FreeMutex(wolfSSL_Mutex* m)
2366 {
2367 vSemaphoreDelete( *m );
2368 return 0;
2369 }
2370
2371 int wc_LockMutex(wolfSSL_Mutex* m)
2372 {
2373 /* Assume an infinite block, or should there be zero block? */
2374 xSemaphoreTake( *m, portMAX_DELAY );
2375 return 0;
2376 }
2377
2378 int wc_UnLockMutex(wolfSSL_Mutex* m)
2379 {
2380 xSemaphoreGive( *m );
2381 return 0;
2382 }
2383
2384#elif defined(RTTHREAD)
2385
2386 int wc_InitMutex(wolfSSL_Mutex* m)
2387 {
2388 int iReturn;
2389
2390 *m = ( wolfSSL_Mutex ) rt_mutex_create("mutex",RT_IPC_FLAG_FIFO);
2391 if( *m != NULL )
2392 iReturn = 0;
2393 else
2394 iReturn = BAD_MUTEX_E;
2395
2396
2397 return iReturn;
2398 }
2399
2400 int wc_FreeMutex(wolfSSL_Mutex* m)
2401 {
2402 rt_mutex_delete( *m );
2403 return 0;
2404 }
2405
2406
2407 int wc_LockMutex(wolfSSL_Mutex* m)
2408 {
2409 /* Assume an infinite block, or should there be zero block? */
2410 return rt_mutex_take( *m, RT_WAITING_FOREVER );
2411 }
2412
2413 int wc_UnLockMutex(wolfSSL_Mutex* m)
2414 {
2415 return rt_mutex_release( *m );
2416 }
2417
2418#elif defined(WOLFSSL_SAFERTOS)
2419
2420 int wc_InitMutex(wolfSSL_Mutex* m)
2421 {
2422 vSemaphoreCreateBinary(m->mutexBuffer, m->mutex);
2423 if (m->mutex == NULL)
2424 return BAD_MUTEX_E;
2425
2426 return 0;
2427 }
2428
2429 int wc_FreeMutex(wolfSSL_Mutex* m)
2430 {
2431 (void)m;
2432 return 0;
2433 }
2434
2435 int wc_LockMutex(wolfSSL_Mutex* m)
2436 {
2437 /* Assume an infinite block */
2438 xSemaphoreTake(m->mutex, portMAX_DELAY);
2439 return 0;
2440 }
2441
2442 int wc_UnLockMutex(wolfSSL_Mutex* m)
2443 {
2444 xSemaphoreGive(m->mutex);
2445 return 0;
2446 }
2447
2448#elif defined(USE_WINDOWS_API) && !defined(WOLFSSL_PTHREADS)
2449
2450 int wc_InitMutex(wolfSSL_Mutex* m)
2451 {
2452 InitializeCriticalSection(m);
2453 return 0;
2454 }
2455
2456
2457 int wc_FreeMutex(wolfSSL_Mutex* m)
2458 {
2459 DeleteCriticalSection(m);
2460 return 0;
2461 }
2462
2463
2464 int wc_LockMutex(wolfSSL_Mutex* m)
2465 {
2466 EnterCriticalSection(m);
2467 return 0;
2468 }
2469
2470
2471 int wc_UnLockMutex(wolfSSL_Mutex* m)
2472 {
2473 LeaveCriticalSection(m);
2474 return 0;
2475 }
2476
2477#elif defined(MAXQ10XX_MUTEX)
2478 static pthread_mutex_t *wcCryptHwSharedMutexPtr;
2479 static pthread_once_t key_once_own_hw_mutex = PTHREAD_ONCE_INIT;
2480 static pthread_key_t key_own_hw_mutex;
2481
2482 static void destruct_key(void *buf)
2483 {
2484 if (buf != NULL) {
2485 XFREE(buf, NULL, DYNAMIC_TYPE_OS_BUF);
2486 }
2487 }
2488
2489 static void make_key_own_hw_mutex(void)
2490 {
2491 (void)pthread_key_create(&key_own_hw_mutex, destruct_key);
2492 }
2493
2494 int wc_InitMutex(wolfSSL_Mutex* m)
2495 {
2496 int created = 0;
2497 void *addr = NULL;
2498
2499 if (m != &wcCryptHwMutex) {
2500 if (pthread_mutex_init(m, 0) == 0) {
2501 return 0;
2502 }
2503 return BAD_MUTEX_E;
2504 }
2505
2506 /* try to open mutex memory */
2507 int shm_fd = shm_open("/maxq-mutex", O_RDWR, 0666);
2508 if (shm_fd < 0) {
2509 /* create mutex memory */
2510 shm_fd = shm_open("/maxq-mutex", O_RDWR | O_CREAT | O_EXCL, 0666);
2511 created = 1;
2512 }
2513
2514 if (shm_fd < 0) {
2515 WOLFSSL_MSG("wc_InitMutex: shm_open() failed");
2516 return BAD_MUTEX_E;
2517 }
2518
2519 if (ftruncate(shm_fd, sizeof(pthread_mutex_t))) {
2520 WOLFSSL_MSG("wc_InitMutex: ftruncate() failed");
2521 return BAD_MUTEX_E;
2522 }
2523
2524 addr = mmap(NULL, sizeof(pthread_mutex_t), PROT_READ | PROT_WRITE,
2525 MAP_SHARED, shm_fd, 0);
2526
2527 if (addr == MAP_FAILED) {
2528 WOLFSSL_MSG("wc_InitMutex: mmap() failed");
2529 return BAD_MUTEX_E;
2530 }
2531
2532 wcCryptHwSharedMutexPtr = (pthread_mutex_t *)addr;
2533
2534 if (close(shm_fd)) {
2535 WOLFSSL_MSG("wc_InitMutex: close() failed");
2536 return BAD_MUTEX_E;
2537 }
2538
2539 if (created) {
2540 /* initialize mutex */
2541 pthread_mutexattr_t attr;
2542 if (pthread_mutexattr_init(&attr)) {
2543 WOLFSSL_MSG("wc_InitMutex: pthread_mutexattr_init() failed");
2544 return BAD_MUTEX_E;
2545 }
2546
2547 if (pthread_mutexattr_setpshared(&attr,
2548 PTHREAD_PROCESS_SHARED)) {
2549 WOLFSSL_MSG(
2550 "wc_InitMutex: pthread_mutexattr_setpshared() failed");
2551 return BAD_MUTEX_E;
2552 }
2553
2554 if (pthread_mutex_init(wcCryptHwSharedMutexPtr, &attr)) {
2555 WOLFSSL_MSG("wc_InitMutex: pthread_mutex_init() failed");
2556 return BAD_MUTEX_E;
2557 }
2558 }
2559
2560 if (pthread_once(&key_once_own_hw_mutex, make_key_own_hw_mutex)) {
2561 WOLFSSL_MSG("wc_InitMutex: pthread_once() failed");
2562 return BAD_MUTEX_E;
2563 }
2564
2565 return 0;
2566 }
2567
2568 int wc_FreeMutex(wolfSSL_Mutex* m)
2569 {
2570 void *key_ptr = NULL;
2571 if (m != &wcCryptHwMutex) {
2572 if (pthread_mutex_destroy(m) == 0) {
2573 return 0;
2574 }
2575 return BAD_MUTEX_E;
2576 }
2577
2578 if (wcCryptHwSharedMutexPtr) {
2579 if (munmap((void *)wcCryptHwSharedMutexPtr,
2580 sizeof(pthread_mutex_t))) {
2581 WOLFSSL_MSG("wc_FreeMutex: munmap() failed");
2582 return BAD_MUTEX_E;
2583 }
2584
2585 wcCryptHwSharedMutexPtr = NULL;
2586 }
2587
2588 key_ptr = pthread_getspecific(key_own_hw_mutex);
2589 if (key_ptr) {
2590 *((int *)key_ptr) = 0;
2591 }
2592
2593 return 0;
2594 }
2595
2596 static int maxq_LockMutex(wolfSSL_Mutex* m, int trylock)
2597 {
2598 void *key_ptr = NULL;
2599 int ret = 0;
2600
2601 if (m != &wcCryptHwMutex) {
2602 if (pthread_mutex_lock(m) == 0) {
2603 return 0;
2604 }
2605 return BAD_MUTEX_E;
2606 }
2607
2608 if (wcCryptHwSharedMutexPtr == NULL) {
2609 return BAD_MUTEX_E;
2610 }
2611
2612 key_ptr = pthread_getspecific(key_own_hw_mutex);
2613 if (key_ptr == NULL) {
2614 key_ptr = XMALLOC(sizeof(int), NULL, DYNAMIC_TYPE_OS_BUF);
2615 if (key_ptr == NULL) {
2616 return MEMORY_E;
2617 }
2618
2619 memset(key_ptr, 0, sizeof(int));
2620
2621 if (pthread_setspecific(key_own_hw_mutex, key_ptr)) {
2622 return THREAD_STORE_SET_E;
2623 }
2624 }
2625 else {
2626 if ((trylock == 0) && (*((int *)key_ptr) > 0)) {
2627 *((int *)key_ptr) = *((int *)key_ptr) + 1;
2628 return 0;
2629 }
2630 }
2631
2632 if (trylock) {
2633 ret = pthread_mutex_trylock(wcCryptHwSharedMutexPtr);
2634 }
2635 else {
2636 ret = pthread_mutex_lock(wcCryptHwSharedMutexPtr);
2637 }
2638
2639 if (ret != 0) {
2640 return BAD_MUTEX_E;
2641 }
2642
2643 *((int *)key_ptr) = 1;
2644 return 0;
2645 }
2646
2647 int wc_LockMutex(wolfSSL_Mutex* m)
2648 {
2649 return maxq_LockMutex(m, 0);
2650 }
2651
2652 int maxq_CryptHwMutexTryLock()
2653 {
2654 /* Make sure HW Mutex has been initialized */
2655 int ret = wolfSSL_CryptHwMutexInit();
2656 if (ret == 0) {
2657 ret = maxq_LockMutex(&wcCryptHwMutex, 1);
2658 }
2659 return ret;
2660 }
2661
2662 int wc_UnLockMutex(wolfSSL_Mutex* m)
2663 {
2664 void *key_ptr = NULL;
2665
2666 if (m != &wcCryptHwMutex) {
2667 if (pthread_mutex_unlock(m) == 0) {
2668 return 0;
2669 }
2670 return BAD_MUTEX_E;
2671 }
2672
2673 if (wcCryptHwSharedMutexPtr == NULL) {
2674 return BAD_MUTEX_E;
2675 }
2676
2677 key_ptr = pthread_getspecific(key_own_hw_mutex);
2678 if (key_ptr) {
2679 if (*((int *)key_ptr) > 0) {
2680 *((int *)key_ptr) = *((int *)key_ptr) - 1;
2681 if (*((int *)key_ptr) > 0) {
2682 return 0;
2683 }
2684 }
2685 }
2686
2687 if (pthread_mutex_unlock(wcCryptHwSharedMutexPtr) != 0) {
2688 return BAD_MUTEX_E;
2689 }
2690 return 0;
2691 }
2692
2693#elif defined(WOLFSSL_PTHREADS)
2694
2695 #ifdef WOLFSSL_USE_RWLOCK
2696 int wc_InitRwLock(wolfSSL_RwLock* m)
2697 {
2698 if (pthread_rwlock_init(m, NULL) == 0)
2699 return 0;
2700 else
2701 return BAD_MUTEX_E;
2702 }
2703
2704 int wc_FreeRwLock(wolfSSL_RwLock* m)
2705 {
2706 if (pthread_rwlock_destroy(m) == 0)
2707 return 0;
2708 else
2709 return BAD_MUTEX_E;
2710 }
2711
2712 int wc_LockRwLock_Wr(wolfSSL_RwLock* m)
2713 {
2714 if (pthread_rwlock_wrlock(m) == 0)
2715 return 0;
2716 else
2717 return BAD_MUTEX_E;
2718 }
2719
2720 int wc_LockRwLock_Rd(wolfSSL_RwLock* m)
2721 {
2722 if (pthread_rwlock_rdlock(m) == 0)
2723 return 0;
2724 else
2725 return BAD_MUTEX_E;
2726 }
2727
2728 int wc_UnLockRwLock(wolfSSL_RwLock* m)
2729 {
2730 if (pthread_rwlock_unlock(m) == 0)
2731 return 0;
2732 else
2733 return BAD_MUTEX_E;
2734 }
2735 #endif
2736
2737 int wc_InitMutex(wolfSSL_Mutex* m)
2738 {
2739 if (pthread_mutex_init(m, NULL) == 0)
2740 return 0;
2741 else
2742 return BAD_MUTEX_E;
2743 }
2744
2745
2746 int wc_FreeMutex(wolfSSL_Mutex* m)
2747 {
2748 if (pthread_mutex_destroy(m) == 0)
2749 return 0;
2750 else
2751 return BAD_MUTEX_E;
2752 }
2753
2754
2755 int wc_LockMutex(wolfSSL_Mutex* m)
2756 {
2757 if (pthread_mutex_lock(m) == 0)
2758 return 0;
2759 else
2760 return BAD_MUTEX_E;
2761 }
2762
2763
2764 int wc_UnLockMutex(wolfSSL_Mutex* m)
2765 {
2766 if (pthread_mutex_unlock(m) == 0)
2767 return 0;
2768 else
2769 return BAD_MUTEX_E;
2770 }
2771#elif defined(WOLFSSL_VXWORKS)
2772
2773 int wc_InitMutex(wolfSSL_Mutex* m)
2774 {
2775 if (m) {
2776 if ((*m = semMCreate(0)) != SEM_ID_NULL)
2777 return 0;
2778 }
2779 return BAD_MUTEX_E;
2780 }
2781
2782
2783 int wc_FreeMutex(wolfSSL_Mutex* m)
2784 {
2785 if (m) {
2786 if (semDelete(*m) == OK)
2787 return 0;
2788 }
2789 return BAD_MUTEX_E;
2790 }
2791
2792
2793 int wc_LockMutex(wolfSSL_Mutex* m)
2794 {
2795 if (m) {
2796 if (semTake(*m, WAIT_FOREVER) == OK)
2797 return 0;
2798 }
2799 return BAD_MUTEX_E;
2800 }
2801
2802
2803 int wc_UnLockMutex(wolfSSL_Mutex* m)
2804 {
2805 if (m) {
2806 if (semGive(*m) == OK)
2807 return 0;
2808 }
2809 return BAD_MUTEX_E;
2810 }
2811
2812#elif defined(THREADX)
2813
2814 int wc_InitMutex(wolfSSL_Mutex* m)
2815 {
2816 if (tx_mutex_create(m, (CHAR*)"wolfSSL Mutex", TX_NO_INHERIT) == 0)
2817 return 0;
2818 else
2819 return BAD_MUTEX_E;
2820 }
2821
2822
2823 int wc_FreeMutex(wolfSSL_Mutex* m)
2824 {
2825 if (tx_mutex_delete(m) == 0)
2826 return 0;
2827 else
2828 return BAD_MUTEX_E;
2829 }
2830
2831
2832 int wc_LockMutex(wolfSSL_Mutex* m)
2833 {
2834 if (tx_mutex_get(m, TX_WAIT_FOREVER) == 0)
2835 return 0;
2836 else
2837 return BAD_MUTEX_E;
2838 }
2839
2840 int wc_UnLockMutex(wolfSSL_Mutex* m)
2841 {
2842 if (tx_mutex_put(m) == 0)
2843 return 0;
2844 else
2845 return BAD_MUTEX_E;
2846 }
2847
2848#elif defined(WOLFSSL_DEOS)
2849
2850 int wc_InitMutex(wolfSSL_Mutex* m)
2851 {
2852 mutexStatus mutStat;
2853 /*
2854 The empty string "" denotes an anonymous mutex, so objects do not cause name collisions.
2855 `protectWolfSSLTemp` in an XML configuration element template describing a mutex.
2856 */
2857 if (m) {
2858 mutStat = createMutex("", "protectWolfSSLTemp", m);
2859 if (mutStat == mutexSuccess)
2860 return 0;
2861 else{
2862 WOLFSSL_MSG("wc_InitMutex failed");
2863 return mutStat;
2864 }
2865 }
2866 return BAD_MUTEX_E;
2867 }
2868
2869 int wc_FreeMutex(wolfSSL_Mutex* m)
2870 {
2871 mutexStatus mutStat;
2872 if (m) {
2873 mutStat = deleteMutex(*m);
2874 if (mutStat == mutexSuccess)
2875 return 0;
2876 else{
2877 WOLFSSL_MSG("wc_FreeMutex failed");
2878 return mutStat;
2879 }
2880 }
2881 return BAD_MUTEX_E;
2882 }
2883
2884 int wc_LockMutex(wolfSSL_Mutex* m)
2885 {
2886 mutexStatus mutStat;
2887 if (m) {
2888 mutStat = lockMutex(*m);
2889 if (mutStat == mutexSuccess)
2890 return 0;
2891 else{
2892 WOLFSSL_MSG("wc_LockMutex failed");
2893 return mutStat;
2894 }
2895 }
2896 return BAD_MUTEX_E;
2897 }
2898
2899 int wc_UnLockMutex(wolfSSL_Mutex* m)
2900 {
2901 mutexStatus mutStat;
2902 if (m) {
2903 mutStat = unlockMutex(*m);
2904 if (mutStat== mutexSuccess)
2905 return 0;
2906 else{
2907 WOLFSSL_MSG("wc_UnLockMutex failed");
2908 return mutStat;
2909 }
2910 }
2911 return BAD_MUTEX_E;
2912 }
2913
2914#elif defined(MICRIUM)
2915 #if (OS_VERSION < 50000)
2916 #define MICRIUM_ERR_TYPE OS_ERR
2917 #define MICRIUM_ERR_NONE OS_ERR_NONE
2918 #define MICRIUM_ERR_CODE(err) err
2919 #else
2920 #define MICRIUM_ERR_TYPE RTOS_ERR
2921 #define MICRIUM_ERR_NONE RTOS_ERR_NONE
2922 #define MICRIUM_ERR_CODE(err) RTOS_ERR_CODE_GET(err)
2923 #endif
2924
2925 int wc_InitMutex(wolfSSL_Mutex* m)
2926 {
2927 MICRIUM_ERR_TYPE err;
2928
2929 OSMutexCreate(m, "wolfSSL Mutex", &err);
2930
2931 if (MICRIUM_ERR_CODE(err) == MICRIUM_ERR_NONE)
2932 return 0;
2933 else
2934 return BAD_MUTEX_E;
2935 }
2936
2937 int wc_FreeMutex(wolfSSL_Mutex* m)
2938 {
2939 #if (OS_CFG_MUTEX_DEL_EN == DEF_ENABLED)
2940 MICRIUM_ERR_TYPE err;
2941
2942 OSMutexDel(m, OS_OPT_DEL_ALWAYS, &err);
2943
2944 if (MICRIUM_ERR_CODE(err) == MICRIUM_ERR_NONE)
2945 return 0;
2946 else
2947 return BAD_MUTEX_E;
2948 #else
2949 (void)m;
2950 return 0;
2951 #endif
2952 }
2953
2954 int wc_LockMutex(wolfSSL_Mutex* m)
2955 {
2956 MICRIUM_ERR_TYPE err;
2957
2958 OSMutexPend(m, 0, OS_OPT_PEND_BLOCKING, NULL, &err);
2959
2960 if (MICRIUM_ERR_CODE(err) == MICRIUM_ERR_NONE)
2961 return 0;
2962 else
2963 return BAD_MUTEX_E;
2964 }
2965
2966 int wc_UnLockMutex(wolfSSL_Mutex* m)
2967 {
2968 MICRIUM_ERR_TYPE err;
2969
2970 OSMutexPost(m, OS_OPT_POST_NONE, &err);
2971
2972 if (MICRIUM_ERR_CODE(err) == MICRIUM_ERR_NONE)
2973 return 0;
2974 else
2975 return BAD_MUTEX_E;
2976 }
2977
2978#elif defined(EBSNET)
2979 #if (defined(RTPLATFORM) && (RTPLATFORM != 0))
2980 int wc_InitMutex(wolfSSL_Mutex* m)
2981 {
2982 if (rtp_sig_mutex_alloc(m, "wolfSSL Mutex") == -1)
2983 return BAD_MUTEX_E;
2984 else
2985 return 0;
2986 }
2987
2988 int wc_FreeMutex(wolfSSL_Mutex* m)
2989 {
2990 rtp_sig_mutex_free(*m);
2991 return 0;
2992 }
2993
2994 int wc_LockMutex(wolfSSL_Mutex* m)
2995 {
2996 if (rtp_sig_mutex_claim_timed(*m, RTIP_INF) == 0)
2997 return 0;
2998 else
2999 return BAD_MUTEX_E;
3000 }
3001
3002 int wc_UnLockMutex(wolfSSL_Mutex* m)
3003 {
3004 rtp_sig_mutex_release(*m);
3005 return 0;
3006 }
3007
3008 int ebsnet_fseek(int a, long b, int c)
3009 {
3010 int retval;
3011
3012 retval = vf_lseek(a, b, c);
3013 if (retval > 0)
3014 retval = 0;
3015 else
3016 retval = -1;
3017
3018 return(retval);
3019 }
3020 #else
3021 static int rtip_semaphore_build(wolfSSL_Mutex *m)
3022 {
3023 KS_SEMAPHORE_BUILD(m)
3024 return(RTP_TRUE);
3025 }
3026
3027 int wc_InitMutex(wolfSSL_Mutex* m)
3028 {
3029 if (rtip_semaphore_build(m) == RTP_FALSE)
3030 return BAD_MUTEX_E;
3031 else
3032 return 0;
3033 }
3034
3035 int wc_FreeMutex(wolfSSL_Mutex* m)
3036 {
3037 KS_SEMAPHORE_FREE(*m);
3038 return 0;
3039 }
3040
3041 int wc_LockMutex(wolfSSL_Mutex* m)
3042 {
3043 if (KS_SEMAPHORE_GET(*m))
3044 return 0;
3045 else
3046 return BAD_MUTEX_E;
3047 }
3048
3049 int wc_UnLockMutex(wolfSSL_Mutex* m)
3050 {
3051 KS_SEMAPHORE_GIVE(*m);
3052 return 0;
3053 }
3054 #endif
3055 int ebsnet_fseek(int a, long b, int c)
3056 {
3057 int retval;
3058
3059 retval = (int)vf_lseek(a, b, c);
3060 if (retval > 0)
3061 retval = 0;
3062 else
3063 retval = -1;
3064
3065 return(retval);
3066 }
3067
3068 int strcasecmp(const char *s1, const char *s2)
3069 {
3070 while (rtp_tolower(*s1) == rtp_tolower(*s2)) {
3071 if (*s1 == '\0' || *s2 == '\0')
3072 break;
3073 s1++;
3074 s2++;
3075 }
3076
3077 return rtp_tolower(*(unsigned char *) s1) -
3078 rtp_tolower(*(unsigned char *) s2);
3079 }
3080
3081#elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX)
3082
3083 int wc_InitMutex(wolfSSL_Mutex* m)
3084 {
3085 #if (defined(HAVE_FIPS) && FIPS_VERSION_EQ(5,2))
3086 if (wolfCrypt_GetMode_fips() == FIPS_MODE_INIT)
3087 return 0;
3088 #endif
3089 if (_mutex_init(m, NULL) == MQX_EOK)
3090 return 0;
3091 else
3092 return BAD_MUTEX_E;
3093 }
3094
3095 int wc_FreeMutex(wolfSSL_Mutex* m)
3096 {
3097 if (_mutex_destroy(m) == MQX_EOK)
3098 return 0;
3099 else
3100 return BAD_MUTEX_E;
3101 }
3102
3103 int wc_LockMutex(wolfSSL_Mutex* m)
3104 {
3105 #if (defined(HAVE_FIPS) && FIPS_VERSION_EQ(5,2))
3106 if (m->VALID != MUTEX_VALID) {
3107 if (_mutex_init(m, NULL) != MQX_EOK)
3108 return BAD_MUTEX_E;
3109 }
3110 #endif
3111
3112 if (_mutex_lock(m) == MQX_EOK)
3113 return 0;
3114 else
3115 return BAD_MUTEX_E;
3116 }
3117
3118 int wc_UnLockMutex(wolfSSL_Mutex* m)
3119 {
3120 #if (defined(HAVE_FIPS) && FIPS_VERSION_EQ(5,2))
3121 if (m->VALID != MUTEX_VALID) {
3122 if (_mutex_init(m, NULL) != MQX_EOK)
3123 return BAD_MUTEX_E;
3124 }
3125 #endif
3126
3127 if (_mutex_unlock(m) == MQX_EOK)
3128 return 0;
3129 else
3130 return BAD_MUTEX_E;
3131 }
3132
3133#elif defined(WOLFSSL_TIRTOS)
3134 #include <xdc/runtime/Error.h>
3135
3136 int wc_InitMutex(wolfSSL_Mutex* m)
3137 {
3138 Semaphore_Params params;
3139 Error_Block eb;
3140
3141 Error_init(&eb);
3142 Semaphore_Params_init(¶ms);
3143 params.mode = Semaphore_Mode_BINARY;
3144
3145 *m = Semaphore_create(1, ¶ms, &eb);
3146 if (Error_check(&eb)) {
3147 Error_raise(&eb, Error_E_generic, "Failed to Create the semaphore.",
3148 NULL);
3149 return BAD_MUTEX_E;
3150 }
3151 else
3152 return 0;
3153 }
3154
3155 int wc_FreeMutex(wolfSSL_Mutex* m)
3156 {
3157 Semaphore_delete(m);
3158
3159 return 0;
3160 }
3161
3162 int wc_LockMutex(wolfSSL_Mutex* m)
3163 {
3164 Semaphore_pend(*m, BIOS_WAIT_FOREVER);
3165
3166 return 0;
3167 }
3168
3169 int wc_UnLockMutex(wolfSSL_Mutex* m)
3170 {
3171 Semaphore_post(*m);
3172
3173 return 0;
3174 }
3175
3176#elif defined(WOLFSSL_uITRON4)
3177
3178 int wc_InitMutex(wolfSSL_Mutex* m)
3179 {
3180 int iReturn;
3181 m->sem.sematr = TA_TFIFO;
3182 m->sem.isemcnt = 1;
3183 m->sem.maxsem = 1;
3184 m->sem.name = NULL;
3185
3186 m->id = acre_sem(&m->sem);
3187 if( m->id != E_OK )
3188 iReturn = 0;
3189 else
3190 iReturn = BAD_MUTEX_E;
3191
3192 return iReturn;
3193 }
3194
3195 int wc_FreeMutex(wolfSSL_Mutex* m)
3196 {
3197 del_sem( m->id );
3198 return 0;
3199 }
3200
3201 int wc_LockMutex(wolfSSL_Mutex* m)
3202 {
3203 wai_sem(m->id);
3204 return 0;
3205 }
3206
3207 int wc_UnLockMutex(wolfSSL_Mutex* m)
3208 {
3209 sig_sem(m->id);
3210 return 0;
3211 }
3212
3213 /**** uITRON malloc/free ***/
3214 static ID ID_wolfssl_MPOOL = 0;
3215 static T_CMPL wolfssl_MPOOL = {TA_TFIFO, 0, NULL, "wolfSSL_MPOOL"};
3216
3217 int uITRON4_minit(size_t poolsz) {
3218 ER ercd;
3219 wolfssl_MPOOL.mplsz = poolsz;
3220 ercd = acre_mpl(&wolfssl_MPOOL);
3221 if (ercd > 0) {
3222 ID_wolfssl_MPOOL = ercd;
3223 return 0;
3224 } else {
3225 return -1;
3226 }
3227 }
3228
3229 void *uITRON4_malloc(size_t sz) {
3230 ER ercd;
3231 void *p = NULL;
3232 ercd = get_mpl(ID_wolfssl_MPOOL, sz, (VP)&p);
3233 if (ercd == E_OK) {
3234 return p;
3235 } else {
3236 return 0;
3237 }
3238 }
3239
3240 void *uITRON4_realloc(void *p, size_t sz) {
3241 ER ercd;
3242 void *newp = NULL;
3243 if(p) {
3244 ercd = get_mpl(ID_wolfssl_MPOOL, sz, (VP)&newp);
3245 if ((ercd == E_OK) && (newp != NULL)) {
3246 XMEMCPY(newp, p, sz);
3247 ercd = rel_mpl(ID_wolfssl_MPOOL, (VP)p);
3248 if (ercd == E_OK) {
3249 return newp;
3250 }
3251 }
3252 }
3253 return 0;
3254 }
3255
3256 void uITRON4_free(void *p) {
3257 ER ercd;
3258 ercd = rel_mpl(ID_wolfssl_MPOOL, (VP)p);
3259 if (ercd == E_OK) {
3260 return;
3261 } else {
3262 return;
3263 }
3264 }
3265
3266#elif defined(WOLFSSL_uTKERNEL2)
3267
3268 int wc_InitMutex(wolfSSL_Mutex* m)
3269 {
3270 int iReturn;
3271 m->sem.sematr = TA_TFIFO;
3272 m->sem.isemcnt = 1;
3273 m->sem.maxsem = 1;
3274
3275 m->id = tk_cre_sem(&m->sem);
3276 if( m->id != NULL )
3277 iReturn = 0;
3278 else
3279 iReturn = BAD_MUTEX_E;
3280
3281 return iReturn;
3282 }
3283
3284 int wc_FreeMutex(wolfSSL_Mutex* m)
3285 {
3286 tk_del_sem(m->id);
3287 return 0;
3288 }
3289
3290 int wc_LockMutex(wolfSSL_Mutex* m)
3291 {
3292 tk_wai_sem(m->id, 1, TMO_FEVR);
3293 return 0;
3294 }
3295
3296 int wc_UnLockMutex(wolfSSL_Mutex* m)
3297 {
3298 tk_sig_sem(m->id, 1);
3299 return 0;
3300 }
3301
3302 /**** uT-Kernel malloc/free ***/
3303 static ID ID_wolfssl_MPOOL = 0;
3304 static T_CMPL wolfssl_MPOOL = {
3305 NULL, /* Extended information */
3306 TA_TFIFO, /* Memory pool attribute */
3307 0, /* Size of whole memory pool (byte) */
3308 "wolfSSL" /* Object name (max 8-char) */
3309 };
3310
3311 int uTKernel_init_mpool(unsigned int sz) {
3312 ER ercd;
3313 wolfssl_MPOOL.mplsz = sz;
3314 ercd = tk_cre_mpl(&wolfssl_MPOOL);
3315 if (ercd > 0) {
3316 ID_wolfssl_MPOOL = ercd;
3317 return 0;
3318 } else {
3319 return (int)ercd;
3320 }
3321 }
3322
3323 void *uTKernel_malloc(unsigned int sz) {
3324 ER ercd;
3325 void *p = NULL;
3326 ercd = tk_get_mpl(ID_wolfssl_MPOOL, sz, (VP)&p, TMO_FEVR);
3327 if (ercd == E_OK) {
3328 return p;
3329 } else {
3330 return 0;
3331 }
3332 }
3333
3334 void *uTKernel_realloc(void *p, unsigned int sz) {
3335 ER ercd;
3336 void *newp = NULL;
3337 if (p) {
3338 ercd = tk_get_mpl(ID_wolfssl_MPOOL, sz, (VP)&newp, TMO_FEVR);
3339 if ((ercd == E_OK) && (newp != NULL)) {
3340 XMEMCPY(newp, p, sz);
3341 ercd = tk_rel_mpl(ID_wolfssl_MPOOL, (VP)p);
3342 if (ercd == E_OK) {
3343 return newp;
3344 }
3345 }
3346 }
3347 return 0;
3348 }
3349
3350 void uTKernel_free(void *p) {
3351 ER ercd;
3352 ercd = tk_rel_mpl(ID_wolfssl_MPOOL, (VP)p);
3353 if (ercd == E_OK) {
3354 return;
3355 } else {
3356 return;
3357 }
3358 }
3359
3360#elif defined (WOLFSSL_FROSTED)
3361
3362 int wc_InitMutex(wolfSSL_Mutex* m)
3363 {
3364 *m = mutex_init();
3365 if (*m)
3366 return 0;
3367 else
3368 return -1;
3369 }
3370
3371 int wc_FreeMutex(wolfSSL_Mutex* m)
3372 {
3373 mutex_destroy(*m);
3374 return(0);
3375 }
3376
3377 int wc_LockMutex(wolfSSL_Mutex* m)
3378 {
3379 mutex_lock(*m);
3380 return 0;
3381 }
3382
3383 int wc_UnLockMutex(wolfSSL_Mutex* m)
3384 {
3385 mutex_unlock(*m);
3386 return 0;
3387 }
3388
3389#elif defined(WOLFSSL_CMSIS_RTOS)
3390
3391 #ifndef CMSIS_NMUTEX
3392 #define CMSIS_NMUTEX 10
3393 #endif
3394 osMutexDef(wolfSSL_mt0); osMutexDef(wolfSSL_mt1); osMutexDef(wolfSSL_mt2);
3395 osMutexDef(wolfSSL_mt3); osMutexDef(wolfSSL_mt4); osMutexDef(wolfSSL_mt5);
3396 osMutexDef(wolfSSL_mt6); osMutexDef(wolfSSL_mt7); osMutexDef(wolfSSL_mt8);
3397 osMutexDef(wolfSSL_mt9);
3398
3399 static const osMutexDef_t *CMSIS_mutex[] = { osMutex(wolfSSL_mt0),
3400 osMutex(wolfSSL_mt1), osMutex(wolfSSL_mt2), osMutex(wolfSSL_mt3),
3401 osMutex(wolfSSL_mt4), osMutex(wolfSSL_mt5), osMutex(wolfSSL_mt6),
3402 osMutex(wolfSSL_mt7), osMutex(wolfSSL_mt8), osMutex(wolfSSL_mt9) };
3403
3404 static osMutexId CMSIS_mutexID[CMSIS_NMUTEX] = {0};
3405
3406 int wc_InitMutex(wolfSSL_Mutex* m)
3407 {
3408 int i;
3409
3410 if(!osKernelRunning()) {
3411 return 0;
3412 }
3413
3414 for (i=0; i<CMSIS_NMUTEX; i++) {
3415 if(CMSIS_mutexID[i] == 0) {
3416 CMSIS_mutexID[i] = osMutexCreate(CMSIS_mutex[i]);
3417 (*m) = CMSIS_mutexID[i];
3418 return 0;
3419 }
3420 }
3421 return -1;
3422 }
3423
3424 int wc_FreeMutex(wolfSSL_Mutex* m)
3425 {
3426 int i;
3427
3428 if(!osKernelRunning()) {
3429 return 0;
3430 }
3431
3432 osMutexDelete (*m);
3433 for (i=0; i<CMSIS_NMUTEX; i++) {
3434 if(CMSIS_mutexID[i] == (*m)) {
3435 CMSIS_mutexID[i] = 0;
3436 return(0);
3437 }
3438 }
3439 return(-1);
3440 }
3441
3442 int wc_LockMutex(wolfSSL_Mutex* m)
3443 {
3444 if(osKernelRunning()) {
3445 osMutexWait(*m, osWaitForever);
3446 }
3447 return(0);
3448 }
3449
3450 int wc_UnLockMutex(wolfSSL_Mutex* m)
3451 {
3452 if(osKernelRunning()) {
3453 osMutexRelease (*m);
3454 }
3455 return 0;
3456 }
3457
3458#elif defined(WOLFSSL_CMSIS_RTOSv2)
3459 int wc_InitMutex(wolfSSL_Mutex *m)
3460 {
3461 static const osMutexAttr_t attr = {
3462 "wolfSSL_mutex", osMutexRecursive, NULL, 0};
3463
3464 if ((*m = osMutexNew(&attr)) != NULL)
3465 return 0;
3466 else
3467 return BAD_MUTEX_E;
3468 }
3469
3470 int wc_FreeMutex(wolfSSL_Mutex *m)
3471 {
3472 if (osMutexDelete(*m) == osOK)
3473 return 0;
3474 else
3475 return BAD_MUTEX_E;
3476 }
3477
3478
3479 int wc_LockMutex(wolfSSL_Mutex *m)
3480 {
3481 if (osMutexAcquire(*m, osWaitForever) == osOK)
3482 return 0;
3483 else
3484 return BAD_MUTEX_E;
3485 }
3486
3487 int wc_UnLockMutex(wolfSSL_Mutex *m)
3488 {
3489 if (osMutexRelease(*m) == osOK)
3490 return 0;
3491 else
3492 return BAD_MUTEX_E;
3493 }
3494
3495#elif defined(WOLFSSL_MDK_ARM)
3496
3497 int wc_InitMutex(wolfSSL_Mutex* m)
3498 {
3499 os_mut_init (m);
3500 return 0;
3501 }
3502
3503 int wc_FreeMutex(wolfSSL_Mutex* m)
3504 {
3505 return(0);
3506 }
3507
3508 int wc_LockMutex(wolfSSL_Mutex* m)
3509 {
3510 os_mut_wait (m, 0xffff);
3511 return(0);
3512 }
3513
3514 int wc_UnLockMutex(wolfSSL_Mutex* m)
3515 {
3516 os_mut_release (m);
3517 return 0;
3518 }
3519
3520#elif defined(INTIME_RTOS)
3521
3522 int wc_InitMutex(wolfSSL_Mutex* m)
3523 {
3524 int ret = 0;
3525
3526 if (m == NULL)
3527 return BAD_FUNC_ARG;
3528
3529 *m = CreateRtSemaphore(
3530 1, /* initial unit count */
3531 1, /* maximum unit count */
3532 PRIORITY_QUEUING /* creation flags: FIFO_QUEUING or PRIORITY_QUEUING */
3533 );
3534 if (*m == BAD_RTHANDLE) {
3535 ret = GetLastRtError();
3536 if (ret != E_OK)
3537 ret = BAD_MUTEX_E;
3538 }
3539 return ret;
3540 }
3541
3542 int wc_FreeMutex(wolfSSL_Mutex* m)
3543 {
3544 int ret = 0;
3545 BOOLEAN del;
3546
3547 if (m == NULL)
3548 return BAD_FUNC_ARG;
3549
3550 del = DeleteRtSemaphore(
3551 *m /* handle for RT semaphore */
3552 );
3553 if (del != TRUE)
3554 ret = BAD_MUTEX_E;
3555
3556 return ret;
3557 }
3558
3559 int wc_LockMutex(wolfSSL_Mutex* m)
3560 {
3561 int ret = 0;
3562 DWORD lck;
3563
3564 if (m == NULL)
3565 return BAD_FUNC_ARG;
3566
3567 lck = WaitForRtSemaphore(
3568 *m, /* handle for RT semaphore */
3569 1, /* number of units to wait for */
3570 WAIT_FOREVER /* number of milliseconds to wait for units */
3571 );
3572 if (lck == WAIT_FAILED) {
3573 ret = GetLastRtError();
3574 if (ret != E_OK)
3575 ret = BAD_MUTEX_E;
3576 }
3577 return ret;
3578 }
3579
3580 int wc_UnLockMutex(wolfSSL_Mutex* m)
3581 {
3582 int ret = 0;
3583 BOOLEAN rel;
3584
3585 if (m == NULL)
3586 return BAD_FUNC_ARG;
3587
3588 rel = ReleaseRtSemaphore(
3589 *m, /* handle for RT semaphore */
3590 1 /* number of units to release to semaphore */
3591 );
3592 if (rel != TRUE)
3593 ret = BAD_MUTEX_E;
3594
3595 return ret;
3596 }
3597
3598#elif defined(WOLFSSL_NUCLEUS_1_2)
3599
3600 int wc_InitMutex(wolfSSL_Mutex* m)
3601 {
3602 /* Call the Nucleus function to create the semaphore */
3603 if (NU_Create_Semaphore(m, "WOLFSSL_MTX", 1,
3604 NU_PRIORITY) == NU_SUCCESS) {
3605 return 0;
3606 }
3607
3608 return BAD_MUTEX_E;
3609 }
3610
3611 int wc_FreeMutex(wolfSSL_Mutex* m)
3612 {
3613 if (NU_Delete_Semaphore(m) == NU_SUCCESS)
3614 return 0;
3615
3616 return BAD_MUTEX_E;
3617 }
3618
3619 int wc_LockMutex(wolfSSL_Mutex* m)
3620 {
3621 /* passing suspend task option */
3622 if (NU_Obtain_Semaphore(m, NU_SUSPEND) == NU_SUCCESS)
3623 return 0;
3624
3625 return BAD_MUTEX_E;
3626 }
3627
3628 int wc_UnLockMutex(wolfSSL_Mutex* m)
3629 {
3630 if (NU_Release_Semaphore(m) == NU_SUCCESS)
3631 return 0;
3632
3633 return BAD_MUTEX_E;
3634 }
3635
3636#elif defined(WOLFSSL_ZEPHYR)
3637
3638 int wc_InitMutex(wolfSSL_Mutex* m)
3639 {
3640 k_mutex_init(m);
3641
3642 return 0;
3643 }
3644
3645 int wc_FreeMutex(wolfSSL_Mutex* m)
3646 {
3647 return 0;
3648 }
3649
3650 int wc_LockMutex(wolfSSL_Mutex* m)
3651 {
3652 int ret = 0;
3653
3654 if (k_mutex_lock(m, K_FOREVER) != 0)
3655 ret = BAD_MUTEX_E;
3656
3657 return ret;
3658 }
3659
3660 int wc_UnLockMutex(wolfSSL_Mutex* m)
3661 {
3662 k_mutex_unlock(m);
3663
3664 return 0;
3665 }
3666
3667#elif defined(WOLFSSL_TELIT_M2MB)
3668
3669 int wc_InitMutex(wolfSSL_Mutex* m)
3670 {
3671 M2MB_OS_RESULT_E osRes;
3672 M2MB_OS_MTX_ATTR_HANDLE mtxAttrHandle;
3673 UINT32 inheritVal = 1;
3674
3675 osRes = m2mb_os_mtx_setAttrItem(&mtxAttrHandle,
3676 CMDS_ARGS(
3677 M2MB_OS_MTX_SEL_CMD_CREATE_ATTR, NULL,
3678 M2MB_OS_MTX_SEL_CMD_NAME, "wolfMtx",
3679 M2MB_OS_MTX_SEL_CMD_INHERIT, inheritVal
3680 )
3681 );
3682 if (osRes != M2MB_OS_SUCCESS) {
3683 return BAD_MUTEX_E;
3684 }
3685
3686 osRes = m2mb_os_mtx_init(m, &mtxAttrHandle);
3687 if (osRes != M2MB_OS_SUCCESS) {
3688 return BAD_MUTEX_E;
3689 }
3690
3691 return 0;
3692 }
3693
3694 int wc_FreeMutex(wolfSSL_Mutex* m)
3695 {
3696 M2MB_OS_RESULT_E osRes;
3697
3698 if (m == NULL)
3699 return BAD_MUTEX_E;
3700
3701 osRes = m2mb_os_mtx_deinit(*m);
3702 if (osRes != M2MB_OS_SUCCESS) {
3703 return BAD_MUTEX_E;
3704 }
3705
3706 return 0;
3707 }
3708
3709 int wc_LockMutex(wolfSSL_Mutex* m)
3710 {
3711 M2MB_OS_RESULT_E osRes;
3712
3713 if (m == NULL)
3714 return BAD_MUTEX_E;
3715
3716 osRes = m2mb_os_mtx_get(*m, M2MB_OS_WAIT_FOREVER);
3717 if (osRes != M2MB_OS_SUCCESS) {
3718 return BAD_MUTEX_E;
3719 }
3720
3721 return 0;
3722 }
3723
3724 int wc_UnLockMutex(wolfSSL_Mutex* m)
3725 {
3726 M2MB_OS_RESULT_E osRes;
3727
3728 if (m == NULL)
3729 return BAD_MUTEX_E;
3730
3731 osRes = m2mb_os_mtx_put(*m);
3732 if (osRes != M2MB_OS_SUCCESS) {
3733 return BAD_MUTEX_E;
3734 }
3735
3736 return 0;
3737 }
3738
3739#elif defined(WOLFSSL_EMBOS)
3740
3741 int wc_InitMutex(wolfSSL_Mutex* m)
3742 {
3743 int ret;
3744
3745 OS_MUTEX_Create((OS_MUTEX*) m);
3746 if (m != NULL)
3747 ret = 0;
3748 else
3749 ret = BAD_MUTEX_E;
3750
3751 return ret;
3752 }
3753
3754 int wc_FreeMutex(wolfSSL_Mutex* m)
3755 {
3756 OS_MUTEX_Delete((OS_MUTEX*) m);
3757 return 0;
3758 }
3759
3760 int wc_LockMutex(wolfSSL_Mutex* m)
3761 {
3762 OS_MUTEX_LockBlocked((OS_MUTEX*) m);
3763 return 0;
3764 }
3765
3766 int wc_UnLockMutex(wolfSSL_Mutex* m)
3767 {
3768 OS_MUTEX_Unlock((OS_MUTEX*) m);
3769 return 0;
3770 }
3771
3772#elif defined(NETOS)
3773
3774 int wc_InitMutex(wolfSSL_Mutex* m)
3775 {
3776 if (tx_mutex_create(&ready->mutex, "wolfSSL Lock", TX_INHERIT)
3777 == TX_SUCCESS)
3778 return 0;
3779 else
3780 return BAD_MUTEX_E;
3781 }
3782
3783 int wc_FreeMutex(wolfSSL_Mutex* m)
3784 {
3785 if (tx_mutex_delete(&ready->mutex) == TX_SUCCESS)
3786 return 0;
3787 else
3788 return BAD_MUTEX_E;
3789 }
3790
3791 int wc_LockMutex(wolfSSL_Mutex* m)
3792 {
3793
3794 }
3795
3796 int wc_UnLockMutex(wolfSSL_Mutex* m)
3797 {
3798
3799 }
3800
3801#elif defined(WOLFSSL_USER_MUTEX)
3802
3803 /* Use user own mutex */
3804
3805 /*
3806 int wc_InitMutex(wolfSSL_Mutex* m) { ... }
3807 int wc_FreeMutex(wolfSSL_Mutex *m) { ... }
3808 int wc_LockMutex(wolfSSL_Mutex *m) { ... }
3809 int wc_UnLockMutex(wolfSSL_Mutex *m) { ... }
3810 */
3811
3812#else
3813 #warning No mutex handling defined
3814
3815#endif
3816#if !defined(WOLFSSL_USE_RWLOCK) || defined(SINGLE_THREADED) || \
3817 (defined(WC_MUTEX_OPS_INLINE) && !defined(WC_RWLOCK_OPS_INLINE))
3818 int wc_InitRwLock(wolfSSL_RwLock* m)
3819 {
3820 return wc_InitMutex(m);
3821 }
3822
3823 int wc_FreeRwLock(wolfSSL_RwLock* m)
3824 {
3825 return wc_FreeMutex(m);
3826 }
3827
3828 int wc_LockRwLock_Wr(wolfSSL_RwLock* m)
3829 {
3830 return wc_LockMutex(m);
3831 }
3832
3833 int wc_LockRwLock_Rd(wolfSSL_RwLock* m)
3834 {
3835 return wc_LockMutex(m);
3836 }
3837
3838 int wc_UnLockRwLock(wolfSSL_RwLock* m)
3839 {
3840 return wc_UnLockMutex(m);
3841 }
3842#endif
3843
3844#ifndef NO_ASN_TIME
3845#if defined(_WIN32_WCE)
3846time_t windows_time(time_t* timer)
3847{
3848 SYSTEMTIME sysTime;
3849 FILETIME fTime;
3850 ULARGE_INTEGER intTime;
3851
3852
3853 GetSystemTime(&sysTime);
3854 SystemTimeToFileTime(&sysTime, &fTime);
3855
3856 XMEMCPY(&intTime, &fTime, sizeof(FILETIME));
3857 /* subtract EPOCH */
3858 intTime.QuadPart -= 0x19db1ded53e8000;
3859 /* to secs */
3860 intTime.QuadPart /= 10000000;
3861
3862 if (timer != NULL)
3863 *timer = (time_t)intTime.QuadPart;
3864
3865 return (time_t)intTime.QuadPart;
3866}
3867#endif /* _WIN32_WCE */
3868
3869#if defined(WOLFSSL_APACHE_MYNEWT)
3870#include "os/os_time.h"
3871
3872time_t mynewt_time(time_t* timer)
3873{
3874 time_t now;
3875 struct os_timeval tv;
3876 os_gettimeofday(&tv, NULL);
3877 now = (time_t)tv.tv_sec;
3878 if(timer != NULL) {
3879 *timer = now;
3880 }
3881 return now;
3882}
3883#endif /* WOLFSSL_APACHE_MYNEWT */
3884
3885#if defined(WOLFSSL_GMTIME)
3886struct tm* gmtime_r(const time_t* timer, struct tm *ret)
3887{
3888 #define YEAR0 1900
3889 #define EPOCH_YEAR 1970
3890 #define SECS_DAY (24L * 60L * 60L)
3891 #define LEAPYEAR(year) (!((year) % 4) && (((year) % 100) || !((year) %400)))
3892 #define YEARSIZE(year) (LEAPYEAR(year) ? 366 : 365)
3893
3894 static const int _ytab[2][12] =
3895 {
3896 {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
3897 {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
3898 };
3899
3900 time_t secs = *timer;
3901 unsigned long dayclock, dayno;
3902 int year = EPOCH_YEAR;
3903
3904 dayclock = (unsigned long)secs % SECS_DAY;
3905 dayno = (unsigned long)secs / SECS_DAY;
3906
3907 ret->tm_sec = (int) dayclock % 60;
3908 ret->tm_min = (int)(dayclock % 3600) / 60;
3909 ret->tm_hour = (int) dayclock / 3600;
3910 ret->tm_wday = (int) (dayno + 4) % 7; /* day 0 a Thursday */
3911
3912 while(dayno >= (unsigned long)YEARSIZE(year)) {
3913 dayno -= YEARSIZE(year);
3914 year++;
3915 }
3916
3917 ret->tm_year = year - YEAR0;
3918 ret->tm_yday = (int)dayno;
3919 ret->tm_mon = 0;
3920
3921 while(dayno >= (unsigned long)_ytab[LEAPYEAR(year)][ret->tm_mon]) {
3922 dayno -= _ytab[LEAPYEAR(year)][ret->tm_mon];
3923 ret->tm_mon++;
3924 }
3925
3926 ret->tm_mday = (int)++dayno;
3927#ifndef WOLFSSL_LINUXKM
3928 ret->tm_isdst = 0;
3929#endif
3930
3931 return ret;
3932}
3933
3934struct tm* gmtime(const time_t* timer) {
3935 static struct tm st_time;
3936 return gmtime_r(timer, &st_time);
3937}
3938
3939#endif /* WOLFSSL_GMTIME */
3940
3941
3942#if defined(HAVE_RTP_SYS)
3943#define YEAR0 1900
3944
3945struct tm* rtpsys_gmtime(const time_t* timer) /* has a gmtime() but hangs */
3946{
3947 static struct tm st_time;
3948 struct tm* ret = &st_time;
3949
3950 DC_RTC_CALENDAR cal;
3951 dc_rtc_time_get(&cal, TRUE);
3952
3953 ret->tm_year = cal.year - YEAR0; /* gm starts at 1900 */
3954 ret->tm_mon = cal.month - 1; /* gm starts at 0 */
3955 ret->tm_mday = cal.day;
3956 ret->tm_hour = cal.hour;
3957 ret->tm_min = cal.minute;
3958 ret->tm_sec = cal.second;
3959
3960 return ret;
3961}
3962
3963#endif /* HAVE_RTP_SYS */
3964
3965
3966#if defined(MICROCHIP_TCPIP_V5) || defined(MICROCHIP_TCPIP)
3967
3968/*
3969 * time() is just a stub in Microchip libraries. We need our own
3970 * implementation. Use SNTP client to get seconds since epoch.
3971 */
3972time_t pic32_time(time_t* timer)
3973{
3974#ifdef MICROCHIP_TCPIP_V5
3975 DWORD sec = 0;
3976#else
3977 word32 sec = 0;
3978#endif
3979
3980#ifdef MICROCHIP_MPLAB_HARMONY
3981 sec = TCPIP_SNTP_UTCSecondsGet();
3982#else
3983 sec = SNTPGetUTCSeconds();
3984#endif
3985
3986 if (timer != NULL)
3987 *timer = (time_t)sec;
3988
3989 return (time_t)sec;
3990}
3991
3992#endif /* MICROCHIP_TCPIP || MICROCHIP_TCPIP_V5 */
3993
3994#if defined(WOLFSSL_DEOS) || defined(WOLFSSL_DEOS_RTEMS)
3995
3996time_t deos_time(time_t* timer)
3997{
3998 const word32 systemTickTimeInHz = 1000000 / systemTickInMicroseconds();
3999 const volatile word32 *systemTickPtr = systemTickPointer();
4000
4001 if (timer != NULL)
4002 *timer = *systemTickPtr/systemTickTimeInHz;
4003
4004 #if defined(CURRENT_UNIX_TIMESTAMP)
4005 /* CURRENT_UNIX_TIMESTAMP is seconds since Jan 01 1970. (UTC) */
4006 return (time_t) (*systemTickPtr/systemTickTimeInHz) + CURRENT_UNIX_TIMESTAMP;
4007 #else
4008 return (time_t) *systemTickPtr/systemTickTimeInHz;
4009 #endif
4010}
4011#endif /* WOLFSSL_DEOS || WOLFSSL_DEOS_RTEMS */
4012
4013#if defined(FREESCALE_RTC)
4014#include "fsl_rtc.h"
4015time_t fsl_time(time_t* t)
4016{
4017 *t = RTC_GetSecondsTimerCount(RTC);
4018 return *t;
4019}
4020#endif
4021
4022#if defined(FREESCALE_SNVS_RTC)
4023time_t fsl_time(time_t* t)
4024{
4025 struct tm tm_time;
4026 time_t ret;
4027
4028 snvs_hp_rtc_datetime_t rtcDate;
4029 snvs_hp_rtc_config_t snvsRtcConfig;
4030
4031 SNVS_HP_RTC_GetDefaultConfig(&snvsRtcConfig);
4032 SNVS_HP_RTC_Init(SNVS, &snvsRtcConfig);
4033
4034 SNVS_HP_RTC_GetDatetime(SNVS, &rtcDate);
4035
4036 tm_time.tm_year = rtcDate.year;
4037 tm_time.tm_mon = rtcDate.month;
4038 tm_time.tm_mday = rtcDate.day;
4039 tm_time.tm_hour = rtcDate.hour;
4040 tm_time.tm_min = rtcDate.minute;
4041 tm_time.tm_sec = rtcDate.second;
4042
4043 ret = mktime(&tm_time);
4044 if (t != NULL)
4045 *t = ret;
4046 return ret;
4047}
4048#endif
4049
4050#if defined(MICRIUM)
4051
4052time_t micrium_time(time_t* timer)
4053{
4054 CLK_TS_SEC sec;
4055
4056 Clk_GetTS_Unix(&sec);
4057
4058 if (timer != NULL)
4059 *timer = sec;
4060
4061 return (time_t) sec;
4062}
4063
4064#endif /* MICRIUM */
4065
4066#if defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX)
4067
4068time_t mqx_time(time_t* timer)
4069{
4070 TIME_STRUCT time_s;
4071
4072 _time_get(&time_s);
4073
4074 if (timer != NULL)
4075 *timer = (time_t)time_s.SECONDS;
4076
4077 return (time_t)time_s.SECONDS;
4078}
4079
4080#endif /* FREESCALE_MQX || FREESCALE_KSDK_MQX */
4081
4082#if defined(MAX3266X_RTC)
4083 #define XTIME wc_MXC_RTC_Time
4084#endif
4085
4086#if defined(WOLFSSL_TIRTOS) && defined(USER_TIME)
4087
4088time_t XTIME(time_t * timer)
4089{
4090 time_t sec = 0;
4091
4092 sec = (time_t) Seconds_get();
4093
4094 if (timer != NULL)
4095 *timer = sec;
4096
4097 return sec;
4098}
4099
4100#endif /* WOLFSSL_TIRTOS */
4101
4102#if defined(WOLFSSL_XILINX)
4103#include "xrtcpsu.h"
4104
4105time_t xilinx_time(time_t * timer)
4106{
4107 time_t sec = 0;
4108 XRtcPsu_Config* con;
4109 XRtcPsu rtc;
4110
4111 con = XRtcPsu_LookupConfig(XPAR_XRTCPSU_0_DEVICE_ID);
4112 if (con != NULL) {
4113 if (XRtcPsu_CfgInitialize(&rtc, con, con->BaseAddr) == XST_SUCCESS) {
4114 sec = (time_t)XRtcPsu_GetCurrentTime(&rtc);
4115 }
4116 else {
4117 WOLFSSL_MSG("Unable to initialize RTC");
4118 }
4119 }
4120
4121 if (timer != NULL)
4122 *timer = sec;
4123
4124 return sec;
4125}
4126
4127#endif /* WOLFSSL_XILINX */
4128
4129#if defined(WOLFSSL_ZEPHYR)
4130
4131time_t z_time(time_t * timer)
4132{
4133 struct timespec ts;
4134
4135 #if defined(CONFIG_RTC) && \
4136 (defined(CONFIG_PICOLIBC) || defined(CONFIG_NEWLIB_LIBC))
4137
4138 #if defined(CONFIG_BOARD_NATIVE_POSIX) || defined(CONFIG_BOARD_NATIVE_SIM)
4139
4140 /* When using native sim, get time from simulator rtc */
4141 uint32_t nsec = 0;
4142 uint64_t sec = 0;
4143 native_rtc_gettime(RTC_CLOCK_PSEUDOHOSTREALTIME, &nsec, &sec);
4144
4145 if (timer != NULL)
4146 *timer = sec;
4147
4148 return sec;
4149
4150 #else
4151
4152 /* Try to obtain the actual time from an RTC */
4153 static const struct device *rtc = DEVICE_DT_GET(DT_NODELABEL(rtc));
4154
4155 if (device_is_ready(rtc)) {
4156 struct rtc_time rtc_time;
4157 struct tm *tm_time = rtc_time_to_tm(&rtc_time);
4158
4159 int ret = rtc_get_time(rtc, &rtc_time);
4160
4161 if (ret == 0) {
4162 time_t epochTime = mktime(tm_time);
4163
4164 if (timer != NULL)
4165 *timer = epochTime;
4166
4167 return epochTime;
4168 }
4169 }
4170 #endif /* CONFIG_BOARD_NATIVE_POSIX || CONFIG_BOARD_NATIVE_SIM */
4171 #endif
4172
4173 /* Fallback to uptime since boot. This works for relative times, but
4174 * not for ASN.1 date validation */
4175 if (clock_gettime(CLOCK_REALTIME, &ts) == 0)
4176 if (timer != NULL)
4177 *timer = ts.tv_sec;
4178
4179 return ts.tv_sec;
4180}
4181
4182#endif /* WOLFSSL_ZEPHYR */
4183
4184
4185#if defined(WOLFSSL_WICED)
4186 #ifndef WOLFSSL_WICED_PSEUDO_UNIX_EPOCH_TIME
4187 #error Please define WOLFSSL_WICED_PSEUDO_UNIX_EPOCH_TIME at build time.
4188 #endif /* WOLFSSL_WICED_PSEUDO_UNIX_EPOCH_TIME */
4189
4190time_t wiced_pseudo_unix_epoch_time(time_t * timer)
4191{
4192 time_t epoch_time;
4193 /* The time() function return uptime on WICED platform. */
4194 epoch_time = time(NULL) + WOLFSSL_WICED_PSEUDO_UNIX_EPOCH_TIME;
4195
4196 if (timer != NULL) {
4197 *timer = epoch_time;
4198 }
4199 return epoch_time;
4200}
4201#endif /* WOLFSSL_WICED */
4202
4203#ifdef WOLFSSL_TELIT_M2MB
4204 time_t m2mb_xtime(time_t * timer)
4205 {
4206 time_t myTime = 0;
4207 INT32 fd = m2mb_rtc_open("/dev/rtc0", 0);
4208 if (fd != -1) {
4209 M2MB_RTC_TIMEVAL_T timeval;
4210
4211 m2mb_rtc_ioctl(fd, M2MB_RTC_IOCTL_GET_TIMEVAL, &timeval);
4212
4213 myTime = timeval.sec;
4214
4215 m2mb_rtc_close(fd);
4216 }
4217 return myTime;
4218 }
4219 #ifdef WOLFSSL_TLS13
4220 time_t m2mb_xtime_ms(time_t * timer)
4221 {
4222 time_t myTime = 0;
4223 INT32 fd = m2mb_rtc_open("/dev/rtc0", 0);
4224 if (fd != -1) {
4225 M2MB_RTC_TIMEVAL_T timeval;
4226
4227 m2mb_rtc_ioctl(fd, M2MB_RTC_IOCTL_GET_TIMEVAL, &timeval);
4228
4229 myTime = timeval.sec + timeval.msec;
4230
4231 m2mb_rtc_close(fd);
4232 }
4233 return myTime;
4234 }
4235 #endif /* WOLFSSL_TLS13 */
4236 #ifndef NO_CRYPT_BENCHMARK
4237 double m2mb_xtime_bench(int reset)
4238 {
4239 double myTime = 0;
4240 INT32 fd = m2mb_rtc_open("/dev/rtc0", 0);
4241 if (fd != -1) {
4242 M2MB_RTC_TIMEVAL_T timeval;
4243
4244 m2mb_rtc_ioctl(fd, M2MB_RTC_IOCTL_GET_TIMEVAL, &timeval);
4245
4246 myTime = (double)timeval.sec + ((double)timeval.msec / 1000);
4247
4248 m2mb_rtc_close(fd);
4249 }
4250 return myTime;
4251 }
4252 #endif /* !NO_CRYPT_BENCHMARK */
4253#endif /* WOLFSSL_TELIT_M2MB */
4254
4255
4256#if defined(WOLFSSL_LINUXKM)
4257time_t time(time_t * timer)
4258{
4259 time_t ret;
4260#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)
4261 struct timespec ts;
4262 getnstimeofday(&ts);
4263 ret = ts.tv_sec;
4264#else
4265 struct timespec64 ts;
4266#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
4267 ts = current_kernel_time64();
4268#else
4269 ktime_get_coarse_real_ts64(&ts);
4270#endif
4271 ret = ts.tv_sec;
4272#endif
4273 if (timer)
4274 *timer = ret;
4275 return ret;
4276}
4277#endif /* WOLFSSL_LINUXKM */
4278
4279#ifdef HAL_RTC_MODULE_ENABLED
4280extern RTC_HandleTypeDef hrtc;
4281time_t stm32_hal_time(time_t *t1)
4282{
4283 struct tm tm_time;
4284 time_t ret;
4285 RTC_TimeTypeDef time;
4286 RTC_DateTypeDef date;
4287
4288 XMEMSET(&tm_time, 0, sizeof(struct tm));
4289
4290 /* order of GetTime followed by GetDate required here due to STM32 HW
4291 * requirement */
4292 HAL_RTC_GetTime(&hrtc, &time, FORMAT_BIN);
4293 HAL_RTC_GetDate(&hrtc, &date, FORMAT_BIN);
4294
4295 /* RTC year is 0-99 and "struct tm" is 1900+, so assume after year 2000 */
4296 tm_time.tm_year = date.Year + 100;
4297 /* RTC month is 1-12 and "struct tm" is 0-12, so subtract 1 */
4298 tm_time.tm_mon = date.Month - 1;
4299 tm_time.tm_mday = date.Date;
4300 tm_time.tm_hour = time.Hours;
4301 tm_time.tm_min = time.Minutes;
4302 tm_time.tm_sec = time.Seconds;
4303
4304 ret = mktime(&tm_time);
4305 if (t1 != NULL)
4306 *t1 = ret;
4307 return ret;
4308}
4309#endif /* HAL_RTC_MODULE_ENABLED */
4310
4311#endif /* !NO_ASN_TIME */
4312
4313#if (!defined(WOLFSSL_LEANPSK) && !defined(STRING_USER)) || \
4314 defined(USE_WOLF_STRNSTR)
4315char* wolfSSL_strnstr(const char* s1, const char* s2, size_t n)
4316{
4317 size_t s2_len = XSTRLEN(s2);
4318
4319 if (s2_len == 0)
4320 return (char *)(wc_ptr_t)s1;
4321
4322 while (n >= s2_len && s1[0]) {
4323 if (s1[0] == s2[0])
4324 if (XMEMCMP(s1, s2, s2_len) == 0)
4325 return (char *)(wc_ptr_t)s1;
4326 s1++;
4327 n--;
4328 }
4329
4330 return NULL;
4331}
4332#endif
4333
4334
4335/* custom memory wrappers */
4336#ifdef WOLFSSL_NUCLEUS_1_2
4337
4338 /* system memory pool */
4339 extern NU_MEMORY_POOL System_Memory;
4340
4341 void* nucleus_malloc(unsigned long size, void* heap, int type)
4342 {
4343 STATUS status;
4344 void* stack_ptr;
4345
4346 status = NU_Allocate_Memory(&System_Memory, &stack_ptr, size,
4347 NU_NO_SUSPEND);
4348 if (status == NU_SUCCESS) {
4349 return 0;
4350 } else {
4351 return stack_ptr;
4352 }
4353 }
4354
4355 void* nucleus_realloc(void* ptr, unsigned long size, void* heap, int type)
4356 {
4357 DM_HEADER* old_header;
4358 word32 old_size, copy_size;
4359 void* new_mem;
4360
4361 /* if ptr is NULL, behave like malloc */
4362 new_mem = nucleus_malloc(size, NULL, 0);
4363 if (new_mem == 0 || ptr == 0) {
4364 return new_mem;
4365 }
4366
4367 /* calculate old memory block size */
4368 /* mem pointers stored in block headers (ref dm_defs.h) */
4369 old_header = (DM_HEADER*) ((byte*)ptr - DM_OVERHEAD);
4370 old_size = (byte*)old_header->dm_next_memory - (byte*)ptr;
4371
4372 /* copy old to new */
4373 if (old_size < size) {
4374 copy_size = old_size;
4375 } else {
4376 copy_size = size;
4377 }
4378 XMEMCPY(new_mem, ptr, copy_size);
4379
4380 /* free old */
4381 nucleus_free(ptr, NULL, 0);
4382
4383 return new_mem;
4384 }
4385
4386 void nucleus_free(void* ptr, void* heap, int type)
4387 {
4388 if (ptr != NULL)
4389 NU_Deallocate_Memory(ptr);
4390 }
4391
4392#endif /* WOLFSSL_NUCLEUS_1_2 */
4393
4394#if defined(WOLFSSL_TI_CRYPT) || defined(WOLFSSL_TI_HASH)
4395 #include <wolfcrypt/src/port/ti/ti-ccm.c> /* initialize and Mutex for TI Crypt Engine */
4396 #include <wolfcrypt/src/port/ti/ti-hash.c> /* md5, sha1, sha224, sha256 */
4397#endif
4398
4399#if defined(WOLFSSL_CRYPTOCELL)
4400 #define WOLFSSL_CRYPTOCELL_C
4401 #include <wolfcrypt/src/port/arm/cryptoCell.c> /* CC310, RTC and RNG */
4402 #if !defined(NO_SHA256)
4403 #define WOLFSSL_CRYPTOCELL_HASH_C
4404 #include <wolfcrypt/src/port/arm/cryptoCellHash.c> /* sha256 */
4405 #endif
4406#endif
4407
4408
4409#ifndef SINGLE_THREADED
4410
4411/* Environment-specific multi-thread implementation check */
4412#if defined(__WATCOMC__)
4413
4414 int wolfSSL_NewThread(THREAD_TYPE* thread,
4415 THREAD_CB cb, void* arg)
4416 {
4417 if (thread == NULL || cb == NULL)
4418 return BAD_FUNC_ARG;
4419 #if defined(__OS2__)
4420 *thread = _beginthread(cb, NULL, 0, arg);
4421 if (*thread == INVALID_THREAD_VAL) {
4422 return MEMORY_E;
4423 }
4424 #elif defined(__NT__)
4425 /* Use _beginthreadex instead of _beginthread because of:
4426 * _beginthreadex is safer to use than _beginthread. If the thread
4427 * that's generated by _beginthread exits quickly, the handle that's
4428 * returned to the caller of _beginthread might be invalid or point
4429 * to another thread. However, the handle that's returned by
4430 * _beginthreadex has to be closed by the caller of _beginthreadex,
4431 * so it's guaranteed to be a valid handle if _beginthreadex didn't
4432 * return an error.*/
4433 *thread = _beginthreadex(NULL, 0, cb, arg, 0, NULL);
4434 if (*thread == 0) {
4435 *thread = INVALID_THREAD_VAL;
4436 return MEMORY_E;
4437 }
4438 #elif defined(__LINUX__)
4439 if (pthread_create(thread, NULL, cb, arg))
4440 return MEMORY_E;
4441 #endif
4442 return 0;
4443 }
4444
4445 int wolfSSL_JoinThread(THREAD_TYPE thread)
4446 {
4447 int ret = 0;
4448
4449 if (thread == INVALID_THREAD_VAL)
4450 return BAD_FUNC_ARG;
4451 #if defined(__OS2__)
4452 DosWaitThread(&thread, DCWW_WAIT);
4453 #elif defined(__NT__)
4454 /* We still want to attempt to close the thread handle even on error */
4455 if (WaitForSingleObject((HANDLE)thread, INFINITE) == WAIT_FAILED)
4456 ret = MEMORY_E;
4457 if (CloseHandle((HANDLE)thread) == 0)
4458 ret = MEMORY_E;
4459 #elif defined(__LINUX__)
4460 if (pthread_join(thread, NULL) != 0)
4461 ret = MEMORY_E;
4462 #endif
4463 return ret;
4464 }
4465
4466 #if defined(WOLFSSL_THREAD_NO_JOIN)
4467 int wolfSSL_NewThreadNoJoin(THREAD_CB_NOJOIN cb, void* arg)
4468 {
4469 THREAD_TYPE thread;
4470 int ret = 0;
4471
4472 if (cb == NULL)
4473 return BAD_FUNC_ARG;
4474 #if defined(__OS2__)
4475 thread = _beginthread(cb, NULL, 0, arg);
4476 if (thread == INVALID_THREAD_VAL)
4477 ret = MEMORY_E;
4478 #elif defined(__NT__)
4479 thread = _beginthread(cb, 0, arg);
4480 if (thread == -1L)
4481 ret = MEMORY_E;
4482 #elif defined(__LINUX__)
4483 XMEMSET(&thread, 0, sizeof(thread));
4484 ret = wolfSSL_NewThread(&thread, cb, arg);
4485 if (ret == 0)
4486 ret = pthread_detach(thread);
4487 #endif
4488 return ret;
4489 }
4490 #endif
4491
4492 #ifdef WOLFSSL_COND
4493 int wolfSSL_CondInit(COND_TYPE* cond)
4494 {
4495 if (cond == NULL)
4496 return BAD_FUNC_ARG;
4497 #if defined(__MACH__)
4498 cond->cond = dispatch_semaphore_create(0);
4499 if (cond->cond == NULL)
4500 return MEMORY_E;
4501
4502 /* dispatch_release() fails hard, with Trace/BPT trap signal, if the
4503 * sem's internal count is less than the value passed in with
4504 * dispatch_semaphore_create(). work around this by initializing
4505 * with 0, then incrementing it afterwards.
4506 */
4507 if (dispatch_semaphore_signal(s->sem) < 0) {
4508 dispatch_release(s->sem);
4509 return MEMORY_E;
4510 }
4511 #elif defined(__OS2__)
4512 DosCreateMutexSem( NULL, &cond->mutex, 0, FALSE );
4513 DosCreateEventSem( NULL, &cond->cond, DCE_POSTONE, FALSE );
4514 #elif defined(__NT__)
4515 cond->cond = CreateEventA(NULL, FALSE, FALSE, NULL);
4516 if (cond->cond == NULL)
4517 return MEMORY_E;
4518
4519 if (wc_InitMutex(&cond->mutex) != 0) {
4520 if (CloseHandle(cond->cond) == 0)
4521 return MEMORY_E;
4522 return MEMORY_E;
4523 }
4524 #elif defined(__LINUX__)
4525 if (pthread_mutex_init(&cond->mutex, NULL) != 0)
4526 return MEMORY_E;
4527
4528 if (pthread_cond_init(&cond->cond, NULL) != 0) {
4529 /* Keep compilers happy that we are using the return code */
4530 if (pthread_mutex_destroy(&cond->mutex) != 0)
4531 return MEMORY_E;
4532 return MEMORY_E;
4533 }
4534 #endif
4535 return 0;
4536 }
4537
4538 int wolfSSL_CondFree(COND_TYPE* cond)
4539 {
4540 if (cond == NULL)
4541 return BAD_FUNC_ARG;
4542 #if defined(__MACH__)
4543 dispatch_release(cond->cond);
4544 #elif defined(__OS2__)
4545 DosCloseMutexSem(cond->mutex);
4546 DosCloseEventSem(cond->cond);
4547 #elif defined(__NT__)
4548 if (CloseHandle(cond->cond) == 0)
4549 return MEMORY_E;
4550 #elif defined(__LINUX__)
4551 if (pthread_mutex_destroy(&cond->mutex) != 0)
4552 return MEMORY_E;
4553
4554 if (pthread_cond_destroy(&cond->cond) != 0)
4555 return MEMORY_E;
4556 #endif
4557 return 0;
4558 }
4559
4560 int wolfSSL_CondStart(COND_TYPE* cond)
4561 {
4562 if (cond == NULL)
4563 return BAD_FUNC_ARG;
4564 #if defined(__MACH__)
4565 #elif defined(__OS2__)
4566 #elif defined(__NT__)
4567 if (wc_LockMutex(&cond->mutex) != 0)
4568 return BAD_MUTEX_E;
4569 #elif defined(__LINUX__)
4570 if (pthread_mutex_lock(&cond->mutex) != 0)
4571 return BAD_MUTEX_E;
4572 #endif
4573 return 0;
4574 }
4575
4576 int wolfSSL_CondSignal(COND_TYPE* cond)
4577 {
4578 if (cond == NULL)
4579 return BAD_FUNC_ARG;
4580 #if defined(__MACH__)
4581 dispatch_semaphore_signal(cond->cond);
4582 #elif defined(__OS2__)
4583 #elif defined(__NT__)
4584 if (wc_UnLockMutex(&cond->mutex) != 0)
4585 return BAD_MUTEX_E;
4586
4587 if (SetEvent(cond->cond) == 0)
4588 return MEMORY_E;
4589
4590 if (wc_LockMutex(&cond->mutex) != 0)
4591 return BAD_MUTEX_E;
4592 #elif defined(__LINUX__)
4593 if (pthread_cond_signal(&cond->cond) != 0)
4594 return MEMORY_E;
4595 #endif
4596 return 0;
4597 }
4598
4599 int wolfSSL_CondWait(COND_TYPE* cond)
4600 {
4601 if (cond == NULL)
4602 return BAD_FUNC_ARG;
4603 #if defined(__MACH__)
4604 dispatch_semaphore_wait(cond->cond, DISPATCH_TIME_FOREVER);
4605 #elif defined(__OS2__)
4606 #elif defined(__NT__)
4607 if (wc_UnLockMutex(&cond->mutex) != 0)
4608 return BAD_MUTEX_E;
4609
4610 if (WaitForSingleObject(cond->cond, INFINITE) == WAIT_FAILED)
4611 return MEMORY_E;
4612
4613 if (wc_LockMutex(&cond->mutex) != 0)
4614 return BAD_MUTEX_E;
4615 #elif defined(__LINUX__)
4616 if (pthread_cond_wait(&cond->cond, &cond->mutex) != 0)
4617 return MEMORY_E;
4618 #endif
4619 return 0;
4620 }
4621
4622 int wolfSSL_CondEnd(COND_TYPE* cond)
4623 {
4624 if (cond == NULL)
4625 return BAD_FUNC_ARG;
4626 #if defined(__OS2__)
4627 #elif defined(__NT__)
4628 if (wc_UnLockMutex(&cond->mutex) != 0)
4629 return BAD_MUTEX_E;
4630 #elif defined(__LINUX__)
4631 if (pthread_mutex_unlock(&cond->mutex) != 0)
4632 return BAD_MUTEX_E;
4633 #endif
4634 return 0;
4635 }
4636 #endif /* WOLFSSL_COND */
4637
4638
4639#elif defined(USE_WINDOWS_API) && !defined(WOLFSSL_PTHREADS) && \
4640 !defined(_WIN32_WCE)
4641 int wolfSSL_NewThread(THREAD_TYPE* thread,
4642 THREAD_CB cb, void* arg)
4643 {
4644 if (thread == NULL || cb == NULL)
4645 return BAD_FUNC_ARG;
4646
4647 /* Use _beginthreadex instead of _beginthread because of:
4648 * _beginthreadex is safer to use than _beginthread. If the thread
4649 * that's generated by _beginthread exits quickly, the handle that's
4650 * returned to the caller of _beginthread might be invalid or point
4651 * to another thread. However, the handle that's returned by
4652 * _beginthreadex has to be closed by the caller of _beginthreadex,
4653 * so it's guaranteed to be a valid handle if _beginthreadex didn't
4654 * return an error.*/
4655 *thread = _beginthreadex(NULL, 0, cb, arg, 0, NULL);
4656 if (*thread == 0) {
4657 *thread = INVALID_THREAD_VAL;
4658 return MEMORY_E;
4659 }
4660
4661 return 0;
4662 }
4663
4664#ifdef WOLFSSL_THREAD_NO_JOIN
4665 int wolfSSL_NewThreadNoJoin(THREAD_CB_NOJOIN cb, void* arg)
4666 {
4667 THREAD_TYPE thread;
4668
4669 if (cb == NULL)
4670 return BAD_FUNC_ARG;
4671
4672 thread = _beginthread(cb, 0, arg);
4673 if (thread == -1L) {
4674 return MEMORY_E;
4675 }
4676
4677 return 0;
4678 }
4679#endif
4680
4681 int wolfSSL_JoinThread(THREAD_TYPE thread)
4682 {
4683 int ret = 0;
4684
4685 if (thread == INVALID_THREAD_VAL)
4686 return BAD_FUNC_ARG;
4687
4688 /* We still want to attempt to close the thread handle even on error */
4689 if (WaitForSingleObject((HANDLE)thread, INFINITE) == WAIT_FAILED)
4690 ret = MEMORY_E;
4691
4692 if (CloseHandle((HANDLE)thread) == 0)
4693 ret = MEMORY_E;
4694
4695 return ret;
4696 }
4697
4698#ifdef WOLFSSL_COND
4699 int wolfSSL_CondInit(COND_TYPE* cond)
4700 {
4701 if (cond == NULL)
4702 return BAD_FUNC_ARG;
4703
4704 cond->cond = CreateEventA(NULL, FALSE, FALSE, NULL);
4705 if (cond->cond == NULL)
4706 return MEMORY_E;
4707
4708 if (wc_InitMutex(&cond->mutex) != 0) {
4709 if (CloseHandle(cond->cond) == 0)
4710 return MEMORY_E;
4711 return MEMORY_E;
4712 }
4713
4714 return 0;
4715 }
4716
4717 int wolfSSL_CondFree(COND_TYPE* cond)
4718 {
4719 if (cond == NULL)
4720 return BAD_FUNC_ARG;
4721
4722 if (CloseHandle(cond->cond) == 0)
4723 return MEMORY_E;
4724
4725 return 0;
4726 }
4727
4728 int wolfSSL_CondStart(COND_TYPE* cond)
4729 {
4730 if (cond == NULL)
4731 return BAD_FUNC_ARG;
4732
4733 if (wc_LockMutex(&cond->mutex) != 0)
4734 return BAD_MUTEX_E;
4735
4736 return 0;
4737 }
4738
4739 int wolfSSL_CondSignal(COND_TYPE* cond)
4740 {
4741 if (cond == NULL)
4742 return BAD_FUNC_ARG;
4743
4744 if (wc_UnLockMutex(&cond->mutex) != 0)
4745 return BAD_MUTEX_E;
4746
4747 if (SetEvent(cond->cond) == 0)
4748 return MEMORY_E;
4749
4750 if (wc_LockMutex(&cond->mutex) != 0)
4751 return BAD_MUTEX_E;
4752
4753 return 0;
4754 }
4755
4756 int wolfSSL_CondWait(COND_TYPE* cond)
4757 {
4758 if (cond == NULL)
4759 return BAD_FUNC_ARG;
4760
4761 if (wc_UnLockMutex(&cond->mutex) != 0)
4762 return BAD_MUTEX_E;
4763
4764 if (WaitForSingleObject(cond->cond, INFINITE) == WAIT_FAILED)
4765 return MEMORY_E;
4766
4767 if (wc_LockMutex(&cond->mutex) != 0)
4768 return BAD_MUTEX_E;
4769
4770 return 0;
4771 }
4772
4773 int wolfSSL_CondEnd(COND_TYPE* cond)
4774 {
4775 if (cond == NULL)
4776 return BAD_FUNC_ARG;
4777
4778 if (wc_UnLockMutex(&cond->mutex) != 0)
4779 return BAD_MUTEX_E;
4780
4781 return 0;
4782 }
4783#endif /* WOLFSSL_COND */
4784
4785#elif defined(WOLFSSL_TIRTOS)
4786
4787 int wolfSSL_NewThread(THREAD_TYPE* thread,
4788 THREAD_CB cb, void* arg)
4789 {
4790 /* Initialize the defaults and set the parameters. */
4791 Task_Params taskParams;
4792 Task_Params_init(&taskParams);
4793 taskParams.arg0 = (UArg)arg;
4794 taskParams.stackSize = 65535;
4795 *thread = Task_create((Task_FuncPtr)cb, &taskParams, NULL);
4796 if (*thread == NULL) {
4797 return MEMORY_E;
4798 }
4799 Task_yield();
4800 return 0;
4801 }
4802
4803 int wolfSSL_JoinThread(THREAD_TYPE thread)
4804 {
4805 while(1) {
4806 if (Task_getMode(thread) == Task_Mode_TERMINATED) {
4807 Task_sleep(5);
4808 break;
4809 }
4810 Task_yield();
4811 }
4812 return 0;
4813 }
4814
4815#elif defined(NETOS)
4816
4817 int wolfSSL_NewThread(THREAD_TYPE* thread,
4818 THREAD_CB cb, void* arg)
4819 {
4820 /* For backwards compatibility allow using this declaration as well. */
4821 #ifdef TESTSUITE_THREAD_STACK_SZ
4822 #define WOLFSSL_NETOS_STACK_SZ TESTSUITE_THREAD_STACK_SZ
4823 #endif
4824 /* This can be adjusted by defining in user_settings.h, will default to
4825 * 65k in the event it is undefined */
4826 #ifndef WOLFSSL_NETOS_STACK_SZ
4827 #define WOLFSSL_NETOS_STACK_SZ 65535
4828 #endif
4829 int result;
4830
4831 if (thread == NULL || cb == NULL)
4832 return BAD_FUNC_ARG;
4833
4834 XMEMSET(thread, 0, sizeof(*thread));
4835
4836 thread->threadStack = (void *)XMALLOC(WOLFSSL_NETOS_STACK_SZ, NULL,
4837 DYNAMIC_TYPE_OS_BUF);
4838 if (thread->threadStack == NULL)
4839 return MEMORY_E;
4840
4841
4842 /* first create the idle thread:
4843 * ARGS:
4844 * Param1: pointer to thread
4845 * Param2: name
4846 * Param3 and 4: entry function and input
4847 * Param5: pointer to thread stack
4848 * Param6: stack size
4849 * Param7 and 8: priority level and preempt threshold
4850 * Param9 and 10: time slice and auto-start indicator */
4851 result = tx_thread_create(&thread->tid,
4852 "wolfSSL thread",
4853 (entry_functionType)cb, (ULONG)arg,
4854 thread->threadStack,
4855 WOLFSSL_NETOS_STACK_SZ,
4856 2, 2,
4857 1, TX_AUTO_START);
4858 if (result != TX_SUCCESS) {
4859 XFREE(thread->threadStack, NULL, DYNAMIC_TYPE_OS_BUF);
4860 thread->threadStack = NULL;
4861 return MEMORY_E;
4862 }
4863
4864 return 0;
4865 }
4866
4867 int wolfSSL_JoinThread(THREAD_TYPE thread)
4868 {
4869 /* TODO: maybe have to use tx_thread_delete? */
4870 XFREE(thread.threadStack, NULL, DYNAMIC_TYPE_OS_BUF);
4871 thread.threadStack = NULL;
4872 return 0;
4873 }
4874
4875#elif defined(WOLFSSL_ZEPHYR)
4876
4877 void* wolfsslThreadHeapHint = NULL;
4878
4879 int wolfSSL_NewThread(THREAD_TYPE* thread,
4880 THREAD_CB cb, void* arg)
4881 {
4882 #ifndef WOLFSSL_ZEPHYR_STACK_SZ
4883 #define WOLFSSL_ZEPHYR_STACK_SZ (48*1024)
4884 #endif
4885
4886 if (thread == NULL || cb == NULL)
4887 return BAD_FUNC_ARG;
4888
4889 XMEMSET(thread, 0, sizeof(*thread));
4890
4891 thread->tid = (struct k_thread*)XMALLOC(
4892 Z_KERNEL_STACK_SIZE_ADJUST(sizeof(struct k_thread)),
4893 wolfsslThreadHeapHint, DYNAMIC_TYPE_TMP_BUFFER);
4894 if (thread->tid == NULL) {
4895 WOLFSSL_MSG("error: XMALLOC thread->tid failed");
4896 return MEMORY_E;
4897 }
4898
4899 /* TODO: Use the following once k_thread_stack_alloc makes it into a
4900 * release.
4901 * thread->threadStack = k_thread_stack_alloc(WOLFSSL_ZEPHYR_STACK_SZ,
4902 * 0);
4903 */
4904 thread->threadStack = (void*)XMALLOC(
4905 Z_KERNEL_STACK_SIZE_ADJUST(WOLFSSL_ZEPHYR_STACK_SZ),
4906 wolfsslThreadHeapHint, DYNAMIC_TYPE_TMP_BUFFER);
4907 if (thread->threadStack == NULL) {
4908 XFREE(thread->tid, wolfsslThreadHeapHint,
4909 DYNAMIC_TYPE_TMP_BUFFER);
4910 thread->tid = NULL;
4911
4912 WOLFSSL_MSG("error: XMALLOC thread->threadStack failed");
4913 return MEMORY_E;
4914 }
4915
4916 /* k_thread_create does not return any error codes */
4917 /* Casting to k_thread_entry_t should be fine since we just ignore the
4918 * extra arguments being passed in */
4919 k_thread_create(thread->tid, thread->threadStack,
4920 WOLFSSL_ZEPHYR_STACK_SZ, (k_thread_entry_t)cb, arg, NULL, NULL,
4921 5, 0, K_NO_WAIT);
4922
4923 return 0;
4924 }
4925
4926 int wolfSSL_JoinThread(THREAD_TYPE thread)
4927 {
4928 int ret = 0;
4929 int err;
4930
4931 err = k_thread_join(thread.tid, K_FOREVER);
4932 if (err != 0)
4933 ret = MEMORY_E;
4934
4935 XFREE(thread.tid, wolfsslThreadHeapHint,
4936 DYNAMIC_TYPE_TMP_BUFFER);
4937 thread.tid = NULL;
4938
4939 /* TODO: Use the following once k_thread_stack_free makes it into a
4940 * release.
4941 * err = k_thread_stack_free(thread.threadStack);
4942 * if (err != 0)
4943 * ret = MEMORY_E;
4944 */
4945 XFREE(thread.threadStack, wolfsslThreadHeapHint,
4946 DYNAMIC_TYPE_TMP_BUFFER);
4947 thread.threadStack = NULL;
4948
4949 /* No thread resources to free. Everything is stored in thread.tid */
4950
4951 return ret;
4952 }
4953
4954#ifdef WOLFSSL_COND
4955 /* Use the pthreads translation layer for signaling */
4956
4957#endif /* WOLFSSL_COND */
4958
4959#elif defined(WOLFSSL_PTHREADS) || \
4960 (defined(FREERTOS) && defined(WOLFSSL_ESPIDF))
4961
4962 int wolfSSL_NewThread(THREAD_TYPE* thread,
4963 THREAD_CB cb, void* arg)
4964 {
4965 if (thread == NULL || cb == NULL)
4966 return BAD_FUNC_ARG;
4967
4968 if (pthread_create(thread, NULL, cb, arg) != 0)
4969 return MEMORY_E;
4970
4971 return 0;
4972 }
4973
4974 #ifdef WOLFSSL_THREAD_NO_JOIN
4975 int wolfSSL_NewThreadNoJoin(THREAD_CB_NOJOIN cb, void* arg)
4976 {
4977 THREAD_TYPE thread;
4978 int ret;
4979 XMEMSET(&thread, 0, sizeof(thread));
4980 ret = wolfSSL_NewThread(&thread, cb, arg);
4981 if (ret == 0)
4982 ret = pthread_detach(thread);
4983 return ret;
4984 }
4985 #endif
4986
4987 int wolfSSL_JoinThread(THREAD_TYPE thread)
4988 {
4989 if (thread == INVALID_THREAD_VAL)
4990 return BAD_FUNC_ARG;
4991
4992 if (pthread_join(thread, NULL) != 0)
4993 return MEMORY_E;
4994
4995 return 0;
4996 }
4997
4998#ifdef WOLFSSL_COND
4999 #if defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 \
5000 && !defined(__ppc__)
5001 /* Apple style dispatch semaphore */
5002 int wolfSSL_CondInit(COND_TYPE* cond)
5003 {
5004 if (cond == NULL)
5005 return BAD_FUNC_ARG;
5006
5007 /* dispatch_release() fails hard, with Trace/BPT trap signal, if the
5008 * sem's internal count is less than the value passed in with
5009 * dispatch_semaphore_create(). work around this by initing
5010 * with 0, then incrementing it afterwards.
5011 */
5012 cond->cond = dispatch_semaphore_create(0);
5013 if (cond->cond == NULL)
5014 return MEMORY_E;
5015
5016 if (wc_InitMutex(&cond->mutex) != 0) {
5017 dispatch_release(cond->cond);
5018 return MEMORY_E;
5019 }
5020
5021 return 0;
5022 }
5023
5024 int wolfSSL_CondFree(COND_TYPE* cond)
5025 {
5026 if (cond == NULL)
5027 return BAD_FUNC_ARG;
5028
5029 dispatch_release(cond->cond);
5030 cond->cond = NULL;
5031
5032 if (wc_FreeMutex(&cond->mutex) != 0) {
5033 return MEMORY_E;
5034 }
5035
5036 return 0;
5037 }
5038
5039 int wolfSSL_CondStart(COND_TYPE* cond)
5040 {
5041 if (cond == NULL)
5042 return BAD_FUNC_ARG;
5043
5044 if (wc_LockMutex(&cond->mutex) != 0)
5045 return BAD_MUTEX_E;
5046
5047 return 0;
5048 }
5049
5050 int wolfSSL_CondSignal(COND_TYPE* cond)
5051 {
5052 if (cond == NULL)
5053 return BAD_FUNC_ARG;
5054
5055 if (wc_UnLockMutex(&cond->mutex) != 0)
5056 return BAD_MUTEX_E;
5057
5058 dispatch_semaphore_signal(cond->cond);
5059
5060 if (wc_LockMutex(&cond->mutex) != 0)
5061 return BAD_MUTEX_E;
5062
5063 return 0;
5064 }
5065
5066 int wolfSSL_CondWait(COND_TYPE* cond)
5067 {
5068 if (cond == NULL)
5069 return BAD_FUNC_ARG;
5070
5071 if (wc_UnLockMutex(&cond->mutex) != 0)
5072 return BAD_MUTEX_E;
5073
5074 dispatch_semaphore_wait(cond->cond, DISPATCH_TIME_FOREVER);
5075
5076 if (wc_LockMutex(&cond->mutex) != 0)
5077 return BAD_MUTEX_E;
5078
5079 return 0;
5080 }
5081
5082 int wolfSSL_CondEnd(COND_TYPE* cond)
5083 {
5084 if (cond == NULL)
5085 return BAD_FUNC_ARG;
5086
5087 if (wc_UnLockMutex(&cond->mutex) != 0)
5088 return BAD_MUTEX_E;
5089
5090 return 0;
5091 }
5092
5093 #else /* Generic POSIX conditional */
5094
5095 int wolfSSL_CondInit(COND_TYPE* cond)
5096 {
5097 if (cond == NULL)
5098 return BAD_FUNC_ARG;
5099
5100 if (pthread_mutex_init(&cond->mutex, NULL) != 0)
5101 return MEMORY_E;
5102
5103 if (pthread_cond_init(&cond->cond, NULL) != 0) {
5104 /* Keep compilers happy that we are using the return code */
5105 if (pthread_mutex_destroy(&cond->mutex) != 0)
5106 return MEMORY_E;
5107 return MEMORY_E;
5108 }
5109
5110 return 0;
5111 }
5112
5113 int wolfSSL_CondFree(COND_TYPE* cond)
5114 {
5115 int ret = 0;
5116
5117 if (cond == NULL)
5118 return BAD_FUNC_ARG;
5119
5120 if (pthread_mutex_destroy(&cond->mutex) != 0)
5121 ret = MEMORY_E;
5122
5123 if (pthread_cond_destroy(&cond->cond) != 0)
5124 ret = MEMORY_E;
5125
5126 return ret;
5127 }
5128
5129 int wolfSSL_CondStart(COND_TYPE* cond)
5130 {
5131 if (cond == NULL)
5132 return BAD_FUNC_ARG;
5133
5134 if (pthread_mutex_lock(&cond->mutex) != 0)
5135 return BAD_MUTEX_E;
5136
5137 return 0;
5138 }
5139
5140 int wolfSSL_CondSignal(COND_TYPE* cond)
5141 {
5142 if (cond == NULL)
5143 return BAD_FUNC_ARG;
5144
5145 if (pthread_cond_signal(&cond->cond) != 0)
5146 return MEMORY_E;
5147
5148 return 0;
5149 }
5150
5151 int wolfSSL_CondWait(COND_TYPE* cond)
5152 {
5153 if (cond == NULL)
5154 return BAD_FUNC_ARG;
5155
5156 if (pthread_cond_wait(&cond->cond, &cond->mutex) != 0)
5157 return MEMORY_E;
5158
5159 return 0;
5160 }
5161
5162 int wolfSSL_CondEnd(COND_TYPE* cond)
5163 {
5164 if (cond == NULL)
5165 return BAD_FUNC_ARG;
5166
5167 if (pthread_mutex_unlock(&cond->mutex) != 0)
5168 return BAD_MUTEX_E;
5169
5170 return 0;
5171 }
5172
5173 #endif /* __MACH__ */
5174#endif /* WOLFSSL_COND */
5175
5176#endif /* Environment check */
5177
5178#endif /* not SINGLE_THREADED */
5179
5180#if (defined(__unix__) || defined(__APPLE__)) && \
5181 !defined(WOLFSSL_LINUXKM) && !defined(WOLFSSL_ZEPHYR)
5182
5183#include <fcntl.h>
5184#include <errno.h>
5185#include <sys/socket.h>
5186
5187#ifndef O_CLOEXEC
5188 #define O_CLOEXEC 0
5189#endif
5190#ifndef SOCK_CLOEXEC
5191 #define SOCK_CLOEXEC 0
5192#endif
5193
5194void wc_set_cloexec(int fd)
5195{
5196#ifdef FD_CLOEXEC
5197 int fdFlags;
5198 if (fd < 0)
5199 return;
5200 fdFlags = fcntl(fd, F_GETFD);
5201 if (fdFlags >= 0)
5202 (void)fcntl(fd, F_SETFD, fdFlags | FD_CLOEXEC);
5203#else
5204 (void)fd;
5205#endif
5206}
5207
5208int wc_open_cloexec(const char* path, int flags)
5209{
5210 int fd = open(path, flags | O_CLOEXEC);
5211#ifdef FD_CLOEXEC
5212 if (fd < 0 && errno == EINVAL) {
5213 fd = open(path, flags);
5214 wc_set_cloexec(fd);
5215 }
5216#endif
5217 return fd;
5218}
5219
5220int wc_socket_cloexec(int domain, int type, int protocol)
5221{
5222 int fd = socket(domain, type | SOCK_CLOEXEC, protocol);
5223#ifdef FD_CLOEXEC
5224 if (fd < 0 && errno == EINVAL) {
5225 fd = socket(domain, type, protocol);
5226 wc_set_cloexec(fd);
5227 }
5228#endif
5229 return fd;
5230}
5231
5232int wc_accept_cloexec(int sockfd, void* addr, void* addrlen)
5233{
5234 int fd;
5235#if (defined(__USE_GNU) && (defined(__linux__) || defined(__ANDROID__))) || \
5236 (defined(__FreeBSD__) && defined(__BSD_VISIBLE) && __BSD_VISIBLE && \
5237 (__FreeBSD_version >= 1000000))
5238 fd = accept4(sockfd, (struct sockaddr*)addr, (socklen_t*)addrlen,
5239 SOCK_CLOEXEC);
5240 if (fd >= 0)
5241 return fd;
5242 if (errno != ENOSYS && errno != EINVAL)
5243 return fd;
5244#endif
5245 fd = accept(sockfd, (struct sockaddr*)addr, (socklen_t*)addrlen);
5246 wc_set_cloexec(fd);
5247 return fd;
5248}
5249
5250#endif /* (__unix__ || __APPLE__) && !WOLFSSL_LINUXKM && !WOLFSSL_ZEPHYR */
5251
5252#if defined(WOLFSSL_LINUXKM) && defined(CONFIG_ARM64) && \
5253 defined(WC_SYM_RELOC_TABLES)
5254#ifndef CONFIG_ARCH_TEGRA
5255
5256#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
5257noinstr void my__alt_cb_patch_nops(struct alt_instr *alt, __le32 *origptr,
5258 __le32 *updptr, int nr_inst)
5259{
5260 return WC_PIE_INDIRECT_SYM(alt_cb_patch_nops)
5261 (alt, origptr, updptr, nr_inst);
5262}
5263#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0) */
5264
5265void my__queued_spin_lock_slowpath(struct qspinlock *lock, u32 val)
5266{
5267 return WC_PIE_INDIRECT_SYM(queued_spin_lock_slowpath)
5268 (lock, val);
5269}
5270#endif
5271#endif