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/linuxkm/lkcapi_aes_glue.c
raw
1/* lkcapi_aes_glue.c -- glue logic for AES modes
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/* included by linuxkm/lkcapi_glue.c */
23#ifndef WC_SKIP_INCLUDED_C_FILES
24
25#ifndef LINUXKM_LKCAPI_REGISTER
26 #error lkcapi_aes_glue.c included in non-LINUXKM_LKCAPI_REGISTER project.
27#endif
28
29#if (defined(LINUXKM_LKCAPI_REGISTER_ALL) || \
30 defined(LINUXKM_LKCAPI_REGISTER_AES_ALL) || \
31 (defined(LINUXKM_LKCAPI_REGISTER_ALL_KCONFIG) && defined(CONFIG_CRYPTO_AES))) && \
32 !defined(LINUXKM_LKCAPI_DONT_REGISTER_AES_ALL) && \
33 !defined(LINUXKM_LKCAPI_REGISTER_AES)
34 #define LINUXKM_LKCAPI_REGISTER_AES
35#endif
36
37#if defined(LINUXKM_LKCAPI_REGISTER_AESCBC) || \
38 defined(LINUXKM_LKCAPI_REGISTER_AESCFB) || \
39 defined(LINUXKM_LKCAPI_REGISTER_AESGCM) || \
40 defined(LINUXKM_LKCAPI_REGISTER_AESGCM_RFC4106) || \
41 defined(LINUXKM_LKCAPI_REGISTER_AESCCM) || \
42 defined(LINUXKM_LKCAPI_REGISTER_AESCCM_RFC4309) || \
43 defined(LINUXKM_LKCAPI_REGISTER_AESXTS) || \
44 defined(LINUXKM_LKCAPI_REGISTER_AESCTR) || \
45 defined(LINUXKM_LKCAPI_REGISTER_AESOFB) || \
46 defined(LINUXKM_LKCAPI_REGISTER_AESECB) || \
47 defined(LINUXKM_LKCAPI_REGISTER_AES_ALL)
48
49 #ifdef NO_AES
50 #error LINUXKM_LKCAPI_REGISTER_AES* requires !defined(NO_AES)
51 #endif
52
53 #ifndef LINUXKM_LKCAPI_REGISTER_AES
54 #define LINUXKM_LKCAPI_REGISTER_AES
55 #endif
56#endif
57
58#ifdef NO_AES
59 #undef LINUXKM_LKCAPI_REGISTER_AES
60#endif
61
62#if defined(LINUXKM_LKCAPI_REGISTER_ALL_KCONFIG) && !defined(CONFIG_CRYPTO_AES)
63 #undef LINUXKM_LKCAPI_REGISTER_AES
64#endif
65
66#if defined(LINUXKM_LKCAPI_REGISTER_ALL_KCONFIG) && defined(CONFIG_CRYPTO_AES) && \
67 !defined(LINUXKM_LKCAPI_REGISTER_AES)
68 #error Config conflict: CONFIG_CRYPTO_AES is defined, but LINUXKM_LKCAPI_REGISTER_AES is not.
69#endif
70
71#ifdef LINUXKM_LKCAPI_REGISTER_AES
72
73#include <wolfssl/wolfcrypt/aes.h>
74
75#if defined(WC_FLAG_DONT_USE_AESNI) && !defined(WC_FLAG_DONT_USE_VECTOR_OPS)
76 /* backward compat */
77 #define WC_FLAG_DONT_USE_VECTOR_OPS WC_FLAG_DONT_USE_AESNI
78#endif
79
80#if defined(WC_LINUXKM_C_FALLBACK_IN_SHIMS) && !defined(WC_FLAG_DONT_USE_VECTOR_OPS)
81 #error WC_LINUXKM_C_FALLBACK_IN_SHIMS is defined but WC_FLAG_DONT_USE_VECTOR_OPS is missing.
82#endif
83
84/* note the FIPS code will be returned on failure even in non-FIPS builds. */
85#define LINUXKM_LKCAPI_AES_KAT_MISMATCH_E AES_KAT_FIPS_E
86#define LINUXKM_LKCAPI_AESGCM_KAT_MISMATCH_E AESGCM_KAT_FIPS_E
87
88#define WOLFKM_AESCBC_NAME "cbc(aes)"
89#define WOLFKM_AESCFB_NAME "cfb(aes)"
90#define WOLFKM_AESGCM_NAME "gcm(aes)"
91#define WOLFKM_AESGCM_RFC4106_NAME "rfc4106(gcm(aes))"
92#define WOLFKM_AESCCM_NAME "ccm(aes)"
93#define WOLFKM_AESCCM_RFC4309_NAME "rfc4309(ccm(aes))"
94#define WOLFKM_AESXTS_NAME "xts(aes)"
95#define WOLFKM_AESCTR_NAME "ctr(aes)"
96#define WOLFKM_AESOFB_NAME "ofb(aes)"
97#define WOLFKM_AESECB_NAME "ecb(aes)"
98
99#if defined(USE_INTEL_SPEEDUP) || defined(USE_INTEL_SPEEDUP_FOR_AES)
100 #define WOLFKM_AES_DRIVER_ISA_EXT "-aesni-avx"
101#elif defined(WOLFSSL_AESNI)
102 #define WOLFKM_AES_DRIVER_ISA_EXT "-aesni"
103#else
104 #define WOLFKM_AES_DRIVER_ISA_EXT ""
105#endif
106
107#define WOLFKM_AES_DRIVER_SUFFIX \
108 WOLFKM_AES_DRIVER_ISA_EXT WOLFKM_DRIVER_SUFFIX_BASE
109
110#define WOLFKM_AESCBC_DRIVER ("cbc-aes" WOLFKM_AES_DRIVER_SUFFIX)
111#define WOLFKM_AESCFB_DRIVER ("cfb-aes" WOLFKM_AES_DRIVER_SUFFIX)
112#define WOLFKM_AESGCM_DRIVER ("gcm-aes" WOLFKM_AES_DRIVER_SUFFIX)
113#define WOLFKM_AESGCM_RFC4106_DRIVER ("rfc4106-gcm-aes" WOLFKM_AES_DRIVER_SUFFIX)
114#define WOLFKM_AESCCM_DRIVER ("ccm-aes" WOLFKM_AES_DRIVER_SUFFIX)
115#define WOLFKM_AESCCM_RFC4309_DRIVER ("rfc4309-ccm-aes" WOLFKM_AES_DRIVER_SUFFIX)
116#define WOLFKM_AESXTS_DRIVER ("xts-aes" WOLFKM_AES_DRIVER_SUFFIX)
117#define WOLFKM_AESCTR_DRIVER ("ctr-aes" WOLFKM_AES_DRIVER_SUFFIX)
118#define WOLFKM_AESOFB_DRIVER ("ofb-aes" WOLFKM_AES_DRIVER_SUFFIX)
119#define WOLFKM_AESECB_DRIVER ("ecb-aes" WOLFKM_AES_DRIVER_SUFFIX)
120
121#ifdef HAVE_AES_CBC
122 #if (defined(LINUXKM_LKCAPI_REGISTER_ALL) || \
123 defined(LINUXKM_LKCAPI_REGISTER_AES_ALL) || \
124 (defined(LINUXKM_LKCAPI_REGISTER_ALL_KCONFIG) && defined(CONFIG_CRYPTO_CBC))) && \
125 !defined(LINUXKM_LKCAPI_DONT_REGISTER_AESCBC) && \
126 !defined(LINUXKM_LKCAPI_REGISTER_AESCBC)
127 #define LINUXKM_LKCAPI_REGISTER_AESCBC
128 #endif
129#else
130 #if defined(LINUXKM_LKCAPI_REGISTER_ALL_KCONFIG) && defined(CONFIG_CRYPTO_CBC) && \
131 !defined(LINUXKM_LKCAPI_DONT_REGISTER_AESCBC)
132 #error Config conflict: target kernel has CONFIG_CRYPTO_CBC, but module is missing HAVE_AES_CBC.
133 #endif
134 #undef LINUXKM_LKCAPI_REGISTER_AESCBC
135#endif
136#ifdef WOLFSSL_AES_CFB
137 #if (defined(LINUXKM_LKCAPI_REGISTER_ALL) || \
138 defined(LINUXKM_LKCAPI_REGISTER_AES_ALL)) && \
139 !defined(LINUXKM_LKCAPI_DONT_REGISTER_AESCFB) && \
140 !defined(LINUXKM_LKCAPI_REGISTER_AESCFB)
141 #define LINUXKM_LKCAPI_REGISTER_AESCFB
142 #endif
143#else
144 #undef LINUXKM_LKCAPI_REGISTER_AESCFB
145#endif
146#ifdef HAVE_AESGCM
147 #if (defined(LINUXKM_LKCAPI_REGISTER_ALL) || \
148 defined(LINUXKM_LKCAPI_REGISTER_AES_ALL) || \
149 (defined(LINUXKM_LKCAPI_REGISTER_ALL_KCONFIG) && defined(CONFIG_CRYPTO_GCM))) && \
150 !defined(LINUXKM_LKCAPI_DONT_REGISTER_AESGCM) && \
151 !defined(LINUXKM_LKCAPI_REGISTER_AESGCM)
152 #define LINUXKM_LKCAPI_REGISTER_AESGCM
153 #endif
154 #if ((defined(LINUXKM_LKCAPI_REGISTER_ALL) || \
155 defined(LINUXKM_LKCAPI_REGISTER_AES_ALL) || \
156 (defined(LINUXKM_LKCAPI_REGISTER_ALL_KCONFIG) && defined(CONFIG_CRYPTO_GCM))) && \
157 !defined(LINUXKM_LKCAPI_DONT_REGISTER_AESGCM_RFC4106)) && \
158 !defined(LINUXKM_LKCAPI_REGISTER_AESGCM_RFC4106)
159 #define LINUXKM_LKCAPI_REGISTER_AESGCM_RFC4106
160 #endif
161#else
162 #if defined(LINUXKM_LKCAPI_REGISTER_ALL_KCONFIG) && defined(CONFIG_CRYPTO_GCM) && \
163 !defined(LINUXKM_LKCAPI_DONT_REGISTER_AESGCM)
164 #error Config conflict: target kernel has CONFIG_CRYPTO_GCM, but module is missing HAVE_AESGCM.
165 #endif
166 #undef LINUXKM_LKCAPI_REGISTER_AESGCM
167 #undef LINUXKM_LKCAPI_REGISTER_AESGCM_RFC4106
168#endif
169#ifdef HAVE_AESCCM
170 #if (defined(LINUXKM_LKCAPI_REGISTER_ALL) || \
171 defined(LINUXKM_LKCAPI_REGISTER_AES_ALL) || \
172 (defined(LINUXKM_LKCAPI_REGISTER_ALL_KCONFIG) && defined(CONFIG_CRYPTO_CCM))) && \
173 !defined(LINUXKM_LKCAPI_DONT_REGISTER_AESCCM) && \
174 !defined(LINUXKM_LKCAPI_REGISTER_AESCCM)
175 #define LINUXKM_LKCAPI_REGISTER_AESCCM
176 #endif
177 #if ((defined(LINUXKM_LKCAPI_REGISTER_ALL) || \
178 defined(LINUXKM_LKCAPI_REGISTER_AES_ALL) || \
179 (defined(LINUXKM_LKCAPI_REGISTER_ALL_KCONFIG) && defined(CONFIG_CRYPTO_CCM))) && \
180 !defined(LINUXKM_LKCAPI_DONT_REGISTER_AESCCM_RFC4309)) && \
181 !defined(LINUXKM_LKCAPI_REGISTER_AESCCM_RFC4309)
182 #define LINUXKM_LKCAPI_REGISTER_AESCCM_RFC4309
183 #endif
184#else
185 #if defined(LINUXKM_LKCAPI_REGISTER_ALL_KCONFIG) && defined(CONFIG_CRYPTO_CCM) && \
186 !defined(LINUXKM_LKCAPI_DONT_REGISTER_AESCCM)
187 #error Config conflict: target kernel has CONFIG_CRYPTO_CCM, but module is missing HAVE_AESCCM.
188 #endif
189 #undef LINUXKM_LKCAPI_REGISTER_AESCCM
190 #undef LINUXKM_LKCAPI_REGISTER_AESCCM_RFC4309
191#endif
192#ifdef WOLFSSL_AES_XTS
193 #if (defined(LINUXKM_LKCAPI_REGISTER_ALL) || \
194 defined(LINUXKM_LKCAPI_REGISTER_AES_ALL) || \
195 (defined(LINUXKM_LKCAPI_REGISTER_ALL_KCONFIG) && defined(CONFIG_CRYPTO_XTS))) && \
196 !defined(LINUXKM_LKCAPI_DONT_REGISTER_AESXTS) && \
197 !defined(LINUXKM_LKCAPI_REGISTER_AESXTS)
198 #define LINUXKM_LKCAPI_REGISTER_AESXTS
199 #endif
200#else
201 #if defined(LINUXKM_LKCAPI_REGISTER_ALL_KCONFIG) && defined(CONFIG_CRYPTO_XTS) && \
202 !defined(LINUXKM_LKCAPI_DONT_REGISTER_AESXTS)
203 #error Config conflict: target kernel has CONFIG_CRYPTO_XTS, but module is missing WOLFSSL_AES_XTS.
204 #endif
205 #undef LINUXKM_LKCAPI_REGISTER_AESXTS
206#endif
207#ifdef WOLFSSL_AES_COUNTER
208 #if (defined(LINUXKM_LKCAPI_REGISTER_ALL) || \
209 defined(LINUXKM_LKCAPI_REGISTER_AES_ALL) || \
210 (defined(LINUXKM_LKCAPI_REGISTER_ALL_KCONFIG) && defined(CONFIG_CRYPTO_CTR))) && \
211 !defined(LINUXKM_LKCAPI_DONT_REGISTER_AESCTR) && \
212 !defined(LINUXKM_LKCAPI_REGISTER_AESCTR)
213 #define LINUXKM_LKCAPI_REGISTER_AESCTR
214 #endif
215#else
216 #if defined(LINUXKM_LKCAPI_REGISTER_ALL_KCONFIG) && defined(CONFIG_CRYPTO_CTR) && \
217 !defined(LINUXKM_LKCAPI_DONT_REGISTER_AESCTR)
218 #error Config conflict: target kernel has CONFIG_CRYPTO_CTR, but module is missing WOLFSSL_AES_COUNTER.
219 #endif
220 #undef LINUXKM_LKCAPI_REGISTER_AESCTR
221#endif
222#ifdef WOLFSSL_AES_OFB
223 #if (defined(LINUXKM_LKCAPI_REGISTER_ALL) || \
224 defined(LINUXKM_LKCAPI_REGISTER_AES_ALL)) && \
225 !defined(LINUXKM_LKCAPI_DONT_REGISTER_AESOFB) && \
226 !defined(LINUXKM_LKCAPI_REGISTER_AESOFB)
227 #define LINUXKM_LKCAPI_REGISTER_AESOFB
228 #endif
229#else
230 #undef LINUXKM_LKCAPI_REGISTER_AESOFB
231#endif
232#ifdef HAVE_AES_ECB
233 #if (defined(LINUXKM_LKCAPI_REGISTER_ALL) || \
234 defined(LINUXKM_LKCAPI_REGISTER_AES_ALL) || \
235 (defined(LINUXKM_LKCAPI_REGISTER_ALL_KCONFIG) && defined(CONFIG_CRYPTO_ECB))) && \
236 !defined(LINUXKM_LKCAPI_DONT_REGISTER_AESECB) && \
237 !defined(LINUXKM_LKCAPI_REGISTER_AESECB)
238 #define LINUXKM_LKCAPI_REGISTER_AESECB
239 #endif
240#else
241 #if defined(LINUXKM_LKCAPI_REGISTER_ALL_KCONFIG) && defined(CONFIG_CRYPTO_ECB) && \
242 !defined(LINUXKM_LKCAPI_DONT_REGISTER_AESECB)
243 #error Config conflict: target kernel has CONFIG_CRYPTO_ECB, but module is missing HAVE_AES_ECB.
244 #endif
245 #undef LINUXKM_LKCAPI_REGISTER_AESECB
246#endif
247
248#ifdef LINUXKM_LKCAPI_REGISTER_AESCBC
249 static int linuxkm_test_aescbc(void);
250#endif
251#ifdef LINUXKM_LKCAPI_REGISTER_AESCFB
252 static int linuxkm_test_aescfb(void);
253#endif
254#ifdef LINUXKM_LKCAPI_REGISTER_AESGCM
255 static int linuxkm_test_aesgcm(void);
256#endif
257#ifdef LINUXKM_LKCAPI_REGISTER_AESGCM_RFC4106
258 static int linuxkm_test_aesgcm_rfc4106(void);
259#endif
260#ifdef LINUXKM_LKCAPI_REGISTER_AESCCM
261 static int linuxkm_test_aesccm(void);
262#endif
263#ifdef LINUXKM_LKCAPI_REGISTER_AESCCM_RFC4309
264 static int linuxkm_test_aesccm_rfc4309(void);
265#endif
266#ifdef LINUXKM_LKCAPI_REGISTER_AESXTS
267 static int linuxkm_test_aesxts(void);
268#endif
269#ifdef LINUXKM_LKCAPI_REGISTER_AESCTR
270 static int linuxkm_test_aesctr(void);
271#endif
272#ifdef LINUXKM_LKCAPI_REGISTER_AESOFB
273 static int linuxkm_test_aesofb(void);
274#endif
275#ifdef LINUXKM_LKCAPI_REGISTER_AESECB
276 static int linuxkm_test_aesecb(void);
277#endif
278
279#if defined(LINUXKM_LKCAPI_REGISTER_AESCBC) || \
280 defined(LINUXKM_LKCAPI_REGISTER_AESCFB) || \
281 defined(LINUXKM_LKCAPI_REGISTER_AESCTR) || \
282 defined(LINUXKM_LKCAPI_REGISTER_AESOFB) || \
283 defined(LINUXKM_LKCAPI_REGISTER_AESECB) || \
284 defined(LINUXKM_LKCAPI_REGISTER_AESGCM) || \
285 defined(LINUXKM_LKCAPI_REGISTER_AESGCM_RFC4106) || \
286 defined(LINUXKM_LKCAPI_REGISTER_AESCCM) || \
287 defined(LINUXKM_LKCAPI_REGISTER_AESCCM_RFC4309)
288 #define LINUXKM_LKCAPI_NEED_AES_COMMON_FUNCS
289#endif
290
291#if defined(LINUXKM_LKCAPI_REGISTER_AESCBC) || \
292 defined(LINUXKM_LKCAPI_REGISTER_AESCFB) || \
293 defined(LINUXKM_LKCAPI_REGISTER_AESCTR) || \
294 defined(LINUXKM_LKCAPI_REGISTER_AESOFB) || \
295 defined(LINUXKM_LKCAPI_REGISTER_AESECB)
296 #define LINUXKM_LKCAPI_NEED_AES_SKCIPHER_COMMON_FUNCS
297#endif
298
299#if defined(LINUXKM_LKCAPI_REGISTER_AESGCM) || \
300 defined(LINUXKM_LKCAPI_REGISTER_AESGCM_RFC4106) || \
301 defined(LINUXKM_LKCAPI_REGISTER_AESCCM) || \
302 defined(LINUXKM_LKCAPI_REGISTER_AESCCM_RFC4309)
303 #define LINUXKM_LKCAPI_REGISTER_AEADS
304#endif
305
306/* km_AesX(): wrappers to wolfcrypt wc_AesX functions and
307 * structures. */
308
309struct km_AesCtx {
310 Aes *aes_encrypt; /* allocated in km_AesInitCommon() to assure
311 * alignment, needed for AESNI.
312 */
313 Aes *aes_decrypt; /* same. */
314#ifdef WC_LINUXKM_C_FALLBACK_IN_SHIMS
315 Aes *aes_encrypt_C; /* fallback if vector registers aren't available. */
316 Aes *aes_decrypt_C;
317#endif
318#if defined(LINUXKM_LKCAPI_REGISTER_AESGCM_RFC4106) || \
319 defined(LINUXKM_LKCAPI_REGISTER_AESCCM_RFC4309)
320 union {
321 byte rfc4106_nonce[4];
322 byte rfc4309_nonce[3];
323 };
324#endif
325};
326
327#ifdef LINUXKM_LKCAPI_NEED_AES_COMMON_FUNCS
328
329static void km_AesExitCommon(struct km_AesCtx * ctx);
330
331static int km_AesInitCommon(
332 struct km_AesCtx * ctx,
333 const char * name,
334 int need_decryption)
335{
336 int err;
337
338 ctx->aes_encrypt = (Aes *)malloc(sizeof(*ctx->aes_encrypt));
339
340 if (! ctx->aes_encrypt) {
341 pr_err("%s: allocation of %zu bytes for encryption key failed.\n",
342 name, sizeof(*ctx->aes_encrypt));
343 err = -ENOMEM;
344 goto out;
345 }
346
347 err = wc_AesInit(ctx->aes_encrypt, NULL, INVALID_DEVID);
348
349 if (unlikely(err)) {
350 pr_err("%s: wc_AesInit failed: %d\n", name, err);
351 free(ctx->aes_encrypt);
352 ctx->aes_encrypt = NULL;
353 err = -EINVAL;
354 goto out;
355 }
356
357 if (! need_decryption) {
358 ctx->aes_decrypt = NULL;
359 }
360 else {
361 ctx->aes_decrypt = (Aes *)malloc(sizeof(*ctx->aes_decrypt));
362
363 if (! ctx->aes_decrypt) {
364 pr_err("%s: allocation of %zu bytes for decryption key failed.\n",
365 name, sizeof(*ctx->aes_decrypt));
366 err = -ENOMEM;
367 goto out;
368 }
369
370 err = wc_AesInit(ctx->aes_decrypt, NULL, INVALID_DEVID);
371
372 if (unlikely(err)) {
373 pr_err("%s: wc_AesInit failed: %d\n", name, err);
374 free(ctx->aes_decrypt);
375 ctx->aes_decrypt = NULL;
376 err = -EINVAL;
377 goto out;
378 }
379 }
380
381#ifdef WC_LINUXKM_C_FALLBACK_IN_SHIMS
382
383 ctx->aes_encrypt_C = (Aes *)malloc(sizeof(*ctx->aes_encrypt_C));
384
385 if (! ctx->aes_encrypt_C) {
386 pr_err("%s: allocation of %zu bytes for encryption key failed.\n",
387 name, sizeof(*ctx->aes_encrypt_C));
388 err = -ENOMEM;
389 goto out;
390 }
391
392 err = wc_AesInit(ctx->aes_encrypt_C, NULL, INVALID_DEVID);
393
394 if (unlikely(err)) {
395 pr_err("%s: wc_AesInit failed: %d\n", name, err);
396 free(ctx->aes_encrypt_C);
397 ctx->aes_encrypt_C = NULL;
398 err = -EINVAL;
399 goto out;
400 }
401
402 if (! need_decryption) {
403 ctx->aes_decrypt_C = NULL;
404 }
405 else {
406 ctx->aes_decrypt_C = (Aes *)malloc(sizeof(*ctx->aes_decrypt_C));
407
408 if (! ctx->aes_decrypt_C) {
409 pr_err("%s: allocation of %zu bytes for decryption key failed.\n",
410 name, sizeof(*ctx->aes_decrypt_C));
411 err = -MEMORY_E;
412 goto out;
413 }
414
415 err = wc_AesInit(ctx->aes_decrypt_C, NULL, INVALID_DEVID);
416
417 if (unlikely(err)) {
418 pr_err("%s: wc_AesInit failed: %d\n", name, err);
419 free(ctx->aes_decrypt_C);
420 ctx->aes_decrypt_C = NULL;
421 err = -EINVAL;
422 goto out;
423 }
424 }
425
426#endif /* WC_LINUXKM_C_FALLBACK_IN_SHIMS */
427
428out:
429
430 if (err != 0)
431 km_AesExitCommon(ctx);
432
433 #ifdef WOLFKM_DEBUG_AES
434 pr_info("info: exiting km_AesInitCommon: %s: %d\n", name, err);
435 #endif /* WOLFKM_DEBUG_AES */
436
437 return err;
438}
439
440static int km_AesGet(struct km_AesCtx *ctx, int decrypt_p, int copy_p, Aes **aes) {
441 Aes *ret;
442
443#ifdef WC_LINUXKM_C_FALLBACK_IN_SHIMS
444 /* First, check if AESNI was disabled in the main SetKey for the requested
445 * direction. If so, use it (the fallback schedule won't even be inited).
446 */
447 if (((! decrypt_p) || (! ctx->aes_decrypt)) && (! ctx->aes_encrypt->use_aesni))
448 ret = ctx->aes_encrypt;
449 else if (decrypt_p && ctx->aes_decrypt && (! ctx->aes_decrypt->use_aesni))
450 ret = ctx->aes_decrypt;
451 else if (
452#ifdef TEST_WC_LINUXKM_C_FALLBACK_IN_SHIMS
453 1
454#else
455 ! CAN_SAVE_VECTOR_REGISTERS()
456#endif
457 )
458 {
459 if (decrypt_p && ctx->aes_decrypt_C)
460 ret = ctx->aes_decrypt_C;
461 else
462 ret = ctx->aes_encrypt_C;
463 if (ret->use_aesni)
464 return -EINVAL;
465 }
466 else
467#endif /* WC_LINUXKM_C_FALLBACK_IN_SHIMS */
468 {
469 if (decrypt_p && ctx->aes_decrypt)
470 ret = ctx->aes_decrypt;
471 else
472 ret = ctx->aes_encrypt;
473 }
474
475 if (copy_p) {
476 /* Copy the cipher state to mitigate races on Aes.reg, Aes.tmp, and dynamic Aes.use_aesni. */
477 Aes *aes_copy = (struct Aes *)malloc(sizeof(Aes));
478 if (aes_copy == NULL)
479 return -ENOMEM;
480 XMEMCPY(aes_copy, ret, sizeof(Aes));
481#if defined(WOLFSSL_AESGCM_STREAM) && defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_AESNI)
482 aes_copy->streamData = NULL;
483#endif
484 *aes = aes_copy;
485 }
486 else {
487 *aes = ret;
488 }
489
490 return 0;
491}
492
493static void km_AesFree(Aes **aes) {
494 if ((! aes) || (! *aes))
495 return;
496 wc_AesFree(*aes);
497#if defined(HAVE_FIPS) && FIPS_VERSION3_LT(6,0,0)
498 ForceZero(*aes, sizeof **aes);
499#endif
500 free(*aes);
501 *aes = NULL;
502}
503
504static void km_AesExitCommon(struct km_AesCtx * ctx)
505{
506 if (ctx->aes_encrypt) {
507 km_AesFree(&ctx->aes_encrypt);
508 }
509 if (ctx->aes_decrypt) {
510 km_AesFree(&ctx->aes_decrypt);
511 }
512
513#ifdef WC_LINUXKM_C_FALLBACK_IN_SHIMS
514 if (ctx->aes_encrypt_C) {
515 km_AesFree(&ctx->aes_encrypt_C);
516 }
517 if (ctx->aes_decrypt_C) {
518 km_AesFree(&ctx->aes_decrypt_C);
519 }
520#endif
521
522 #ifdef WOLFKM_DEBUG_AES
523 pr_info("info: exiting km_AesExitCommon\n");
524 #endif /* WOLFKM_DEBUG_AES */
525}
526
527#ifdef LINUXKM_LKCAPI_NEED_AES_SKCIPHER_COMMON_FUNCS
528
529static int km_AesSetKeyCommon(struct km_AesCtx * ctx, const u8 *in_key,
530 unsigned int key_len, const char * name)
531{
532 int err;
533
534 err = wc_AesSetKey(ctx->aes_encrypt, in_key, key_len, NULL, AES_ENCRYPTION);
535
536 if (unlikely(err)) {
537 if ((! disable_setkey_warnings) && ((key_len == 16) || (key_len == 24) || (key_len == 32)))
538 pr_err("%s: wc_AesSetKey for encryption key (len %u) failed: %d\n", name, key_len, err);
539 return -EINVAL;
540 }
541
542 if (ctx->aes_decrypt) {
543 err = wc_AesSetKey(ctx->aes_decrypt, in_key, key_len, NULL,
544 AES_DECRYPTION);
545
546 if (unlikely(err)) {
547 if ((! disable_setkey_warnings) && ((key_len == 16) || (key_len == 24) || (key_len == 32)))
548 pr_err("%s: wc_AesSetKey for decryption key (len %u) failed: %d\n",
549 name, key_len, err);
550 return -EINVAL;
551 }
552 }
553
554#ifdef WC_LINUXKM_C_FALLBACK_IN_SHIMS
555
556 if (ctx->aes_encrypt->use_aesni) {
557 ctx->aes_encrypt_C->use_aesni = WC_FLAG_DONT_USE_VECTOR_OPS;
558
559 err = wc_AesSetKey(ctx->aes_encrypt_C, in_key, key_len, NULL, AES_ENCRYPTION);
560
561 if (unlikely(err)) {
562 if ((! disable_setkey_warnings) && ((key_len == 16) || (key_len == 24) || (key_len == 32)))
563 pr_err("%s: wc_AesSetKey for encryption key failed: %d\n", name, err);
564 return -EINVAL;
565 }
566
567 if (ctx->aes_encrypt_C->use_aesni)
568 pr_err("%s: after wc_AesSetKey, ctx->aes_encrypt_C has AES-NI asserted.\n", name);
569
570 }
571
572 if (ctx->aes_decrypt_C && ctx->aes_decrypt->use_aesni) {
573 ctx->aes_decrypt_C->use_aesni = WC_FLAG_DONT_USE_VECTOR_OPS;
574
575 err = wc_AesSetKey(ctx->aes_decrypt_C, in_key, key_len, NULL,
576 AES_DECRYPTION);
577
578 if (unlikely(err)) {
579 if ((! disable_setkey_warnings) && ((key_len == 16) || (key_len == 24) || (key_len == 32)))
580 pr_err("%s: wc_AesSetKey for decryption key failed: %d\n",
581 name, err);
582 return -EINVAL;
583 }
584
585 if (ctx->aes_decrypt_C->use_aesni)
586 pr_err("%s: after wc_AesSetKey, ctx->aes_decrypt_C has AES-NI asserted.\n", name);
587 }
588
589#endif /* WC_LINUXKM_C_FALLBACK_IN_SHIMS */
590
591 #ifdef WOLFKM_DEBUG_AES
592 pr_info("info: exiting km_AesSetKeyCommon: %s: %d\n", name, key_len);
593 #endif /* WOLFKM_DEBUG_AES */
594 return 0;
595}
596
597static void km_AesExit(struct crypto_skcipher *tfm)
598{
599 struct km_AesCtx * ctx = crypto_skcipher_ctx(tfm);
600 km_AesExitCommon(ctx);
601}
602
603#endif /* LINUXKM_LKCAPI_NEED_AES_SKCIPHER_COMMON_FUNCS */
604
605#endif /* LINUXKM_LKCAPI_NEED_AES_COMMON_FUNCS */
606
607#ifdef LINUXKM_LKCAPI_REGISTER_AESCBC
608
609static int km_AesCbcInit(struct crypto_skcipher *tfm)
610{
611 struct km_AesCtx * ctx = crypto_skcipher_ctx(tfm);
612 return km_AesInitCommon(ctx, WOLFKM_AESCBC_DRIVER, 1);
613}
614
615static int km_AesCbcSetKey(struct crypto_skcipher *tfm, const u8 *in_key,
616 unsigned int key_len)
617{
618 struct km_AesCtx * ctx = crypto_skcipher_ctx(tfm);
619 return km_AesSetKeyCommon(ctx, in_key, key_len, WOLFKM_AESCBC_DRIVER);
620}
621
622static int km_AesCbcEncrypt(struct skcipher_request *req)
623{
624 struct crypto_skcipher * tfm = NULL;
625 struct km_AesCtx * ctx = NULL;
626 struct skcipher_walk walk;
627 unsigned int nbytes = 0;
628 int err;
629 Aes *aes_copy = NULL;
630
631 tfm = crypto_skcipher_reqtfm(req);
632 ctx = crypto_skcipher_ctx(tfm);
633
634 err = skcipher_walk_virt(&walk, req, false);
635 if (unlikely(err)) {
636 return err;
637 }
638
639 err = km_AesGet(ctx, 0 /* decrypt_p */, 1 /* copy_p */, &aes_copy);
640 if (unlikely(err)) {
641 goto out;
642 }
643
644 err = wc_AesSetIV(aes_copy, walk.iv);
645
646 if (unlikely(err)) {
647 pr_err("%s: wc_AesSetIV failed: %d\n",
648 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
649 err = -EINVAL;
650 goto out;
651 }
652
653 while ((nbytes = walk.nbytes) != 0) {
654 err = wc_AesCbcEncrypt(aes_copy, walk.dst.virt.addr,
655 walk.src.virt.addr, nbytes & (~(WC_AES_BLOCK_SIZE - 1)));
656
657 if (unlikely(err)) {
658 pr_err("%s: wc_AesCbcEncrypt failed for %u bytes: %d\n",
659 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), nbytes, err);
660 err = -EINVAL;
661 goto out;
662 }
663
664 nbytes &= WC_AES_BLOCK_SIZE - 1;
665 err = skcipher_walk_done(&walk, nbytes);
666 }
667
668 /* copy iv from wolfCrypt back to walk.iv */
669 XMEMCPY(walk.iv, aes_copy->reg, WC_AES_BLOCK_SIZE);
670
671out:
672
673 if (err && walk.nbytes)
674 (void)skcipher_walk_done(&walk, err);
675
676 km_AesFree(&aes_copy);
677
678 #ifdef WOLFKM_DEBUG_AES
679 pr_info("info: exiting km_AesCbcEncrypt: err %d, cryptlen %d\n", err,
680 req->cryptlen);
681 #endif /* WOLFKM_DEBUG_AES */
682
683 return err;
684}
685
686static int km_AesCbcDecrypt(struct skcipher_request *req)
687{
688 struct crypto_skcipher * tfm = NULL;
689 struct km_AesCtx * ctx = NULL;
690 struct skcipher_walk walk;
691 unsigned int nbytes = 0;
692 int err;
693 Aes *aes_copy = NULL;
694
695 tfm = crypto_skcipher_reqtfm(req);
696 ctx = crypto_skcipher_ctx(tfm);
697
698 err = skcipher_walk_virt(&walk, req, false);
699
700 if (unlikely(err)) {
701 return err;
702 }
703
704 err = km_AesGet(ctx, 1 /* decrypt_p */, 1 /* copy_p */, &aes_copy);
705 if (unlikely(err)) {
706 goto out;
707 }
708
709 err = wc_AesSetIV(aes_copy, walk.iv);
710
711 if (unlikely(err)) {
712 if (! disable_setkey_warnings)
713 pr_err("%s: wc_AesSetIV failed: %d\n",
714 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
715 err = -EINVAL;
716 goto out;
717 }
718
719 while ((nbytes = walk.nbytes) != 0) {
720 err = wc_AesCbcDecrypt(aes_copy, walk.dst.virt.addr,
721 walk.src.virt.addr, nbytes & (~(WC_AES_BLOCK_SIZE - 1)));
722
723 if (unlikely(err)) {
724 pr_err("%s: wc_AesCbcDecrypt failed for %u bytes: %d\n",
725 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), nbytes, err);
726 err = -EINVAL;
727 goto out;
728 }
729
730 nbytes &= WC_AES_BLOCK_SIZE - 1;
731 err = skcipher_walk_done(&walk, nbytes);
732 }
733
734 /* copy iv from wolfCrypt back to walk.iv */
735 XMEMCPY(walk.iv, aes_copy->reg, WC_AES_BLOCK_SIZE);
736
737out:
738
739 if (err && walk.nbytes)
740 (void)skcipher_walk_done(&walk, err);
741
742 km_AesFree(&aes_copy);
743
744 #ifdef WOLFKM_DEBUG_AES
745 pr_info("info: exiting km_AesCbcDecrypt: err %d, cryptlen %d\n", err,
746 req->cryptlen);
747 #endif /* WOLFKM_DEBUG_AES */
748
749 return err;
750}
751
752static struct skcipher_alg cbcAesAlg = {
753 .base.cra_name = WOLFKM_AESCBC_NAME,
754 .base.cra_driver_name = WOLFKM_AESCBC_DRIVER,
755 .base.cra_priority = WOLFSSL_LINUXKM_LKCAPI_PRIORITY,
756 .base.cra_blocksize = WC_AES_BLOCK_SIZE,
757 .base.cra_ctxsize = sizeof(struct km_AesCtx),
758 .base.cra_module = THIS_MODULE,
759 .init = km_AesCbcInit,
760 .exit = km_AesExit,
761 .min_keysize = AES_128_KEY_SIZE,
762 .max_keysize = AES_256_KEY_SIZE,
763 .ivsize = WC_AES_BLOCK_SIZE,
764 .setkey = km_AesCbcSetKey,
765 .encrypt = km_AesCbcEncrypt,
766 .decrypt = km_AesCbcDecrypt,
767};
768static int cbcAesAlg_loaded = 0;
769
770#endif /* LINUXKM_LKCAPI_REGISTER_AESCBC */
771
772#ifdef LINUXKM_LKCAPI_REGISTER_AESCFB
773
774static int km_AesCfbInit(struct crypto_skcipher *tfm)
775{
776 struct km_AesCtx * ctx = crypto_skcipher_ctx(tfm);
777 return km_AesInitCommon(ctx, WOLFKM_AESCFB_DRIVER, 0);
778}
779
780static int km_AesCfbSetKey(struct crypto_skcipher *tfm, const u8 *in_key,
781 unsigned int key_len)
782{
783 struct km_AesCtx * ctx = crypto_skcipher_ctx(tfm);
784 return km_AesSetKeyCommon(ctx, in_key, key_len, WOLFKM_AESCFB_DRIVER);
785}
786
787static int km_AesCfbEncrypt(struct skcipher_request *req)
788{
789 struct crypto_skcipher * tfm = NULL;
790 struct km_AesCtx * ctx = NULL;
791 struct skcipher_walk walk;
792 int err;
793 Aes *aes_copy = NULL;
794
795 tfm = crypto_skcipher_reqtfm(req);
796 ctx = crypto_skcipher_ctx(tfm);
797
798 err = skcipher_walk_virt(&walk, req, false);
799
800 if (unlikely(err)) {
801 pr_err("%s: skcipher_walk_virt failed: %d\n",
802 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
803 return err;
804 }
805
806 err = km_AesGet(ctx, 0 /* decrypt_p */, 1 /* copy_p */, &aes_copy);
807 if (unlikely(err)) {
808 goto out;
809 }
810
811 err = wc_AesSetIV(aes_copy, walk.iv);
812
813 if (unlikely(err)) {
814 pr_err("%s: wc_AesSetIV failed: %d\n",
815 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
816 err = -EINVAL;
817 goto out;
818 }
819
820 while (walk.nbytes != 0) {
821 err = wc_AesCfbEncrypt(aes_copy, walk.dst.virt.addr,
822 walk.src.virt.addr, walk.nbytes);
823
824 if (unlikely(err)) {
825 pr_err("%s: wc_AesCfbEncrypt failed %d\n",
826 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
827 err = -EINVAL;
828 goto out;
829 }
830
831 err = skcipher_walk_done(&walk, 0);
832
833 if (unlikely(err)) {
834 pr_err("%s: skcipher_walk_done failed: %d\n",
835 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
836 goto out;
837 }
838 }
839
840 /* copy iv from wolfCrypt back to walk.iv */
841 XMEMCPY(walk.iv, aes_copy->reg, WC_AES_BLOCK_SIZE);
842
843out:
844
845 if (err && walk.nbytes)
846 (void)skcipher_walk_done(&walk, err);
847
848 km_AesFree(&aes_copy);
849
850 #ifdef WOLFKM_DEBUG_AES
851 pr_info("info: exiting km_AesCfbEncrypt: err %d, cryptlen %d\n", err,
852 req->cryptlen);
853 #endif /* WOLFKM_DEBUG_AES */
854
855 return err;
856}
857
858static int km_AesCfbDecrypt(struct skcipher_request *req)
859{
860 struct crypto_skcipher * tfm = NULL;
861 struct km_AesCtx * ctx = NULL;
862 struct skcipher_walk walk;
863 int err;
864 Aes *aes_copy = NULL;
865
866 tfm = crypto_skcipher_reqtfm(req);
867 ctx = crypto_skcipher_ctx(tfm);
868
869 err = skcipher_walk_virt(&walk, req, false);
870
871 if (unlikely(err)) {
872 pr_err("%s: skcipher_walk_virt failed: %d\n",
873 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
874 return err;
875 }
876
877 err = km_AesGet(ctx, 1 /* decrypt_p */, 1 /* copy_p */, &aes_copy);
878 if (unlikely(err)) {
879 goto out;
880 }
881
882 err = wc_AesSetIV(aes_copy, walk.iv);
883
884 if (unlikely(err)) {
885 if (! disable_setkey_warnings)
886 pr_err("%s: wc_AesSetIV failed: %d\n",
887 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
888 err = -EINVAL;
889 goto out;
890 }
891
892 while (walk.nbytes != 0) {
893 err = wc_AesCfbDecrypt(aes_copy, walk.dst.virt.addr,
894 walk.src.virt.addr, walk.nbytes);
895
896 if (unlikely(err)) {
897 pr_err("%s: wc_AesCfbDecrypt failed: %d\n",
898 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
899 err = -EINVAL;
900 goto out;
901 }
902
903 err = skcipher_walk_done(&walk, 0);
904
905 if (unlikely(err)) {
906 pr_err("%s: skcipher_walk_done failed: %d\n",
907 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
908 goto out;
909 }
910 }
911
912 /* copy iv from wolfCrypt back to walk.iv */
913 XMEMCPY(walk.iv, aes_copy->reg, WC_AES_BLOCK_SIZE);
914
915out:
916
917 if (err && walk.nbytes)
918 (void)skcipher_walk_done(&walk, err);
919
920 km_AesFree(&aes_copy);
921
922 #ifdef WOLFKM_DEBUG_AES
923 pr_info("info: exiting km_AesCfbDecrypt: err %d, cryptlen %d\n", err,
924 req->cryptlen);
925 #endif /* WOLFKM_DEBUG_AES */
926
927 return err;
928}
929
930static struct skcipher_alg cfbAesAlg = {
931 .base.cra_name = WOLFKM_AESCFB_NAME,
932 .base.cra_driver_name = WOLFKM_AESCFB_DRIVER,
933 .base.cra_priority = WOLFSSL_LINUXKM_LKCAPI_PRIORITY,
934 .base.cra_blocksize = 1,
935 .base.cra_ctxsize = sizeof(struct km_AesCtx),
936 .base.cra_module = THIS_MODULE,
937 .init = km_AesCfbInit,
938 .exit = km_AesExit,
939 .min_keysize = AES_128_KEY_SIZE,
940 .max_keysize = AES_256_KEY_SIZE,
941 .ivsize = WC_AES_BLOCK_SIZE,
942 .setkey = km_AesCfbSetKey,
943 .encrypt = km_AesCfbEncrypt,
944 .decrypt = km_AesCfbDecrypt,
945};
946static int cfbAesAlg_loaded = 0;
947
948#endif /* LINUXKM_LKCAPI_REGISTER_AESCBC */
949
950#if defined(LINUXKM_LKCAPI_REGISTER_AESGCM) || \
951 defined(LINUXKM_LKCAPI_REGISTER_AESGCM_RFC4106)
952
953static int km_AesGcmInit(struct crypto_aead * tfm)
954{
955 struct km_AesCtx * ctx = crypto_aead_ctx(tfm);
956 return km_AesInitCommon(ctx, WOLFKM_AESGCM_DRIVER, 0);
957}
958
959static void km_AesGcmExit(struct crypto_aead * tfm)
960{
961 struct km_AesCtx * ctx = crypto_aead_ctx(tfm);
962 km_AesExitCommon(ctx);
963}
964
965#ifdef LINUXKM_LKCAPI_REGISTER_AESGCM
966
967static int km_AesGcmSetKey(struct crypto_aead *tfm, const u8 *in_key,
968 unsigned int key_len)
969{
970 int err;
971 struct km_AesCtx * ctx = crypto_aead_ctx(tfm);
972
973 err = wc_AesGcmSetKey(ctx->aes_encrypt, in_key, key_len);
974
975 if (unlikely(err)) {
976 if ((! disable_setkey_warnings) && ((key_len == 16) || (key_len == 24) || (key_len == 32)))
977 pr_err("%s: wc_AesGcmSetKey failed: %d\n",
978 crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)), err);
979 return -EINVAL;
980 }
981
982#ifdef WC_LINUXKM_C_FALLBACK_IN_SHIMS
983 if (ctx->aes_encrypt->use_aesni) {
984 ctx->aes_encrypt_C->use_aesni = WC_FLAG_DONT_USE_VECTOR_OPS;
985
986 err = wc_AesGcmSetKey(ctx->aes_encrypt_C, in_key, key_len);
987
988 if (unlikely(err)) {
989 if ((! disable_setkey_warnings) && ((key_len == 16) || (key_len == 24) || (key_len == 32)))
990 pr_err("%s: wc_AesGcmSetKey failed: %d\n",
991 crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)), err);
992 return -EINVAL;
993 }
994
995 if (ctx->aes_encrypt_C->use_aesni)
996 pr_err("%s: after wc_AesGcmSetKey, ctx->aes_encrypt_C has AES-NI asserted.\n", WOLFKM_AESGCM_DRIVER);
997 }
998#endif
999
1000 #ifdef WOLFKM_DEBUG_AES
1001 pr_info("info: exiting km_AesGcmSetKey: %d\n", key_len);
1002 #endif /* WOLFKM_DEBUG_AES */
1003 return 0;
1004}
1005
1006#endif /* LINUXKM_LKCAPI_REGISTER_AESGCM */
1007
1008#ifdef LINUXKM_LKCAPI_REGISTER_AESGCM_RFC4106
1009
1010static int km_AesGcmSetKey_Rfc4106(struct crypto_aead *tfm, const u8 *in_key,
1011 unsigned int key_len)
1012{
1013 int err;
1014 struct km_AesCtx * ctx = crypto_aead_ctx(tfm);
1015
1016 if (key_len < 4)
1017 return -EINVAL;
1018 key_len -= 4;
1019 memcpy(ctx->rfc4106_nonce, in_key + key_len, 4);
1020
1021 err = wc_AesGcmSetKey(ctx->aes_encrypt, in_key, key_len);
1022
1023 if (unlikely(err)) {
1024 if ((! disable_setkey_warnings) && ((key_len == 16) || (key_len == 24) || (key_len == 32)))
1025 pr_err("%s: wc_AesGcmSetKey failed: %d\n",
1026 crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)), err);
1027 return -EINVAL;
1028 }
1029
1030#ifdef WC_LINUXKM_C_FALLBACK_IN_SHIMS
1031 if (ctx->aes_encrypt->use_aesni) {
1032 ctx->aes_encrypt_C->use_aesni = WC_FLAG_DONT_USE_VECTOR_OPS;
1033
1034 err = wc_AesGcmSetKey(ctx->aes_encrypt_C, in_key, key_len);
1035
1036 if (unlikely(err)) {
1037 if ((! disable_setkey_warnings) && ((key_len == 16) || (key_len == 24) || (key_len == 32)))
1038 pr_err("%s: wc_AesGcmSetKey failed: %d\n",
1039 crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)), err);
1040 return -EINVAL;
1041 }
1042
1043 if (ctx->aes_encrypt_C->use_aesni)
1044 pr_err("%s: after wc_AesGcmSetKey, ctx->aes_encrypt_C has AES-NI asserted.\n", WOLFKM_AESGCM_DRIVER);
1045 }
1046#endif
1047
1048 #ifdef WOLFKM_DEBUG_AES
1049 pr_info("info: exiting km_AesGcmSetKey_Rfc4106: %d\n", key_len);
1050 #endif /* WOLFKM_DEBUG_AES */
1051 return 0;
1052}
1053
1054#endif /* LINUXKM_LKCAPI_REGISTER_AESGCM_RFC4106 */
1055
1056#ifdef LINUXKM_LKCAPI_REGISTER_AESGCM
1057
1058static int km_AesGcmSetAuthsize(struct crypto_aead *tfm, unsigned int authsize)
1059{
1060 (void)tfm;
1061
1062 switch (authsize) {
1063 case 4:
1064 case 8:
1065 case 12:
1066 case 13:
1067 case 14:
1068 case 15:
1069 case 16:
1070 return 0;
1071 }
1072
1073#ifdef WOLFSSL_LINUXKM_VERBOSE_LKCAPI_DEBUG
1074 pr_err("%s: invalid authsize: %d\n",
1075 crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)), authsize);
1076#endif
1077 return -EINVAL;
1078}
1079
1080#endif /* LINUXKM_LKCAPI_REGISTER_AESGCM */
1081
1082#ifdef LINUXKM_LKCAPI_REGISTER_AESGCM_RFC4106
1083
1084static int km_AesGcmSetAuthsize_Rfc4106(struct crypto_aead *tfm, unsigned int authsize)
1085{
1086 (void)tfm;
1087
1088 switch (authsize) {
1089 case 8:
1090 case 12:
1091 case 16:
1092 return 0;
1093 }
1094
1095#ifdef WOLFSSL_LINUXKM_VERBOSE_LKCAPI_DEBUG
1096 pr_err("%s: invalid authsize: %d\n",
1097 crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)), authsize);
1098#endif
1099 return -EINVAL;
1100}
1101
1102#endif /* LINUXKM_LKCAPI_REGISTER_AESGCM_RFC4106 */
1103
1104/*
1105 * aead ciphers receive data in scatterlists in following order:
1106 * encrypt
1107 * req->src: aad||plaintext
1108 * req->dst: aad||ciphertext||tag
1109 * decrypt
1110 * req->src: aad||ciphertext||tag
1111 * req->dst: aad||plaintext, return 0 or -EBADMSG
1112 */
1113
1114#ifdef WOLFSSL_AESGCM_STREAM
1115
1116static int AesGcmCrypt_1(struct aead_request *req, int decrypt_p, int rfc4106_p)
1117{
1118 struct crypto_aead * tfm = NULL;
1119 struct km_AesCtx * ctx = NULL;
1120 struct skcipher_walk walk;
1121 struct scatter_walk assocSgWalk;
1122 u8 authTag[WC_AES_BLOCK_SIZE];
1123 int err;
1124 unsigned int assoclen = req->assoclen;
1125 u8 * assoc = NULL;
1126 u8 * assocmem = NULL;
1127 Aes *aes_copy = NULL;
1128
1129 tfm = crypto_aead_reqtfm(req);
1130 ctx = crypto_aead_ctx(tfm);
1131
1132 if (decrypt_p) {
1133 /* Copy out original auth tag from req->src. */
1134 scatterwalk_map_and_copy(authTag, req->src,
1135 req->assoclen + req->cryptlen - tfm->authsize,
1136 tfm->authsize, 0);
1137 err = skcipher_walk_aead_decrypt(&walk, req, false);
1138 }
1139 else {
1140 err = skcipher_walk_aead_encrypt(&walk, req, false);
1141 }
1142
1143 if (unlikely(err)) {
1144 pr_err("%s: %s failed: %d\n",
1145 crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)),
1146 decrypt_p ? "skcipher_walk_aead_decrypt" : "skcipher_walk_aead_encrypt",
1147 err);
1148 return err;
1149 }
1150
1151 err = km_AesGet(ctx, decrypt_p, 1 /* copy_p */, &aes_copy);
1152 if (unlikely(err)) {
1153 goto out;
1154 }
1155
1156#ifdef LINUXKM_LKCAPI_REGISTER_AESGCM_RFC4106
1157 if (rfc4106_p) {
1158 byte rfc4106_iv[12];
1159
1160 if (unlikely(assoclen != 16 && assoclen != 20)) {
1161 err = -EINVAL;
1162 goto out;
1163 }
1164 assoclen -= 8;
1165
1166 memcpy(rfc4106_iv, ctx->rfc4106_nonce, 4);
1167 memcpy(rfc4106_iv + 4, walk.iv, 8);
1168 err = wc_AesGcmInit(aes_copy, NULL /*key*/, 0 /*keylen*/, rfc4106_iv,
1169 GCM_NONCE_MID_SZ);
1170 }
1171 else
1172#else
1173 (void)rfc4106_p;
1174#endif /* LINUXKM_LKCAPI_REGISTER_AESGCM_RFC4106 */
1175 {
1176 err = wc_AesGcmInit(aes_copy, NULL /*key*/, 0 /*keylen*/, walk.iv,
1177 GCM_NONCE_MID_SZ);
1178 }
1179 if (unlikely(err)) {
1180 pr_err("%s: wc_AesGcmInit failed: %d\n",
1181 crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)), err);
1182 err = -EINVAL;
1183 goto out;
1184 }
1185
1186 if (req->src->length >= assoclen && req->src->length) {
1187 scatterwalk_start(&assocSgWalk, req->src);
1188#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 15, 0)
1189 scatterwalk_map(&assocSgWalk);
1190 assoc = assocSgWalk.addr;
1191#else
1192 assoc = scatterwalk_map(&assocSgWalk);
1193#endif
1194 if (unlikely(IS_ERR(assoc))) {
1195 err = (int)PTR_ERR(assoc);
1196 pr_err("%s: scatterwalk_map failed: %ld\n",
1197 crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)),
1198 PTR_ERR(assoc));
1199 assoc = NULL;
1200 goto out;
1201 }
1202 }
1203 else {
1204 /* assoc can be any length, so if it's noncontiguous, we have to copy it
1205 * to a contiguous heap allocation.
1206 */
1207 assocmem = malloc(assoclen);
1208 if (unlikely(assocmem == NULL)) {
1209 err = -ENOMEM;
1210 goto out;
1211 }
1212 assoc = assocmem;
1213 scatterwalk_map_and_copy(assoc, req->src, 0, assoclen, 0);
1214 }
1215
1216 if (decrypt_p) {
1217 err = wc_AesGcmDecryptUpdate(aes_copy, NULL, NULL, 0,
1218 assoc, assoclen);
1219 }
1220 else {
1221 err = wc_AesGcmEncryptUpdate(aes_copy, NULL, NULL, 0,
1222 assoc, assoclen);
1223 }
1224
1225 if (assocmem)
1226 free(assocmem);
1227 else {
1228#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 15, 0)
1229 scatterwalk_unmap(&assocSgWalk);
1230#else
1231 scatterwalk_unmap(assoc);
1232#endif
1233 }
1234
1235 if (unlikely(err)) {
1236 pr_err("%s: %s failed: %d\n",
1237 crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)),
1238 decrypt_p ? "wc_AesGcmDecryptUpdate" : "wc_AesGcmEncryptUpdate",
1239 err);
1240 err = -EINVAL;
1241 goto out;
1242 }
1243
1244 while (walk.nbytes) {
1245 if (decrypt_p) {
1246 err = wc_AesGcmDecryptUpdate(
1247 aes_copy,
1248 walk.dst.virt.addr,
1249 walk.src.virt.addr,
1250 walk.nbytes,
1251 NULL, 0);
1252 }
1253 else {
1254 err = wc_AesGcmEncryptUpdate(
1255 aes_copy,
1256 walk.dst.virt.addr,
1257 walk.src.virt.addr,
1258 walk.nbytes,
1259 NULL, 0);
1260 }
1261
1262 if (unlikely(err)) {
1263 pr_err("%s: %s failed: %d\n",
1264 crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)),
1265 decrypt_p ? "wc_AesGcmDecryptUpdate" : "wc_AesGcmEncryptUpdate",
1266 err);
1267 err = -EINVAL;
1268 goto out;
1269 }
1270
1271 err = skcipher_walk_done(&walk, 0);
1272
1273 if (unlikely(err)) {
1274 pr_err("%s: skcipher_walk_done failed: %d\n",
1275 crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)), err);
1276 goto out;
1277 }
1278 }
1279
1280 if (decrypt_p) {
1281 err = wc_AesGcmDecryptFinal(aes_copy, authTag, tfm->authsize);
1282 if (unlikely(err)) {
1283#ifdef WOLFSSL_LINUXKM_VERBOSE_LKCAPI_DEBUG
1284 pr_err("%s: wc_AesGcmDecryptFinal failed with return code %d\n",
1285 crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)), err);
1286#endif
1287 if (err == WC_NO_ERR_TRACE(AES_GCM_AUTH_E)) {
1288 err = -EBADMSG;
1289 goto out;
1290 }
1291 else {
1292 err = -EINVAL;
1293 goto out;
1294 }
1295 }
1296 }
1297 else {
1298 err = wc_AesGcmEncryptFinal(aes_copy, authTag, tfm->authsize);
1299 if (unlikely(err)) {
1300 pr_err("%s: wc_AesGcmEncryptFinal failed with return code %d\n",
1301 crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)), err);
1302 err = -EINVAL;
1303 goto out;
1304 }
1305 /* Now copy the auth tag into request scatterlist. */
1306 scatterwalk_map_and_copy(authTag, req->dst,
1307 req->assoclen + req->cryptlen,
1308 tfm->authsize, 1);
1309 }
1310
1311out:
1312
1313 if (err && walk.nbytes)
1314 (void)skcipher_walk_done(&walk, err);
1315
1316 km_AesFree(&aes_copy);
1317
1318 #ifdef WOLFKM_DEBUG_AES
1319 pr_info("info: exiting AesGcmCrypt_1: err %d, dec %d, cryptlen %d, "
1320 "assoclen %d\n", err, decrypt_p,
1321 req->cryptlen, req->assoclen);
1322 #endif /* WOLFKM_DEBUG_AES */
1323
1324 return err;
1325}
1326
1327#else /* !WOLFSSL_AESGCM_STREAM */
1328
1329static int AesGcmCrypt_1(struct aead_request *req, int decrypt_p, int rfc4106_p)
1330{
1331 struct crypto_aead * tfm = NULL;
1332 struct km_AesCtx * ctx = NULL;
1333 struct skcipher_walk sk_walk;
1334 struct scatter_walk in_walk, out_walk;
1335 u8 *in_map = NULL, *out_map = NULL;
1336 u8 authTag[WC_AES_BLOCK_SIZE];
1337 int err;
1338 unsigned int assoclen = req->assoclen;
1339 u8 * assoc = NULL;
1340 u8 * sg_buf = NULL;
1341 Aes *aes_copy = NULL;
1342 u8 * in_text = NULL;
1343 u8 * out_text = NULL;
1344#ifdef LINUXKM_LKCAPI_REGISTER_AESGCM_RFC4106
1345 byte rfc4106_iv[12];
1346#endif
1347
1348 tfm = crypto_aead_reqtfm(req);
1349 ctx = crypto_aead_ctx(tfm);
1350
1351 if (decrypt_p) {
1352 /* Copy out original auth tag from req->src. */
1353 scatterwalk_map_and_copy(authTag, req->src,
1354 req->assoclen + req->cryptlen - tfm->authsize,
1355 tfm->authsize, 0);
1356 err = skcipher_walk_aead_decrypt(&sk_walk, req, false);
1357 }
1358 else {
1359 err = skcipher_walk_aead_encrypt(&sk_walk, req, false);
1360 }
1361
1362 if (unlikely(err)) {
1363 pr_err("%s: %s failed: %d\n",
1364 crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)),
1365 decrypt_p ? "skcipher_walk_aead_decrypt" : "skcipher_walk_aead_encrypt",
1366 err);
1367 return -EINVAL;
1368 }
1369
1370 err = km_AesGet(ctx, decrypt_p, 1 /* copy_p */, &aes_copy);
1371 if (unlikely(err)) {
1372 goto out;
1373 }
1374
1375#ifdef LINUXKM_LKCAPI_REGISTER_AESGCM_RFC4106
1376 if (rfc4106_p) {
1377 if (unlikely(assoclen != 16 && assoclen != 20)) {
1378 err = -EINVAL;
1379 goto out;
1380 }
1381 assoclen -= 8;
1382
1383 memcpy(rfc4106_iv, ctx->rfc4106_nonce, 4);
1384 memcpy(rfc4106_iv + 4, sk_walk.iv, 8);
1385 }
1386#else
1387 (void)rfc4106_p;
1388#endif /* LINUXKM_LKCAPI_REGISTER_AESGCM_RFC4106 */
1389
1390 if ((req->src->length >= req->assoclen + req->cryptlen) &&
1391 (req->dst->length >= req->assoclen + req->cryptlen))
1392 {
1393 scatterwalk_start(&in_walk, req->src);
1394#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 15, 0)
1395 scatterwalk_map(&in_walk);
1396 in_map = in_walk.addr;
1397#else
1398 in_map = scatterwalk_map(&in_walk);
1399#endif
1400 if (unlikely(IS_ERR(in_map))) {
1401 err = (int)PTR_ERR(in_map);
1402 pr_err("%s: scatterwalk_map failed: %ld\n",
1403 crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)),
1404 PTR_ERR(in_map));
1405 in_map = NULL;
1406 goto out;
1407 }
1408 assoc = in_map;
1409 in_text = in_map + req->assoclen;
1410
1411 scatterwalk_start(&out_walk, req->dst);
1412#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 15, 0)
1413 scatterwalk_map(&out_walk);
1414 out_map = out_walk.addr;
1415#else
1416 out_map = scatterwalk_map(&out_walk);
1417#endif
1418 if (unlikely(IS_ERR(out_map))) {
1419 err = (int)PTR_ERR(out_map);
1420 pr_err("%s: scatterwalk_map failed: %ld\n",
1421 crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)),
1422 PTR_ERR(out_map));
1423 out_map = NULL;
1424 goto out;
1425 }
1426 out_text = out_map + req->assoclen;
1427 }
1428 else {
1429 sg_buf = malloc(req->assoclen + req->cryptlen);
1430 if (unlikely(sg_buf == NULL)) {
1431 err = -ENOMEM;
1432 goto out;
1433 }
1434 if (decrypt_p)
1435 scatterwalk_map_and_copy(sg_buf, req->src, 0, req->assoclen + req->cryptlen - tfm->authsize, 0);
1436 else
1437 scatterwalk_map_and_copy(sg_buf, req->src, 0, req->assoclen + req->cryptlen, 0);
1438 assoc = sg_buf;
1439 in_text = out_text = sg_buf + req->assoclen;
1440 }
1441
1442 if (decrypt_p) {
1443 err = wc_AesGcmDecrypt(aes_copy, out_text, in_text, req->cryptlen - tfm->authsize,
1444#ifdef LINUXKM_LKCAPI_REGISTER_AESGCM_RFC4106
1445 rfc4106_p ? rfc4106_iv :
1446#endif
1447 sk_walk.iv, GCM_NONCE_MID_SZ,
1448 authTag, tfm->authsize,
1449 assoc, assoclen);
1450
1451 if (unlikely(err)) {
1452#ifdef WOLFSSL_LINUXKM_VERBOSE_LKCAPI_DEBUG
1453 pr_err("%s: wc_AesGcmDecrypt failed with return code %d\n",
1454 crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)), err);
1455#endif
1456
1457 if (err == WC_NO_ERR_TRACE(AES_GCM_AUTH_E)) {
1458 err = -EBADMSG;
1459 goto out;
1460 }
1461 else {
1462 err = -EINVAL;
1463 goto out;
1464 }
1465 }
1466 }
1467 else {
1468 err = wc_AesGcmEncrypt(aes_copy, out_text, in_text, req->cryptlen,
1469#ifdef LINUXKM_LKCAPI_REGISTER_AESGCM_RFC4106
1470 rfc4106_p ? rfc4106_iv :
1471#endif
1472 sk_walk.iv, GCM_NONCE_MID_SZ,
1473 authTag, tfm->authsize,
1474 assoc, assoclen);
1475
1476 if (unlikely(err)) {
1477 pr_err("%s: wc_AesGcmEncrypt failed: %d\n",
1478 crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)), err);
1479 err = -EINVAL;
1480 goto out;
1481 }
1482
1483 }
1484
1485 if (sg_buf) {
1486 if (decrypt_p)
1487 scatterwalk_map_and_copy(sg_buf, req->dst, 0, req->assoclen + req->cryptlen - tfm->authsize, 1);
1488 else
1489 scatterwalk_map_and_copy(sg_buf, req->dst, 0, req->assoclen + req->cryptlen, 1);
1490 }
1491
1492 if (! decrypt_p) {
1493 /* Now copy the auth tag into request scatterlist. */
1494 scatterwalk_map_and_copy(authTag, req->dst,
1495 req->assoclen + req->cryptlen,
1496 tfm->authsize, 1);
1497 }
1498
1499out:
1500
1501 if (sg_buf) {
1502 free(sg_buf);
1503 }
1504 else {
1505 if (in_map) {
1506#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 15, 0)
1507 scatterwalk_unmap(&in_walk);
1508#else
1509 scatterwalk_unmap(in_map);
1510#endif
1511 }
1512 if (out_map) {
1513#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 15, 0)
1514 scatterwalk_unmap(&out_walk);
1515#else
1516 scatterwalk_unmap(out_map);
1517#endif
1518 }
1519 }
1520
1521 km_AesFree(&aes_copy);
1522
1523 #ifdef WOLFKM_DEBUG_AES
1524 pr_info("info: exiting AesGcmCrypt_1: err %d, dec %d, cryptlen %d, "
1525 "assoclen %d\n", err, decrypt_p,
1526 req->cryptlen, req->assoclen);
1527 #endif /* WOLFKM_DEBUG_AES */
1528
1529 return err;
1530}
1531
1532#endif /* !WOLFSSL_AESGCM_STREAM */
1533
1534#ifdef LINUXKM_LKCAPI_REGISTER_AESGCM
1535
1536static int km_AesGcmEncrypt(struct aead_request *req) {
1537 return AesGcmCrypt_1(req, 0 /* decrypt_p */, 0 /* rfc4106_p */);
1538}
1539
1540static int km_AesGcmDecrypt(struct aead_request *req) {
1541 return AesGcmCrypt_1(req, 1 /* decrypt_p */, 0 /* rfc4106_p */);
1542}
1543
1544static struct aead_alg gcmAesAead = {
1545 .base.cra_name = WOLFKM_AESGCM_NAME,
1546 .base.cra_driver_name = WOLFKM_AESGCM_DRIVER,
1547 .base.cra_priority = WOLFSSL_LINUXKM_LKCAPI_PRIORITY,
1548 .base.cra_blocksize = 1,
1549 .base.cra_ctxsize = sizeof(struct km_AesCtx),
1550 .base.cra_module = THIS_MODULE,
1551 .init = km_AesGcmInit,
1552 .exit = km_AesGcmExit,
1553 .setkey = km_AesGcmSetKey,
1554 .setauthsize = km_AesGcmSetAuthsize,
1555 .encrypt = km_AesGcmEncrypt,
1556 .decrypt = km_AesGcmDecrypt,
1557 .ivsize = GCM_NONCE_MID_SZ,
1558 .maxauthsize = WC_AES_BLOCK_SIZE,
1559 .chunksize = WC_AES_BLOCK_SIZE,
1560};
1561static int gcmAesAead_loaded = 0;
1562
1563#endif /* LINUXKM_LKCAPI_REGISTER_AESGCM */
1564
1565#ifdef LINUXKM_LKCAPI_REGISTER_AESGCM_RFC4106
1566
1567static int km_AesGcmEncrypt_Rfc4106(struct aead_request *req) {
1568 return AesGcmCrypt_1(req, 0 /* decrypt_p */, 1 /* rfc4106 */);
1569}
1570
1571static int km_AesGcmDecrypt_Rfc4106(struct aead_request *req) {
1572 return AesGcmCrypt_1(req, 1 /* decrypt_p */, 1 /* rfc4106 */);
1573}
1574
1575static struct aead_alg gcmAesAead_rfc4106 = {
1576 .base.cra_name = WOLFKM_AESGCM_RFC4106_NAME,
1577 .base.cra_driver_name = WOLFKM_AESGCM_RFC4106_DRIVER,
1578 .base.cra_priority = WOLFSSL_LINUXKM_LKCAPI_PRIORITY,
1579 .base.cra_blocksize = 1,
1580 .base.cra_ctxsize = sizeof(struct km_AesCtx),
1581 .base.cra_module = THIS_MODULE,
1582 .init = km_AesGcmInit,
1583 .exit = km_AesGcmExit,
1584 .setkey = km_AesGcmSetKey_Rfc4106,
1585 .setauthsize = km_AesGcmSetAuthsize_Rfc4106,
1586 .encrypt = km_AesGcmEncrypt_Rfc4106,
1587 .decrypt = km_AesGcmDecrypt_Rfc4106,
1588 .ivsize = 8,
1589 .maxauthsize = WC_AES_BLOCK_SIZE,
1590 .chunksize = WC_AES_BLOCK_SIZE,
1591};
1592static int gcmAesAead_rfc4106_loaded = 0;
1593
1594#endif /* LINUXKM_LKCAPI_REGISTER_AESGCM_RFC4106 */
1595
1596#endif /* LINUXKM_LKCAPI_REGISTER_AESGCM || LINUXKM_LKCAPI_REGISTER_AESGCM_RFC4106 */
1597
1598#if defined(LINUXKM_LKCAPI_REGISTER_AESCCM) || \
1599 defined(LINUXKM_LKCAPI_REGISTER_AESCCM_RFC4309)
1600
1601static int km_AesCcmInit(struct crypto_aead * tfm)
1602{
1603 struct km_AesCtx * ctx = crypto_aead_ctx(tfm);
1604 return km_AesInitCommon(ctx, WOLFKM_AESCCM_DRIVER, 0);
1605}
1606
1607static void km_AesCcmExit(struct crypto_aead * tfm)
1608{
1609 struct km_AesCtx * ctx = crypto_aead_ctx(tfm);
1610 km_AesExitCommon(ctx);
1611}
1612
1613#ifdef LINUXKM_LKCAPI_REGISTER_AESCCM
1614
1615static int km_AesCcmSetKey(struct crypto_aead *tfm, const u8 *in_key,
1616 unsigned int key_len)
1617{
1618 int err;
1619 struct km_AesCtx * ctx = crypto_aead_ctx(tfm);
1620
1621 err = wc_AesCcmSetKey(ctx->aes_encrypt, in_key, key_len);
1622
1623 if (unlikely(err)) {
1624 if ((! disable_setkey_warnings) && ((key_len == 16) || (key_len == 24) || (key_len == 32)))
1625 pr_err("%s: wc_AesCcmSetKey failed: %d\n",
1626 crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)), err);
1627 return -EINVAL;
1628 }
1629
1630#ifdef WC_LINUXKM_C_FALLBACK_IN_SHIMS
1631 if (ctx->aes_encrypt->use_aesni) {
1632 ctx->aes_encrypt_C->use_aesni = WC_FLAG_DONT_USE_VECTOR_OPS;
1633
1634 err = wc_AesCcmSetKey(ctx->aes_encrypt_C, in_key, key_len);
1635
1636 if (unlikely(err)) {
1637 if ((! disable_setkey_warnings) && ((key_len == 16) || (key_len == 24) || (key_len == 32)))
1638 pr_err("%s: wc_AesCcmSetKey failed: %d\n",
1639 crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)), err);
1640 return -EINVAL;
1641 }
1642
1643 if (ctx->aes_encrypt_C->use_aesni)
1644 pr_err("%s: after wc_AesCcmSetKey, ctx->aes_encrypt_C has AES-NI asserted.\n", WOLFKM_AESCCM_DRIVER);
1645 }
1646#endif
1647
1648 #ifdef WOLFKM_DEBUG_AES
1649 pr_info("info: exiting km_AesCcmSetKey: %d\n", key_len);
1650 #endif /* WOLFKM_DEBUG_AES */
1651 return 0;
1652}
1653
1654#endif /* LINUXKM_LKCAPI_REGISTER_AESCCM */
1655
1656#ifdef LINUXKM_LKCAPI_REGISTER_AESCCM_RFC4309
1657
1658static int km_AesCcmSetKey_Rfc4309(struct crypto_aead *tfm, const u8 *in_key,
1659 unsigned int key_len)
1660{
1661 int err;
1662 struct km_AesCtx * ctx = crypto_aead_ctx(tfm);
1663
1664 if (key_len < 3)
1665 return -EINVAL;
1666 key_len -= 3;
1667 memcpy(ctx->rfc4309_nonce, in_key + key_len, 3);
1668
1669 err = wc_AesCcmSetKey(ctx->aes_encrypt, in_key, key_len);
1670
1671 if (unlikely(err)) {
1672 if ((! disable_setkey_warnings) && ((key_len == 16) || (key_len == 24) || (key_len == 32)))
1673 pr_err("%s: wc_AesCcmSetKey failed: %d\n",
1674 crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)), err);
1675 return -EINVAL;
1676 }
1677
1678#ifdef WC_LINUXKM_C_FALLBACK_IN_SHIMS
1679 if (ctx->aes_encrypt->use_aesni) {
1680 ctx->aes_encrypt_C->use_aesni = WC_FLAG_DONT_USE_VECTOR_OPS;
1681
1682 err = wc_AesCcmSetKey(ctx->aes_encrypt_C, in_key, key_len);
1683
1684 if (unlikely(err)) {
1685 if ((! disable_setkey_warnings) && ((key_len == 16) || (key_len == 24) || (key_len == 32)))
1686 pr_err("%s: wc_AesCcmSetKey failed: %d\n",
1687 crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)), err);
1688 return -EINVAL;
1689 }
1690
1691 if (ctx->aes_encrypt_C->use_aesni)
1692 pr_err("%s: after wc_AesCcmSetKey, ctx->aes_encrypt_C has AES-NI asserted.\n", WOLFKM_AESCCM_RFC4309_DRIVER);
1693 }
1694#endif
1695
1696 #ifdef WOLFKM_DEBUG_AES
1697 pr_info("info: exiting km_AesCcmSetKey_Rfc4309: %d\n", key_len);
1698 #endif /* WOLFKM_DEBUG_AES */
1699 return 0;
1700}
1701
1702#endif /* LINUXKM_LKCAPI_REGISTER_AESCCM_RFC4309 */
1703
1704#ifdef LINUXKM_LKCAPI_REGISTER_AESCCM
1705
1706static int km_AesCcmSetAuthsize(struct crypto_aead *tfm, unsigned int authsize)
1707{
1708 (void)tfm;
1709
1710 /* RFC 3610 section 2 */
1711 switch (authsize) {
1712 case 4:
1713 case 6:
1714 case 8:
1715 case 10:
1716 case 12:
1717 case 14:
1718 case 16:
1719 return 0;
1720 }
1721
1722#ifdef WOLFSSL_LINUXKM_VERBOSE_LKCAPI_DEBUG
1723 pr_err("%s: invalid authsize: %d\n",
1724 crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)), authsize);
1725#endif
1726 return -EINVAL;
1727}
1728
1729#endif /* LINUXKM_LKCAPI_REGISTER_AESCCM */
1730
1731#ifdef LINUXKM_LKCAPI_REGISTER_AESCCM_RFC4309
1732
1733static int km_AesCcmSetAuthsize_Rfc4309(struct crypto_aead *tfm, unsigned int authsize)
1734{
1735 (void)tfm;
1736
1737 /* RFC 4309 permits 8, 12, and 16; the kernel rfc4309 wrapper enforces
1738 * the same set, so we match it.
1739 */
1740 switch (authsize) {
1741 case 8:
1742 case 12:
1743 case 16:
1744 return 0;
1745 }
1746
1747#ifdef WOLFSSL_LINUXKM_VERBOSE_LKCAPI_DEBUG
1748 pr_err("%s: invalid authsize: %d\n",
1749 crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)), authsize);
1750#endif
1751 return -EINVAL;
1752}
1753
1754#endif /* LINUXKM_LKCAPI_REGISTER_AESCCM_RFC4309 */
1755
1756/*
1757 * ccm(aes) -- the generic kernel CCM convention. ivsize is 16,
1758 * and req->iv is a partially-formed B0 block where
1759 * req->iv[0] = L - 1, req->iv[1 .. 15-L] = nonce N,
1760 * and bytes [16-L .. 15] are scratch (the kernel's
1761 * generic ccm() template would write the message
1762 * length there before encrypting B0). We don't need
1763 * that scratch region: wc_AesCcmEncrypt rebuilds B0
1764 * internally from (nonce, nonceSz, inSz, ...).
1765 * So all we have to do is decode L from req->iv[0]
1766 * and present (&req->iv[1], 15 - L) as the nonce.
1767 *
1768 * rfc4309(ccm(aes)) -- IPsec ESP convention per RFC 4309. The trailing
1769 * three bytes of the key material are a per-SA salt
1770 * that we stash at setkey time, and ivsize is 8 (the
1771 * explicit per-packet IV). At request time we form
1772 * an 11-byte nonce as salt(3) || req->iv(8), giving
1773 * L = 4, matching RFC 4309 section 4. RFC 4309
1774 * also packs an extra 8 bytes (a copy of the
1775 * explicit IV) into the AAD region between the real
1776 * AAD and the ciphertext, so the real AAD length is
1777 * req->assoclen - 8, and the ciphertext starts at
1778 * offset req->assoclen. This mirrors what the GCM
1779 * rfc4106 path does.
1780 *
1781 * aead ciphers receive data in scatterlists in the following order:
1782 * encrypt
1783 * req->src: aad||plaintext
1784 * req->dst: aad||ciphertext||tag
1785 * decrypt
1786 * req->src: aad||ciphertext||tag
1787 * req->dst: aad||plaintext, return 0 or -EBADMSG
1788 *
1789 * For rfc4309 the AAD region additionally contains an inline 8-byte copy of
1790 * the explicit IV between the real AAD and the (cipher)text, so:
1791 * real AAD length = req->assoclen - 8
1792 * (cipher)text offset = req->assoclen (skips the inline IV too)
1793 *
1794 * Note that wc_AesCcm has no streaming API, so we always linearize the
1795 * scatterlists into a single bounce buffer when they aren't already
1796 * contiguous, exactly as the !WOLFSSL_AESGCM_STREAM branch of the GCM glue
1797 * does.
1798 */
1799
1800static int AesCcmCrypt_1(struct aead_request *req, int decrypt_p, int rfc4309_p)
1801{
1802 struct crypto_aead * tfm = NULL;
1803 struct km_AesCtx * ctx = NULL;
1804 struct skcipher_walk sk_walk;
1805 struct scatter_walk in_walk, out_walk;
1806 u8 *in_map = NULL, *out_map = NULL;
1807 u8 authTag[WC_AES_BLOCK_SIZE];
1808 int err;
1809 unsigned int assoclen = req->assoclen;
1810 u8 * assoc = NULL;
1811 u8 * sg_buf = NULL;
1812 Aes *aes_copy = NULL;
1813 u8 * in_text = NULL;
1814 u8 * out_text = NULL;
1815 const byte * nonce = NULL;
1816 word32 nonceSz = 0;
1817#ifdef LINUXKM_LKCAPI_REGISTER_AESCCM_RFC4309
1818 byte rfc4309_iv[CCM_NONCE_MAX_SZ]; /* >= 11 */
1819#endif
1820
1821 tfm = crypto_aead_reqtfm(req);
1822 ctx = crypto_aead_ctx(tfm);
1823
1824 if (decrypt_p) {
1825 /* Copy out the original auth tag from req->src. */
1826 scatterwalk_map_and_copy(authTag, req->src,
1827 req->assoclen + req->cryptlen - tfm->authsize,
1828 tfm->authsize, 0);
1829 err = skcipher_walk_aead_decrypt(&sk_walk, req, false);
1830 }
1831 else {
1832 err = skcipher_walk_aead_encrypt(&sk_walk, req, false);
1833 }
1834
1835 if (unlikely(err)) {
1836 pr_err("%s: %s failed: %d\n",
1837 crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)),
1838 decrypt_p ? "skcipher_walk_aead_decrypt" : "skcipher_walk_aead_encrypt",
1839 err);
1840 return -EINVAL;
1841 }
1842
1843 err = km_AesGet(ctx, decrypt_p, 1 /* copy_p */, &aes_copy);
1844 if (unlikely(err)) {
1845 goto out;
1846 }
1847
1848#ifdef LINUXKM_LKCAPI_REGISTER_AESCCM_RFC4309
1849 if (rfc4309_p) {
1850 if (unlikely(assoclen != 16 && assoclen != 20)) {
1851 err = -EINVAL;
1852 goto out;
1853 }
1854 assoclen -= 8;
1855
1856 memcpy(rfc4309_iv, ctx->rfc4309_nonce, 3);
1857 memcpy(rfc4309_iv + 3, sk_walk.iv, 8);
1858 nonce = rfc4309_iv;
1859 nonceSz = 11;
1860 }
1861 else
1862#else
1863 (void)rfc4309_p;
1864#endif /* LINUXKM_LKCAPI_REGISTER_AESCCM_RFC4309 */
1865 {
1866 /* Generic ccm(aes): req->iv is a 16-byte buffer.
1867 * req->iv[0] = L - 1 (2 <= L <= 8)
1868 * req->iv[1 .. 15-L] = nonce N (length 15 - L = nonceSz)
1869 * req->iv[16-L .. 15] = scratch (we don't read it)
1870 */
1871 unsigned int L_minus_1 = ((byte *)sk_walk.iv)[0];
1872 unsigned int L = L_minus_1 + 1U;
1873
1874 if (unlikely(L < 2U || L > 8U)) {
1875 err = -EINVAL;
1876 goto out;
1877 }
1878 nonceSz = 15U - L;
1879 nonce = &((byte *)sk_walk.iv)[1];
1880 }
1881
1882 if ((req->src->length >= req->assoclen + req->cryptlen) &&
1883 (req->dst->length >= req->assoclen + req->cryptlen))
1884 {
1885 scatterwalk_start(&in_walk, req->src);
1886#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 15, 0)
1887 scatterwalk_map(&in_walk);
1888 in_map = in_walk.addr;
1889#else
1890 in_map = scatterwalk_map(&in_walk);
1891#endif
1892 if (unlikely(IS_ERR(in_map))) {
1893 err = (int)PTR_ERR(in_map);
1894 pr_err("%s: scatterwalk_map failed: %ld\n",
1895 crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)),
1896 PTR_ERR(in_map));
1897 in_map = NULL;
1898 goto out;
1899 }
1900 assoc = in_map;
1901 in_text = in_map + req->assoclen;
1902
1903 scatterwalk_start(&out_walk, req->dst);
1904#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 15, 0)
1905 scatterwalk_map(&out_walk);
1906 out_map = out_walk.addr;
1907#else
1908 out_map = scatterwalk_map(&out_walk);
1909#endif
1910 if (unlikely(IS_ERR(out_map))) {
1911 err = (int)PTR_ERR(out_map);
1912 pr_err("%s: scatterwalk_map failed: %ld\n",
1913 crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)),
1914 PTR_ERR(out_map));
1915 out_map = NULL;
1916 goto out;
1917 }
1918 out_text = out_map + req->assoclen;
1919 }
1920 else {
1921 sg_buf = malloc(req->assoclen + req->cryptlen);
1922 if (unlikely(sg_buf == NULL)) {
1923 err = -ENOMEM;
1924 goto out;
1925 }
1926 if (decrypt_p)
1927 scatterwalk_map_and_copy(sg_buf, req->src, 0, req->assoclen + req->cryptlen - tfm->authsize, 0);
1928 else
1929 scatterwalk_map_and_copy(sg_buf, req->src, 0, req->assoclen + req->cryptlen, 0);
1930 assoc = sg_buf;
1931 in_text = out_text = sg_buf + req->assoclen;
1932 }
1933
1934 if (decrypt_p) {
1935 err = wc_AesCcmDecrypt(aes_copy, out_text, in_text,
1936 req->cryptlen - tfm->authsize,
1937 nonce, nonceSz,
1938 authTag, tfm->authsize,
1939 assoc, assoclen);
1940
1941 if (unlikely(err)) {
1942#ifdef WOLFSSL_LINUXKM_VERBOSE_LKCAPI_DEBUG
1943 pr_err("%s: wc_AesCcmDecrypt failed with return code %d\n",
1944 crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)), err);
1945#endif
1946
1947 if (err == WC_NO_ERR_TRACE(AES_CCM_AUTH_E)) {
1948 err = -EBADMSG;
1949 goto out;
1950 }
1951 else {
1952 err = -EINVAL;
1953 goto out;
1954 }
1955 }
1956 }
1957 else {
1958 err = wc_AesCcmEncrypt(aes_copy, out_text, in_text, req->cryptlen,
1959 nonce, nonceSz,
1960 authTag, tfm->authsize,
1961 assoc, assoclen);
1962
1963 if (unlikely(err)) {
1964 pr_err("%s: wc_AesCcmEncrypt failed: %d\n",
1965 crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)), err);
1966 err = -EINVAL;
1967 goto out;
1968 }
1969 }
1970
1971 if (sg_buf) {
1972 if (decrypt_p)
1973 scatterwalk_map_and_copy(sg_buf, req->dst, 0, req->assoclen + req->cryptlen - tfm->authsize, 1);
1974 else
1975 scatterwalk_map_and_copy(sg_buf, req->dst, 0, req->assoclen + req->cryptlen, 1);
1976 }
1977
1978 if (! decrypt_p) {
1979 /* Now copy the auth tag into the request scatterlist. */
1980 scatterwalk_map_and_copy(authTag, req->dst,
1981 req->assoclen + req->cryptlen,
1982 tfm->authsize, 1);
1983 }
1984
1985out:
1986
1987 if (sg_buf) {
1988 free(sg_buf);
1989 }
1990 else {
1991 if (in_map) {
1992#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 15, 0)
1993 scatterwalk_unmap(&in_walk);
1994#else
1995 scatterwalk_unmap(in_map);
1996#endif
1997 }
1998 if (out_map) {
1999#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 15, 0)
2000 scatterwalk_unmap(&out_walk);
2001#else
2002 scatterwalk_unmap(out_map);
2003#endif
2004 }
2005 }
2006
2007 km_AesFree(&aes_copy);
2008
2009 #ifdef WOLFKM_DEBUG_AES
2010 pr_info("info: exiting AesCcmCrypt_1: err %d, dec %d, cryptlen %d, "
2011 "assoclen %d\n", err, decrypt_p,
2012 req->cryptlen, req->assoclen);
2013 #endif /* WOLFKM_DEBUG_AES */
2014
2015 return err;
2016}
2017
2018#ifdef LINUXKM_LKCAPI_REGISTER_AESCCM
2019
2020static int km_AesCcmEncrypt(struct aead_request *req) {
2021 return AesCcmCrypt_1(req, 0 /* decrypt_p */, 0 /* rfc4309_p */);
2022}
2023
2024static int km_AesCcmDecrypt(struct aead_request *req) {
2025 return AesCcmCrypt_1(req, 1 /* decrypt_p */, 0 /* rfc4309_p */);
2026}
2027
2028static struct aead_alg ccmAesAead = {
2029 .base.cra_name = WOLFKM_AESCCM_NAME,
2030 .base.cra_driver_name = WOLFKM_AESCCM_DRIVER,
2031 .base.cra_priority = WOLFSSL_LINUXKM_LKCAPI_PRIORITY,
2032 .base.cra_blocksize = 1,
2033 .base.cra_ctxsize = sizeof(struct km_AesCtx),
2034 .base.cra_module = THIS_MODULE,
2035 .init = km_AesCcmInit,
2036 .exit = km_AesCcmExit,
2037 .setkey = km_AesCcmSetKey,
2038 .setauthsize = km_AesCcmSetAuthsize,
2039 .encrypt = km_AesCcmEncrypt,
2040 .decrypt = km_AesCcmDecrypt,
2041 .ivsize = WC_AES_BLOCK_SIZE,
2042 .maxauthsize = WC_AES_BLOCK_SIZE,
2043 .chunksize = 1,
2044};
2045static int ccmAesAead_loaded = 0;
2046
2047#endif /* LINUXKM_LKCAPI_REGISTER_AESCCM */
2048
2049#ifdef LINUXKM_LKCAPI_REGISTER_AESCCM_RFC4309
2050
2051static int km_AesCcmEncrypt_Rfc4309(struct aead_request *req) {
2052 return AesCcmCrypt_1(req, 0 /* decrypt_p */, 1 /* rfc4309_p */);
2053}
2054
2055static int km_AesCcmDecrypt_Rfc4309(struct aead_request *req) {
2056 return AesCcmCrypt_1(req, 1 /* decrypt_p */, 1 /* rfc4309_p */);
2057}
2058
2059static struct aead_alg ccmAesAead_rfc4309 = {
2060 .base.cra_name = WOLFKM_AESCCM_RFC4309_NAME,
2061 .base.cra_driver_name = WOLFKM_AESCCM_RFC4309_DRIVER,
2062 .base.cra_priority = WOLFSSL_LINUXKM_LKCAPI_PRIORITY,
2063 .base.cra_blocksize = 1,
2064 .base.cra_ctxsize = sizeof(struct km_AesCtx),
2065 .base.cra_module = THIS_MODULE,
2066 .init = km_AesCcmInit,
2067 .exit = km_AesCcmExit,
2068 .setkey = km_AesCcmSetKey_Rfc4309,
2069 .setauthsize = km_AesCcmSetAuthsize_Rfc4309,
2070 .encrypt = km_AesCcmEncrypt_Rfc4309,
2071 .decrypt = km_AesCcmDecrypt_Rfc4309,
2072 .ivsize = 8,
2073 .maxauthsize = WC_AES_BLOCK_SIZE,
2074 .chunksize = 1,
2075};
2076static int ccmAesAead_rfc4309_loaded = 0;
2077
2078#endif /* LINUXKM_LKCAPI_REGISTER_AESCCM_RFC4309 */
2079
2080#endif /* LINUXKM_LKCAPI_REGISTER_AESCCM || LINUXKM_LKCAPI_REGISTER_AESCCM_RFC4309 */
2081
2082
2083
2084
2085#ifdef LINUXKM_LKCAPI_REGISTER_AESXTS
2086
2087#ifndef WOLFSSL_AESXTS_STREAM
2088 #error LKCAPI registration of AES-XTS requires WOLFSSL_AESXTS_STREAM (--enable-aesxts-stream).
2089#endif
2090
2091#if defined(WOLFSSL_AESNI) && !defined(WC_C_DYNAMIC_FALLBACK)
2092 #error LKCAPI registration of AES-XTS with AESNI requires WC_C_DYNAMIC_FALLBACK.
2093#endif
2094
2095struct km_AesXtsCtx {
2096 XtsAes *aesXts; /* allocated in km_AesXtsInitCommon() to assure alignment
2097 * for AESNI.
2098 */
2099};
2100
2101static int km_AesXtsInitCommon(struct km_AesXtsCtx * ctx, const char * name)
2102{
2103 int err;
2104
2105 ctx->aesXts = (XtsAes *)malloc(sizeof(*ctx->aesXts));
2106
2107 if (! ctx->aesXts)
2108 return -ENOMEM;
2109
2110 err = wc_AesXtsInit(ctx->aesXts, NULL, INVALID_DEVID);
2111
2112 if (unlikely(err)) {
2113 pr_err("%s: km_AesXtsInitCommon failed: %d\n", name, err);
2114 free(ctx->aesXts);
2115 ctx->aesXts = NULL;
2116 return -EINVAL;
2117 }
2118
2119 return 0;
2120}
2121
2122static int km_AesXtsInit(struct crypto_skcipher *tfm)
2123{
2124 struct km_AesXtsCtx * ctx = crypto_skcipher_ctx(tfm);
2125 return km_AesXtsInitCommon(ctx, WOLFKM_AESXTS_DRIVER);
2126}
2127
2128static void km_AesXtsExit(struct crypto_skcipher *tfm)
2129{
2130 struct km_AesXtsCtx * ctx = crypto_skcipher_ctx(tfm);
2131 wc_AesXtsFree(ctx->aesXts);
2132 free(ctx->aesXts);
2133 ctx->aesXts = NULL;
2134}
2135
2136static int km_AesXtsSetKey(struct crypto_skcipher *tfm, const u8 *in_key,
2137 unsigned int key_len)
2138{
2139 int err;
2140 struct km_AesXtsCtx * ctx = crypto_skcipher_ctx(tfm);
2141
2142 err = wc_AesXtsSetKeyNoInit(ctx->aesXts, in_key, key_len,
2143 AES_ENCRYPTION_AND_DECRYPTION);
2144
2145 if (unlikely(err)) {
2146 if ((! disable_setkey_warnings) && ((key_len == 16) || (key_len == 24) || (key_len == 32)))
2147 pr_err("%s: wc_AesXtsSetKeyNoInit failed: %d\n",
2148 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
2149 return -EINVAL;
2150 }
2151
2152 /* It's possible to set ctx->aesXts->{tweak,aes,aes_decrypt}.use_aesni to
2153 * WC_FLAG_DONT_USE_VECTOR_OPS here, for WC_LINUXKM_C_FALLBACK_IN_SHIMS in
2154 * AES-XTS, but we can use the WC_C_DYNAMIC_FALLBACK mechanism
2155 * unconditionally because there's no AES-XTS in Cert 4718.
2156 */
2157
2158 #ifdef WOLFKM_DEBUG_AES
2159 pr_info("info: exiting km_AesXtsSetKey: %d\n", key_len);
2160 #endif /* WOLFKM_DEBUG_AES */
2161
2162 return 0;
2163}
2164
2165/* see /usr/src/linux/drivers/md/dm-crypt.c */
2166
2167static int km_AesXtsEncrypt(struct skcipher_request *req)
2168{
2169 int err;
2170 struct crypto_skcipher * tfm = NULL;
2171 struct km_AesXtsCtx * ctx = NULL;
2172 struct skcipher_walk walk;
2173 unsigned int nbytes = 0;
2174
2175 tfm = crypto_skcipher_reqtfm(req);
2176 ctx = crypto_skcipher_ctx(tfm);
2177
2178 if (req->cryptlen < WC_AES_BLOCK_SIZE)
2179 return -EINVAL;
2180
2181 err = skcipher_walk_virt(&walk, req, false);
2182
2183 if (unlikely(err)) {
2184 pr_err("%s: skcipher_walk_virt failed: %d\n",
2185 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
2186 return err;
2187 }
2188
2189 if (walk.nbytes == walk.total) {
2190 err = wc_AesXtsEncrypt(ctx->aesXts, walk.dst.virt.addr,
2191 walk.src.virt.addr, walk.nbytes, walk.iv, walk.ivsize);
2192
2193 if (unlikely(err)) {
2194 pr_err("%s: wc_AesXtsEncrypt failed: %d\n",
2195 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
2196 return -EINVAL;
2197 }
2198
2199 err = skcipher_walk_done(&walk, 0);
2200
2201 } else {
2202 int tail = req->cryptlen % WC_AES_BLOCK_SIZE;
2203 struct skcipher_request subreq;
2204 struct XtsAesStreamData stream;
2205
2206 if (tail > 0) {
2207 int blocks = DIV_ROUND_UP(req->cryptlen, WC_AES_BLOCK_SIZE) - 2;
2208
2209 skcipher_walk_abort(&walk);
2210
2211 skcipher_request_set_tfm(&subreq, tfm);
2212 skcipher_request_set_callback(&subreq,
2213 skcipher_request_flags(req),
2214 NULL, NULL);
2215 skcipher_request_set_crypt(&subreq, req->src, req->dst,
2216 blocks * WC_AES_BLOCK_SIZE, req->iv);
2217 req = &subreq;
2218
2219 err = skcipher_walk_virt(&walk, req, false);
2220 if (!walk.nbytes)
2221 return err ? : -EINVAL;
2222 } else {
2223 tail = 0;
2224 }
2225
2226 err = wc_AesXtsEncryptInit(ctx->aesXts, walk.iv, walk.ivsize, &stream);
2227
2228 if (unlikely(err)) {
2229 pr_err("%s: wc_AesXtsEncryptInit failed: %d\n",
2230 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
2231 return -EINVAL;
2232 }
2233
2234 while ((nbytes = walk.nbytes) != 0) {
2235 /* if this isn't the final call, pass block-aligned data to prevent
2236 * end-of-message ciphertext stealing.
2237 */
2238 if (nbytes < walk.total)
2239 nbytes &= ~(WC_AES_BLOCK_SIZE - 1);
2240
2241 if (nbytes & ((unsigned int)WC_AES_BLOCK_SIZE - 1U))
2242 err = wc_AesXtsEncryptFinal(ctx->aesXts, walk.dst.virt.addr,
2243 walk.src.virt.addr, nbytes,
2244 &stream);
2245 else
2246 err = wc_AesXtsEncryptUpdate(ctx->aesXts, walk.dst.virt.addr,
2247 walk.src.virt.addr, nbytes,
2248 &stream);
2249
2250 if (unlikely(err)) {
2251 pr_err("%s: wc_AesXtsEncryptUpdate failed: %d\n",
2252 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
2253 return -EINVAL;
2254 }
2255
2256 err = skcipher_walk_done(&walk, walk.nbytes - nbytes);
2257
2258 if (unlikely(err)) {
2259 pr_err("%s: skcipher_walk_done failed: %d\n",
2260 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
2261 return err;
2262 }
2263 }
2264
2265 if (unlikely(tail > 0)) {
2266 struct scatterlist sg_src[2], sg_dst[2];
2267 struct scatterlist *src, *dst;
2268
2269 dst = src = scatterwalk_ffwd(sg_src, req->src, req->cryptlen);
2270 if (req->dst != req->src)
2271 dst = scatterwalk_ffwd(sg_dst, req->dst, req->cryptlen);
2272
2273 skcipher_request_set_crypt(req, src, dst, WC_AES_BLOCK_SIZE + tail,
2274 req->iv);
2275
2276 err = skcipher_walk_virt(&walk, &subreq, false);
2277 if (err)
2278 return err;
2279
2280 err = wc_AesXtsEncryptFinal(ctx->aesXts, walk.dst.virt.addr,
2281 walk.src.virt.addr, walk.nbytes,
2282 &stream);
2283
2284 if (unlikely(err)) {
2285 pr_err("%s: wc_AesXtsEncryptFinal failed: %d\n",
2286 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
2287 return -EINVAL;
2288 }
2289
2290 err = skcipher_walk_done(&walk, 0);
2291 } else if (! (stream.bytes_crypted_with_this_tweak & ((word32)WC_AES_BLOCK_SIZE - 1U))) {
2292 err = wc_AesXtsEncryptFinal(ctx->aesXts, NULL, NULL, 0, &stream);
2293 }
2294 }
2295
2296 #ifdef WOLFKM_DEBUG_AES
2297 pr_info("info: exiting km_AesXtsEncrypt: err %d, cryptlen %d\n", err,
2298 req->cryptlen);
2299 #endif /* WOLFKM_DEBUG_AES */
2300
2301 return err;
2302}
2303
2304static int km_AesXtsDecrypt(struct skcipher_request *req)
2305{
2306 int err;
2307 struct crypto_skcipher * tfm = NULL;
2308 struct km_AesXtsCtx * ctx = NULL;
2309 struct skcipher_walk walk;
2310 unsigned int nbytes = 0;
2311
2312 tfm = crypto_skcipher_reqtfm(req);
2313 ctx = crypto_skcipher_ctx(tfm);
2314
2315 if (req->cryptlen < WC_AES_BLOCK_SIZE)
2316 return -EINVAL;
2317
2318 err = skcipher_walk_virt(&walk, req, false);
2319
2320 if (unlikely(err)) {
2321 pr_err("%s: skcipher_walk_virt failed: %d\n",
2322 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
2323 return err;
2324 }
2325
2326 if (walk.nbytes == walk.total) {
2327 err = wc_AesXtsDecrypt(ctx->aesXts,
2328 walk.dst.virt.addr, walk.src.virt.addr,
2329 walk.nbytes, walk.iv, walk.ivsize);
2330
2331 if (unlikely(err)) {
2332 pr_err("%s: wc_AesXtsDecrypt failed: %d\n",
2333 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
2334 return -EINVAL;
2335 }
2336
2337 err = skcipher_walk_done(&walk, 0);
2338 } else {
2339 int tail = req->cryptlen % WC_AES_BLOCK_SIZE;
2340 struct skcipher_request subreq;
2341 struct XtsAesStreamData stream;
2342
2343 if (unlikely(tail > 0)) {
2344 int blocks = DIV_ROUND_UP(req->cryptlen, WC_AES_BLOCK_SIZE) - 2;
2345
2346 skcipher_walk_abort(&walk);
2347
2348 skcipher_request_set_tfm(&subreq, tfm);
2349 skcipher_request_set_callback(&subreq,
2350 skcipher_request_flags(req),
2351 NULL, NULL);
2352 skcipher_request_set_crypt(&subreq, req->src, req->dst,
2353 blocks * WC_AES_BLOCK_SIZE, req->iv);
2354 req = &subreq;
2355
2356 err = skcipher_walk_virt(&walk, req, false);
2357 if (!walk.nbytes)
2358 return err ? : -EINVAL;
2359 } else {
2360 tail = 0;
2361 }
2362
2363 err = wc_AesXtsDecryptInit(ctx->aesXts, walk.iv, walk.ivsize, &stream);
2364
2365 if (unlikely(err)) {
2366 pr_err("%s: wc_AesXtsDecryptInit failed: %d\n",
2367 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
2368 return -EINVAL;
2369 }
2370
2371 while ((nbytes = walk.nbytes) != 0) {
2372 /* if this isn't the final call, pass block-aligned data to prevent
2373 * end-of-message ciphertext stealing.
2374 */
2375 if (nbytes < walk.total)
2376 nbytes &= ~(WC_AES_BLOCK_SIZE - 1);
2377
2378 if (nbytes & ((unsigned int)WC_AES_BLOCK_SIZE - 1U))
2379 err = wc_AesXtsDecryptFinal(ctx->aesXts, walk.dst.virt.addr,
2380 walk.src.virt.addr, nbytes,
2381 &stream);
2382 else
2383 err = wc_AesXtsDecryptUpdate(ctx->aesXts, walk.dst.virt.addr,
2384 walk.src.virt.addr, nbytes,
2385 &stream);
2386
2387 if (unlikely(err)) {
2388 pr_err("%s: wc_AesXtsDecryptUpdate failed: %d\n",
2389 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
2390 return -EINVAL;
2391 }
2392
2393 err = skcipher_walk_done(&walk, walk.nbytes - nbytes);
2394
2395 if (unlikely(err)) {
2396 pr_err("%s: skcipher_walk_done failed: %d\n",
2397 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
2398 return err;
2399 }
2400 }
2401
2402 if (unlikely(tail > 0)) {
2403 struct scatterlist sg_src[2], sg_dst[2];
2404 struct scatterlist *src, *dst;
2405
2406 dst = src = scatterwalk_ffwd(sg_src, req->src, req->cryptlen);
2407 if (req->dst != req->src)
2408 dst = scatterwalk_ffwd(sg_dst, req->dst, req->cryptlen);
2409
2410 skcipher_request_set_crypt(req, src, dst, WC_AES_BLOCK_SIZE + tail,
2411 req->iv);
2412
2413 err = skcipher_walk_virt(&walk, &subreq, false);
2414 if (err)
2415 return err;
2416
2417 err = wc_AesXtsDecryptFinal(ctx->aesXts, walk.dst.virt.addr,
2418 walk.src.virt.addr, walk.nbytes,
2419 &stream);
2420
2421 if (unlikely(err)) {
2422 pr_err("%s: wc_AesXtsDecryptFinal failed: %d\n",
2423 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
2424 return -EINVAL;
2425 }
2426
2427 err = skcipher_walk_done(&walk, 0);
2428 } else if (! (stream.bytes_crypted_with_this_tweak & ((word32)WC_AES_BLOCK_SIZE - 1U))) {
2429 err = wc_AesXtsDecryptFinal(ctx->aesXts, NULL, NULL, 0, &stream);
2430 }
2431 }
2432
2433 #ifdef WOLFKM_DEBUG_AES
2434 pr_info("info: exiting km_AesXtsDecrypt: err %d, cryptlen %d\n", err,
2435 req->cryptlen);
2436 #endif /* WOLFKM_DEBUG_AES */
2437
2438 return err;
2439}
2440
2441static struct skcipher_alg xtsAesAlg = {
2442 .base.cra_name = WOLFKM_AESXTS_NAME,
2443 .base.cra_driver_name = WOLFKM_AESXTS_DRIVER,
2444 .base.cra_priority = WOLFSSL_LINUXKM_LKCAPI_PRIORITY,
2445 .base.cra_blocksize = WC_AES_BLOCK_SIZE,
2446 .base.cra_ctxsize = sizeof(struct km_AesXtsCtx),
2447 .base.cra_module = THIS_MODULE,
2448
2449 .min_keysize = 2 * AES_128_KEY_SIZE,
2450 .max_keysize = 2 * AES_256_KEY_SIZE,
2451 .ivsize = WC_AES_BLOCK_SIZE,
2452 .walksize = 2 * WC_AES_BLOCK_SIZE,
2453 .init = km_AesXtsInit,
2454 .exit = km_AesXtsExit,
2455 .setkey = km_AesXtsSetKey,
2456 .encrypt = km_AesXtsEncrypt,
2457 .decrypt = km_AesXtsDecrypt
2458};
2459static int xtsAesAlg_loaded = 0;
2460
2461#endif /* LINUXKM_LKCAPI_REGISTER_AESXTS */
2462
2463#ifdef LINUXKM_LKCAPI_REGISTER_AESCTR
2464
2465static int km_AesCtrInit(struct crypto_skcipher *tfm)
2466{
2467 struct km_AesCtx * ctx = crypto_skcipher_ctx(tfm);
2468 return km_AesInitCommon(ctx, WOLFKM_AESCTR_DRIVER, 0);
2469}
2470
2471static int km_AesCtrSetKey(struct crypto_skcipher *tfm, const u8 *in_key,
2472 unsigned int key_len)
2473{
2474 struct km_AesCtx * ctx = crypto_skcipher_ctx(tfm);
2475 return km_AesSetKeyCommon(ctx, in_key, key_len, WOLFKM_AESCTR_DRIVER);
2476}
2477
2478static int km_AesCtrEncrypt(struct skcipher_request *req)
2479{
2480 struct crypto_skcipher * tfm = NULL;
2481 struct km_AesCtx * ctx = NULL;
2482 struct skcipher_walk walk;
2483 int err;
2484 Aes *aes_copy = NULL;
2485
2486 tfm = crypto_skcipher_reqtfm(req);
2487 ctx = crypto_skcipher_ctx(tfm);
2488
2489 err = skcipher_walk_virt(&walk, req, false);
2490
2491 if (unlikely(err)) {
2492 pr_err("%s: skcipher_walk_virt failed: %d\n",
2493 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
2494 return err;
2495 }
2496
2497 /* Copy the cipher state to mitigate races on Aes.reg and Aes.tmp. */
2498 aes_copy = (struct Aes *)malloc(sizeof(Aes));
2499 if (aes_copy == NULL) {
2500 err = -ENOMEM;
2501 goto out;
2502 }
2503 XMEMCPY(aes_copy, ctx->aes_encrypt, sizeof(Aes));
2504
2505 err = wc_AesSetIV(aes_copy, walk.iv);
2506
2507 if (unlikely(err)) {
2508 pr_err("%s: wc_AesSetIV failed: %d\n",
2509 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
2510 err = -EINVAL;
2511 goto out;
2512 }
2513
2514 while (walk.nbytes != 0) {
2515 err = wc_AesCtrEncrypt(aes_copy, walk.dst.virt.addr,
2516 walk.src.virt.addr, walk.nbytes);
2517
2518 if (unlikely(err)) {
2519 pr_err("%s: wc_AesCtrEncrypt failed %d\n",
2520 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
2521 err = -EINVAL;
2522 goto out;
2523 }
2524
2525 err = skcipher_walk_done(&walk, 0);
2526
2527 if (unlikely(err)) {
2528 pr_err("%s: skcipher_walk_done failed: %d\n",
2529 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
2530 return err;
2531 }
2532 }
2533
2534 /* copy iv from wolfCrypt back to walk.iv */
2535 XMEMCPY(walk.iv, aes_copy->reg, WC_AES_BLOCK_SIZE);
2536
2537out:
2538
2539 if (err && walk.nbytes)
2540 (void)skcipher_walk_done(&walk, err);
2541
2542 km_AesFree(&aes_copy);
2543
2544 #ifdef WOLFKM_DEBUG_AES
2545 pr_info("info: exiting km_AesCtrEncrypt: err %d, cryptlen %d\n", err,
2546 req->cryptlen);
2547 #endif /* WOLFKM_DEBUG_AES */
2548
2549 return err;
2550}
2551
2552static int km_AesCtrDecrypt(struct skcipher_request *req)
2553{
2554 struct crypto_skcipher * tfm = NULL;
2555 struct km_AesCtx * ctx = NULL;
2556 struct skcipher_walk walk;
2557 int err;
2558 Aes *aes_copy = NULL;
2559
2560 tfm = crypto_skcipher_reqtfm(req);
2561 ctx = crypto_skcipher_ctx(tfm);
2562
2563 err = skcipher_walk_virt(&walk, req, false);
2564
2565 if (unlikely(err)) {
2566 pr_err("%s: skcipher_walk_virt failed: %d\n",
2567 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
2568 return err;
2569 }
2570
2571 /* Copy the cipher state to mitigate races on Aes.reg and Aes.tmp. */
2572 aes_copy = (struct Aes *)malloc(sizeof(Aes));
2573 if (aes_copy == NULL) {
2574 err = -ENOMEM;
2575 goto out;
2576 }
2577 XMEMCPY(aes_copy, ctx->aes_encrypt, sizeof(Aes)); /* CTR uses the same
2578 * schedule for encrypt
2579 * and decrypt.
2580 */
2581
2582 err = wc_AesSetIV(aes_copy, walk.iv);
2583
2584 if (unlikely(err)) {
2585 if (! disable_setkey_warnings)
2586 pr_err("%s: wc_AesSetIV failed: %d\n",
2587 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
2588 err = -EINVAL;
2589 goto out;
2590 }
2591
2592 while (walk.nbytes != 0) {
2593 /* CTR uses the same function for encrypt and decrypt. */
2594 err = wc_AesCtrEncrypt(aes_copy, walk.dst.virt.addr,
2595 walk.src.virt.addr, walk.nbytes);
2596
2597 if (unlikely(err)) {
2598 pr_err("%s: wc_AesCtrDecrypt failed: %d\n",
2599 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
2600 err = -EINVAL;
2601 goto out;
2602 }
2603
2604 err = skcipher_walk_done(&walk, 0);
2605
2606 if (unlikely(err)) {
2607 pr_err("%s: skcipher_walk_done failed: %d\n",
2608 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
2609 goto out;
2610 }
2611 }
2612
2613 /* copy iv from wolfCrypt back to walk.iv */
2614 XMEMCPY(walk.iv, aes_copy->reg, WC_AES_BLOCK_SIZE);
2615
2616out:
2617
2618 if (err && walk.nbytes)
2619 (void)skcipher_walk_done(&walk, err);
2620
2621 km_AesFree(&aes_copy);
2622
2623 #ifdef WOLFKM_DEBUG_AES
2624 pr_info("info: exiting km_AesCtrDecrypt: err %d, cryptlen %d\n", err,
2625 req->cryptlen);
2626 #endif /* WOLFKM_DEBUG_AES */
2627
2628 return err;
2629}
2630
2631static struct skcipher_alg ctrAesAlg = {
2632 .base.cra_name = WOLFKM_AESCTR_NAME,
2633 .base.cra_driver_name = WOLFKM_AESCTR_DRIVER,
2634 .base.cra_priority = WOLFSSL_LINUXKM_LKCAPI_PRIORITY,
2635 .base.cra_blocksize = 1,
2636 .base.cra_ctxsize = sizeof(struct km_AesCtx),
2637 .base.cra_module = THIS_MODULE,
2638 .init = km_AesCtrInit,
2639 .exit = km_AesExit,
2640 .min_keysize = AES_128_KEY_SIZE,
2641 .max_keysize = AES_256_KEY_SIZE,
2642 .ivsize = WC_AES_BLOCK_SIZE,
2643 .setkey = km_AesCtrSetKey,
2644 .encrypt = km_AesCtrEncrypt,
2645 .decrypt = km_AesCtrDecrypt,
2646};
2647static int ctrAesAlg_loaded = 0;
2648
2649#endif /* LINUXKM_LKCAPI_REGISTER_AESCTR */
2650
2651#ifdef LINUXKM_LKCAPI_REGISTER_AESOFB
2652
2653static int km_AesOfbInit(struct crypto_skcipher *tfm)
2654{
2655 struct km_AesCtx * ctx = crypto_skcipher_ctx(tfm);
2656 return km_AesInitCommon(ctx, WOLFKM_AESOFB_DRIVER, 0);
2657}
2658
2659static int km_AesOfbSetKey(struct crypto_skcipher *tfm, const u8 *in_key,
2660 unsigned int key_len)
2661{
2662 struct km_AesCtx * ctx = crypto_skcipher_ctx(tfm);
2663 return km_AesSetKeyCommon(ctx, in_key, key_len, WOLFKM_AESOFB_DRIVER);
2664}
2665
2666static int km_AesOfbEncrypt(struct skcipher_request *req)
2667{
2668 struct crypto_skcipher * tfm = NULL;
2669 struct km_AesCtx * ctx = NULL;
2670 struct skcipher_walk walk;
2671 int err;
2672 Aes *aes_copy = NULL;
2673
2674 tfm = crypto_skcipher_reqtfm(req);
2675 ctx = crypto_skcipher_ctx(tfm);
2676
2677 err = skcipher_walk_virt(&walk, req, false);
2678
2679 if (unlikely(err)) {
2680 pr_err("%s: skcipher_walk_virt failed: %d\n",
2681 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
2682 return err;
2683 }
2684
2685 /* Copy the cipher state to mitigate races on Aes.reg and Aes.tmp. */
2686 aes_copy = (struct Aes *)malloc(sizeof(Aes));
2687 if (aes_copy == NULL) {
2688 err = -ENOMEM;
2689 goto out;
2690 }
2691 XMEMCPY(aes_copy, ctx->aes_encrypt, sizeof(Aes));
2692
2693 err = wc_AesSetIV(aes_copy, walk.iv);
2694
2695 if (unlikely(err)) {
2696 pr_err("%s: wc_AesSetIV failed: %d\n",
2697 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
2698 err = -EINVAL;
2699 goto out;
2700 }
2701
2702 while (walk.nbytes != 0) {
2703 err = wc_AesOfbEncrypt(aes_copy, walk.dst.virt.addr,
2704 walk.src.virt.addr, walk.nbytes);
2705
2706 if (unlikely(err)) {
2707 pr_err("%s: wc_AesOfbEncrypt failed %d\n",
2708 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
2709 err = -EINVAL;
2710 goto out;
2711 }
2712
2713 err = skcipher_walk_done(&walk, 0);
2714
2715 if (unlikely(err)) {
2716 pr_err("%s: skcipher_walk_done failed: %d\n",
2717 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
2718 return err;
2719 }
2720 }
2721
2722 /* copy iv from wolfCrypt back to walk.iv */
2723 XMEMCPY(walk.iv, aes_copy->reg, WC_AES_BLOCK_SIZE);
2724
2725out:
2726
2727 if (err && walk.nbytes)
2728 (void)skcipher_walk_done(&walk, err);
2729
2730 km_AesFree(&aes_copy);
2731
2732 #ifdef WOLFKM_DEBUG_AES
2733 pr_info("info: exiting km_AesOfbEncrypt: err %d, cryptlen %d\n", err,
2734 req->cryptlen);
2735 #endif /* WOLFKM_DEBUG_AES */
2736
2737 return err;
2738}
2739
2740static int km_AesOfbDecrypt(struct skcipher_request *req)
2741{
2742 struct crypto_skcipher * tfm = NULL;
2743 struct km_AesCtx * ctx = NULL;
2744 struct skcipher_walk walk;
2745 int err;
2746 Aes *aes_copy = NULL;
2747
2748 tfm = crypto_skcipher_reqtfm(req);
2749 ctx = crypto_skcipher_ctx(tfm);
2750
2751 err = skcipher_walk_virt(&walk, req, false);
2752
2753 if (unlikely(err)) {
2754 pr_err("%s: skcipher_walk_virt failed: %d\n",
2755 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
2756 return err;
2757 }
2758
2759 /* Copy the cipher state to mitigate races on Aes.reg and Aes.tmp. */
2760 aes_copy = (struct Aes *)malloc(sizeof(Aes));
2761 if (aes_copy == NULL) {
2762 err = -ENOMEM;
2763 goto out;
2764 }
2765 XMEMCPY(aes_copy, ctx->aes_encrypt, sizeof(Aes)); /* OFB uses the same
2766 * schedule for encrypt
2767 * and decrypt.
2768 */
2769
2770 err = wc_AesSetIV(aes_copy, walk.iv);
2771
2772 if (unlikely(err)) {
2773 if (! disable_setkey_warnings)
2774 pr_err("%s: wc_AesSetIV failed: %d\n",
2775 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
2776 err = -EINVAL;
2777 goto out;
2778 }
2779
2780 while (walk.nbytes != 0) {
2781 err = wc_AesOfbDecrypt(aes_copy, walk.dst.virt.addr,
2782 walk.src.virt.addr, walk.nbytes);
2783
2784 if (unlikely(err)) {
2785 pr_err("%s: wc_AesOfbDecrypt failed: %d\n",
2786 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
2787 err = -EINVAL;
2788 goto out;
2789 }
2790
2791 err = skcipher_walk_done(&walk, 0);
2792
2793 if (unlikely(err)) {
2794 pr_err("%s: skcipher_walk_done failed: %d\n",
2795 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), err);
2796 goto out;
2797 }
2798 }
2799
2800 /* copy iv from wolfCrypt back to walk.iv */
2801 XMEMCPY(walk.iv, aes_copy->reg, WC_AES_BLOCK_SIZE);
2802
2803out:
2804
2805 if (err && walk.nbytes)
2806 (void)skcipher_walk_done(&walk, err);
2807
2808 km_AesFree(&aes_copy);
2809
2810 #ifdef WOLFKM_DEBUG_AES
2811 pr_info("info: exiting km_AesOfbDecrypt: err %d, cryptlen %d\n", err,
2812 req->cryptlen);
2813 #endif /* WOLFKM_DEBUG_AES */
2814
2815 return err;
2816}
2817
2818static struct skcipher_alg ofbAesAlg = {
2819 .base.cra_name = WOLFKM_AESOFB_NAME,
2820 .base.cra_driver_name = WOLFKM_AESOFB_DRIVER,
2821 .base.cra_priority = WOLFSSL_LINUXKM_LKCAPI_PRIORITY,
2822 .base.cra_blocksize = 1,
2823 .base.cra_ctxsize = sizeof(struct km_AesCtx),
2824 .base.cra_module = THIS_MODULE,
2825 .init = km_AesOfbInit,
2826 .exit = km_AesExit,
2827 .min_keysize = AES_128_KEY_SIZE,
2828 .max_keysize = AES_256_KEY_SIZE,
2829 .ivsize = WC_AES_BLOCK_SIZE,
2830 .setkey = km_AesOfbSetKey,
2831 .encrypt = km_AesOfbEncrypt,
2832 .decrypt = km_AesOfbDecrypt,
2833};
2834static int ofbAesAlg_loaded = 0;
2835
2836#endif /* LINUXKM_LKCAPI_REGISTER_AESOFB */
2837
2838#ifdef LINUXKM_LKCAPI_REGISTER_AESECB
2839
2840static int km_AesEcbInit(struct crypto_skcipher *tfm)
2841{
2842 struct km_AesCtx * ctx = crypto_skcipher_ctx(tfm);
2843 return km_AesInitCommon(ctx, WOLFKM_AESECB_DRIVER, 1);
2844}
2845
2846static int km_AesEcbSetKey(struct crypto_skcipher *tfm, const u8 *in_key,
2847 unsigned int key_len)
2848{
2849 struct km_AesCtx * ctx = crypto_skcipher_ctx(tfm);
2850 return km_AesSetKeyCommon(ctx, in_key, key_len, WOLFKM_AESECB_DRIVER);
2851}
2852
2853static int km_AesEcbEncrypt(struct skcipher_request *req)
2854{
2855 struct crypto_skcipher * tfm = NULL;
2856 struct km_AesCtx * ctx = NULL;
2857 struct skcipher_walk walk;
2858 unsigned int nbytes = 0;
2859 int err;
2860 Aes *aes;
2861
2862 tfm = crypto_skcipher_reqtfm(req);
2863 ctx = crypto_skcipher_ctx(tfm);
2864
2865 err = skcipher_walk_virt(&walk, req, false);
2866
2867 if (unlikely(err)) {
2868 return err;
2869 }
2870
2871 err = km_AesGet(ctx, 0 /* decrypt_p */, 0 /* copy_p */, &aes);
2872 if (unlikely(err)) {
2873 goto out;
2874 }
2875
2876 while ((nbytes = walk.nbytes) != 0) {
2877 err = wc_AesEcbEncrypt(aes, walk.dst.virt.addr, walk.src.virt.addr,
2878 nbytes & (~(WC_AES_BLOCK_SIZE - 1)));
2879
2880 if (unlikely(err)) {
2881 pr_err("%s: wc_AesEcbEncrypt failed for %u bytes: %d\n",
2882 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), nbytes, err);
2883 err = -EINVAL;
2884 goto out;
2885 }
2886
2887 nbytes &= WC_AES_BLOCK_SIZE - 1;
2888 err = skcipher_walk_done(&walk, nbytes);
2889 }
2890
2891out:
2892
2893 if (err && walk.nbytes)
2894 (void)skcipher_walk_done(&walk, err);
2895
2896 #ifdef WOLFKM_DEBUG_AES
2897 pr_info("info: exiting km_AesEcbEncrypt: err %d, cryptlen %d\n", err,
2898 req->cryptlen);
2899 #endif /* WOLFKM_DEBUG_AES */
2900
2901 return err;
2902}
2903
2904static int km_AesEcbDecrypt(struct skcipher_request *req)
2905{
2906 struct crypto_skcipher * tfm = NULL;
2907 struct km_AesCtx * ctx = NULL;
2908 struct skcipher_walk walk;
2909 unsigned int nbytes = 0;
2910 int err;
2911 Aes *aes;
2912
2913 tfm = crypto_skcipher_reqtfm(req);
2914 ctx = crypto_skcipher_ctx(tfm);
2915
2916 err = skcipher_walk_virt(&walk, req, false);
2917
2918 if (unlikely(err)) {
2919 return err;
2920 }
2921
2922 err = km_AesGet(ctx, 1 /* decrypt_p */, 0 /* copy_p */, &aes);
2923 if (unlikely(err)) {
2924 goto out;
2925 }
2926
2927 while ((nbytes = walk.nbytes) != 0) {
2928 err = wc_AesEcbDecrypt(aes, walk.dst.virt.addr, walk.src.virt.addr,
2929 nbytes & (~(WC_AES_BLOCK_SIZE - 1)));
2930
2931 if (unlikely(err)) {
2932 pr_err("%s: wc_AesEcbDecrypt failed for %u bytes: %d\n",
2933 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)), nbytes, err);
2934 err = -EINVAL;
2935 goto out;
2936 }
2937
2938 nbytes &= WC_AES_BLOCK_SIZE - 1;
2939 err = skcipher_walk_done(&walk, nbytes);
2940 }
2941
2942out:
2943
2944 if (err && walk.nbytes)
2945 (void)skcipher_walk_done(&walk, err);
2946
2947 #ifdef WOLFKM_DEBUG_AES
2948 pr_info("info: exiting km_AesEcbDecrypt: err %d, cryptlen %d\n", err,
2949 req->cryptlen);
2950 #endif /* WOLFKM_DEBUG_AES */
2951
2952 return err;
2953}
2954
2955static struct skcipher_alg ecbAesAlg = {
2956 .base.cra_name = WOLFKM_AESECB_NAME,
2957 .base.cra_driver_name = WOLFKM_AESECB_DRIVER,
2958 .base.cra_priority = WOLFSSL_LINUXKM_LKCAPI_PRIORITY,
2959 .base.cra_blocksize = WC_AES_BLOCK_SIZE,
2960 .base.cra_ctxsize = sizeof(struct km_AesCtx),
2961 .base.cra_module = THIS_MODULE,
2962 .init = km_AesEcbInit,
2963 .exit = km_AesExit,
2964 .min_keysize = AES_128_KEY_SIZE,
2965 .max_keysize = AES_256_KEY_SIZE,
2966 .ivsize = 0,
2967 .setkey = km_AesEcbSetKey,
2968 .encrypt = km_AesEcbEncrypt,
2969 .decrypt = km_AesEcbDecrypt,
2970};
2971static int ecbAesAlg_loaded = 0;
2972
2973#endif /* LINUXKM_LKCAPI_REGISTER_AESECB */
2974
2975/* cipher tests, cribbed from test.c, with supplementary LKCAPI tests: */
2976
2977#ifdef LINUXKM_LKCAPI_REGISTER_AESCBC
2978
2979static int linuxkm_test_aescbc(void)
2980{
2981 int ret = 0;
2982 struct crypto_skcipher * tfm = NULL;
2983 struct skcipher_request * req = NULL;
2984 struct scatterlist src, dst;
2985 Aes *aes;
2986 int aes_inited = 0;
2987 static const byte key32[] =
2988 {
2989 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2990 0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
2991 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2992 0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66
2993 };
2994 static const byte p_vector[] =
2995 /* Now is the time for all good men w/o trailing 0 */
2996 {
2997 0x4e,0x6f,0x77,0x20,0x69,0x73,0x20,0x74,
2998 0x68,0x65,0x20,0x74,0x69,0x6d,0x65,0x20,
2999 0x66,0x6f,0x72,0x20,0x61,0x6c,0x6c,0x20,
3000 0x67,0x6f,0x6f,0x64,0x20,0x6d,0x65,0x6e
3001 };
3002 static const byte iv[] = "1234567890abcdef";
3003
3004 static const byte c_vector[] =
3005 {
3006 0xd7,0xd6,0x04,0x5b,0x4d,0xc4,0x90,0xdf,
3007 0x4a,0x82,0xed,0x61,0x26,0x4e,0x23,0xb3,
3008 0xe4,0xb5,0x85,0x30,0x29,0x4c,0x9d,0xcf,
3009 0x73,0xc9,0x46,0xd1,0xaa,0xc8,0xcb,0x62
3010 };
3011
3012 byte iv_copy[sizeof(iv)];
3013 byte enc[sizeof(p_vector)];
3014 byte dec[sizeof(p_vector)];
3015 u8 * enc2 = NULL;
3016 u8 * dec2 = NULL;
3017
3018 aes = (Aes *)malloc(sizeof(*aes));
3019 if (aes == NULL)
3020 return MEMORY_E;
3021
3022 XMEMSET(enc, 0, sizeof(enc));
3023 XMEMSET(dec, 0, sizeof(enc));
3024
3025 ret = wc_AesInit(aes, NULL, INVALID_DEVID);
3026 if (ret) {
3027 pr_err("wolfcrypt wc_AesInit failed with return code %d.\n", ret);
3028 goto test_cbc_end;
3029 }
3030 aes_inited = 1;
3031
3032 ret = wc_AesSetKey(aes, key32, WC_AES_BLOCK_SIZE * 2, iv, AES_ENCRYPTION);
3033 if (ret) {
3034 pr_err("wolfcrypt wc_AesSetKey failed with return code %d\n", ret);
3035 goto test_cbc_end;
3036 }
3037
3038 ret = wc_AesCbcEncrypt(aes, enc, p_vector, sizeof(p_vector));
3039 if (ret) {
3040 pr_err("wolfcrypt wc_AesCbcEncrypt failed with return code %d\n", ret);
3041 goto test_cbc_end;
3042 }
3043
3044 if (XMEMCMP(enc, c_vector, sizeof(c_vector)) != 0) {
3045 pr_err("wolfcrypt wc_AesCbcEncrypt KAT mismatch\n");
3046 return LINUXKM_LKCAPI_AES_KAT_MISMATCH_E;
3047 }
3048
3049 /* Re init for decrypt and set flag. */
3050 wc_AesFree(aes);
3051 aes_inited = 0;
3052
3053 ret = wc_AesInit(aes, NULL, INVALID_DEVID);
3054 if (ret) {
3055 pr_err("wolfcrypt wc_AesInit failed with return code %d.\n", ret);
3056 goto test_cbc_end;
3057 }
3058 aes_inited = 1;
3059
3060 ret = wc_AesSetKey(aes, key32, WC_AES_BLOCK_SIZE * 2, iv, AES_DECRYPTION);
3061 if (ret) {
3062 pr_err("wolfcrypt wc_AesSetKey failed with return code %d.\n", ret);
3063 goto test_cbc_end;
3064 }
3065
3066 ret = wc_AesCbcDecrypt(aes, dec, enc, sizeof(p_vector));
3067 if (ret) {
3068 pr_err("wolfcrypt wc_AesCbcDecrypt failed with return code %d\n", ret);
3069 goto test_cbc_end;
3070 }
3071
3072 ret = XMEMCMP(p_vector, dec, sizeof(p_vector));
3073 if (ret) {
3074 pr_err("error: p_vector and dec do not match: %d\n", ret);
3075 goto test_cbc_end;
3076 }
3077
3078 /* now the kernel crypto part */
3079 enc2 = malloc(sizeof(p_vector));
3080 if (!enc2) {
3081 pr_err("error: malloc failed\n");
3082 goto test_cbc_end;
3083 }
3084
3085 dec2 = malloc(sizeof(p_vector));
3086 if (!dec2) {
3087 pr_err("error: malloc failed\n");
3088 goto test_cbc_end;
3089 }
3090
3091 memcpy(dec2, p_vector, sizeof(p_vector));
3092
3093 tfm = crypto_alloc_skcipher(WOLFKM_AESCBC_NAME, 0, 0);
3094 if (IS_ERR(tfm)) {
3095 pr_err("error: allocating AES skcipher algorithm %s failed: %ld\n",
3096 WOLFKM_AESCBC_DRIVER, PTR_ERR(tfm));
3097 tfm = NULL;
3098 goto test_cbc_end;
3099 }
3100
3101#ifndef LINUXKM_LKCAPI_PRIORITY_ALLOW_MASKING
3102 {
3103 const char *driver_name =
3104 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm));
3105 if (strcmp(driver_name, WOLFKM_AESCBC_DRIVER)) {
3106 pr_err("error: unexpected implementation for %s: %s (expected %s)\n",
3107 WOLFKM_AESCBC_NAME, driver_name, WOLFKM_AESCBC_DRIVER);
3108 ret = -ENOENT;
3109 goto test_cbc_end;
3110 }
3111 }
3112#endif
3113
3114 ret = crypto_skcipher_setkey(tfm, key32, WC_AES_BLOCK_SIZE * 2);
3115 if (ret) {
3116 pr_err("error: crypto_skcipher_setkey returned: %d\n", ret);
3117 goto test_cbc_end;
3118 }
3119
3120 req = skcipher_request_alloc(tfm, GFP_KERNEL);
3121 if (IS_ERR(req)) {
3122 pr_err("error: allocating AES skcipher request %s failed\n",
3123 WOLFKM_AESCBC_DRIVER);
3124 req = NULL;
3125 goto test_cbc_end;
3126 }
3127
3128 sg_init_one(&src, dec2, sizeof(p_vector));
3129 sg_init_one(&dst, enc2, sizeof(p_vector));
3130
3131 XMEMCPY(iv_copy, iv, sizeof(iv));
3132 skcipher_request_set_crypt(req, &src, &dst, sizeof(p_vector), iv_copy);
3133
3134 ret = crypto_skcipher_encrypt(req);
3135
3136 if (ret) {
3137 pr_err("error: crypto_skcipher_encrypt returned: %d\n", ret);
3138 goto test_cbc_end;
3139 }
3140
3141 ret = XMEMCMP(enc, enc2, sizeof(p_vector));
3142 if (ret) {
3143 pr_err("error: enc and enc2 do not match: %d\n", ret);
3144 goto test_cbc_end;
3145 }
3146
3147 memset(dec2, 0, sizeof(p_vector));
3148 sg_init_one(&src, enc2, sizeof(p_vector));
3149 sg_init_one(&dst, dec2, sizeof(p_vector));
3150
3151 XMEMCPY(iv_copy, iv, sizeof(iv));
3152 skcipher_request_set_crypt(req, &src, &dst, sizeof(p_vector), iv_copy);
3153
3154 ret = crypto_skcipher_decrypt(req);
3155
3156 if (ret) {
3157 pr_err("ERROR: crypto_skcipher_decrypt returned %d\n", ret);
3158 goto test_cbc_end;
3159 }
3160
3161 ret = XMEMCMP(dec, dec2, sizeof(p_vector));
3162 if (ret) {
3163 pr_err("error: dec and dec2 do not match: %d\n", ret);
3164 goto test_cbc_end;
3165 }
3166
3167test_cbc_end:
3168
3169 if (enc2) { free(enc2); }
3170 if (dec2) { free(dec2); }
3171 if (req) { skcipher_request_free(req); }
3172 if (tfm) { crypto_free_skcipher(tfm); }
3173
3174 if (aes_inited)
3175 wc_AesFree(aes);
3176 free(aes);
3177
3178 return ret;
3179}
3180
3181#endif /* LINUXKM_LKCAPI_REGISTER_AESCBC */
3182
3183#ifdef LINUXKM_LKCAPI_REGISTER_AESCFB
3184
3185static int linuxkm_test_aescfb(void)
3186{
3187 int ret = 0;
3188 struct crypto_skcipher * tfm = NULL;
3189 struct skcipher_request * req = NULL;
3190 struct scatterlist src, dst;
3191 Aes *aes;
3192 int aes_inited = 0;
3193 static const byte key32[] =
3194 {
3195 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
3196 0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
3197 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
3198 0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66
3199 };
3200 static const byte p_vector[] =
3201 /* Now is the time for all good men w/o trailing 0 */
3202 {
3203 0x4e,0x6f,0x77,0x20,0x69,0x73,0x20,0x74,
3204 0x68,0x65,0x20,0x74,0x69,0x6d,0x65,0x20,
3205 0x66,0x6f,0x72,0x20,0x61,0x6c,0x6c,0x20,
3206 0x67,0x6f,0x6f,0x64,0x20,0x6d,0x65,0x6e
3207 };
3208 static const byte iv[] = "1234567890abcdef";
3209 static const byte c_vector[] =
3210 {
3211 0x56,0x35,0x3f,0xdd,0xde,0xa6,0x15,0x87,
3212 0x57,0xdc,0x34,0x62,0x9a,0x68,0x96,0x51,
3213 0xc7,0x09,0xb9,0x4e,0x47,0x6b,0x24,0x72,
3214 0x19,0x5a,0xdf,0x7e,0xba,0xa8,0x01,0xb6
3215 };
3216 byte iv_copy[sizeof(iv)];
3217 byte enc[sizeof(p_vector)];
3218 byte dec[sizeof(p_vector)];
3219 u8 * enc2 = NULL;
3220 u8 * dec2 = NULL;
3221
3222 aes = (Aes *)malloc(sizeof(*aes));
3223 if (aes == NULL)
3224 return MEMORY_E;
3225
3226 ret = aes_cfb_test();
3227 if (ret) {
3228 wc_test_render_error_message("aes_cfb_test failed: ", ret);
3229 ret = WC_TEST_RET_DEC_EC(ret);
3230 goto test_cfb_end;
3231 }
3232
3233 XMEMSET(enc, 0, sizeof(enc));
3234 XMEMSET(dec, 0, sizeof(enc));
3235
3236 ret = wc_AesInit(aes, NULL, INVALID_DEVID);
3237 if (ret) {
3238 pr_err("wolfcrypt wc_AesInit failed with return code %d.\n", ret);
3239 goto test_cfb_end;
3240 }
3241 aes_inited = 1;
3242
3243 ret = wc_AesSetKey(aes, key32, WC_AES_BLOCK_SIZE * 2, iv, AES_ENCRYPTION);
3244 if (ret) {
3245 pr_err("wolfcrypt wc_AesSetKey failed with return code %d\n", ret);
3246 goto test_cfb_end;
3247 }
3248
3249 ret = wc_AesCfbEncrypt(aes, enc, p_vector, sizeof(p_vector));
3250 if (ret) {
3251 pr_err("wolfcrypt wc_AesCfbEncrypt failed with return code %d\n", ret);
3252 goto test_cfb_end;
3253 }
3254
3255 if (XMEMCMP(enc, c_vector, sizeof(c_vector)) != 0) {
3256 pr_err("wolfcrypt wc_AesCfbEncrypt KAT mismatch\n");
3257 return LINUXKM_LKCAPI_AES_KAT_MISMATCH_E;
3258 }
3259
3260 /* Re init for decrypt and set flag. */
3261 wc_AesFree(aes);
3262 aes_inited = 0;
3263
3264 ret = wc_AesInit(aes, NULL, INVALID_DEVID);
3265 if (ret) {
3266 pr_err("wolfcrypt wc_AesInit failed with return code %d.\n", ret);
3267 goto test_cfb_end;
3268 }
3269 aes_inited = 1;
3270
3271 ret = wc_AesSetKey(aes, key32, WC_AES_BLOCK_SIZE * 2, iv, AES_ENCRYPTION);
3272 if (ret) {
3273 pr_err("wolfcrypt wc_AesSetKey failed with return code %d.\n", ret);
3274 goto test_cfb_end;
3275 }
3276
3277 ret = wc_AesCfbDecrypt(aes, dec, enc, sizeof(p_vector));
3278 if (ret) {
3279 pr_err("wolfcrypt wc_AesCfbDecrypt failed with return code %d\n", ret);
3280 goto test_cfb_end;
3281 }
3282
3283 ret = XMEMCMP(p_vector, dec, sizeof(p_vector));
3284 if (ret) {
3285 pr_err("error: p_vector and dec do not match: %d\n", ret);
3286 goto test_cfb_end;
3287 }
3288
3289 /* now the kernel crypto part */
3290 enc2 = malloc(sizeof(p_vector));
3291 if (!enc2) {
3292 pr_err("error: malloc failed\n");
3293 goto test_cfb_end;
3294 }
3295
3296 dec2 = malloc(sizeof(p_vector));
3297 if (!dec2) {
3298 pr_err("error: malloc failed\n");
3299 goto test_cfb_end;
3300 }
3301
3302 memcpy(dec2, p_vector, sizeof(p_vector));
3303
3304 tfm = crypto_alloc_skcipher(WOLFKM_AESCFB_NAME, 0, 0);
3305 if (IS_ERR(tfm)) {
3306 pr_err("error: allocating AES skcipher algorithm %s failed: %ld\n",
3307 WOLFKM_AESCFB_DRIVER, PTR_ERR(tfm));
3308 tfm = NULL;
3309 goto test_cfb_end;
3310 }
3311
3312 ret = check_skcipher_driver_masking(tfm, WOLFKM_AESCFB_NAME, WOLFKM_AESCFB_DRIVER);
3313 if (ret)
3314 goto test_cfb_end;
3315
3316 ret = crypto_skcipher_setkey(tfm, key32, WC_AES_BLOCK_SIZE * 2);
3317 if (ret) {
3318 pr_err("error: crypto_skcipher_setkey returned: %d\n", ret);
3319 goto test_cfb_end;
3320 }
3321
3322 req = skcipher_request_alloc(tfm, GFP_KERNEL);
3323 if (IS_ERR(req)) {
3324 pr_err("error: allocating AES skcipher request %s failed\n",
3325 WOLFKM_AESCFB_DRIVER);
3326 req = NULL;
3327 goto test_cfb_end;
3328 }
3329
3330 sg_init_one(&src, dec2, sizeof(p_vector));
3331 sg_init_one(&dst, enc2, sizeof(p_vector));
3332
3333 XMEMCPY(iv_copy, iv, sizeof(iv));
3334 skcipher_request_set_crypt(req, &src, &dst, sizeof(p_vector), iv_copy);
3335
3336 ret = crypto_skcipher_encrypt(req);
3337
3338 if (ret) {
3339 pr_err("error: crypto_skcipher_encrypt returned: %d\n", ret);
3340 goto test_cfb_end;
3341 }
3342
3343 ret = XMEMCMP(enc, enc2, sizeof(p_vector));
3344 if (ret) {
3345 pr_err("error: enc and enc2 do not match: %d\n", ret);
3346 goto test_cfb_end;
3347 }
3348
3349 memset(dec2, 0, sizeof(p_vector));
3350 sg_init_one(&src, enc2, sizeof(p_vector));
3351 sg_init_one(&dst, dec2, sizeof(p_vector));
3352
3353 XMEMCPY(iv_copy, iv, sizeof(iv));
3354 skcipher_request_set_crypt(req, &src, &dst, sizeof(p_vector), iv_copy);
3355
3356 ret = crypto_skcipher_decrypt(req);
3357
3358 if (ret) {
3359 pr_err("error: crypto_skcipher_decrypt returned: %d\n", ret);
3360 goto test_cfb_end;
3361 }
3362
3363 ret = XMEMCMP(dec, dec2, sizeof(p_vector));
3364 if (ret) {
3365 pr_err("error: dec and dec2 do not match: %d\n", ret);
3366 goto test_cfb_end;
3367 }
3368
3369test_cfb_end:
3370
3371 if (enc2) { free(enc2); }
3372 if (dec2) { free(dec2); }
3373 if (req) { skcipher_request_free(req); }
3374 if (tfm) { crypto_free_skcipher(tfm); }
3375
3376 if (aes_inited)
3377 wc_AesFree(aes);
3378 free(aes);
3379
3380 return ret;
3381}
3382
3383#endif /* LINUXKM_LKCAPI_REGISTER_AESCFB */
3384
3385#ifdef LINUXKM_LKCAPI_REGISTER_AESGCM
3386
3387static int linuxkm_test_aesgcm(void)
3388{
3389#ifndef WOLFSSL_AESGCM_STREAM
3390 wc_test_ret_t ret = aesgcm_test();
3391 if (ret >= 0)
3392 return check_aead_driver_masking(NULL /* tfm */, WOLFKM_AESGCM_NAME, WOLFKM_AESGCM_DRIVER);
3393 else {
3394 wc_test_render_error_message("aesgcm_test failed: ", ret);
3395 return WC_TEST_RET_DEC_EC(ret);
3396 }
3397#else
3398 int ret = 0;
3399 struct crypto_aead * tfm = NULL;
3400 struct aead_request * req = NULL;
3401 struct scatterlist * src = NULL;
3402 struct scatterlist * dst = NULL;
3403 Aes *aes;
3404 int aes_inited = 0;
3405 static const byte key32[] =
3406 {
3407 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
3408 0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
3409 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
3410 0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66
3411 };
3412 static const byte p_vector[] =
3413 /* Now is the time for all w/o trailing 0 */
3414 {
3415 0x4e,0x6f,0x77,0x20,0x69,0x73,0x20,0x74,
3416 0x68,0x65,0x20,0x74,0x69,0x6d,0x65,0x20,
3417 0x66,0x6f,0x72,0x20,0x61,0x6c,0x6c,0x20
3418 };
3419 static const byte assoc[] =
3420 {
3421 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
3422 0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
3423 0xab, 0xad, 0xda, 0xd2
3424 };
3425 static const byte ivstr[] = "1234567890ab";
3426 static const byte c_vector[] =
3427 {
3428 0x80,0xb9,0x00,0xdc,0x03,0xb8,0x0e,0xaa,
3429 0x98,0x09,0x75,0x01,0x40,0x09,0xb0,0xc3,
3430 0x7a,0xed,0x2c,0x2e,0x4d,0xe5,0xca,0x80
3431 };
3432 static const byte KAT_authTag[] =
3433 {
3434 0x8d,0xf5,0x76,0xae,0x53,0x20,0x5d,0x9c,
3435 0x01,0x64,0xcd,0xf2,0xec,0x7a,0x13,0x03
3436 };
3437 byte enc[sizeof(p_vector)];
3438 byte authTag[WC_AES_BLOCK_SIZE];
3439 byte dec[sizeof(p_vector)];
3440 u8 * assoc2 = NULL;
3441 u8 * enc2 = NULL;
3442 u8 * dec2 = NULL;
3443 u8 * iv = NULL;
3444 size_t encryptLen = sizeof(p_vector);
3445 size_t decryptLen = sizeof(p_vector) + sizeof(authTag);
3446
3447 /* Init stack variables. */
3448 XMEMSET(enc, 0, sizeof(p_vector));
3449 XMEMSET(dec, 0, sizeof(p_vector));
3450 XMEMSET(authTag, 0, WC_AES_BLOCK_SIZE);
3451
3452 aes = (Aes *)malloc(sizeof(*aes));
3453 if (aes == NULL)
3454 return MEMORY_E;
3455
3456 ret = wc_AesInit(aes, NULL, INVALID_DEVID);
3457 if (ret) {
3458 pr_err("error: wc_AesInit failed with return code %d.\n", ret);
3459 goto test_gcm_end;
3460 }
3461 aes_inited = 1;
3462
3463 ret = wc_AesGcmInit(aes, key32, sizeof(key32)/sizeof(byte), ivstr,
3464 GCM_NONCE_MID_SZ);
3465 if (ret) {
3466 pr_err("error: wc_AesGcmInit failed with return code %d.\n", ret);
3467 goto test_gcm_end;
3468 }
3469
3470 ret = wc_AesGcmEncryptUpdate(aes, NULL, NULL, 0, assoc, sizeof(assoc));
3471 if (ret) {
3472 pr_err("error: wc_AesGcmEncryptUpdate failed with return code %d\n",
3473 ret);
3474 goto test_gcm_end;
3475 }
3476
3477 ret = wc_AesGcmEncryptUpdate(aes, enc, p_vector, sizeof(p_vector), NULL, 0);
3478 if (ret) {
3479 pr_err("error: wc_AesGcmEncryptUpdate failed with return code %d\n",
3480 ret);
3481 goto test_gcm_end;
3482 }
3483
3484 if (XMEMCMP(enc, c_vector, sizeof(c_vector)) != 0) {
3485 pr_err("wolfcrypt AES-GCM KAT mismatch on ciphertext\n");
3486 ret = LINUXKM_LKCAPI_AESGCM_KAT_MISMATCH_E;
3487 goto test_gcm_end;
3488 }
3489
3490 ret = wc_AesGcmEncryptFinal(aes, authTag, WC_AES_BLOCK_SIZE);
3491 if (ret) {
3492 pr_err("error: wc_AesGcmEncryptFinal failed with return code %d\n",
3493 ret);
3494 goto test_gcm_end;
3495 }
3496
3497 if (XMEMCMP(authTag, KAT_authTag, sizeof(KAT_authTag)) != 0) {
3498 pr_err("wolfcrypt AES-GCM KAT mismatch on authTag\n");
3499 ret = LINUXKM_LKCAPI_AESGCM_KAT_MISMATCH_E;
3500 goto test_gcm_end;
3501 }
3502
3503 ret = wc_AesGcmInit(aes, key32, sizeof(key32)/sizeof(byte), ivstr,
3504 GCM_NONCE_MID_SZ);
3505 if (ret) {
3506 pr_err("error: wc_AesGcmInit failed with return code %d.\n", ret);
3507 goto test_gcm_end;
3508 }
3509
3510 ret = wc_AesGcmDecryptUpdate(aes, dec, enc, sizeof(p_vector),
3511 assoc, sizeof(assoc));
3512 if (ret) {
3513 pr_err("error: wc_AesGcmDecryptUpdate failed with return code %d\n",
3514 ret);
3515 goto test_gcm_end;
3516 }
3517
3518 ret = wc_AesGcmDecryptFinal(aes, authTag, WC_AES_BLOCK_SIZE);
3519 if (ret) {
3520 pr_err("error: wc_AesGcmEncryptFinal failed with return code %d\n",
3521 ret);
3522 goto test_gcm_end;
3523 }
3524
3525 ret = XMEMCMP(p_vector, dec, sizeof(p_vector));
3526 if (ret) {
3527 pr_err("error: gcm: p_vector and dec do not match: %d\n", ret);
3528 goto test_gcm_end;
3529 }
3530
3531 /* now the kernel crypto part */
3532 assoc2 = malloc(sizeof(assoc));
3533 if (! assoc2) {
3534 pr_err("error: malloc failed\n");
3535 goto test_gcm_end;
3536 }
3537 memset(assoc2, 0, sizeof(assoc));
3538 memcpy(assoc2, assoc, sizeof(assoc));
3539
3540 iv = malloc(WC_AES_BLOCK_SIZE);
3541 if (! iv) {
3542 pr_err("error: malloc failed\n");
3543 goto test_gcm_end;
3544 }
3545 memset(iv, 0, WC_AES_BLOCK_SIZE);
3546 memcpy(iv, ivstr, GCM_NONCE_MID_SZ);
3547
3548 enc2 = malloc(decryptLen);
3549 if (! enc2) {
3550 pr_err("error: malloc failed\n");
3551 goto test_gcm_end;
3552 }
3553
3554 dec2 = malloc(decryptLen);
3555 if (! dec2) {
3556 pr_err("error: malloc failed\n");
3557 goto test_gcm_end;
3558 }
3559
3560 memset(enc2, 0, decryptLen);
3561 memset(dec2, 0, decryptLen);
3562 memcpy(dec2, p_vector, sizeof(p_vector));
3563
3564 tfm = crypto_alloc_aead(WOLFKM_AESGCM_NAME, 0, 0);
3565 if (IS_ERR(tfm)) {
3566 pr_err("error: allocating AES skcipher algorithm %s failed: %ld\n",
3567 WOLFKM_AESGCM_DRIVER, PTR_ERR(tfm));
3568 tfm = NULL;
3569 goto test_gcm_end;
3570 }
3571
3572 ret = check_aead_driver_masking(tfm, WOLFKM_AESGCM_NAME, WOLFKM_AESGCM_DRIVER);
3573 if (ret)
3574 goto test_gcm_end;
3575
3576 ret = crypto_aead_setkey(tfm, key32, WC_AES_BLOCK_SIZE * 2);
3577 if (ret) {
3578 pr_err("error: crypto_aead_setkey returned: %d\n", ret);
3579 goto test_gcm_end;
3580 }
3581
3582 ret = crypto_aead_setauthsize(tfm, sizeof(authTag));
3583 if (ret) {
3584 pr_err("error: crypto_aead_setauthsize returned: %d\n", ret);
3585 goto test_gcm_end;
3586 }
3587
3588 req = aead_request_alloc(tfm, GFP_KERNEL);
3589 if (IS_ERR(req)) {
3590 pr_err("error: allocating AES aead request %s failed: %ld\n",
3591 WOLFKM_AESCBC_DRIVER, PTR_ERR(req));
3592 req = NULL;
3593 goto test_gcm_end;
3594 }
3595
3596 src = malloc(sizeof(struct scatterlist) * 2);
3597
3598 if (! src) {
3599 pr_err("error: malloc src failed: %ld\n",
3600 PTR_ERR(src));
3601 goto test_gcm_end;
3602 }
3603
3604 dst = malloc(sizeof(struct scatterlist) * 2);
3605
3606 if (! dst) {
3607 pr_err("error: malloc dst failed: %ld\n",
3608 PTR_ERR(dst));
3609 goto test_gcm_end;
3610 }
3611
3612 sg_init_table(src, 2);
3613 sg_set_buf(src, assoc2, sizeof(assoc));
3614 sg_set_buf(&src[1], dec2, sizeof(p_vector));
3615
3616 sg_init_table(dst, 2);
3617 sg_set_buf(dst, assoc2, sizeof(assoc));
3618 sg_set_buf(&dst[1], enc2, decryptLen);
3619
3620 aead_request_set_callback(req, 0, NULL, NULL);
3621 aead_request_set_ad(req, sizeof(assoc));
3622 aead_request_set_crypt(req, src, dst, sizeof(p_vector), iv);
3623
3624 ret = crypto_aead_encrypt(req);
3625
3626 if (ret) {
3627 pr_err("error: crypto_aead_encrypt returned: %d\n", ret);
3628 goto test_gcm_end;
3629 }
3630
3631 ret = XMEMCMP(enc, enc2, sizeof(p_vector));
3632 if (ret) {
3633 pr_err("error: enc and enc2 do not match: %d\n", ret);
3634 goto test_gcm_end;
3635 }
3636
3637 ret = XMEMCMP(authTag, enc2 + encryptLen, sizeof(authTag));
3638 if (ret) {
3639 pr_err("error: authTags do not match: %d\n", ret);
3640 goto test_gcm_end;
3641 }
3642
3643 /* Now decrypt crypto request. Reverse src and dst. */
3644 memset(dec2, 0, decryptLen);
3645 aead_request_set_ad(req, sizeof(assoc));
3646 aead_request_set_crypt(req, dst, src, decryptLen, iv);
3647
3648 ret = crypto_aead_decrypt(req);
3649
3650 if (ret) {
3651 pr_err("error: crypto_aead_decrypt returned: %d\n", ret);
3652 goto test_gcm_end;
3653 }
3654
3655 ret = XMEMCMP(dec, dec2, sizeof(p_vector));
3656 if (ret) {
3657 pr_err("error: dec and dec2 do not match: %d\n", ret);
3658 goto test_gcm_end;
3659 }
3660
3661test_gcm_end:
3662 if (req) { aead_request_free(req); req = NULL; }
3663 if (tfm) { crypto_free_aead(tfm); tfm = NULL; }
3664
3665 if (src) { free(src); src = NULL; }
3666 if (dst) { free(dst); dst = NULL; }
3667
3668 if (dec2) { free(dec2); dec2 = NULL; }
3669 if (enc2) { free(enc2); enc2 = NULL; }
3670
3671 if (assoc2) { free(assoc2); assoc2 = NULL; }
3672 if (iv) { free(iv); iv = NULL; }
3673
3674 if (aes_inited)
3675 wc_AesFree(aes);
3676 free(aes);
3677
3678 return ret;
3679#endif /* WOLFSSL_AESGCM_STREAM */
3680}
3681
3682#endif /* LINUXKM_LKCAPI_REGISTER_AESGCM */
3683
3684#ifdef LINUXKM_LKCAPI_REGISTER_AESGCM_RFC4106
3685
3686static int linuxkm_test_aesgcm_rfc4106(void)
3687{
3688 wc_test_ret_t ret = aesgcm_test();
3689 if (ret >= 0)
3690 return check_aead_driver_masking(NULL /* tfm */, WOLFKM_AESGCM_RFC4106_NAME, WOLFKM_AESGCM_RFC4106_DRIVER);
3691 else {
3692 wc_test_render_error_message("aesgcm_test failed: ", ret);
3693 return WC_TEST_RET_DEC_EC(ret);
3694 }
3695}
3696
3697#endif /* LINUXKM_LKCAPI_REGISTER_AESGCM_RFC4106 */
3698
3699#if defined(LINUXKM_LKCAPI_REGISTER_AESCCM) || defined(LINUXKM_LKCAPI_REGISTER_AESCCM_RFC4309)
3700
3701static int aesccm_test_once(void) {
3702 static int once = 0;
3703 static int ret;
3704 if (! once) {
3705 ret = aesccm_test();
3706 once = 1;
3707 }
3708 return ret;
3709}
3710
3711#ifdef LINUXKM_LKCAPI_REGISTER_AESCCM
3712
3713static int linuxkm_test_aesccm(void) {
3714 return aesccm_test_once();
3715}
3716
3717#endif /* LINUXKM_LKCAPI_REGISTER_AESCCM */
3718
3719#ifdef LINUXKM_LKCAPI_REGISTER_AESCCM_RFC4309
3720
3721static int linuxkm_test_aesccm_rfc4309(void) {
3722 return aesccm_test_once();
3723}
3724
3725#endif /* LINUXKM_LKCAPI_REGISTER_AESCCM_RFC4309 */
3726
3727#endif /* LINUXKM_LKCAPI_REGISTER_AESCCM || LINUXKM_LKCAPI_REGISTER_AESCCM_RFC4309 */
3728
3729#ifdef LINUXKM_LKCAPI_REGISTER_AESXTS
3730
3731/* test vectors from
3732 * http://csrc.nist.gov/groups/STM/cavp/block-cipher-modes.html
3733 */
3734#ifdef WOLFSSL_AES_128
3735static int aes_xts_128_test(void)
3736{
3737 XtsAes *aes = NULL;
3738 int aes_inited = 0;
3739 int ret = 0;
3740#define AES_XTS_128_TEST_BUF_SIZ (WC_AES_BLOCK_SIZE * 2 + 8)
3741 unsigned char *buf = NULL;
3742 unsigned char *cipher = NULL;
3743 u8 * enc2 = NULL;
3744 u8 * dec2 = NULL;
3745 struct scatterlist * src = NULL;
3746 struct scatterlist * dst = NULL;
3747 struct crypto_skcipher *tfm = NULL;
3748 struct skcipher_request *req = NULL;
3749 struct XtsAesStreamData stream;
3750 byte* large_input = NULL;
3751
3752 /* 128 key tests */
3753 static const unsigned char k1[] = {
3754 0xa1, 0xb9, 0x0c, 0xba, 0x3f, 0x06, 0xac, 0x35,
3755 0x3b, 0x2c, 0x34, 0x38, 0x76, 0x08, 0x17, 0x62,
3756 0x09, 0x09, 0x23, 0x02, 0x6e, 0x91, 0x77, 0x18,
3757 0x15, 0xf2, 0x9d, 0xab, 0x01, 0x93, 0x2f, 0x2f
3758 };
3759
3760 static const unsigned char i1[] = {
3761 0x4f, 0xae, 0xf7, 0x11, 0x7c, 0xda, 0x59, 0xc6,
3762 0x6e, 0x4b, 0x92, 0x01, 0x3e, 0x76, 0x8a, 0xd5
3763 };
3764
3765 static const unsigned char p1[] = {
3766 0xeb, 0xab, 0xce, 0x95, 0xb1, 0x4d, 0x3c, 0x8d,
3767 0x6f, 0xb3, 0x50, 0x39, 0x07, 0x90, 0x31, 0x1c
3768 };
3769
3770 /* plain text test of partial block is not from NIST test vector list */
3771 static const unsigned char pp[] = {
3772 0xeb, 0xab, 0xce, 0x95, 0xb1, 0x4d, 0x3c, 0x8d,
3773 0x6f, 0xb3, 0x50, 0x39, 0x07, 0x90, 0x31, 0x1c,
3774 0x6e, 0x4b, 0x92, 0x01, 0x3e, 0x76, 0x8a, 0xd5
3775 };
3776
3777 static const unsigned char c1[] = {
3778 0x77, 0x8a, 0xe8, 0xb4, 0x3c, 0xb9, 0x8d, 0x5a,
3779 0x82, 0x50, 0x81, 0xd5, 0xbe, 0x47, 0x1c, 0x63
3780 };
3781
3782 /* plain text test of partial block is not from NIST test vector list */
3783 static const unsigned char cp[] = {
3784 0x2b, 0xf7, 0x2c, 0xf3, 0xeb, 0x85, 0xef, 0x7b,
3785 0x0b, 0x76, 0xa0, 0xaa, 0xf3, 0x3f, 0x25, 0x8b,
3786 0x77, 0x8a, 0xe8, 0xb4, 0x3c, 0xb9, 0x8d, 0x5a
3787 };
3788
3789 static const unsigned char k2[] = {
3790 0x39, 0x25, 0x79, 0x05, 0xdf, 0xcc, 0x77, 0x76,
3791 0x6c, 0x87, 0x0a, 0x80, 0x6a, 0x60, 0xe3, 0xc0,
3792 0x93, 0xd1, 0x2a, 0xcf, 0xcb, 0x51, 0x42, 0xfa,
3793 0x09, 0x69, 0x89, 0x62, 0x5b, 0x60, 0xdb, 0x16
3794 };
3795
3796 static const unsigned char i2[] = {
3797 0x5c, 0xf7, 0x9d, 0xb6, 0xc5, 0xcd, 0x99, 0x1a,
3798 0x1c, 0x78, 0x81, 0x42, 0x24, 0x95, 0x1e, 0x84
3799 };
3800
3801 static const unsigned char p2[] = {
3802 0xbd, 0xc5, 0x46, 0x8f, 0xbc, 0x8d, 0x50, 0xa1,
3803 0x0d, 0x1c, 0x85, 0x7f, 0x79, 0x1c, 0x5c, 0xba,
3804 0xb3, 0x81, 0x0d, 0x0d, 0x73, 0xcf, 0x8f, 0x20,
3805 0x46, 0xb1, 0xd1, 0x9e, 0x7d, 0x5d, 0x8a, 0x56
3806 };
3807
3808 static const unsigned char c2[] = {
3809 0xd6, 0xbe, 0x04, 0x6d, 0x41, 0xf2, 0x3b, 0x5e,
3810 0xd7, 0x0b, 0x6b, 0x3d, 0x5c, 0x8e, 0x66, 0x23,
3811 0x2b, 0xe6, 0xb8, 0x07, 0xd4, 0xdc, 0xc6, 0x0e,
3812 0xff, 0x8d, 0xbc, 0x1d, 0x9f, 0x7f, 0xc8, 0x22
3813 };
3814
3815#ifndef HAVE_FIPS /* FIPS requires different keys for main and tweak. */
3816 static const unsigned char k3[] = {
3817 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
3818 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
3819 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
3820 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
3821 };
3822 static const unsigned char i3[] = {
3823 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
3824 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
3825 };
3826 static const unsigned char p3[] = {
3827 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
3828 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
3829 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
3830 0x20, 0xff, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
3831 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20
3832 };
3833 static const unsigned char c3[] = {
3834 0xA2, 0x07, 0x47, 0x76, 0x3F, 0xEC, 0x0C, 0x23,
3835 0x1B, 0xD0, 0xBD, 0x46, 0x9A, 0x27, 0x38, 0x12,
3836 0x95, 0x02, 0x3D, 0x5D, 0xC6, 0x94, 0x51, 0x36,
3837 0xA0, 0x85, 0xD2, 0x69, 0x6E, 0x87, 0x0A, 0xBF,
3838 0xB5, 0x5A, 0xDD, 0xCB, 0x80, 0xE0, 0xFC, 0xCD
3839 };
3840#endif /* HAVE_FIPS */
3841
3842 if ((aes = (XtsAes *)XMALLOC(sizeof(*aes), NULL, DYNAMIC_TYPE_AES))
3843 == NULL)
3844 {
3845 ret = MEMORY_E;
3846 goto out;
3847 }
3848
3849 if ((buf = (unsigned char *)XMALLOC(AES_XTS_128_TEST_BUF_SIZ, NULL,
3850 DYNAMIC_TYPE_AES)) == NULL)
3851 {
3852 ret = MEMORY_E;
3853 goto out;
3854 }
3855 if ((cipher = (unsigned char *)XMALLOC(AES_XTS_128_TEST_BUF_SIZ, NULL,
3856 DYNAMIC_TYPE_AES)) == NULL)
3857 {
3858 ret = MEMORY_E;
3859 goto out;
3860 }
3861
3862 XMEMSET(buf, 0, AES_XTS_128_TEST_BUF_SIZ);
3863 ret = wc_AesXtsInit(aes, NULL, INVALID_DEVID);
3864 if (ret != 0)
3865 goto out;
3866 else
3867 aes_inited = 1;
3868
3869 ret = wc_AesXtsSetKeyNoInit(aes, k2, sizeof(k2), AES_ENCRYPTION);
3870 if (ret != 0)
3871 goto out;
3872
3873 ret = wc_AesXtsEncrypt(aes, buf, p2, sizeof(p2), i2, sizeof(i2));
3874 if (ret != 0)
3875 goto out;
3876 if (XMEMCMP(c2, buf, sizeof(c2))) {
3877 ret = LINUXKM_LKCAPI_AES_KAT_MISMATCH_E;
3878 goto out;
3879 }
3880
3881#if defined(DEBUG_VECTOR_REGISTER_ACCESS) && defined(WC_C_DYNAMIC_FALLBACK)
3882 WC_DEBUG_SET_VECTOR_REGISTERS_RETVAL(WC_NO_ERR_TRACE(SYSLIB_FAILED_E));
3883 ret = wc_AesXtsEncrypt(aes, buf, p2, sizeof(p2), i2, sizeof(i2));
3884 WC_DEBUG_SET_VECTOR_REGISTERS_RETVAL(0);
3885 if (ret != 0)
3886 goto out;
3887 if (XMEMCMP(c2, buf, sizeof(c2))) {
3888 ret = LINUXKM_LKCAPI_AES_KAT_MISMATCH_E;
3889 goto out;
3890 }
3891#endif
3892
3893 XMEMSET(buf, 0, AES_XTS_128_TEST_BUF_SIZ);
3894
3895 ret = wc_AesXtsEncryptInit(aes, i2, sizeof(i2), &stream);
3896 if (ret != 0)
3897 goto out;
3898 ret = wc_AesXtsEncryptUpdate(aes, buf, p2, WC_AES_BLOCK_SIZE, &stream);
3899 if (ret != 0)
3900 goto out;
3901 ret = wc_AesXtsEncryptFinal(aes, buf + WC_AES_BLOCK_SIZE,
3902 p2 + WC_AES_BLOCK_SIZE,
3903 sizeof(p2) - WC_AES_BLOCK_SIZE, &stream);
3904 if (ret != 0)
3905 goto out;
3906 if (XMEMCMP(c2, buf, sizeof(c2))) {
3907 ret = LINUXKM_LKCAPI_AES_KAT_MISMATCH_E;
3908 goto out;
3909 }
3910
3911 XMEMSET(buf, 0, AES_XTS_128_TEST_BUF_SIZ);
3912
3913 ret = wc_AesXtsSetKeyNoInit(aes, k1, sizeof(k1), AES_ENCRYPTION);
3914 if (ret != 0)
3915 goto out;
3916 ret = wc_AesXtsEncrypt(aes, buf, p1, sizeof(p1), i1, sizeof(i1));
3917 if (ret != 0)
3918 goto out;
3919 if (XMEMCMP(c1, buf, WC_AES_BLOCK_SIZE)) {
3920 ret = LINUXKM_LKCAPI_AES_KAT_MISMATCH_E;
3921 goto out;
3922 }
3923
3924#if defined(DEBUG_VECTOR_REGISTER_ACCESS) && defined(WC_C_DYNAMIC_FALLBACK)
3925 WC_DEBUG_SET_VECTOR_REGISTERS_RETVAL(WC_NO_ERR_TRACE(SYSLIB_FAILED_E));
3926 ret = wc_AesXtsEncrypt(aes, buf, p1, sizeof(p1), i1, sizeof(i1));
3927 WC_DEBUG_SET_VECTOR_REGISTERS_RETVAL(0);
3928 if (ret != 0)
3929 goto out;
3930 if (XMEMCMP(c1, buf, WC_AES_BLOCK_SIZE)) {
3931 ret = LINUXKM_LKCAPI_AES_KAT_MISMATCH_E;
3932 goto out;
3933 }
3934#endif
3935
3936 /* partial block encryption test */
3937 XMEMSET(cipher, 0, AES_XTS_128_TEST_BUF_SIZ);
3938 ret = wc_AesXtsEncrypt(aes, cipher, pp, sizeof(pp), i1, sizeof(i1));
3939 if (ret != 0)
3940 goto out;
3941 if (XMEMCMP(cp, cipher, sizeof(cp))) {
3942 ret = LINUXKM_LKCAPI_AES_KAT_MISMATCH_E;
3943 goto out;
3944 }
3945
3946#if defined(DEBUG_VECTOR_REGISTER_ACCESS) && defined(WC_C_DYNAMIC_FALLBACK)
3947 WC_DEBUG_SET_VECTOR_REGISTERS_RETVAL(WC_NO_ERR_TRACE(SYSLIB_FAILED_E));
3948 XMEMSET(cipher, 0, AES_XTS_128_TEST_BUF_SIZ);
3949 ret = wc_AesXtsEncrypt(aes, cipher, pp, sizeof(pp), i1, sizeof(i1));
3950 WC_DEBUG_SET_VECTOR_REGISTERS_RETVAL(0);
3951 if (ret != 0)
3952 goto out;
3953 if (XMEMCMP(cp, cipher, sizeof(cp))) {
3954 ret = LINUXKM_LKCAPI_AES_KAT_MISMATCH_E;
3955 goto out;
3956 }
3957#endif
3958
3959 /* partial block decrypt test */
3960 XMEMSET(buf, 0, AES_XTS_128_TEST_BUF_SIZ);
3961 ret = wc_AesXtsSetKeyNoInit(aes, k1, sizeof(k1), AES_DECRYPTION);
3962 if (ret != 0)
3963 goto out;
3964 ret = wc_AesXtsDecrypt(aes, buf, cipher, sizeof(pp), i1, sizeof(i1));
3965 if (ret != 0)
3966 goto out;
3967 if (XMEMCMP(pp, buf, sizeof(pp))) {
3968 ret = LINUXKM_LKCAPI_AES_KAT_MISMATCH_E;
3969 goto out;
3970 }
3971
3972#if defined(DEBUG_VECTOR_REGISTER_ACCESS) && defined(WC_C_DYNAMIC_FALLBACK)
3973 WC_DEBUG_SET_VECTOR_REGISTERS_RETVAL(WC_NO_ERR_TRACE(SYSLIB_FAILED_E));
3974 XMEMSET(buf, 0, AES_XTS_128_TEST_BUF_SIZ);
3975 ret = wc_AesXtsDecrypt(aes, buf, cipher, sizeof(pp), i1, sizeof(i1));
3976 WC_DEBUG_SET_VECTOR_REGISTERS_RETVAL(0);
3977 if (ret != 0)
3978 goto out;
3979 if (XMEMCMP(pp, buf, sizeof(pp))) {
3980 ret = LINUXKM_LKCAPI_AES_KAT_MISMATCH_E;
3981 goto out;
3982 }
3983#endif
3984
3985 /* NIST decrypt test vector */
3986 XMEMSET(buf, 0, AES_XTS_128_TEST_BUF_SIZ);
3987 ret = wc_AesXtsDecrypt(aes, buf, c1, sizeof(c1), i1, sizeof(i1));
3988 if (ret != 0)
3989 goto out;
3990 if (XMEMCMP(p1, buf, WC_AES_BLOCK_SIZE)) {
3991 ret = LINUXKM_LKCAPI_AES_KAT_MISMATCH_E;
3992 goto out;
3993 }
3994
3995#if defined(DEBUG_VECTOR_REGISTER_ACCESS) && defined(WC_C_DYNAMIC_FALLBACK)
3996 WC_DEBUG_SET_VECTOR_REGISTERS_RETVAL(WC_NO_ERR_TRACE(SYSLIB_FAILED_E));
3997 XMEMSET(buf, 0, AES_XTS_128_TEST_BUF_SIZ);
3998 ret = wc_AesXtsDecrypt(aes, buf, c1, sizeof(c1), i1, sizeof(i1));
3999 WC_DEBUG_SET_VECTOR_REGISTERS_RETVAL(0);
4000 if (ret != 0)
4001 goto out;
4002 if (XMEMCMP(p1, buf, WC_AES_BLOCK_SIZE)) {
4003 ret = LINUXKM_LKCAPI_AES_KAT_MISMATCH_E;
4004 goto out;
4005 }
4006#endif
4007
4008 /* fail case with decrypting using wrong key */
4009 XMEMSET(buf, 0, AES_XTS_128_TEST_BUF_SIZ);
4010 ret = wc_AesXtsDecrypt(aes, buf, c2, sizeof(c2), i2, sizeof(i2));
4011 if (ret != 0)
4012 goto out;
4013 if (XMEMCMP(p2, buf, sizeof(p2)) == 0) { /* fail case with wrong key */
4014 ret = LINUXKM_LKCAPI_AES_KAT_MISMATCH_E;
4015 goto out;
4016 }
4017
4018 /* set correct key and retest */
4019 XMEMSET(buf, 0, AES_XTS_128_TEST_BUF_SIZ);
4020 ret = wc_AesXtsSetKeyNoInit(aes, k2, sizeof(k2), AES_DECRYPTION);
4021 if (ret != 0)
4022 goto out;
4023 ret = wc_AesXtsDecrypt(aes, buf, c2, sizeof(c2), i2, sizeof(i2));
4024 if (ret != 0)
4025 goto out;
4026 if (XMEMCMP(p2, buf, sizeof(p2))) {
4027 ret = LINUXKM_LKCAPI_AES_KAT_MISMATCH_E;
4028 goto out;
4029 }
4030
4031#ifndef HAVE_FIPS
4032
4033 /* Test ciphertext stealing in-place. */
4034 XMEMCPY(buf, p3, sizeof(p3));
4035 ret = wc_AesXtsSetKeyNoInit(aes, k3, sizeof(k3), AES_ENCRYPTION);
4036 if (ret != 0)
4037 goto out;
4038
4039 ret = wc_AesXtsEncrypt(aes, buf, buf, sizeof(p3), i3, sizeof(i3));
4040 if (ret != 0)
4041 goto out;
4042 if (XMEMCMP(c3, buf, sizeof(c3))) {
4043 ret = LINUXKM_LKCAPI_AES_KAT_MISMATCH_E;
4044 goto out;
4045 }
4046
4047 ret = wc_AesXtsSetKeyNoInit(aes, k3, sizeof(k3), AES_DECRYPTION);
4048 if (ret != 0)
4049 goto out;
4050 ret = wc_AesXtsDecrypt(aes, buf, buf, sizeof(c3), i3, sizeof(i3));
4051 if (ret != 0)
4052 goto out;
4053 if (XMEMCMP(p3, buf, sizeof(p3))) {
4054 ret = LINUXKM_LKCAPI_AES_KAT_MISMATCH_E;
4055 goto out;
4056 }
4057
4058#endif /* HAVE_FIPS */
4059
4060 {
4061 #define LARGE_XTS_SZ 1024
4062 int i;
4063 int j;
4064 int k;
4065
4066 large_input = (byte *)XMALLOC(LARGE_XTS_SZ, NULL,
4067 DYNAMIC_TYPE_TMP_BUFFER);
4068 if (large_input == NULL) {
4069 ret = MEMORY_E;
4070 goto out;
4071 }
4072
4073 for (i = 0; i < (int)LARGE_XTS_SZ; i++)
4074 large_input[i] = (byte)i;
4075
4076 /* first, encrypt block by block then decrypt with a one-shot call. */
4077 for (j = 16; j < (int)LARGE_XTS_SZ; j++) {
4078 ret = wc_AesXtsSetKeyNoInit(aes, k1, sizeof(k1), AES_ENCRYPTION);
4079 if (ret != 0)
4080 goto out;
4081 ret = wc_AesXtsEncryptInit(aes, i1, sizeof(i1), &stream);
4082 if (ret != 0)
4083 goto out;
4084 for (k = 0; k < j; k += WC_AES_BLOCK_SIZE) {
4085 if ((j - k) < WC_AES_BLOCK_SIZE*2)
4086 ret = wc_AesXtsEncryptFinal(aes, large_input + k, large_input + k, j - k, &stream);
4087 else
4088 ret = wc_AesXtsEncryptUpdate(aes, large_input + k, large_input + k, WC_AES_BLOCK_SIZE, &stream);
4089 if (ret != 0)
4090 goto out;
4091 if ((j - k) < WC_AES_BLOCK_SIZE*2)
4092 break;
4093 }
4094 ret = wc_AesXtsSetKeyNoInit(aes, k1, sizeof(k1), AES_DECRYPTION);
4095 if (ret != 0)
4096 goto out;
4097 ret = wc_AesXtsDecrypt(aes, large_input, large_input, j, i1,
4098 sizeof(i1));
4099 if (ret != 0)
4100 goto out;
4101 for (i = 0; i < j; i++) {
4102 if (large_input[i] != (byte)i) {
4103 ret = LINUXKM_LKCAPI_AES_KAT_MISMATCH_E;
4104 goto out;
4105 }
4106 }
4107 }
4108
4109 /* second, encrypt with a one-shot call then decrypt block by block. */
4110 for (j = 16; j < (int)LARGE_XTS_SZ; j++) {
4111 ret = wc_AesXtsSetKeyNoInit(aes, k1, sizeof(k1), AES_ENCRYPTION);
4112 if (ret != 0)
4113 goto out;
4114 ret = wc_AesXtsEncrypt(aes, large_input, large_input, j, i1,
4115 sizeof(i1));
4116 if (ret != 0)
4117 goto out;
4118 ret = wc_AesXtsSetKeyNoInit(aes, k1, sizeof(k1), AES_DECRYPTION);
4119 if (ret != 0)
4120 goto out;
4121 ret = wc_AesXtsDecryptInit(aes, i1, sizeof(i1), &stream);
4122 if (ret != 0)
4123 goto out;
4124 for (k = 0; k < j; k += WC_AES_BLOCK_SIZE) {
4125 if ((j - k) < WC_AES_BLOCK_SIZE*2)
4126 ret = wc_AesXtsDecryptFinal(aes, large_input + k, large_input + k, j - k, &stream);
4127 else
4128 ret = wc_AesXtsDecryptUpdate(aes, large_input + k, large_input + k, WC_AES_BLOCK_SIZE, &stream);
4129 if (ret != 0)
4130 goto out;
4131 if ((j - k) < WC_AES_BLOCK_SIZE*2)
4132 break;
4133 }
4134 for (i = 0; i < j; i++) {
4135 if (large_input[i] != (byte)i) {
4136 ret = LINUXKM_LKCAPI_AES_KAT_MISMATCH_E;
4137 goto out;
4138 }
4139 }
4140 }
4141 }
4142
4143 /* now the kernel crypto part */
4144
4145 enc2 = XMALLOC(sizeof(pp), NULL, DYNAMIC_TYPE_AES);
4146 if (!enc2) {
4147 pr_err("error: malloc failed\n");
4148 ret = -ENOMEM;
4149 goto test_xts_end;
4150 }
4151
4152 dec2 = XMALLOC(sizeof(pp), NULL, DYNAMIC_TYPE_AES);
4153 if (!dec2) {
4154 pr_err("error: malloc failed\n");
4155 ret = -ENOMEM;
4156 goto test_xts_end;
4157 }
4158
4159 src = XMALLOC(sizeof(*src) * 2, NULL, DYNAMIC_TYPE_AES);
4160 if (! src) {
4161 pr_err("error: malloc failed\n");
4162 ret = -ENOMEM;
4163 goto test_xts_end;
4164 }
4165
4166 dst = XMALLOC(sizeof(*dst) * 2, NULL, DYNAMIC_TYPE_AES);
4167 if (! dst) {
4168 pr_err("error: malloc failed\n");
4169 ret = -ENOMEM;
4170 goto test_xts_end;
4171 }
4172
4173 tfm = crypto_alloc_skcipher(WOLFKM_AESXTS_NAME, 0, 0);
4174 if (IS_ERR(tfm)) {
4175 ret = PTR_ERR(tfm);
4176 pr_err("error: allocating AES skcipher algorithm %s failed: %d\n",
4177 WOLFKM_AESXTS_DRIVER, ret);
4178 tfm = NULL;
4179 goto test_xts_end;
4180 }
4181
4182#ifndef LINUXKM_LKCAPI_PRIORITY_ALLOW_MASKING
4183 {
4184 const char *driver_name =
4185 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm));
4186 if (strcmp(driver_name, WOLFKM_AESXTS_DRIVER)) {
4187 pr_err("error: unexpected implementation for %s: %s (expected %s)\n",
4188 WOLFKM_AESXTS_NAME, driver_name, WOLFKM_AESXTS_DRIVER);
4189 ret = -ENOENT;
4190 goto test_xts_end;
4191 }
4192 }
4193#endif
4194
4195 ret = crypto_skcipher_ivsize(tfm);
4196 if (ret != sizeof(stream.tweak_block)) {
4197 pr_err("error: AES skcipher algorithm %s crypto_skcipher_ivsize()"
4198 " returned %d but expected %d\n",
4199 WOLFKM_AESXTS_DRIVER, ret, (int)sizeof(stream.tweak_block));
4200 ret = -EINVAL;
4201 goto test_xts_end;
4202 }
4203
4204 ret = crypto_skcipher_setkey(tfm, k1, sizeof(k1));
4205 if (ret) {
4206 pr_err("error: crypto_skcipher_setkey for %s returned: %d\n",
4207 WOLFKM_AESXTS_NAME, ret);
4208 goto test_xts_end;
4209 }
4210
4211 req = skcipher_request_alloc(tfm, GFP_KERNEL);
4212 if (IS_ERR(req)) {
4213 ret = PTR_ERR(req);
4214 pr_err("error: allocating AES skcipher request %s failed: %d\n",
4215 WOLFKM_AESXTS_DRIVER, ret);
4216 req = NULL;
4217 goto test_xts_end;
4218 }
4219
4220 memcpy(dec2, p1, sizeof(p1));
4221 memset(enc2, 0, sizeof(p1));
4222
4223 sg_init_one(src, dec2, sizeof(p1));
4224 sg_init_one(dst, enc2, sizeof(p1));
4225
4226 memcpy(stream.tweak_block, i1, sizeof(stream.tweak_block));
4227 skcipher_request_set_crypt(req, src, dst, sizeof(p1), stream.tweak_block);
4228
4229 ret = crypto_skcipher_encrypt(req);
4230
4231 if (ret) {
4232 pr_err("error: crypto_skcipher_encrypt returned: %d\n", ret);
4233 goto test_xts_end;
4234 }
4235
4236 ret = XMEMCMP(c1, enc2, sizeof(c1));
4237 if (ret) {
4238 pr_err("error: c1 and enc2 do not match: %d\n", ret);
4239 ret = -EINVAL;
4240 goto test_xts_end;
4241 }
4242
4243 memset(dec2, 0, sizeof(p1));
4244 sg_init_one(src, enc2, sizeof(p1));
4245 sg_init_one(dst, dec2, sizeof(p1));
4246
4247 memcpy(stream.tweak_block, i1, sizeof(stream.tweak_block));
4248 skcipher_request_set_crypt(req, src, dst, sizeof(p1), stream.tweak_block);
4249
4250 ret = crypto_skcipher_decrypt(req);
4251
4252 if (ret) {
4253 pr_err("ERROR: crypto_skcipher_decrypt returned %d\n", ret);
4254 goto test_xts_end;
4255 }
4256
4257 ret = XMEMCMP(p1, dec2, sizeof(p1));
4258 if (ret) {
4259 pr_err("error: p1 and dec2 do not match: %d\n", ret);
4260 ret = -EINVAL;
4261 goto test_xts_end;
4262 }
4263
4264 memcpy(dec2, pp, sizeof(pp));
4265 memset(enc2, 0, sizeof(pp));
4266
4267 sg_init_one(src, dec2, sizeof(pp));
4268 sg_init_one(dst, enc2, sizeof(pp));
4269
4270 memcpy(stream.tweak_block, i1, sizeof(stream.tweak_block));
4271 skcipher_request_set_crypt(req, src, dst, sizeof(pp), stream.tweak_block);
4272
4273 ret = crypto_skcipher_encrypt(req);
4274
4275 if (ret) {
4276 pr_err("error: crypto_skcipher_encrypt returned: %d\n", ret);
4277 goto test_xts_end;
4278 }
4279
4280 ret = XMEMCMP(cp, enc2, sizeof(cp));
4281 if (ret) {
4282 pr_err("error: cp and enc2 do not match: %d\n", ret);
4283 ret = -EINVAL;
4284 goto test_xts_end;
4285 }
4286
4287 memset(dec2, 0, sizeof(pp));
4288 sg_init_one(src, enc2, sizeof(pp));
4289 sg_init_one(dst, dec2, sizeof(pp));
4290
4291 memcpy(stream.tweak_block, i1, sizeof(stream.tweak_block));
4292 skcipher_request_set_crypt(req, src, dst, sizeof(pp), stream.tweak_block);
4293
4294 ret = crypto_skcipher_decrypt(req);
4295
4296 if (ret) {
4297 pr_err("ERROR: crypto_skcipher_decrypt returned %d\n", ret);
4298 goto test_xts_end;
4299 }
4300
4301 ret = XMEMCMP(pp, dec2, sizeof(pp));
4302 if (ret) {
4303 pr_err("error: pp and dec2 do not match: %d\n", ret);
4304 ret = -EINVAL;
4305 goto test_xts_end;
4306 }
4307
4308 test_xts_end:
4309
4310 XFREE(enc2, NULL, DYNAMIC_TYPE_AES);
4311 XFREE(dec2, NULL, DYNAMIC_TYPE_AES);
4312 XFREE(src, NULL, DYNAMIC_TYPE_AES);
4313 XFREE(dst, NULL, DYNAMIC_TYPE_AES);
4314 if (req)
4315 skcipher_request_free(req);
4316 if (tfm)
4317 crypto_free_skcipher(tfm);
4318
4319 out:
4320
4321 XFREE(large_input, NULL, DYNAMIC_TYPE_TMP_BUFFER);
4322
4323 if (aes_inited)
4324 wc_AesXtsFree(aes);
4325
4326 XFREE(buf, NULL, DYNAMIC_TYPE_AES);
4327 XFREE(cipher, NULL, DYNAMIC_TYPE_AES);
4328 XFREE(aes, NULL, DYNAMIC_TYPE_AES);
4329
4330#undef AES_XTS_128_TEST_BUF_SIZ
4331
4332 return ret;
4333}
4334#endif /* WOLFSSL_AES_128 */
4335
4336#ifdef WOLFSSL_AES_256
4337static int aes_xts_256_test(void)
4338{
4339 XtsAes *aes = NULL;
4340 int aes_inited = 0;
4341 int ret = 0;
4342#define AES_XTS_256_TEST_BUF_SIZ (WC_AES_BLOCK_SIZE * 3)
4343 unsigned char *buf = NULL;
4344 unsigned char *cipher = NULL;
4345 u8 * enc2 = NULL;
4346 u8 * dec2 = NULL;
4347 struct scatterlist * src = NULL;
4348 struct scatterlist * dst = NULL;
4349 struct crypto_skcipher *tfm = NULL;
4350 struct skcipher_request *req = NULL;
4351 struct XtsAesStreamData stream;
4352 byte* large_input = NULL;
4353
4354 /* 256 key tests */
4355 static const unsigned char k1[] = {
4356 0x1e, 0xa6, 0x61, 0xc5, 0x8d, 0x94, 0x3a, 0x0e,
4357 0x48, 0x01, 0xe4, 0x2f, 0x4b, 0x09, 0x47, 0x14,
4358 0x9e, 0x7f, 0x9f, 0x8e, 0x3e, 0x68, 0xd0, 0xc7,
4359 0x50, 0x52, 0x10, 0xbd, 0x31, 0x1a, 0x0e, 0x7c,
4360 0xd6, 0xe1, 0x3f, 0xfd, 0xf2, 0x41, 0x8d, 0x8d,
4361 0x19, 0x11, 0xc0, 0x04, 0xcd, 0xa5, 0x8d, 0xa3,
4362 0xd6, 0x19, 0xb7, 0xe2, 0xb9, 0x14, 0x1e, 0x58,
4363 0x31, 0x8e, 0xea, 0x39, 0x2c, 0xf4, 0x1b, 0x08
4364 };
4365
4366 static const unsigned char i1[] = {
4367 0xad, 0xf8, 0xd9, 0x26, 0x27, 0x46, 0x4a, 0xd2,
4368 0xf0, 0x42, 0x8e, 0x84, 0xa9, 0xf8, 0x75, 0x64
4369 };
4370
4371 static const unsigned char p1[] = {
4372 0x2e, 0xed, 0xea, 0x52, 0xcd, 0x82, 0x15, 0xe1,
4373 0xac, 0xc6, 0x47, 0xe8, 0x10, 0xbb, 0xc3, 0x64,
4374 0x2e, 0x87, 0x28, 0x7f, 0x8d, 0x2e, 0x57, 0xe3,
4375 0x6c, 0x0a, 0x24, 0xfb, 0xc1, 0x2a, 0x20, 0x2e
4376 };
4377
4378 static const unsigned char c1[] = {
4379 0xcb, 0xaa, 0xd0, 0xe2, 0xf6, 0xce, 0xa3, 0xf5,
4380 0x0b, 0x37, 0xf9, 0x34, 0xd4, 0x6a, 0x9b, 0x13,
4381 0x0b, 0x9d, 0x54, 0xf0, 0x7e, 0x34, 0xf3, 0x6a,
4382 0xf7, 0x93, 0xe8, 0x6f, 0x73, 0xc6, 0xd7, 0xdb
4383 };
4384
4385 /* plain text test of partial block is not from NIST test vector list */
4386 static const unsigned char pp[] = {
4387 0xeb, 0xab, 0xce, 0x95, 0xb1, 0x4d, 0x3c, 0x8d,
4388 0x6f, 0xb3, 0x50, 0x39, 0x07, 0x90, 0x31, 0x1c,
4389 0x6e, 0x4b, 0x92, 0x01, 0x3e, 0x76, 0x8a, 0xd5
4390 };
4391
4392 static const unsigned char cp[] = {
4393 0x65, 0x5e, 0x1d, 0x37, 0x4a, 0x91, 0xe7, 0x6c,
4394 0x4f, 0x83, 0x92, 0xbc, 0x5a, 0x10, 0x55, 0x27,
4395 0x61, 0x0e, 0x5a, 0xde, 0xca, 0xc5, 0x12, 0xd8
4396 };
4397
4398 static const unsigned char k2[] = {
4399 0xad, 0x50, 0x4b, 0x85, 0xd7, 0x51, 0xbf, 0xba,
4400 0x69, 0x13, 0xb4, 0xcc, 0x79, 0xb6, 0x5a, 0x62,
4401 0xf7, 0xf3, 0x9d, 0x36, 0x0f, 0x35, 0xb5, 0xec,
4402 0x4a, 0x7e, 0x95, 0xbd, 0x9b, 0xa5, 0xf2, 0xec,
4403 0xc1, 0xd7, 0x7e, 0xa3, 0xc3, 0x74, 0xbd, 0x4b,
4404 0x13, 0x1b, 0x07, 0x83, 0x87, 0xdd, 0x55, 0x5a,
4405 0xb5, 0xb0, 0xc7, 0xe5, 0x2d, 0xb5, 0x06, 0x12,
4406 0xd2, 0xb5, 0x3a, 0xcb, 0x47, 0x8a, 0x53, 0xb4
4407 };
4408
4409 static const unsigned char i2[] = {
4410 0xe6, 0x42, 0x19, 0xed, 0xe0, 0xe1, 0xc2, 0xa0,
4411 0x0e, 0xf5, 0x58, 0x6a, 0xc4, 0x9b, 0xeb, 0x6f
4412 };
4413
4414 static const unsigned char p2[] = {
4415 0x24, 0xcb, 0x76, 0x22, 0x55, 0xb5, 0xa8, 0x00,
4416 0xf4, 0x6e, 0x80, 0x60, 0x56, 0x9e, 0x05, 0x53,
4417 0xbc, 0xfe, 0x86, 0x55, 0x3b, 0xca, 0xd5, 0x89,
4418 0xc7, 0x54, 0x1a, 0x73, 0xac, 0xc3, 0x9a, 0xbd,
4419 0x53, 0xc4, 0x07, 0x76, 0xd8, 0xe8, 0x22, 0x61,
4420 0x9e, 0xa9, 0xad, 0x77, 0xa0, 0x13, 0x4c, 0xfc
4421 };
4422
4423 static const unsigned char c2[] = {
4424 0xa3, 0xc6, 0xf3, 0xf3, 0x82, 0x79, 0x5b, 0x10,
4425 0x87, 0xd7, 0x02, 0x50, 0xdb, 0x2c, 0xd3, 0xb1,
4426 0xa1, 0x62, 0xa8, 0xb6, 0xdc, 0x12, 0x60, 0x61,
4427 0xc1, 0x0a, 0x84, 0xa5, 0x85, 0x3f, 0x3a, 0x89,
4428 0xe6, 0x6c, 0xdb, 0xb7, 0x9a, 0xb4, 0x28, 0x9b,
4429 0xc3, 0xea, 0xd8, 0x10, 0xe9, 0xc0, 0xaf, 0x92
4430 };
4431
4432 if ((aes = (XtsAes *)XMALLOC(sizeof(*aes), NULL, DYNAMIC_TYPE_AES))
4433 == NULL)
4434 {
4435 ret = MEMORY_E;
4436 goto out;
4437 }
4438
4439 if ((buf = (unsigned char *)XMALLOC(AES_XTS_256_TEST_BUF_SIZ, NULL,
4440 DYNAMIC_TYPE_AES)) == NULL)
4441 {
4442 ret = MEMORY_E;
4443 goto out;
4444 }
4445 if ((cipher = (unsigned char *)XMALLOC(AES_XTS_256_TEST_BUF_SIZ, NULL,
4446 DYNAMIC_TYPE_AES)) == NULL)
4447 {
4448 ret = MEMORY_E;
4449 goto out;
4450 }
4451
4452 ret = wc_AesXtsInit(aes, NULL, INVALID_DEVID);
4453 if (ret != 0)
4454 goto out;
4455 else
4456 aes_inited = 1;
4457
4458 XMEMSET(buf, 0, AES_XTS_256_TEST_BUF_SIZ);
4459 ret = wc_AesXtsSetKeyNoInit(aes, k2, sizeof(k2), AES_ENCRYPTION);
4460 if (ret != 0)
4461 goto out;
4462
4463 ret = wc_AesXtsEncrypt(aes, buf, p2, sizeof(p2), i2, sizeof(i2));
4464 if (ret != 0)
4465 goto out;
4466 if (XMEMCMP(c2, buf, sizeof(c2))) {
4467 ret = LINUXKM_LKCAPI_AES_KAT_MISMATCH_E;
4468 goto out;
4469 }
4470
4471 XMEMSET(buf, 0, AES_XTS_256_TEST_BUF_SIZ);
4472
4473 ret = wc_AesXtsEncryptInit(aes, i2, sizeof(i2), &stream);
4474 if (ret != 0)
4475 goto out;
4476 ret = wc_AesXtsEncryptUpdate(aes, buf, p2, WC_AES_BLOCK_SIZE, &stream);
4477 if (ret != 0)
4478 goto out;
4479 ret = wc_AesXtsEncryptFinal(aes, buf + WC_AES_BLOCK_SIZE,
4480 p2 + WC_AES_BLOCK_SIZE,
4481 sizeof(p2) - WC_AES_BLOCK_SIZE, &stream);
4482 if (ret != 0)
4483 goto out;
4484 if (XMEMCMP(c2, buf, sizeof(c2))) {
4485 ret = LINUXKM_LKCAPI_AES_KAT_MISMATCH_E;
4486 goto out;
4487 }
4488
4489 XMEMSET(buf, 0, AES_XTS_256_TEST_BUF_SIZ);
4490 ret = wc_AesXtsSetKeyNoInit(aes, k1, sizeof(k1), AES_ENCRYPTION);
4491 if (ret != 0)
4492 goto out;
4493 ret = wc_AesXtsEncrypt(aes, buf, p1, sizeof(p1), i1, sizeof(i1));
4494 if (ret != 0)
4495 goto out;
4496 if (XMEMCMP(c1, buf, WC_AES_BLOCK_SIZE)) {
4497 ret = LINUXKM_LKCAPI_AES_KAT_MISMATCH_E;
4498 goto out;
4499 }
4500
4501 /* partial block encryption test */
4502 XMEMSET(cipher, 0, AES_XTS_256_TEST_BUF_SIZ);
4503 ret = wc_AesXtsEncrypt(aes, cipher, pp, sizeof(pp), i1, sizeof(i1));
4504 if (ret != 0)
4505 goto out;
4506
4507 /* partial block decrypt test */
4508 XMEMSET(buf, 0, AES_XTS_256_TEST_BUF_SIZ);
4509 ret = wc_AesXtsSetKeyNoInit(aes, k1, sizeof(k1), AES_DECRYPTION);
4510 if (ret != 0)
4511 goto out;
4512 ret = wc_AesXtsDecrypt(aes, buf, cipher, sizeof(pp), i1, sizeof(i1));
4513 if (ret != 0)
4514 goto out;
4515 if (XMEMCMP(pp, buf, sizeof(pp))) {
4516 ret = LINUXKM_LKCAPI_AES_KAT_MISMATCH_E;
4517 goto out;
4518 }
4519
4520 /* NIST decrypt test vector */
4521 XMEMSET(buf, 0, AES_XTS_256_TEST_BUF_SIZ);
4522 ret = wc_AesXtsDecrypt(aes, buf, c1, sizeof(c1), i1, sizeof(i1));
4523 if (ret != 0)
4524 goto out;
4525 if (XMEMCMP(p1, buf, WC_AES_BLOCK_SIZE)) {
4526 ret = LINUXKM_LKCAPI_AES_KAT_MISMATCH_E;
4527 goto out;
4528 }
4529
4530 XMEMSET(buf, 0, AES_XTS_256_TEST_BUF_SIZ);
4531 ret = wc_AesXtsSetKeyNoInit(aes, k2, sizeof(k2), AES_DECRYPTION);
4532 if (ret != 0)
4533 goto out;
4534 ret = wc_AesXtsDecrypt(aes, buf, c2, sizeof(c2), i2, sizeof(i2));
4535 if (ret != 0)
4536 goto out;
4537 if (XMEMCMP(p2, buf, sizeof(p2))) {
4538 ret = LINUXKM_LKCAPI_AES_KAT_MISMATCH_E;
4539 goto out;
4540 }
4541
4542 {
4543 #define LARGE_XTS_SZ 1024
4544 int i;
4545 int j;
4546 int k;
4547
4548 large_input = (byte *)XMALLOC(LARGE_XTS_SZ, NULL,
4549 DYNAMIC_TYPE_TMP_BUFFER);
4550 if (large_input == NULL) {
4551 ret = MEMORY_E;
4552 goto out;
4553 }
4554
4555 for (i = 0; i < (int)LARGE_XTS_SZ; i++)
4556 large_input[i] = (byte)i;
4557
4558 /* first, encrypt block by block then decrypt with a one-shot call. */
4559 for (j = 16; j < (int)LARGE_XTS_SZ; j++) {
4560 ret = wc_AesXtsSetKeyNoInit(aes, k1, sizeof(k1), AES_ENCRYPTION);
4561 if (ret != 0)
4562 goto out;
4563 ret = wc_AesXtsEncryptInit(aes, i1, sizeof(i1), &stream);
4564 if (ret != 0)
4565 goto out;
4566 for (k = 0; k < j; k += WC_AES_BLOCK_SIZE) {
4567 if ((j - k) < WC_AES_BLOCK_SIZE*2)
4568 ret = wc_AesXtsEncryptFinal(aes, large_input + k, large_input + k, j - k, &stream);
4569 else
4570 ret = wc_AesXtsEncryptUpdate(aes, large_input + k, large_input + k, WC_AES_BLOCK_SIZE, &stream);
4571 if (ret != 0)
4572 goto out;
4573 if ((j - k) < WC_AES_BLOCK_SIZE*2)
4574 break;
4575 }
4576 ret = wc_AesXtsSetKeyNoInit(aes, k1, sizeof(k1), AES_DECRYPTION);
4577 if (ret != 0)
4578 goto out;
4579 ret = wc_AesXtsDecrypt(aes, large_input, large_input, j, i1,
4580 sizeof(i1));
4581 if (ret != 0)
4582 goto out;
4583 for (i = 0; i < j; i++) {
4584 if (large_input[i] != (byte)i) {
4585 ret = LINUXKM_LKCAPI_AES_KAT_MISMATCH_E;
4586 goto out;
4587 }
4588 }
4589 }
4590
4591 /* second, encrypt with a one-shot call then decrypt block by block. */
4592 for (j = 16; j < (int)LARGE_XTS_SZ; j++) {
4593 ret = wc_AesXtsSetKeyNoInit(aes, k1, sizeof(k1), AES_ENCRYPTION);
4594 if (ret != 0)
4595 goto out;
4596 ret = wc_AesXtsEncrypt(aes, large_input, large_input, j, i1,
4597 sizeof(i1));
4598 if (ret != 0)
4599 goto out;
4600 ret = wc_AesXtsSetKeyNoInit(aes, k1, sizeof(k1), AES_DECRYPTION);
4601 if (ret != 0)
4602 goto out;
4603 ret = wc_AesXtsDecryptInit(aes, i1, sizeof(i1), &stream);
4604 if (ret != 0)
4605 goto out;
4606 for (k = 0; k < j; k += WC_AES_BLOCK_SIZE) {
4607 if ((j - k) < WC_AES_BLOCK_SIZE*2)
4608 ret = wc_AesXtsDecryptFinal(aes, large_input + k, large_input + k, j - k, &stream);
4609 else
4610 ret = wc_AesXtsDecryptUpdate(aes, large_input + k, large_input + k, WC_AES_BLOCK_SIZE, &stream);
4611 if (ret != 0)
4612 goto out;
4613 if ((j - k) < WC_AES_BLOCK_SIZE*2)
4614 break;
4615 }
4616 for (i = 0; i < j; i++) {
4617 if (large_input[i] != (byte)i) {
4618 ret = LINUXKM_LKCAPI_AES_KAT_MISMATCH_E;
4619 goto out;
4620 }
4621 }
4622 }
4623 }
4624
4625 /* now the kernel crypto part */
4626
4627 enc2 = XMALLOC(sizeof(p1), NULL, DYNAMIC_TYPE_AES);
4628 if (!enc2) {
4629 pr_err("error: malloc failed\n");
4630 ret = -ENOMEM;
4631 goto test_xts_end;
4632 }
4633
4634 dec2 = XMALLOC(sizeof(p1), NULL, DYNAMIC_TYPE_AES);
4635 if (!dec2) {
4636 pr_err("error: malloc failed\n");
4637 ret = -ENOMEM;
4638 goto test_xts_end;
4639 }
4640
4641 src = XMALLOC(sizeof(*src) * 2, NULL, DYNAMIC_TYPE_AES);
4642 if (! src) {
4643 pr_err("error: malloc failed\n");
4644 ret = -ENOMEM;
4645 goto test_xts_end;
4646 }
4647
4648 dst = XMALLOC(sizeof(*dst) * 2, NULL, DYNAMIC_TYPE_AES);
4649 if (! dst) {
4650 pr_err("error: malloc failed\n");
4651 ret = -ENOMEM;
4652 goto test_xts_end;
4653 }
4654
4655 tfm = crypto_alloc_skcipher(WOLFKM_AESXTS_NAME, 0, 0);
4656 if (IS_ERR(tfm)) {
4657 ret = PTR_ERR(tfm);
4658 pr_err("error: allocating AES skcipher algorithm %s failed: %d\n",
4659 WOLFKM_AESXTS_DRIVER, ret);
4660 tfm = NULL;
4661 goto test_xts_end;
4662 }
4663
4664#ifndef LINUXKM_LKCAPI_PRIORITY_ALLOW_MASKING
4665 {
4666 const char *driver_name = crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm));
4667 if (strcmp(driver_name, WOLFKM_AESXTS_DRIVER)) {
4668 pr_err("error: unexpected implementation for %s: %s (expected %s)\n",
4669 WOLFKM_AESXTS_NAME, driver_name, WOLFKM_AESXTS_DRIVER);
4670 ret = -ENOENT;
4671 goto test_xts_end;
4672 }
4673 }
4674#endif
4675
4676 ret = crypto_skcipher_ivsize(tfm);
4677 if (ret != sizeof(stream.tweak_block)) {
4678 pr_err("error: AES skcipher algorithm %s crypto_skcipher_ivsize()"
4679 " returned %d but expected %d\n",
4680 WOLFKM_AESXTS_DRIVER, ret, (int)sizeof(stream.tweak_block));
4681 ret = -EINVAL;
4682 goto test_xts_end;
4683 }
4684
4685 ret = crypto_skcipher_setkey(tfm, k1, sizeof(k1));
4686 if (ret) {
4687 pr_err("error: crypto_skcipher_setkey for %s returned: %d\n",
4688 WOLFKM_AESXTS_NAME, ret);
4689 goto test_xts_end;
4690 }
4691
4692 req = skcipher_request_alloc(tfm, GFP_KERNEL);
4693 if (IS_ERR(req)) {
4694 ret = PTR_ERR(req);
4695 pr_err("error: allocating AES skcipher request %s failed: %d\n",
4696 WOLFKM_AESXTS_DRIVER, ret);
4697 req = NULL;
4698 goto test_xts_end;
4699 }
4700
4701 memcpy(dec2, p1, sizeof(p1));
4702 memset(enc2, 0, sizeof(p1));
4703
4704 sg_init_one(src, dec2, sizeof(p1));
4705 sg_init_one(dst, enc2, sizeof(p1));
4706
4707 memcpy(stream.tweak_block, i1, sizeof(stream.tweak_block));
4708 skcipher_request_set_crypt(req, src, dst, sizeof(p1), stream.tweak_block);
4709
4710 ret = crypto_skcipher_encrypt(req);
4711
4712 if (ret) {
4713 pr_err("error: crypto_skcipher_encrypt returned: %d\n", ret);
4714 goto test_xts_end;
4715 }
4716
4717 ret = XMEMCMP(c1, enc2, sizeof(c1));
4718 if (ret) {
4719 pr_err("error: c1 and enc2 do not match: %d\n", ret);
4720 ret = -EINVAL;
4721 goto test_xts_end;
4722 }
4723
4724 memset(dec2, 0, sizeof(p1));
4725 sg_init_one(src, enc2, sizeof(p1));
4726 sg_init_one(dst, dec2, sizeof(p1));
4727
4728 memcpy(stream.tweak_block, i1, sizeof(stream.tweak_block));
4729 skcipher_request_set_crypt(req, src, dst, sizeof(p1), stream.tweak_block);
4730
4731 ret = crypto_skcipher_decrypt(req);
4732
4733 if (ret) {
4734 pr_err("ERROR: crypto_skcipher_decrypt returned %d\n", ret);
4735 goto test_xts_end;
4736 }
4737
4738 ret = XMEMCMP(p1, dec2, sizeof(p1));
4739 if (ret) {
4740 pr_err("error: p1 and dec2 do not match: %d\n", ret);
4741 ret = -EINVAL;
4742 goto test_xts_end;
4743 }
4744
4745 memcpy(dec2, pp, sizeof(pp));
4746 memset(enc2, 0, sizeof(pp));
4747
4748 sg_init_one(src, dec2, sizeof(pp));
4749 sg_init_one(dst, enc2, sizeof(pp));
4750
4751 memcpy(stream.tweak_block, i1, sizeof(stream.tweak_block));
4752 skcipher_request_set_crypt(req, src, dst, sizeof(pp), stream.tweak_block);
4753
4754 ret = crypto_skcipher_encrypt(req);
4755
4756 if (ret) {
4757 pr_err("error: crypto_skcipher_encrypt returned: %d\n", ret);
4758 goto test_xts_end;
4759 }
4760
4761 ret = XMEMCMP(cp, enc2, sizeof(cp));
4762 if (ret) {
4763 pr_err("error: cp and enc2 do not match: %d\n", ret);
4764 ret = -EINVAL;
4765 goto test_xts_end;
4766 }
4767
4768 memset(dec2, 0, sizeof(pp));
4769 sg_init_one(src, enc2, sizeof(pp));
4770 sg_init_one(dst, dec2, sizeof(pp));
4771
4772 memcpy(stream.tweak_block, i1, sizeof(stream.tweak_block));
4773 skcipher_request_set_crypt(req, src, dst, sizeof(pp), stream.tweak_block);
4774
4775 ret = crypto_skcipher_decrypt(req);
4776
4777 if (ret) {
4778 pr_err("ERROR: crypto_skcipher_decrypt returned %d\n", ret);
4779 goto test_xts_end;
4780 }
4781
4782 ret = XMEMCMP(pp, dec2, sizeof(pp));
4783 if (ret) {
4784 pr_err("error: pp and dec2 do not match: %d\n", ret);
4785 ret = -EINVAL;
4786 goto test_xts_end;
4787 }
4788
4789 test_xts_end:
4790
4791 XFREE(enc2, NULL, DYNAMIC_TYPE_AES);
4792 XFREE(dec2, NULL, DYNAMIC_TYPE_AES);
4793 XFREE(src, NULL, DYNAMIC_TYPE_AES);
4794 XFREE(dst, NULL, DYNAMIC_TYPE_AES);
4795 if (req)
4796 skcipher_request_free(req);
4797 if (tfm)
4798 crypto_free_skcipher(tfm);
4799
4800 out:
4801
4802 XFREE(large_input, NULL, DYNAMIC_TYPE_TMP_BUFFER);
4803
4804 if (aes_inited)
4805 wc_AesXtsFree(aes);
4806
4807 XFREE(buf, NULL, DYNAMIC_TYPE_AES);
4808 XFREE(cipher, NULL, DYNAMIC_TYPE_AES);
4809
4810 XFREE(aes, NULL, DYNAMIC_TYPE_AES);
4811
4812#undef AES_XTS_256_TEST_BUF_SIZ
4813
4814 return ret;
4815}
4816#endif /* WOLFSSL_AES_256 */
4817
4818static int linuxkm_test_aesxts(void) {
4819 int ret;
4820
4821 #ifdef WOLFSSL_AES_128
4822 ret = aes_xts_128_test();
4823 if (ret != 0) {
4824 pr_err("aes_xts_128_test() failed with retval %d.\n", ret);
4825 goto out;
4826 }
4827 #endif
4828 #ifdef WOLFSSL_AES_256
4829 ret = aes_xts_256_test();
4830 if (ret != 0) {
4831 pr_err("aes_xts_256_test() failed with retval %d.\n", ret);
4832 goto out;
4833 }
4834 #endif
4835
4836out:
4837
4838 return ret;
4839}
4840
4841#endif /* LINUXKM_LKCAPI_REGISTER_AESXTS */
4842
4843#ifdef LINUXKM_LKCAPI_REGISTER_AESCTR
4844
4845static int linuxkm_test_aesctr(void) {
4846 wc_test_ret_t ret = aes_ctr_test();
4847 if (ret >= 0)
4848 return check_skcipher_driver_masking(NULL /* tfm */, WOLFKM_AESCTR_NAME, WOLFKM_AESCTR_DRIVER);
4849 else {
4850 wc_test_render_error_message("aes_ctr_test failed: ", ret);
4851 return WC_TEST_RET_DEC_EC(ret);
4852 }
4853}
4854
4855#endif /* LINUXKM_LKCAPI_REGISTER_AESCTR */
4856
4857#ifdef LINUXKM_LKCAPI_REGISTER_AESOFB
4858
4859static int linuxkm_test_aesofb(void) {
4860 wc_test_ret_t ret = aesofb_test();
4861 if (ret >= 0)
4862 return check_skcipher_driver_masking(NULL /* tfm */, WOLFKM_AESOFB_NAME, WOLFKM_AESOFB_DRIVER);
4863 else {
4864 wc_test_render_error_message("aesofb_test failed: ", ret);
4865 return WC_TEST_RET_DEC_EC(ret);
4866 }
4867}
4868
4869#endif /* LINUXKM_LKCAPI_REGISTER_AESOFB */
4870
4871#ifdef LINUXKM_LKCAPI_REGISTER_AESECB
4872
4873static int linuxkm_test_aesecb(void) {
4874 wc_test_ret_t ret = aes_test();
4875 if (ret >= 0)
4876 return check_skcipher_driver_masking(NULL /* tfm */, WOLFKM_AESECB_NAME, WOLFKM_AESECB_DRIVER);
4877 else {
4878 wc_test_render_error_message("aes_test failed: ", ret);
4879 return WC_TEST_RET_DEC_EC(ret);
4880 }
4881}
4882
4883#endif /* LINUXKM_LKCAPI_REGISTER_AESECB */
4884
4885#endif /* LINUXKM_LKCAPI_REGISTER_AES */
4886
4887#endif /* !WC_SKIP_INCLUDED_C_FILES */