From ece24e8f9a042561f188d8f09c60b146dd081c94 Mon Sep 17 00:00:00 2001 From: Chunrong Guo Date: Fri, 28 Jul 2017 15:44:09 +0800 Subject: [PATCH] cryptodev-qoriq: update to v1.9 Signed-off-by: Chunrong Guo Signed-off-by: Otavio Salvador --- ...ux_1.8.bb => cryptodev-qoriq-linux_1.9.bb} | 0 ...e_1.8.bb => cryptodev-qoriq-module_1.9.bb} | 0 ...ts_1.8.bb => cryptodev-qoriq-tests_1.9.bb} | 0 .../cryptodev/cryptodev-qoriq_1.8.inc | 138 -- .../cryptodev/cryptodev-qoriq_1.9.inc | 42 + .../0001-don-t-advertise-RSA-keygen.patch | 33 - ...t-big-function-to-simplify-maintaina.patch | 244 +++ ...pport-for-COMPAT_CIOCAUTHCRYPT-ioctl.patch | 207 -- ...ocate-code-to-simplify-later-patches.patch | 58 + ...KC-support-added-in-cryptodev-module.patch | 898 -------- ...o-new-AEAD-interface-in-kernels-v4.2.patch | 96 + .../0004-Compat-versions-of-PKC-IOCTLs.patch | 200 -- .../0004-fix-type-of-returned-value.patch | 29 + ...onous-interface-changes-in-cryptodev.patch | 213 -- ...-remove-unnecessary-header-inclusion.patch | 26 + ...LC_KEYGEN-supported-in-cryptodev-mod.patch | 212 -- ...ucture-definition-to-cryptodev_int.h.patch | 51 + ...-fixed-in-PKC-asynchronous-interface.patch | 238 --- ...RSA-public-and-private-key-operation.patch | 440 ++++ ...08-Add-RSA-Key-generation-offloading.patch | 170 -- ...ags-early-to-avoid-incorrect-failure.patch | 54 + ...n-error-of-openssl-with-fsl-cryptode.patch | 160 -- ...omposite-TLS10-SHA1-AES-algorithm-o.patch} | 16 +- ...composite-TLS10-SHA1-3DES-algorithm-.patch | 54 - ...d-support-for-TLSv1.1-record-offload.patch | 76 - ...d-support-for-TLSv1.2-record-offload.patch | 72 - .../0013-clean-up-code-layout.patch | 186 -- ...dundant-data-copy-for-pkc-operations.patch | 494 ----- .../0015-fix-pkc-request-deallocation.patch | 40 - ...add-basic-detection-of-asym-features.patch | 37 - .../sdk_patches/0017-remove-dead-code.patch | 67 - .../0018-fix-compat-warnings.patch | 64 - .../0019-fix-size_t-print-format.patch | 61 - ...nitialized-variable-compiler-warning.patch | 38 - ...odes-for-copy-to-from-user-functions.patch | 398 ---- ...022-fix-double-free-pkc-req-on-error.patch | 26 - ...emove-MAY_BACKLOG-flag-from-requests.patch | 69 - ...-COMPAT_CIOCKEY-ioctl-command-number.patch | 29 - .../0025-fix-benchmarks-linking.patch | 25 - ...to-allow-parallel-make-with-j-option.patch | 56 - ...l-conventions-for-Makefile-variables.patch | 47 - ...ency-use-.-instead-of-.-in-makefiles.patch | 73 - ...error-path-for-crypto_create_session.patch | 117 -- ...e-duplication-in-cryptodev_hash_init.patch | 59 - .../sdk_patches/0031-fix-comment-typo.patch | 26 - ...2-avoid-calls-to-kmalloc-on-hotpaths.patch | 220 -- ...unnecessary-checks-for-hash-clean-up.patch | 33 - ...CIOCHASH-to-support-direct-hash-oper.patch | 114 - ...pto-API-digest-operation-for-CIOCHAS.patch | 315 --- ...36-add-compat-for-CIOCHASH-operation.patch | 120 -- ...a_speed.c-to-reduce-code-duplication.patch | 190 -- ...-extend-sha_speed.c-to-test-CIOCHASH.patch | 143 -- ...ory-leaks-on-error-path-for-CIOCHASH.patch | 70 - ...fix-structure-init-in-sha_speed-test.patch | 53 - ...d-separate-target-for-building-tests.patch | 38 - ...-fix-destination-for-staged-installs.patch | 55 - .../0043-add-install-target-for-tests.patch | 46 - ...256-xts-support-for-async-speed-test.patch | 64 - ...ort-for-crc32c-hash-async-speed-test.patch | 92 - ...pport-for-sha1-hash-async-speed-test.patch | 47 - ...t-for-sha2-256-hash-async-speed-test.patch | 47 - ...port-for-aes-256-xts-sync-speed-test.patch | 48 - ...port-for-crc32c-hash-sync-speed-test.patch | 63 - ...optargs-support-for-async_speed-test.patch | 439 ---- .../0051-enable-async-code-by-default.patch | 37 - ...-report-in-a-machine-friendly-format.patch | 55 - ...0053-honor-the-m-flag-in-async_speed.patch | 137 -- ...4-rename-algorithm-names-for-clarity.patch | 57 - ...hreaded-wrapper-for-async-speed-test.patch | 173 -- ...e-when-allocating-alligned-memory-bu.patch | 58 - ...gracefull-stop-for-async-speed-tests.patch | 64 - ...ity-check-on-dev-crypto-availability.patch | 26 - ...me-issues-with-parsing-mpstat-output.patch | 42 - ...060-more-precision-in-running-mpstat.patch | 55 - ...ttle-space-in-the-output-for-clarity.patch | 27 - ...gs-on-implicit-function-declarations.patch | 129 -- ...onversion-between-signed-and-unsigne.patch | 698 ------- ...0064-remove-not-used-local-variables.patch | 129 -- ...ror-code-of-the-test-if-there-is-one.patch | 68 - ...ode-checking-to-avoid-maintenance-is.patch | 25 - .../0067-fix-issues-with-install-target.patch | 52 - ..._DIR-is-not-necessary-to-build-tests.patch | 24 - .../0069-fix-the-reported-unit.patch | 29 - ...d-results-to-avoid-incorrect-reports.patch | 27 - ...1-fix-the-scale-of-the-runtime-value.patch | 29 - ...2-use-.-instead-of-.-for-consistency.patch | 82 - ...3-really-fix-again.-the-mpstat-issue.patch | 34 - .../0074-make-default-output-tabular.patch | 83 - ...ix-incorrect-handling-of-error-cases.patch | 27 - ...if-cryptodev-tests-are-not-installed.patch | 48 - ...sed-by-cryptodev-is-C90-with-GNU-ext.patch | 66 - ...ne-because-it-does-not-add-clarity-t.patch | 32 - ...0079-fix-typo-use-consistent-spacing.patch | 28 - ...-cryptodev-is-not-built-with-ASYNC-f.patch | 31 - ...ests-with-the-same-format-as-async-o.patch | 718 ------- ...lue-to-avoid-mpstat-not-using-ISO860.patch | 31 - ...orithm-names-in-sync_speed-as-in-asy.patch | 58 - ...ed-SIGALRM-signals-on-some-platforms.patch | 44 - ...bout-configured-limits-in-SEC-driver.patch | 56 - ...wrapper-script-for-running-all-tests.patch | 58 - ...0087-add-to-cpu-idle-for-convenience.patch | 26 - ...sync-benchmarks-into-a-single-progra.patch | 1858 ----------------- ...-async-option-to-run_crypto_tests.sh.patch | 62 - ...just-to-recent-user-page-API-changes.patch | 55 - .../0091-Fix-test-compile-time-warnings.patch | 65 - ...cipher-in-addition-to-ablkcipher-API.patch | 281 --- ...her-algorithms-usage-in-v4.8-kernels.patch | 147 -- ...-another-change-in-the-user-page-API.patch | 36 - ...ename-header-file-to-clarify-purpose.patch | 173 -- ...ign-macro-to-reduce-code-duplication.patch | 248 --- ...onversion-between-signed-and-unsigne.patch | 304 --- ...ests-Makefile-distance-with-upstream.patch | 25 - ...authenc-hmac-sha1-cbc-aes-speed-test.patch | 288 --- ...0-close-the-session-after-every-test.patch | 108 - ...0101-add-support-for-rsa-speed-tests.patch | 179 -- ...adjust-to-API-changes-in-kernel-4.10.patch | 57 - .../0103-zc-Use-the-power-of-elif.patch | 51 - ...t-finish-condition-before-test-start.patch | 29 - .../0105-update-copyright-notes.patch | 77 - 119 files changed, 1047 insertions(+), 14195 deletions(-) rename recipes-kernel/cryptodev/{cryptodev-qoriq-linux_1.8.bb => cryptodev-qoriq-linux_1.9.bb} (100%) rename recipes-kernel/cryptodev/{cryptodev-qoriq-module_1.8.bb => cryptodev-qoriq-module_1.9.bb} (100%) rename recipes-kernel/cryptodev/{cryptodev-qoriq-tests_1.8.bb => cryptodev-qoriq-tests_1.9.bb} (100%) delete mode 100644 recipes-kernel/cryptodev/cryptodev-qoriq_1.8.inc create mode 100644 recipes-kernel/cryptodev/cryptodev-qoriq_1.9.inc delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0001-don-t-advertise-RSA-keygen.patch create mode 100644 recipes-kernel/cryptodev/sdk_patches/0001-refactoring-split-big-function-to-simplify-maintaina.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0002-add-support-for-COMPAT_CIOCAUTHCRYPT-ioctl.patch create mode 100644 recipes-kernel/cryptodev/sdk_patches/0002-refactoring-relocate-code-to-simplify-later-patches.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0003-PKC-support-added-in-cryptodev-module.patch create mode 100644 recipes-kernel/cryptodev/sdk_patches/0003-convert-to-new-AEAD-interface-in-kernels-v4.2.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0004-Compat-versions-of-PKC-IOCTLs.patch create mode 100644 recipes-kernel/cryptodev/sdk_patches/0004-fix-type-of-returned-value.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0005-Asynchronous-interface-changes-in-cryptodev.patch create mode 100644 recipes-kernel/cryptodev/sdk_patches/0005-remove-unnecessary-header-inclusion.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0006-ECC_KEYGEN-and-DLC_KEYGEN-supported-in-cryptodev-mod.patch create mode 100644 recipes-kernel/cryptodev/sdk_patches/0006-move-structure-definition-to-cryptodev_int.h.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0007-RCU-stall-fixed-in-PKC-asynchronous-interface.patch create mode 100644 recipes-kernel/cryptodev/sdk_patches/0007-add-support-for-RSA-public-and-private-key-operation.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0008-Add-RSA-Key-generation-offloading.patch create mode 100644 recipes-kernel/cryptodev/sdk_patches/0008-check-session-flags-early-to-avoid-incorrect-failure.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0009-Fixed-compilation-error-of-openssl-with-fsl-cryptode.patch rename recipes-kernel/cryptodev/sdk_patches/{0001-add-support-for-composite-TLS10-SHA1-AES-algorithm-o.patch => 0009-add-support-for-composite-TLS10-SHA1-AES-algorithm-o.patch} (71%) delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0010-add-support-for-composite-TLS10-SHA1-3DES-algorithm-.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0011-add-support-for-TLSv1.1-record-offload.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0012-add-support-for-TLSv1.2-record-offload.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0013-clean-up-code-layout.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0014-remove-redundant-data-copy-for-pkc-operations.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0015-fix-pkc-request-deallocation.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0016-add-basic-detection-of-asym-features.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0017-remove-dead-code.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0018-fix-compat-warnings.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0019-fix-size_t-print-format.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0020-fix-uninitialized-variable-compiler-warning.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0021-check-return-codes-for-copy-to-from-user-functions.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0022-fix-double-free-pkc-req-on-error.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0023-remove-MAY_BACKLOG-flag-from-requests.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0024-fix-COMPAT_CIOCKEY-ioctl-command-number.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0025-fix-benchmarks-linking.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0026-fix-Makefile-to-allow-parallel-make-with-j-option.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0027-use-Linux-kernel-conventions-for-Makefile-variables.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0028-for-consistency-use-.-instead-of-.-in-makefiles.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0029-fix-clean-up-on-error-path-for-crypto_create_session.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0030-remove-code-duplication-in-cryptodev_hash_init.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0031-fix-comment-typo.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0032-avoid-calls-to-kmalloc-on-hotpaths.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0033-avoid-unnecessary-checks-for-hash-clean-up.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0034-extend-API-with-CIOCHASH-to-support-direct-hash-oper.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0035-use-directly-crypto-API-digest-operation-for-CIOCHAS.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0036-add-compat-for-CIOCHASH-operation.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0037-rewrite-sha_speed.c-to-reduce-code-duplication.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0038-extend-sha_speed.c-to-test-CIOCHASH.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0039-fix-memory-leaks-on-error-path-for-CIOCHASH.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0040-fix-structure-init-in-sha_speed-test.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0041-add-separate-target-for-building-tests.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0042-fix-destination-for-staged-installs.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0043-add-install-target-for-tests.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0044-add-aes-256-xts-support-for-async-speed-test.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0045-add-support-for-crc32c-hash-async-speed-test.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0046-add-support-for-sha1-hash-async-speed-test.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0047-add-support-for-sha2-256-hash-async-speed-test.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0048-add-support-for-aes-256-xts-sync-speed-test.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0049-add-support-for-crc32c-hash-sync-speed-test.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0050-add-basic-optargs-support-for-async_speed-test.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0051-enable-async-code-by-default.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0052-add-flag-to-report-in-a-machine-friendly-format.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0053-honor-the-m-flag-in-async_speed.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0054-rename-algorithm-names-for-clarity.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0055-add-multithreaded-wrapper-for-async-speed-test.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0056-fix-set-min-value-when-allocating-alligned-memory-bu.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0057-gracefull-stop-for-async-speed-tests.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0058-sanity-check-on-dev-crypto-availability.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0059-fix-some-issues-with-parsing-mpstat-output.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0060-more-precision-in-running-mpstat.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0061-add-a-little-space-in-the-output-for-clarity.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0062-fix-build-warnings-on-implicit-function-declarations.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0063-avoid-implicit-conversion-between-signed-and-unsigne.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0064-remove-not-used-local-variables.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0065-return-error-code-of-the-test-if-there-is-one.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0066-do-more-strict-code-checking-to-avoid-maintenance-is.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0067-fix-issues-with-install-target.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0068-setting-KERNEL_DIR-is-not-necessary-to-build-tests.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0069-fix-the-reported-unit.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0070-remove-old-results-to-avoid-incorrect-reports.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0071-fix-the-scale-of-the-runtime-value.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0072-use-.-instead-of-.-for-consistency.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0073-really-fix-again.-the-mpstat-issue.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0074-make-default-output-tabular.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0075-fix-incorrect-handling-of-error-cases.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0076-exit-early-if-cryptodev-tests-are-not-installed.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0077-the-C-standard-used-by-cryptodev-is-C90-with-GNU-ext.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0078-remove-output-line-because-it-does-not-add-clarity-t.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0079-fix-typo-use-consistent-spacing.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0080-graceful-exit-if-cryptodev-is-not-built-with-ASYNC-f.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0081-add-sync-speed-tests-with-the-same-format-as-async-o.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0082-force-LC_TIME-value-to-avoid-mpstat-not-using-ISO860.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0083-use-the-same-algorithm-names-in-sync_speed-as-in-asy.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0084-fix-ignored-SIGALRM-signals-on-some-platforms.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0085-add-notes-about-configured-limits-in-SEC-driver.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0086-add-a-wrapper-script-for-running-all-tests.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0087-add-to-cpu-idle-for-convenience.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0088-merge-sync-and-async-benchmarks-into-a-single-progra.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0089-add-async-option-to-run_crypto_tests.sh.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0090-Adjust-to-recent-user-page-API-changes.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0091-Fix-test-compile-time-warnings.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0092-Support-skcipher-in-addition-to-ablkcipher-API.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0093-Fix-ablkcipher-algorithms-usage-in-v4.8-kernels.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0094-Adjust-to-another-change-in-the-user-page-API.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0095-rename-header-file-to-clarify-purpose.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0096-use-buf_align-macro-to-reduce-code-duplication.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0097-avoid-implicit-conversion-between-signed-and-unsigne.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0098-reduce-tests-Makefile-distance-with-upstream.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0099-add-support-for-authenc-hmac-sha1-cbc-aes-speed-test.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0100-close-the-session-after-every-test.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0101-add-support-for-rsa-speed-tests.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0102-adjust-to-API-changes-in-kernel-4.10.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0103-zc-Use-the-power-of-elif.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0104-fix-reset-finish-condition-before-test-start.patch delete mode 100644 recipes-kernel/cryptodev/sdk_patches/0105-update-copyright-notes.patch diff --git a/recipes-kernel/cryptodev/cryptodev-qoriq-linux_1.8.bb b/recipes-kernel/cryptodev/cryptodev-qoriq-linux_1.9.bb similarity index 100% rename from recipes-kernel/cryptodev/cryptodev-qoriq-linux_1.8.bb rename to recipes-kernel/cryptodev/cryptodev-qoriq-linux_1.9.bb diff --git a/recipes-kernel/cryptodev/cryptodev-qoriq-module_1.8.bb b/recipes-kernel/cryptodev/cryptodev-qoriq-module_1.9.bb similarity index 100% rename from recipes-kernel/cryptodev/cryptodev-qoriq-module_1.8.bb rename to recipes-kernel/cryptodev/cryptodev-qoriq-module_1.9.bb diff --git a/recipes-kernel/cryptodev/cryptodev-qoriq-tests_1.8.bb b/recipes-kernel/cryptodev/cryptodev-qoriq-tests_1.9.bb similarity index 100% rename from recipes-kernel/cryptodev/cryptodev-qoriq-tests_1.8.bb rename to recipes-kernel/cryptodev/cryptodev-qoriq-tests_1.9.bb diff --git a/recipes-kernel/cryptodev/cryptodev-qoriq_1.8.inc b/recipes-kernel/cryptodev/cryptodev-qoriq_1.8.inc deleted file mode 100644 index b55a33c4..00000000 --- a/recipes-kernel/cryptodev/cryptodev-qoriq_1.8.inc +++ /dev/null @@ -1,138 +0,0 @@ -HOMEPAGE = "http://cryptodev-linux.org/" - -LICENSE = "GPLv2" -LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263" - -python() { - pkgs = d.getVar('PACKAGES', True).split() - for p in pkgs: - if 'cryptodev-qoriq' in p: - d.appendVar("RPROVIDES_%s" % p, p.replace('cryptodev-qoriq', 'cryptodev')) - d.appendVar("RCONFLICTS_%s" % p, p.replace('cryptodev-qoriq', 'cryptodev')) - d.appendVar("RREPLACES_%s" % p, p.replace('cryptodev-qoriq', 'cryptodev')) -} - -FILESEXTRAPATHS_prepend := "${THISDIR}/sdk_patches:" -FILESEXTRAPATHS_prepend := "${THISDIR}/yocto_patches:" - -SRC_URI = "http://download.gna.org/cryptodev-linux/cryptodev-linux-${PV}.tar.gz" - -SRC_URI[md5sum] = "02644cc4cd02301e0b503a332eb2f0b5" -SRC_URI[sha256sum] = "67fabde9fb67b286a96c4f45b594b0eccd0f761b495705c18f2ae9461b831376" - -# SDK patches -SRC_URI_append = " file://0001-add-support-for-composite-TLS10-SHA1-AES-algorithm-o.patch \ -file://0002-add-support-for-COMPAT_CIOCAUTHCRYPT-ioctl.patch \ -file://0003-PKC-support-added-in-cryptodev-module.patch \ -file://0004-Compat-versions-of-PKC-IOCTLs.patch \ -file://0005-Asynchronous-interface-changes-in-cryptodev.patch \ -file://0006-ECC_KEYGEN-and-DLC_KEYGEN-supported-in-cryptodev-mod.patch \ -file://0007-RCU-stall-fixed-in-PKC-asynchronous-interface.patch \ -file://0008-Add-RSA-Key-generation-offloading.patch \ -file://0009-Fixed-compilation-error-of-openssl-with-fsl-cryptode.patch \ -file://0010-add-support-for-composite-TLS10-SHA1-3DES-algorithm-.patch \ -file://0011-add-support-for-TLSv1.1-record-offload.patch \ -file://0012-add-support-for-TLSv1.2-record-offload.patch \ -file://0013-clean-up-code-layout.patch \ -file://0014-remove-redundant-data-copy-for-pkc-operations.patch \ -file://0015-fix-pkc-request-deallocation.patch \ -file://0016-add-basic-detection-of-asym-features.patch \ -file://0017-remove-dead-code.patch \ -file://0018-fix-compat-warnings.patch \ -file://0019-fix-size_t-print-format.patch \ -file://0020-fix-uninitialized-variable-compiler-warning.patch \ -file://0021-check-return-codes-for-copy-to-from-user-functions.patch \ -file://0022-fix-double-free-pkc-req-on-error.patch \ -file://0023-remove-MAY_BACKLOG-flag-from-requests.patch \ -file://0024-fix-COMPAT_CIOCKEY-ioctl-command-number.patch \ -file://0025-fix-benchmarks-linking.patch \ -file://0026-fix-Makefile-to-allow-parallel-make-with-j-option.patch \ -file://0027-use-Linux-kernel-conventions-for-Makefile-variables.patch \ -file://0028-for-consistency-use-.-instead-of-.-in-makefiles.patch \ -file://0029-fix-clean-up-on-error-path-for-crypto_create_session.patch \ -file://0030-remove-code-duplication-in-cryptodev_hash_init.patch \ -file://0031-fix-comment-typo.patch \ -file://0032-avoid-calls-to-kmalloc-on-hotpaths.patch \ -file://0033-avoid-unnecessary-checks-for-hash-clean-up.patch \ -file://0034-extend-API-with-CIOCHASH-to-support-direct-hash-oper.patch \ -file://0035-use-directly-crypto-API-digest-operation-for-CIOCHAS.patch \ -file://0036-add-compat-for-CIOCHASH-operation.patch \ -file://0037-rewrite-sha_speed.c-to-reduce-code-duplication.patch \ -file://0038-extend-sha_speed.c-to-test-CIOCHASH.patch \ -file://0039-fix-memory-leaks-on-error-path-for-CIOCHASH.patch \ -file://0040-fix-structure-init-in-sha_speed-test.patch \ -file://0041-add-separate-target-for-building-tests.patch \ -file://0042-fix-destination-for-staged-installs.patch \ -file://0043-add-install-target-for-tests.patch \ -file://0044-add-aes-256-xts-support-for-async-speed-test.patch \ -file://0045-add-support-for-crc32c-hash-async-speed-test.patch \ -file://0046-add-support-for-sha1-hash-async-speed-test.patch \ -file://0047-add-support-for-sha2-256-hash-async-speed-test.patch \ -file://0048-add-support-for-aes-256-xts-sync-speed-test.patch \ -file://0049-add-support-for-crc32c-hash-sync-speed-test.patch \ -file://0050-add-basic-optargs-support-for-async_speed-test.patch \ -file://0051-enable-async-code-by-default.patch \ -file://0052-add-flag-to-report-in-a-machine-friendly-format.patch \ -file://0053-honor-the-m-flag-in-async_speed.patch \ -file://0054-rename-algorithm-names-for-clarity.patch \ -file://0055-add-multithreaded-wrapper-for-async-speed-test.patch \ -file://0056-fix-set-min-value-when-allocating-alligned-memory-bu.patch \ -file://0057-gracefull-stop-for-async-speed-tests.patch \ -file://0058-sanity-check-on-dev-crypto-availability.patch \ -file://0059-fix-some-issues-with-parsing-mpstat-output.patch \ -file://0060-more-precision-in-running-mpstat.patch \ -file://0061-add-a-little-space-in-the-output-for-clarity.patch \ -file://0062-fix-build-warnings-on-implicit-function-declarations.patch \ -file://0063-avoid-implicit-conversion-between-signed-and-unsigne.patch \ -file://0064-remove-not-used-local-variables.patch \ -file://0065-return-error-code-of-the-test-if-there-is-one.patch \ -file://0066-do-more-strict-code-checking-to-avoid-maintenance-is.patch \ -file://0067-fix-issues-with-install-target.patch \ -file://0068-setting-KERNEL_DIR-is-not-necessary-to-build-tests.patch \ -file://0069-fix-the-reported-unit.patch \ -file://0070-remove-old-results-to-avoid-incorrect-reports.patch \ -file://0071-fix-the-scale-of-the-runtime-value.patch \ -file://0072-use-.-instead-of-.-for-consistency.patch \ -file://0073-really-fix-again.-the-mpstat-issue.patch \ -file://0074-make-default-output-tabular.patch \ -file://0075-fix-incorrect-handling-of-error-cases.patch \ -file://0076-exit-early-if-cryptodev-tests-are-not-installed.patch \ -file://0077-the-C-standard-used-by-cryptodev-is-C90-with-GNU-ext.patch \ -file://0078-remove-output-line-because-it-does-not-add-clarity-t.patch \ -file://0079-fix-typo-use-consistent-spacing.patch \ -file://0080-graceful-exit-if-cryptodev-is-not-built-with-ASYNC-f.patch \ -file://0081-add-sync-speed-tests-with-the-same-format-as-async-o.patch \ -file://0082-force-LC_TIME-value-to-avoid-mpstat-not-using-ISO860.patch \ -file://0083-use-the-same-algorithm-names-in-sync_speed-as-in-asy.patch \ -file://0084-fix-ignored-SIGALRM-signals-on-some-platforms.patch \ -file://0085-add-notes-about-configured-limits-in-SEC-driver.patch \ -file://0086-add-a-wrapper-script-for-running-all-tests.patch \ -file://0087-add-to-cpu-idle-for-convenience.patch \ -file://0088-merge-sync-and-async-benchmarks-into-a-single-progra.patch \ -file://0089-add-async-option-to-run_crypto_tests.sh.patch \ -file://0090-Adjust-to-recent-user-page-API-changes.patch \ -file://0091-Fix-test-compile-time-warnings.patch \ -file://0092-Support-skcipher-in-addition-to-ablkcipher-API.patch \ -file://0093-Fix-ablkcipher-algorithms-usage-in-v4.8-kernels.patch \ -file://0094-Adjust-to-another-change-in-the-user-page-API.patch \ -file://0095-rename-header-file-to-clarify-purpose.patch \ -file://0096-use-buf_align-macro-to-reduce-code-duplication.patch \ -file://0097-avoid-implicit-conversion-between-signed-and-unsigne.patch \ -file://0098-reduce-tests-Makefile-distance-with-upstream.patch \ -file://0099-add-support-for-authenc-hmac-sha1-cbc-aes-speed-test.patch \ -file://0100-close-the-session-after-every-test.patch \ -file://0101-add-support-for-rsa-speed-tests.patch \ -file://0102-adjust-to-API-changes-in-kernel-4.10.patch \ -file://0103-zc-Use-the-power-of-elif.patch \ -file://0104-fix-reset-finish-condition-before-test-start.patch \ -file://0105-update-copyright-notes.patch \ -" -SRC_URI_append = " file://0003-update-the-install-path-for-cryptodev-tests.patch" - -# NOTE: remove this patch and all traces of DISTRO_FEATURE c29x_pkc -# if pkc-host does not need customized cryptodev patches anymore -SRC_URI_append = "${@bb.utils.contains('DISTRO_FEATURES', 'c29x_pkc', ' file://0001-don-t-advertise-RSA-keygen.patch', '', d)}" - -S = "${WORKDIR}/cryptodev-linux-${PV}" - -CLEANBROKEN = "1" diff --git a/recipes-kernel/cryptodev/cryptodev-qoriq_1.9.inc b/recipes-kernel/cryptodev/cryptodev-qoriq_1.9.inc new file mode 100644 index 00000000..24cc87c9 --- /dev/null +++ b/recipes-kernel/cryptodev/cryptodev-qoriq_1.9.inc @@ -0,0 +1,42 @@ +HOMEPAGE = "http://cryptodev-linux.org/" + +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263" + +python() { + pkgs = d.getVar('PACKAGES', True).split() + for p in pkgs: + if 'cryptodev-qoriq' in p: + d.appendVar("RPROVIDES_%s" % p, p.replace('cryptodev-qoriq', 'cryptodev')) + d.appendVar("RCONFLICTS_%s" % p, p.replace('cryptodev-qoriq', 'cryptodev')) + d.appendVar("RREPLACES_%s" % p, p.replace('cryptodev-qoriq', 'cryptodev')) +} + +FILESEXTRAPATHS_prepend := "${THISDIR}/sdk_patches:" +FILESEXTRAPATHS_prepend := "${THISDIR}/yocto_patches:" + +SRC_URI = "http://nwl.cc/pub/cryptodev-linux/cryptodev-linux-${PV}.tar.gz" + +SRC_URI[md5sum] = "cb4e0ed9e5937716c7c8a7be84895b6d" +SRC_URI[sha256sum] = "9f4c0b49b30e267d776f79455d09c70cc9c12c86eee400a0d0a0cd1d8e467950" + +# SDK patches +SRC_URI_append = " file://0001-refactoring-split-big-function-to-simplify-maintaina.patch \ + file://0002-refactoring-relocate-code-to-simplify-later-patches.patch \ + file://0003-convert-to-new-AEAD-interface-in-kernels-v4.2.patch \ + file://0004-fix-type-of-returned-value.patch \ + file://0005-remove-unnecessary-header-inclusion.patch \ + file://0006-move-structure-definition-to-cryptodev_int.h.patch \ + file://0007-add-support-for-RSA-public-and-private-key-operation.patch \ + file://0008-check-session-flags-early-to-avoid-incorrect-failure.patch \ + file://0009-add-support-for-composite-TLS10-SHA1-AES-algorithm-o.patch \ +" +#SRC_URI_append = " file://0003-update-the-install-path-for-cryptodev-tests.patch" + +# NOTE: remove this patch and all traces of DISTRO_FEATURE c29x_pkc +# if pkc-host does not need customized cryptodev patches anymore +#SRC_URI_append = "${@bb.utils.contains('DISTRO_FEATURES', 'c29x_pkc', ' file://0001-don-t-advertise-RSA-keygen.patch', '', d)}" + +S = "${WORKDIR}/cryptodev-linux-${PV}" + +CLEANBROKEN = "1" diff --git a/recipes-kernel/cryptodev/sdk_patches/0001-don-t-advertise-RSA-keygen.patch b/recipes-kernel/cryptodev/sdk_patches/0001-don-t-advertise-RSA-keygen.patch deleted file mode 100644 index 10d6c8b5..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0001-don-t-advertise-RSA-keygen.patch +++ /dev/null @@ -1,33 +0,0 @@ -From d30c9c64aca4a7905e1b7eb3e28e1c616191bd34 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Tue, 9 Dec 2014 16:41:25 +0200 -Subject: [PATCH] don't advertise RSA keygen - -Disable RSA keygen operations when they are not available. - -Currently no testing can be done and this patch should be applied -selectively on platforms that have incomplete support for RSA operations -(for example pkc driver on C293) - -Change-Id: Ic8df014623410c3cf4b0b217a246efcea8f2eeef -Signed-off-by: Cristian Stoica ---- - ioctl.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/ioctl.c b/ioctl.c -index 53dbf64..27dc66e 100644 ---- a/ioctl.c -+++ b/ioctl.c -@@ -979,7 +979,7 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) - case CIOCASYMFEAT: - ses = 0; - if (crypto_has_alg("pkc(rsa)", 0, 0)) -- ses = CRF_MOD_EXP_CRT | CRF_MOD_EXP | CRF_RSA_GENERATE_KEY; -+ ses = CRF_MOD_EXP_CRT | CRF_MOD_EXP ; - if (crypto_has_alg("pkc(dsa)", 0, 0)) - ses |= CRF_DSA_SIGN | CRF_DSA_VERIFY | CRF_DSA_GENERATE_KEY; - if (crypto_has_alg("pkc(dh)", 0, 0)) --- -2.3.5 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0001-refactoring-split-big-function-to-simplify-maintaina.patch b/recipes-kernel/cryptodev/sdk_patches/0001-refactoring-split-big-function-to-simplify-maintaina.patch new file mode 100644 index 00000000..57ac8e1e --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0001-refactoring-split-big-function-to-simplify-maintaina.patch @@ -0,0 +1,244 @@ +From 20dcf071bc3076ee7db9d603cfbe6a06e86c7d5f Mon Sep 17 00:00:00 2001 +From: Cristian Stoica +Date: Thu, 4 May 2017 15:06:20 +0300 +Subject: [PATCH 1/9] refactoring: split big function to simplify maintainance + +The setup of auth_buf in tls and aead is now duplicated but this +is temporary and allows necessary corrections for the aead case +with v4.2+ kernels. + +Signed-off-by: Cristian Stoica +--- + authenc.c | 197 ++++++++++++++++++++++++++++++++++++++++---------------------- + 1 file changed, 126 insertions(+), 71 deletions(-) + +diff --git a/authenc.c b/authenc.c +index 1bd7377..28eb0f9 100644 +--- a/authenc.c ++++ b/authenc.c +@@ -609,96 +609,151 @@ auth_n_crypt(struct csession *ses_ptr, struct kernel_crypt_auth_op *kcaop, + return 0; + } + +-/* This is the main crypto function - zero-copy edition */ +-static int +-__crypto_auth_run_zc(struct csession *ses_ptr, struct kernel_crypt_auth_op *kcaop) ++static int crypto_auth_zc_srtp(struct csession *ses_ptr, struct kernel_crypt_auth_op *kcaop) + { +- struct scatterlist *dst_sg, *auth_sg, *src_sg; ++ struct scatterlist *dst_sg, *auth_sg; + struct crypt_auth_op *caop = &kcaop->caop; +- int ret = 0; ++ int ret; + +- if (caop->flags & COP_FLAG_AEAD_SRTP_TYPE) { +- if (unlikely(ses_ptr->cdata.init != 0 && +- (ses_ptr->cdata.stream == 0 || +- ses_ptr->cdata.aead != 0))) { +- derr(0, "Only stream modes are allowed in SRTP mode (but not AEAD)"); +- return -EINVAL; +- } ++ if (unlikely(ses_ptr->cdata.init != 0 && ++ (ses_ptr->cdata.stream == 0 || ses_ptr->cdata.aead != 0))) { ++ derr(0, "Only stream modes are allowed in SRTP mode (but not AEAD)"); ++ return -EINVAL; ++ } + +- ret = get_userbuf_srtp(ses_ptr, kcaop, &auth_sg, &dst_sg); +- if (unlikely(ret)) { +- derr(1, "get_userbuf_srtp(): Error getting user pages."); +- return ret; +- } ++ ret = get_userbuf_srtp(ses_ptr, kcaop, &auth_sg, &dst_sg); ++ if (unlikely(ret)) { ++ derr(1, "get_userbuf_srtp(): Error getting user pages."); ++ return ret; ++ } + +- ret = srtp_auth_n_crypt(ses_ptr, kcaop, auth_sg, caop->auth_len, +- dst_sg, caop->len); ++ ret = srtp_auth_n_crypt(ses_ptr, kcaop, auth_sg, caop->auth_len, ++ dst_sg, caop->len); + +- release_user_pages(ses_ptr); +- } else { /* TLS and normal cases. Here auth data are usually small +- * so we just copy them to a free page, instead of trying +- * to map them. +- */ +- unsigned char *auth_buf = NULL; +- struct scatterlist tmp; ++ release_user_pages(ses_ptr); + +- if (unlikely(caop->auth_len > PAGE_SIZE)) { +- derr(1, "auth data len is excessive."); +- return -EINVAL; +- } ++ return ret; ++} + +- auth_buf = (char *)__get_free_page(GFP_KERNEL); +- if (unlikely(!auth_buf)) { +- derr(1, "unable to get a free page."); +- return -ENOMEM; +- } ++static int crypto_auth_zc_tls(struct csession *ses_ptr, struct kernel_crypt_auth_op *kcaop) ++{ ++ struct crypt_auth_op *caop = &kcaop->caop; ++ struct scatterlist *dst_sg, *auth_sg; ++ unsigned char *auth_buf = NULL; ++ struct scatterlist tmp; ++ int ret; + +- if (caop->auth_src && caop->auth_len > 0) { +- if (unlikely(copy_from_user(auth_buf, caop->auth_src, caop->auth_len))) { +- derr(1, "unable to copy auth data from userspace."); +- ret = -EFAULT; +- goto free_auth_buf; +- } ++ if (unlikely(ses_ptr->cdata.aead != 0)) { ++ return -EINVAL; ++ } ++ ++ if (unlikely(caop->auth_len > PAGE_SIZE)) { ++ derr(1, "auth data len is excessive."); ++ return -EINVAL; ++ } ++ ++ auth_buf = (char *)__get_free_page(GFP_KERNEL); ++ if (unlikely(!auth_buf)) { ++ derr(1, "unable to get a free page."); ++ return -ENOMEM; ++ } + +- sg_init_one(&tmp, auth_buf, caop->auth_len); +- auth_sg = &tmp; +- } else { +- auth_sg = NULL; ++ if (caop->auth_src && caop->auth_len > 0) { ++ if (unlikely(copy_from_user(auth_buf, caop->auth_src, caop->auth_len))) { ++ derr(1, "unable to copy auth data from userspace."); ++ ret = -EFAULT; ++ goto free_auth_buf; + } + +- if (caop->flags & COP_FLAG_AEAD_TLS_TYPE && ses_ptr->cdata.aead == 0) { +- ret = get_userbuf_tls(ses_ptr, kcaop, &dst_sg); +- if (unlikely(ret)) { +- derr(1, "get_userbuf_tls(): Error getting user pages."); +- goto free_auth_buf; +- } ++ sg_init_one(&tmp, auth_buf, caop->auth_len); ++ auth_sg = &tmp; ++ } else { ++ auth_sg = NULL; ++ } + +- ret = tls_auth_n_crypt(ses_ptr, kcaop, auth_sg, caop->auth_len, +- dst_sg, caop->len); +- } else { +- if (unlikely(ses_ptr->cdata.init == 0 || +- (ses_ptr->cdata.stream == 0 && +- ses_ptr->cdata.aead == 0))) { +- derr(0, "Only stream and AEAD ciphers are allowed for authenc"); +- ret = -EINVAL; +- goto free_auth_buf; +- } ++ ret = get_userbuf_tls(ses_ptr, kcaop, &dst_sg); ++ if (unlikely(ret)) { ++ derr(1, "get_userbuf_tls(): Error getting user pages."); ++ goto free_auth_buf; ++ } + +- ret = get_userbuf(ses_ptr, caop->src, caop->len, caop->dst, kcaop->dst_len, +- kcaop->task, kcaop->mm, &src_sg, &dst_sg); +- if (unlikely(ret)) { +- derr(1, "get_userbuf(): Error getting user pages."); +- goto free_auth_buf; +- } ++ ret = tls_auth_n_crypt(ses_ptr, kcaop, auth_sg, caop->auth_len, ++ dst_sg, caop->len); ++ release_user_pages(ses_ptr); ++ ++free_auth_buf: ++ free_page((unsigned long)auth_buf); ++ return ret; ++} ++ ++static int crypto_auth_zc_aead(struct csession *ses_ptr, struct kernel_crypt_auth_op *kcaop) ++{ ++ struct scatterlist *dst_sg, *auth_sg, *src_sg; ++ struct crypt_auth_op *caop = &kcaop->caop; ++ unsigned char *auth_buf = NULL; ++ struct scatterlist tmp; ++ int ret; + +- ret = auth_n_crypt(ses_ptr, kcaop, auth_sg, caop->auth_len, +- src_sg, dst_sg, caop->len); ++ if (unlikely(ses_ptr->cdata.init == 0 || ++ (ses_ptr->cdata.stream == 0 && ses_ptr->cdata.aead == 0))) { ++ derr(0, "Only stream and AEAD ciphers are allowed for authenc"); ++ return -EINVAL; ++ } ++ ++ if (unlikely(caop->auth_len > PAGE_SIZE)) { ++ derr(1, "auth data len is excessive."); ++ return -EINVAL; ++ } ++ ++ auth_buf = (char *)__get_free_page(GFP_KERNEL); ++ if (unlikely(!auth_buf)) { ++ derr(1, "unable to get a free page."); ++ return -ENOMEM; ++ } ++ ++ if (caop->auth_src && caop->auth_len > 0) { ++ if (unlikely(copy_from_user(auth_buf, caop->auth_src, caop->auth_len))) { ++ derr(1, "unable to copy auth data from userspace."); ++ ret = -EFAULT; ++ goto free_auth_buf; + } + +- release_user_pages(ses_ptr); ++ sg_init_one(&tmp, auth_buf, caop->auth_len); ++ auth_sg = &tmp; ++ } else { ++ auth_sg = NULL; ++ } ++ ++ ret = get_userbuf(ses_ptr, caop->src, caop->len, caop->dst, kcaop->dst_len, ++ kcaop->task, kcaop->mm, &src_sg, &dst_sg); ++ if (unlikely(ret)) { ++ derr(1, "get_userbuf(): Error getting user pages."); ++ goto free_auth_buf; ++ } ++ ++ ret = auth_n_crypt(ses_ptr, kcaop, auth_sg, caop->auth_len, ++ src_sg, dst_sg, caop->len); ++ ++ release_user_pages(ses_ptr); + + free_auth_buf: +- free_page((unsigned long)auth_buf); ++ free_page((unsigned long)auth_buf); ++ ++ return ret; ++} ++ ++static int ++__crypto_auth_run_zc(struct csession *ses_ptr, struct kernel_crypt_auth_op *kcaop) ++{ ++ struct crypt_auth_op *caop = &kcaop->caop; ++ int ret; ++ ++ if (caop->flags & COP_FLAG_AEAD_SRTP_TYPE) { ++ ret = crypto_auth_zc_srtp(ses_ptr, kcaop); ++ } else if (caop->flags & COP_FLAG_AEAD_TLS_TYPE) { ++ ret = crypto_auth_zc_tls(ses_ptr, kcaop); ++ } else { ++ ret = crypto_auth_zc_aead(ses_ptr, kcaop); + } + + return ret; +-- +2.7.4 + diff --git a/recipes-kernel/cryptodev/sdk_patches/0002-add-support-for-COMPAT_CIOCAUTHCRYPT-ioctl.patch b/recipes-kernel/cryptodev/sdk_patches/0002-add-support-for-COMPAT_CIOCAUTHCRYPT-ioctl.patch deleted file mode 100644 index d83da974..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0002-add-support-for-COMPAT_CIOCAUTHCRYPT-ioctl.patch +++ /dev/null @@ -1,207 +0,0 @@ -From d9f27d08708556e22e1b1dc87b0495896879ca66 Mon Sep 17 00:00:00 2001 -From: Horia Geanta -Date: Wed, 4 Dec 2013 15:43:41 +0200 -Subject: [PATCH 02/38] add support for COMPAT_CIOCAUTHCRYPT ioctl() - -Upstream-status: Pending - -Needed for 64b kernel with 32b user space. - -Change-Id: I44a999a4164e7ae7122dee6ed0716b2f25cadbc1 -Signed-off-by: Horia Geanta -Tested-by: Cristian Stoica ---- - authenc.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - cryptodev_int.h | 40 +++++++++++++++++++++++++++++ - ioctl.c | 16 ++++++++++++ - 3 files changed, 134 insertions(+) - -diff --git a/authenc.c b/authenc.c -index 1bd7377..ef0d3db 100644 ---- a/authenc.c -+++ b/authenc.c -@@ -272,6 +272,84 @@ static int fill_caop_from_kcaop(struct kernel_crypt_auth_op *kcaop, struct fcryp - return 0; - } - -+/* compatibility code for 32bit userlands */ -+#ifdef CONFIG_COMPAT -+ -+static inline void -+compat_to_crypt_auth_op(struct compat_crypt_auth_op *compat, -+ struct crypt_auth_op *caop) -+{ -+ caop->ses = compat->ses; -+ caop->op = compat->op; -+ caop->flags = compat->flags; -+ caop->len = compat->len; -+ caop->auth_len = compat->auth_len; -+ caop->tag_len = compat->tag_len; -+ caop->iv_len = compat->iv_len; -+ -+ caop->auth_src = compat_ptr(compat->auth_src); -+ caop->src = compat_ptr(compat->src); -+ caop->dst = compat_ptr(compat->dst); -+ caop->tag = compat_ptr(compat->tag); -+ caop->iv = compat_ptr(compat->iv); -+} -+ -+static inline void -+crypt_auth_op_to_compat(struct crypt_auth_op *caop, -+ struct compat_crypt_auth_op *compat) -+{ -+ compat->ses = caop->ses; -+ compat->op = caop->op; -+ compat->flags = caop->flags; -+ compat->len = caop->len; -+ compat->auth_len = caop->auth_len; -+ compat->tag_len = caop->tag_len; -+ compat->iv_len = caop->iv_len; -+ -+ compat->auth_src = ptr_to_compat(caop->auth_src); -+ compat->src = ptr_to_compat(caop->src); -+ compat->dst = ptr_to_compat(caop->dst); -+ compat->tag = ptr_to_compat(caop->tag); -+ compat->iv = ptr_to_compat(caop->iv); -+} -+ -+int compat_kcaop_from_user(struct kernel_crypt_auth_op *kcaop, -+ struct fcrypt *fcr, void __user *arg) -+{ -+ struct compat_crypt_auth_op compat_caop; -+ -+ if (unlikely(copy_from_user(&compat_caop, arg, sizeof(compat_caop)))) { -+ dprintk(1, KERN_ERR, "Error in copying from userspace\n"); -+ return -EFAULT; -+ } -+ -+ compat_to_crypt_auth_op(&compat_caop, &kcaop->caop); -+ -+ return fill_kcaop_from_caop(kcaop, fcr); -+} -+ -+int compat_kcaop_to_user(struct kernel_crypt_auth_op *kcaop, -+ struct fcrypt *fcr, void __user *arg) -+{ -+ int ret; -+ struct compat_crypt_auth_op compat_caop; -+ -+ ret = fill_caop_from_kcaop(kcaop, fcr); -+ if (unlikely(ret)) { -+ dprintk(1, KERN_ERR, "fill_caop_from_kcaop\n"); -+ return ret; -+ } -+ -+ crypt_auth_op_to_compat(&kcaop->caop, &compat_caop); -+ -+ if (unlikely(copy_to_user(arg, &compat_caop, sizeof(compat_caop)))) { -+ dprintk(1, KERN_ERR, "Error in copying to userspace\n"); -+ return -EFAULT; -+ } -+ return 0; -+} -+ -+#endif /* CONFIG_COMPAT */ - - int kcaop_from_user(struct kernel_crypt_auth_op *kcaop, - struct fcrypt *fcr, void __user *arg) -diff --git a/cryptodev_int.h b/cryptodev_int.h -index d7660fa..8e687e7 100644 ---- a/cryptodev_int.h -+++ b/cryptodev_int.h -@@ -73,11 +73,42 @@ struct compat_crypt_op { - compat_uptr_t iv;/* initialization vector for encryption operations */ - }; - -+ /* input of CIOCAUTHCRYPT */ -+struct compat_crypt_auth_op { -+ uint32_t ses; /* session identifier */ -+ uint16_t op; /* COP_ENCRYPT or COP_DECRYPT */ -+ uint16_t flags; /* see COP_FLAG_AEAD_* */ -+ uint32_t len; /* length of source data */ -+ uint32_t auth_len; /* length of auth data */ -+ compat_uptr_t auth_src; /* authenticated-only data */ -+ -+ /* The current implementation is more efficient if data are -+ * encrypted in-place (src==dst). */ -+ compat_uptr_t src; /* data to be encrypted and -+ authenticated */ -+ compat_uptr_t dst; /* pointer to output data. Must have -+ * space for tag. For TLS this should be -+ * at least len + tag_size + block_size -+ * for padding */ -+ -+ compat_uptr_t tag; /* where the tag will be copied to. TLS -+ * mode doesn't use that as tag is -+ * copied to dst. -+ * SRTP mode copies tag there. */ -+ uint32_t tag_len; /* the length of the tag. Use zero for -+ * digest size or max tag. */ -+ -+ /* initialization vector for encryption operations */ -+ compat_uptr_t iv; -+ uint32_t iv_len; -+}; -+ - /* compat ioctls, defined for the above structs */ - #define COMPAT_CIOCGSESSION _IOWR('c', 102, struct compat_session_op) - #define COMPAT_CIOCCRYPT _IOWR('c', 104, struct compat_crypt_op) - #define COMPAT_CIOCASYNCCRYPT _IOW('c', 107, struct compat_crypt_op) - #define COMPAT_CIOCASYNCFETCH _IOR('c', 108, struct compat_crypt_op) -+#define COMPAT_CIOCAUTHCRYPT _IOWR('c', 109, struct compat_crypt_auth_op) - - #endif /* CONFIG_COMPAT */ - -@@ -108,6 +139,15 @@ struct kernel_crypt_auth_op { - - /* auth */ - -+#ifdef CONFIG_COMPAT -+int compat_kcaop_from_user(struct kernel_crypt_auth_op *kcaop, -+ struct fcrypt *fcr, void __user *arg); -+ -+int compat_kcaop_to_user(struct kernel_crypt_auth_op *kcaop, -+ struct fcrypt *fcr, void __user *arg); -+#endif /* CONFIG_COMPAT */ -+ -+ - int kcaop_from_user(struct kernel_crypt_auth_op *kcop, - struct fcrypt *fcr, void __user *arg); - int kcaop_to_user(struct kernel_crypt_auth_op *kcaop, -diff --git a/ioctl.c b/ioctl.c -index a3f8379..5a44807 100644 ---- a/ioctl.c -+++ b/ioctl.c -@@ -998,6 +998,7 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) - struct session_op sop; - struct compat_session_op compat_sop; - struct kernel_crypt_op kcop; -+ struct kernel_crypt_auth_op kcaop; - int ret; - - if (unlikely(!pcr)) -@@ -1040,6 +1041,21 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) - return ret; - - return compat_kcop_to_user(&kcop, fcr, arg); -+ -+ case COMPAT_CIOCAUTHCRYPT: -+ if (unlikely(ret = compat_kcaop_from_user(&kcaop, fcr, arg))) { -+ dprintk(1, KERN_WARNING, "Error copying from user\n"); -+ return ret; -+ } -+ -+ ret = crypto_auth_run(fcr, &kcaop); -+ if (unlikely(ret)) { -+ dprintk(1, KERN_WARNING, "Error in crypto_auth_run\n"); -+ return ret; -+ } -+ -+ return compat_kcaop_to_user(&kcaop, fcr, arg); -+ - #ifdef ENABLE_ASYNC - case COMPAT_CIOCASYNCCRYPT: - if (unlikely(ret = compat_kcop_from_user(&kcop, fcr, arg))) --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0002-refactoring-relocate-code-to-simplify-later-patches.patch b/recipes-kernel/cryptodev/sdk_patches/0002-refactoring-relocate-code-to-simplify-later-patches.patch new file mode 100644 index 00000000..b948c914 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0002-refactoring-relocate-code-to-simplify-later-patches.patch @@ -0,0 +1,58 @@ +From c2bf0e42b1d9fda60cde4a3a682784d349ef1c0b Mon Sep 17 00:00:00 2001 +From: Cristian Stoica +Date: Thu, 4 May 2017 15:06:21 +0300 +Subject: [PATCH 2/9] refactoring: relocate code to simplify later patches + +This code move will simplify the conversion to new AEAD interface in +next patches + +Signed-off-by: Cristian Stoica +--- + authenc.c | 17 +++++++++-------- + 1 file changed, 9 insertions(+), 8 deletions(-) + +diff --git a/authenc.c b/authenc.c +index 28eb0f9..95727b4 100644 +--- a/authenc.c ++++ b/authenc.c +@@ -711,11 +711,18 @@ static int crypto_auth_zc_aead(struct csession *ses_ptr, struct kernel_crypt_aut + return -ENOMEM; + } + ++ ret = get_userbuf(ses_ptr, caop->src, caop->len, caop->dst, kcaop->dst_len, ++ kcaop->task, kcaop->mm, &src_sg, &dst_sg); ++ if (unlikely(ret)) { ++ derr(1, "get_userbuf(): Error getting user pages."); ++ goto free_auth_buf; ++ } ++ + if (caop->auth_src && caop->auth_len > 0) { + if (unlikely(copy_from_user(auth_buf, caop->auth_src, caop->auth_len))) { + derr(1, "unable to copy auth data from userspace."); + ret = -EFAULT; +- goto free_auth_buf; ++ goto free_pages; + } + + sg_init_one(&tmp, auth_buf, caop->auth_len); +@@ -724,16 +731,10 @@ static int crypto_auth_zc_aead(struct csession *ses_ptr, struct kernel_crypt_aut + auth_sg = NULL; + } + +- ret = get_userbuf(ses_ptr, caop->src, caop->len, caop->dst, kcaop->dst_len, +- kcaop->task, kcaop->mm, &src_sg, &dst_sg); +- if (unlikely(ret)) { +- derr(1, "get_userbuf(): Error getting user pages."); +- goto free_auth_buf; +- } +- + ret = auth_n_crypt(ses_ptr, kcaop, auth_sg, caop->auth_len, + src_sg, dst_sg, caop->len); + ++free_pages: + release_user_pages(ses_ptr); + + free_auth_buf: +-- +2.7.4 + diff --git a/recipes-kernel/cryptodev/sdk_patches/0003-PKC-support-added-in-cryptodev-module.patch b/recipes-kernel/cryptodev/sdk_patches/0003-PKC-support-added-in-cryptodev-module.patch deleted file mode 100644 index ffa0b453..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0003-PKC-support-added-in-cryptodev-module.patch +++ /dev/null @@ -1,898 +0,0 @@ -From 2bda43095b511e0052b3bc27b216ff9909cc03d2 Mon Sep 17 00:00:00 2001 -From: Yashpal Dutta -Date: Fri, 7 Mar 2014 06:16:09 +0545 -Subject: [PATCH 03/38] PKC support added in cryptodev module - -Upstream-status: Pending - -Signed-off-by: Yashpal Dutta ---- - cryptlib.c | 66 +++++++++- - cryptlib.h | 28 ++++ - crypto/cryptodev.h | 15 ++- - cryptodev_int.h | 20 ++- - ioctl.c | 196 +++++++++++++++++++++++++-- - main.c | 378 +++++++++++++++++++++++++++++++++++++++++++++++++++++ - 6 files changed, 685 insertions(+), 18 deletions(-) - -diff --git a/cryptlib.c b/cryptlib.c -index 44ce763..6900028 100644 ---- a/cryptlib.c -+++ b/cryptlib.c -@@ -5,6 +5,8 @@ - * Portions Copyright (c) 2010 Michael Weiser - * Portions Copyright (c) 2010 Phil Sutter - * -+ * Copyright 2012 Freescale Semiconductor, Inc. -+ * - * This file is part of linux cryptodev. - * - * This program is free software; you can redistribute it and/or -@@ -39,11 +41,6 @@ - #include "cryptodev_int.h" - - --struct cryptodev_result { -- struct completion completion; -- int err; --}; -- - static void cryptodev_complete(struct crypto_async_request *req, int err) - { - struct cryptodev_result *res = req->data; -@@ -259,7 +256,6 @@ static inline int waitfor(struct cryptodev_result *cr, ssize_t ret) - case 0: - break; - case -EINPROGRESS: -- case -EBUSY: - wait_for_completion(&cr->completion); - /* At this point we known for sure the request has finished, - * because wait_for_completion above was not interruptible. -@@ -439,3 +435,61 @@ int cryptodev_hash_final(struct hash_data *hdata, void *output) - return waitfor(hdata->async.result, ret); - } - -+int cryptodev_pkc_offload(struct cryptodev_pkc *pkc) -+{ -+ int ret = 0; -+ struct pkc_request *pkc_req = &pkc->req, *pkc_requested; -+ -+ switch (pkc_req->type) { -+ case RSA_PUB: -+ case RSA_PRIV_FORM1: -+ case RSA_PRIV_FORM2: -+ case RSA_PRIV_FORM3: -+ pkc->s = crypto_alloc_pkc("pkc(rsa)", -+ CRYPTO_ALG_TYPE_PKC_RSA, 0); -+ break; -+ case DSA_SIGN: -+ case DSA_VERIFY: -+ case ECDSA_SIGN: -+ case ECDSA_VERIFY: -+ pkc->s = crypto_alloc_pkc("pkc(dsa)", -+ CRYPTO_ALG_TYPE_PKC_DSA, 0); -+ break; -+ case DH_COMPUTE_KEY: -+ case ECDH_COMPUTE_KEY: -+ pkc->s = crypto_alloc_pkc("pkc(dh)", -+ CRYPTO_ALG_TYPE_PKC_DH, 0); -+ break; -+ default: -+ return -EINVAL; -+ } -+ -+ if (IS_ERR_OR_NULL(pkc->s)) -+ return -EINVAL; -+ -+ init_completion(&pkc->result.completion); -+ pkc_requested = pkc_request_alloc(pkc->s, GFP_KERNEL); -+ -+ if (unlikely(IS_ERR_OR_NULL(pkc_requested))) { -+ ret = -ENOMEM; -+ goto error; -+ } -+ pkc_requested->type = pkc_req->type; -+ pkc_requested->curve_type = pkc_req->curve_type; -+ memcpy(&pkc_requested->req_u, &pkc_req->req_u, sizeof(pkc_req->req_u)); -+ pkc_request_set_callback(pkc_requested, CRYPTO_TFM_REQ_MAY_BACKLOG, -+ cryptodev_complete_asym, pkc); -+ ret = crypto_pkc_op(pkc_requested); -+ if (ret != -EINPROGRESS && ret != 0) -+ goto error2; -+ -+ if (pkc->type == SYNCHRONOUS) -+ ret = waitfor(&pkc->result, ret); -+ -+ return ret; -+error2: -+ kfree(pkc_requested); -+error: -+ crypto_free_pkc(pkc->s); -+ return ret; -+} -diff --git a/cryptlib.h b/cryptlib.h -index a0a8a63..56d325a 100644 ---- a/cryptlib.h -+++ b/cryptlib.h -@@ -1,3 +1,6 @@ -+/* -+ * Copyright 2012 Freescale Semiconductor, Inc. -+ */ - #ifndef CRYPTLIB_H - # define CRYPTLIB_H - -@@ -89,5 +92,30 @@ void cryptodev_hash_deinit(struct hash_data *hdata); - int cryptodev_hash_init(struct hash_data *hdata, const char *alg_name, - int hmac_mode, void *mackey, size_t mackeylen); - -+/* Operation Type */ -+enum offload_type { -+ SYNCHRONOUS, -+ ASYNCHRONOUS -+}; -+ -+struct cryptodev_result { -+ struct completion completion; -+ int err; -+}; -+ -+struct cryptodev_pkc { -+ struct list_head list; /* To maintain the Jobs in completed -+ cryptodev lists */ -+ struct kernel_crypt_kop kop; -+ struct crypto_pkc *s; /* Transform pointer from CryptoAPI */ -+ struct cryptodev_result result; /* Result to be updated by -+ completion handler */ -+ struct pkc_request req; /* PKC request structure allocated -+ from CryptoAPI */ -+ enum offload_type type; /* Synchronous Vs Asynchronous request */ -+ void *cookie; /*Additional opaque cookie to be used in future */ -+ struct crypt_priv *priv; -+}; - -+int cryptodev_pkc_offload(struct cryptodev_pkc *); - #endif -diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h -index c0e8cd4..96675fe 100644 ---- a/crypto/cryptodev.h -+++ b/crypto/cryptodev.h -@@ -1,6 +1,10 @@ --/* This is a source compatible implementation with the original API of -+/* -+ * Copyright 2012 Freescale Semiconductor, Inc. -+ * -+ * This is a source compatible implementation with the original API of - * cryptodev by Angelos D. Keromytis, found at openbsd cryptodev.h. -- * Placed under public domain */ -+ * Placed under public domain -+ */ - - #ifndef L_CRYPTODEV_H - #define L_CRYPTODEV_H -@@ -245,6 +249,9 @@ struct crypt_kop { - __u16 crk_oparams; - __u32 crk_pad1; - struct crparam crk_param[CRK_MAXPARAM]; -+ enum curve_t curve_type; /* 0 == Discrete Log, -+ 1 = EC_PRIME, 2 = EC_BINARY */ -+ void *cookie; - }; - - enum cryptodev_crk_op_t { -@@ -289,5 +296,7 @@ enum cryptodev_crk_op_t { - */ - #define CIOCASYNCCRYPT _IOW('c', 110, struct crypt_op) - #define CIOCASYNCFETCH _IOR('c', 111, struct crypt_op) -- -+/* additional ioctls for asynchronous operation for asymmetric ciphers*/ -+#define CIOCASYMASYNCRYPT _IOW('c', 112, struct crypt_kop) -+#define CIOCASYMASYNFETCH _IOR('c', 113, struct crypt_kop) - #endif /* L_CRYPTODEV_H */ -diff --git a/cryptodev_int.h b/cryptodev_int.h -index 8e687e7..fdbcc61 100644 ---- a/cryptodev_int.h -+++ b/cryptodev_int.h -@@ -1,4 +1,6 @@ --/* cipher stuff */ -+/* cipher stuff -+ * Copyright 2012 Freescale Semiconductor, Inc. -+ */ - #ifndef CRYPTODEV_INT_H - # define CRYPTODEV_INT_H - -@@ -112,6 +114,14 @@ struct compat_crypt_auth_op { - - #endif /* CONFIG_COMPAT */ - -+/* kernel-internal extension to struct crypt_kop */ -+struct kernel_crypt_kop { -+ struct crypt_kop kop; -+ -+ struct task_struct *task; -+ struct mm_struct *mm; -+}; -+ - /* kernel-internal extension to struct crypt_op */ - struct kernel_crypt_op { - struct crypt_op cop; -@@ -157,6 +167,14 @@ int crypto_run(struct fcrypt *fcr, struct kernel_crypt_op *kcop); - - #include - -+/* Cryptodev Key operation handler */ -+int crypto_bn_modexp(struct cryptodev_pkc *); -+int crypto_modexp_crt(struct cryptodev_pkc *); -+int crypto_kop_dsasign(struct cryptodev_pkc *); -+int crypto_kop_dsaverify(struct cryptodev_pkc *); -+int crypto_run_asym(struct cryptodev_pkc *); -+void cryptodev_complete_asym(struct crypto_async_request *, int); -+ - /* other internal structs */ - struct csession { - struct list_head entry; -diff --git a/ioctl.c b/ioctl.c -index 5a44807..69980e3 100644 ---- a/ioctl.c -+++ b/ioctl.c -@@ -4,6 +4,7 @@ - * Copyright (c) 2004 Michal Ludvig , SuSE Labs - * Copyright (c) 2009,2010,2011 Nikos Mavrogiannopoulos - * Copyright (c) 2010 Phil Sutter -+ * Copyright 2012 Freescale Semiconductor, Inc. - * - * This file is part of linux cryptodev. - * -@@ -89,8 +90,37 @@ struct crypt_priv { - int itemcount; - struct work_struct cryptask; - wait_queue_head_t user_waiter; -+ /* List of pending cryptodev_pkc asym requests */ -+ struct list_head asym_completed_list; -+ /* For addition/removal of entry in pending list of asymmetric request*/ -+ spinlock_t completion_lock; - }; - -+/* Asymmetric request Completion handler */ -+void cryptodev_complete_asym(struct crypto_async_request *req, int err) -+{ -+ struct cryptodev_pkc *pkc = req->data; -+ struct cryptodev_result *res = &pkc->result; -+ -+ crypto_free_pkc(pkc->s); -+ res->err = err; -+ if (pkc->type == SYNCHRONOUS) { -+ if (err == -EINPROGRESS) -+ return; -+ complete(&res->completion); -+ } else { -+ struct crypt_priv *pcr = pkc->priv; -+ unsigned long flags; -+ spin_lock_irqsave(&pcr->completion_lock, flags); -+ list_add_tail(&pkc->list, &pcr->asym_completed_list); -+ spin_unlock_irqrestore(&pcr->completion_lock, flags); -+ /* wake for POLLIN */ -+ wake_up_interruptible(&pcr->user_waiter); -+ } -+ -+ kfree(req); -+} -+ - #define FILL_SG(sg, ptr, len) \ - do { \ - (sg)->page = virt_to_page(ptr); \ -@@ -472,7 +502,8 @@ cryptodev_open(struct inode *inode, struct file *filp) - INIT_LIST_HEAD(&pcr->free.list); - INIT_LIST_HEAD(&pcr->todo.list); - INIT_LIST_HEAD(&pcr->done.list); -- -+ INIT_LIST_HEAD(&pcr->asym_completed_list); -+ spin_lock_init(&pcr->completion_lock); - INIT_WORK(&pcr->cryptask, cryptask_routine); - - init_waitqueue_head(&pcr->user_waiter); -@@ -639,6 +670,79 @@ static int crypto_async_fetch(struct crypt_priv *pcr, - } - #endif - -+/* get the first asym cipher completed job from the "done" queue -+ * -+ * returns: -+ * -EBUSY if no completed jobs are ready (yet) -+ * the return value otherwise */ -+static int crypto_async_fetch_asym(struct cryptodev_pkc *pkc) -+{ -+ int ret = 0; -+ struct kernel_crypt_kop *kop = &pkc->kop; -+ struct crypt_kop *ckop = &kop->kop; -+ struct pkc_request *pkc_req = &pkc->req; -+ -+ switch (ckop->crk_op) { -+ case CRK_MOD_EXP: -+ { -+ struct rsa_pub_req_s *rsa_req = &pkc_req->req_u.rsa_pub_req; -+ copy_to_user(ckop->crk_param[3].crp_p, rsa_req->g, -+ rsa_req->g_len); -+ } -+ break; -+ case CRK_MOD_EXP_CRT: -+ { -+ struct rsa_priv_frm3_req_s *rsa_req = -+ &pkc_req->req_u.rsa_priv_f3; -+ copy_to_user(ckop->crk_param[6].crp_p, -+ rsa_req->f, rsa_req->f_len); -+ } -+ break; -+ case CRK_DSA_SIGN: -+ { -+ struct dsa_sign_req_s *dsa_req = &pkc_req->req_u.dsa_sign; -+ -+ if (pkc_req->type == ECDSA_SIGN) { -+ copy_to_user(ckop->crk_param[6].crp_p, -+ dsa_req->c, dsa_req->d_len); -+ copy_to_user(ckop->crk_param[7].crp_p, -+ dsa_req->d, dsa_req->d_len); -+ } else { -+ copy_to_user(ckop->crk_param[5].crp_p, -+ dsa_req->c, dsa_req->d_len); -+ copy_to_user(ckop->crk_param[6].crp_p, -+ dsa_req->d, dsa_req->d_len); -+ } -+ } -+ break; -+ case CRK_DSA_VERIFY: -+ break; -+ case CRK_DH_COMPUTE_KEY: -+ { -+ struct dh_key_req_s *dh_req = &pkc_req->req_u.dh_req; -+ if (pkc_req->type == ECDH_COMPUTE_KEY) -+ copy_to_user(ckop->crk_param[4].crp_p, -+ dh_req->z, dh_req->z_len); -+ else -+ copy_to_user(ckop->crk_param[3].crp_p, -+ dh_req->z, dh_req->z_len); -+ } -+ break; -+ default: -+ ret = -EINVAL; -+ } -+ kfree(pkc->cookie); -+ return ret; -+} -+ -+/* this function has to be called from process context */ -+static int fill_kop_from_cop(struct kernel_crypt_kop *kop) -+{ -+ kop->task = current; -+ kop->mm = current->mm; -+ return 0; -+} -+ - /* this function has to be called from process context */ - static int fill_kcop_from_cop(struct kernel_crypt_op *kcop, struct fcrypt *fcr) - { -@@ -662,11 +766,8 @@ static int fill_kcop_from_cop(struct kernel_crypt_op *kcop, struct fcrypt *fcr) - - if (cop->iv) { - rc = copy_from_user(kcop->iv, cop->iv, kcop->ivlen); -- if (unlikely(rc)) { -- derr(1, "error copying IV (%d bytes), copy_from_user returned %d for address %p", -- kcop->ivlen, rc, cop->iv); -+ if (unlikely(rc)) - return -EFAULT; -- } - } - - return 0; -@@ -692,6 +793,25 @@ static int fill_cop_from_kcop(struct kernel_crypt_op *kcop, struct fcrypt *fcr) - return 0; - } - -+static int kop_from_user(struct kernel_crypt_kop *kop, -+ void __user *arg) -+{ -+ if (unlikely(copy_from_user(&kop->kop, arg, sizeof(kop->kop)))) -+ return -EFAULT; -+ -+ return fill_kop_from_cop(kop); -+} -+ -+static int kop_to_user(struct kernel_crypt_kop *kop, -+ void __user *arg) -+{ -+ if (unlikely(copy_to_user(arg, &kop->kop, sizeof(kop->kop)))) { -+ dprintk(1, KERN_ERR, "Cannot copy to userspace\n"); -+ return -EFAULT; -+ } -+ return 0; -+} -+ - static int kcop_from_user(struct kernel_crypt_op *kcop, - struct fcrypt *fcr, void __user *arg) - { -@@ -821,7 +941,8 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) - - switch (cmd) { - case CIOCASYMFEAT: -- return put_user(0, p); -+ return put_user(CRF_MOD_EXP_CRT | CRF_MOD_EXP | -+ CRF_DSA_SIGN | CRF_DSA_VERIFY | CRF_DH_COMPUTE_KEY, p); - case CRIOGET: - fd = clonefd(filp); - ret = put_user(fd, p); -@@ -857,6 +978,24 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) - if (unlikely(ret)) - return ret; - return copy_to_user(arg, &siop, sizeof(siop)); -+ case CIOCKEY: -+ { -+ struct cryptodev_pkc *pkc = -+ kzalloc(sizeof(struct cryptodev_pkc), GFP_KERNEL); -+ -+ if (!pkc) -+ return -ENOMEM; -+ -+ ret = kop_from_user(&pkc->kop, arg); -+ if (unlikely(ret)) { -+ kfree(pkc); -+ return ret; -+ } -+ pkc->type = SYNCHRONOUS; -+ ret = crypto_run_asym(pkc); -+ kfree(pkc); -+ } -+ return ret; - case CIOCCRYPT: - if (unlikely(ret = kcop_from_user(&kcop, fcr, arg))) { - dwarning(1, "Error copying from user"); -@@ -895,6 +1034,45 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) - - return kcop_to_user(&kcop, fcr, arg); - #endif -+ case CIOCASYMASYNCRYPT: -+ { -+ struct cryptodev_pkc *pkc = -+ kzalloc(sizeof(struct cryptodev_pkc), GFP_KERNEL); -+ ret = kop_from_user(&pkc->kop, arg); -+ -+ if (unlikely(ret)) -+ return -EINVAL; -+ -+ /* Store associated FD priv data with asymmetric request */ -+ pkc->priv = pcr; -+ pkc->type = ASYNCHRONOUS; -+ ret = crypto_run_asym(pkc); -+ if (ret == -EINPROGRESS) -+ ret = 0; -+ } -+ return ret; -+ case CIOCASYMASYNFETCH: -+ { -+ struct cryptodev_pkc *pkc; -+ unsigned long flags; -+ -+ spin_lock_irqsave(&pcr->completion_lock, flags); -+ if (list_empty(&pcr->asym_completed_list)) { -+ spin_unlock_irqrestore(&pcr->completion_lock, flags); -+ return -ENOMEM; -+ } -+ pkc = list_first_entry(&pcr->asym_completed_list, -+ struct cryptodev_pkc, list); -+ list_del(&pkc->list); -+ spin_unlock_irqrestore(&pcr->completion_lock, flags); -+ ret = crypto_async_fetch_asym(pkc); -+ -+ /* Reflect the updated request to user-space */ -+ if (!ret) -+ kop_to_user(&pkc->kop, arg); -+ kfree(pkc); -+ } -+ return ret; - default: - return -EINVAL; - } -@@ -1083,9 +1261,11 @@ static unsigned int cryptodev_poll(struct file *file, poll_table *wait) - - poll_wait(file, &pcr->user_waiter, wait); - -- if (!list_empty_careful(&pcr->done.list)) -+ if (!list_empty_careful(&pcr->done.list) || -+ !list_empty_careful(&pcr->asym_completed_list)) - ret |= POLLIN | POLLRDNORM; -- if (!list_empty_careful(&pcr->free.list) || pcr->itemcount < MAX_COP_RINGSIZE) -+ if (!list_empty_careful(&pcr->free.list) || -+ pcr->itemcount < MAX_COP_RINGSIZE) - ret |= POLLOUT | POLLWRNORM; - - return ret; -diff --git a/main.c b/main.c -index 57e5c38..0b7951e 100644 ---- a/main.c -+++ b/main.c -@@ -181,6 +181,384 @@ __crypto_run_zc(struct csession *ses_ptr, struct kernel_crypt_op *kcop) - return ret; - } - -+int crypto_kop_dsasign(struct cryptodev_pkc *pkc) -+{ -+ struct kernel_crypt_kop *kop = &pkc->kop; -+ struct crypt_kop *cop = &kop->kop; -+ struct pkc_request *pkc_req = &pkc->req; -+ struct dsa_sign_req_s *dsa_req = &pkc_req->req_u.dsa_sign; -+ int rc, buf_size; -+ uint8_t *buf; -+ -+ if (!cop->crk_param[0].crp_nbits || !cop->crk_param[1].crp_nbits || -+ !cop->crk_param[2].crp_nbits || !cop->crk_param[3].crp_nbits || -+ !cop->crk_param[4].crp_nbits || !cop->crk_param[5].crp_nbits || -+ !cop->crk_param[6].crp_nbits || (cop->crk_iparams == 6 && -+ !cop->crk_param[7].crp_nbits)) -+ return -EINVAL; -+ -+ dsa_req->m_len = (cop->crk_param[0].crp_nbits + 7)/8; -+ dsa_req->q_len = (cop->crk_param[1].crp_nbits + 7)/8; -+ dsa_req->r_len = (cop->crk_param[2].crp_nbits + 7)/8; -+ dsa_req->g_len = (cop->crk_param[3].crp_nbits + 7)/8; -+ dsa_req->priv_key_len = (cop->crk_param[4].crp_nbits + 7)/8; -+ dsa_req->d_len = (cop->crk_param[6].crp_nbits + 7)/8; -+ buf_size = dsa_req->m_len + dsa_req->q_len + dsa_req->r_len + -+ dsa_req->g_len + dsa_req->priv_key_len + dsa_req->d_len + -+ dsa_req->d_len; -+ if (cop->crk_iparams == 6) { -+ dsa_req->ab_len = (cop->crk_param[5].crp_nbits + 7)/8; -+ buf_size += dsa_req->ab_len; -+ pkc_req->type = ECDSA_SIGN; -+ pkc_req->curve_type = cop->curve_type; -+ } else { -+ pkc_req->type = DSA_SIGN; -+ } -+ -+ buf = kzalloc(buf_size, GFP_DMA); -+ -+ dsa_req->q = buf; -+ dsa_req->r = dsa_req->q + dsa_req->q_len; -+ dsa_req->g = dsa_req->r + dsa_req->r_len; -+ dsa_req->priv_key = dsa_req->g + dsa_req->g_len; -+ dsa_req->m = dsa_req->priv_key + dsa_req->priv_key_len; -+ dsa_req->c = dsa_req->m + dsa_req->m_len; -+ dsa_req->d = dsa_req->c + dsa_req->d_len; -+ copy_from_user(dsa_req->m, cop->crk_param[0].crp_p, dsa_req->m_len); -+ copy_from_user(dsa_req->q, cop->crk_param[1].crp_p, dsa_req->q_len); -+ copy_from_user(dsa_req->r, cop->crk_param[2].crp_p, dsa_req->r_len); -+ copy_from_user(dsa_req->g, cop->crk_param[3].crp_p, dsa_req->g_len); -+ copy_from_user(dsa_req->priv_key, cop->crk_param[4].crp_p, -+ dsa_req->priv_key_len); -+ if (cop->crk_iparams == 6) { -+ dsa_req->ab = dsa_req->d + dsa_req->d_len; -+ copy_from_user(dsa_req->ab, cop->crk_param[5].crp_p, -+ dsa_req->ab_len); -+ } -+ rc = cryptodev_pkc_offload(pkc); -+ if (pkc->type == SYNCHRONOUS) { -+ if (rc) -+ goto err; -+ if (cop->crk_iparams == 6) { -+ copy_to_user(cop->crk_param[6].crp_p, dsa_req->c, -+ dsa_req->d_len); -+ copy_to_user(cop->crk_param[7].crp_p, dsa_req->d, -+ dsa_req->d_len); -+ } else { -+ copy_to_user(cop->crk_param[5].crp_p, dsa_req->c, -+ dsa_req->d_len); -+ copy_to_user(cop->crk_param[6].crp_p, dsa_req->d, -+ dsa_req->d_len); -+ } -+ } else { -+ if (rc != -EINPROGRESS && rc != 0) -+ goto err; -+ -+ pkc->cookie = buf; -+ return rc; -+ } -+err: -+ kfree(buf); -+ return rc; -+} -+ -+int crypto_kop_dsaverify(struct cryptodev_pkc *pkc) -+{ -+ struct kernel_crypt_kop *kop = &pkc->kop; -+ struct crypt_kop *cop = &kop->kop; -+ struct pkc_request *pkc_req; -+ struct dsa_verify_req_s *dsa_req; -+ int rc, buf_size; -+ uint8_t *buf; -+ -+ if (!cop->crk_param[0].crp_nbits || !cop->crk_param[1].crp_nbits || -+ !cop->crk_param[2].crp_nbits || !cop->crk_param[3].crp_nbits || -+ !cop->crk_param[4].crp_nbits || !cop->crk_param[5].crp_nbits || -+ !cop->crk_param[6].crp_nbits || (cop->crk_iparams == 8 && -+ !cop->crk_param[7].crp_nbits)) -+ return -EINVAL; -+ -+ pkc_req = &pkc->req; -+ dsa_req = &pkc_req->req_u.dsa_verify; -+ dsa_req->m_len = (cop->crk_param[0].crp_nbits + 7)/8; -+ dsa_req->q_len = (cop->crk_param[1].crp_nbits + 7)/8; -+ dsa_req->r_len = (cop->crk_param[2].crp_nbits + 7)/8; -+ dsa_req->g_len = (cop->crk_param[3].crp_nbits + 7)/8; -+ dsa_req->pub_key_len = (cop->crk_param[4].crp_nbits + 7)/8; -+ dsa_req->d_len = (cop->crk_param[6].crp_nbits + 7)/8; -+ buf_size = dsa_req->m_len + dsa_req->q_len + dsa_req->r_len + -+ dsa_req->g_len + dsa_req->pub_key_len + dsa_req->d_len + -+ dsa_req->d_len; -+ if (cop->crk_iparams == 8) { -+ dsa_req->ab_len = (cop->crk_param[5].crp_nbits + 7)/8; -+ buf_size += dsa_req->ab_len; -+ pkc_req->type = ECDSA_VERIFY; -+ pkc_req->curve_type = cop->curve_type; -+ } else { -+ pkc_req->type = DSA_VERIFY; -+ } -+ -+ buf = kzalloc(buf_size, GFP_DMA); -+ -+ dsa_req->q = buf; -+ dsa_req->r = dsa_req->q + dsa_req->q_len; -+ dsa_req->g = dsa_req->r + dsa_req->r_len; -+ dsa_req->pub_key = dsa_req->g + dsa_req->g_len; -+ dsa_req->m = dsa_req->pub_key + dsa_req->pub_key_len; -+ dsa_req->c = dsa_req->m + dsa_req->m_len; -+ dsa_req->d = dsa_req->c + dsa_req->d_len; -+ copy_from_user(dsa_req->m, cop->crk_param[0].crp_p, dsa_req->m_len); -+ copy_from_user(dsa_req->q, cop->crk_param[1].crp_p, dsa_req->q_len); -+ copy_from_user(dsa_req->r, cop->crk_param[2].crp_p, dsa_req->r_len); -+ copy_from_user(dsa_req->g, cop->crk_param[3].crp_p, dsa_req->g_len); -+ copy_from_user(dsa_req->pub_key, cop->crk_param[4].crp_p, -+ dsa_req->pub_key_len); -+ if (cop->crk_iparams == 8) { -+ dsa_req->ab = dsa_req->d + dsa_req->d_len; -+ copy_from_user(dsa_req->ab, cop->crk_param[5].crp_p, -+ dsa_req->ab_len); -+ copy_from_user(dsa_req->c, cop->crk_param[6].crp_p, -+ dsa_req->d_len); -+ copy_from_user(dsa_req->d, cop->crk_param[7].crp_p, -+ dsa_req->d_len); -+ } else { -+ copy_from_user(dsa_req->c, cop->crk_param[5].crp_p, -+ dsa_req->d_len); -+ copy_from_user(dsa_req->d, cop->crk_param[6].crp_p, -+ dsa_req->d_len); -+ } -+ rc = cryptodev_pkc_offload(pkc); -+ if (pkc->type == SYNCHRONOUS) { -+ if (rc) -+ goto err; -+ } else { -+ if (rc != -EINPROGRESS && !rc) -+ goto err; -+ pkc->cookie = buf; -+ return rc; -+ } -+err: -+ kfree(buf); -+ return rc; -+} -+ -+int crypto_kop_dh_key(struct cryptodev_pkc *pkc) -+{ -+ struct kernel_crypt_kop *kop = &pkc->kop; -+ struct crypt_kop *cop = &kop->kop; -+ struct pkc_request *pkc_req; -+ struct dh_key_req_s *dh_req; -+ int buf_size; -+ uint8_t *buf; -+ int rc = -EINVAL; -+ -+ pkc_req = &pkc->req; -+ dh_req = &pkc_req->req_u.dh_req; -+ dh_req->s_len = (cop->crk_param[0].crp_nbits + 7)/8; -+ dh_req->pub_key_len = (cop->crk_param[1].crp_nbits + 7)/8; -+ dh_req->q_len = (cop->crk_param[2].crp_nbits + 7)/8; -+ buf_size = dh_req->q_len + dh_req->pub_key_len + dh_req->s_len; -+ if (cop->crk_iparams == 4) { -+ pkc_req->type = ECDH_COMPUTE_KEY; -+ dh_req->ab_len = (cop->crk_param[3].crp_nbits + 7)/8; -+ dh_req->z_len = (cop->crk_param[4].crp_nbits + 7)/8; -+ buf_size += dh_req->ab_len; -+ } else { -+ dh_req->z_len = (cop->crk_param[3].crp_nbits + 7)/8; -+ pkc_req->type = DH_COMPUTE_KEY; -+ } -+ buf_size += dh_req->z_len; -+ buf = kzalloc(buf_size, GFP_DMA); -+ dh_req->q = buf; -+ dh_req->s = dh_req->q + dh_req->q_len; -+ dh_req->pub_key = dh_req->s + dh_req->s_len; -+ dh_req->z = dh_req->pub_key + dh_req->pub_key_len; -+ if (cop->crk_iparams == 4) { -+ dh_req->ab = dh_req->z + dh_req->z_len; -+ pkc_req->curve_type = cop->curve_type; -+ copy_from_user(dh_req->ab, cop->crk_param[3].crp_p, -+ dh_req->ab_len); -+ } -+ copy_from_user(dh_req->s, cop->crk_param[0].crp_p, dh_req->s_len); -+ copy_from_user(dh_req->pub_key, cop->crk_param[1].crp_p, -+ dh_req->pub_key_len); -+ copy_from_user(dh_req->q, cop->crk_param[2].crp_p, dh_req->q_len); -+ rc = cryptodev_pkc_offload(pkc); -+ if (pkc->type == SYNCHRONOUS) { -+ if (rc) -+ goto err; -+ if (cop->crk_iparams == 4) -+ copy_to_user(cop->crk_param[4].crp_p, dh_req->z, -+ dh_req->z_len); -+ else -+ copy_to_user(cop->crk_param[3].crp_p, dh_req->z, -+ dh_req->z_len); -+ } else { -+ if (rc != -EINPROGRESS && rc != 0) -+ goto err; -+ -+ pkc->cookie = buf; -+ return rc; -+ } -+err: -+ kfree(buf); -+ return rc; -+} -+ -+int crypto_modexp_crt(struct cryptodev_pkc *pkc) -+{ -+ struct kernel_crypt_kop *kop = &pkc->kop; -+ struct crypt_kop *cop = &kop->kop; -+ struct pkc_request *pkc_req; -+ struct rsa_priv_frm3_req_s *rsa_req; -+ int rc; -+ uint8_t *buf; -+ -+ if (!cop->crk_param[0].crp_nbits || !cop->crk_param[1].crp_nbits || -+ !cop->crk_param[2].crp_nbits || !cop->crk_param[3].crp_nbits || -+ !cop->crk_param[4].crp_nbits || !cop->crk_param[5].crp_nbits) -+ return -EINVAL; -+ -+ pkc_req = &pkc->req; -+ pkc_req->type = RSA_PRIV_FORM3; -+ rsa_req = &pkc_req->req_u.rsa_priv_f3; -+ rsa_req->p_len = (cop->crk_param[0].crp_nbits + 7)/8; -+ rsa_req->q_len = (cop->crk_param[1].crp_nbits + 7)/8; -+ rsa_req->g_len = (cop->crk_param[2].crp_nbits + 7)/8; -+ rsa_req->dp_len = (cop->crk_param[3].crp_nbits + 7)/8; -+ rsa_req->dq_len = (cop->crk_param[4].crp_nbits + 7)/8; -+ rsa_req->c_len = (cop->crk_param[5].crp_nbits + 7)/8; -+ rsa_req->f_len = (cop->crk_param[6].crp_nbits + 7)/8; -+ buf = kzalloc(rsa_req->p_len + rsa_req->q_len + rsa_req->f_len + -+ rsa_req->dp_len + rsa_req->dp_len + rsa_req->c_len + -+ rsa_req->g_len, GFP_DMA); -+ rsa_req->p = buf; -+ rsa_req->q = rsa_req->p + rsa_req->p_len; -+ rsa_req->g = rsa_req->q + rsa_req->q_len; -+ rsa_req->dp = rsa_req->g + rsa_req->g_len; -+ rsa_req->dq = rsa_req->dp + rsa_req->dp_len; -+ rsa_req->c = rsa_req->dq + rsa_req->dq_len; -+ rsa_req->f = rsa_req->c + rsa_req->c_len; -+ copy_from_user(rsa_req->p, cop->crk_param[0].crp_p, rsa_req->p_len); -+ copy_from_user(rsa_req->q, cop->crk_param[1].crp_p, rsa_req->q_len); -+ copy_from_user(rsa_req->g, cop->crk_param[2].crp_p, rsa_req->g_len); -+ copy_from_user(rsa_req->dp, cop->crk_param[3].crp_p, rsa_req->dp_len); -+ copy_from_user(rsa_req->dq, cop->crk_param[4].crp_p, rsa_req->dq_len); -+ copy_from_user(rsa_req->c, cop->crk_param[5].crp_p, rsa_req->c_len); -+ rc = cryptodev_pkc_offload(pkc); -+ -+ if (pkc->type == SYNCHRONOUS) { -+ if (rc) -+ goto err; -+ copy_to_user(cop->crk_param[6].crp_p, rsa_req->f, -+ rsa_req->f_len); -+ } else { -+ if (rc != -EINPROGRESS && rc != 0) -+ goto err; -+ -+ pkc->cookie = buf; -+ return rc; -+ } -+err: -+ kfree(buf); -+ return rc; -+} -+ -+int crypto_bn_modexp(struct cryptodev_pkc *pkc) -+{ -+ struct pkc_request *pkc_req; -+ struct rsa_pub_req_s *rsa_req; -+ int rc; -+ struct kernel_crypt_kop *kop = &pkc->kop; -+ struct crypt_kop *cop = &kop->kop; -+ uint8_t *buf; -+ -+ if (!cop->crk_param[0].crp_nbits || !cop->crk_param[1].crp_nbits || -+ !cop->crk_param[2].crp_nbits || !cop->crk_param[3].crp_nbits) -+ return -EINVAL; -+ -+ pkc_req = &pkc->req; -+ pkc_req->type = RSA_PUB; -+ rsa_req = &pkc_req->req_u.rsa_pub_req; -+ rsa_req->f_len = (cop->crk_param[0].crp_nbits + 7)/8; -+ rsa_req->e_len = (cop->crk_param[1].crp_nbits + 7)/8; -+ rsa_req->n_len = (cop->crk_param[2].crp_nbits + 7)/8; -+ rsa_req->g_len = (cop->crk_param[3].crp_nbits + 7)/8; -+ buf = kzalloc(rsa_req->f_len + rsa_req->e_len + rsa_req->n_len -+ + rsa_req->g_len, GFP_DMA); -+ if (!buf) -+ return -ENOMEM; -+ -+ rsa_req->e = buf; -+ rsa_req->f = rsa_req->e + rsa_req->e_len; -+ rsa_req->g = rsa_req->f + rsa_req->f_len; -+ rsa_req->n = rsa_req->g + rsa_req->g_len; -+ copy_from_user(rsa_req->f, cop->crk_param[0].crp_p, rsa_req->f_len); -+ copy_from_user(rsa_req->e, cop->crk_param[1].crp_p, rsa_req->e_len); -+ copy_from_user(rsa_req->n, cop->crk_param[2].crp_p, rsa_req->n_len); -+ rc = cryptodev_pkc_offload(pkc); -+ if (pkc->type == SYNCHRONOUS) { -+ if (rc) -+ goto err; -+ -+ copy_to_user(cop->crk_param[3].crp_p, rsa_req->g, -+ rsa_req->g_len); -+ } else { -+ if (rc != -EINPROGRESS && rc != 0) -+ goto err; -+ -+ /* This one will be freed later in fetch handler */ -+ pkc->cookie = buf; -+ return rc; -+ } -+err: -+ kfree(buf); -+ return rc; -+} -+ -+int crypto_run_asym(struct cryptodev_pkc *pkc) -+{ -+ int ret = -EINVAL; -+ struct kernel_crypt_kop *kop = &pkc->kop; -+ -+ switch (kop->kop.crk_op) { -+ case CRK_MOD_EXP: -+ if (kop->kop.crk_iparams != 3 && kop->kop.crk_oparams != 1) -+ goto err; -+ -+ ret = crypto_bn_modexp(pkc); -+ break; -+ case CRK_MOD_EXP_CRT: -+ if (kop->kop.crk_iparams != 6 && kop->kop.crk_oparams != 1) -+ goto err; -+ -+ ret = crypto_modexp_crt(pkc); -+ break; -+ case CRK_DSA_SIGN: -+ if ((kop->kop.crk_iparams != 5 && kop->kop.crk_iparams != 6) || -+ kop->kop.crk_oparams != 2) -+ goto err; -+ -+ ret = crypto_kop_dsasign(pkc); -+ break; -+ case CRK_DSA_VERIFY: -+ if ((kop->kop.crk_iparams != 7 && kop->kop.crk_iparams != 8) || -+ kop->kop.crk_oparams != 0) -+ goto err; -+ -+ ret = crypto_kop_dsaverify(pkc); -+ break; -+ case CRK_DH_COMPUTE_KEY: -+ if ((kop->kop.crk_iparams != 3 && kop->kop.crk_iparams != 4) || -+ kop->kop.crk_oparams != 1) -+ goto err; -+ ret = crypto_kop_dh_key(pkc); -+ break; -+ } -+err: -+ return ret; -+} -+ - int crypto_run(struct fcrypt *fcr, struct kernel_crypt_op *kcop) - { - struct csession *ses_ptr; --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0003-convert-to-new-AEAD-interface-in-kernels-v4.2.patch b/recipes-kernel/cryptodev/sdk_patches/0003-convert-to-new-AEAD-interface-in-kernels-v4.2.patch new file mode 100644 index 00000000..ab3c7a81 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0003-convert-to-new-AEAD-interface-in-kernels-v4.2.patch @@ -0,0 +1,96 @@ +From a705360197260d28535746ae98c461ba2cfb7a9e Mon Sep 17 00:00:00 2001 +From: Cristian Stoica +Date: Thu, 4 May 2017 15:06:22 +0300 +Subject: [PATCH 3/9] convert to new AEAD interface in kernels v4.2+ + +The crypto API for AEAD ciphers changed in recent kernels so that +associated data is now part of both source and destination scatter +gathers. The source, destination and associated data buffers need +to be stiched accordingly for the operations to succeed: + +src_sg: auth_buf + src_buf +dst_sg: auth_buf + (dst_buf + tag space) + +This patch fixes a kernel crash observed with cipher-gcm test. + +See also kernel patch: 81c4c35eb61a69c229871c490b011c1171511d5a + crypto: ccm - Convert to new AEAD interface + +Reported-by: Phil Sutter +Signed-off-by: Cristian Stoica +--- + authenc.c | 40 ++++++++++++++++++++++++++++++++++++++-- + 1 file changed, 38 insertions(+), 2 deletions(-) + +diff --git a/authenc.c b/authenc.c +index 95727b4..692951f 100644 +--- a/authenc.c ++++ b/authenc.c +@@ -688,12 +688,20 @@ free_auth_buf: + + static int crypto_auth_zc_aead(struct csession *ses_ptr, struct kernel_crypt_auth_op *kcaop) + { +- struct scatterlist *dst_sg, *auth_sg, *src_sg; ++ struct scatterlist *dst_sg; ++ struct scatterlist *src_sg; + struct crypt_auth_op *caop = &kcaop->caop; + unsigned char *auth_buf = NULL; +- struct scatterlist tmp; + int ret; + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0)) ++ struct scatterlist tmp; ++ struct scatterlist *auth_sg; ++#else ++ struct scatterlist auth1[2]; ++ struct scatterlist auth2[2]; ++#endif ++ + if (unlikely(ses_ptr->cdata.init == 0 || + (ses_ptr->cdata.stream == 0 && ses_ptr->cdata.aead == 0))) { + derr(0, "Only stream and AEAD ciphers are allowed for authenc"); +@@ -718,6 +726,7 @@ static int crypto_auth_zc_aead(struct csession *ses_ptr, struct kernel_crypt_aut + goto free_auth_buf; + } + ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0)) + if (caop->auth_src && caop->auth_len > 0) { + if (unlikely(copy_from_user(auth_buf, caop->auth_src, caop->auth_len))) { + derr(1, "unable to copy auth data from userspace."); +@@ -733,6 +742,33 @@ static int crypto_auth_zc_aead(struct csession *ses_ptr, struct kernel_crypt_aut + + ret = auth_n_crypt(ses_ptr, kcaop, auth_sg, caop->auth_len, + src_sg, dst_sg, caop->len); ++#else ++ if (caop->auth_src && caop->auth_len > 0) { ++ if (unlikely(copy_from_user(auth_buf, caop->auth_src, caop->auth_len))) { ++ derr(1, "unable to copy auth data from userspace."); ++ ret = -EFAULT; ++ goto free_pages; ++ } ++ ++ sg_init_table(auth1, 2); ++ sg_set_buf(auth1, auth_buf, caop->auth_len); ++ sg_chain(auth1, 2, src_sg); ++ ++ if (src_sg == dst_sg) { ++ src_sg = auth1; ++ dst_sg = auth1; ++ } else { ++ sg_init_table(auth2, 2); ++ sg_set_buf(auth2, auth_buf, caop->auth_len); ++ sg_chain(auth2, 2, dst_sg); ++ src_sg = auth1; ++ dst_sg = auth2; ++ } ++ } ++ ++ ret = auth_n_crypt(ses_ptr, kcaop, NULL, caop->auth_len, ++ src_sg, dst_sg, caop->len); ++#endif + + free_pages: + release_user_pages(ses_ptr); +-- +2.7.4 + diff --git a/recipes-kernel/cryptodev/sdk_patches/0004-Compat-versions-of-PKC-IOCTLs.patch b/recipes-kernel/cryptodev/sdk_patches/0004-Compat-versions-of-PKC-IOCTLs.patch deleted file mode 100644 index e963f589..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0004-Compat-versions-of-PKC-IOCTLs.patch +++ /dev/null @@ -1,200 +0,0 @@ -From e0e5c1bfb21888bf9f87f72ac8cdf7eee951f619 Mon Sep 17 00:00:00 2001 -From: Yashpal Dutta -Date: Fri, 7 Mar 2014 06:52:13 +0545 -Subject: [PATCH 04/38] Compat versions of PKC IOCTLs - -Upstream-status: Pending - -Signed-off-by: Yashpal Dutta ---- - cryptodev_int.h | 20 ++++++++++ - ioctl.c | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 140 insertions(+) - -diff --git a/cryptodev_int.h b/cryptodev_int.h -index fdbcc61..cf54dac 100644 ---- a/cryptodev_int.h -+++ b/cryptodev_int.h -@@ -75,6 +75,24 @@ struct compat_crypt_op { - compat_uptr_t iv;/* initialization vector for encryption operations */ - }; - -+/* input of CIOCKEY */ -+struct compat_crparam { -+ compat_uptr_t crp_p; -+ uint32_t crp_nbits; -+}; -+ -+struct compat_crypt_kop { -+ uint32_t crk_op; /* cryptodev_crk_ot_t */ -+ uint32_t crk_status; -+ uint16_t crk_iparams; -+ uint16_t crk_oparams; -+ uint32_t crk_pad1; -+ struct compat_crparam crk_param[CRK_MAXPARAM]; -+ enum curve_t curve_type; /* 0 == Discrete Log, 1 = EC_PRIME, -+ 2 = EC_BINARY */ -+ compat_uptr_t cookie; -+}; -+ - /* input of CIOCAUTHCRYPT */ - struct compat_crypt_auth_op { - uint32_t ses; /* session identifier */ -@@ -111,6 +129,8 @@ struct compat_crypt_auth_op { - #define COMPAT_CIOCASYNCCRYPT _IOW('c', 107, struct compat_crypt_op) - #define COMPAT_CIOCASYNCFETCH _IOR('c', 108, struct compat_crypt_op) - #define COMPAT_CIOCAUTHCRYPT _IOWR('c', 109, struct compat_crypt_auth_op) -+#define COMPAT_CIOCASYMASYNCRYPT _IOW('c', 110, struct compat_crypt_kop) -+#define COMPAT_CIOCASYMASYNFETCH _IOR('c', 111, struct compat_crypt_kop) - - #endif /* CONFIG_COMPAT */ - -diff --git a/ioctl.c b/ioctl.c -index 69980e3..9431025 100644 ---- a/ioctl.c -+++ b/ioctl.c -@@ -1081,6 +1081,68 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) - /* compatibility code for 32bit userlands */ - #ifdef CONFIG_COMPAT - -+static inline void compat_to_crypt_kop(struct compat_crypt_kop *compat, -+ struct crypt_kop *kop) -+{ -+ int i; -+ kop->crk_op = compat->crk_op; -+ kop->crk_status = compat->crk_status; -+ kop->crk_iparams = compat->crk_iparams; -+ kop->crk_oparams = compat->crk_oparams; -+ -+ for (i = 0; i < CRK_MAXPARAM; i++) { -+ kop->crk_param[i].crp_p = -+ compat_ptr(compat->crk_param[i].crp_p); -+ kop->crk_param[i].crp_nbits = compat->crk_param[i].crp_nbits; -+ } -+ -+ kop->curve_type = compat->curve_type; -+ kop->cookie = compat->cookie; -+} -+ -+static int compat_kop_from_user(struct kernel_crypt_kop *kop, -+ void __user *arg) -+{ -+ struct compat_crypt_kop compat_kop; -+ -+ if (unlikely(copy_from_user(&compat_kop, arg, sizeof(compat_kop)))) -+ return -EFAULT; -+ -+ compat_to_crypt_kop(&compat_kop, &kop->kop); -+ return fill_kop_from_cop(kop); -+} -+ -+static inline void crypt_kop_to_compat(struct crypt_kop *kop, -+ struct compat_crypt_kop *compat) -+{ -+ int i; -+ -+ compat->crk_op = kop->crk_op; -+ compat->crk_status = kop->crk_status; -+ compat->crk_iparams = kop->crk_iparams; -+ compat->crk_oparams = kop->crk_oparams; -+ -+ for (i = 0; i < CRK_MAXPARAM; i++) { -+ compat->crk_param[i].crp_p = -+ ptr_to_compat(kop->crk_param[i].crp_p); -+ compat->crk_param[i].crp_nbits = kop->crk_param[i].crp_nbits; -+ } -+ compat->cookie = kop->cookie; -+ compat->curve_type = kop->curve_type; -+} -+ -+static int compat_kop_to_user(struct kernel_crypt_kop *kop, void __user *arg) -+{ -+ struct compat_crypt_kop compat_kop; -+ -+ crypt_kop_to_compat(&kop->kop, &compat_kop); -+ if (unlikely(copy_to_user(arg, &compat_kop, sizeof(compat_kop)))) { -+ dprintk(1, KERN_ERR, "Cannot copy to userspace\n"); -+ return -EFAULT; -+ } -+ return 0; -+} -+ - static inline void - compat_to_session_op(struct compat_session_op *compat, struct session_op *sop) - { -@@ -1208,7 +1270,26 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) - return -EFAULT; - } - return ret; -+ case COMPAT_CIOCKEY: -+ { -+ struct cryptodev_pkc *pkc = -+ kzalloc(sizeof(struct cryptodev_pkc), GFP_KERNEL); -+ -+ if (!pkc) -+ return -ENOMEM; -+ -+ ret = compat_kop_from_user(&pkc->kop, arg); -+ -+ if (unlikely(ret)) { -+ kfree(pkc); -+ return ret; -+ } - -+ pkc->type = SYNCHRONOUS; -+ ret = crypto_run_asym(pkc); -+ kfree(pkc); -+ } -+ return ret; - case COMPAT_CIOCCRYPT: - ret = compat_kcop_from_user(&kcop, fcr, arg); - if (unlikely(ret)) -@@ -1247,6 +1328,45 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) - - return compat_kcop_to_user(&kcop, fcr, arg); - #endif -+ case COMPAT_CIOCASYMASYNCRYPT: -+ { -+ struct cryptodev_pkc *pkc = -+ kzalloc(sizeof(struct cryptodev_pkc), GFP_KERNEL); -+ -+ ret = compat_kop_from_user(&pkc->kop, arg); -+ if (unlikely(ret)) -+ return -EINVAL; -+ -+ /* Store associated FD priv data with asymmetric request */ -+ pkc->priv = pcr; -+ pkc->type = ASYNCHRONOUS; -+ ret = crypto_run_asym(pkc); -+ if (ret == -EINPROGRESS) -+ ret = 0; -+ } -+ return ret; -+ case COMPAT_CIOCASYMASYNFETCH: -+ { -+ struct cryptodev_pkc *pkc; -+ unsigned long flags; -+ -+ spin_lock_irqsave(&pcr->completion_lock, flags); -+ if (list_empty(&pcr->asym_completed_list)) { -+ spin_unlock_irqrestore(&pcr->completion_lock, flags); -+ return -ENOMEM; -+ } -+ pkc = list_first_entry(&pcr->asym_completed_list, -+ struct cryptodev_pkc, list); -+ list_del(&pkc->list); -+ spin_unlock_irqrestore(&pcr->completion_lock, flags); -+ ret = crypto_async_fetch_asym(pkc); -+ -+ /* Reflect the updated request to user-space */ -+ if (!ret) -+ compat_kop_to_user(&pkc->kop, arg); -+ kfree(pkc); -+ } -+ return ret; - default: - return -EINVAL; - } --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0004-fix-type-of-returned-value.patch b/recipes-kernel/cryptodev/sdk_patches/0004-fix-type-of-returned-value.patch new file mode 100644 index 00000000..faad6cc5 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0004-fix-type-of-returned-value.patch @@ -0,0 +1,29 @@ +From 1d7c84838445981a06812869f8906bdef52e69eb Mon Sep 17 00:00:00 2001 +From: Cristian Stoica +Date: Mon, 15 Feb 2016 18:27:35 +0200 +Subject: [PATCH 4/9] fix type of returned value + +The function is declared as unsigned int so we return an +unsigned int as well + +Signed-off-by: Cristian Stoica +--- + ioctl.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/ioctl.c b/ioctl.c +index 0385203..db7207a 100644 +--- a/ioctl.c ++++ b/ioctl.c +@@ -1065,7 +1065,7 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) + static unsigned int cryptodev_poll(struct file *file, poll_table *wait) + { + struct crypt_priv *pcr = file->private_data; +- int ret = 0; ++ unsigned int ret = 0; + + poll_wait(file, &pcr->user_waiter, wait); + +-- +2.7.4 + diff --git a/recipes-kernel/cryptodev/sdk_patches/0005-Asynchronous-interface-changes-in-cryptodev.patch b/recipes-kernel/cryptodev/sdk_patches/0005-Asynchronous-interface-changes-in-cryptodev.patch deleted file mode 100644 index 5b96e841..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0005-Asynchronous-interface-changes-in-cryptodev.patch +++ /dev/null @@ -1,213 +0,0 @@ -From d98f979d76c30058da24e62220f19c5b8c627819 Mon Sep 17 00:00:00 2001 -From: Yashpal Dutta -Date: Fri, 7 Mar 2014 07:24:00 +0545 -Subject: [PATCH 05/38] Asynchronous interface changes in cryptodev - -Upstream-status: Pending - -Signed-off-by: Yashpal Dutta ---- - cryptlib.h | 7 ++++- - crypto/cryptodev.h | 10 ++++++- - cryptodev_int.h | 10 ++++++- - ioctl.c | 76 +++++++++++++++++++++++++++++++++++++----------------- - 4 files changed, 76 insertions(+), 27 deletions(-) - -diff --git a/cryptlib.h b/cryptlib.h -index 56d325a..7ffa54c 100644 ---- a/cryptlib.h -+++ b/cryptlib.h -@@ -113,7 +113,12 @@ struct cryptodev_pkc { - struct pkc_request req; /* PKC request structure allocated - from CryptoAPI */ - enum offload_type type; /* Synchronous Vs Asynchronous request */ -- void *cookie; /*Additional opaque cookie to be used in future */ -+ /* -+ * cookie used for transfering tranparent information from async -+ * submission to async fetch. Currently some dynamic allocated -+ * buffers are maintained which will be freed later during fetch -+ */ -+ void *cookie; - struct crypt_priv *priv; - }; - -diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h -index 96675fe..4436fbf 100644 ---- a/crypto/cryptodev.h -+++ b/crypto/cryptodev.h -@@ -254,6 +254,14 @@ struct crypt_kop { - void *cookie; - }; - -+#define MAX_COOKIES 4 -+ -+struct pkc_cookie_list_s { -+ int cookie_available; -+ void *cookie[MAX_COOKIES]; -+ int status[MAX_COOKIES]; -+}; -+ - enum cryptodev_crk_op_t { - CRK_MOD_EXP = 0, - CRK_MOD_EXP_CRT = 1, -@@ -298,5 +306,5 @@ enum cryptodev_crk_op_t { - #define CIOCASYNCFETCH _IOR('c', 111, struct crypt_op) - /* additional ioctls for asynchronous operation for asymmetric ciphers*/ - #define CIOCASYMASYNCRYPT _IOW('c', 112, struct crypt_kop) --#define CIOCASYMASYNFETCH _IOR('c', 113, struct crypt_kop) -+#define CIOCASYMFETCHCOOKIE _IOR('c', 113, struct pkc_cookie_list_s) - #endif /* L_CRYPTODEV_H */ -diff --git a/cryptodev_int.h b/cryptodev_int.h -index cf54dac..5347cae 100644 ---- a/cryptodev_int.h -+++ b/cryptodev_int.h -@@ -93,6 +93,12 @@ struct compat_crypt_kop { - compat_uptr_t cookie; - }; - -+struct compat_pkc_cookie_list_s { -+ int cookie_available; -+ compat_uptr_t cookie[MAX_COOKIES]; -+ int status[MAX_COOKIES]; -+}; -+ - /* input of CIOCAUTHCRYPT */ - struct compat_crypt_auth_op { - uint32_t ses; /* session identifier */ -@@ -126,11 +132,13 @@ struct compat_crypt_auth_op { - /* compat ioctls, defined for the above structs */ - #define COMPAT_CIOCGSESSION _IOWR('c', 102, struct compat_session_op) - #define COMPAT_CIOCCRYPT _IOWR('c', 104, struct compat_crypt_op) -+#define COMPAT_CIOCKEY _IOW('c', 105, struct compat_crypt_kop) - #define COMPAT_CIOCASYNCCRYPT _IOW('c', 107, struct compat_crypt_op) - #define COMPAT_CIOCASYNCFETCH _IOR('c', 108, struct compat_crypt_op) - #define COMPAT_CIOCAUTHCRYPT _IOWR('c', 109, struct compat_crypt_auth_op) - #define COMPAT_CIOCASYMASYNCRYPT _IOW('c', 110, struct compat_crypt_kop) --#define COMPAT_CIOCASYMASYNFETCH _IOR('c', 111, struct compat_crypt_kop) -+#define COMPAT_CIOCASYMFETCHCOOKIE _IOR('c', 111, \ -+ struct compat_pkc_cookie_list_s) - - #endif /* CONFIG_COMPAT */ - -diff --git a/ioctl.c b/ioctl.c -index 9431025..e2f407f 100644 ---- a/ioctl.c -+++ b/ioctl.c -@@ -105,8 +105,6 @@ void cryptodev_complete_asym(struct crypto_async_request *req, int err) - crypto_free_pkc(pkc->s); - res->err = err; - if (pkc->type == SYNCHRONOUS) { -- if (err == -EINPROGRESS) -- return; - complete(&res->completion); - } else { - struct crypt_priv *pcr = pkc->priv; -@@ -1051,26 +1049,41 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) - ret = 0; - } - return ret; -- case CIOCASYMASYNFETCH: -+ case CIOCASYMFETCHCOOKIE: - { - struct cryptodev_pkc *pkc; - unsigned long flags; -+ int i; -+ struct pkc_cookie_list_s cookie_list; - - spin_lock_irqsave(&pcr->completion_lock, flags); -- if (list_empty(&pcr->asym_completed_list)) { -- spin_unlock_irqrestore(&pcr->completion_lock, flags); -- return -ENOMEM; -+ cookie_list.cookie_available = 0; -+ for (i = 0; i < MAX_COOKIES; i++) { -+ if (!list_empty(&pcr->asym_completed_list)) { -+ /* Run a loop in the list for upto elements -+ and copy their response back */ -+ pkc = -+ list_first_entry(&pcr->asym_completed_list, -+ struct cryptodev_pkc, list); -+ list_del(&pkc->list); -+ ret = crypto_async_fetch_asym(pkc); -+ if (!ret) { -+ cookie_list.cookie_available++; -+ cookie_list.cookie[i] = -+ pkc->kop.kop.cookie; -+ cookie_list.status[i] = pkc->result.err; -+ } -+ kfree(pkc); -+ } else { -+ break; -+ } - } -- pkc = list_first_entry(&pcr->asym_completed_list, -- struct cryptodev_pkc, list); -- list_del(&pkc->list); - spin_unlock_irqrestore(&pcr->completion_lock, flags); -- ret = crypto_async_fetch_asym(pkc); - - /* Reflect the updated request to user-space */ -- if (!ret) -- kop_to_user(&pkc->kop, arg); -- kfree(pkc); -+ if (cookie_list.cookie_available) -+ copy_to_user(arg, &cookie_list, -+ sizeof(struct pkc_cookie_list_s)); - } - return ret; - default: -@@ -1345,26 +1358,41 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) - ret = 0; - } - return ret; -- case COMPAT_CIOCASYMASYNFETCH: -+ case COMPAT_CIOCASYMFETCHCOOKIE: - { - struct cryptodev_pkc *pkc; - unsigned long flags; -+ int i = 0; -+ struct compat_pkc_cookie_list_s cookie_list; - - spin_lock_irqsave(&pcr->completion_lock, flags); -- if (list_empty(&pcr->asym_completed_list)) { -- spin_unlock_irqrestore(&pcr->completion_lock, flags); -- return -ENOMEM; -+ cookie_list.cookie_available = 0; -+ -+ for (i = 0; i < MAX_COOKIES; i++) { -+ if (!list_empty(&pcr->asym_completed_list)) { -+ /* Run a loop in the list for upto elements -+ and copy their response back */ -+ pkc = -+ list_first_entry(&pcr->asym_completed_list, -+ struct cryptodev_pkc, list); -+ list_del(&pkc->list); -+ ret = crypto_async_fetch_asym(pkc); -+ if (!ret) { -+ cookie_list.cookie_available++; -+ cookie_list.cookie[i] = -+ pkc->kop.kop.cookie; -+ } -+ kfree(pkc); -+ } else { -+ break; -+ } - } -- pkc = list_first_entry(&pcr->asym_completed_list, -- struct cryptodev_pkc, list); -- list_del(&pkc->list); - spin_unlock_irqrestore(&pcr->completion_lock, flags); -- ret = crypto_async_fetch_asym(pkc); - - /* Reflect the updated request to user-space */ -- if (!ret) -- compat_kop_to_user(&pkc->kop, arg); -- kfree(pkc); -+ if (cookie_list.cookie_available) -+ copy_to_user(arg, &cookie_list, -+ sizeof(struct compat_pkc_cookie_list_s)); - } - return ret; - default: --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0005-remove-unnecessary-header-inclusion.patch b/recipes-kernel/cryptodev/sdk_patches/0005-remove-unnecessary-header-inclusion.patch new file mode 100644 index 00000000..f9c8f3a0 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0005-remove-unnecessary-header-inclusion.patch @@ -0,0 +1,26 @@ +From 00a686189f7e05d70a7184cd6218f7424ab21b0d Mon Sep 17 00:00:00 2001 +From: Cristian Stoica +Date: Tue, 23 May 2017 15:28:58 +0300 +Subject: [PATCH 5/9] remove unnecessary header inclusion + +Signed-off-by: Cristian Stoica +--- + zc.h | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/zc.h b/zc.h +index 6f975d6..666c4a5 100644 +--- a/zc.h ++++ b/zc.h +@@ -1,8 +1,6 @@ + #ifndef ZC_H + # define ZC_H + +-#include "cryptodev_int.h" +- + /* For zero copy */ + int __get_userbuf(uint8_t __user *addr, uint32_t len, int write, + unsigned int pgcount, struct page **pg, struct scatterlist *sg, +-- +2.7.4 + diff --git a/recipes-kernel/cryptodev/sdk_patches/0006-ECC_KEYGEN-and-DLC_KEYGEN-supported-in-cryptodev-mod.patch b/recipes-kernel/cryptodev/sdk_patches/0006-ECC_KEYGEN-and-DLC_KEYGEN-supported-in-cryptodev-mod.patch deleted file mode 100644 index 978efd16..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0006-ECC_KEYGEN-and-DLC_KEYGEN-supported-in-cryptodev-mod.patch +++ /dev/null @@ -1,212 +0,0 @@ -From b92d23a790d9634d52db3b9a5e1882fde620b073 Mon Sep 17 00:00:00 2001 -From: Yashpal Dutta -Date: Fri, 7 Mar 2014 07:53:53 +0545 -Subject: [PATCH 06/38] ECC_KEYGEN and DLC_KEYGEN supported in cryptodev module - -Upstream-status: Pending - -Signed-off-by: Yashpal Dutta ---- - cryptlib.c | 2 ++ - crypto/cryptodev.h | 5 +++- - ioctl.c | 29 +++++++++++++++++-- - main.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 4 files changed, 118 insertions(+), 3 deletions(-) - -diff --git a/cryptlib.c b/cryptlib.c -index 6900028..47cd568 100644 ---- a/cryptlib.c -+++ b/cryptlib.c -@@ -452,6 +452,8 @@ int cryptodev_pkc_offload(struct cryptodev_pkc *pkc) - case DSA_VERIFY: - case ECDSA_SIGN: - case ECDSA_VERIFY: -+ case DLC_KEYGEN: -+ case ECC_KEYGEN: - pkc->s = crypto_alloc_pkc("pkc(dsa)", - CRYPTO_ALG_TYPE_PKC_DSA, 0); - break; -diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h -index 4436fbf..275a55c 100644 ---- a/crypto/cryptodev.h -+++ b/crypto/cryptodev.h -@@ -268,6 +268,8 @@ enum cryptodev_crk_op_t { - CRK_DSA_SIGN = 2, - CRK_DSA_VERIFY = 3, - CRK_DH_COMPUTE_KEY = 4, -+ CRK_DSA_GENERATE_KEY = 5, -+ CRK_DH_GENERATE_KEY = 6, - CRK_ALGORITHM_ALL - }; - -@@ -280,7 +282,8 @@ enum cryptodev_crk_op_t { - #define CRF_DSA_SIGN (1 << CRK_DSA_SIGN) - #define CRF_DSA_VERIFY (1 << CRK_DSA_VERIFY) - #define CRF_DH_COMPUTE_KEY (1 << CRK_DH_COMPUTE_KEY) -- -+#define CRF_DSA_GENERATE_KEY (1 << CRK_DSA_GENERATE_KEY) -+#define CRF_DH_GENERATE_KEY (1 << CRK_DH_GENERATE_KEY) - - /* ioctl's. Compatible with old linux cryptodev.h - */ -diff --git a/ioctl.c b/ioctl.c -index e2f407f..1f0741a 100644 ---- a/ioctl.c -+++ b/ioctl.c -@@ -726,6 +726,23 @@ static int crypto_async_fetch_asym(struct cryptodev_pkc *pkc) - dh_req->z, dh_req->z_len); - } - break; -+ case CRK_DSA_GENERATE_KEY: -+ case CRK_DH_GENERATE_KEY: -+ { -+ struct keygen_req_s *key_req = &pkc_req->req_u.keygen; -+ -+ if (pkc_req->type == ECC_KEYGEN) { -+ copy_to_user(ckop->crk_param[4].crp_p, key_req->pub_key, -+ key_req->pub_key_len); -+ copy_to_user(ckop->crk_param[5].crp_p, -+ key_req->priv_key, key_req->priv_key_len); -+ } else { -+ copy_to_user(ckop->crk_param[3].crp_p, -+ key_req->pub_key, key_req->pub_key_len); -+ copy_to_user(ckop->crk_param[4].crp_p, -+ key_req->priv_key, key_req->priv_key_len); -+ } -+ } - default: - ret = -EINVAL; - } -@@ -939,8 +956,9 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) - - switch (cmd) { - case CIOCASYMFEAT: -- return put_user(CRF_MOD_EXP_CRT | CRF_MOD_EXP | -- CRF_DSA_SIGN | CRF_DSA_VERIFY | CRF_DH_COMPUTE_KEY, p); -+ return put_user(CRF_MOD_EXP_CRT | CRF_MOD_EXP | CRF_DSA_SIGN | -+ CRF_DSA_VERIFY | CRF_DH_COMPUTE_KEY | -+ CRF_DSA_GENERATE_KEY, p); - case CRIOGET: - fd = clonefd(filp); - ret = put_user(fd, p); -@@ -1084,7 +1102,14 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) - if (cookie_list.cookie_available) - copy_to_user(arg, &cookie_list, - sizeof(struct pkc_cookie_list_s)); -+ else { -+ struct pkc_cookie_list_s *user_ck_list = (void *)arg; -+ -+ put_user(0, &(user_ck_list->cookie_available)); -+ } -+ ret = cookie_list.cookie_available; - } -+ - return ret; - default: - return -EINVAL; -diff --git a/main.c b/main.c -index 0b7951e..c901bc7 100644 ---- a/main.c -+++ b/main.c -@@ -342,6 +342,85 @@ err: - return rc; - } - -+int crypto_kop_keygen(struct cryptodev_pkc *pkc) -+{ -+ struct kernel_crypt_kop *kop = &pkc->kop; -+ struct crypt_kop *cop = &kop->kop; -+ struct pkc_request *pkc_req; -+ struct keygen_req_s *key_req; -+ int rc, buf_size; -+ uint8_t *buf; -+ -+ if (!cop->crk_param[0].crp_nbits || !cop->crk_param[1].crp_nbits || -+ !cop->crk_param[2].crp_nbits || !cop->crk_param[3].crp_nbits || -+ !cop->crk_param[4].crp_nbits) -+ return -EINVAL; -+ -+ pkc_req = &pkc->req; -+ key_req = &pkc_req->req_u.keygen; -+ key_req->q_len = (cop->crk_param[0].crp_nbits + 7)/8; -+ key_req->r_len = (cop->crk_param[1].crp_nbits + 7)/8; -+ key_req->g_len = (cop->crk_param[2].crp_nbits + 7)/8; -+ if (cop->crk_iparams == 3) { -+ key_req->pub_key_len = (cop->crk_param[3].crp_nbits + 7)/8; -+ key_req->priv_key_len = (cop->crk_param[4].crp_nbits + 7)/8; -+ buf_size = key_req->q_len + key_req->r_len + key_req->g_len + -+ key_req->pub_key_len + key_req->priv_key_len; -+ pkc_req->type = DLC_KEYGEN; -+ } else { -+ key_req->ab_len = (cop->crk_param[3].crp_nbits + 7)/8; -+ key_req->pub_key_len = (cop->crk_param[4].crp_nbits + 7)/8; -+ key_req->priv_key_len = (cop->crk_param[5].crp_nbits + 7)/8; -+ buf_size = key_req->q_len + key_req->r_len + key_req->g_len + -+ key_req->pub_key_len + key_req->priv_key_len + -+ key_req->ab_len; -+ pkc_req->type = ECC_KEYGEN; -+ pkc_req->curve_type = cop->curve_type; -+ } -+ -+ buf = kzalloc(buf_size, GFP_DMA); -+ if (!buf) -+ return -ENOMEM; -+ -+ key_req->q = buf; -+ key_req->r = key_req->q + key_req->q_len; -+ key_req->g = key_req->r + key_req->r_len; -+ key_req->pub_key = key_req->g + key_req->g_len; -+ key_req->priv_key = key_req->pub_key + key_req->pub_key_len; -+ copy_from_user(key_req->q, cop->crk_param[0].crp_p, key_req->q_len); -+ copy_from_user(key_req->r, cop->crk_param[1].crp_p, key_req->r_len); -+ copy_from_user(key_req->g, cop->crk_param[2].crp_p, key_req->g_len); -+ if (cop->crk_iparams == 3) { -+ copy_from_user(key_req->pub_key, cop->crk_param[3].crp_p, -+ key_req->pub_key_len); -+ copy_from_user(key_req->priv_key, cop->crk_param[4].crp_p, -+ key_req->priv_key_len); -+ } else { -+ key_req->ab = key_req->priv_key + key_req->priv_key_len; -+ copy_from_user(key_req->ab, cop->crk_param[3].crp_p, -+ key_req->ab_len); -+ copy_from_user(key_req->pub_key, cop->crk_param[4].crp_p, -+ key_req->pub_key_len); -+ copy_from_user(key_req->priv_key, cop->crk_param[5].crp_p, -+ key_req->priv_key_len); -+ } -+ -+ rc = cryptodev_pkc_offload(pkc); -+ if (pkc->type == SYNCHRONOUS) { -+ if (rc) -+ goto err; -+ } else { -+ if (rc != -EINPROGRESS && !rc) -+ goto err; -+ -+ pkc->cookie = buf; -+ return rc; -+ } -+err: -+ kfree(buf); -+ return rc; -+} -+ - int crypto_kop_dh_key(struct cryptodev_pkc *pkc) - { - struct kernel_crypt_kop *kop = &pkc->kop; -@@ -554,6 +633,12 @@ int crypto_run_asym(struct cryptodev_pkc *pkc) - goto err; - ret = crypto_kop_dh_key(pkc); - break; -+ case CRK_DH_GENERATE_KEY: -+ case CRK_DSA_GENERATE_KEY: -+ if ((kop->kop.crk_iparams != 3 && kop->kop.crk_iparams != 4)) -+ goto err; -+ ret = crypto_kop_keygen(pkc); -+ break; - } - err: - return ret; --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0006-move-structure-definition-to-cryptodev_int.h.patch b/recipes-kernel/cryptodev/sdk_patches/0006-move-structure-definition-to-cryptodev_int.h.patch new file mode 100644 index 00000000..9a7ef3dc --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0006-move-structure-definition-to-cryptodev_int.h.patch @@ -0,0 +1,51 @@ +From 3245b0f9ed2085f6167068409fb344166093808c Mon Sep 17 00:00:00 2001 +From: Cristian Stoica +Date: Tue, 23 May 2017 15:50:40 +0300 +Subject: [PATCH 6/9] move structure definition to cryptodev_int.h + +This is necessary for the rsa patch and makes this data structure +visible to kernel_crypt_pkop structure which will be defined in +cryptodev_int.h as well. + +Signed-off-by: Cristian Stoica +--- + cryptlib.h | 6 ------ + cryptodev_int.h | 5 +++++ + 2 files changed, 5 insertions(+), 6 deletions(-) + +diff --git a/cryptlib.h b/cryptlib.h +index 8e8aa71..48fe9bd 100644 +--- a/cryptlib.h ++++ b/cryptlib.h +@@ -2,12 +2,6 @@ + # define CRYPTLIB_H + + #include +- +-struct cryptodev_result { +- struct completion completion; +- int err; +-}; +- + #include "cipherapi.h" + + struct cipher_data { +diff --git a/cryptodev_int.h b/cryptodev_int.h +index d7660fa..c1879fd 100644 +--- a/cryptodev_int.h ++++ b/cryptodev_int.h +@@ -35,6 +35,11 @@ + #define ddebug(level, format, a...) dprintk(level, KERN_DEBUG, format, ##a) + + ++struct cryptodev_result { ++ struct completion completion; ++ int err; ++}; ++ + extern int cryptodev_verbosity; + + struct fcrypt { +-- +2.7.4 + diff --git a/recipes-kernel/cryptodev/sdk_patches/0007-RCU-stall-fixed-in-PKC-asynchronous-interface.patch b/recipes-kernel/cryptodev/sdk_patches/0007-RCU-stall-fixed-in-PKC-asynchronous-interface.patch deleted file mode 100644 index cfaabaec..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0007-RCU-stall-fixed-in-PKC-asynchronous-interface.patch +++ /dev/null @@ -1,238 +0,0 @@ -From 00a8ac310a33767eac0a07e32597c1a6f467315f Mon Sep 17 00:00:00 2001 -From: Yashpal Dutta -Date: Fri, 7 Mar 2014 08:49:15 +0545 -Subject: [PATCH 07/38] RCU stall fixed in PKC asynchronous interface - -Upstream-status: Pending - -Signed-off-by: Yashpal Dutta ---- - ioctl.c | 23 +++++++++++------------ - main.c | 43 +++++++++++++++++++++++++++---------------- - 2 files changed, 38 insertions(+), 28 deletions(-) - -diff --git a/ioctl.c b/ioctl.c -index 1f0741a..e4e16a8 100644 ---- a/ioctl.c -+++ b/ioctl.c -@@ -108,10 +108,9 @@ void cryptodev_complete_asym(struct crypto_async_request *req, int err) - complete(&res->completion); - } else { - struct crypt_priv *pcr = pkc->priv; -- unsigned long flags; -- spin_lock_irqsave(&pcr->completion_lock, flags); -+ spin_lock_bh(&pcr->completion_lock); - list_add_tail(&pkc->list, &pcr->asym_completed_list); -- spin_unlock_irqrestore(&pcr->completion_lock, flags); -+ spin_unlock_bh(&pcr->completion_lock); - /* wake for POLLIN */ - wake_up_interruptible(&pcr->user_waiter); - } -@@ -958,7 +957,7 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) - case CIOCASYMFEAT: - return put_user(CRF_MOD_EXP_CRT | CRF_MOD_EXP | CRF_DSA_SIGN | - CRF_DSA_VERIFY | CRF_DH_COMPUTE_KEY | -- CRF_DSA_GENERATE_KEY, p); -+ CRF_DSA_GENERATE_KEY | CRF_DH_GENERATE_KEY, p); - case CRIOGET: - fd = clonefd(filp); - ret = put_user(fd, p); -@@ -997,7 +996,7 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) - case CIOCKEY: - { - struct cryptodev_pkc *pkc = -- kzalloc(sizeof(struct cryptodev_pkc), GFP_KERNEL); -+ kmalloc(sizeof(struct cryptodev_pkc), GFP_KERNEL); - - if (!pkc) - return -ENOMEM; -@@ -1053,7 +1052,7 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) - case CIOCASYMASYNCRYPT: - { - struct cryptodev_pkc *pkc = -- kzalloc(sizeof(struct cryptodev_pkc), GFP_KERNEL); -+ kmalloc(sizeof(struct cryptodev_pkc), GFP_KERNEL); - ret = kop_from_user(&pkc->kop, arg); - - if (unlikely(ret)) -@@ -1070,13 +1069,12 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) - case CIOCASYMFETCHCOOKIE: - { - struct cryptodev_pkc *pkc; -- unsigned long flags; - int i; - struct pkc_cookie_list_s cookie_list; - -- spin_lock_irqsave(&pcr->completion_lock, flags); - cookie_list.cookie_available = 0; - for (i = 0; i < MAX_COOKIES; i++) { -+ spin_lock_bh(&pcr->completion_lock); - if (!list_empty(&pcr->asym_completed_list)) { - /* Run a loop in the list for upto elements - and copy their response back */ -@@ -1084,6 +1082,7 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) - list_first_entry(&pcr->asym_completed_list, - struct cryptodev_pkc, list); - list_del(&pkc->list); -+ spin_unlock_bh(&pcr->completion_lock); - ret = crypto_async_fetch_asym(pkc); - if (!ret) { - cookie_list.cookie_available++; -@@ -1093,10 +1092,10 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) - } - kfree(pkc); - } else { -+ spin_unlock_bh(&pcr->completion_lock); - break; - } - } -- spin_unlock_irqrestore(&pcr->completion_lock, flags); - - /* Reflect the updated request to user-space */ - if (cookie_list.cookie_available) -@@ -1386,14 +1385,13 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) - case COMPAT_CIOCASYMFETCHCOOKIE: - { - struct cryptodev_pkc *pkc; -- unsigned long flags; - int i = 0; - struct compat_pkc_cookie_list_s cookie_list; - -- spin_lock_irqsave(&pcr->completion_lock, flags); - cookie_list.cookie_available = 0; - - for (i = 0; i < MAX_COOKIES; i++) { -+ spin_lock_bh(&pcr->completion_lock); - if (!list_empty(&pcr->asym_completed_list)) { - /* Run a loop in the list for upto elements - and copy their response back */ -@@ -1401,6 +1399,7 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) - list_first_entry(&pcr->asym_completed_list, - struct cryptodev_pkc, list); - list_del(&pkc->list); -+ spin_unlock_bh(&pcr->completion_lock); - ret = crypto_async_fetch_asym(pkc); - if (!ret) { - cookie_list.cookie_available++; -@@ -1409,10 +1408,10 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) - } - kfree(pkc); - } else { -+ spin_unlock_bh(&pcr->completion_lock); - break; - } - } -- spin_unlock_irqrestore(&pcr->completion_lock, flags); - - /* Reflect the updated request to user-space */ - if (cookie_list.cookie_available) -diff --git a/main.c b/main.c -index c901bc7..2747706 100644 ---- a/main.c -+++ b/main.c -@@ -215,7 +215,9 @@ int crypto_kop_dsasign(struct cryptodev_pkc *pkc) - pkc_req->type = DSA_SIGN; - } - -- buf = kzalloc(buf_size, GFP_DMA); -+ buf = kmalloc(buf_size, GFP_DMA); -+ if (!buf) -+ return -ENOMEM; - - dsa_req->q = buf; - dsa_req->r = dsa_req->q + dsa_req->q_len; -@@ -298,7 +300,9 @@ int crypto_kop_dsaverify(struct cryptodev_pkc *pkc) - pkc_req->type = DSA_VERIFY; - } - -- buf = kzalloc(buf_size, GFP_DMA); -+ buf = kmalloc(buf_size, GFP_DMA); -+ if (!buf) -+ return -ENOMEM; - - dsa_req->q = buf; - dsa_req->r = dsa_req->q + dsa_req->q_len; -@@ -378,7 +382,7 @@ int crypto_kop_keygen(struct cryptodev_pkc *pkc) - pkc_req->curve_type = cop->curve_type; - } - -- buf = kzalloc(buf_size, GFP_DMA); -+ buf = kmalloc(buf_size, GFP_DMA); - if (!buf) - return -ENOMEM; - -@@ -390,25 +394,28 @@ int crypto_kop_keygen(struct cryptodev_pkc *pkc) - copy_from_user(key_req->q, cop->crk_param[0].crp_p, key_req->q_len); - copy_from_user(key_req->r, cop->crk_param[1].crp_p, key_req->r_len); - copy_from_user(key_req->g, cop->crk_param[2].crp_p, key_req->g_len); -- if (cop->crk_iparams == 3) { -- copy_from_user(key_req->pub_key, cop->crk_param[3].crp_p, -- key_req->pub_key_len); -- copy_from_user(key_req->priv_key, cop->crk_param[4].crp_p, -- key_req->priv_key_len); -- } else { -+ if (cop->crk_iparams == 4) { - key_req->ab = key_req->priv_key + key_req->priv_key_len; - copy_from_user(key_req->ab, cop->crk_param[3].crp_p, - key_req->ab_len); -- copy_from_user(key_req->pub_key, cop->crk_param[4].crp_p, -- key_req->pub_key_len); -- copy_from_user(key_req->priv_key, cop->crk_param[5].crp_p, -- key_req->priv_key_len); - } - - rc = cryptodev_pkc_offload(pkc); - if (pkc->type == SYNCHRONOUS) { - if (rc) - goto err; -+ -+ if (cop->crk_iparams == 4) { -+ copy_to_user(cop->crk_param[4].crp_p, key_req->pub_key, -+ key_req->pub_key_len); -+ copy_to_user(cop->crk_param[5].crp_p, key_req->priv_key, -+ key_req->priv_key_len); -+ } else { -+ copy_to_user(cop->crk_param[3].crp_p, key_req->pub_key, -+ key_req->pub_key_len); -+ copy_to_user(cop->crk_param[4].crp_p, -+ key_req->priv_key, key_req->priv_key_len); -+ } - } else { - if (rc != -EINPROGRESS && !rc) - goto err; -@@ -447,7 +454,9 @@ int crypto_kop_dh_key(struct cryptodev_pkc *pkc) - pkc_req->type = DH_COMPUTE_KEY; - } - buf_size += dh_req->z_len; -- buf = kzalloc(buf_size, GFP_DMA); -+ buf = kmalloc(buf_size, GFP_DMA); -+ if (!buf) -+ return -ENOMEM; - dh_req->q = buf; - dh_req->s = dh_req->q + dh_req->q_len; - dh_req->pub_key = dh_req->s + dh_req->s_len; -@@ -508,9 +517,11 @@ int crypto_modexp_crt(struct cryptodev_pkc *pkc) - rsa_req->dq_len = (cop->crk_param[4].crp_nbits + 7)/8; - rsa_req->c_len = (cop->crk_param[5].crp_nbits + 7)/8; - rsa_req->f_len = (cop->crk_param[6].crp_nbits + 7)/8; -- buf = kzalloc(rsa_req->p_len + rsa_req->q_len + rsa_req->f_len + -+ buf = kmalloc(rsa_req->p_len + rsa_req->q_len + rsa_req->f_len + - rsa_req->dp_len + rsa_req->dp_len + rsa_req->c_len + - rsa_req->g_len, GFP_DMA); -+ if (!buf) -+ return -ENOMEM; - rsa_req->p = buf; - rsa_req->q = rsa_req->p + rsa_req->p_len; - rsa_req->g = rsa_req->q + rsa_req->q_len; -@@ -563,7 +574,7 @@ int crypto_bn_modexp(struct cryptodev_pkc *pkc) - rsa_req->e_len = (cop->crk_param[1].crp_nbits + 7)/8; - rsa_req->n_len = (cop->crk_param[2].crp_nbits + 7)/8; - rsa_req->g_len = (cop->crk_param[3].crp_nbits + 7)/8; -- buf = kzalloc(rsa_req->f_len + rsa_req->e_len + rsa_req->n_len -+ buf = kmalloc(rsa_req->f_len + rsa_req->e_len + rsa_req->n_len - + rsa_req->g_len, GFP_DMA); - if (!buf) - return -ENOMEM; --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0007-add-support-for-RSA-public-and-private-key-operation.patch b/recipes-kernel/cryptodev/sdk_patches/0007-add-support-for-RSA-public-and-private-key-operation.patch new file mode 100644 index 00000000..803b90ad --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0007-add-support-for-RSA-public-and-private-key-operation.patch @@ -0,0 +1,440 @@ +From 6213ae5228a2ff0bb3521474ae37effda95a5d46 Mon Sep 17 00:00:00 2001 +From: Cristian Stoica +Date: Fri, 12 May 2017 17:04:40 +0300 +Subject: [PATCH 7/9] add support for RSA public and private key operations + +Only form 1 support is added with this patch. To maintain +compatibility with OpenBSD we need to reverse bignum buffers before +giving them to the kernel. This adds an artificial performance +penalty that can be resolved only with a CIOCKEY extension in +cryptodev API. + +As of Linux kernel 4.12 it is not possible to give to the kernel +directly a pointer to a RSA key structure and must resort to a BER +encoding scheme. + +Support for private keys in form 3 (CRT) must wait for updates and +fixes in Linux kernel crypto API. + +Known issue: +Kernels <= v4.7 strip leading zeros from the result and we get padding +errors from Openssl: RSA_EAY_PUBLIC_DECRYPT: padding check failed +(Fixed with kernel commit "crypto: rsa - Generate fixed-length output" +9b45b7bba3d22de52e09df63c50f390a193a3f53) + +Signed-off-by: Cristian Stoica +--- + cryptlib.c | 234 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + cryptlib.h | 4 +- + cryptodev_int.h | 17 ++++ + ioctl.c | 17 +++- + main.c | 42 ++++++++++ + 5 files changed, 312 insertions(+), 2 deletions(-) + +diff --git a/cryptlib.c b/cryptlib.c +index 2c6028e..1c044a4 100644 +--- a/cryptlib.c ++++ b/cryptlib.c +@@ -37,6 +37,10 @@ + #include + #include "cryptodev_int.h" + #include "cipherapi.h" ++#if (LINUX_VERSION_CODE > KERNEL_VERSION(4, 3, 0)) ++#include ++#include ++#endif + + extern const struct crypto_type crypto_givcipher_type; + +@@ -435,3 +439,233 @@ int cryptodev_hash_final(struct hash_data *hdata, void *output) + return waitfor(&hdata->async.result, ret); + } + ++#if (LINUX_VERSION_CODE > KERNEL_VERSION(4, 3, 0)) ++/* This function is necessary because the bignums in Linux kernel are MSB first ++ * (big endian) as opposed to LSB first as OpenBSD crypto layer uses */ ++void reverse_buf(uint8_t *buf, size_t sz) ++{ ++ int i; ++ uint8_t *end; ++ uint8_t tmp; ++ ++ end = buf + sz; ++ ++ for (i = 0; i < sz/2; i++) { ++ end--; ++ ++ tmp = *buf; ++ *buf = *end; ++ *end = tmp; ++ ++ buf++; ++ } ++} ++ ++int ber_wr_tag(uint8_t **ber_ptr, uint8_t tag) ++{ ++ **ber_ptr = tag; ++ *ber_ptr += 1; ++ ++ return 0; ++} ++ ++int ber_wr_len(uint8_t **ber_ptr, size_t len, size_t sz) ++{ ++ if (len < 127) { ++ **ber_ptr = len; ++ *ber_ptr += 1; ++ } else { ++ size_t sz_save = sz; ++ ++ sz--; ++ **ber_ptr = 0x80 | sz; ++ ++ while (sz > 0) { ++ *(*ber_ptr + sz) = len & 0xff; ++ len >>= 8; ++ sz--; ++ } ++ *ber_ptr += sz_save; ++ } ++ ++ return 0; ++} ++ ++int ber_wr_int(uint8_t **ber_ptr, uint8_t *crp_p, size_t sz) ++{ ++ int ret; ++ ++ ret = copy_from_user(*ber_ptr, crp_p, sz); ++ reverse_buf(*ber_ptr, sz); ++ ++ *ber_ptr += sz; ++ ++ return ret; ++} ++ ++/* calculate the size of the length field itself in BER encoding */ ++size_t ber_enc_len(size_t len) ++{ ++ size_t sz; ++ ++ sz = 1; ++ if (len > 127) { /* long encoding */ ++ while (len != 0) { ++ len >>= 8; ++ sz++; ++ } ++ } ++ ++ return sz; ++} ++ ++void *cryptodev_alloc_rsa_pub_key(struct kernel_crypt_pkop *pkop, ++ uint32_t *key_len) ++{ ++ struct crypt_kop *cop = &pkop->pkop; ++ uint8_t *ber_key; ++ uint8_t *ber_ptr; ++ uint32_t ber_key_len; ++ size_t s_sz; ++ size_t e_sz; ++ size_t n_sz; ++ size_t s_enc_len; ++ size_t e_enc_len; ++ size_t n_enc_len; ++ int err; ++ ++ /* BER public key format: ++ * SEQUENCE TAG 1 byte ++ * SEQUENCE LENGTH s_enc_len bytes ++ * INTEGER TAG 1 byte ++ * INTEGER LENGTH n_enc_len bytes ++ * INTEGER (n modulus) n_sz bytes ++ * INTEGER TAG 1 byte ++ * INTEGER LENGTH e_enc_len bytes ++ * INTEGER (e exponent) e_sz bytes ++ */ ++ ++ e_sz = (cop->crk_param[1].crp_nbits + 7)/8; ++ n_sz = (cop->crk_param[2].crp_nbits + 7)/8; ++ ++ e_enc_len = ber_enc_len(e_sz); ++ n_enc_len = ber_enc_len(n_sz); ++ ++ /* ++ * Sequence length is the size of all the fields following the sequence ++ * tag, added together. The two added bytes account for the two INT ++ * tags in the Public Key sequence ++ */ ++ s_sz = e_sz + e_enc_len + n_sz + n_enc_len + 2; ++ s_enc_len = ber_enc_len(s_sz); ++ ++ /* The added byte accounts for the SEQ tag at the start of the key */ ++ ber_key_len = s_sz + s_enc_len + 1; ++ ++ /* Linux asn1_ber_decoder doesn't like keys that are too large */ ++ if (ber_key_len > 65535) { ++ return NULL; ++ } ++ ++ ber_key = kmalloc(ber_key_len, GFP_DMA); ++ if (!ber_key) { ++ return NULL; ++ } ++ ++ ber_ptr = ber_key; ++ ++ err = ber_wr_tag(&ber_ptr, _tag(UNIV, CONS, SEQ)) || ++ ber_wr_len(&ber_ptr, s_sz, s_enc_len) || ++ ber_wr_tag(&ber_ptr, _tag(UNIV, PRIM, INT)) || ++ ber_wr_len(&ber_ptr, n_sz, n_enc_len) || ++ ber_wr_int(&ber_ptr, cop->crk_param[2].crp_p, n_sz) || ++ ber_wr_tag(&ber_ptr, _tag(UNIV, PRIM, INT)) || ++ ber_wr_len(&ber_ptr, e_sz, e_enc_len) || ++ ber_wr_int(&ber_ptr, cop->crk_param[1].crp_p, e_sz); ++ if (err != 0) { ++ goto free_key; ++ } ++ ++ *key_len = ber_key_len; ++ return ber_key; ++ ++free_key: ++ kfree(ber_key); ++ return NULL; ++} ++ ++int crypto_bn_modexp(struct kernel_crypt_pkop *pkop) ++{ ++ struct crypt_kop *cop = &pkop->pkop; ++ uint8_t *ber_key; ++ uint32_t ber_key_len; ++ size_t m_sz; ++ size_t c_sz; ++ size_t c_sz_max; ++ uint8_t *m_buf; ++ uint8_t *c_buf; ++ struct scatterlist src; ++ struct scatterlist dst; ++ int err; ++ ++ ber_key = cryptodev_alloc_rsa_pub_key(pkop, &ber_key_len); ++ if (!ber_key) { ++ return -ENOMEM; ++ } ++ ++ err = crypto_akcipher_set_pub_key(pkop->s, ber_key, ber_key_len); ++ if (err != 0) { ++ goto free_key; ++ } ++ ++ m_sz = (cop->crk_param[0].crp_nbits + 7)/8; ++ c_sz = (cop->crk_param[3].crp_nbits + 7)/8; ++ ++ m_buf = kmalloc(m_sz, GFP_DMA); ++ if (!m_buf) { ++ err = -ENOMEM; ++ goto free_key; ++ } ++ ++ err = copy_from_user(m_buf, cop->crk_param[0].crp_p, m_sz); ++ if (err != 0) { ++ goto free_m_buf; ++ } ++ reverse_buf(m_buf, m_sz); ++ ++ c_sz_max = crypto_akcipher_maxsize(pkop->s); ++ if (c_sz > c_sz_max) { ++ err = -EINVAL; ++ goto free_m_buf; ++ } ++ ++ c_buf = kzalloc(c_sz_max, GFP_KERNEL); ++ if (!c_buf) { ++ goto free_m_buf; ++ } ++ ++ sg_init_one(&src, m_buf, m_sz); ++ sg_init_one(&dst, c_buf, c_sz); ++ ++ init_completion(&pkop->result.completion); ++ akcipher_request_set_callback(pkop->req, 0, ++ cryptodev_complete, &pkop->result); ++ akcipher_request_set_crypt(pkop->req, &src, &dst, m_sz, c_sz); ++ ++ err = crypto_akcipher_encrypt(pkop->req); ++ err = waitfor(&pkop->result, err); ++ ++ if (err == 0) { ++ reverse_buf(c_buf, c_sz); ++ err = copy_to_user(cop->crk_param[3].crp_p, c_buf, c_sz); ++ } ++ ++ kfree(c_buf); ++free_m_buf: ++ kfree(m_buf); ++free_key: ++ kfree(ber_key); ++ ++ return err; ++} ++#endif +diff --git a/cryptlib.h b/cryptlib.h +index 48fe9bd..f909c34 100644 +--- a/cryptlib.h ++++ b/cryptlib.h +@@ -95,6 +95,8 @@ int cryptodev_hash_reset(struct hash_data *hdata); + void cryptodev_hash_deinit(struct hash_data *hdata); + int cryptodev_hash_init(struct hash_data *hdata, const char *alg_name, + int hmac_mode, void *mackey, size_t mackeylen); +- ++#if (LINUX_VERSION_CODE > KERNEL_VERSION(4, 3, 0)) ++int crypto_bn_modexp(struct kernel_crypt_pkop *pkop); ++#endif + + #endif +diff --git a/cryptodev_int.h b/cryptodev_int.h +index c1879fd..7860c39 100644 +--- a/cryptodev_int.h ++++ b/cryptodev_int.h +@@ -19,6 +19,10 @@ + #include + #include + #include ++#if (LINUX_VERSION_CODE > KERNEL_VERSION(4, 3, 0)) ++#include ++#endif ++ + + #define PFX "cryptodev: " + #define dprintk(level, severity, format, a...) \ +@@ -111,6 +115,18 @@ struct kernel_crypt_auth_op { + struct mm_struct *mm; + }; + ++#if (LINUX_VERSION_CODE > KERNEL_VERSION(4, 3, 0)) ++struct kernel_crypt_pkop { ++ struct crypt_kop pkop; ++ ++ struct crypto_akcipher *s; /* Transform pointer from CryptoAPI */ ++ struct akcipher_request *req; /* PKC request allocated from CryptoAPI */ ++ struct cryptodev_result result; /* updated by completion handler */ ++}; ++ ++int crypto_run_asym(struct kernel_crypt_pkop *pkop); ++#endif ++ + /* auth */ + + int kcaop_from_user(struct kernel_crypt_auth_op *kcop, +@@ -122,6 +138,7 @@ int crypto_run(struct fcrypt *fcr, struct kernel_crypt_op *kcop); + + #include + ++ + /* other internal structs */ + struct csession { + struct list_head entry; +diff --git a/ioctl.c b/ioctl.c +index db7207a..8b0df4e 100644 +--- a/ioctl.c ++++ b/ioctl.c +@@ -810,6 +810,9 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) + struct session_op sop; + struct kernel_crypt_op kcop; + struct kernel_crypt_auth_op kcaop; ++#if (LINUX_VERSION_CODE > KERNEL_VERSION(4, 3, 0)) ++ struct kernel_crypt_pkop pkop; ++#endif + struct crypt_priv *pcr = filp->private_data; + struct fcrypt *fcr; + struct session_info_op siop; +@@ -823,7 +826,11 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) + + switch (cmd) { + case CIOCASYMFEAT: +- return put_user(0, p); ++ ses = 0; ++ if (crypto_has_alg("rsa", 0, 0)) { ++ ses = CRF_MOD_EXP; ++ } ++ return put_user(ses, p); + case CRIOGET: + fd = clonefd(filp); + ret = put_user(fd, p); +@@ -859,6 +866,14 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) + if (unlikely(ret)) + return ret; + return copy_to_user(arg, &siop, sizeof(siop)); ++#if (LINUX_VERSION_CODE > KERNEL_VERSION(4, 3, 0)) ++ case CIOCKEY: ++ ret = copy_from_user(&pkop.pkop, arg, sizeof(struct crypt_kop)); ++ if (ret == 0) { ++ ret = crypto_run_asym(&pkop); ++ } ++ return ret; ++#endif + case CIOCCRYPT: + if (unlikely(ret = kcop_from_user(&kcop, fcr, arg))) { + dwarning(1, "Error copying from user"); +diff --git a/main.c b/main.c +index 57e5c38..2bfe6f0 100644 +--- a/main.c ++++ b/main.c +@@ -48,6 +48,9 @@ + #include "zc.h" + #include "cryptlib.h" + #include "version.h" ++#if (LINUX_VERSION_CODE > KERNEL_VERSION(4, 3, 0)) ++#include ++#endif + + /* This file contains the traditional operations of encryption + * and hashing of /dev/crypto. +@@ -265,3 +268,42 @@ out_unlock: + crypto_put_session(ses_ptr); + return ret; + } ++ ++#if (LINUX_VERSION_CODE > KERNEL_VERSION(4, 3, 0)) ++int crypto_run_asym(struct kernel_crypt_pkop *pkop) ++{ ++ int err; ++ ++ pkop->s = crypto_alloc_akcipher("rsa", 0, 0); ++ if (IS_ERR(pkop->s)) { ++ return PTR_ERR(pkop->s); ++ } ++ ++ pkop->req = akcipher_request_alloc(pkop->s, GFP_KERNEL); ++ if (pkop->req == NULL) { ++ err = -ENOMEM; ++ goto out_free_tfm; ++ } ++ ++ switch (pkop->pkop.crk_op) { ++ case CRK_MOD_EXP: /* RSA_PUB or PRIV form 1 */ ++ if (pkop->pkop.crk_iparams != 3 && pkop->pkop.crk_oparams != 1) { ++ err = -EINVAL; ++ goto out_free_req; ++ } ++ err = crypto_bn_modexp(pkop); ++ break; ++ default: ++ err = -EINVAL; ++ break; ++ } ++ ++out_free_req: ++ kfree(pkop->req); ++ ++out_free_tfm: ++ crypto_free_akcipher(pkop->s); ++ ++ return err; ++} ++#endif +-- +2.7.4 + diff --git a/recipes-kernel/cryptodev/sdk_patches/0008-Add-RSA-Key-generation-offloading.patch b/recipes-kernel/cryptodev/sdk_patches/0008-Add-RSA-Key-generation-offloading.patch deleted file mode 100644 index ef4ea091..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0008-Add-RSA-Key-generation-offloading.patch +++ /dev/null @@ -1,170 +0,0 @@ -From a2cbb5fcc2d6f3734b5ed2826e828d852cfdf8ba Mon Sep 17 00:00:00 2001 -From: Hou Zhiqiang -Date: Wed, 19 Mar 2014 14:02:46 +0800 -Subject: [PATCH 08/38] Add RSA Key generation offloading - -Upstream-status: Pending - -Signed-off-by: Hou Zhiqiang -Tested-by: Cristian Stoica ---- - cryptlib.c | 1 + - crypto/cryptodev.h | 2 ++ - ioctl.c | 3 +- - main.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++- - 4 files changed, 84 insertions(+), 2 deletions(-) - -diff --git a/cryptlib.c b/cryptlib.c -index 47cd568..4dd1847 100644 ---- a/cryptlib.c -+++ b/cryptlib.c -@@ -441,6 +441,7 @@ int cryptodev_pkc_offload(struct cryptodev_pkc *pkc) - struct pkc_request *pkc_req = &pkc->req, *pkc_requested; - - switch (pkc_req->type) { -+ case RSA_KEYGEN: - case RSA_PUB: - case RSA_PRIV_FORM1: - case RSA_PRIV_FORM2: -diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h -index 275a55c..d0cc542 100644 ---- a/crypto/cryptodev.h -+++ b/crypto/cryptodev.h -@@ -270,6 +270,7 @@ enum cryptodev_crk_op_t { - CRK_DH_COMPUTE_KEY = 4, - CRK_DSA_GENERATE_KEY = 5, - CRK_DH_GENERATE_KEY = 6, -+ CRK_RSA_GENERATE_KEY = 7, - CRK_ALGORITHM_ALL - }; - -@@ -279,6 +280,7 @@ enum cryptodev_crk_op_t { - */ - #define CRF_MOD_EXP (1 << CRK_MOD_EXP) - #define CRF_MOD_EXP_CRT (1 << CRK_MOD_EXP_CRT) -+#define CRF_RSA_GENERATE_KEY (1 << CRK_RSA_GENERATE_KEY) - #define CRF_DSA_SIGN (1 << CRK_DSA_SIGN) - #define CRF_DSA_VERIFY (1 << CRK_DSA_VERIFY) - #define CRF_DH_COMPUTE_KEY (1 << CRK_DH_COMPUTE_KEY) -diff --git a/ioctl.c b/ioctl.c -index e4e16a8..3762a47 100644 ---- a/ioctl.c -+++ b/ioctl.c -@@ -957,7 +957,8 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) - case CIOCASYMFEAT: - return put_user(CRF_MOD_EXP_CRT | CRF_MOD_EXP | CRF_DSA_SIGN | - CRF_DSA_VERIFY | CRF_DH_COMPUTE_KEY | -- CRF_DSA_GENERATE_KEY | CRF_DH_GENERATE_KEY, p); -+ CRF_DSA_GENERATE_KEY | CRF_DH_GENERATE_KEY | -+ CRF_RSA_GENERATE_KEY, p); - case CRIOGET: - fd = clonefd(filp); - ret = put_user(fd, p); -diff --git a/main.c b/main.c -index 2747706..14dcf40 100644 ---- a/main.c -+++ b/main.c -@@ -346,6 +346,82 @@ err: - return rc; - } - -+int crypto_kop_rsa_keygen(struct cryptodev_pkc *pkc) -+{ -+ struct kernel_crypt_kop *kop = &pkc->kop; -+ struct crypt_kop *cop = &kop->kop; -+ struct pkc_request *pkc_req; -+ struct rsa_keygen_req_s *key_req; -+ int rc, buf_size; -+ uint8_t *buf; -+ -+ if (!cop->crk_param[0].crp_nbits || !cop->crk_param[1].crp_nbits || -+ !cop->crk_param[2].crp_nbits || !cop->crk_param[3].crp_nbits || -+ !cop->crk_param[4].crp_nbits || !cop->crk_param[5].crp_nbits || -+ !cop->crk_param[6].crp_nbits) -+ return -EINVAL; -+ -+ pkc_req = &pkc->req; -+ pkc_req->type = RSA_KEYGEN; -+ key_req = &pkc_req->req_u.rsa_keygen; -+ key_req->n_len = (cop->crk_param[2].crp_nbits + 7)/8; -+ key_req->p_len = (cop->crk_param[0].crp_nbits + 7) / 8; -+ key_req->q_len = (cop->crk_param[1].crp_nbits + 7) / 8; -+ key_req->n_len = (cop->crk_param[2].crp_nbits + 7) / 8; -+ key_req->d_len = (cop->crk_param[3].crp_nbits + 7) / 8; -+ key_req->dp_len = (cop->crk_param[4].crp_nbits + 7) / 8; -+ key_req->dq_len = (cop->crk_param[5].crp_nbits + 7) / 8; -+ key_req->c_len = (cop->crk_param[6].crp_nbits + 7) / 8; -+ -+ buf_size = key_req->p_len + key_req->q_len + key_req->n_len + -+ key_req->d_len + key_req->dp_len + -+ key_req->dq_len + key_req->c_len; -+ -+ buf = kmalloc(buf_size, GFP_DMA); -+ if (!buf) -+ return -ENOMEM; -+ key_req->p = buf; -+ key_req->q = key_req->p + key_req->p_len; -+ key_req->n = key_req->q + key_req->q_len; -+ key_req->d = key_req->n + key_req->n_len; -+ key_req->dp = key_req->d + key_req->d_len; -+ key_req->dq = key_req->dp + key_req->dp_len; -+ key_req->c = key_req->dq + key_req->dq_len; -+ -+ rc = cryptodev_pkc_offload(pkc); -+ -+ if (pkc->type == SYNCHRONOUS) { -+ if (rc) -+ goto err; -+ -+ copy_to_user(cop->crk_param[0].crp_p, -+ key_req->p, key_req->p_len); -+ copy_to_user(cop->crk_param[1].crp_p, -+ key_req->q, key_req->q_len); -+ copy_to_user(cop->crk_param[2].crp_p, -+ key_req->n, key_req->n_len); -+ copy_to_user(cop->crk_param[3].crp_p, -+ key_req->d, key_req->d_len); -+ copy_to_user(cop->crk_param[4].crp_p, -+ key_req->dp, key_req->dp_len); -+ copy_to_user(cop->crk_param[5].crp_p, -+ key_req->dq, key_req->dq_len); -+ copy_to_user(cop->crk_param[6].crp_p, -+ key_req->c, key_req->c_len); -+ } else { -+ if (rc != -EINPROGRESS && !rc) { -+ printk("%s: Failed\n", __func__); -+ goto err; -+ } -+ pkc->cookie = buf; -+ return rc; -+ } -+err: -+ kfree(buf); -+ return rc; -+ -+} -+ - int crypto_kop_keygen(struct cryptodev_pkc *pkc) - { - struct kernel_crypt_kop *kop = &pkc->kop; -@@ -385,7 +461,6 @@ int crypto_kop_keygen(struct cryptodev_pkc *pkc) - buf = kmalloc(buf_size, GFP_DMA); - if (!buf) - return -ENOMEM; -- - key_req->q = buf; - key_req->r = key_req->q + key_req->q_len; - key_req->g = key_req->r + key_req->r_len; -@@ -650,6 +725,9 @@ int crypto_run_asym(struct cryptodev_pkc *pkc) - goto err; - ret = crypto_kop_keygen(pkc); - break; -+ case CRK_RSA_GENERATE_KEY: -+ ret = crypto_kop_rsa_keygen(pkc); -+ break; - } - err: - return ret; --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0008-check-session-flags-early-to-avoid-incorrect-failure.patch b/recipes-kernel/cryptodev/sdk_patches/0008-check-session-flags-early-to-avoid-incorrect-failure.patch new file mode 100644 index 00000000..1fce5580 --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0008-check-session-flags-early-to-avoid-incorrect-failure.patch @@ -0,0 +1,54 @@ +From ec2529027a6565fdede79e7bda4a0232757acf70 Mon Sep 17 00:00:00 2001 +From: Cristian Stoica +Date: Wed, 14 Jun 2017 11:23:18 +0300 +Subject: [PATCH 8/9] check session flags early to avoid incorrect failure + modes + +This verification of aead flag was incorrectly removed in +"refactoring: split big function to simplify maintainance" +20dcf071bc3076ee7db9d603cfbe6a06e86c7d5f +resulting in an incorrect dispatching of functions. + +Add back this check and at the same time remove the second check from +the called function which now becomes redundant. +Add another guard check for aead modes and reject not supported combinations. + +Signed-off-by: Cristian Stoica +--- + authenc.c | 11 +++++------ + 1 file changed, 5 insertions(+), 6 deletions(-) + +diff --git a/authenc.c b/authenc.c +index 692951f..fc32f43 100644 +--- a/authenc.c ++++ b/authenc.c +@@ -643,10 +643,6 @@ static int crypto_auth_zc_tls(struct csession *ses_ptr, struct kernel_crypt_auth + struct scatterlist tmp; + int ret; + +- if (unlikely(ses_ptr->cdata.aead != 0)) { +- return -EINVAL; +- } +- + if (unlikely(caop->auth_len > PAGE_SIZE)) { + derr(1, "auth data len is excessive."); + return -EINVAL; +@@ -787,10 +783,13 @@ __crypto_auth_run_zc(struct csession *ses_ptr, struct kernel_crypt_auth_op *kcao + + if (caop->flags & COP_FLAG_AEAD_SRTP_TYPE) { + ret = crypto_auth_zc_srtp(ses_ptr, kcaop); +- } else if (caop->flags & COP_FLAG_AEAD_TLS_TYPE) { ++ } else if (caop->flags & COP_FLAG_AEAD_TLS_TYPE && ++ ses_ptr->cdata.aead == 0) { + ret = crypto_auth_zc_tls(ses_ptr, kcaop); +- } else { ++ } else if (ses_ptr->cdata.aead) { + ret = crypto_auth_zc_aead(ses_ptr, kcaop); ++ } else { ++ ret = -EINVAL; + } + + return ret; +-- +2.7.4 + diff --git a/recipes-kernel/cryptodev/sdk_patches/0009-Fixed-compilation-error-of-openssl-with-fsl-cryptode.patch b/recipes-kernel/cryptodev/sdk_patches/0009-Fixed-compilation-error-of-openssl-with-fsl-cryptode.patch deleted file mode 100644 index 47fd2e16..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0009-Fixed-compilation-error-of-openssl-with-fsl-cryptode.patch +++ /dev/null @@ -1,160 +0,0 @@ -From 263483d1023f6c1c35b5488b9b79796ee2605e9b Mon Sep 17 00:00:00 2001 -From: Yashpal Dutta -Date: Thu, 17 Apr 2014 07:08:47 +0545 -Subject: [PATCH 09/38] Fixed compilation error of openssl with fsl cryptodev - -Upstream-status: Pending - -Signed-off-by: Yashpal Dutta -Tested-by: Cristian Stoica ---- - authenc.c | 1 + - cryptlib.c | 9 ++++----- - crypto/cryptodev.h | 9 ++++++++- - cryptodev_int.h | 2 +- - ioctl.c | 8 ++++++-- - main.c | 1 + - 6 files changed, 21 insertions(+), 9 deletions(-) - -diff --git a/authenc.c b/authenc.c -index ef0d3db..2aa4d38 100644 ---- a/authenc.c -+++ b/authenc.c -@@ -2,6 +2,7 @@ - * Driver for /dev/crypto device (aka CryptoDev) - * - * Copyright (c) 2011, 2012 OpenSSL Software Foundation, Inc. -+ * Copyright (c) 2014 Freescale Semiconductor, Inc. - * - * Author: Nikos Mavrogiannopoulos - * -diff --git a/cryptlib.c b/cryptlib.c -index 4dd1847..ec6693e 100644 ---- a/cryptlib.c -+++ b/cryptlib.c -@@ -4,8 +4,7 @@ - * Copyright (c) 2010,2011 Nikos Mavrogiannopoulos - * Portions Copyright (c) 2010 Michael Weiser - * Portions Copyright (c) 2010 Phil Sutter -- * -- * Copyright 2012 Freescale Semiconductor, Inc. -+ * Copyright 2012-2014 Freescale Semiconductor, Inc. - * - * This file is part of linux cryptodev. - * -@@ -144,7 +143,7 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, - if (alg->max_keysize > 0 && - unlikely((keylen < alg->min_keysize) || - (keylen > alg->max_keysize))) { -- ddebug(1, "Wrong keylen '%zu' for algorithm '%s'. Use %u to %u.", -+ ddebug(1, "Wrong keylen '%u' for algorithm '%s'. Use %u to %u.", - keylen, alg_name, alg->min_keysize, alg->max_keysize); - ret = -EINVAL; - goto error; -@@ -171,7 +170,7 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, - } - - if (unlikely(ret)) { -- ddebug(1, "Setting key failed for %s-%zu.", alg_name, keylen*8); -+ ddebug(1, "Setting key failed for %s-%u.", alg_name, keylen*8); - ret = -EINVAL; - goto error; - } -@@ -338,7 +337,7 @@ int cryptodev_hash_init(struct hash_data *hdata, const char *alg_name, - if (hmac_mode != 0) { - ret = crypto_ahash_setkey(hdata->async.s, mackey, mackeylen); - if (unlikely(ret)) { -- ddebug(1, "Setting hmac key failed for %s-%zu.", -+ ddebug(1, "Setting hmac key failed for %s-%u.", - alg_name, mackeylen*8); - ret = -EINVAL; - goto error; -diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h -index d0cc542..e7edd97 100644 ---- a/crypto/cryptodev.h -+++ b/crypto/cryptodev.h -@@ -234,6 +234,13 @@ struct crypt_auth_op { - #define CRYPTO_ALG_FLAG_RNG_ENABLE 2 - #define CRYPTO_ALG_FLAG_DSA_SHA 4 - -+enum ec_curve_t { -+ EC_DISCRETE_LOG, -+ EC_PRIME, -+ EC_BINARY, -+ MAX_EC_TYPE -+}; -+ - struct crparam { - __u8 *crp_p; - __u32 crp_nbits; -@@ -249,7 +256,7 @@ struct crypt_kop { - __u16 crk_oparams; - __u32 crk_pad1; - struct crparam crk_param[CRK_MAXPARAM]; -- enum curve_t curve_type; /* 0 == Discrete Log, -+ enum ec_curve_t curve_type; /* 0 == Discrete Log, - 1 = EC_PRIME, 2 = EC_BINARY */ - void *cookie; - }; -diff --git a/cryptodev_int.h b/cryptodev_int.h -index 5347cae..c83c885 100644 ---- a/cryptodev_int.h -+++ b/cryptodev_int.h -@@ -88,7 +88,7 @@ struct compat_crypt_kop { - uint16_t crk_oparams; - uint32_t crk_pad1; - struct compat_crparam crk_param[CRK_MAXPARAM]; -- enum curve_t curve_type; /* 0 == Discrete Log, 1 = EC_PRIME, -+ enum ec_curve_t curve_type; /* 0 == Discrete Log, 1 = EC_PRIME, - 2 = EC_BINARY */ - compat_uptr_t cookie; - }; -diff --git a/ioctl.c b/ioctl.c -index 3762a47..c97320b 100644 ---- a/ioctl.c -+++ b/ioctl.c -@@ -4,7 +4,7 @@ - * Copyright (c) 2004 Michal Ludvig , SuSE Labs - * Copyright (c) 2009,2010,2011 Nikos Mavrogiannopoulos - * Copyright (c) 2010 Phil Sutter -- * Copyright 2012 Freescale Semiconductor, Inc. -+ * Copyright 2012-2014 Freescale Semiconductor, Inc. - * - * This file is part of linux cryptodev. - * -@@ -501,6 +501,7 @@ cryptodev_open(struct inode *inode, struct file *filp) - INIT_LIST_HEAD(&pcr->done.list); - INIT_LIST_HEAD(&pcr->asym_completed_list); - spin_lock_init(&pcr->completion_lock); -+ - INIT_WORK(&pcr->cryptask, cryptask_routine); - - init_waitqueue_head(&pcr->user_waiter); -@@ -780,8 +781,11 @@ static int fill_kcop_from_cop(struct kernel_crypt_op *kcop, struct fcrypt *fcr) - - if (cop->iv) { - rc = copy_from_user(kcop->iv, cop->iv, kcop->ivlen); -- if (unlikely(rc)) -+ if (unlikely(rc)) { -+ derr(1, "error copying IV (%d bytes), copy_from_user returned %d for address %p", -+ kcop->ivlen, rc, cop->iv); - return -EFAULT; -+ } - } - - return 0; -diff --git a/main.c b/main.c -index 14dcf40..6365911 100644 ---- a/main.c -+++ b/main.c -@@ -3,6 +3,7 @@ - * - * Copyright (c) 2004 Michal Ludvig , SuSE Labs - * Copyright (c) 2009-2013 Nikos Mavrogiannopoulos -+ * Copyright (c) 2014 Freescale Semiconductor, Inc. - * - * This file is part of linux cryptodev. - * --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0001-add-support-for-composite-TLS10-SHA1-AES-algorithm-o.patch b/recipes-kernel/cryptodev/sdk_patches/0009-add-support-for-composite-TLS10-SHA1-AES-algorithm-o.patch similarity index 71% rename from recipes-kernel/cryptodev/sdk_patches/0001-add-support-for-composite-TLS10-SHA1-AES-algorithm-o.patch rename to recipes-kernel/cryptodev/sdk_patches/0009-add-support-for-composite-TLS10-SHA1-AES-algorithm-o.patch index b8d2a001..795abdf0 100644 --- a/recipes-kernel/cryptodev/sdk_patches/0001-add-support-for-composite-TLS10-SHA1-AES-algorithm-o.patch +++ b/recipes-kernel/cryptodev/sdk_patches/0009-add-support-for-composite-TLS10-SHA1-AES-algorithm-o.patch @@ -1,7 +1,7 @@ -From 25a68839e3aab5acebcbe51f7fbe9d2d26216bc0 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Thu, 29 Aug 2013 16:52:30 +0300 -Subject: [PATCH 01/38] add support for composite TLS10(SHA1,AES) algorithm +From f365c69d7852d6579952825c9f90a27129f92d22 Mon Sep 17 00:00:00 2001 +From: Cristian Stoica +Date: Tue, 13 Jun 2017 11:13:33 +0300 +Subject: [PATCH 9/9] add support for composite TLS10(SHA1,AES) algorithm offload This adds support for composite algorithm offload as a primitive @@ -11,9 +11,7 @@ It requires kernel support for tls10(hmac(sha1),cbc(aes)) algorithm provided either in software or accelerated by hardware such as Freescale B*, P* and T* platforms. -Change-Id: Ia1c605da3860e91e681295dfc8df7c09eb4006cf -Signed-off-by: Cristian Stoica -Reviewed-on: http://git.am.freescale.net:8181/17218 +Signed-off-by: Cristian Stoica --- crypto/cryptodev.h | 1 + ioctl.c | 5 +++++ @@ -32,7 +30,7 @@ index 7fb9c7d..c0e8cd4 100644 }; diff --git a/ioctl.c b/ioctl.c -index b23f5fd..a3f8379 100644 +index 8b0df4e..998f51a 100644 --- a/ioctl.c +++ b/ioctl.c @@ -159,6 +159,11 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) @@ -48,5 +46,5 @@ index b23f5fd..a3f8379 100644 alg_name = "ecb(cipher_null)"; stream = 1; -- -2.7.0 +2.7.4 diff --git a/recipes-kernel/cryptodev/sdk_patches/0010-add-support-for-composite-TLS10-SHA1-3DES-algorithm-.patch b/recipes-kernel/cryptodev/sdk_patches/0010-add-support-for-composite-TLS10-SHA1-3DES-algorithm-.patch deleted file mode 100644 index 352a45d2..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0010-add-support-for-composite-TLS10-SHA1-3DES-algorithm-.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 269564f4e00fa907388ccfa046b930b3c4eef4dc Mon Sep 17 00:00:00 2001 -From: Tudor Ambarus -Date: Tue, 10 Jun 2014 08:27:59 +0300 -Subject: [PATCH 10/38] add support for composite TLS10(SHA1,3DES) algorithm - offload - -This adds support for composite algorithm offload in a single crypto -(cipher + hmac) operation. - -It requires either software or hardware TLS support in the Linux kernel -and can be used with Freescale B*, P* and T* platforms that have support -for hardware TLS acceleration. - -Change-Id: Ibce0ceb4174809c9c96b453cd3202bc5220ff084 -Signed-off-by: Tudor Ambarus -Reviewed-on: http://git.am.freescale.net:8181/34000 -Reviewed-by: Cristian Stoica -Tested-by: Cristian Stoica ---- - crypto/cryptodev.h | 1 + - ioctl.c | 5 +++++ - 2 files changed, 6 insertions(+) - -diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h -index e7edd97..07f40b2 100644 ---- a/crypto/cryptodev.h -+++ b/crypto/cryptodev.h -@@ -55,6 +55,7 @@ enum cryptodev_crypto_op_t { - CRYPTO_SHA2_512, - CRYPTO_SHA2_224_HMAC, - CRYPTO_TLS10_AES_CBC_HMAC_SHA1, -+ CRYPTO_TLS10_3DES_CBC_HMAC_SHA1, - CRYPTO_ALGORITHM_ALL, /* Keep updated - see below */ - }; - -diff --git a/ioctl.c b/ioctl.c -index c97320b..574e913 100644 ---- a/ioctl.c -+++ b/ioctl.c -@@ -191,6 +191,11 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) - stream = 0; - aead = 1; - break; -+ case CRYPTO_TLS10_3DES_CBC_HMAC_SHA1: -+ alg_name = "tls10(hmac(sha1),cbc(des3_ede))"; -+ stream = 0; -+ aead = 1; -+ break; - case CRYPTO_NULL: - alg_name = "ecb(cipher_null)"; - stream = 1; --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0011-add-support-for-TLSv1.1-record-offload.patch b/recipes-kernel/cryptodev/sdk_patches/0011-add-support-for-TLSv1.1-record-offload.patch deleted file mode 100644 index 34d6ade0..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0011-add-support-for-TLSv1.1-record-offload.patch +++ /dev/null @@ -1,76 +0,0 @@ -From 73c20be9ae1ed57d8c428c86471f42d953e79fba Mon Sep 17 00:00:00 2001 -From: Tudor Ambarus -Date: Tue, 31 Mar 2015 16:15:47 +0300 -Subject: [PATCH 11/38] add support for TLSv1.1 record offload - -This adds support for composite algorithm offload in a single crypto -(cipher + hmac) operation. - -Supported cipher suites: -- 3des-ede-cbc-sha -- aes-128-cbc-hmac-sha -- aes-256-cbc-hmac-sha - -It requires either software or hardware TLS support in the Linux kernel -and can be used with Freescale B*, P* and T* platforms that have support -for hardware TLS acceleration. - -Signed-off-by: Tudor Ambarus -Change-Id: Ia5f3fa7ec090d5643d71b0f608c68a274ec6b51f -Reviewed-on: http://git.am.freescale.net:8181/33998 -Reviewed-by: Cristian Stoica -Tested-by: Cristian Stoica ---- - crypto/cryptodev.h | 4 +++- - ioctl.c | 14 ++++++++++++-- - 2 files changed, 15 insertions(+), 3 deletions(-) - -diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h -index 07f40b2..61e8599 100644 ---- a/crypto/cryptodev.h -+++ b/crypto/cryptodev.h -@@ -54,8 +54,10 @@ enum cryptodev_crypto_op_t { - CRYPTO_SHA2_384, - CRYPTO_SHA2_512, - CRYPTO_SHA2_224_HMAC, -- CRYPTO_TLS10_AES_CBC_HMAC_SHA1, - CRYPTO_TLS10_3DES_CBC_HMAC_SHA1, -+ CRYPTO_TLS10_AES_CBC_HMAC_SHA1, -+ CRYPTO_TLS11_3DES_CBC_HMAC_SHA1, -+ CRYPTO_TLS11_AES_CBC_HMAC_SHA1, - CRYPTO_ALGORITHM_ALL, /* Keep updated - see below */ - }; - -diff --git a/ioctl.c b/ioctl.c -index 574e913..ba82387 100644 ---- a/ioctl.c -+++ b/ioctl.c -@@ -186,13 +186,23 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) - stream = 1; - aead = 1; - break; -+ case CRYPTO_TLS10_3DES_CBC_HMAC_SHA1: -+ alg_name = "tls10(hmac(sha1),cbc(des3_ede))"; -+ stream = 0; -+ aead = 1; -+ break; - case CRYPTO_TLS10_AES_CBC_HMAC_SHA1: - alg_name = "tls10(hmac(sha1),cbc(aes))"; - stream = 0; - aead = 1; - break; -- case CRYPTO_TLS10_3DES_CBC_HMAC_SHA1: -- alg_name = "tls10(hmac(sha1),cbc(des3_ede))"; -+ case CRYPTO_TLS11_3DES_CBC_HMAC_SHA1: -+ alg_name = "tls11(hmac(sha1),cbc(des3_ede))"; -+ stream = 0; -+ aead = 1; -+ break; -+ case CRYPTO_TLS11_AES_CBC_HMAC_SHA1: -+ alg_name = "tls11(hmac(sha1),cbc(aes))"; - stream = 0; - aead = 1; - break; --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0012-add-support-for-TLSv1.2-record-offload.patch b/recipes-kernel/cryptodev/sdk_patches/0012-add-support-for-TLSv1.2-record-offload.patch deleted file mode 100644 index b7a72683..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0012-add-support-for-TLSv1.2-record-offload.patch +++ /dev/null @@ -1,72 +0,0 @@ -From f1a519d9eed072bd45a45d251603c64f942814fb Mon Sep 17 00:00:00 2001 -From: Tudor Ambarus -Date: Tue, 31 Mar 2015 16:16:28 +0300 -Subject: [PATCH 12/38] add support for TLSv1.2 record offload - -This adds support for composite algorithm offload in a single crypto -(cipher + hmac) operation. - -Supported cipher suites: -- 3des-ede-cbc-sha -- aes-128-cbc-hmac-sha -- aes-256-cbc-hmac-sha -- aes-128-cbc-hmac-sha256 -- aes-256-cbc-hmac-sha256 - -It requires either software or hardware TLS support in the Linux kernel -and can be used with Freescale B*, P* and T* platforms that have support -for hardware TLS acceleration. - -Signed-off-by: Tudor Ambarus -Change-Id: I21f45993505fc3dad09848a13aa20f778a7c2de0 -Reviewed-on: http://git.am.freescale.net:8181/33999 -Reviewed-by: Cristian Stoica -Tested-by: Cristian Stoica ---- - crypto/cryptodev.h | 3 +++ - ioctl.c | 15 +++++++++++++++ - 2 files changed, 18 insertions(+) - -diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h -index 61e8599..f6058ca 100644 ---- a/crypto/cryptodev.h -+++ b/crypto/cryptodev.h -@@ -58,6 +58,9 @@ enum cryptodev_crypto_op_t { - CRYPTO_TLS10_AES_CBC_HMAC_SHA1, - CRYPTO_TLS11_3DES_CBC_HMAC_SHA1, - CRYPTO_TLS11_AES_CBC_HMAC_SHA1, -+ CRYPTO_TLS12_3DES_CBC_HMAC_SHA1, -+ CRYPTO_TLS12_AES_CBC_HMAC_SHA1, -+ CRYPTO_TLS12_AES_CBC_HMAC_SHA256, - CRYPTO_ALGORITHM_ALL, /* Keep updated - see below */ - }; - -diff --git a/ioctl.c b/ioctl.c -index ba82387..fb4c4e3 100644 ---- a/ioctl.c -+++ b/ioctl.c -@@ -206,6 +206,21 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) - stream = 0; - aead = 1; - break; -+ case CRYPTO_TLS12_3DES_CBC_HMAC_SHA1: -+ alg_name = "tls12(hmac(sha1),cbc(des3_ede))"; -+ stream = 0; -+ aead = 1; -+ break; -+ case CRYPTO_TLS12_AES_CBC_HMAC_SHA1: -+ alg_name = "tls12(hmac(sha1),cbc(aes))"; -+ stream = 0; -+ aead = 1; -+ break; -+ case CRYPTO_TLS12_AES_CBC_HMAC_SHA256: -+ alg_name = "tls12(hmac(sha256),cbc(aes))"; -+ stream = 0; -+ aead = 1; -+ break; - case CRYPTO_NULL: - alg_name = "ecb(cipher_null)"; - stream = 1; --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0013-clean-up-code-layout.patch b/recipes-kernel/cryptodev/sdk_patches/0013-clean-up-code-layout.patch deleted file mode 100644 index a6884fa8..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0013-clean-up-code-layout.patch +++ /dev/null @@ -1,186 +0,0 @@ -From 5a87b9d5f2295ed0fd36a41c8376e01eb0df62b2 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Fri, 20 Feb 2015 12:46:58 +0200 -Subject: [PATCH 13/38] clean-up code layout - -Signed-off-by: Cristian Stoica -Change-Id: I92c2f4baeed9470a2c3c42b592d878e65918b0af -Reviewed-on: http://git.am.freescale.net:8181/34222 ---- - cryptlib.c | 11 ++++------- - ioctl.c | 55 +++++++++++++++++++++---------------------------------- - main.c | 4 +--- - 3 files changed, 26 insertions(+), 44 deletions(-) - -diff --git a/cryptlib.c b/cryptlib.c -index ec6693e..21e691b 100644 ---- a/cryptlib.c -+++ b/cryptlib.c -@@ -434,7 +434,7 @@ int cryptodev_hash_final(struct hash_data *hdata, void *output) - return waitfor(hdata->async.result, ret); - } - --int cryptodev_pkc_offload(struct cryptodev_pkc *pkc) -+int cryptodev_pkc_offload(struct cryptodev_pkc *pkc) - { - int ret = 0; - struct pkc_request *pkc_req = &pkc->req, *pkc_requested; -@@ -445,8 +445,7 @@ int cryptodev_pkc_offload(struct cryptodev_pkc *pkc) - case RSA_PRIV_FORM1: - case RSA_PRIV_FORM2: - case RSA_PRIV_FORM3: -- pkc->s = crypto_alloc_pkc("pkc(rsa)", -- CRYPTO_ALG_TYPE_PKC_RSA, 0); -+ pkc->s = crypto_alloc_pkc("pkc(rsa)", CRYPTO_ALG_TYPE_PKC_RSA, 0); - break; - case DSA_SIGN: - case DSA_VERIFY: -@@ -454,13 +453,11 @@ int cryptodev_pkc_offload(struct cryptodev_pkc *pkc) - case ECDSA_VERIFY: - case DLC_KEYGEN: - case ECC_KEYGEN: -- pkc->s = crypto_alloc_pkc("pkc(dsa)", -- CRYPTO_ALG_TYPE_PKC_DSA, 0); -+ pkc->s = crypto_alloc_pkc("pkc(dsa)", CRYPTO_ALG_TYPE_PKC_DSA, 0); - break; - case DH_COMPUTE_KEY: - case ECDH_COMPUTE_KEY: -- pkc->s = crypto_alloc_pkc("pkc(dh)", -- CRYPTO_ALG_TYPE_PKC_DH, 0); -+ pkc->s = crypto_alloc_pkc("pkc(dh)", CRYPTO_ALG_TYPE_PKC_DH, 0); - break; - default: - return -EINVAL; -diff --git a/ioctl.c b/ioctl.c -index fb4c4e3..ee0486c 100644 ---- a/ioctl.c -+++ b/ioctl.c -@@ -714,16 +714,13 @@ static int crypto_async_fetch_asym(struct cryptodev_pkc *pkc) - case CRK_MOD_EXP: - { - struct rsa_pub_req_s *rsa_req = &pkc_req->req_u.rsa_pub_req; -- copy_to_user(ckop->crk_param[3].crp_p, rsa_req->g, -- rsa_req->g_len); -+ copy_to_user(ckop->crk_param[3].crp_p, rsa_req->g, rsa_req->g_len); - } - break; - case CRK_MOD_EXP_CRT: - { -- struct rsa_priv_frm3_req_s *rsa_req = -- &pkc_req->req_u.rsa_priv_f3; -- copy_to_user(ckop->crk_param[6].crp_p, -- rsa_req->f, rsa_req->f_len); -+ struct rsa_priv_frm3_req_s *rsa_req = &pkc_req->req_u.rsa_priv_f3; -+ copy_to_user(ckop->crk_param[6].crp_p, rsa_req->f, rsa_req->f_len); - } - break; - case CRK_DSA_SIGN: -@@ -731,15 +728,11 @@ static int crypto_async_fetch_asym(struct cryptodev_pkc *pkc) - struct dsa_sign_req_s *dsa_req = &pkc_req->req_u.dsa_sign; - - if (pkc_req->type == ECDSA_SIGN) { -- copy_to_user(ckop->crk_param[6].crp_p, -- dsa_req->c, dsa_req->d_len); -- copy_to_user(ckop->crk_param[7].crp_p, -- dsa_req->d, dsa_req->d_len); -+ copy_to_user(ckop->crk_param[6].crp_p, dsa_req->c, dsa_req->d_len); -+ copy_to_user(ckop->crk_param[7].crp_p, dsa_req->d, dsa_req->d_len); - } else { -- copy_to_user(ckop->crk_param[5].crp_p, -- dsa_req->c, dsa_req->d_len); -- copy_to_user(ckop->crk_param[6].crp_p, -- dsa_req->d, dsa_req->d_len); -+ copy_to_user(ckop->crk_param[5].crp_p, dsa_req->c, dsa_req->d_len); -+ copy_to_user(ckop->crk_param[6].crp_p, dsa_req->d, dsa_req->d_len); - } - } - break; -@@ -749,11 +742,9 @@ static int crypto_async_fetch_asym(struct cryptodev_pkc *pkc) - { - struct dh_key_req_s *dh_req = &pkc_req->req_u.dh_req; - if (pkc_req->type == ECDH_COMPUTE_KEY) -- copy_to_user(ckop->crk_param[4].crp_p, -- dh_req->z, dh_req->z_len); -+ copy_to_user(ckop->crk_param[4].crp_p, dh_req->z, dh_req->z_len); - else -- copy_to_user(ckop->crk_param[3].crp_p, -- dh_req->z, dh_req->z_len); -+ copy_to_user(ckop->crk_param[3].crp_p, dh_req->z, dh_req->z_len); - } - break; - case CRK_DSA_GENERATE_KEY: -@@ -763,14 +754,14 @@ static int crypto_async_fetch_asym(struct cryptodev_pkc *pkc) - - if (pkc_req->type == ECC_KEYGEN) { - copy_to_user(ckop->crk_param[4].crp_p, key_req->pub_key, -- key_req->pub_key_len); -- copy_to_user(ckop->crk_param[5].crp_p, -- key_req->priv_key, key_req->priv_key_len); -+ key_req->pub_key_len); -+ copy_to_user(ckop->crk_param[5].crp_p, key_req->priv_key, -+ key_req->priv_key_len); - } else { -- copy_to_user(ckop->crk_param[3].crp_p, -- key_req->pub_key, key_req->pub_key_len); -- copy_to_user(ckop->crk_param[4].crp_p, -- key_req->priv_key, key_req->priv_key_len); -+ copy_to_user(ckop->crk_param[3].crp_p, key_req->pub_key, -+ key_req->pub_key_len); -+ copy_to_user(ckop->crk_param[4].crp_p, key_req->priv_key, -+ key_req->priv_key_len); - } - } - default: -@@ -1113,16 +1104,14 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) - if (!list_empty(&pcr->asym_completed_list)) { - /* Run a loop in the list for upto elements - and copy their response back */ -- pkc = -- list_first_entry(&pcr->asym_completed_list, -+ pkc = list_first_entry(&pcr->asym_completed_list, - struct cryptodev_pkc, list); - list_del(&pkc->list); - spin_unlock_bh(&pcr->completion_lock); - ret = crypto_async_fetch_asym(pkc); - if (!ret) { - cookie_list.cookie_available++; -- cookie_list.cookie[i] = -- pkc->kop.kop.cookie; -+ cookie_list.cookie[i] = pkc->kop.kop.cookie; - cookie_list.status[i] = pkc->result.err; - } - kfree(pkc); -@@ -1133,12 +1122,10 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) - } - - /* Reflect the updated request to user-space */ -- if (cookie_list.cookie_available) -- copy_to_user(arg, &cookie_list, -- sizeof(struct pkc_cookie_list_s)); -- else { -+ if (cookie_list.cookie_available) { -+ copy_to_user(arg, &cookie_list, sizeof(struct pkc_cookie_list_s)); -+ } else { - struct pkc_cookie_list_s *user_ck_list = (void *)arg; -- - put_user(0, &(user_ck_list->cookie_available)); - } - ret = cookie_list.cookie_available; -diff --git a/main.c b/main.c -index 6365911..af66553 100644 ---- a/main.c -+++ b/main.c -@@ -666,9 +666,7 @@ int crypto_bn_modexp(struct cryptodev_pkc *pkc) - if (pkc->type == SYNCHRONOUS) { - if (rc) - goto err; -- -- copy_to_user(cop->crk_param[3].crp_p, rsa_req->g, -- rsa_req->g_len); -+ copy_to_user(cop->crk_param[3].crp_p, rsa_req->g, rsa_req->g_len); - } else { - if (rc != -EINPROGRESS && rc != 0) - goto err; --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0014-remove-redundant-data-copy-for-pkc-operations.patch b/recipes-kernel/cryptodev/sdk_patches/0014-remove-redundant-data-copy-for-pkc-operations.patch deleted file mode 100644 index 58d37fa8..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0014-remove-redundant-data-copy-for-pkc-operations.patch +++ /dev/null @@ -1,494 +0,0 @@ -From a4d88e5379ddb7d9bceac3141f508b8173d1e902 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Mon, 23 Feb 2015 12:14:07 +0200 -Subject: [PATCH 14/38] remove redundant data copy for pkc operations - -This patch removes a copy of a pkc request that was -allocated on the hot-path. The copy was not necessary -and was just slowing things down. - -Change-Id: I3ad85f78c188f100ab9fc03a5777bb704a9dcb63 -Signed-off-by: Cristian Stoica -Reviewed-on: http://git.am.freescale.net:8181/34223 ---- - cryptlib.c | 49 +++---------------- - cryptlib.h | 3 +- - ioctl.c | 17 +++---- - main.c | 162 +++++++++++++++++++++++++++++++++++++------------------------ - 4 files changed, 113 insertions(+), 118 deletions(-) - -diff --git a/cryptlib.c b/cryptlib.c -index 21e691b..5882a30 100644 ---- a/cryptlib.c -+++ b/cryptlib.c -@@ -436,59 +436,22 @@ int cryptodev_hash_final(struct hash_data *hdata, void *output) - - int cryptodev_pkc_offload(struct cryptodev_pkc *pkc) - { -- int ret = 0; -- struct pkc_request *pkc_req = &pkc->req, *pkc_requested; -- -- switch (pkc_req->type) { -- case RSA_KEYGEN: -- case RSA_PUB: -- case RSA_PRIV_FORM1: -- case RSA_PRIV_FORM2: -- case RSA_PRIV_FORM3: -- pkc->s = crypto_alloc_pkc("pkc(rsa)", CRYPTO_ALG_TYPE_PKC_RSA, 0); -- break; -- case DSA_SIGN: -- case DSA_VERIFY: -- case ECDSA_SIGN: -- case ECDSA_VERIFY: -- case DLC_KEYGEN: -- case ECC_KEYGEN: -- pkc->s = crypto_alloc_pkc("pkc(dsa)", CRYPTO_ALG_TYPE_PKC_DSA, 0); -- break; -- case DH_COMPUTE_KEY: -- case ECDH_COMPUTE_KEY: -- pkc->s = crypto_alloc_pkc("pkc(dh)", CRYPTO_ALG_TYPE_PKC_DH, 0); -- break; -- default: -- return -EINVAL; -- } -- -- if (IS_ERR_OR_NULL(pkc->s)) -- return -EINVAL; -+ int ret; - - init_completion(&pkc->result.completion); -- pkc_requested = pkc_request_alloc(pkc->s, GFP_KERNEL); -- -- if (unlikely(IS_ERR_OR_NULL(pkc_requested))) { -- ret = -ENOMEM; -- goto error; -- } -- pkc_requested->type = pkc_req->type; -- pkc_requested->curve_type = pkc_req->curve_type; -- memcpy(&pkc_requested->req_u, &pkc_req->req_u, sizeof(pkc_req->req_u)); -- pkc_request_set_callback(pkc_requested, CRYPTO_TFM_REQ_MAY_BACKLOG, -+ pkc_request_set_callback(pkc->req, CRYPTO_TFM_REQ_MAY_BACKLOG, - cryptodev_complete_asym, pkc); -- ret = crypto_pkc_op(pkc_requested); -+ ret = crypto_pkc_op(pkc->req); - if (ret != -EINPROGRESS && ret != 0) -- goto error2; -+ goto error; - - if (pkc->type == SYNCHRONOUS) - ret = waitfor(&pkc->result, ret); - - return ret; --error2: -- kfree(pkc_requested); -+ - error: -+ kfree(pkc->req); - crypto_free_pkc(pkc->s); - return ret; - } -diff --git a/cryptlib.h b/cryptlib.h -index 7ffa54c..4fac0c8 100644 ---- a/cryptlib.h -+++ b/cryptlib.h -@@ -110,8 +110,7 @@ struct cryptodev_pkc { - struct crypto_pkc *s; /* Transform pointer from CryptoAPI */ - struct cryptodev_result result; /* Result to be updated by - completion handler */ -- struct pkc_request req; /* PKC request structure allocated -- from CryptoAPI */ -+ struct pkc_request *req; /* PKC request allocated from CryptoAPI */ - enum offload_type type; /* Synchronous Vs Asynchronous request */ - /* - * cookie used for transfering tranparent information from async -diff --git a/ioctl.c b/ioctl.c -index ee0486c..797b73c 100644 ---- a/ioctl.c -+++ b/ioctl.c -@@ -708,26 +708,25 @@ static int crypto_async_fetch_asym(struct cryptodev_pkc *pkc) - int ret = 0; - struct kernel_crypt_kop *kop = &pkc->kop; - struct crypt_kop *ckop = &kop->kop; -- struct pkc_request *pkc_req = &pkc->req; - - switch (ckop->crk_op) { - case CRK_MOD_EXP: - { -- struct rsa_pub_req_s *rsa_req = &pkc_req->req_u.rsa_pub_req; -+ struct rsa_pub_req_s *rsa_req = &pkc->req->req_u.rsa_pub_req; - copy_to_user(ckop->crk_param[3].crp_p, rsa_req->g, rsa_req->g_len); - } - break; - case CRK_MOD_EXP_CRT: - { -- struct rsa_priv_frm3_req_s *rsa_req = &pkc_req->req_u.rsa_priv_f3; -+ struct rsa_priv_frm3_req_s *rsa_req = &pkc->req->req_u.rsa_priv_f3; - copy_to_user(ckop->crk_param[6].crp_p, rsa_req->f, rsa_req->f_len); - } - break; - case CRK_DSA_SIGN: - { -- struct dsa_sign_req_s *dsa_req = &pkc_req->req_u.dsa_sign; -+ struct dsa_sign_req_s *dsa_req = &pkc->req->req_u.dsa_sign; - -- if (pkc_req->type == ECDSA_SIGN) { -+ if (pkc->req->type == ECDSA_SIGN) { - copy_to_user(ckop->crk_param[6].crp_p, dsa_req->c, dsa_req->d_len); - copy_to_user(ckop->crk_param[7].crp_p, dsa_req->d, dsa_req->d_len); - } else { -@@ -740,8 +739,8 @@ static int crypto_async_fetch_asym(struct cryptodev_pkc *pkc) - break; - case CRK_DH_COMPUTE_KEY: - { -- struct dh_key_req_s *dh_req = &pkc_req->req_u.dh_req; -- if (pkc_req->type == ECDH_COMPUTE_KEY) -+ struct dh_key_req_s *dh_req = &pkc->req->req_u.dh_req; -+ if (pkc->req->type == ECDH_COMPUTE_KEY) - copy_to_user(ckop->crk_param[4].crp_p, dh_req->z, dh_req->z_len); - else - copy_to_user(ckop->crk_param[3].crp_p, dh_req->z, dh_req->z_len); -@@ -750,9 +749,9 @@ static int crypto_async_fetch_asym(struct cryptodev_pkc *pkc) - case CRK_DSA_GENERATE_KEY: - case CRK_DH_GENERATE_KEY: - { -- struct keygen_req_s *key_req = &pkc_req->req_u.keygen; -+ struct keygen_req_s *key_req = &pkc->req->req_u.keygen; - -- if (pkc_req->type == ECC_KEYGEN) { -+ if (pkc->req->type == ECC_KEYGEN) { - copy_to_user(ckop->crk_param[4].crp_p, key_req->pub_key, - key_req->pub_key_len); - copy_to_user(ckop->crk_param[5].crp_p, key_req->priv_key, -diff --git a/main.c b/main.c -index af66553..ed1c69a 100644 ---- a/main.c -+++ b/main.c -@@ -186,8 +186,7 @@ int crypto_kop_dsasign(struct cryptodev_pkc *pkc) - { - struct kernel_crypt_kop *kop = &pkc->kop; - struct crypt_kop *cop = &kop->kop; -- struct pkc_request *pkc_req = &pkc->req; -- struct dsa_sign_req_s *dsa_req = &pkc_req->req_u.dsa_sign; -+ struct dsa_sign_req_s *dsa_req = &pkc->req->req_u.dsa_sign; - int rc, buf_size; - uint8_t *buf; - -@@ -210,10 +209,7 @@ int crypto_kop_dsasign(struct cryptodev_pkc *pkc) - if (cop->crk_iparams == 6) { - dsa_req->ab_len = (cop->crk_param[5].crp_nbits + 7)/8; - buf_size += dsa_req->ab_len; -- pkc_req->type = ECDSA_SIGN; -- pkc_req->curve_type = cop->curve_type; -- } else { -- pkc_req->type = DSA_SIGN; -+ pkc->req->curve_type = cop->curve_type; - } - - buf = kmalloc(buf_size, GFP_DMA); -@@ -269,7 +265,6 @@ int crypto_kop_dsaverify(struct cryptodev_pkc *pkc) - { - struct kernel_crypt_kop *kop = &pkc->kop; - struct crypt_kop *cop = &kop->kop; -- struct pkc_request *pkc_req; - struct dsa_verify_req_s *dsa_req; - int rc, buf_size; - uint8_t *buf; -@@ -281,8 +276,7 @@ int crypto_kop_dsaverify(struct cryptodev_pkc *pkc) - !cop->crk_param[7].crp_nbits)) - return -EINVAL; - -- pkc_req = &pkc->req; -- dsa_req = &pkc_req->req_u.dsa_verify; -+ dsa_req = &pkc->req->req_u.dsa_verify; - dsa_req->m_len = (cop->crk_param[0].crp_nbits + 7)/8; - dsa_req->q_len = (cop->crk_param[1].crp_nbits + 7)/8; - dsa_req->r_len = (cop->crk_param[2].crp_nbits + 7)/8; -@@ -295,10 +289,7 @@ int crypto_kop_dsaverify(struct cryptodev_pkc *pkc) - if (cop->crk_iparams == 8) { - dsa_req->ab_len = (cop->crk_param[5].crp_nbits + 7)/8; - buf_size += dsa_req->ab_len; -- pkc_req->type = ECDSA_VERIFY; -- pkc_req->curve_type = cop->curve_type; -- } else { -- pkc_req->type = DSA_VERIFY; -+ pkc->req->curve_type = cop->curve_type; - } - - buf = kmalloc(buf_size, GFP_DMA); -@@ -351,7 +342,6 @@ int crypto_kop_rsa_keygen(struct cryptodev_pkc *pkc) - { - struct kernel_crypt_kop *kop = &pkc->kop; - struct crypt_kop *cop = &kop->kop; -- struct pkc_request *pkc_req; - struct rsa_keygen_req_s *key_req; - int rc, buf_size; - uint8_t *buf; -@@ -362,9 +352,7 @@ int crypto_kop_rsa_keygen(struct cryptodev_pkc *pkc) - !cop->crk_param[6].crp_nbits) - return -EINVAL; - -- pkc_req = &pkc->req; -- pkc_req->type = RSA_KEYGEN; -- key_req = &pkc_req->req_u.rsa_keygen; -+ key_req = &pkc->req->req_u.rsa_keygen; - key_req->n_len = (cop->crk_param[2].crp_nbits + 7)/8; - key_req->p_len = (cop->crk_param[0].crp_nbits + 7) / 8; - key_req->q_len = (cop->crk_param[1].crp_nbits + 7) / 8; -@@ -427,7 +415,6 @@ int crypto_kop_keygen(struct cryptodev_pkc *pkc) - { - struct kernel_crypt_kop *kop = &pkc->kop; - struct crypt_kop *cop = &kop->kop; -- struct pkc_request *pkc_req; - struct keygen_req_s *key_req; - int rc, buf_size; - uint8_t *buf; -@@ -437,8 +424,7 @@ int crypto_kop_keygen(struct cryptodev_pkc *pkc) - !cop->crk_param[4].crp_nbits) - return -EINVAL; - -- pkc_req = &pkc->req; -- key_req = &pkc_req->req_u.keygen; -+ key_req = &pkc->req->req_u.keygen; - key_req->q_len = (cop->crk_param[0].crp_nbits + 7)/8; - key_req->r_len = (cop->crk_param[1].crp_nbits + 7)/8; - key_req->g_len = (cop->crk_param[2].crp_nbits + 7)/8; -@@ -447,7 +433,6 @@ int crypto_kop_keygen(struct cryptodev_pkc *pkc) - key_req->priv_key_len = (cop->crk_param[4].crp_nbits + 7)/8; - buf_size = key_req->q_len + key_req->r_len + key_req->g_len + - key_req->pub_key_len + key_req->priv_key_len; -- pkc_req->type = DLC_KEYGEN; - } else { - key_req->ab_len = (cop->crk_param[3].crp_nbits + 7)/8; - key_req->pub_key_len = (cop->crk_param[4].crp_nbits + 7)/8; -@@ -455,8 +440,7 @@ int crypto_kop_keygen(struct cryptodev_pkc *pkc) - buf_size = key_req->q_len + key_req->r_len + key_req->g_len + - key_req->pub_key_len + key_req->priv_key_len + - key_req->ab_len; -- pkc_req->type = ECC_KEYGEN; -- pkc_req->curve_type = cop->curve_type; -+ pkc->req->curve_type = cop->curve_type; - } - - buf = kmalloc(buf_size, GFP_DMA); -@@ -508,26 +492,22 @@ int crypto_kop_dh_key(struct cryptodev_pkc *pkc) - { - struct kernel_crypt_kop *kop = &pkc->kop; - struct crypt_kop *cop = &kop->kop; -- struct pkc_request *pkc_req; - struct dh_key_req_s *dh_req; - int buf_size; - uint8_t *buf; - int rc = -EINVAL; - -- pkc_req = &pkc->req; -- dh_req = &pkc_req->req_u.dh_req; -+ dh_req = &pkc->req->req_u.dh_req; - dh_req->s_len = (cop->crk_param[0].crp_nbits + 7)/8; - dh_req->pub_key_len = (cop->crk_param[1].crp_nbits + 7)/8; - dh_req->q_len = (cop->crk_param[2].crp_nbits + 7)/8; - buf_size = dh_req->q_len + dh_req->pub_key_len + dh_req->s_len; - if (cop->crk_iparams == 4) { -- pkc_req->type = ECDH_COMPUTE_KEY; - dh_req->ab_len = (cop->crk_param[3].crp_nbits + 7)/8; - dh_req->z_len = (cop->crk_param[4].crp_nbits + 7)/8; - buf_size += dh_req->ab_len; - } else { - dh_req->z_len = (cop->crk_param[3].crp_nbits + 7)/8; -- pkc_req->type = DH_COMPUTE_KEY; - } - buf_size += dh_req->z_len; - buf = kmalloc(buf_size, GFP_DMA); -@@ -539,7 +519,7 @@ int crypto_kop_dh_key(struct cryptodev_pkc *pkc) - dh_req->z = dh_req->pub_key + dh_req->pub_key_len; - if (cop->crk_iparams == 4) { - dh_req->ab = dh_req->z + dh_req->z_len; -- pkc_req->curve_type = cop->curve_type; -+ pkc->req->curve_type = cop->curve_type; - copy_from_user(dh_req->ab, cop->crk_param[3].crp_p, - dh_req->ab_len); - } -@@ -573,7 +553,6 @@ int crypto_modexp_crt(struct cryptodev_pkc *pkc) - { - struct kernel_crypt_kop *kop = &pkc->kop; - struct crypt_kop *cop = &kop->kop; -- struct pkc_request *pkc_req; - struct rsa_priv_frm3_req_s *rsa_req; - int rc; - uint8_t *buf; -@@ -583,9 +562,7 @@ int crypto_modexp_crt(struct cryptodev_pkc *pkc) - !cop->crk_param[4].crp_nbits || !cop->crk_param[5].crp_nbits) - return -EINVAL; - -- pkc_req = &pkc->req; -- pkc_req->type = RSA_PRIV_FORM3; -- rsa_req = &pkc_req->req_u.rsa_priv_f3; -+ rsa_req = &pkc->req->req_u.rsa_priv_f3; - rsa_req->p_len = (cop->crk_param[0].crp_nbits + 7)/8; - rsa_req->q_len = (cop->crk_param[1].crp_nbits + 7)/8; - rsa_req->g_len = (cop->crk_param[2].crp_nbits + 7)/8; -@@ -632,7 +609,6 @@ err: - - int crypto_bn_modexp(struct cryptodev_pkc *pkc) - { -- struct pkc_request *pkc_req; - struct rsa_pub_req_s *rsa_req; - int rc; - struct kernel_crypt_kop *kop = &pkc->kop; -@@ -643,9 +619,7 @@ int crypto_bn_modexp(struct cryptodev_pkc *pkc) - !cop->crk_param[2].crp_nbits || !cop->crk_param[3].crp_nbits) - return -EINVAL; - -- pkc_req = &pkc->req; -- pkc_req->type = RSA_PUB; -- rsa_req = &pkc_req->req_u.rsa_pub_req; -+ rsa_req = &pkc->req->req_u.rsa_pub_req; - rsa_req->f_len = (cop->crk_param[0].crp_nbits + 7)/8; - rsa_req->e_len = (cop->crk_param[1].crp_nbits + 7)/8; - rsa_req->n_len = (cop->crk_param[2].crp_nbits + 7)/8; -@@ -680,56 +654,116 @@ err: - return rc; - } - -+static struct { -+ char *alg_name; -+ u32 type; -+ u32 mask; -+} pkc_alg_list[] = { -+ {"pkc(rsa)", CRYPTO_ALG_TYPE_PKC_RSA, 0}, -+ {"pkc(dsa)", CRYPTO_ALG_TYPE_PKC_DSA, 0}, -+ {"pkc(dh)", CRYPTO_ALG_TYPE_PKC_DH, 0}, -+}; -+ - int crypto_run_asym(struct cryptodev_pkc *pkc) - { -- int ret = -EINVAL; -+ int err = -EINVAL; -+ int id; - struct kernel_crypt_kop *kop = &pkc->kop; -+ enum pkc_req_type pkc_req_type; -+ int (*call_next_action)(struct cryptodev_pkc *pkc); - - switch (kop->kop.crk_op) { - case CRK_MOD_EXP: - if (kop->kop.crk_iparams != 3 && kop->kop.crk_oparams != 1) -- goto err; -- -- ret = crypto_bn_modexp(pkc); -+ return err; -+ pkc_req_type = RSA_PUB; -+ id = 0; -+ call_next_action = crypto_bn_modexp; - break; - case CRK_MOD_EXP_CRT: - if (kop->kop.crk_iparams != 6 && kop->kop.crk_oparams != 1) -- goto err; -- -- ret = crypto_modexp_crt(pkc); -+ return err; -+ pkc_req_type = RSA_PRIV_FORM3; -+ id = 0; -+ call_next_action = crypto_modexp_crt; - break; - case CRK_DSA_SIGN: -- if ((kop->kop.crk_iparams != 5 && kop->kop.crk_iparams != 6) || -- kop->kop.crk_oparams != 2) -- goto err; -- -- ret = crypto_kop_dsasign(pkc); -+ if (kop->kop.crk_oparams != 2) -+ return err; -+ else if (kop->kop.crk_iparams == 5) -+ pkc_req_type = DSA_SIGN; -+ else if (kop->kop.crk_iparams == 6) -+ pkc_req_type = ECDSA_SIGN; -+ else -+ return err; -+ id = 1; -+ call_next_action = crypto_kop_dsasign; - break; - case CRK_DSA_VERIFY: -- if ((kop->kop.crk_iparams != 7 && kop->kop.crk_iparams != 8) || -- kop->kop.crk_oparams != 0) -- goto err; -- -- ret = crypto_kop_dsaverify(pkc); -+ if (kop->kop.crk_oparams != 0) -+ return err; -+ else if (kop->kop.crk_iparams == 7) -+ pkc_req_type = DSA_VERIFY; -+ else if (kop->kop.crk_iparams == 8) -+ pkc_req_type = ECDSA_VERIFY; -+ else -+ return err; -+ id = 1; -+ call_next_action = crypto_kop_dsaverify; - break; - case CRK_DH_COMPUTE_KEY: -- if ((kop->kop.crk_iparams != 3 && kop->kop.crk_iparams != 4) || -- kop->kop.crk_oparams != 1) -- goto err; -- ret = crypto_kop_dh_key(pkc); -+ if (kop->kop.crk_oparams != 1) -+ return err; -+ else if (kop->kop.crk_iparams == 3) -+ pkc_req_type = DH_COMPUTE_KEY; -+ else if (kop->kop.crk_iparams == 4) -+ pkc_req_type = ECDH_COMPUTE_KEY; -+ else -+ return err; -+ id = 2; -+ call_next_action = crypto_kop_dh_key; - break; - case CRK_DH_GENERATE_KEY: - case CRK_DSA_GENERATE_KEY: -- if ((kop->kop.crk_iparams != 3 && kop->kop.crk_iparams != 4)) -- goto err; -- ret = crypto_kop_keygen(pkc); -+ if (kop->kop.crk_iparams == 3) -+ pkc_req_type = DLC_KEYGEN; -+ else if (kop->kop.crk_iparams == 4) -+ pkc_req_type = ECC_KEYGEN; -+ else -+ return err; -+ id = 1; -+ call_next_action = crypto_kop_keygen; - break; - case CRK_RSA_GENERATE_KEY: -- ret = crypto_kop_rsa_keygen(pkc); -+ pkc_req_type = RSA_KEYGEN; -+ id = 0; -+ call_next_action = crypto_kop_rsa_keygen; - break; -+ default: -+ return err; - } --err: -- return ret; -+ err = -ENOMEM; -+ pkc->s = crypto_alloc_pkc(pkc_alg_list[id].alg_name, -+ pkc_alg_list[id].type, -+ pkc_alg_list[id].mask); -+ if (IS_ERR_OR_NULL(pkc->s)) -+ return err; -+ -+ pkc->req = pkc_request_alloc(pkc->s, GFP_KERNEL); -+ if (IS_ERR_OR_NULL(pkc->req)) -+ goto out_free_tfm; -+ -+ /* todo - fix alloc-free on error path */ -+ pkc->req->type = pkc_req_type; -+ err = call_next_action(pkc); -+ if (pkc->type == SYNCHRONOUS) -+ kfree(pkc->req); -+ -+ return err; -+ -+out_free_tfm: -+ crypto_free_pkc(pkc->s); -+ return err; - } - - int crypto_run(struct fcrypt *fcr, struct kernel_crypt_op *kcop) --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0015-fix-pkc-request-deallocation.patch b/recipes-kernel/cryptodev/sdk_patches/0015-fix-pkc-request-deallocation.patch deleted file mode 100644 index ef189921..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0015-fix-pkc-request-deallocation.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 212e418fa7b70c8ba79446006001c574cb9d42f8 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Mon, 23 Feb 2015 15:28:22 +0200 -Subject: [PATCH 15/38] fix pkc request deallocation - -The request to be freed is actually pkc->req, and should be done inside -the fetch ioctl for ASYNC (this patch) and in crypt ioctl for SYNC -operations. - -Change-Id: I6f046f2ebeae4cb513a419996ca96b52e37468ed -Signed-off-by: Cristian Stoica -Reviewed-on: http://git.am.freescale.net:8181/34224 ---- - ioctl.c | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -diff --git a/ioctl.c b/ioctl.c -index 797b73c..da3a842 100644 ---- a/ioctl.c -+++ b/ioctl.c -@@ -114,8 +114,6 @@ void cryptodev_complete_asym(struct crypto_async_request *req, int err) - /* wake for POLLIN */ - wake_up_interruptible(&pcr->user_waiter); - } -- -- kfree(req); - } - - #define FILL_SG(sg, ptr, len) \ -@@ -1113,6 +1111,7 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) - cookie_list.cookie[i] = pkc->kop.kop.cookie; - cookie_list.status[i] = pkc->result.err; - } -+ kfree(pkc->req); - kfree(pkc); - } else { - spin_unlock_bh(&pcr->completion_lock); --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0016-add-basic-detection-of-asym-features.patch b/recipes-kernel/cryptodev/sdk_patches/0016-add-basic-detection-of-asym-features.patch deleted file mode 100644 index 9301349a..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0016-add-basic-detection-of-asym-features.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 4ce4081d9abef651473e9d7e089a0748f77db631 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Mon, 20 Apr 2015 13:18:47 +0300 -Subject: [PATCH 16/38] add basic detection of asym features - -Change-Id: I3b3ba8664bf631a63be1f11e715024509e20f841 -Signed-off-by: Cristian Stoica ---- - ioctl.c | 12 ++++++++---- - 1 file changed, 8 insertions(+), 4 deletions(-) - -diff --git a/ioctl.c b/ioctl.c -index da3a842..53dbf64 100644 ---- a/ioctl.c -+++ b/ioctl.c -@@ -977,10 +977,14 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) - - switch (cmd) { - case CIOCASYMFEAT: -- return put_user(CRF_MOD_EXP_CRT | CRF_MOD_EXP | CRF_DSA_SIGN | -- CRF_DSA_VERIFY | CRF_DH_COMPUTE_KEY | -- CRF_DSA_GENERATE_KEY | CRF_DH_GENERATE_KEY | -- CRF_RSA_GENERATE_KEY, p); -+ ses = 0; -+ if (crypto_has_alg("pkc(rsa)", 0, 0)) -+ ses = CRF_MOD_EXP_CRT | CRF_MOD_EXP | CRF_RSA_GENERATE_KEY; -+ if (crypto_has_alg("pkc(dsa)", 0, 0)) -+ ses |= CRF_DSA_SIGN | CRF_DSA_VERIFY | CRF_DSA_GENERATE_KEY; -+ if (crypto_has_alg("pkc(dh)", 0, 0)) -+ ses |= CRF_DH_COMPUTE_KEY |CRF_DH_GENERATE_KEY; -+ return put_user(ses, p); - case CRIOGET: - fd = clonefd(filp); - ret = put_user(fd, p); --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0017-remove-dead-code.patch b/recipes-kernel/cryptodev/sdk_patches/0017-remove-dead-code.patch deleted file mode 100644 index 07c389c7..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0017-remove-dead-code.patch +++ /dev/null @@ -1,67 +0,0 @@ -From 0ca641091b4113d73e75d30ef530c88836849308 Mon Sep 17 00:00:00 2001 -From: Tudor Ambarus -Date: Fri, 29 May 2015 15:28:47 +0300 -Subject: [PATCH 17/38] remove dead code - -Functions kop_to_user and compat_kop_to_user are never used. Delete them -to avoid compiler warnings. - - -crypto/../../cryptodev-linux/ioctl.c:841:12: warning: 'kop_to_user' defined but not used [-Wunused-function] - static int kop_to_user(struct kernel_crypt_kop *kop, - ^ -crypto/../../cryptodev-linux/ioctl.c: At top level: -crypto/../../cryptodev-linux/ioctl.c:1195:12: warning: 'compat_kop_to_user' defined but not used [-Wunused-function] - static int compat_kop_to_user(struct kernel_crypt_kop *kop, void __user *arg) - ^ -Signed-off-by: Tudor Ambarus -Signed-off-by: Cristian Stoica -Change-Id: I6bd8a7eb6144224a20cd400813ab15a7a192dbb1 -Reviewed-on: http://git.am.freescale.net:8181/37440 ---- - ioctl.c | 22 ---------------------- - 1 file changed, 22 deletions(-) - -diff --git a/ioctl.c b/ioctl.c -index 53dbf64..39635a4 100644 ---- a/ioctl.c -+++ b/ioctl.c -@@ -838,16 +838,6 @@ static int kop_from_user(struct kernel_crypt_kop *kop, - return fill_kop_from_cop(kop); - } - --static int kop_to_user(struct kernel_crypt_kop *kop, -- void __user *arg) --{ -- if (unlikely(copy_to_user(arg, &kop->kop, sizeof(kop->kop)))) { -- dprintk(1, KERN_ERR, "Cannot copy to userspace\n"); -- return -EFAULT; -- } -- return 0; --} -- - static int kcop_from_user(struct kernel_crypt_op *kcop, - struct fcrypt *fcr, void __user *arg) - { -@@ -1192,18 +1182,6 @@ static inline void crypt_kop_to_compat(struct crypt_kop *kop, - compat->curve_type = kop->curve_type; - } - --static int compat_kop_to_user(struct kernel_crypt_kop *kop, void __user *arg) --{ -- struct compat_crypt_kop compat_kop; -- -- crypt_kop_to_compat(&kop->kop, &compat_kop); -- if (unlikely(copy_to_user(arg, &compat_kop, sizeof(compat_kop)))) { -- dprintk(1, KERN_ERR, "Cannot copy to userspace\n"); -- return -EFAULT; -- } -- return 0; --} -- - static inline void - compat_to_session_op(struct compat_session_op *compat, struct session_op *sop) - { --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0018-fix-compat-warnings.patch b/recipes-kernel/cryptodev/sdk_patches/0018-fix-compat-warnings.patch deleted file mode 100644 index b0fcf0f6..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0018-fix-compat-warnings.patch +++ /dev/null @@ -1,64 +0,0 @@ -From 596378a22532908487f2c5e4d717c5ae618c4c7d Mon Sep 17 00:00:00 2001 -From: Tudor Ambarus -Date: Tue, 2 Jun 2015 10:44:12 +0300 -Subject: [PATCH 18/38] fix compat warnings - - CC [M] crypto/../../cryptodev-linux/ioctl.o -crypto/../../cryptodev-linux/ioctl.c: In function 'compat_to_crypt_kop': -crypto/../../cryptodev-linux/ioctl.c:1161:14: warning: assignment makes pointer from integer without a cast - kop->cookie = compat->cookie; - ^ -crypto/../../cryptodev-linux/ioctl.c: In function 'crypt_kop_to_compat': -crypto/../../cryptodev-linux/ioctl.c:1191:17: warning: assignment makes integer from pointer without a cast - compat->cookie = kop->cookie; - ^ -crypto/../../cryptodev-linux/ioctl.c: In function 'cryptodev_compat_ioctl': -crypto/../../cryptodev-linux/ioctl.c:1430:28: warning: assignment makes integer from pointer without a cast - cookie_list.cookie[i] = - ^ - -Signed-off-by: Tudor Ambarus -Change-Id: Id851408c0c743c01447f3b0ced38fbc1ae94d4db -Reviewed-on: http://git.am.freescale.net:8181/37442 -Reviewed-by: Cristian Stoica -Tested-by: Cristian Stoica ---- - ioctl.c | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -diff --git a/ioctl.c b/ioctl.c -index 39635a4..f3ce2f6 100644 ---- a/ioctl.c -+++ b/ioctl.c -@@ -1148,7 +1148,7 @@ static inline void compat_to_crypt_kop(struct compat_crypt_kop *compat, - } - - kop->curve_type = compat->curve_type; -- kop->cookie = compat->cookie; -+ kop->cookie = compat_ptr(compat->cookie); - } - - static int compat_kop_from_user(struct kernel_crypt_kop *kop, -@@ -1178,7 +1178,7 @@ static inline void crypt_kop_to_compat(struct crypt_kop *kop, - ptr_to_compat(kop->crk_param[i].crp_p); - compat->crk_param[i].crp_nbits = kop->crk_param[i].crp_nbits; - } -- compat->cookie = kop->cookie; -+ compat->cookie = ptr_to_compat(kop->cookie); - compat->curve_type = kop->curve_type; - } - -@@ -1405,8 +1405,8 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) - ret = crypto_async_fetch_asym(pkc); - if (!ret) { - cookie_list.cookie_available++; -- cookie_list.cookie[i] = -- pkc->kop.kop.cookie; -+ cookie_list.cookie[i] = ptr_to_compat( -+ pkc->kop.kop.cookie); - } - kfree(pkc); - } else { --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0019-fix-size_t-print-format.patch b/recipes-kernel/cryptodev/sdk_patches/0019-fix-size_t-print-format.patch deleted file mode 100644 index fdf8c5d3..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0019-fix-size_t-print-format.patch +++ /dev/null @@ -1,61 +0,0 @@ -From 1d10f06bef0f07980a08b387850c1daf1d3a8e87 Mon Sep 17 00:00:00 2001 -From: Tudor Ambarus -Date: Tue, 2 Jun 2015 12:11:12 +0300 -Subject: [PATCH 19/38] fix size_t print format - - CC [M] crypto/../../cryptodev-linux/cryptlib.o -crypto/../../cryptodev-linux/cryptlib.c: In function 'cryptodev_cipher_init': -crypto/../../cryptodev-linux/cryptlib.c:146:5: warning: format '%u' expects argument of type 'unsigned int', but argument 6 has type 'size_t' [-Wformat=] - ddebug(1, "Wrong keylen '%u' for algorithm '%s'. Use %u to %u.", - ^ -crypto/../../cryptodev-linux/cryptlib.c:173:3: warning: format '%u' expects argument of type 'unsigned int', but argument 7 has type 'size_t' [-Wformat=] - ddebug(1, "Setting key failed for %s-%u.", alg_name, keylen*8); - ^ -crypto/../../cryptodev-linux/cryptlib.c: In function 'cryptodev_hash_init': -crypto/../../cryptodev-linux/cryptlib.c:340:4: warning: format '%u' expects argument of type 'unsigned int', but argument 7 has type 'size_t' [-Wformat=] - ddebug(1, "Setting hmac key failed for %s-%u.", - ^ - -Signed-off-by: Tudor Ambarus -Change-Id: I67f2d79f68b4d62b598073c6a918a110523fadfd -Reviewed-on: http://git.am.freescale.net:8181/37443 -Reviewed-by: Cristian Stoica -Tested-by: Cristian Stoica ---- - cryptlib.c | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/cryptlib.c b/cryptlib.c -index 5882a30..10f5e1a 100644 ---- a/cryptlib.c -+++ b/cryptlib.c -@@ -143,7 +143,7 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, - if (alg->max_keysize > 0 && - unlikely((keylen < alg->min_keysize) || - (keylen > alg->max_keysize))) { -- ddebug(1, "Wrong keylen '%u' for algorithm '%s'. Use %u to %u.", -+ ddebug(1, "Wrong keylen '%zu' for algorithm '%s'. Use %u to %u.", - keylen, alg_name, alg->min_keysize, alg->max_keysize); - ret = -EINVAL; - goto error; -@@ -170,7 +170,7 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, - } - - if (unlikely(ret)) { -- ddebug(1, "Setting key failed for %s-%u.", alg_name, keylen*8); -+ ddebug(1, "Setting key failed for %s-%zu.", alg_name, keylen*8); - ret = -EINVAL; - goto error; - } -@@ -337,7 +337,7 @@ int cryptodev_hash_init(struct hash_data *hdata, const char *alg_name, - if (hmac_mode != 0) { - ret = crypto_ahash_setkey(hdata->async.s, mackey, mackeylen); - if (unlikely(ret)) { -- ddebug(1, "Setting hmac key failed for %s-%u.", -+ ddebug(1, "Setting hmac key failed for %s-%zu.", - alg_name, mackeylen*8); - ret = -EINVAL; - goto error; --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0020-fix-uninitialized-variable-compiler-warning.patch b/recipes-kernel/cryptodev/sdk_patches/0020-fix-uninitialized-variable-compiler-warning.patch deleted file mode 100644 index dddd77ea..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0020-fix-uninitialized-variable-compiler-warning.patch +++ /dev/null @@ -1,38 +0,0 @@ -From be9f6a0dc90847dbb00307d23f47b8b3fc3ff130 Mon Sep 17 00:00:00 2001 -From: Tudor Ambarus -Date: Fri, 29 May 2015 15:49:22 +0300 -Subject: [PATCH 20/38] fix uninitialized variable compiler warning - -crypto/../../cryptodev-linux/ioctl.c: In function 'cryptodev_compat_ioctl': -crypto/../../cryptodev-linux/ioctl.c:1445:2: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized] - return ret; - ^ - -Signed-off-by: Tudor Ambarus -Change-Id: Id5226fc97a3bb880ca6db86df58957122bbaa428 -Reviewed-on: http://git.am.freescale.net:8181/37441 -Reviewed-by: Cristian Stoica -Tested-by: Cristian Stoica ---- - ioctl.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/ioctl.c b/ioctl.c -index f3ce2f6..7cd3c56 100644 ---- a/ioctl.c -+++ b/ioctl.c -@@ -1387,9 +1387,10 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) - case COMPAT_CIOCASYMFETCHCOOKIE: - { - struct cryptodev_pkc *pkc; -- int i = 0; -+ int i; - struct compat_pkc_cookie_list_s cookie_list; - -+ ret = 0; - cookie_list.cookie_available = 0; - - for (i = 0; i < MAX_COOKIES; i++) { --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0021-check-return-codes-for-copy-to-from-user-functions.patch b/recipes-kernel/cryptodev/sdk_patches/0021-check-return-codes-for-copy-to-from-user-functions.patch deleted file mode 100644 index 2cace5fd..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0021-check-return-codes-for-copy-to-from-user-functions.patch +++ /dev/null @@ -1,398 +0,0 @@ -From 4078382cfc69c0f5e582d485fe8cc778f9e458d1 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Mon, 21 Sep 2015 16:39:52 +0300 -Subject: [PATCH 21/38] check return codes for copy to/from user functions - -- these functions may fail and we should check their return codes. -- fix an unintended fall-through in CRK_DSA_GENERATE_KEY -- fix incorrect return code for CIOCASYMFETCHCOOKIE - -Signed-off-by: Cristian Stoica ---- - ioctl.c | 42 +++++++-------- - main.c | 183 ++++++++++++++++++++++++++++++---------------------------------- - 2 files changed, 108 insertions(+), 117 deletions(-) - -diff --git a/ioctl.c b/ioctl.c -index 7cd3c56..8fa3e5c 100644 ---- a/ioctl.c -+++ b/ioctl.c -@@ -711,13 +711,13 @@ static int crypto_async_fetch_asym(struct cryptodev_pkc *pkc) - case CRK_MOD_EXP: - { - struct rsa_pub_req_s *rsa_req = &pkc->req->req_u.rsa_pub_req; -- copy_to_user(ckop->crk_param[3].crp_p, rsa_req->g, rsa_req->g_len); -+ ret = copy_to_user(ckop->crk_param[3].crp_p, rsa_req->g, rsa_req->g_len); - } - break; - case CRK_MOD_EXP_CRT: - { - struct rsa_priv_frm3_req_s *rsa_req = &pkc->req->req_u.rsa_priv_f3; -- copy_to_user(ckop->crk_param[6].crp_p, rsa_req->f, rsa_req->f_len); -+ ret = copy_to_user(ckop->crk_param[6].crp_p, rsa_req->f, rsa_req->f_len); - } - break; - case CRK_DSA_SIGN: -@@ -725,11 +725,11 @@ static int crypto_async_fetch_asym(struct cryptodev_pkc *pkc) - struct dsa_sign_req_s *dsa_req = &pkc->req->req_u.dsa_sign; - - if (pkc->req->type == ECDSA_SIGN) { -- copy_to_user(ckop->crk_param[6].crp_p, dsa_req->c, dsa_req->d_len); -- copy_to_user(ckop->crk_param[7].crp_p, dsa_req->d, dsa_req->d_len); -+ ret = copy_to_user(ckop->crk_param[6].crp_p, dsa_req->c, dsa_req->d_len) || -+ copy_to_user(ckop->crk_param[7].crp_p, dsa_req->d, dsa_req->d_len); - } else { -- copy_to_user(ckop->crk_param[5].crp_p, dsa_req->c, dsa_req->d_len); -- copy_to_user(ckop->crk_param[6].crp_p, dsa_req->d, dsa_req->d_len); -+ ret = copy_to_user(ckop->crk_param[5].crp_p, dsa_req->c, dsa_req->d_len) || -+ copy_to_user(ckop->crk_param[6].crp_p, dsa_req->d, dsa_req->d_len); - } - } - break; -@@ -739,9 +739,9 @@ static int crypto_async_fetch_asym(struct cryptodev_pkc *pkc) - { - struct dh_key_req_s *dh_req = &pkc->req->req_u.dh_req; - if (pkc->req->type == ECDH_COMPUTE_KEY) -- copy_to_user(ckop->crk_param[4].crp_p, dh_req->z, dh_req->z_len); -+ ret = copy_to_user(ckop->crk_param[4].crp_p, dh_req->z, dh_req->z_len); - else -- copy_to_user(ckop->crk_param[3].crp_p, dh_req->z, dh_req->z_len); -+ ret = copy_to_user(ckop->crk_param[3].crp_p, dh_req->z, dh_req->z_len); - } - break; - case CRK_DSA_GENERATE_KEY: -@@ -750,16 +750,17 @@ static int crypto_async_fetch_asym(struct cryptodev_pkc *pkc) - struct keygen_req_s *key_req = &pkc->req->req_u.keygen; - - if (pkc->req->type == ECC_KEYGEN) { -- copy_to_user(ckop->crk_param[4].crp_p, key_req->pub_key, -- key_req->pub_key_len); -- copy_to_user(ckop->crk_param[5].crp_p, key_req->priv_key, -+ ret = copy_to_user(ckop->crk_param[4].crp_p, key_req->pub_key, -+ key_req->pub_key_len) || -+ copy_to_user(ckop->crk_param[5].crp_p, key_req->priv_key, - key_req->priv_key_len); - } else { -- copy_to_user(ckop->crk_param[3].crp_p, key_req->pub_key, -- key_req->pub_key_len); -- copy_to_user(ckop->crk_param[4].crp_p, key_req->priv_key, -+ ret = copy_to_user(ckop->crk_param[3].crp_p, key_req->pub_key, -+ key_req->pub_key_len) || -+ copy_to_user(ckop->crk_param[4].crp_p, key_req->priv_key, - key_req->priv_key_len); - } -+ break; - } - default: - ret = -EINVAL; -@@ -1115,14 +1116,12 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) - - /* Reflect the updated request to user-space */ - if (cookie_list.cookie_available) { -- copy_to_user(arg, &cookie_list, sizeof(struct pkc_cookie_list_s)); -+ ret = copy_to_user(arg, &cookie_list, sizeof(struct pkc_cookie_list_s)); - } else { - struct pkc_cookie_list_s *user_ck_list = (void *)arg; -- put_user(0, &(user_ck_list->cookie_available)); -+ ret = put_user(0, &(user_ck_list->cookie_available)); - } -- ret = cookie_list.cookie_available; - } -- - return ret; - default: - return -EINVAL; -@@ -1417,9 +1416,10 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) - } - - /* Reflect the updated request to user-space */ -- if (cookie_list.cookie_available) -- copy_to_user(arg, &cookie_list, -- sizeof(struct compat_pkc_cookie_list_s)); -+ if (cookie_list.cookie_available) { -+ ret = copy_to_user(arg, &cookie_list, -+ sizeof(struct compat_pkc_cookie_list_s)); -+ } - } - return ret; - default: -diff --git a/main.c b/main.c -index ed1c69a..e5adb93 100644 ---- a/main.c -+++ b/main.c -@@ -223,31 +223,29 @@ int crypto_kop_dsasign(struct cryptodev_pkc *pkc) - dsa_req->m = dsa_req->priv_key + dsa_req->priv_key_len; - dsa_req->c = dsa_req->m + dsa_req->m_len; - dsa_req->d = dsa_req->c + dsa_req->d_len; -- copy_from_user(dsa_req->m, cop->crk_param[0].crp_p, dsa_req->m_len); -- copy_from_user(dsa_req->q, cop->crk_param[1].crp_p, dsa_req->q_len); -- copy_from_user(dsa_req->r, cop->crk_param[2].crp_p, dsa_req->r_len); -- copy_from_user(dsa_req->g, cop->crk_param[3].crp_p, dsa_req->g_len); -- copy_from_user(dsa_req->priv_key, cop->crk_param[4].crp_p, -- dsa_req->priv_key_len); -+ rc = copy_from_user(dsa_req->m, cop->crk_param[0].crp_p, dsa_req->m_len) || -+ copy_from_user(dsa_req->q, cop->crk_param[1].crp_p, dsa_req->q_len) || -+ copy_from_user(dsa_req->r, cop->crk_param[2].crp_p, dsa_req->r_len) || -+ copy_from_user(dsa_req->g, cop->crk_param[3].crp_p, dsa_req->g_len) || -+ copy_from_user(dsa_req->priv_key, cop->crk_param[4].crp_p, dsa_req->priv_key_len); - if (cop->crk_iparams == 6) { - dsa_req->ab = dsa_req->d + dsa_req->d_len; -- copy_from_user(dsa_req->ab, cop->crk_param[5].crp_p, -+ rc = rc || copy_from_user(dsa_req->ab, cop->crk_param[5].crp_p, - dsa_req->ab_len); - } -+ if (rc) -+ goto err; -+ - rc = cryptodev_pkc_offload(pkc); - if (pkc->type == SYNCHRONOUS) { -- if (rc) -- goto err; - if (cop->crk_iparams == 6) { -- copy_to_user(cop->crk_param[6].crp_p, dsa_req->c, -- dsa_req->d_len); -- copy_to_user(cop->crk_param[7].crp_p, dsa_req->d, -- dsa_req->d_len); -+ rc = rc || -+ copy_to_user(cop->crk_param[6].crp_p, dsa_req->c, dsa_req->d_len) || -+ copy_to_user(cop->crk_param[7].crp_p, dsa_req->d, dsa_req->d_len); - } else { -- copy_to_user(cop->crk_param[5].crp_p, dsa_req->c, -- dsa_req->d_len); -- copy_to_user(cop->crk_param[6].crp_p, dsa_req->d, -- dsa_req->d_len); -+ rc = rc || -+ copy_to_user(cop->crk_param[5].crp_p, dsa_req->c, dsa_req->d_len) || -+ copy_to_user(cop->crk_param[6].crp_p, dsa_req->d, dsa_req->d_len); - } - } else { - if (rc != -EINPROGRESS && rc != 0) -@@ -303,31 +301,28 @@ int crypto_kop_dsaverify(struct cryptodev_pkc *pkc) - dsa_req->m = dsa_req->pub_key + dsa_req->pub_key_len; - dsa_req->c = dsa_req->m + dsa_req->m_len; - dsa_req->d = dsa_req->c + dsa_req->d_len; -- copy_from_user(dsa_req->m, cop->crk_param[0].crp_p, dsa_req->m_len); -- copy_from_user(dsa_req->q, cop->crk_param[1].crp_p, dsa_req->q_len); -- copy_from_user(dsa_req->r, cop->crk_param[2].crp_p, dsa_req->r_len); -- copy_from_user(dsa_req->g, cop->crk_param[3].crp_p, dsa_req->g_len); -- copy_from_user(dsa_req->pub_key, cop->crk_param[4].crp_p, -- dsa_req->pub_key_len); -+ rc = copy_from_user(dsa_req->m, cop->crk_param[0].crp_p, dsa_req->m_len) || -+ copy_from_user(dsa_req->q, cop->crk_param[1].crp_p, dsa_req->q_len) || -+ copy_from_user(dsa_req->r, cop->crk_param[2].crp_p, dsa_req->r_len) || -+ copy_from_user(dsa_req->g, cop->crk_param[3].crp_p, dsa_req->g_len) || -+ copy_from_user(dsa_req->pub_key, cop->crk_param[4].crp_p, dsa_req->pub_key_len); - if (cop->crk_iparams == 8) { - dsa_req->ab = dsa_req->d + dsa_req->d_len; -- copy_from_user(dsa_req->ab, cop->crk_param[5].crp_p, -- dsa_req->ab_len); -- copy_from_user(dsa_req->c, cop->crk_param[6].crp_p, -- dsa_req->d_len); -- copy_from_user(dsa_req->d, cop->crk_param[7].crp_p, -- dsa_req->d_len); -+ rc = rc || -+ copy_from_user(dsa_req->ab, cop->crk_param[5].crp_p, dsa_req->ab_len) || -+ copy_from_user(dsa_req->c, cop->crk_param[6].crp_p, dsa_req->d_len) || -+ copy_from_user(dsa_req->d, cop->crk_param[7].crp_p, dsa_req->d_len); - } else { -- copy_from_user(dsa_req->c, cop->crk_param[5].crp_p, -- dsa_req->d_len); -- copy_from_user(dsa_req->d, cop->crk_param[6].crp_p, -- dsa_req->d_len); -+ rc = rc || -+ copy_from_user(dsa_req->c, cop->crk_param[5].crp_p, dsa_req->d_len) || -+ copy_from_user(dsa_req->d, cop->crk_param[6].crp_p, dsa_req->d_len); - } -+ -+ if (rc) -+ goto err; -+ - rc = cryptodev_pkc_offload(pkc); -- if (pkc->type == SYNCHRONOUS) { -- if (rc) -- goto err; -- } else { -+ if (pkc->type != SYNCHRONOUS) { - if (rc != -EINPROGRESS && !rc) - goto err; - pkc->cookie = buf; -@@ -380,24 +375,15 @@ int crypto_kop_rsa_keygen(struct cryptodev_pkc *pkc) - rc = cryptodev_pkc_offload(pkc); - - if (pkc->type == SYNCHRONOUS) { -- if (rc) -- goto err; -- -- copy_to_user(cop->crk_param[0].crp_p, -- key_req->p, key_req->p_len); -- copy_to_user(cop->crk_param[1].crp_p, -- key_req->q, key_req->q_len); -- copy_to_user(cop->crk_param[2].crp_p, -- key_req->n, key_req->n_len); -- copy_to_user(cop->crk_param[3].crp_p, -- key_req->d, key_req->d_len); -- copy_to_user(cop->crk_param[4].crp_p, -- key_req->dp, key_req->dp_len); -- copy_to_user(cop->crk_param[5].crp_p, -- key_req->dq, key_req->dq_len); -- copy_to_user(cop->crk_param[6].crp_p, -- key_req->c, key_req->c_len); -- } else { -+ rc = rc || -+ copy_to_user(cop->crk_param[0].crp_p, key_req->p, key_req->p_len) || -+ copy_to_user(cop->crk_param[1].crp_p, key_req->q, key_req->q_len) || -+ copy_to_user(cop->crk_param[2].crp_p, key_req->n, key_req->n_len) || -+ copy_to_user(cop->crk_param[3].crp_p, key_req->d, key_req->d_len) || -+ copy_to_user(cop->crk_param[4].crp_p, key_req->dp, key_req->dp_len) || -+ copy_to_user(cop->crk_param[5].crp_p, key_req->dq, key_req->dq_len) || -+ copy_to_user(cop->crk_param[6].crp_p, key_req->c, key_req->c_len); -+ } else { - if (rc != -EINPROGRESS && !rc) { - printk("%s: Failed\n", __func__); - goto err; -@@ -451,30 +437,33 @@ int crypto_kop_keygen(struct cryptodev_pkc *pkc) - key_req->g = key_req->r + key_req->r_len; - key_req->pub_key = key_req->g + key_req->g_len; - key_req->priv_key = key_req->pub_key + key_req->pub_key_len; -- copy_from_user(key_req->q, cop->crk_param[0].crp_p, key_req->q_len); -- copy_from_user(key_req->r, cop->crk_param[1].crp_p, key_req->r_len); -- copy_from_user(key_req->g, cop->crk_param[2].crp_p, key_req->g_len); -+ rc = copy_from_user(key_req->q, cop->crk_param[0].crp_p, key_req->q_len) || -+ copy_from_user(key_req->r, cop->crk_param[1].crp_p, key_req->r_len) || -+ copy_from_user(key_req->g, cop->crk_param[2].crp_p, key_req->g_len); -+ - if (cop->crk_iparams == 4) { - key_req->ab = key_req->priv_key + key_req->priv_key_len; -- copy_from_user(key_req->ab, cop->crk_param[3].crp_p, -+ rc = rc || copy_from_user(key_req->ab, cop->crk_param[3].crp_p, - key_req->ab_len); - } - -+ if (rc) -+ goto err; -+ - rc = cryptodev_pkc_offload(pkc); - if (pkc->type == SYNCHRONOUS) { -- if (rc) -- goto err; -- - if (cop->crk_iparams == 4) { -- copy_to_user(cop->crk_param[4].crp_p, key_req->pub_key, -- key_req->pub_key_len); -- copy_to_user(cop->crk_param[5].crp_p, key_req->priv_key, -+ rc = rc || -+ copy_to_user(cop->crk_param[4].crp_p, key_req->pub_key, -+ key_req->pub_key_len) || -+ copy_to_user(cop->crk_param[5].crp_p, key_req->priv_key, - key_req->priv_key_len); - } else { -- copy_to_user(cop->crk_param[3].crp_p, key_req->pub_key, -- key_req->pub_key_len); -- copy_to_user(cop->crk_param[4].crp_p, -- key_req->priv_key, key_req->priv_key_len); -+ rc = rc || -+ copy_to_user(cop->crk_param[3].crp_p, key_req->pub_key, -+ key_req->pub_key_len) || -+ copy_to_user(cop->crk_param[4].crp_p, key_req->priv_key, -+ key_req->priv_key_len); - } - } else { - if (rc != -EINPROGRESS && !rc) -@@ -495,7 +484,7 @@ int crypto_kop_dh_key(struct cryptodev_pkc *pkc) - struct dh_key_req_s *dh_req; - int buf_size; - uint8_t *buf; -- int rc = -EINVAL; -+ int rc = 0; - - dh_req = &pkc->req->req_u.dh_req; - dh_req->s_len = (cop->crk_param[0].crp_nbits + 7)/8; -@@ -520,22 +509,23 @@ int crypto_kop_dh_key(struct cryptodev_pkc *pkc) - if (cop->crk_iparams == 4) { - dh_req->ab = dh_req->z + dh_req->z_len; - pkc->req->curve_type = cop->curve_type; -- copy_from_user(dh_req->ab, cop->crk_param[3].crp_p, -- dh_req->ab_len); -+ rc = copy_from_user(dh_req->ab, cop->crk_param[3].crp_p, dh_req->ab_len); - } -- copy_from_user(dh_req->s, cop->crk_param[0].crp_p, dh_req->s_len); -- copy_from_user(dh_req->pub_key, cop->crk_param[1].crp_p, -- dh_req->pub_key_len); -- copy_from_user(dh_req->q, cop->crk_param[2].crp_p, dh_req->q_len); -+ -+ rc = rc || -+ copy_from_user(dh_req->s, cop->crk_param[0].crp_p, dh_req->s_len) || -+ copy_from_user(dh_req->pub_key, cop->crk_param[1].crp_p, dh_req->pub_key_len) || -+ copy_from_user(dh_req->q, cop->crk_param[2].crp_p, dh_req->q_len); -+ if (rc) -+ goto err; -+ - rc = cryptodev_pkc_offload(pkc); - if (pkc->type == SYNCHRONOUS) { -- if (rc) -- goto err; - if (cop->crk_iparams == 4) -- copy_to_user(cop->crk_param[4].crp_p, dh_req->z, -+ rc = rc || copy_to_user(cop->crk_param[4].crp_p, dh_req->z, - dh_req->z_len); - else -- copy_to_user(cop->crk_param[3].crp_p, dh_req->z, -+ rc = rc || copy_to_user(cop->crk_param[3].crp_p, dh_req->z, - dh_req->z_len); - } else { - if (rc != -EINPROGRESS && rc != 0) -@@ -582,19 +572,19 @@ int crypto_modexp_crt(struct cryptodev_pkc *pkc) - rsa_req->dq = rsa_req->dp + rsa_req->dp_len; - rsa_req->c = rsa_req->dq + rsa_req->dq_len; - rsa_req->f = rsa_req->c + rsa_req->c_len; -- copy_from_user(rsa_req->p, cop->crk_param[0].crp_p, rsa_req->p_len); -- copy_from_user(rsa_req->q, cop->crk_param[1].crp_p, rsa_req->q_len); -- copy_from_user(rsa_req->g, cop->crk_param[2].crp_p, rsa_req->g_len); -- copy_from_user(rsa_req->dp, cop->crk_param[3].crp_p, rsa_req->dp_len); -- copy_from_user(rsa_req->dq, cop->crk_param[4].crp_p, rsa_req->dq_len); -- copy_from_user(rsa_req->c, cop->crk_param[5].crp_p, rsa_req->c_len); -+ rc = copy_from_user(rsa_req->p, cop->crk_param[0].crp_p, rsa_req->p_len) || -+ copy_from_user(rsa_req->q, cop->crk_param[1].crp_p, rsa_req->q_len) || -+ copy_from_user(rsa_req->g, cop->crk_param[2].crp_p, rsa_req->g_len) || -+ copy_from_user(rsa_req->dp, cop->crk_param[3].crp_p, rsa_req->dp_len) || -+ copy_from_user(rsa_req->dq, cop->crk_param[4].crp_p, rsa_req->dq_len) || -+ copy_from_user(rsa_req->c, cop->crk_param[5].crp_p, rsa_req->c_len); -+ if (rc) -+ goto err; -+ - rc = cryptodev_pkc_offload(pkc); - - if (pkc->type == SYNCHRONOUS) { -- if (rc) -- goto err; -- copy_to_user(cop->crk_param[6].crp_p, rsa_req->f, -- rsa_req->f_len); -+ rc = rc || copy_to_user(cop->crk_param[6].crp_p, rsa_req->f, rsa_req->f_len); - } else { - if (rc != -EINPROGRESS && rc != 0) - goto err; -@@ -633,14 +623,15 @@ int crypto_bn_modexp(struct cryptodev_pkc *pkc) - rsa_req->f = rsa_req->e + rsa_req->e_len; - rsa_req->g = rsa_req->f + rsa_req->f_len; - rsa_req->n = rsa_req->g + rsa_req->g_len; -- copy_from_user(rsa_req->f, cop->crk_param[0].crp_p, rsa_req->f_len); -- copy_from_user(rsa_req->e, cop->crk_param[1].crp_p, rsa_req->e_len); -- copy_from_user(rsa_req->n, cop->crk_param[2].crp_p, rsa_req->n_len); -+ rc = copy_from_user(rsa_req->f, cop->crk_param[0].crp_p, rsa_req->f_len) || -+ copy_from_user(rsa_req->e, cop->crk_param[1].crp_p, rsa_req->e_len) || -+ copy_from_user(rsa_req->n, cop->crk_param[2].crp_p, rsa_req->n_len); -+ if (rc) -+ goto err; -+ - rc = cryptodev_pkc_offload(pkc); - if (pkc->type == SYNCHRONOUS) { -- if (rc) -- goto err; -- copy_to_user(cop->crk_param[3].crp_p, rsa_req->g, rsa_req->g_len); -+ rc = rc || copy_to_user(cop->crk_param[3].crp_p, rsa_req->g, rsa_req->g_len); - } else { - if (rc != -EINPROGRESS && rc != 0) - goto err; --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0022-fix-double-free-pkc-req-on-error.patch b/recipes-kernel/cryptodev/sdk_patches/0022-fix-double-free-pkc-req-on-error.patch deleted file mode 100644 index 7bc177e3..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0022-fix-double-free-pkc-req-on-error.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 85146b8429ba11bd0be68c24c17dd77b21ec8c25 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Mon, 12 Oct 2015 23:03:28 +0300 -Subject: [PATCH 22/38] fix double free pkc->req on error - -Signed-off-by: Cristian Stoica ---- - main.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/main.c b/main.c -index e5adb93..ec11129 100644 ---- a/main.c -+++ b/main.c -@@ -747,7 +747,7 @@ int crypto_run_asym(struct cryptodev_pkc *pkc) - /* todo - fix alloc-free on error path */ - pkc->req->type = pkc_req_type; - err = call_next_action(pkc); -- if (pkc->type == SYNCHRONOUS) -+ if (err == 0 && pkc->type == SYNCHRONOUS) - kfree(pkc->req); - - return err; --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0023-remove-MAY_BACKLOG-flag-from-requests.patch b/recipes-kernel/cryptodev/sdk_patches/0023-remove-MAY_BACKLOG-flag-from-requests.patch deleted file mode 100644 index 5674e035..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0023-remove-MAY_BACKLOG-flag-from-requests.patch +++ /dev/null @@ -1,69 +0,0 @@ -From 7d0d0deb255f8c59b0cf6d3944ee2e3be4133b4c Mon Sep 17 00:00:00 2001 -From: Alex Porosanu -Date: Mon, 19 Oct 2015 11:53:11 +0300 -Subject: [PATCH 23/38] remove MAY_BACKLOG flag from requests - -cryptodev doesn't implement the backlogging mechanism properly, -since it misses the possibility of sleeping and waiting for -wake-up when the crypto driver below starts working on the -submitted backloggable request. -In case the crypto driver below implements backlogging mechanisms, -this can lead to side-effects such as working on previously-free'ed -data. -This patch removes the MAY_BACKLOG flag from the requests. - -Change-Id: Ia3d822b1abfc1a51e2ce3e9682476b2c99d19c5a -Signed-off-by: Alex Porosanu ---- - cryptlib.c | 14 +++++--------- - 1 file changed, 5 insertions(+), 9 deletions(-) - -diff --git a/cryptlib.c b/cryptlib.c -index 10f5e1a..eba4616 100644 ---- a/cryptlib.c -+++ b/cryptlib.c -@@ -194,8 +194,7 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, - goto error; - } - -- ablkcipher_request_set_callback(out->async.request, -- CRYPTO_TFM_REQ_MAY_BACKLOG, -+ ablkcipher_request_set_callback(out->async.request, 0, - cryptodev_complete, out->async.result); - } else { - out->async.arequest = aead_request_alloc(out->async.as, GFP_KERNEL); -@@ -205,8 +204,7 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, - goto error; - } - -- aead_request_set_callback(out->async.arequest, -- CRYPTO_TFM_REQ_MAY_BACKLOG, -+ aead_request_set_callback(out->async.arequest, 0, - cryptodev_complete, out->async.result); - } - -@@ -362,9 +360,8 @@ int cryptodev_hash_init(struct hash_data *hdata, const char *alg_name, - goto error; - } - -- ahash_request_set_callback(hdata->async.request, -- CRYPTO_TFM_REQ_MAY_BACKLOG, -- cryptodev_complete, hdata->async.result); -+ ahash_request_set_callback(hdata->async.request, 0, -+ cryptodev_complete, hdata->async.result); - - ret = crypto_ahash_init(hdata->async.request); - if (unlikely(ret)) { -@@ -439,8 +436,7 @@ int cryptodev_pkc_offload(struct cryptodev_pkc *pkc) - int ret; - - init_completion(&pkc->result.completion); -- pkc_request_set_callback(pkc->req, CRYPTO_TFM_REQ_MAY_BACKLOG, -- cryptodev_complete_asym, pkc); -+ pkc_request_set_callback(pkc->req, 0, cryptodev_complete_asym, pkc); - ret = crypto_pkc_op(pkc->req); - if (ret != -EINPROGRESS && ret != 0) - goto error; --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0024-fix-COMPAT_CIOCKEY-ioctl-command-number.patch b/recipes-kernel/cryptodev/sdk_patches/0024-fix-COMPAT_CIOCKEY-ioctl-command-number.patch deleted file mode 100644 index 72770863..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0024-fix-COMPAT_CIOCKEY-ioctl-command-number.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 53e4d0fe4a334dae3df32b2053e4ebdfda2e9148 Mon Sep 17 00:00:00 2001 -From: Tudor Ambarus -Date: Tue, 27 Oct 2015 15:51:02 +0200 -Subject: [PATCH 24/38] fix COMPAT_CIOCKEY ioctl command number - -CIOCKEY and COMPAT_CIOCKEY had different command numbers, -so that 32-bit applications got EINVAL error on 64-bit kernel. - -Signed-off-by: Tudor Ambarus ---- - cryptodev_int.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/cryptodev_int.h b/cryptodev_int.h -index c83c885..cb005d7 100644 ---- a/cryptodev_int.h -+++ b/cryptodev_int.h -@@ -132,7 +132,7 @@ struct compat_crypt_auth_op { - /* compat ioctls, defined for the above structs */ - #define COMPAT_CIOCGSESSION _IOWR('c', 102, struct compat_session_op) - #define COMPAT_CIOCCRYPT _IOWR('c', 104, struct compat_crypt_op) --#define COMPAT_CIOCKEY _IOW('c', 105, struct compat_crypt_kop) -+#define COMPAT_CIOCKEY _IOWR('c', 105, struct compat_crypt_kop) - #define COMPAT_CIOCASYNCCRYPT _IOW('c', 107, struct compat_crypt_op) - #define COMPAT_CIOCASYNCFETCH _IOR('c', 108, struct compat_crypt_op) - #define COMPAT_CIOCAUTHCRYPT _IOWR('c', 109, struct compat_crypt_auth_op) --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0025-fix-benchmarks-linking.patch b/recipes-kernel/cryptodev/sdk_patches/0025-fix-benchmarks-linking.patch deleted file mode 100644 index 608c6812..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0025-fix-benchmarks-linking.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 978cfcf9253c409520c0f168f8caa249f50a8843 Mon Sep 17 00:00:00 2001 -From: Fridolin Pokorny -Date: Fri, 8 Jan 2016 09:38:29 +0100 -Subject: [PATCH 25/38] fix benchmarks linking - ---- - lib/Makefile | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/lib/Makefile b/lib/Makefile -index af87795..3bedc34 100644 ---- a/lib/Makefile -+++ b/lib/Makefile -@@ -3,7 +3,7 @@ CFLAGS=-g -O2 -Wall - all: benchmark - - benchmark: main.c libthreshold.a -- gcc $(CFLAGS) -DDEBUG -o $@ $^ -lssl libthreshold.a -+ gcc $(CFLAGS) -DDEBUG -o $@ $^ -lssl -lcrypto libthreshold.a - - .o: - gcc $(CCFLAGS) -c $< -o $@ --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0026-fix-Makefile-to-allow-parallel-make-with-j-option.patch b/recipes-kernel/cryptodev/sdk_patches/0026-fix-Makefile-to-allow-parallel-make-with-j-option.patch deleted file mode 100644 index b8cf4e19..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0026-fix-Makefile-to-allow-parallel-make-with-j-option.patch +++ /dev/null @@ -1,56 +0,0 @@ -From d96ae48c87f80af1a202c2d2e837bf477edc0fb7 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Thu, 10 Dec 2015 12:42:18 +0200 -Subject: [PATCH 26/38] fix Makefile to allow parallel make with -j option -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Recursive make commands should always use the variable MAKE, not the -explicit command name ‘make’ - -Documented in section "5.7.1 How the MAKE Variable Works" of GNU Make manual - -Signed-off-by: Cristian Stoica ---- - Makefile | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - -diff --git a/Makefile b/Makefile -index 9e56e9d..2f50210 100644 ---- a/Makefile -+++ b/Makefile -@@ -22,7 +22,7 @@ KERNEL_MAKE_OPTS += CROSS_COMPILE=${CROSS_COMPILE} - endif - - build: version.h -- make ${KERNEL_MAKE_OPTS} modules -+ $(MAKE) $(KERNEL_MAKE_OPTS) modules - - version.h: Makefile - @echo "#define VERSION \"$(VERSION)\"" > version.h -@@ -30,17 +30,17 @@ version.h: Makefile - install: modules_install - - modules_install: -- make -C $(KERNEL_DIR) SUBDIRS=`pwd` modules_install -+ $(MAKE) -C $(KERNEL_DIR) SUBDIRS=`pwd` modules_install - @echo "Installing cryptodev.h in $(PREFIX)/usr/include/crypto ..." - @install -D crypto/cryptodev.h $(PREFIX)/usr/include/crypto/cryptodev.h - - clean: -- make -C $(KERNEL_DIR) SUBDIRS=`pwd` clean -+ $(MAKE) -C $(KERNEL_DIR) SUBDIRS=`pwd` clean - rm -f $(hostprogs) *~ -- CFLAGS=$(CRYPTODEV_CFLAGS) KERNEL_DIR=$(KERNEL_DIR) make -C tests clean -+ CFLAGS=$(CRYPTODEV_CFLAGS) KERNEL_DIR=$(KERNEL_DIR) $(MAKE) -C tests clean - - check: -- CFLAGS=$(CRYPTODEV_CFLAGS) KERNEL_DIR=$(KERNEL_DIR) make -C tests check -+ CFLAGS=$(CRYPTODEV_CFLAGS) KERNEL_DIR=$(KERNEL_DIR) $(MAKE) -C tests check - - CPOPTS = - ifneq (${SHOW_TYPES},) --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0027-use-Linux-kernel-conventions-for-Makefile-variables.patch b/recipes-kernel/cryptodev/sdk_patches/0027-use-Linux-kernel-conventions-for-Makefile-variables.patch deleted file mode 100644 index ad18da81..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0027-use-Linux-kernel-conventions-for-Makefile-variables.patch +++ /dev/null @@ -1,47 +0,0 @@ -From e51bf208fbd3796238ff4d721e8d070f711f8c56 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Thu, 10 Dec 2015 12:42:19 +0200 -Subject: [PATCH 27/38] use Linux kernel conventions for Makefile variables - -The kernel Makefile specifies to use M=... instead of SUBDIR=... for -external modules. - -PWD variable is already set in a POSIX system and calling `pwd` to find -it is redundant. - -Signed-off-by: Cristian Stoica ---- - Makefile | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/Makefile b/Makefile -index 2f50210..7c7e193 100644 ---- a/Makefile -+++ b/Makefile -@@ -13,7 +13,7 @@ cryptodev-objs = ioctl.o main.o cryptlib.o authenc.o zc.o util.o - - obj-m += cryptodev.o - --KERNEL_MAKE_OPTS := -C ${KERNEL_DIR} SUBDIRS=`pwd` -+KERNEL_MAKE_OPTS := -C $(KERNEL_DIR) M=$(PWD) - ifneq (${ARCH},) - KERNEL_MAKE_OPTS += ARCH=${ARCH} - endif -@@ -30,12 +30,12 @@ version.h: Makefile - install: modules_install - - modules_install: -- $(MAKE) -C $(KERNEL_DIR) SUBDIRS=`pwd` modules_install -+ $(MAKE) -C $(KERNEL_DIR) M=$(PWD) modules_install - @echo "Installing cryptodev.h in $(PREFIX)/usr/include/crypto ..." - @install -D crypto/cryptodev.h $(PREFIX)/usr/include/crypto/cryptodev.h - - clean: -- $(MAKE) -C $(KERNEL_DIR) SUBDIRS=`pwd` clean -+ $(MAKE) -C $(KERNEL_DIR) M=$(PWD) clean - rm -f $(hostprogs) *~ - CFLAGS=$(CRYPTODEV_CFLAGS) KERNEL_DIR=$(KERNEL_DIR) $(MAKE) -C tests clean - --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0028-for-consistency-use-.-instead-of-.-in-makefiles.patch b/recipes-kernel/cryptodev/sdk_patches/0028-for-consistency-use-.-instead-of-.-in-makefiles.patch deleted file mode 100644 index 756ca33f..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0028-for-consistency-use-.-instead-of-.-in-makefiles.patch +++ /dev/null @@ -1,73 +0,0 @@ -From 22b63631de17507c12355c30e408dbd88350bb3a Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Thu, 10 Dec 2015 12:42:20 +0200 -Subject: [PATCH 28/38] for consistency, use $(...) instead of ${...} in - makefiles - -Both syntax rules are equaly valid and mixing them is permitted but -looks inconsistent. - -See section "6.1 Basics of Variable References" of GNU make manual - -Signed-off-by: Cristian Stoica ---- - Makefile | 16 ++++++++-------- - tests/Makefile | 2 +- - 2 files changed, 9 insertions(+), 9 deletions(-) - -diff --git a/Makefile b/Makefile -index 7c7e193..7f8df37 100644 ---- a/Makefile -+++ b/Makefile -@@ -14,11 +14,11 @@ cryptodev-objs = ioctl.o main.o cryptlib.o authenc.o zc.o util.o - obj-m += cryptodev.o - - KERNEL_MAKE_OPTS := -C $(KERNEL_DIR) M=$(PWD) --ifneq (${ARCH},) --KERNEL_MAKE_OPTS += ARCH=${ARCH} -+ifneq ($(ARCH),) -+KERNEL_MAKE_OPTS += ARCH=$(ARCH) - endif --ifneq (${CROSS_COMPILE},) --KERNEL_MAKE_OPTS += CROSS_COMPILE=${CROSS_COMPILE} -+ifneq ($(CROSS_COMPILE),) -+KERNEL_MAKE_OPTS += CROSS_COMPILE=$(CROSS_COMPILE) - endif - - build: version.h -@@ -43,15 +43,15 @@ check: - CFLAGS=$(CRYPTODEV_CFLAGS) KERNEL_DIR=$(KERNEL_DIR) $(MAKE) -C tests check - - CPOPTS = --ifneq (${SHOW_TYPES},) -+ifneq ($(SHOW_TYPES),) - CPOPTS += --show-types - endif --ifneq (${IGNORE_TYPES},) --CPOPTS += --ignore ${IGNORE_TYPES} -+ifneq ($(IGNORE_TYPES),) -+CPOPTS += --ignore $(IGNORE_TYPES) - endif - - checkpatch: -- $(KERNEL_DIR)/scripts/checkpatch.pl ${CPOPTS} --file *.c *.h -+ $(KERNEL_DIR)/scripts/checkpatch.pl $(CPOPTS) --file *.c *.h - - VERSIONTAG = refs/tags/cryptodev-linux-$(VERSION) - FILEBASE = cryptodev-linux-$(VERSION) -diff --git a/tests/Makefile b/tests/Makefile -index 20c52ba..3155da9 100644 ---- a/tests/Makefile -+++ b/tests/Makefile -@@ -6,7 +6,7 @@ comp_progs := cipher_comp hash_comp hmac_comp - - hostprogs := cipher cipher-aead hmac speed async_cipher async_hmac \ - async_speed sha_speed hashcrypt_speed fullspeed cipher-gcm \ -- cipher-aead-srtp ${comp_progs} -+ cipher-aead-srtp $(comp_progs) - - example-cipher-objs := cipher.o - example-cipher-aead-objs := cipher-aead.o --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0029-fix-clean-up-on-error-path-for-crypto_create_session.patch b/recipes-kernel/cryptodev/sdk_patches/0029-fix-clean-up-on-error-path-for-crypto_create_session.patch deleted file mode 100644 index 67e4a89d..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0029-fix-clean-up-on-error-path-for-crypto_create_session.patch +++ /dev/null @@ -1,117 +0,0 @@ -From 294abaaa4540ec340ed6046a784c9789c8724420 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Mon, 11 Jan 2016 17:45:50 +0200 -Subject: [PATCH 29/38] fix clean-up on error path for crypto_create_session - -This patch fixes clean-up on error path for failed allocations of -ses_new->pages or ses_new->sg. In these cases, allocations made in -cryptodev_hash_init have not been undone resulting in possible memory -leaks. - -We take advantage of the initializations with zeros of the session -structure to trim the code to a single clean-up path. - -Signed-off-by: Cristian Stoica ---- - ioctl.c | 28 +++++++++++++++------------- - 1 file changed, 15 insertions(+), 13 deletions(-) - -diff --git a/ioctl.c b/ioctl.c -index b23f5fd..c781f9d 100644 ---- a/ioctl.c -+++ b/ioctl.c -@@ -228,7 +228,8 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) - return -EINVAL; - } - -- /* Create a session and put it to the list. */ -+ /* Create a session and put it to the list. Zeroing the structure helps -+ * also with a single exit point in case of errors */ - ses_new = kzalloc(sizeof(*ses_new), GFP_KERNEL); - if (!ses_new) - return -ENOMEM; -@@ -240,19 +241,19 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) - if (unlikely(ret < 0)) { - ddebug(1, "Setting key failed for %s-%zu.", - alg_name, (size_t)sop->keylen*8); -- goto error_cipher; -+ goto session_error; - } - - ret = cryptodev_get_cipher_key(keys.ckey, sop, aead); - if (unlikely(ret < 0)) -- goto error_cipher; -+ goto session_error; - - ret = cryptodev_cipher_init(&ses_new->cdata, alg_name, keys.ckey, - keylen, stream, aead); - if (ret < 0) { - ddebug(1, "Failed to load cipher for %s", alg_name); - ret = -EINVAL; -- goto error_cipher; -+ goto session_error; - } - } - -@@ -261,13 +262,13 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) - ddebug(1, "Setting key failed for %s-%zu.", - hash_name, (size_t)sop->mackeylen*8); - ret = -EINVAL; -- goto error_hash; -+ goto session_error; - } - - if (sop->mackey && unlikely(copy_from_user(keys.mkey, sop->mackey, - sop->mackeylen))) { - ret = -EFAULT; -- goto error_hash; -+ goto session_error; - } - - ret = cryptodev_hash_init(&ses_new->hdata, hash_name, hmac_mode, -@@ -275,7 +276,7 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) - if (ret != 0) { - ddebug(1, "Failed to load hash for %s", hash_name); - ret = -EINVAL; -- goto error_hash; -+ goto session_error; - } - } - -@@ -292,7 +293,7 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) - if (ses_new->sg == NULL || ses_new->pages == NULL) { - ddebug(0, "Memory error"); - ret = -ENOMEM; -- goto error_hash; -+ goto session_error; - } - - /* put the new session to the list */ -@@ -316,18 +317,19 @@ restart: - - /* Fill in some values for the user. */ - sop->ses = ses_new->sid; -- - return 0; - --error_hash: -+ /* We count on ses_new to be initialized with zeroes -+ * Since hdata and cdata are embedded within ses_new, it follows that -+ * hdata->init and cdata->init are either zero or one as they have been -+ * initialized or not */ -+session_error: -+ cryptodev_hash_deinit(&ses_new->hdata); - cryptodev_cipher_deinit(&ses_new->cdata); - kfree(ses_new->sg); - kfree(ses_new->pages); --error_cipher: - kfree(ses_new); -- - return ret; -- - } - - /* Everything that needs to be done when remowing a session. */ --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0030-remove-code-duplication-in-cryptodev_hash_init.patch b/recipes-kernel/cryptodev/sdk_patches/0030-remove-code-duplication-in-cryptodev_hash_init.patch deleted file mode 100644 index 1e3ebf34..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0030-remove-code-duplication-in-cryptodev_hash_init.patch +++ /dev/null @@ -1,59 +0,0 @@ -From f4534df637b078fce275763bd8bc2a83bfad25e0 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Mon, 11 Jan 2016 18:01:06 +0200 -Subject: [PATCH 30/38] remove code duplication in cryptodev_hash_init - -cryptodev_hash_init is concerned mostly with allocating data structures -for hash operations. -This patch replaces the call it makes to crypto_ahash_init with -one to cryptodev_hash_reset to avoid code duplication. This call is made -now outside of the original function to increase modularity. - -Signed-off-by: Cristian Stoica ---- - cryptlib.c | 9 --------- - ioctl.c | 5 +++++ - 2 files changed, 5 insertions(+), 9 deletions(-) - -diff --git a/cryptlib.c b/cryptlib.c -index eba4616..4fd29eb 100644 ---- a/cryptlib.c -+++ b/cryptlib.c -@@ -362,18 +362,9 @@ int cryptodev_hash_init(struct hash_data *hdata, const char *alg_name, - - ahash_request_set_callback(hdata->async.request, 0, - cryptodev_complete, hdata->async.result); -- -- ret = crypto_ahash_init(hdata->async.request); -- if (unlikely(ret)) { -- derr(0, "error in crypto_hash_init()"); -- goto error_request; -- } -- - hdata->init = 1; - return 0; - --error_request: -- ahash_request_free(hdata->async.request); - error: - kfree(hdata->async.result); - crypto_free_ahash(hdata->async.s); -diff --git a/ioctl.c b/ioctl.c -index b36dd03..a537886 100644 ---- a/ioctl.c -+++ b/ioctl.c -@@ -338,6 +338,11 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) - ret = -EINVAL; - goto session_error; - } -+ -+ ret = cryptodev_hash_reset(&ses_new->hdata); -+ if (ret != 0) { -+ goto session_error; -+ } - } - - ses_new->alignmask = max(ses_new->cdata.alignmask, --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0031-fix-comment-typo.patch b/recipes-kernel/cryptodev/sdk_patches/0031-fix-comment-typo.patch deleted file mode 100644 index cde95524..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0031-fix-comment-typo.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 73a2489ba634503a0cc2bb6e84627ceeda0f059f Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Tue, 12 Jan 2016 17:15:56 +0200 -Subject: [PATCH 31/38] fix comment typo - -Signed-off-by: Cristian Stoica ---- - ioctl.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/ioctl.c b/ioctl.c -index a537886..7adde75 100644 ---- a/ioctl.c -+++ b/ioctl.c -@@ -397,7 +397,7 @@ session_error: - return ret; - } - --/* Everything that needs to be done when remowing a session. */ -+/* Everything that needs to be done when removing a session. */ - static inline void - crypto_destroy_session(struct csession *ses_ptr) - { --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0032-avoid-calls-to-kmalloc-on-hotpaths.patch b/recipes-kernel/cryptodev/sdk_patches/0032-avoid-calls-to-kmalloc-on-hotpaths.patch deleted file mode 100644 index 2aa5810b..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0032-avoid-calls-to-kmalloc-on-hotpaths.patch +++ /dev/null @@ -1,220 +0,0 @@ -From 9b513838035c35fd3706bb824edd17d705641439 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Tue, 12 Jan 2016 15:13:15 +0200 -Subject: [PATCH 32/38] avoid calls to kmalloc on hotpaths - -We replace a pointer to a small structure with the structure itself to -avoid unnecessary dynamic allocations at runtime. The embedding -structure is itself dynamically allocated and we get a slight increase -in performance from elimination of unnecessary code. - -Signed-off-by: Cristian Stoica ---- - cryptlib.c | 42 +++++++++++++----------------------------- - cryptlib.h | 14 +++++++------- - 2 files changed, 20 insertions(+), 36 deletions(-) - -diff --git a/cryptlib.c b/cryptlib.c -index 4fd29eb..5972fc2 100644 ---- a/cryptlib.c -+++ b/cryptlib.c -@@ -178,13 +178,7 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, - out->stream = stream; - out->aead = aead; - -- out->async.result = kzalloc(sizeof(*out->async.result), GFP_KERNEL); -- if (unlikely(!out->async.result)) { -- ret = -ENOMEM; -- goto error; -- } -- -- init_completion(&out->async.result->completion); -+ init_completion(&out->async.result.completion); - - if (aead == 0) { - out->async.request = ablkcipher_request_alloc(out->async.s, GFP_KERNEL); -@@ -195,7 +189,7 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, - } - - ablkcipher_request_set_callback(out->async.request, 0, -- cryptodev_complete, out->async.result); -+ cryptodev_complete, &out->async.result); - } else { - out->async.arequest = aead_request_alloc(out->async.as, GFP_KERNEL); - if (unlikely(!out->async.arequest)) { -@@ -205,7 +199,7 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, - } - - aead_request_set_callback(out->async.arequest, 0, -- cryptodev_complete, out->async.result); -+ cryptodev_complete, &out->async.result); - } - - out->init = 1; -@@ -222,7 +216,6 @@ error: - if (out->async.as) - crypto_free_aead(out->async.as); - } -- kfree(out->async.result); - - return ret; - } -@@ -242,7 +235,6 @@ void cryptodev_cipher_deinit(struct cipher_data *cdata) - crypto_free_aead(cdata->async.as); - } - -- kfree(cdata->async.result); - cdata->init = 0; - } - } -@@ -279,7 +271,7 @@ ssize_t cryptodev_cipher_encrypt(struct cipher_data *cdata, - { - int ret; - -- reinit_completion(&cdata->async.result->completion); -+ reinit_completion(&cdata->async.result.completion); - - if (cdata->aead == 0) { - ablkcipher_request_set_crypt(cdata->async.request, -@@ -293,7 +285,7 @@ ssize_t cryptodev_cipher_encrypt(struct cipher_data *cdata, - ret = crypto_aead_encrypt(cdata->async.arequest); - } - -- return waitfor(cdata->async.result, ret); -+ return waitfor(&cdata->async.result, ret); - } - - ssize_t cryptodev_cipher_decrypt(struct cipher_data *cdata, -@@ -302,7 +294,7 @@ ssize_t cryptodev_cipher_decrypt(struct cipher_data *cdata, - { - int ret; - -- reinit_completion(&cdata->async.result->completion); -+ reinit_completion(&cdata->async.result.completion); - if (cdata->aead == 0) { - ablkcipher_request_set_crypt(cdata->async.request, - (struct scatterlist *)src, dst, -@@ -315,7 +307,7 @@ ssize_t cryptodev_cipher_decrypt(struct cipher_data *cdata, - ret = crypto_aead_decrypt(cdata->async.arequest); - } - -- return waitfor(cdata->async.result, ret); -+ return waitfor(&cdata->async.result, ret); - } - - /* Hash functions */ -@@ -345,13 +337,7 @@ int cryptodev_hash_init(struct hash_data *hdata, const char *alg_name, - hdata->digestsize = crypto_ahash_digestsize(hdata->async.s); - hdata->alignmask = crypto_ahash_alignmask(hdata->async.s); - -- hdata->async.result = kzalloc(sizeof(*hdata->async.result), GFP_KERNEL); -- if (unlikely(!hdata->async.result)) { -- ret = -ENOMEM; -- goto error; -- } -- -- init_completion(&hdata->async.result->completion); -+ init_completion(&hdata->async.result.completion); - - hdata->async.request = ahash_request_alloc(hdata->async.s, GFP_KERNEL); - if (unlikely(!hdata->async.request)) { -@@ -361,12 +347,11 @@ int cryptodev_hash_init(struct hash_data *hdata, const char *alg_name, - } - - ahash_request_set_callback(hdata->async.request, 0, -- cryptodev_complete, hdata->async.result); -+ cryptodev_complete, &hdata->async.result); - hdata->init = 1; - return 0; - - error: -- kfree(hdata->async.result); - crypto_free_ahash(hdata->async.s); - return ret; - } -@@ -376,7 +361,6 @@ void cryptodev_hash_deinit(struct hash_data *hdata) - if (hdata->init) { - if (hdata->async.request) - ahash_request_free(hdata->async.request); -- kfree(hdata->async.result); - if (hdata->async.s) - crypto_free_ahash(hdata->async.s); - hdata->init = 0; -@@ -402,24 +386,24 @@ ssize_t cryptodev_hash_update(struct hash_data *hdata, - { - int ret; - -- reinit_completion(&hdata->async.result->completion); -+ reinit_completion(&hdata->async.result.completion); - ahash_request_set_crypt(hdata->async.request, sg, NULL, len); - - ret = crypto_ahash_update(hdata->async.request); - -- return waitfor(hdata->async.result, ret); -+ return waitfor(&hdata->async.result, ret); - } - - int cryptodev_hash_final(struct hash_data *hdata, void *output) - { - int ret; - -- reinit_completion(&hdata->async.result->completion); -+ reinit_completion(&hdata->async.result.completion); - ahash_request_set_crypt(hdata->async.request, NULL, output, 0); - - ret = crypto_ahash_final(hdata->async.request); - -- return waitfor(hdata->async.result, ret); -+ return waitfor(&hdata->async.result, ret); - } - - int cryptodev_pkc_offload(struct cryptodev_pkc *pkc) -diff --git a/cryptlib.h b/cryptlib.h -index e1c4e3e..d8e8046 100644 ---- a/cryptlib.h -+++ b/cryptlib.h -@@ -6,6 +6,11 @@ - - #include - -+struct cryptodev_result { -+ struct completion completion; -+ int err; -+}; -+ - struct cipher_data { - int init; /* 0 uninitialized */ - int blocksize; -@@ -22,7 +27,7 @@ struct cipher_data { - struct crypto_aead *as; - struct aead_request *arequest; - -- struct cryptodev_result *result; -+ struct cryptodev_result result; - uint8_t iv[EALG_MAX_BLOCK_LEN]; - } async; - }; -@@ -85,7 +90,7 @@ struct hash_data { - int alignmask; - struct { - struct crypto_ahash *s; -- struct cryptodev_result *result; -+ struct cryptodev_result result; - struct ahash_request *request; - } async; - }; -@@ -104,11 +109,6 @@ enum offload_type { - ASYNCHRONOUS - }; - --struct cryptodev_result { -- struct completion completion; -- int err; --}; -- - struct cryptodev_pkc { - struct list_head list; /* To maintain the Jobs in completed - cryptodev lists */ --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0033-avoid-unnecessary-checks-for-hash-clean-up.patch b/recipes-kernel/cryptodev/sdk_patches/0033-avoid-unnecessary-checks-for-hash-clean-up.patch deleted file mode 100644 index 3ce8a5ff..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0033-avoid-unnecessary-checks-for-hash-clean-up.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 774c6bd169b683ed54ebad164d0ff541e1381a64 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Tue, 12 Jan 2016 17:09:33 +0200 -Subject: [PATCH 33/38] avoid unnecessary checks for hash clean-up - -hdata->init is set only after all necessary allocations succeed. On -clean-up is no longer necessary to make the allocation checks. - -Signed-off-by: Cristian Stoica ---- - cryptlib.c | 6 ++---- - 1 file changed, 2 insertions(+), 4 deletions(-) - -diff --git a/cryptlib.c b/cryptlib.c -index 5972fc2..5d1a5a9 100644 ---- a/cryptlib.c -+++ b/cryptlib.c -@@ -359,10 +359,8 @@ error: - void cryptodev_hash_deinit(struct hash_data *hdata) - { - if (hdata->init) { -- if (hdata->async.request) -- ahash_request_free(hdata->async.request); -- if (hdata->async.s) -- crypto_free_ahash(hdata->async.s); -+ ahash_request_free(hdata->async.request); -+ crypto_free_ahash(hdata->async.s); - hdata->init = 0; - } - } --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0034-extend-API-with-CIOCHASH-to-support-direct-hash-oper.patch b/recipes-kernel/cryptodev/sdk_patches/0034-extend-API-with-CIOCHASH-to-support-direct-hash-oper.patch deleted file mode 100644 index 3a1f0c05..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0034-extend-API-with-CIOCHASH-to-support-direct-hash-oper.patch +++ /dev/null @@ -1,114 +0,0 @@ -From c43fa74b9ed11f0183d25b21486b71fe02d84de7 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Tue, 15 Dec 2015 15:31:47 +0200 -Subject: [PATCH 34/38] extend API with CIOCHASH to support direct hash - operations - -Signed-off-by: Cristian Stoica ---- - crypto/cryptodev.h | 16 ++++++++++++++++ - ioctl.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 65 insertions(+) - -diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h -index f6058ca..c6083f7 100644 ---- a/crypto/cryptodev.h -+++ b/crypto/cryptodev.h -@@ -167,6 +167,19 @@ struct crypt_auth_op { - __u32 iv_len; - }; - -+/* data container for CIOCHASH operations */ -+struct hash_op_data { -+ __u32 ses; /* session identifier */ -+ __u32 mac_op; /* cryptodev_crypto_op_t */ -+ __u8 *mackey; -+ __u32 mackeylen; -+ -+ __u16 flags; /* see COP_FLAG_* */ -+ __u32 len; /* length of source data */ -+ __u8 *src; /* source data */ -+ __u8 *mac_result; -+}; -+ - /* In plain AEAD mode the following are required: - * flags : 0 - * iv : the initialization vector (12 bytes) -@@ -325,4 +338,7 @@ enum cryptodev_crk_op_t { - /* additional ioctls for asynchronous operation for asymmetric ciphers*/ - #define CIOCASYMASYNCRYPT _IOW('c', 112, struct crypt_kop) - #define CIOCASYMFETCHCOOKIE _IOR('c', 113, struct pkc_cookie_list_s) -+ -+#define CIOCHASH _IOWR('c', 114, struct hash_op_data) -+ - #endif /* L_CRYPTODEV_H */ -diff --git a/ioctl.c b/ioctl.c -index 7adde75..3763954 100644 ---- a/ioctl.c -+++ b/ioctl.c -@@ -960,6 +960,7 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) - void __user *arg = (void __user *)arg_; - int __user *p = arg; - struct session_op sop; -+ struct hash_op_data hash_op; - struct kernel_crypt_op kcop; - struct kernel_crypt_auth_op kcaop; - struct crypt_priv *pcr = filp->private_data; -@@ -1049,6 +1050,54 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) - } - - return kcop_to_user(&kcop, fcr, arg); -+ case CIOCHASH: -+ /* get session */ -+ if (unlikely(copy_from_user(&hash_op, arg, sizeof(struct hash_op_data)))) { -+ pr_err("copy from user fault\n"); -+ return -EFAULT; -+ } -+ -+ sop.cipher = 0; -+ sop.mac = hash_op.mac_op; -+ sop.mackey = hash_op.mackey; -+ sop.mackeylen = hash_op.mackeylen; -+ -+ /* writes sop.ses as a side-effect */ -+ ret = crypto_create_session(fcr, &sop); -+ if (unlikely(ret)) { -+ pr_err("can't get session\n"); -+ return ret; -+ } -+ -+ /* do hashing */ -+ kcop.cop.ses = sop.ses; -+ kcop.cop.flags = hash_op.flags; -+ kcop.cop.len = hash_op.len; -+ kcop.cop.src = hash_op.src; -+ kcop.cop.mac = hash_op.mac_result; -+ kcop.cop.dst = 0; -+ kcop.cop.op = 0; -+ kcop.cop.iv = 0; -+ kcop.ivlen = 0; -+ kcop.digestsize = 0; /* will be updated during operation */ -+ kcop.task = current; -+ kcop.mm = current->mm; -+ -+ ret = crypto_run(fcr, &kcop); -+ if (unlikely(ret)) { -+ dwarning(1, "Error in hash run"); -+ return ret; -+ } -+ -+ ret = copy_to_user(kcop.cop.mac, kcop.hash_output, kcop.digestsize); -+ if (unlikely(ret)) { -+ dwarning(1, "Error in copy to user"); -+ return ret; -+ } -+ -+ /* put session */ -+ ret = crypto_finish_session(fcr, sop.ses); -+ return 0; - case CIOCAUTHCRYPT: - if (unlikely(ret = kcaop_from_user(&kcaop, fcr, arg))) { - dwarning(1, "Error copying from user"); --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0035-use-directly-crypto-API-digest-operation-for-CIOCHAS.patch b/recipes-kernel/cryptodev/sdk_patches/0035-use-directly-crypto-API-digest-operation-for-CIOCHAS.patch deleted file mode 100644 index 4745dc90..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0035-use-directly-crypto-API-digest-operation-for-CIOCHAS.patch +++ /dev/null @@ -1,315 +0,0 @@ -From f123f38532ae022e818312a9bc04cdb287e9623f Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Thu, 17 Dec 2015 10:34:20 +0200 -Subject: [PATCH 35/38] use directly crypto API 'digest' operation for CIOCHASH - -Signed-off-by: Cristian Stoica ---- - crypto/cryptodev.h | 2 +- - cryptodev_int.h | 10 ++++ - ioctl.c | 158 ++++++++++++++++++++++++++++++++++++++++++++--------- - main.c | 39 ++++++++++++- - 4 files changed, 179 insertions(+), 30 deletions(-) - -diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h -index c6083f7..9ade102 100644 ---- a/crypto/cryptodev.h -+++ b/crypto/cryptodev.h -@@ -169,7 +169,7 @@ struct crypt_auth_op { - - /* data container for CIOCHASH operations */ - struct hash_op_data { -- __u32 ses; /* session identifier */ -+ struct csession *ses; /* session identifier */ - __u32 mac_op; /* cryptodev_crypto_op_t */ - __u8 *mackey; - __u32 mackeylen; -diff --git a/cryptodev_int.h b/cryptodev_int.h -index cb005d7..74c295a 100644 ---- a/cryptodev_int.h -+++ b/cryptodev_int.h -@@ -164,6 +164,15 @@ struct kernel_crypt_op { - struct mm_struct *mm; - }; - -+struct kernel_hash_op { -+ struct hash_op_data hash_op; -+ -+ int digestsize; -+ uint8_t hash_output[AALG_MAX_RESULT_LEN]; -+ struct task_struct *task; -+ struct mm_struct *mm; -+}; -+ - struct kernel_crypt_auth_op { - struct crypt_auth_op caop; - -@@ -192,6 +201,7 @@ int kcaop_to_user(struct kernel_crypt_auth_op *kcaop, - struct fcrypt *fcr, void __user *arg); - int crypto_auth_run(struct fcrypt *fcr, struct kernel_crypt_auth_op *kcaop); - int crypto_run(struct fcrypt *fcr, struct kernel_crypt_op *kcop); -+int hash_run(struct kernel_hash_op *khop); - - #include - -diff --git a/ioctl.c b/ioctl.c -index 3763954..a052614 100644 ---- a/ioctl.c -+++ b/ioctl.c -@@ -397,7 +397,128 @@ session_error: - return ret; - } - --/* Everything that needs to be done when removing a session. */ -+static inline void hash_destroy_session(struct csession *ses_ptr) -+{ -+ cryptodev_hash_deinit(&ses_ptr->hdata); -+ kfree(ses_ptr->pages); -+ kfree(ses_ptr->sg); -+ kfree(ses_ptr); -+} -+ -+static int hash_create_session(struct hash_op_data *hash_op) -+{ -+ struct csession *ses; -+ int ret = 0; -+ const char *hash_name; -+ int hmac_mode = 1; -+ uint8_t mkey[CRYPTO_HMAC_MAX_KEY_LEN]; -+ -+ switch (hash_op->mac_op) { -+ case CRYPTO_MD5_HMAC: -+ hash_name = "hmac(md5)"; -+ break; -+ case CRYPTO_RIPEMD160_HMAC: -+ hash_name = "hmac(rmd160)"; -+ break; -+ case CRYPTO_SHA1_HMAC: -+ hash_name = "hmac(sha1)"; -+ break; -+ case CRYPTO_SHA2_224_HMAC: -+ hash_name = "hmac(sha224)"; -+ break; -+ case CRYPTO_SHA2_256_HMAC: -+ hash_name = "hmac(sha256)"; -+ break; -+ case CRYPTO_SHA2_384_HMAC: -+ hash_name = "hmac(sha384)"; -+ break; -+ case CRYPTO_SHA2_512_HMAC: -+ hash_name = "hmac(sha512)"; -+ break; -+ /* non-hmac cases */ -+ case CRYPTO_MD5: -+ hash_name = "md5"; -+ hmac_mode = 0; -+ break; -+ case CRYPTO_RIPEMD160: -+ hash_name = "rmd160"; -+ hmac_mode = 0; -+ break; -+ case CRYPTO_SHA1: -+ hash_name = "sha1"; -+ hmac_mode = 0; -+ break; -+ case CRYPTO_SHA2_224: -+ hash_name = "sha224"; -+ hmac_mode = 0; -+ break; -+ case CRYPTO_SHA2_256: -+ hash_name = "sha256"; -+ hmac_mode = 0; -+ break; -+ case CRYPTO_SHA2_384: -+ hash_name = "sha384"; -+ hmac_mode = 0; -+ break; -+ case CRYPTO_SHA2_512: -+ hash_name = "sha512"; -+ hmac_mode = 0; -+ break; -+ default: -+ ddebug(1, "bad mac: %d", hash_op->mac_op); -+ return -EINVAL; -+ } -+ -+ ses = kzalloc(sizeof(*ses), GFP_KERNEL); -+ if (!ses) { -+ return -ENOMEM; -+ } -+ -+ if (unlikely(hash_op->mackeylen > CRYPTO_HMAC_MAX_KEY_LEN)) { -+ ddebug(1, "Setting key failed for %s-%zu.", hash_name, -+ (size_t)hash_op->mackeylen * 8); -+ ret = -EINVAL; -+ goto error_hash; -+ } -+ -+ if (hash_op->mackey && -+ unlikely(copy_from_user(mkey, hash_op->mackey, hash_op->mackeylen))) { -+ ret = -EFAULT; -+ goto error_hash; -+ } -+ -+ ret = cryptodev_hash_init(&ses->hdata, hash_name, hmac_mode, -+ mkey, hash_op->mackeylen); -+ if (ret != 0) { -+ ddebug(1, "Failed to load hash for %s", hash_name); -+ ret = -EINVAL; -+ goto error_hash; -+ } -+ -+ ses->alignmask = ses->hdata.alignmask; -+ ddebug(2, "got alignmask %d", ses->alignmask); -+ -+ ses->array_size = DEFAULT_PREALLOC_PAGES; -+ ddebug(2, "preallocating for %d user pages", ses->array_size); -+ -+ ses->pages = kzalloc(ses->array_size * sizeof(struct page *), GFP_KERNEL); -+ ses->sg = kzalloc(ses->array_size * sizeof(struct scatterlist), GFP_KERNEL); -+ if (ses->sg == NULL || ses->pages == NULL) { -+ ddebug(0, "Memory error"); -+ ret = -ENOMEM; -+ goto error_hash; -+ } -+ -+ hash_op->ses = ses; -+ return 0; -+ -+error_hash: -+ hash_destroy_session(ses); -+ return ret; -+} -+ -+ -+/* Everything that needs to be done when remowing a session. */ - static inline void - crypto_destroy_session(struct csession *ses_ptr) - { -@@ -960,7 +1081,7 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) - void __user *arg = (void __user *)arg_; - int __user *p = arg; - struct session_op sop; -- struct hash_op_data hash_op; -+ struct kernel_hash_op khop; - struct kernel_crypt_op kcop; - struct kernel_crypt_auth_op kcaop; - struct crypt_priv *pcr = filp->private_data; -@@ -1051,52 +1172,35 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) - - return kcop_to_user(&kcop, fcr, arg); - case CIOCHASH: -- /* get session */ -- if (unlikely(copy_from_user(&hash_op, arg, sizeof(struct hash_op_data)))) { -+ if (unlikely(copy_from_user(&khop.hash_op, arg, sizeof(struct hash_op_data)))) { - pr_err("copy from user fault\n"); - return -EFAULT; - } -+ khop.task = current; -+ khop.mm = current->mm; - -- sop.cipher = 0; -- sop.mac = hash_op.mac_op; -- sop.mackey = hash_op.mackey; -- sop.mackeylen = hash_op.mackeylen; -- -- /* writes sop.ses as a side-effect */ -- ret = crypto_create_session(fcr, &sop); -+ /* get session */ -+ ret = hash_create_session(&khop.hash_op); - if (unlikely(ret)) { - pr_err("can't get session\n"); - return ret; - } - - /* do hashing */ -- kcop.cop.ses = sop.ses; -- kcop.cop.flags = hash_op.flags; -- kcop.cop.len = hash_op.len; -- kcop.cop.src = hash_op.src; -- kcop.cop.mac = hash_op.mac_result; -- kcop.cop.dst = 0; -- kcop.cop.op = 0; -- kcop.cop.iv = 0; -- kcop.ivlen = 0; -- kcop.digestsize = 0; /* will be updated during operation */ -- kcop.task = current; -- kcop.mm = current->mm; -- -- ret = crypto_run(fcr, &kcop); -+ ret = hash_run(&khop); - if (unlikely(ret)) { - dwarning(1, "Error in hash run"); - return ret; - } - -- ret = copy_to_user(kcop.cop.mac, kcop.hash_output, kcop.digestsize); -+ ret = copy_to_user(khop.hash_op.mac_result, khop.hash_output, khop.digestsize); - if (unlikely(ret)) { - dwarning(1, "Error in copy to user"); - return ret; - } - - /* put session */ -- ret = crypto_finish_session(fcr, sop.ses); -+ hash_destroy_session(khop.hash_op.ses); - return 0; - case CIOCAUTHCRYPT: - if (unlikely(ret = kcaop_from_user(&kcaop, fcr, arg))) { -diff --git a/main.c b/main.c -index ec11129..095aea5 100644 ---- a/main.c -+++ b/main.c -@@ -159,8 +159,6 @@ __crypto_run_std(struct csession *ses_ptr, struct crypt_op *cop) - return ret; - } - -- -- - /* This is the main crypto function - zero-copy edition */ - static int - __crypto_run_zc(struct csession *ses_ptr, struct kernel_crypt_op *kcop) -@@ -841,3 +839,40 @@ out_unlock: - crypto_put_session(ses_ptr); - return ret; - } -+ -+int hash_run(struct kernel_hash_op *khop) -+{ -+ struct hash_op_data *hash_op = &khop->hash_op; -+ struct csession *ses_ptr = hash_op->ses; -+ struct hash_data *hdata = &ses_ptr->hdata; -+ int ret; -+ struct scatterlist *src_sg; -+ struct scatterlist *dst_sg; /* required by get_userbuf but not used */ -+ -+ if (hash_op->len == 0) { -+ src_sg = NULL; -+ } else { -+ ret = get_userbuf(ses_ptr, hash_op->src, hash_op->len, NULL, 0, -+ khop->task, khop->mm, &src_sg, &dst_sg); -+ if (unlikely(ret)) { -+ derr(1, "Error getting user pages"); -+ return ret; -+ } -+ } -+ -+ ahash_request_set_crypt(hdata->async.request, src_sg, khop->hash_output, hash_op->len); -+ -+ ret = crypto_ahash_digest(hdata->async.request); -+ if (ret == -EINPROGRESS || ret == -EBUSY) { -+ wait_for_completion(&hdata->async.result.completion); -+ ret = hdata->async.result.err; -+ if (ret != 0) { -+ derr(0, "CryptoAPI failure: %d", ret); -+ } -+ } -+ -+ khop->digestsize = ses_ptr->hdata.digestsize; -+ -+ release_user_pages(ses_ptr); -+ return ret; -+} --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0036-add-compat-for-CIOCHASH-operation.patch b/recipes-kernel/cryptodev/sdk_patches/0036-add-compat-for-CIOCHASH-operation.patch deleted file mode 100644 index c2069957..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0036-add-compat-for-CIOCHASH-operation.patch +++ /dev/null @@ -1,120 +0,0 @@ -From 711529cc7b8743ae8c9c0db4980ac15f7acb8618 Mon Sep 17 00:00:00 2001 -From: Alex Porosanu -Date: Tue, 12 Jan 2016 14:51:00 +0200 -Subject: [PATCH 36/38] add compat for CIOCHASH operation - -This patch adds the necessary ioctl for using the CIOCHASH -operation for different userspace & kernel (i.e. 32b userspace -and 64b kernel). - -Signed-off-by: Alex Porosanu ---- - cryptodev_int.h | 14 +++++++++++++- - ioctl.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 63 insertions(+), 1 deletion(-) - -diff --git a/cryptodev_int.h b/cryptodev_int.h -index 74c295a..6dcfd69 100644 ---- a/cryptodev_int.h -+++ b/cryptodev_int.h -@@ -129,6 +129,18 @@ struct compat_crypt_auth_op { - uint32_t iv_len; - }; - -+struct compat_hash_op_data { -+ compat_uptr_t ses; -+ uint32_t mac_op; /* cryptodev_crypto_op_t */ -+ compat_uptr_t mackey; -+ uint32_t mackeylen; -+ -+ uint16_t flags; /* see COP_FLAG_* */ -+ uint32_t len; /* length of source data */ -+ compat_uptr_t src; /* source data */ -+ compat_uptr_t mac_result; -+}; -+ - /* compat ioctls, defined for the above structs */ - #define COMPAT_CIOCGSESSION _IOWR('c', 102, struct compat_session_op) - #define COMPAT_CIOCCRYPT _IOWR('c', 104, struct compat_crypt_op) -@@ -139,7 +151,7 @@ struct compat_crypt_auth_op { - #define COMPAT_CIOCASYMASYNCRYPT _IOW('c', 110, struct compat_crypt_kop) - #define COMPAT_CIOCASYMFETCHCOOKIE _IOR('c', 111, \ - struct compat_pkc_cookie_list_s) -- -+#define COMPAT_CIOCHASH _IOWR('c', 114, struct compat_hash_op_data) - #endif /* CONFIG_COMPAT */ - - /* kernel-internal extension to struct crypt_kop */ -diff --git a/ioctl.c b/ioctl.c -index a052614..ff3de44 100644 ---- a/ioctl.c -+++ b/ioctl.c -@@ -1435,8 +1435,11 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) - struct fcrypt *fcr; - struct session_op sop; - struct compat_session_op compat_sop; -+ struct kernel_hash_op khop; - struct kernel_crypt_op kcop; - struct kernel_crypt_auth_op kcaop; -+ struct compat_hash_op_data compat_hash_op_data; -+ - int ret; - - if (unlikely(!pcr)) -@@ -1499,6 +1502,53 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) - - return compat_kcop_to_user(&kcop, fcr, arg); - -+ case COMPAT_CIOCHASH: -+ /* get session */ -+ if (unlikely(copy_from_user(&compat_hash_op_data, arg, -+ sizeof(struct compat_hash_op_data)))) { -+ pr_err("copy from user fault\n"); -+ return -EFAULT; -+ } -+ -+ khop.task = current; -+ khop.mm = current->mm; -+ -+ khop.hash_op.mac_op = compat_hash_op_data.mac_op; -+ khop.hash_op.mackey = compat_ptr(compat_hash_op_data.mackey); -+ khop.hash_op.mackeylen = compat_hash_op_data.mackeylen; -+ khop.hash_op.flags = compat_hash_op_data.flags; -+ khop.hash_op.len = compat_hash_op_data.len; -+ khop.hash_op.src = compat_ptr(compat_hash_op_data.src); -+ khop.hash_op.mac_result = -+ compat_ptr(compat_hash_op_data.mac_result); -+ -+ ret = hash_create_session(&khop.hash_op); -+ if (unlikely(ret)) { -+ pr_err("can't get session\n"); -+ return ret; -+ } -+ -+ /* do hashing */ -+ ret = hash_run(&khop); -+ if (unlikely(ret)) { -+ dwarning(1, "Error in hash run"); -+ return ret; -+ } -+ -+ ret = copy_to_user(khop.hash_op.mac_result, khop.hash_output, -+ khop.digestsize); -+ if (unlikely(ret)) { -+ dwarning(1, "Error in copy to user"); -+ return ret; -+ } -+ -+ copy_to_user(arg, &compat_hash_op_data, -+ sizeof(struct compat_hash_op_data)); -+ -+ /* put session */ -+ hash_destroy_session(khop.hash_op.ses); -+ return 0; -+ - case COMPAT_CIOCAUTHCRYPT: - if (unlikely(ret = compat_kcaop_from_user(&kcaop, fcr, arg))) { - dprintk(1, KERN_WARNING, "Error copying from user\n"); --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0037-rewrite-sha_speed.c-to-reduce-code-duplication.patch b/recipes-kernel/cryptodev/sdk_patches/0037-rewrite-sha_speed.c-to-reduce-code-duplication.patch deleted file mode 100644 index eff6ed9f..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0037-rewrite-sha_speed.c-to-reduce-code-duplication.patch +++ /dev/null @@ -1,190 +0,0 @@ -From 344a0243e31f8fc467253404a548eedbb72b35d0 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Wed, 20 Jan 2016 17:11:49 +0200 -Subject: [PATCH 37/38] rewrite sha_speed.c to reduce code duplication - -Signed-off-by: Cristian Stoica ---- - tests/sha_speed.c | 131 ++++++++++++++++++++++++++++++++++-------------------- - 1 file changed, 84 insertions(+), 47 deletions(-) - -diff --git a/tests/sha_speed.c b/tests/sha_speed.c -index e1dc54b..5f694bd 100644 ---- a/tests/sha_speed.c -+++ b/tests/sha_speed.c -@@ -28,6 +28,13 @@ - - #include - -+/* Sizes of buffers to be hashed */ -+int buffer_lengths[] = {256, 512, 1024, 2048, 4096, 8192, 65536, 0}; -+ -+/* Time in seconds allocated for each tested buffer lengths */ -+#define BUFFER_TEST_TIME 10 -+ -+ - static double udifftimeval(struct timeval start, struct timeval end) - { - return (double)(end.tv_usec - start.tv_usec) + -@@ -97,7 +104,7 @@ int hash_data(struct session_op *sess, int fdc, int chunksize, int alignmask) - memset(buffer, val++, chunksize); - - must_finish = 0; -- alarm(5); -+ alarm(BUFFER_TEST_TIME); - - gettimeofday(&start, NULL); - do { -@@ -126,73 +133,103 @@ int hash_data(struct session_op *sess, int fdc, int chunksize, int alignmask) - return 0; - } - --int main(void) --{ -- int fd, i, fdc = -1, alignmask = 0; -- struct session_op sess; -- char keybuf[32]; -+ - #ifdef CIOCGSESSINFO -+int get_alignmask(struct session_op *sess, int fdc) -+{ - struct session_info_op siop; -+ -+ siop.ses = sess->ses; -+ if (ioctl(fdc, CIOCGSESSINFO, &siop) < 0) { -+ perror("ioctl(CIOCGSESSINFO)"); -+ /* continue test ignoring CIOCGSESSINFO error */ -+ return 0; -+ } -+ -+ printf("using algorithm %s with driver %s\n", -+ siop.hash_info.cra_name, siop.hash_info.cra_driver_name); -+ -+ return siop.alignmask; -+} - #endif - -- signal(SIGALRM, alarm_handler); - -- if ((fd = open("/dev/crypto", O_RDWR, 0)) < 0) { -- perror("open()"); -- return 1; -- } -- if (ioctl(fd, CRIOGET, &fdc)) { -- perror("ioctl(CRIOGET)"); -- return 1; -- } -+int hash_session(struct session_op *sess, int fdc) -+{ -+ int i; -+ int err; -+ int alignmask; - -- fprintf(stderr, "Testing SHA1 Hash: \n"); -- memset(&sess, 0, sizeof(sess)); -- sess.mac = CRYPTO_SHA1; -- if (ioctl(fdc, CIOCGSESSION, &sess)) { -+ if (ioctl(fdc, CIOCGSESSION, sess)) { - perror("ioctl(CIOCGSESSION)"); - return 1; - } -+ - #ifdef CIOCGSESSINFO -- siop.ses = sess.ses; -- if (ioctl(fdc, CIOCGSESSINFO, &siop)) { -- perror("ioctl(CIOCGSESSINFO)"); -- return 1; -- } -- printf("requested hash CRYPTO_SHA1, got %s with driver %s\n", -- siop.hash_info.cra_name, siop.hash_info.cra_driver_name); -- alignmask = siop.alignmask; -+ alignmask = get_alignmask(sess, fdc); -+#else -+ alignmask = 0; - #endif - -- for (i = 256; i <= (64 * 1024); i *= 4) { -- if (hash_data(&sess, fdc, i, alignmask)) -- break; -+ err = 0; -+ for(i = 0; (err == 0) && (buffer_lengths[i] != 0); i++) { -+ err = hash_data(sess, fdc, buffer_lengths[i], alignmask); - } - -- fprintf(stderr, "\nTesting SHA256 Hash: \n"); -- memset(&sess, 0, sizeof(sess)); -- sess.mac = CRYPTO_SHA2_256; -- if (ioctl(fdc, CIOCGSESSION, &sess)) { -- perror("ioctl(CIOCGSESSION)"); -+ if (ioctl(fdc, CIOCFSESSION, sess)) { -+ perror("ioctl(CIOCFSESSION)"); - return 1; - } --#ifdef CIOCGSESSINFO -- siop.ses = sess.ses; -- if (ioctl(fdc, CIOCGSESSINFO, &siop)) { -- perror("ioctl(CIOCGSESSINFO)"); -+ -+ return err; -+} -+ -+int test_sha1(struct session_op *sess, int fdc) -+{ -+ fprintf(stderr, "Testing SHA1 Hash: \n"); -+ memset(sess, 0, sizeof(sess)); -+ sess->mac = CRYPTO_SHA1; -+ return hash_session(sess, fdc); -+} -+ -+ -+int test_sha256(struct session_op *sess, int fdc) -+{ -+ fprintf(stderr, "Testing SHA256 Hash: \n"); -+ memset(sess, 0, sizeof(sess)); -+ sess->mac = CRYPTO_SHA2_256; -+ return hash_session(sess, fdc); -+} -+ -+ -+int main(void) -+{ -+ int fd; -+ int fdc; -+ int err; -+ int i; -+ struct session_op sess; -+ -+ signal(SIGALRM, alarm_handler); -+ -+ fd = open("/dev/crypto", O_RDWR, 0); -+ if (fd < 0) { -+ perror("open()"); - return 1; - } -- printf("requested hash CRYPTO_SHA2_256, got %s with driver %s\n", -- siop.hash_info.cra_name, siop.hash_info.cra_driver_name); -- alignmask = siop.alignmask; --#endif - -- for (i = 256; i <= (64 * 1024); i *= 4) { -- if (hash_data(&sess, fdc, i, alignmask)) -- break; -+ err = ioctl(fd, CRIOGET, &fdc); -+ if (err != 0) { -+ perror("ioctl(CRIOGET)"); -+ close(fd); -+ return 1; - } - -+ /* run all tests but return an eventual error */ -+ err |= test_sha1(&sess, fdc); -+ err |= test_sha256(&sess, fdc); -+ - close(fdc); - close(fd); -- return 0; -+ return err; - } --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0038-extend-sha_speed.c-to-test-CIOCHASH.patch b/recipes-kernel/cryptodev/sdk_patches/0038-extend-sha_speed.c-to-test-CIOCHASH.patch deleted file mode 100644 index eb8bf197..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0038-extend-sha_speed.c-to-test-CIOCHASH.patch +++ /dev/null @@ -1,143 +0,0 @@ -From 65704ea24e80647e8c5f938300f51cb70af50c1c Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Thu, 21 Jan 2016 17:30:59 +0200 -Subject: [PATCH 38/38] extend sha_speed.c to test CIOCHASH - -Signed-off-by: Cristian Stoica ---- - tests/sha_speed.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 90 insertions(+) - -diff --git a/tests/sha_speed.c b/tests/sha_speed.c -index 5f694bd..d731c66 100644 ---- a/tests/sha_speed.c -+++ b/tests/sha_speed.c -@@ -133,6 +133,62 @@ int hash_data(struct session_op *sess, int fdc, int chunksize, int alignmask) - return 0; - } - -+int digest_data(struct session_op *sess, int fdc, int chunksize, int alignmask) -+{ -+ struct hash_op_data hash_op; -+ char *buffer; -+ static int val = 23; -+ struct timeval start, end; -+ double total = 0; -+ double secs, ddata, dspeed; -+ char metric[16]; -+ uint8_t mac[AALG_MAX_RESULT_LEN]; -+ -+ if (alignmask) { -+ if (posix_memalign((void **)&buffer, alignmask + 1, chunksize)) { -+ printf("posix_memalign() failed!\n"); -+ return 1; -+ } -+ } else { -+ if (!(buffer = malloc(chunksize))) { -+ perror("malloc()"); -+ return 1; -+ } -+ } -+ -+ printf("\tEncrypting in chunks of %d bytes: ", chunksize); -+ fflush(stdout); -+ -+ memset(buffer, val++, chunksize); -+ -+ must_finish = 0; -+ alarm(BUFFER_TEST_TIME); -+ -+ gettimeofday(&start, NULL); -+ do { -+ memset(&hash_op, 0, sizeof(hash_op)); -+ hash_op.mac_op = sess->mac; -+ hash_op.len = chunksize; -+ hash_op.src = (unsigned char *)buffer; -+ hash_op.mac_result = mac; -+ -+ if (ioctl(fdc, CIOCHASH, hash_op) != 0) { -+ perror("ioctl(CIOCHASH)"); -+ return 1; -+ } -+ total += chunksize; -+ } while(must_finish == 0); -+ gettimeofday(&end, NULL); -+ -+ secs = udifftimeval(start, end)/ 1000000.0; -+ -+ value2human(1, total, secs, &ddata, &dspeed, metric); -+ printf ("done. %.2f %s in %.2f secs: ", ddata, metric, secs); -+ printf ("%.2f %s/sec\n", dspeed, metric); -+ -+ free(buffer); -+ return 0; -+} - - #ifdef CIOCGSESSINFO - int get_alignmask(struct session_op *sess, int fdc) -@@ -154,6 +210,20 @@ int get_alignmask(struct session_op *sess, int fdc) - #endif - - -+int ciochash_session(struct session_op *sess, int fdc) -+{ -+ int i; -+ int err = 0; -+ -+ err = 0; -+ for(i = 0; (err == 0) && (buffer_lengths[i] != 0); i++) { -+ err = digest_data(sess, fdc, buffer_lengths[i], 0); -+ } -+ -+ return err; -+} -+ -+ - int hash_session(struct session_op *sess, int fdc) - { - int i; -@@ -193,6 +263,15 @@ int test_sha1(struct session_op *sess, int fdc) - } - - -+int test_sha1_ciochash(struct session_op *sess, int fdc) -+{ -+ fprintf(stderr, "Testing SHA1 CIOCHASH: \n"); -+ memset(sess, 0, sizeof(sess)); -+ sess->mac = CRYPTO_SHA1; -+ return ciochash_session(sess, fdc); -+} -+ -+ - int test_sha256(struct session_op *sess, int fdc) - { - fprintf(stderr, "Testing SHA256 Hash: \n"); -@@ -202,6 +281,15 @@ int test_sha256(struct session_op *sess, int fdc) - } - - -+int test_sha256_ciochash(struct session_op *sess, int fdc) -+{ -+ fprintf(stderr, "Testing SHA256 CIOCHASH: \n"); -+ memset(sess, 0, sizeof(sess)); -+ sess->mac = CRYPTO_SHA2_256; -+ return ciochash_session(sess, fdc); -+} -+ -+ - int main(void) - { - int fd; -@@ -227,7 +315,9 @@ int main(void) - - /* run all tests but return an eventual error */ - err |= test_sha1(&sess, fdc); -+ err |= test_sha1_ciochash(&sess, fdc); - err |= test_sha256(&sess, fdc); -+ err |= test_sha256_ciochash(&sess, fdc); - - close(fdc); - close(fd); --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0039-fix-memory-leaks-on-error-path-for-CIOCHASH.patch b/recipes-kernel/cryptodev/sdk_patches/0039-fix-memory-leaks-on-error-path-for-CIOCHASH.patch deleted file mode 100644 index fc2f4c88..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0039-fix-memory-leaks-on-error-path-for-CIOCHASH.patch +++ /dev/null @@ -1,70 +0,0 @@ -From 3e3996b40fd3a93cbe2e5ddee244280dd7de6c18 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Tue, 9 Feb 2016 21:07:06 +0200 -Subject: [PATCH 39/40] fix memory leaks on error path for CIOCHASH - -Signed-off-by: Cristian Stoica ---- - ioctl.c | 20 +++++++++++--------- - 1 file changed, 11 insertions(+), 9 deletions(-) - -diff --git a/ioctl.c b/ioctl.c -index ff3de44..8d81b56 100644 ---- a/ioctl.c -+++ b/ioctl.c -@@ -1190,18 +1190,17 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) - ret = hash_run(&khop); - if (unlikely(ret)) { - dwarning(1, "Error in hash run"); -- return ret; -+ goto hash_err; - } - - ret = copy_to_user(khop.hash_op.mac_result, khop.hash_output, khop.digestsize); - if (unlikely(ret)) { - dwarning(1, "Error in copy to user"); -- return ret; - } - -- /* put session */ -+ hash_err: - hash_destroy_session(khop.hash_op.ses); -- return 0; -+ return ret; - case CIOCAUTHCRYPT: - if (unlikely(ret = kcaop_from_user(&kcaop, fcr, arg))) { - dwarning(1, "Error copying from user"); -@@ -1532,22 +1531,25 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) - ret = hash_run(&khop); - if (unlikely(ret)) { - dwarning(1, "Error in hash run"); -- return ret; -+ goto hash_err; - } - - ret = copy_to_user(khop.hash_op.mac_result, khop.hash_output, - khop.digestsize); - if (unlikely(ret)) { - dwarning(1, "Error in copy to user"); -- return ret; -+ goto hash_err; - } - -- copy_to_user(arg, &compat_hash_op_data, -+ ret = copy_to_user(arg, &compat_hash_op_data, - sizeof(struct compat_hash_op_data)); -+ if (unlikely(ret)) { -+ dwarning(1, "Error in copy to user"); -+ } - -- /* put session */ -+ hash_err: - hash_destroy_session(khop.hash_op.ses); -- return 0; -+ return ret; - - case COMPAT_CIOCAUTHCRYPT: - if (unlikely(ret = compat_kcaop_from_user(&kcaop, fcr, arg))) { --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0040-fix-structure-init-in-sha_speed-test.patch b/recipes-kernel/cryptodev/sdk_patches/0040-fix-structure-init-in-sha_speed-test.patch deleted file mode 100644 index 053d376c..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0040-fix-structure-init-in-sha_speed-test.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 3eb9ed52743584949ff9b4844e810333c34a3a1f Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Fri, 12 Feb 2016 11:23:41 +0200 -Subject: [PATCH 40/40] fix structure init in sha_speed test - -Signed-off-by: Cristian Stoica ---- - tests/sha_speed.c | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -diff --git a/tests/sha_speed.c b/tests/sha_speed.c -index d731c66..75d0f42 100644 ---- a/tests/sha_speed.c -+++ b/tests/sha_speed.c -@@ -257,7 +257,7 @@ int hash_session(struct session_op *sess, int fdc) - int test_sha1(struct session_op *sess, int fdc) - { - fprintf(stderr, "Testing SHA1 Hash: \n"); -- memset(sess, 0, sizeof(sess)); -+ memset(sess, 0, sizeof(struct session_op)); - sess->mac = CRYPTO_SHA1; - return hash_session(sess, fdc); - } -@@ -266,7 +266,7 @@ int test_sha1(struct session_op *sess, int fdc) - int test_sha1_ciochash(struct session_op *sess, int fdc) - { - fprintf(stderr, "Testing SHA1 CIOCHASH: \n"); -- memset(sess, 0, sizeof(sess)); -+ memset(sess, 0, sizeof(struct session_op)); - sess->mac = CRYPTO_SHA1; - return ciochash_session(sess, fdc); - } -@@ -275,7 +275,7 @@ int test_sha1_ciochash(struct session_op *sess, int fdc) - int test_sha256(struct session_op *sess, int fdc) - { - fprintf(stderr, "Testing SHA256 Hash: \n"); -- memset(sess, 0, sizeof(sess)); -+ memset(sess, 0, sizeof(struct session_op)); - sess->mac = CRYPTO_SHA2_256; - return hash_session(sess, fdc); - } -@@ -284,7 +284,7 @@ int test_sha256(struct session_op *sess, int fdc) - int test_sha256_ciochash(struct session_op *sess, int fdc) - { - fprintf(stderr, "Testing SHA256 CIOCHASH: \n"); -- memset(sess, 0, sizeof(sess)); -+ memset(sess, 0, sizeof(struct session_op)); - sess->mac = CRYPTO_SHA2_256; - return ciochash_session(sess, fdc); - } --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0041-add-separate-target-for-building-tests.patch b/recipes-kernel/cryptodev/sdk_patches/0041-add-separate-target-for-building-tests.patch deleted file mode 100644 index ff738254..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0041-add-separate-target-for-building-tests.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 0d58530f5c5970db9787a23aef4227c68f941fcc Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Wed, 10 Feb 2016 16:22:05 +0200 -Subject: [PATCH 41/43] add separate target for building tests - -A separate target for build is useful with cross-compilation. In this -case it makes sense to build the tests without running them on the host -machine. - -The default target is now 'all' and only builds the tests - -Signed-off-by: Cristian Stoica ---- - tests/Makefile | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/tests/Makefile b/tests/Makefile -index 3155da9..89f88fe 100644 ---- a/tests/Makefile -+++ b/tests/Makefile -@@ -19,6 +19,8 @@ example-async-hmac-objs := async_hmac.o - example-async-speed-objs := async_speed.o - example-hashcrypt-speed-objs := hashcrypt_speed.c - -+all: $(hostprogs) -+ - check: $(hostprogs) - ./cipher - ./hmac -@@ -33,3 +35,5 @@ clean: - - ${comp_progs}: LDLIBS += -lssl -lcrypto - ${comp_progs}: %: %.o openssl_wrapper.o -+ -+.PHONY: all clean check --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0042-fix-destination-for-staged-installs.patch b/recipes-kernel/cryptodev/sdk_patches/0042-fix-destination-for-staged-installs.patch deleted file mode 100644 index c8ae06e3..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0042-fix-destination-for-staged-installs.patch +++ /dev/null @@ -1,55 +0,0 @@ -From dcb8fe0fcf71feac2a4f57c44a5153bfc404b4c3 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Thu, 11 Feb 2016 16:37:23 +0200 -Subject: [PATCH 42/43] fix destination for staged installs - -The standard variable for staged installations is DESTDIR and it should -be set only by the user, outside of Makefile. This is consistent with -recommendations from both GNU Make and FreeBSD porters-handbook. - - make DESTDIR=/tmp/stage install - -$prefix and $PREFIX (in FreeBSD world) are used to specify where the -files will be installed. It defaults to /usr/local but can be /usr or -/opt or something else. - -Usually one wants to do a stage installation when cross-building or for -other purposes. The convention is to use DESTDIR. -Changing $prefix is useful for installers. They can override its value -when calling make: - - make prefix=/usr install - -Signed-off-by: Cristian Stoica ---- - Makefile | 7 ++++--- - 1 file changed, 4 insertions(+), 3 deletions(-) - -diff --git a/Makefile b/Makefile -index 7f8df37..9871a8e 100644 ---- a/Makefile -+++ b/Makefile -@@ -7,7 +7,9 @@ CRYPTODEV_CFLAGS ?= #-DENABLE_ASYNC - KBUILD_CFLAGS += -I$(src) $(CRYPTODEV_CFLAGS) - KERNEL_DIR ?= /lib/modules/$(shell uname -r)/build - VERSION = 1.8 --PREFIX ?= -+ -+prefix ?= /usr/local -+includedir = $(prefix)/include - - cryptodev-objs = ioctl.o main.o cryptlib.o authenc.o zc.o util.o - -@@ -31,8 +33,7 @@ install: modules_install - - modules_install: - $(MAKE) -C $(KERNEL_DIR) M=$(PWD) modules_install -- @echo "Installing cryptodev.h in $(PREFIX)/usr/include/crypto ..." -- @install -D crypto/cryptodev.h $(PREFIX)/usr/include/crypto/cryptodev.h -+ install -m 644 -D crypto/cryptodev.h $(DESTDIR)/$(includedir)/crypto/cryptodev.h - - clean: - $(MAKE) -C $(KERNEL_DIR) M=$(PWD) clean --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0043-add-install-target-for-tests.patch b/recipes-kernel/cryptodev/sdk_patches/0043-add-install-target-for-tests.patch deleted file mode 100644 index f3b70228..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0043-add-install-target-for-tests.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 44629033d47543d106299b6c8bed9e5c9fed1513 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Thu, 11 Feb 2016 16:48:53 +0200 -Subject: [PATCH 43/43] add install target for tests - -Signed-off-by: Cristian Stoica ---- - tests/Makefile | 12 +++++++++++- - 1 file changed, 11 insertions(+), 1 deletion(-) - -diff --git a/tests/Makefile b/tests/Makefile -index 89f88fe..5e3111d 100644 ---- a/tests/Makefile -+++ b/tests/Makefile -@@ -19,6 +19,10 @@ example-async-hmac-objs := async_hmac.o - example-async-speed-objs := async_speed.o - example-hashcrypt-speed-objs := hashcrypt_speed.c - -+prefix ?= /usr/local -+execprefix ?= $(prefix) -+bindir = $(execprefix)/bin -+ - all: $(hostprogs) - - check: $(hostprogs) -@@ -30,10 +34,16 @@ check: $(hostprogs) - ./cipher-gcm - ./cipher-aead - -+install: -+ install -d $(DESTDIR)/$(bindir) -+ for prog in $(hostprogs); do \ -+ install -m 755 $$prog $(DESTDIR)/$(bindir); \ -+ done -+ - clean: - rm -f *.o *~ $(hostprogs) - - ${comp_progs}: LDLIBS += -lssl -lcrypto - ${comp_progs}: %: %.o openssl_wrapper.o - --.PHONY: all clean check -+.PHONY: all clean check install --- -2.7.0 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0044-add-aes-256-xts-support-for-async-speed-test.patch b/recipes-kernel/cryptodev/sdk_patches/0044-add-aes-256-xts-support-for-async-speed-test.patch deleted file mode 100644 index 8a3c4f24..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0044-add-aes-256-xts-support-for-async-speed-test.patch +++ /dev/null @@ -1,64 +0,0 @@ -From 6a89ac4c49068d4225f4c1cc94a1d20b3d174b3f Mon Sep 17 00:00:00 2001 -From: Radu Alexe -Date: Sat, 22 Oct 2016 21:55:25 +0300 -Subject: [PATCH 044/104] add aes-256-xts support for async speed test - -Signed-off-by: Radu Alexe ---- - ioctl.c | 3 +++ - tests/async_speed.c | 25 +++++++++++++++++++++++++ - 2 files changed, 28 insertions(+) - -diff --git a/ioctl.c b/ioctl.c -index 8d81b56..ca3c5ac 100644 ---- a/ioctl.c -+++ b/ioctl.c -@@ -172,6 +172,9 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) - case CRYPTO_AES_ECB: - alg_name = "ecb(aes)"; - break; -+ case CRYPTO_AES_XTS: -+ alg_name = "xts(aes)"; -+ break; - case CRYPTO_CAMELLIA_CBC: - alg_name = "cbc(camellia)"; - break; -diff --git a/tests/async_speed.c b/tests/async_speed.c -index 1188599..39a3d23 100644 ---- a/tests/async_speed.c -+++ b/tests/async_speed.c -@@ -211,6 +211,31 @@ int main(void) - break; - } - -+ fprintf(stderr, "\nTesting AES-256-XTS cipher: \n"); -+ memset(&sess, 0, sizeof(sess)); -+ sess.cipher = CRYPTO_AES_XTS; -+ sess.keylen = 32; -+ memset(keybuf, 0x42, sess.keylen); -+ sess.key = (unsigned char *)keybuf; -+ if (ioctl(fdc, CIOCGSESSION, &sess)) { -+ perror("ioctl(CIOCGSESSION)"); -+ return 1; -+ } -+#ifdef CIOCGSESSINFO -+ siop.ses = sess.ses; -+ if (ioctl(fdc, CIOCGSESSINFO, &siop)) { -+ perror("ioctl(CIOCGSESSION)"); -+ return 1; -+ } -+ alignmask = siop.alignmask; -+#endif -+ -+ for (i = 256; i <= (64 * 1024); i *= 2) { -+ if (encrypt_data(&sess, fdc, i, alignmask)) -+ break; -+ } -+ -+end: - close(fdc); - close(fd); - return 0; --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0045-add-support-for-crc32c-hash-async-speed-test.patch b/recipes-kernel/cryptodev/sdk_patches/0045-add-support-for-crc32c-hash-async-speed-test.patch deleted file mode 100644 index b1a790eb..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0045-add-support-for-crc32c-hash-async-speed-test.patch +++ /dev/null @@ -1,92 +0,0 @@ -From aa329106f586f8d055ceaa919e327ebc99bdd6e3 Mon Sep 17 00:00:00 2001 -From: Alexe Radu -Date: Tue, 25 Oct 2016 11:15:37 +0300 -Subject: [PATCH 045/104] add support for crc32c hash async speed test - -Signed-off-by: Alexe Radu ---- - crypto/cryptodev.h | 1 + - ioctl.c | 4 ++++ - tests/async_speed.c | 25 +++++++++++++++++++++++++ - 3 files changed, 30 insertions(+) - -diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h -index 9ade102..05221a4 100644 ---- a/crypto/cryptodev.h -+++ b/crypto/cryptodev.h -@@ -46,6 +46,7 @@ enum cryptodev_crypto_op_t { - CRYPTO_AES_XTS = 22, - CRYPTO_AES_ECB = 23, - CRYPTO_AES_GCM = 50, -+ CRYPTO_CRC32C, - - CRYPTO_CAMELLIA_CBC = 101, - CRYPTO_RIPEMD160, -diff --git a/ioctl.c b/ioctl.c -index ca3c5ac..2e2bdeb 100644 ---- a/ioctl.c -+++ b/ioctl.c -@@ -286,6 +286,10 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) - hash_name = "sha512"; - hmac_mode = 0; - break; -+ case CRYPTO_CRC32C: -+ hash_name = "crc32c"; -+ hmac_mode = 0; -+ break; - default: - ddebug(1, "bad mac: %d", sop->mac); - return -EINVAL; -diff --git a/tests/async_speed.c b/tests/async_speed.c -index 39a3d23..8978b4b 100644 ---- a/tests/async_speed.c -+++ b/tests/async_speed.c -@@ -65,6 +65,7 @@ int encrypt_data(struct session_op *sess, int fdc, int chunksize, int alignmask) - { - struct crypt_op cop; - char *buffer[64], iv[32]; -+ char mac[64][HASH_MAX_LEN]; - static int val = 23; - struct timeval start, end; - double total = 0; -@@ -114,6 +115,7 @@ int encrypt_data(struct session_op *sess, int fdc, int chunksize, int alignmask) - cop.iv = (unsigned char *)iv; - cop.op = COP_ENCRYPT; - cop.src = cop.dst = (unsigned char *)buffer[bufidx]; -+ cop.mac = mac[bufidx]; - bufidx = (bufidx + 1) % 64; - - if (ioctl(fdc, CIOCASYNCCRYPT, &cop)) { -@@ -235,6 +237,29 @@ int main(void) - break; - } - -+ fprintf(stderr, "\nTesting CRC32C hash: \n"); -+ memset(&sess, 0, sizeof(sess)); -+ sess.mac = CRYPTO_CRC32C; -+ if (ioctl(fdc, CIOCGSESSION, &sess)) { -+ perror("ioctl(CIOCGSESSION)"); -+ return 1; -+ } -+#ifdef CIOCGSESSINFO -+ siop.ses = sess.ses; -+ if (ioctl(fdc, CIOCGSESSINFO, &siop)) { -+ perror("ioctl(CIOCGSESSION)"); -+ return 1; -+ } -+ printf("requested hash CRYPTO_CRC32C, got %s with driver %s\n", -+ siop.hash_info.cra_name, siop.hash_info.cra_driver_name); -+ alignmask = siop.alignmask; -+#endif -+ -+ for (i = 256; i <= (64 * 1024); i *= 2) { -+ if (encrypt_data(&sess, fdc, i, alignmask)) -+ break; -+ } -+ - end: - close(fdc); - close(fd); --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0046-add-support-for-sha1-hash-async-speed-test.patch b/recipes-kernel/cryptodev/sdk_patches/0046-add-support-for-sha1-hash-async-speed-test.patch deleted file mode 100644 index fb902fbd..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0046-add-support-for-sha1-hash-async-speed-test.patch +++ /dev/null @@ -1,47 +0,0 @@ -From c2fed59ef63a1b9da26e8a5452004b07aad39261 Mon Sep 17 00:00:00 2001 -From: Alexe Radu -Date: Tue, 25 Oct 2016 11:21:47 +0300 -Subject: [PATCH 046/104] add support for sha1 hash async speed test - -Signed-off-by: Alexe Radu ---- - tests/async_speed.c | 23 +++++++++++++++++++++++ - 1 file changed, 23 insertions(+) - -diff --git a/tests/async_speed.c b/tests/async_speed.c -index 8978b4b..64d5603 100644 ---- a/tests/async_speed.c -+++ b/tests/async_speed.c -@@ -260,6 +260,29 @@ int main(void) - break; - } - -+ fprintf(stderr, "\nTesting SHA-1 hash: \n"); -+ memset(&sess, 0, sizeof(sess)); -+ sess.mac = CRYPTO_SHA1; -+ if (ioctl(fdc, CIOCGSESSION, &sess)) { -+ perror("ioctl(CIOCGSESSION)"); -+ return 1; -+ } -+#ifdef CIOCGSESSINFO -+ siop.ses = sess.ses; -+ if (ioctl(fdc, CIOCGSESSINFO, &siop)) { -+ perror("ioctl(CIOCGSESSION)"); -+ return 1; -+ } -+ printf("requested hash CRYPTO_SHA1, got %s with driver %s\n", -+ siop.hash_info.cra_name, siop.hash_info.cra_driver_name); -+ alignmask = siop.alignmask; -+#endif -+ -+ for (i = 256; i <= (64 * 1024); i *= 2) { -+ if (encrypt_data(&sess, fdc, i, alignmask)) -+ break; -+ } -+ - end: - close(fdc); - close(fd); --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0047-add-support-for-sha2-256-hash-async-speed-test.patch b/recipes-kernel/cryptodev/sdk_patches/0047-add-support-for-sha2-256-hash-async-speed-test.patch deleted file mode 100644 index 2721ea84..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0047-add-support-for-sha2-256-hash-async-speed-test.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 14c5355aa23f970c7941afa460b2335f8e67445f Mon Sep 17 00:00:00 2001 -From: Alexe Radu -Date: Tue, 25 Oct 2016 11:28:09 +0300 -Subject: [PATCH 047/104] add support for sha2-256 hash async speed test - -Signed-off-by: Alexe Radu ---- - tests/async_speed.c | 23 +++++++++++++++++++++++ - 1 file changed, 23 insertions(+) - -diff --git a/tests/async_speed.c b/tests/async_speed.c -index 64d5603..15ab80c 100644 ---- a/tests/async_speed.c -+++ b/tests/async_speed.c -@@ -283,6 +283,29 @@ int main(void) - break; - } - -+ fprintf(stderr, "\nTesting SHA2-256 hash: \n"); -+ memset(&sess, 0, sizeof(sess)); -+ sess.mac = CRYPTO_SHA2_256; -+ if (ioctl(fdc, CIOCGSESSION, &sess)) { -+ perror("ioctl(CIOCGSESSION)"); -+ return 1; -+ } -+#ifdef CIOCGSESSINFO -+ siop.ses = sess.ses; -+ if (ioctl(fdc, CIOCGSESSINFO, &siop)) { -+ perror("ioctl(CIOCGSESSION)"); -+ return 1; -+ } -+ printf("requested hash CRYPTO_SHA2_256, got %s with driver %s\n", -+ siop.hash_info.cra_name, siop.hash_info.cra_driver_name); -+ alignmask = siop.alignmask; -+#endif -+ -+ for (i = 256; i <= (64 * 1024); i *= 2) { -+ if (encrypt_data(&sess, fdc, i, alignmask)) -+ break; -+ } -+ - end: - close(fdc); - close(fd); --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0048-add-support-for-aes-256-xts-sync-speed-test.patch b/recipes-kernel/cryptodev/sdk_patches/0048-add-support-for-aes-256-xts-sync-speed-test.patch deleted file mode 100644 index 85301aa8..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0048-add-support-for-aes-256-xts-sync-speed-test.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 139268835b7d84472950e3ed866f41d79a0cb723 Mon Sep 17 00:00:00 2001 -From: Alexe Radu -Date: Tue, 25 Oct 2016 12:05:13 +0300 -Subject: [PATCH 048/104] add support for aes-256-xts sync speed test - -Signed-off-by: Alexe Radu ---- - tests/speed.c | 24 ++++++++++++++++++++++++ - 1 file changed, 24 insertions(+) - -diff --git a/tests/speed.c b/tests/speed.c -index 81c5a65..16ad7b7 100644 ---- a/tests/speed.c -+++ b/tests/speed.c -@@ -206,6 +206,30 @@ int main(int argc, char** argv) - break; - } - -+ fprintf(stderr, "\nTesting AES-256-XTS cipher: \n"); -+ memset(&sess, 0, sizeof(sess)); -+ sess.cipher = CRYPTO_AES_XTS; -+ sess.keylen = 32; -+ memset(keybuf, 0x42, sess.keylen); -+ sess.key = (unsigned char *)keybuf; -+ if (ioctl(fdc, CIOCGSESSION, &sess)) { -+ perror("ioctl(CIOCGSESSION)"); -+ return 1; -+ } -+#ifdef CIOCGSESSINFO -+ siop.ses = sess.ses; -+ if (ioctl(fdc, CIOCGSESSINFO, &siop)) { -+ perror("ioctl(CIOCGSESSINFO)"); -+ return 1; -+ } -+ alignmask = siop.alignmask; -+#endif -+ -+ for (i = 512; i <= (64 * 1024); i *= 2) { -+ if (encrypt_data(&sess, fdc, i, alignmask)) -+ break; -+ } -+ - close(fdc); - close(fd); - return 0; --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0049-add-support-for-crc32c-hash-sync-speed-test.patch b/recipes-kernel/cryptodev/sdk_patches/0049-add-support-for-crc32c-hash-sync-speed-test.patch deleted file mode 100644 index 26279b68..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0049-add-support-for-crc32c-hash-sync-speed-test.patch +++ /dev/null @@ -1,63 +0,0 @@ -From af3d42a68f1e356d21e52e72f3f5ebc7cfd90e81 Mon Sep 17 00:00:00 2001 -From: Alexe Radu -Date: Tue, 25 Oct 2016 12:13:58 +0300 -Subject: [PATCH 049/104] add support for crc32c hash sync speed test - -Signed-off-by: Alexe Radu ---- - tests/speed.c | 25 +++++++++++++++++++++++++ - 1 file changed, 25 insertions(+) - -diff --git a/tests/speed.c b/tests/speed.c -index 16ad7b7..bd6d2b2 100644 ---- a/tests/speed.c -+++ b/tests/speed.c -@@ -74,6 +74,7 @@ int encrypt_data(struct session_op *sess, int fdc, int chunksize, int alignmask) - { - struct crypt_op cop; - char *buffer, iv[32]; -+ char mac[HASH_MAX_LEN]; - static int val = 23; - struct timeval start, end; - double total = 0; -@@ -110,6 +111,7 @@ int encrypt_data(struct session_op *sess, int fdc, int chunksize, int alignmask) - cop.iv = (unsigned char *)iv; - cop.op = COP_ENCRYPT; - cop.src = cop.dst = (unsigned char *)buffer; -+ cop.mac = mac; - - if (ioctl(fdc, CIOCCRYPT, &cop)) { - perror("ioctl(CIOCCRYPT)"); -@@ -230,6 +232,29 @@ int main(int argc, char** argv) - break; - } - -+ fprintf(stderr, "\nTesting CRC32C hash: \n"); -+ memset(&sess, 0, sizeof(sess)); -+ sess.mac = CRYPTO_CRC32C; -+ if (ioctl(fdc, CIOCGSESSION, &sess)) { -+ perror("ioctl(CIOCGSESSION)"); -+ return 1; -+ } -+#ifdef CIOCGSESSINFO -+ siop.ses = sess.ses; -+ if (ioctl(fdc, CIOCGSESSINFO, &siop)) { -+ perror("ioctl(CIOCGSESSINFO)"); -+ return 1; -+ } -+ printf("requested hash CRYPTO_CRC32C, got %s with driver %s\n", -+ siop.hash_info.cra_name, siop.hash_info.cra_driver_name); -+ alignmask = siop.alignmask; -+#endif -+ -+ for (i = 512; i <= (64 * 1024); i *= 2) { -+ if (encrypt_data(&sess, fdc, i, alignmask)) -+ break; -+ } -+ - close(fdc); - close(fd); - return 0; --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0050-add-basic-optargs-support-for-async_speed-test.patch b/recipes-kernel/cryptodev/sdk_patches/0050-add-basic-optargs-support-for-async_speed-test.patch deleted file mode 100644 index f54286ae..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0050-add-basic-optargs-support-for-async_speed-test.patch +++ /dev/null @@ -1,439 +0,0 @@ -From 13cb1f2dcf8865b076a7e8290d8f864d91a2d7c7 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Mon, 24 Oct 2016 16:33:55 +0300 -Subject: [PATCH 050/104] add basic optargs support for async_speed test - -Signed-off-by: Cristian Stoica ---- - tests/async_speed.c | 302 +++++++++++++++++++++++++++++++++++----------------- - 1 file changed, 202 insertions(+), 100 deletions(-) - -diff --git a/tests/async_speed.c b/tests/async_speed.c -index 15ab80c..fff3414 100644 ---- a/tests/async_speed.c -+++ b/tests/async_speed.c -@@ -27,9 +27,45 @@ - #include - #include - #include -+#include -+#include - - #ifdef ENABLE_ASYNC - -+struct test_params { -+ bool tflag; -+ bool nflag; -+ int tvalue; -+ int nvalue; -+}; -+ -+const char usage_str[] = "Usage: %s [OPTION]... |\n" -+ "Run benchmark test for cipher or hash\n\n" -+ " -t \t" "time to run each test (default 10 secs)\n" -+ " -n \t" "size of the test buffer\n" -+ " -h\t\t" "show this help\n" -+; -+ -+int run_null(int fdc, struct test_params tp); -+int run_aes_cbc(int fdc, struct test_params tp); -+int run_aes_xts(int fdc, struct test_params tp); -+int run_crc32c(int fdc, struct test_params tp); -+int run_sha1(int fdc, struct test_params tp); -+int run_sha256(int fdc, struct test_params tp); -+ -+#define ALG_COUNT 6 -+struct { -+ char *name; -+ int (*func)(int, struct test_params); -+} ciphers[ALG_COUNT] = { -+ {"null", run_null}, -+ {"aes-cbc", run_aes_cbc}, -+ {"aes-xts", run_aes_xts}, -+ {"crc32c", run_crc32c}, -+ {"sha1", run_sha1}, -+ {"sha256", run_sha256}, -+}; -+ - static double udifftimeval(struct timeval start, struct timeval end) - { - return (double)(end.tv_usec - start.tv_usec) + -@@ -61,7 +97,7 @@ static void value2human(double bytes, double time, double* data, double* speed,c - } - - --int encrypt_data(struct session_op *sess, int fdc, int chunksize, int alignmask) -+int encrypt_data(int fdc, struct test_params tp, struct session_op *sess) - { - struct crypt_op cop; - char *buffer[64], iv[32]; -@@ -72,31 +108,33 @@ int encrypt_data(struct session_op *sess, int fdc, int chunksize, int alignmask) - double secs, ddata, dspeed; - char metric[16]; - int rc, wqueue = 0, bufidx = 0; -+ int alignmask; - - memset(iv, 0x23, 32); - -- printf("\tEncrypting in chunks of %d bytes: ", chunksize); -+ printf("\tEncrypting in chunks of %d bytes: ", tp.nvalue); - fflush(stdout); - -+ alignmask = get_alignmask(fdc, sess); - for (rc = 0; rc < 64; rc++) { - if (alignmask) { -- if (posix_memalign((void **)(buffer + rc), alignmask + 1, chunksize)) { -+ if (posix_memalign((void **)(buffer + rc), alignmask + 1, tp.nvalue)) { - printf("posix_memalign() failed!\n"); - return 1; - } - } else { -- if (!(buffer[rc] = malloc(chunksize))) { -+ if (!(buffer[rc] = malloc(tp.nvalue))) { - perror("malloc()"); - return 1; - } - } -- memset(buffer[rc], val++, chunksize); -+ memset(buffer[rc], val++, tp.nvalue); - } - pfd.fd = fdc; - pfd.events = POLLOUT | POLLIN; - - must_finish = 0; -- alarm(5); -+ alarm(tp.tvalue); - - gettimeofday(&start, NULL); - do { -@@ -111,7 +149,7 @@ int encrypt_data(struct session_op *sess, int fdc, int chunksize, int alignmask) - if (pfd.revents & POLLOUT) { - memset(&cop, 0, sizeof(cop)); - cop.ses = sess->ses; -- cop.len = chunksize; -+ cop.len = tp.nvalue; - cop.iv = (unsigned char *)iv; - cop.op = COP_ENCRYPT; - cop.src = cop.dst = (unsigned char *)buffer[bufidx]; -@@ -146,25 +184,75 @@ int encrypt_data(struct session_op *sess, int fdc, int chunksize, int alignmask) - return 0; - } - --int main(void) -+void usage(char *cmd_name) - { -- int fd, i, fdc = -1, alignmask = 0; -- struct session_op sess; --#ifdef CIOCGSESSINFO -- struct session_info_op siop; --#endif -- char keybuf[32]; -+ printf(usage_str, cmd_name); -+} - -- signal(SIGALRM, alarm_handler); -+int run_test(int id, struct test_params tp) -+{ -+ int fd; -+ int fdc; - -- if ((fd = open("/dev/crypto", O_RDWR, 0)) < 0) { -+ fd = open("/dev/crypto", O_RDWR, 0); -+ if (fd < 0) { - perror("open()"); -- return 1; -+ return fd; - } - if (ioctl(fd, CRIOGET, &fdc)) { - perror("ioctl(CRIOGET)"); -- return 1; -+ return -EINVAL; -+ } -+ -+ ciphers[id].func(fdc, tp); -+ -+ close(fdc); -+ close(fd); -+} -+ -+int get_alignmask(int fdc, struct session_op *sess) -+{ -+ int alignmask; -+ -+#ifdef CIOCGSESSINFO -+ struct session_info_op siop; -+ -+ siop.ses = sess->ses; -+ if (ioctl(fdc, CIOCGSESSINFO, &siop)) { -+ perror("ioctl(CIOCGSESSINFO)"); -+ return -EINVAL; -+ } -+ alignmask = siop.alignmask; -+#else -+ alignmask = 0; -+#endif -+ -+ return alignmask; -+} -+ -+void do_test_vectors(int fdc, struct test_params tp, struct session_op *sess) -+{ -+ int i; -+ -+ if (tp.nflag) { -+ encrypt_data(fdc, tp, sess); -+ } else { -+ for (i = 256; i <= (64 * 1024); i *= 2) { -+ tp.nvalue = i; -+ if (encrypt_data(fdc, tp, sess)) { -+ break; -+ } -+ } - } -+} -+ -+ -+int run_null(int fdc, struct test_params tp) -+{ -+ struct session_op sess; -+ char keybuf[32]; -+ int alignmask; -+ int i; - - fprintf(stderr, "Testing NULL cipher: \n"); - memset(&sess, 0, sizeof(sess)); -@@ -173,21 +261,19 @@ int main(void) - sess.key = (unsigned char *)keybuf; - if (ioctl(fdc, CIOCGSESSION, &sess)) { - perror("ioctl(CIOCGSESSION)"); -- return 1; -- } --#ifdef CIOCGSESSINFO -- siop.ses = sess.ses; -- if (ioctl(fdc, CIOCGSESSINFO, &siop)) { -- perror("ioctl(CIOCGSESSINFO)"); -- return 1; -+ return -EINVAL; - } -- alignmask = siop.alignmask; --#endif - -- for (i = 256; i <= (64 * 4096); i *= 2) { -- if (encrypt_data(&sess, fdc, i, alignmask)) -- break; -- } -+ do_test_vectors(fdc, tp, &sess); -+ return 0; -+} -+ -+int run_aes_cbc(int fdc, struct test_params tp) -+{ -+ struct session_op sess; -+ char keybuf[32]; -+ int alignmask; -+ int i; - - fprintf(stderr, "\nTesting AES-128-CBC cipher: \n"); - memset(&sess, 0, sizeof(sess)); -@@ -197,21 +283,17 @@ int main(void) - sess.key = (unsigned char *)keybuf; - if (ioctl(fdc, CIOCGSESSION, &sess)) { - perror("ioctl(CIOCGSESSION)"); -- return 1; -- } --#ifdef CIOCGSESSINFO -- siop.ses = sess.ses; -- if (ioctl(fdc, CIOCGSESSINFO, &siop)) { -- perror("ioctl(CIOCGSESSINFO)"); -- return 1; -+ return -EINVAL; - } -- alignmask = siop.alignmask; --#endif - -- for (i = 256; i <= (64 * 1024); i *= 2) { -- if (encrypt_data(&sess, fdc, i, alignmask)) -- break; -- } -+ do_test_vectors(fdc, tp, &sess); -+ return 0; -+} -+ -+int run_aes_xts(int fdc, struct test_params tp) -+{ -+ struct session_op sess; -+ char keybuf[32]; - - fprintf(stderr, "\nTesting AES-256-XTS cipher: \n"); - memset(&sess, 0, sizeof(sess)); -@@ -221,21 +303,16 @@ int main(void) - sess.key = (unsigned char *)keybuf; - if (ioctl(fdc, CIOCGSESSION, &sess)) { - perror("ioctl(CIOCGSESSION)"); -- return 1; -+ return -EINVAL; - } --#ifdef CIOCGSESSINFO -- siop.ses = sess.ses; -- if (ioctl(fdc, CIOCGSESSINFO, &siop)) { -- perror("ioctl(CIOCGSESSION)"); -- return 1; -- } -- alignmask = siop.alignmask; --#endif - -- for (i = 256; i <= (64 * 1024); i *= 2) { -- if (encrypt_data(&sess, fdc, i, alignmask)) -- break; -- } -+ do_test_vectors(fdc, tp, &sess); -+ return 0; -+} -+ -+int run_crc32c(int fdc, struct test_params tp) -+{ -+ struct session_op sess; - - fprintf(stderr, "\nTesting CRC32C hash: \n"); - memset(&sess, 0, sizeof(sess)); -@@ -244,21 +321,14 @@ int main(void) - perror("ioctl(CIOCGSESSION)"); - return 1; - } --#ifdef CIOCGSESSINFO -- siop.ses = sess.ses; -- if (ioctl(fdc, CIOCGSESSINFO, &siop)) { -- perror("ioctl(CIOCGSESSION)"); -- return 1; -- } -- printf("requested hash CRYPTO_CRC32C, got %s with driver %s\n", -- siop.hash_info.cra_name, siop.hash_info.cra_driver_name); -- alignmask = siop.alignmask; --#endif - -- for (i = 256; i <= (64 * 1024); i *= 2) { -- if (encrypt_data(&sess, fdc, i, alignmask)) -- break; -- } -+ do_test_vectors(fdc, tp, &sess); -+ return 0; -+} -+ -+int run_sha1(int fdc, struct test_params tp) -+{ -+ struct session_op sess; - - fprintf(stderr, "\nTesting SHA-1 hash: \n"); - memset(&sess, 0, sizeof(sess)); -@@ -267,21 +337,14 @@ int main(void) - perror("ioctl(CIOCGSESSION)"); - return 1; - } --#ifdef CIOCGSESSINFO -- siop.ses = sess.ses; -- if (ioctl(fdc, CIOCGSESSINFO, &siop)) { -- perror("ioctl(CIOCGSESSION)"); -- return 1; -- } -- printf("requested hash CRYPTO_SHA1, got %s with driver %s\n", -- siop.hash_info.cra_name, siop.hash_info.cra_driver_name); -- alignmask = siop.alignmask; --#endif - -- for (i = 256; i <= (64 * 1024); i *= 2) { -- if (encrypt_data(&sess, fdc, i, alignmask)) -- break; -- } -+ do_test_vectors(fdc, tp, &sess); -+ return 0; -+} -+ -+int run_sha256(int fdc, struct test_params tp) -+{ -+ struct session_op sess; - - fprintf(stderr, "\nTesting SHA2-256 hash: \n"); - memset(&sess, 0, sizeof(sess)); -@@ -290,25 +353,64 @@ int main(void) - perror("ioctl(CIOCGSESSION)"); - return 1; - } --#ifdef CIOCGSESSINFO -- siop.ses = sess.ses; -- if (ioctl(fdc, CIOCGSESSINFO, &siop)) { -- perror("ioctl(CIOCGSESSION)"); -- return 1; -- } -- printf("requested hash CRYPTO_SHA2_256, got %s with driver %s\n", -- siop.hash_info.cra_name, siop.hash_info.cra_driver_name); -- alignmask = siop.alignmask; --#endif - -- for (i = 256; i <= (64 * 1024); i *= 2) { -- if (encrypt_data(&sess, fdc, i, alignmask)) -+ do_test_vectors(fdc, tp, &sess); -+ return 0; -+} -+ -+int main(int argc, char **argv) -+{ -+ int i; -+ int c; -+ int index; -+ bool alg_flag; -+ char *alg_name; -+ struct test_params tp; -+ -+ tp.tflag = false; -+ tp.nflag = false; -+ alg_flag = false; -+ opterr = 0; -+ while ((c = getopt(argc, argv, "hn:t:")) != -1) { -+ switch (c) { -+ case 'n': -+ tp.nvalue = atoi(optarg); -+ tp.nflag = true; -+ break; -+ case 't': -+ tp.tvalue = atoi(optarg); -+ tp.tflag = true; - break; -+ case 'h': /* no break */ -+ default: -+ usage(argv[0]); -+ exit(1); -+ } -+ } -+ -+ /* the name of a specific test asked on the command line */ -+ if (optind < argc) { -+ alg_name = argv[optind]; -+ alg_flag = true; -+ } -+ -+ /* default test time */ -+ if (!tp.tflag) { -+ tp.tvalue = 5; -+ } -+ -+ signal(SIGALRM, alarm_handler); -+ -+ for (i = 0; i < ALG_COUNT; i++) { -+ if (alg_flag) { -+ if (strcmp(alg_name, ciphers[i].name) == 0) { -+ run_test(i, tp); -+ } -+ } else { -+ run_test(i, tp); -+ } - } - --end: -- close(fdc); -- close(fd); - return 0; - } - --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0051-enable-async-code-by-default.patch b/recipes-kernel/cryptodev/sdk_patches/0051-enable-async-code-by-default.patch deleted file mode 100644 index cfe4cd96..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0051-enable-async-code-by-default.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 6b31215e77b89fd7bd4dcfb6e4e3a9ee53e7731d Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Tue, 25 Oct 2016 15:03:19 +0300 -Subject: [PATCH 051/104] enable async code by default - -Signed-off-by: Cristian Stoica ---- - Makefile | 2 +- - tests/Makefile | 1 + - 2 files changed, 2 insertions(+), 1 deletion(-) - -diff --git a/Makefile b/Makefile -index 9871a8e..3934e1f 100644 ---- a/Makefile -+++ b/Makefile -@@ -3,7 +3,7 @@ - # disabled by default. To re-enable it uncomment the - # corresponding CFLAG. - # --CRYPTODEV_CFLAGS ?= #-DENABLE_ASYNC -+CRYPTODEV_CFLAGS += -DENABLE_ASYNC - KBUILD_CFLAGS += -I$(src) $(CRYPTODEV_CFLAGS) - KERNEL_DIR ?= /lib/modules/$(shell uname -r)/build - VERSION = 1.8 -diff --git a/tests/Makefile b/tests/Makefile -index 5e3111d..683f40b 100644 ---- a/tests/Makefile -+++ b/tests/Makefile -@@ -1,4 +1,5 @@ - KERNEL_DIR ?= /lib/modules/$(shell uname -r)/build -+CRYPTODEV_CFLAGS += -DENABLE_ASYNC - KBUILD_CFLAGS += -I.. $(CRYPTODEV_CFLAGS) - CFLAGS += -I.. $(CRYPTODEV_CFLAGS) - --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0052-add-flag-to-report-in-a-machine-friendly-format.patch b/recipes-kernel/cryptodev/sdk_patches/0052-add-flag-to-report-in-a-machine-friendly-format.patch deleted file mode 100644 index c2b88a59..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0052-add-flag-to-report-in-a-machine-friendly-format.patch +++ /dev/null @@ -1,55 +0,0 @@ -From 6d2e0927c2ed2795267d7652d9413d7e01da202e Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Tue, 25 Oct 2016 16:54:06 +0300 -Subject: [PATCH 052/104] add flag to report in a machine friendly format - -Signed-off-by: Cristian Stoica ---- - tests/async_speed.c | 8 +++++++- - 1 file changed, 7 insertions(+), 1 deletion(-) - -diff --git a/tests/async_speed.c b/tests/async_speed.c -index fff3414..1941750 100644 ---- a/tests/async_speed.c -+++ b/tests/async_speed.c -@@ -35,6 +35,7 @@ - struct test_params { - bool tflag; - bool nflag; -+ bool mflag; - int tvalue; - int nvalue; - }; -@@ -43,6 +44,7 @@ const char usage_str[] = "Usage: %s [OPTION]... |\n" - "Run benchmark test for cipher or hash\n\n" - " -t \t" "time to run each test (default 10 secs)\n" - " -n \t" "size of the test buffer\n" -+ " -m\t\t" "output in a machine readable format\n" - " -h\t\t" "show this help\n" - ; - -@@ -369,9 +371,10 @@ int main(int argc, char **argv) - - tp.tflag = false; - tp.nflag = false; -+ tp.mflag = false; - alg_flag = false; - opterr = 0; -- while ((c = getopt(argc, argv, "hn:t:")) != -1) { -+ while ((c = getopt(argc, argv, "hn:t:m")) != -1) { - switch (c) { - case 'n': - tp.nvalue = atoi(optarg); -@@ -381,6 +384,9 @@ int main(int argc, char **argv) - tp.tvalue = atoi(optarg); - tp.tflag = true; - break; -+ case 'm': -+ tp.mflag = true; -+ break; - case 'h': /* no break */ - default: - usage(argv[0]); --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0053-honor-the-m-flag-in-async_speed.patch b/recipes-kernel/cryptodev/sdk_patches/0053-honor-the-m-flag-in-async_speed.patch deleted file mode 100644 index 4653920d..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0053-honor-the-m-flag-in-async_speed.patch +++ /dev/null @@ -1,137 +0,0 @@ -From 9aae91f24b42a9a812cd0518c0c4ef3f548d64d1 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Tue, 25 Oct 2016 17:02:29 +0300 -Subject: [PATCH 053/104] honor the -m flag in async_speed - -Signed-off-by: Cristian Stoica ---- - tests/async_speed.c | 36 ++++++++++++++++++++++++------------ - 1 file changed, 24 insertions(+), 12 deletions(-) - -diff --git a/tests/async_speed.c b/tests/async_speed.c -index 1941750..73ec9d2 100644 ---- a/tests/async_speed.c -+++ b/tests/async_speed.c -@@ -29,6 +29,8 @@ - #include - #include - #include -+#include -+#include - - #ifdef ENABLE_ASYNC - -@@ -85,7 +87,7 @@ static void alarm_handler(int signo) - - static char *units[] = { "", "Ki", "Mi", "Gi", "Ti", 0}; - --static void value2human(double bytes, double time, double* data, double* speed,char* metric) -+static void value2human(uint64_t bytes, double time, double* data, double* speed,char* metric) - { - int unit = 0; - -@@ -98,6 +100,11 @@ static void value2human(double bytes, double time, double* data, double* speed,c - sprintf(metric, "%sB", units[unit]); - } - -+static void value2machine(uint64_t bytes, double time, double* speed) -+{ -+ *speed = bytes / time; -+} -+ - - int encrypt_data(int fdc, struct test_params tp, struct session_op *sess) - { -@@ -106,7 +113,7 @@ int encrypt_data(int fdc, struct test_params tp, struct session_op *sess) - char mac[64][HASH_MAX_LEN]; - static int val = 23; - struct timeval start, end; -- double total = 0; -+ uint64_t total = 0; - double secs, ddata, dspeed; - char metric[16]; - int rc, wqueue = 0, bufidx = 0; -@@ -114,8 +121,10 @@ int encrypt_data(int fdc, struct test_params tp, struct session_op *sess) - - memset(iv, 0x23, 32); - -- printf("\tEncrypting in chunks of %d bytes: ", tp.nvalue); -- fflush(stdout); -+ if (!tp.mflag) { -+ printf("\tBuffer size %d bytes: ", tp.nvalue); -+ fflush(stdout); -+ } - - alignmask = get_alignmask(fdc, sess); - for (rc = 0; rc < 64; rc++) { -@@ -177,9 +186,14 @@ int encrypt_data(int fdc, struct test_params tp, struct session_op *sess) - - secs = udifftimeval(start, end)/ 1000000.0; - -- value2human(total, secs, &ddata, &dspeed, metric); -- printf ("done. %.2f %s in %.2f secs: ", ddata, metric, secs); -- printf ("%.2f %s/sec\n", dspeed, metric); -+ if (tp.mflag) { -+ value2machine(total, secs, &dspeed); -+ printf("%" PRIu64 "\t%.2f\t%.2f\n", total, secs, dspeed); -+ } else { -+ value2human(total, secs, &ddata, &dspeed, metric); -+ printf ("done. %.2f %s in %.2f secs: ", ddata, metric, secs); -+ printf ("%.2f %s/sec\n", dspeed, metric); -+ } - - for (rc = 0; rc < 64; rc++) - free(buffer[rc]); -@@ -206,6 +220,9 @@ int run_test(int id, struct test_params tp) - return -EINVAL; - } - -+ if (!tp.mflag) { -+ fprintf(stderr, "Testing %s:\n", ciphers[id].name); -+ } - ciphers[id].func(fdc, tp); - - close(fdc); -@@ -277,7 +294,6 @@ int run_aes_cbc(int fdc, struct test_params tp) - int alignmask; - int i; - -- fprintf(stderr, "\nTesting AES-128-CBC cipher: \n"); - memset(&sess, 0, sizeof(sess)); - sess.cipher = CRYPTO_AES_CBC; - sess.keylen = 16; -@@ -297,7 +313,6 @@ int run_aes_xts(int fdc, struct test_params tp) - struct session_op sess; - char keybuf[32]; - -- fprintf(stderr, "\nTesting AES-256-XTS cipher: \n"); - memset(&sess, 0, sizeof(sess)); - sess.cipher = CRYPTO_AES_XTS; - sess.keylen = 32; -@@ -316,7 +331,6 @@ int run_crc32c(int fdc, struct test_params tp) - { - struct session_op sess; - -- fprintf(stderr, "\nTesting CRC32C hash: \n"); - memset(&sess, 0, sizeof(sess)); - sess.mac = CRYPTO_CRC32C; - if (ioctl(fdc, CIOCGSESSION, &sess)) { -@@ -332,7 +346,6 @@ int run_sha1(int fdc, struct test_params tp) - { - struct session_op sess; - -- fprintf(stderr, "\nTesting SHA-1 hash: \n"); - memset(&sess, 0, sizeof(sess)); - sess.mac = CRYPTO_SHA1; - if (ioctl(fdc, CIOCGSESSION, &sess)) { -@@ -348,7 +361,6 @@ int run_sha256(int fdc, struct test_params tp) - { - struct session_op sess; - -- fprintf(stderr, "\nTesting SHA2-256 hash: \n"); - memset(&sess, 0, sizeof(sess)); - sess.mac = CRYPTO_SHA2_256; - if (ioctl(fdc, CIOCGSESSION, &sess)) { --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0054-rename-algorithm-names-for-clarity.patch b/recipes-kernel/cryptodev/sdk_patches/0054-rename-algorithm-names-for-clarity.patch deleted file mode 100644 index 242f4a62..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0054-rename-algorithm-names-for-clarity.patch +++ /dev/null @@ -1,57 +0,0 @@ -From f71ba99a8943767c39df5104e86054c9c0e76fd8 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Tue, 25 Oct 2016 17:31:40 +0300 -Subject: [PATCH 054/104] rename algorithm names for clarity - -Signed-off-by: Cristian Stoica ---- - tests/async_speed.c | 12 ++++++------ - 1 file changed, 6 insertions(+), 6 deletions(-) - -diff --git a/tests/async_speed.c b/tests/async_speed.c -index 73ec9d2..263ead7 100644 ---- a/tests/async_speed.c -+++ b/tests/async_speed.c -@@ -51,8 +51,8 @@ const char usage_str[] = "Usage: %s [OPTION]... |\n" - ; - - int run_null(int fdc, struct test_params tp); --int run_aes_cbc(int fdc, struct test_params tp); --int run_aes_xts(int fdc, struct test_params tp); -+int run_aes_128_cbc(int fdc, struct test_params tp); -+int run_aes_256_xts(int fdc, struct test_params tp); - int run_crc32c(int fdc, struct test_params tp); - int run_sha1(int fdc, struct test_params tp); - int run_sha256(int fdc, struct test_params tp); -@@ -63,8 +63,8 @@ struct { - int (*func)(int, struct test_params); - } ciphers[ALG_COUNT] = { - {"null", run_null}, -- {"aes-cbc", run_aes_cbc}, -- {"aes-xts", run_aes_xts}, -+ {"aes-128-cbc", run_aes_128_cbc}, -+ {"aes-256-xts", run_aes_256_xts}, - {"crc32c", run_crc32c}, - {"sha1", run_sha1}, - {"sha256", run_sha256}, -@@ -287,7 +287,7 @@ int run_null(int fdc, struct test_params tp) - return 0; - } - --int run_aes_cbc(int fdc, struct test_params tp) -+int run_aes_128_cbc(int fdc, struct test_params tp) - { - struct session_op sess; - char keybuf[32]; -@@ -308,7 +308,7 @@ int run_aes_cbc(int fdc, struct test_params tp) - return 0; - } - --int run_aes_xts(int fdc, struct test_params tp) -+int run_aes_256_xts(int fdc, struct test_params tp) - { - struct session_op sess; - char keybuf[32]; --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0055-add-multithreaded-wrapper-for-async-speed-test.patch b/recipes-kernel/cryptodev/sdk_patches/0055-add-multithreaded-wrapper-for-async-speed-test.patch deleted file mode 100644 index 4129010b..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0055-add-multithreaded-wrapper-for-async-speed-test.patch +++ /dev/null @@ -1,173 +0,0 @@ -From 789d3c5ecda60a6dc5d5b3597047ad65c412f10d Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Tue, 25 Oct 2016 15:30:59 +0300 -Subject: [PATCH 055/104] add multithreaded wrapper for async speed test - -Signed-off-by: Cristian Stoica ---- - tests/Makefile | 1 + - tests/async_speed_multi.sh | 140 +++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 141 insertions(+) - create mode 100755 tests/async_speed_multi.sh - -diff --git a/tests/Makefile b/tests/Makefile -index 683f40b..6424c11 100644 ---- a/tests/Makefile -+++ b/tests/Makefile -@@ -40,6 +40,7 @@ install: - for prog in $(hostprogs); do \ - install -m 755 $$prog $(DESTDIR)/$(bindir)/tests_cryptodev/; \ - done -+ install -m 755 async_speed_multi.sh $(DESTDIR)/$(bindir) - - clean: - rm -f *.o *~ $(hostprogs) -diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh -new file mode 100755 -index 0000000..761c0cb ---- /dev/null -+++ b/tests/async_speed_multi.sh -@@ -0,0 +1,140 @@ -+#!/bin/bash -+# -+# Copyright 2016 NXP Semiconductors -+# -+# This program is free software: you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation, either version 2 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . -+ -+ -+ -+# no user-configurable options below this line -+ -+NUM_CORES=`nproc` -+OUT_BASENAME="async_speed" -+MPSTAT="mpstat" -+MPSTAT_OUT="mpstat_out" -+ -+function usage -+{ -+cat << EOF -+Usage: `basename $0` [OPTIONS] -+ -+ -m number of threads to run with (defaults to number of cores) -+ -t time to run each test (default 10 secs) -+ -n size of the test buffer (default 256 bytes) -+ -h show this help -+ -+alg_name: null, aes-128-cbc, aes-256-xts, sha1, sha256, crc32c -+EOF -+} -+ -+function SUM { -+ paste -sd+ - | bc -l -+} -+ -+function get_cpu_idle -+{ -+ header_line=`grep %idle ${MPSTAT_OUT} | head -n 1 | sed 's/\s\+/ /g'` -+ idle_column=`echo $header_line | wc -w` -+ -+ all_cpu_idle=`grep all ${MPSTAT_OUT} | tail -n +2 | sed 's/\s\+/ /g' | cut -d' ' -f ${idle_column} | SUM` -+ mpstat_lines=`grep all ${MPSTAT_OUT} | tail -n +2 | wc -l` -+ -+ average_idle=`echo "scale=2; $all_cpu_idle / $mpstat_lines" | bc -l` -+ echo $average_idle -+} -+ -+function run_parallel -+{ -+ trap control_c SIGINT -+ -+ OPTIONS="-t $tvalue -n $nvalue -m" -+ CMD="async_speed $OPTIONS $alg_name" -+ -+ echo "Running $mvalue threads in parallel:" -+ echo " $CMD" -+ -+ $MPSTAT 1 $(($tvalue-1)) &> $MPSTAT_OUT & -+ MPSTAT_PID=$! -+ -+ PIDS="" -+ start=`date +%s.%N` -+ -+ for i in `seq 0 $(($mvalue-1))` -+ do -+ CMD_OUT="${OUT_BASENAME}_${i}" -+ -+ $CMD &> $CMD_OUT & -+ PID=$! -+ AFFINITY=$(($i % $NUM_CORES)) -+ taskset -pc $AFFINITY $PID > /dev/null -+ -+ PIDS="$PID $PIDS" -+ done -+ -+ wait $PIDS -+ end=`date +%s.%N` -+ -+ wait $MPSTAT_PID -+ -+ runtime=$(echo "scale=2; $end - $start" | bc -l ) -+ total_data=`cat ${OUT_BASENAME}_* | cut -f 1 | SUM` -+ avg_speed=$(echo "scale=2; $total_data / $runtime / 1000000000" | bc -l) -+ cpu_idle=`get_cpu_idle` -+ -+ echo -+ echo "buffer size : $nvalue" -+ echo "running time : $runtime" -+ echo "avg_speed : $avg_speed GiB/s" -+ echo "all_cpu idle : $cpu_idle %" -+ echo -+} -+ -+function control_c -+{ -+ killall async_speed > /dev/null -+ killall mpstat > /dev/null -+} -+ -+function main -+{ -+ while getopts hm:t:n: option -+ do -+ case "$option" in -+ m) mvalue="$OPTARG";; -+ t) tvalue="$OPTARG";; -+ n) nvalue="$OPTARG";; -+ *) usage $0; exit 1;; -+ esac -+ done -+ -+ shift $((OPTIND-1)) -+ alg_name=$1 -+ -+ [ -z "$tvalue" ] && tvalue=10 # 10 seconds per test by default -+ [ -z "$mvalue" ] && mvalue=`nproc` # thread count defaults to nproc -+ [ -z "$nvalue" ] && nvalue=256 # 256 bytes default buffer size -+ -+ case "$alg_name" in -+ "null" |\ -+ "aes-128-cbc" |\ -+ "aes-256-xts" |\ -+ "sha1" |\ -+ "sha256" |\ -+ "crc32c" ) run_parallel;; -+ * ) usage && exit 1;; -+ esac -+} -+ -+main "$@" -+ --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0056-fix-set-min-value-when-allocating-alligned-memory-bu.patch b/recipes-kernel/cryptodev/sdk_patches/0056-fix-set-min-value-when-allocating-alligned-memory-bu.patch deleted file mode 100644 index d98e5887..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0056-fix-set-min-value-when-allocating-alligned-memory-bu.patch +++ /dev/null @@ -1,58 +0,0 @@ -From ad7fee26da24fca57efee5ba10756e001769b2ce Mon Sep 17 00:00:00 2001 -From: Alexe Radu -Date: Tue, 25 Oct 2016 16:46:11 +0300 -Subject: [PATCH 056/104] fix: set min value when allocating alligned memory - buffers - -The function "posix_memalign()" requires that the alignment be at least -sizeof(void*). In some situations the alignmask for some crypto algorithms -is smaller then the minimum required. For ex. on 64-bit platforms where -the alignment may be 4 bytes. - -Signed-off-by: Alexe Radu -Signed-off-by: Cristian Stoica ---- - tests/async_speed.c | 4 ++++ - tests/speed.c | 2 ++ - 2 files changed, 6 insertions(+) - -diff --git a/tests/async_speed.c b/tests/async_speed.c -index 263ead7..b895a85 100644 ---- a/tests/async_speed.c -+++ b/tests/async_speed.c -@@ -232,6 +232,7 @@ int run_test(int id, struct test_params tp) - int get_alignmask(int fdc, struct session_op *sess) - { - int alignmask; -+ int min_alignmask = sizeof(void*) - 1; - - #ifdef CIOCGSESSINFO - struct session_info_op siop; -@@ -242,6 +243,9 @@ int get_alignmask(int fdc, struct session_op *sess) - return -EINVAL; - } - alignmask = siop.alignmask; -+ if (alignmask < min_alignmask) { -+ alignmask = min_alignmask; -+ } - #else - alignmask = 0; - #endif -diff --git a/tests/speed.c b/tests/speed.c -index bd6d2b2..0b14c88 100644 ---- a/tests/speed.c -+++ b/tests/speed.c -@@ -80,8 +80,10 @@ int encrypt_data(struct session_op *sess, int fdc, int chunksize, int alignmask) - double total = 0; - double secs, ddata, dspeed; - char metric[16]; -+ int min_alignmask = sizeof(void*) - 1; - - if (alignmask) { -+ alignmask = ((alignmask < min_alignmask) ? min_alignmask : alignmask); - if (posix_memalign((void **)&buffer, MAX(alignmask + 1, sizeof(void*)), chunksize)) { - printf("posix_memalign() failed! (mask %x, size: %d)\n", alignmask+1, chunksize); - return 1; --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0057-gracefull-stop-for-async-speed-tests.patch b/recipes-kernel/cryptodev/sdk_patches/0057-gracefull-stop-for-async-speed-tests.patch deleted file mode 100644 index 5ba0578a..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0057-gracefull-stop-for-async-speed-tests.patch +++ /dev/null @@ -1,64 +0,0 @@ -From f7e3566382bf22fc73c5a0edfde5c5349a92f8ea Mon Sep 17 00:00:00 2001 -From: Alexe Radu -Date: Tue, 25 Oct 2016 18:35:13 +0300 -Subject: [PATCH 057/104] gracefull stop for async speed tests - -Signed-off-by: Alexe Radu -Signed-off-by: Cristian Stoica ---- - tests/async_speed.c | 16 ++++++++++++++++ - 1 file changed, 16 insertions(+) - -diff --git a/tests/async_speed.c b/tests/async_speed.c -index b895a85..e6bbeed 100644 ---- a/tests/async_speed.c -+++ b/tests/async_speed.c -@@ -77,6 +77,7 @@ static double udifftimeval(struct timeval start, struct timeval end) - } - - static int must_finish = 0; -+static int must_exit = 0; - static struct pollfd pfd; - - static void alarm_handler(int signo) -@@ -85,6 +86,12 @@ static void alarm_handler(int signo) - pfd.events = POLLIN; - } - -+static void exit_handler(int signo) -+{ -+ must_exit = 1; -+ printf("\nexit requested by user through ctrl+c \n"); -+} -+ - static char *units[] = { "", "Ki", "Mi", "Gi", "Ti", 0}; - - static void value2human(uint64_t bytes, double time, double* data, double* speed,char* metric) -@@ -261,6 +268,10 @@ void do_test_vectors(int fdc, struct test_params tp, struct session_op *sess) - encrypt_data(fdc, tp, sess); - } else { - for (i = 256; i <= (64 * 1024); i *= 2) { -+ if (must_exit) { -+ break; -+ } -+ - tp.nvalue = i; - if (encrypt_data(fdc, tp, sess)) { - break; -@@ -422,8 +433,13 @@ int main(int argc, char **argv) - } - - signal(SIGALRM, alarm_handler); -+ signal(SIGINT, exit_handler); - - for (i = 0; i < ALG_COUNT; i++) { -+ if (must_exit) { -+ break; -+ } -+ - if (alg_flag) { - if (strcmp(alg_name, ciphers[i].name) == 0) { - run_test(i, tp); --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0058-sanity-check-on-dev-crypto-availability.patch b/recipes-kernel/cryptodev/sdk_patches/0058-sanity-check-on-dev-crypto-availability.patch deleted file mode 100644 index 62733301..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0058-sanity-check-on-dev-crypto-availability.patch +++ /dev/null @@ -1,26 +0,0 @@ -From b04d0b7ccb9150d4f16c712a830f8a4e3bdd2d05 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Wed, 26 Oct 2016 09:29:36 +0300 -Subject: [PATCH 058/104] sanity check on /dev/crypto availability - -Signed-off-by: Cristian Stoica ---- - tests/async_speed_multi.sh | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh -index 761c0cb..94c2312 100755 ---- a/tests/async_speed_multi.sh -+++ b/tests/async_speed_multi.sh -@@ -108,6 +108,8 @@ function control_c - - function main - { -+ [ ! -e "/dev/crypto" ] && sudo modprobe cryptodev || modprobe cryptodev || exit 1 -+ - while getopts hm:t:n: option - do - case "$option" in --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0059-fix-some-issues-with-parsing-mpstat-output.patch b/recipes-kernel/cryptodev/sdk_patches/0059-fix-some-issues-with-parsing-mpstat-output.patch deleted file mode 100644 index fd2fedad..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0059-fix-some-issues-with-parsing-mpstat-output.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 28c87b3dd5ed2ac90185b09bdc7233648d5d89b5 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Wed, 26 Oct 2016 09:14:28 +0300 -Subject: [PATCH 059/104] fix some issues with parsing mpstat output - -- mpstat with 'count' parameter will average the results for us on the - last line so we don't need to do this ourselves. -- set time format to ISO to avoid incorrect parsing of the header line - -Signed-off-by: Cristian Stoica ---- - tests/async_speed_multi.sh | 7 +++---- - 1 file changed, 3 insertions(+), 4 deletions(-) - -diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh -index 94c2312..a28f72d 100755 ---- a/tests/async_speed_multi.sh -+++ b/tests/async_speed_multi.sh -@@ -21,6 +21,7 @@ - - NUM_CORES=`nproc` - OUT_BASENAME="async_speed" -+S_TIME_FORMAT=ISO - MPSTAT="mpstat" - MPSTAT_OUT="mpstat_out" - -@@ -47,10 +48,8 @@ function get_cpu_idle - header_line=`grep %idle ${MPSTAT_OUT} | head -n 1 | sed 's/\s\+/ /g'` - idle_column=`echo $header_line | wc -w` - -- all_cpu_idle=`grep all ${MPSTAT_OUT} | tail -n +2 | sed 's/\s\+/ /g' | cut -d' ' -f ${idle_column} | SUM` -- mpstat_lines=`grep all ${MPSTAT_OUT} | tail -n +2 | wc -l` -- -- average_idle=`echo "scale=2; $all_cpu_idle / $mpstat_lines" | bc -l` -+ average_idle=`grep Average ${MPSTAT_OUT} | sed 's/\s\+/ /g' | cut -d' ' -f ${idle_column} | tail -n 1` -+ - echo $average_idle - } - --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0060-more-precision-in-running-mpstat.patch b/recipes-kernel/cryptodev/sdk_patches/0060-more-precision-in-running-mpstat.patch deleted file mode 100644 index ae749bdc..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0060-more-precision-in-running-mpstat.patch +++ /dev/null @@ -1,55 +0,0 @@ -From 26291db7df602d3d3d5601817229822b13904fe9 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Wed, 26 Oct 2016 09:48:44 +0300 -Subject: [PATCH 060/104] more precision in running mpstat - -Start mpstat one second later than the tests so we don't measure -transient issues. Likewise, stop mpstat just before the tests terminate -so we don't record incorrect CPU idle. - -Signed-off-by: Cristian Stoica ---- - tests/async_speed_multi.sh | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh -index a28f72d..5268c86 100755 ---- a/tests/async_speed_multi.sh -+++ b/tests/async_speed_multi.sh -@@ -22,7 +22,6 @@ - NUM_CORES=`nproc` - OUT_BASENAME="async_speed" - S_TIME_FORMAT=ISO --MPSTAT="mpstat" - MPSTAT_OUT="mpstat_out" - - function usage -@@ -47,7 +46,6 @@ function get_cpu_idle - { - header_line=`grep %idle ${MPSTAT_OUT} | head -n 1 | sed 's/\s\+/ /g'` - idle_column=`echo $header_line | wc -w` -- - average_idle=`grep Average ${MPSTAT_OUT} | sed 's/\s\+/ /g' | cut -d' ' -f ${idle_column} | tail -n 1` - - echo $average_idle -@@ -63,7 +61,7 @@ function run_parallel - echo "Running $mvalue threads in parallel:" - echo " $CMD" - -- $MPSTAT 1 $(($tvalue-1)) &> $MPSTAT_OUT & -+ (sleep 1; mpstat 1 $(($tvalue-2))) &> $MPSTAT_OUT & - MPSTAT_PID=$! - - PIDS="" -@@ -126,6 +124,8 @@ function main - [ -z "$mvalue" ] && mvalue=`nproc` # thread count defaults to nproc - [ -z "$nvalue" ] && nvalue=256 # 256 bytes default buffer size - -+ [ "$tvalue" -lt 5 ] && tvalue=5 -+ - case "$alg_name" in - "null" |\ - "aes-128-cbc" |\ --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0061-add-a-little-space-in-the-output-for-clarity.patch b/recipes-kernel/cryptodev/sdk_patches/0061-add-a-little-space-in-the-output-for-clarity.patch deleted file mode 100644 index 9e3ec848..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0061-add-a-little-space-in-the-output-for-clarity.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 3bfdd0d1991a37c1adc82cc7e1938e2d9d175bd7 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Wed, 26 Oct 2016 10:01:57 +0300 -Subject: [PATCH 061/104] add a little space in the output for clarity - -Signed-off-by: Cristian Stoica ---- - tests/async_speed_multi.sh | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh -index 5268c86..331158b 100755 ---- a/tests/async_speed_multi.sh -+++ b/tests/async_speed_multi.sh -@@ -58,7 +58,8 @@ function run_parallel - OPTIONS="-t $tvalue -n $nvalue -m" - CMD="async_speed $OPTIONS $alg_name" - -- echo "Running $mvalue threads in parallel:" -+ echo -+ echo "Running $tvalue seconds $mvalue threads in parallel:" - echo " $CMD" - - (sleep 1; mpstat 1 $(($tvalue-2))) &> $MPSTAT_OUT & --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0062-fix-build-warnings-on-implicit-function-declarations.patch b/recipes-kernel/cryptodev/sdk_patches/0062-fix-build-warnings-on-implicit-function-declarations.patch deleted file mode 100644 index dba2575f..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0062-fix-build-warnings-on-implicit-function-declarations.patch +++ /dev/null @@ -1,129 +0,0 @@ -From 0fd37b5225bd26182b20588b200a4fc0a3f415e5 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Wed, 26 Oct 2016 10:10:47 +0300 -Subject: [PATCH 062/104] fix build warnings on implicit function declarations - -Signed-off-by: Cristian Stoica ---- - tests/Makefile | 2 +- - tests/async_speed.c | 47 +++++++++++++++++++++++------------------------ - tests/hashcrypt_speed.c | 1 + - tests/sha_speed.c | 1 + - tests/speed.c | 1 + - 5 files changed, 27 insertions(+), 25 deletions(-) - -diff --git a/tests/Makefile b/tests/Makefile -index 6424c11..14ae2c7 100644 ---- a/tests/Makefile -+++ b/tests/Makefile -@@ -1,5 +1,5 @@ - KERNEL_DIR ?= /lib/modules/$(shell uname -r)/build --CRYPTODEV_CFLAGS += -DENABLE_ASYNC -+CRYPTODEV_CFLAGS += -DENABLE_ASYNC -Wimplicit-function-declaration - KBUILD_CFLAGS += -I.. $(CRYPTODEV_CFLAGS) - CFLAGS += -I.. $(CRYPTODEV_CFLAGS) - -diff --git a/tests/async_speed.c b/tests/async_speed.c -index e6bbeed..a1a1b7e 100644 ---- a/tests/async_speed.c -+++ b/tests/async_speed.c -@@ -112,6 +112,29 @@ static void value2machine(uint64_t bytes, double time, double* speed) - *speed = bytes / time; - } - -+int get_alignmask(int fdc, struct session_op *sess) -+{ -+ int alignmask; -+ int min_alignmask = sizeof(void*) - 1; -+ -+#ifdef CIOCGSESSINFO -+ struct session_info_op siop; -+ -+ siop.ses = sess->ses; -+ if (ioctl(fdc, CIOCGSESSINFO, &siop)) { -+ perror("ioctl(CIOCGSESSINFO)"); -+ return -EINVAL; -+ } -+ alignmask = siop.alignmask; -+ if (alignmask < min_alignmask) { -+ alignmask = min_alignmask; -+ } -+#else -+ alignmask = 0; -+#endif -+ -+ return alignmask; -+} - - int encrypt_data(int fdc, struct test_params tp, struct session_op *sess) - { -@@ -236,30 +259,6 @@ int run_test(int id, struct test_params tp) - close(fd); - } - --int get_alignmask(int fdc, struct session_op *sess) --{ -- int alignmask; -- int min_alignmask = sizeof(void*) - 1; -- --#ifdef CIOCGSESSINFO -- struct session_info_op siop; -- -- siop.ses = sess->ses; -- if (ioctl(fdc, CIOCGSESSINFO, &siop)) { -- perror("ioctl(CIOCGSESSINFO)"); -- return -EINVAL; -- } -- alignmask = siop.alignmask; -- if (alignmask < min_alignmask) { -- alignmask = min_alignmask; -- } --#else -- alignmask = 0; --#endif -- -- return alignmask; --} -- - void do_test_vectors(int fdc, struct test_params tp, struct session_op *sess) - { - int i; -diff --git a/tests/hashcrypt_speed.c b/tests/hashcrypt_speed.c -index e60b73d..045bf8e 100644 ---- a/tests/hashcrypt_speed.c -+++ b/tests/hashcrypt_speed.c -@@ -25,6 +25,7 @@ - #include - #include - #include -+#include - #include - - #define MAX(x,y) ((x)>(y)?(x):(y)) -diff --git a/tests/sha_speed.c b/tests/sha_speed.c -index 75d0f42..e5c6efe 100644 ---- a/tests/sha_speed.c -+++ b/tests/sha_speed.c -@@ -25,6 +25,7 @@ - #include - #include - #include -+#include - - #include - -diff --git a/tests/speed.c b/tests/speed.c -index 0b14c88..d2e1aed 100644 ---- a/tests/speed.c -+++ b/tests/speed.c -@@ -24,6 +24,7 @@ - #include - #include - #include -+#include - - #include - --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0063-avoid-implicit-conversion-between-signed-and-unsigne.patch b/recipes-kernel/cryptodev/sdk_patches/0063-avoid-implicit-conversion-between-signed-and-unsigne.patch deleted file mode 100644 index 133d46c1..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0063-avoid-implicit-conversion-between-signed-and-unsigne.patch +++ /dev/null @@ -1,698 +0,0 @@ -From 5f3a9153f7685f6dde29f7cd2d58534126c5b9af Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Wed, 26 Oct 2016 10:45:40 +0300 -Subject: [PATCH 063/104] avoid implicit conversion between signed and unsigned - char - -Signed-off-by: Cristian Stoica ---- - tests/async_cipher.c | 36 ++++++++++++++-------------- - tests/async_hmac.c | 8 +++---- - tests/async_speed.c | 2 +- - tests/cipher-aead-srtp.c | 50 +++++++++++++++++++------------------- - tests/cipher-aead.c | 48 ++++++++++++++++++------------------- - tests/cipher-gcm.c | 62 ++++++++++++++++++++++++------------------------ - tests/cipher.c | 35 ++++++++++++++------------- - tests/cipher_comp.c | 12 +++++----- - tests/fullspeed.c | 3 ++- - tests/hash_comp.c | 8 +++---- - tests/hmac.c | 8 +++---- - tests/speed.c | 3 ++- - 12 files changed, 138 insertions(+), 137 deletions(-) - -diff --git a/tests/async_cipher.c b/tests/async_cipher.c -index 162a695..dd08403 100644 ---- a/tests/async_cipher.c -+++ b/tests/async_cipher.c -@@ -9,7 +9,7 @@ - #include - #include - #include -- -+#include - #include - #include - -@@ -26,10 +26,10 @@ static int debug = 0; - static int - test_crypto(int cfd) - { -- char plaintext_raw[DATA_SIZE + 63], *plaintext; -- char ciphertext_raw[DATA_SIZE + 63], *ciphertext; -- char iv[BLOCK_SIZE]; -- char key[KEY_SIZE]; -+ uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; -+ uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; -+ uint8_t iv[BLOCK_SIZE]; -+ uint8_t key[KEY_SIZE]; - - struct session_op sess; - #ifdef CIOCGSESSINFO -@@ -62,8 +62,8 @@ test_crypto(int cfd) - perror("ioctl(CIOCGSESSINFO)"); - return 1; - } -- plaintext = (char *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); -- ciphertext = (char *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); -+ plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); -+ ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); - #else - plaintext = plaintext_raw; - ciphertext = ciphertext_raw; -@@ -127,15 +127,15 @@ test_crypto(int cfd) - - static int test_aes(int cfd) - { -- char plaintext1_raw[BLOCK_SIZE + 63], *plaintext1; -- char ciphertext1[BLOCK_SIZE] = { 0xdf, 0x55, 0x6a, 0x33, 0x43, 0x8d, 0xb8, 0x7b, 0xc4, 0x1b, 0x17, 0x52, 0xc5, 0x5e, 0x5e, 0x49 }; -- char iv1[BLOCK_SIZE]; -- char key1[KEY_SIZE] = { 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -- char plaintext2_data[BLOCK_SIZE] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00 }; -- char plaintext2_raw[BLOCK_SIZE + 63], *plaintext2; -- char ciphertext2[BLOCK_SIZE] = { 0xb7, 0x97, 0x2b, 0x39, 0x41, 0xc4, 0x4b, 0x90, 0xaf, 0xa7, 0xb2, 0x64, 0xbf, 0xba, 0x73, 0x87 }; -- char iv2[BLOCK_SIZE]; -- char key2[KEY_SIZE]; -+ uint8_t plaintext1_raw[BLOCK_SIZE + 63], *plaintext1; -+ uint8_t ciphertext1[BLOCK_SIZE] = { 0xdf, 0x55, 0x6a, 0x33, 0x43, 0x8d, 0xb8, 0x7b, 0xc4, 0x1b, 0x17, 0x52, 0xc5, 0x5e, 0x5e, 0x49 }; -+ uint8_t iv1[BLOCK_SIZE]; -+ uint8_t key1[KEY_SIZE] = { 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -+ uint8_t plaintext2_data[BLOCK_SIZE] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00 }; -+ uint8_t plaintext2_raw[BLOCK_SIZE + 63], *plaintext2; -+ uint8_t ciphertext2[BLOCK_SIZE] = { 0xb7, 0x97, 0x2b, 0x39, 0x41, 0xc4, 0x4b, 0x90, 0xaf, 0xa7, 0xb2, 0x64, 0xbf, 0xba, 0x73, 0x87 }; -+ uint8_t iv2[BLOCK_SIZE]; -+ uint8_t key2[KEY_SIZE]; - - struct session_op sess1, sess2; - #ifdef CIOCGSESSINFO -@@ -162,7 +162,7 @@ static int test_aes(int cfd) - perror("ioctl(CIOCGSESSINFO)"); - return 1; - } -- plaintext1 = (char *)(((unsigned long)plaintext1_raw + siop1.alignmask) & ~siop1.alignmask); -+ plaintext1 = (uint8_t *)(((unsigned long)plaintext1_raw + siop1.alignmask) & ~siop1.alignmask); - #else - plaintext1 = plaintext1_raw; - #endif -@@ -185,7 +185,7 @@ static int test_aes(int cfd) - perror("ioctl(CIOCGSESSINFO)"); - return 1; - } -- plaintext2 = (char *)(((unsigned long)plaintext2_raw + siop2.alignmask) & ~siop2.alignmask); -+ plaintext2 = (uint8_t *)(((unsigned long)plaintext2_raw + siop2.alignmask) & ~siop2.alignmask); - #else - plaintext2 = plaintext2_raw; - #endif -diff --git a/tests/async_hmac.c b/tests/async_hmac.c -index 97fd0c5..94a02c0 100644 ---- a/tests/async_hmac.c -+++ b/tests/async_hmac.c -@@ -61,7 +61,7 @@ test_crypto(int cfd) - - cryp.ses = sess.ses; - cryp.len = sizeof("what do ya want for nothing?")-1; -- cryp.src = "what do ya want for nothing?"; -+ cryp.src = (uint8_t*)"what do ya want for nothing?"; - cryp.mac = mac; - cryp.op = COP_ENCRYPT; - -@@ -98,7 +98,7 @@ test_crypto(int cfd) - - cryp.ses = sess.ses; - cryp.len = sizeof("what do ya want for nothing?")-1; -- cryp.src = "what do ya want for nothing?"; -+ cryp.src = (uint8_t*)"what do ya want for nothing?"; - cryp.mac = mac; - cryp.op = COP_ENCRYPT; - -@@ -208,7 +208,7 @@ test_extras(int cfd) - - cryp.ses = sess.ses; - cryp.len = sizeof("what do")-1; -- cryp.src = "what do"; -+ cryp.src = (uint8_t*)"what do"; - cryp.mac = mac; - cryp.op = COP_ENCRYPT; - cryp.flags = COP_FLAG_UPDATE; -@@ -218,7 +218,7 @@ test_extras(int cfd) - - cryp.ses = sess.ses; - cryp.len = sizeof(" ya want for nothing?")-1; -- cryp.src = " ya want for nothing?"; -+ cryp.src = (uint8_t*)" ya want for nothing?"; - cryp.mac = mac; - cryp.op = COP_ENCRYPT; - cryp.flags = COP_FLAG_FINAL; -diff --git a/tests/async_speed.c b/tests/async_speed.c -index a1a1b7e..dabbbc1 100644 ---- a/tests/async_speed.c -+++ b/tests/async_speed.c -@@ -140,7 +140,7 @@ int encrypt_data(int fdc, struct test_params tp, struct session_op *sess) - { - struct crypt_op cop; - char *buffer[64], iv[32]; -- char mac[64][HASH_MAX_LEN]; -+ uint8_t mac[64][HASH_MAX_LEN]; - static int val = 23; - struct timeval start, end; - uint64_t total = 0; -diff --git a/tests/cipher-aead-srtp.c b/tests/cipher-aead-srtp.c -index fae04e7..c44877d 100644 ---- a/tests/cipher-aead-srtp.c -+++ b/tests/cipher-aead-srtp.c -@@ -77,13 +77,13 @@ int i; - static int - test_crypto(int cfd) - { -- char plaintext_raw[DATA_SIZE + 63], *plaintext; -- char ciphertext_raw[DATA_SIZE + 63], *ciphertext; -- char iv[BLOCK_SIZE]; -- char key[KEY_SIZE]; -- unsigned char sha1mac[20]; -- unsigned char tag[20]; -- unsigned char mackey[] = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; -+ uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; -+ uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; -+ uint8_t iv[BLOCK_SIZE]; -+ uint8_t key[KEY_SIZE]; -+ uint8_t sha1mac[20]; -+ uint8_t tag[20]; -+ uint8_t mackey[] = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; - int mackey_len = 16; - - struct session_op sess; -@@ -122,8 +122,8 @@ test_crypto(int cfd) - printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", - siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); - -- plaintext = (char *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); -- ciphertext = (char *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); -+ plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); -+ ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); - - memset(plaintext, 0x15, HEADER_SIZE); /* header */ - memset(&plaintext[HEADER_SIZE], 0x17, PLAINTEXT_SIZE); /* payload */ -@@ -225,12 +225,12 @@ test_crypto(int cfd) - static int - test_encrypt_decrypt(int cfd) - { -- char plaintext_raw[DATA_SIZE + 63], *plaintext; -- char ciphertext_raw[DATA_SIZE + 63], *ciphertext; -- char iv[BLOCK_SIZE]; -- char key[KEY_SIZE]; -- unsigned char tag[20]; -- unsigned char mackey[] = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; -+ uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; -+ uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; -+ uint8_t iv[BLOCK_SIZE]; -+ uint8_t key[KEY_SIZE]; -+ uint8_t tag[20]; -+ uint8_t mackey[] = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; - int mackey_len = 16; - - struct session_op sess; -@@ -265,8 +265,8 @@ test_encrypt_decrypt(int cfd) - // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", - // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); - -- plaintext = (char *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); -- ciphertext = (char *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); -+ plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); -+ ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); - - memset(plaintext, 0x15, HEADER_SIZE); /* header */ - memset(&plaintext[HEADER_SIZE], 0x17, PLAINTEXT_SIZE); /* payload */ -@@ -367,12 +367,12 @@ test_encrypt_decrypt(int cfd) - static int - test_encrypt_decrypt_error(int cfd, int err) - { -- char plaintext_raw[DATA_SIZE + 63], *plaintext; -- char ciphertext_raw[DATA_SIZE + 63], *ciphertext; -- char iv[BLOCK_SIZE]; -- char key[KEY_SIZE]; -- unsigned char tag[20]; -- unsigned char mackey[] = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; -+ uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; -+ uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; -+ uint8_t iv[BLOCK_SIZE]; -+ uint8_t key[KEY_SIZE]; -+ uint8_t tag[20]; -+ uint8_t mackey[] = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; - int mackey_len = 16; - - struct session_op sess; -@@ -407,8 +407,8 @@ test_encrypt_decrypt_error(int cfd, int err) - // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", - // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); - -- plaintext = (char *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); -- ciphertext = (char *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); -+ plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); -+ ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); - - memset(plaintext, 0x15, HEADER_SIZE); /* header */ - memset(&plaintext[HEADER_SIZE], 0x17, PLAINTEXT_SIZE); /* payload */ -diff --git a/tests/cipher-aead.c b/tests/cipher-aead.c -index 164327f..da43aa6 100644 ---- a/tests/cipher-aead.c -+++ b/tests/cipher-aead.c -@@ -89,12 +89,12 @@ int i; - static int - test_crypto(int cfd) - { -- char plaintext_raw[DATA_SIZE + 63], *plaintext; -- char ciphertext_raw[DATA_SIZE + 63], *ciphertext; -- char iv[BLOCK_SIZE]; -- char key[KEY_SIZE]; -- char auth[AUTH_SIZE]; -- unsigned char sha1mac[20]; -+ uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; -+ uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; -+ uint8_t iv[BLOCK_SIZE]; -+ uint8_t key[KEY_SIZE]; -+ uint8_t auth[AUTH_SIZE]; -+ uint8_t sha1mac[20]; - int pad, i; - - struct session_op sess; -@@ -133,8 +133,8 @@ test_crypto(int cfd) - printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", - siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); - -- plaintext = (char *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); -- ciphertext = (char *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); -+ plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); -+ ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); - memset(plaintext, 0x15, DATA_SIZE); - - if (get_sha1_hmac(cfd, sess.mackey, sess.mackeylen, auth, sizeof(auth), plaintext, DATA_SIZE, sha1mac) != 0) { -@@ -242,12 +242,12 @@ test_crypto(int cfd) - static int - test_encrypt_decrypt(int cfd) - { -- char plaintext_raw[DATA_SIZE + 63], *plaintext; -- char ciphertext_raw[DATA_SIZE + 63], *ciphertext; -- char iv[BLOCK_SIZE]; -- char key[KEY_SIZE]; -- char auth[AUTH_SIZE]; -- unsigned char sha1mac[20]; -+ uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; -+ uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; -+ uint8_t iv[BLOCK_SIZE]; -+ uint8_t key[KEY_SIZE]; -+ uint8_t auth[AUTH_SIZE]; -+ uint8_t sha1mac[20]; - int enc_len; - - struct session_op sess; -@@ -285,8 +285,8 @@ test_encrypt_decrypt(int cfd) - // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", - // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); - -- plaintext = (char *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); -- ciphertext = (char *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); -+ plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); -+ ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); - - memset(plaintext, 0x15, DATA_SIZE); - -@@ -391,12 +391,12 @@ test_encrypt_decrypt(int cfd) - static int - test_encrypt_decrypt_error(int cfd, int err) - { -- char plaintext_raw[DATA_SIZE + 63], *plaintext; -- char ciphertext_raw[DATA_SIZE + 63], *ciphertext; -- char iv[BLOCK_SIZE]; -- char key[KEY_SIZE]; -- char auth[AUTH_SIZE]; -- unsigned char sha1mac[20]; -+ uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; -+ uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; -+ uint8_t iv[BLOCK_SIZE]; -+ uint8_t key[KEY_SIZE]; -+ uint8_t auth[AUTH_SIZE]; -+ uint8_t sha1mac[20]; - int enc_len; - - struct session_op sess; -@@ -434,8 +434,8 @@ test_encrypt_decrypt_error(int cfd, int err) - // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", - // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); - -- plaintext = (char *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); -- ciphertext = (char *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); -+ plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); -+ ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); - memset(plaintext, 0x15, DATA_SIZE); - - if (get_sha1_hmac(cfd, sess.mackey, sess.mackeylen, auth, sizeof(auth), plaintext, DATA_SIZE, sha1mac) != 0) { -diff --git a/tests/cipher-gcm.c b/tests/cipher-gcm.c -index dfc3d84..3f6cc7b 100644 ---- a/tests/cipher-gcm.c -+++ b/tests/cipher-gcm.c -@@ -45,45 +45,45 @@ struct aes_gcm_vectors_st { - - struct aes_gcm_vectors_st aes_gcm_vectors[] = { - { -- .key = -+ .key = (uint8_t*) - "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", - .auth = NULL, - .auth_size = 0, -- .plaintext = -+ .plaintext = (uint8_t*) - "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", - .plaintext_size = 16, -- .ciphertext = -+ .ciphertext = (uint8_t*) - "\x03\x88\xda\xce\x60\xb6\xa3\x92\xf3\x28\xc2\xb9\x71\xb2\xfe\x78", -- .iv = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", -- .tag = -+ .iv = (uint8_t*)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", -+ .tag = (uint8_t*) - "\xab\x6e\x47\xd4\x2c\xec\x13\xbd\xf5\x3a\x67\xb2\x12\x57\xbd\xdf" - }, - { -- .key = -+ .key = (uint8_t*) - "\xfe\xff\xe9\x92\x86\x65\x73\x1c\x6d\x6a\x8f\x94\x67\x30\x83\x08", - .auth = NULL, - .auth_size = 0, -- .plaintext = -+ .plaintext = (uint8_t*) - "\xd9\x31\x32\x25\xf8\x84\x06\xe5\xa5\x59\x09\xc5\xaf\xf5\x26\x9a\x86\xa7\xa9\x53\x15\x34\xf7\xda\x2e\x4c\x30\x3d\x8a\x31\x8a\x72\x1c\x3c\x0c\x95\x95\x68\x09\x53\x2f\xcf\x0e\x24\x49\xa6\xb5\x25\xb1\x6a\xed\xf5\xaa\x0d\xe6\x57\xba\x63\x7b\x39\x1a\xaf\xd2\x55", - .plaintext_size = 64, -- .ciphertext = -+ .ciphertext = (uint8_t*) - "\x42\x83\x1e\xc2\x21\x77\x74\x24\x4b\x72\x21\xb7\x84\xd0\xd4\x9c\xe3\xaa\x21\x2f\x2c\x02\xa4\xe0\x35\xc1\x7e\x23\x29\xac\xa1\x2e\x21\xd5\x14\xb2\x54\x66\x93\x1c\x7d\x8f\x6a\x5a\xac\x84\xaa\x05\x1b\xa3\x0b\x39\x6a\x0a\xac\x97\x3d\x58\xe0\x91\x47\x3f\x59\x85", -- .iv = "\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88", -- .tag = "\x4d\x5c\x2a\xf3\x27\xcd\x64\xa6\x2c\xf3\x5a\xbd\x2b\xa6\xfa\xb4" -+ .iv = (uint8_t*)"\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88", -+ .tag = (uint8_t*)"\x4d\x5c\x2a\xf3\x27\xcd\x64\xa6\x2c\xf3\x5a\xbd\x2b\xa6\xfa\xb4" - }, - { -- .key = -+ .key = (uint8_t*) - "\xfe\xff\xe9\x92\x86\x65\x73\x1c\x6d\x6a\x8f\x94\x67\x30\x83\x08", -- .auth = -+ .auth = (uint8_t*) - "\xfe\xed\xfa\xce\xde\xad\xbe\xef\xfe\xed\xfa\xce\xde\xad\xbe\xef\xab\xad\xda\xd2", - .auth_size = 20, -- .plaintext = -+ .plaintext = (uint8_t*) - "\xd9\x31\x32\x25\xf8\x84\x06\xe5\xa5\x59\x09\xc5\xaf\xf5\x26\x9a\x86\xa7\xa9\x53\x15\x34\xf7\xda\x2e\x4c\x30\x3d\x8a\x31\x8a\x72\x1c\x3c\x0c\x95\x95\x68\x09\x53\x2f\xcf\x0e\x24\x49\xa6\xb5\x25\xb1\x6a\xed\xf5\xaa\x0d\xe6\x57\xba\x63\x7b\x39", - .plaintext_size = 60, -- .ciphertext = -+ .ciphertext = (uint8_t*) - "\x42\x83\x1e\xc2\x21\x77\x74\x24\x4b\x72\x21\xb7\x84\xd0\xd4\x9c\xe3\xaa\x21\x2f\x2c\x02\xa4\xe0\x35\xc1\x7e\x23\x29\xac\xa1\x2e\x21\xd5\x14\xb2\x54\x66\x93\x1c\x7d\x8f\x6a\x5a\xac\x84\xaa\x05\x1b\xa3\x0b\x39\x6a\x0a\xac\x97\x3d\x58\xe0\x91", -- .iv = "\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88", -- .tag = -+ .iv = (uint8_t*)"\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88", -+ .tag = (uint8_t*) - "\x5b\xc9\x4f\xbc\x32\x21\xa5\xdb\x94\xfa\xe9\x5a\xe7\x12\x1a\x47" - } - }; -@@ -94,7 +94,7 @@ struct aes_gcm_vectors_st aes_gcm_vectors[] = { - static int test_crypto(int cfd) - { - int i; -- int8_t tmp[128]; -+ uint8_t tmp[128]; - - struct session_op sess; - struct crypt_auth_op cao; -@@ -191,11 +191,11 @@ static int test_crypto(int cfd) - */ - static int test_encrypt_decrypt(int cfd) - { -- char plaintext_raw[DATA_SIZE + 63], *plaintext; -- char ciphertext_raw[DATA_SIZE + 63], *ciphertext; -- char iv[BLOCK_SIZE]; -- char key[KEY_SIZE]; -- char auth[AUTH_SIZE]; -+ uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; -+ uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; -+ uint8_t iv[BLOCK_SIZE]; -+ uint8_t key[KEY_SIZE]; -+ uint8_t auth[AUTH_SIZE]; - int enc_len; - - struct session_op sess; -@@ -233,10 +233,10 @@ static int test_encrypt_decrypt(int cfd) - // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); - - plaintext = -- (char *) (((unsigned long) plaintext_raw + siop.alignmask) & -+ (uint8_t *) (((unsigned long) plaintext_raw + siop.alignmask) & - ~siop.alignmask); - ciphertext = -- (char *) (((unsigned long) ciphertext_raw + siop.alignmask) & -+ (uint8_t *) (((unsigned long) ciphertext_raw + siop.alignmask) & - ~siop.alignmask); - - memset(plaintext, 0x15, DATA_SIZE); -@@ -336,11 +336,11 @@ static int test_encrypt_decrypt(int cfd) - - static int test_encrypt_decrypt_error(int cfd, int err) - { -- char plaintext_raw[DATA_SIZE + 63], *plaintext; -- char ciphertext_raw[DATA_SIZE + 63], *ciphertext; -- char iv[BLOCK_SIZE]; -- char key[KEY_SIZE]; -- char auth[AUTH_SIZE]; -+ uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; -+ uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; -+ uint8_t iv[BLOCK_SIZE]; -+ uint8_t key[KEY_SIZE]; -+ uint8_t auth[AUTH_SIZE]; - int enc_len; - - struct session_op sess; -@@ -386,10 +386,10 @@ static int test_encrypt_decrypt_error(int cfd, int err) - // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); - - plaintext = -- (char *) (((unsigned long) plaintext_raw + siop.alignmask) & -+ (uint8_t *) (((unsigned long) plaintext_raw + siop.alignmask) & - ~siop.alignmask); - ciphertext = -- (char *) (((unsigned long) ciphertext_raw + siop.alignmask) & -+ (uint8_t *) (((unsigned long) ciphertext_raw + siop.alignmask) & - ~siop.alignmask); - - memset(plaintext, 0x15, DATA_SIZE); -diff --git a/tests/cipher.c b/tests/cipher.c -index 07144f2..f3ca2f0 100644 ---- a/tests/cipher.c -+++ b/tests/cipher.c -@@ -8,6 +8,7 @@ - #include - #include - #include -+#include - - #include - #include -@@ -21,10 +22,10 @@ static int debug = 0; - static int - test_crypto(int cfd) - { -- char plaintext_raw[DATA_SIZE + 63], *plaintext; -- char ciphertext_raw[DATA_SIZE + 63], *ciphertext; -- char iv[BLOCK_SIZE]; -- char key[KEY_SIZE]; -+ uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; -+ uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; -+ uint8_t iv[BLOCK_SIZE]; -+ uint8_t key[KEY_SIZE]; - - struct session_op sess; - #ifdef CIOCGSESSINFO -@@ -57,8 +58,8 @@ test_crypto(int cfd) - printf("requested cipher CRYPTO_AES_CBC, got %s with driver %s\n", - siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); - -- plaintext = (char *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); -- ciphertext = (char *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); -+ plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); -+ ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); - #else - plaintext = plaintext_raw; - ciphertext = ciphertext_raw; -@@ -143,15 +144,15 @@ test_crypto(int cfd) - - static int test_aes(int cfd) - { -- char plaintext1_raw[BLOCK_SIZE + 63], *plaintext1; -- char ciphertext1[BLOCK_SIZE] = { 0xdf, 0x55, 0x6a, 0x33, 0x43, 0x8d, 0xb8, 0x7b, 0xc4, 0x1b, 0x17, 0x52, 0xc5, 0x5e, 0x5e, 0x49 }; -- char iv1[BLOCK_SIZE]; -- char key1[KEY_SIZE] = { 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -- char plaintext2_data[BLOCK_SIZE] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00 }; -- char plaintext2_raw[BLOCK_SIZE + 63], *plaintext2; -- char ciphertext2[BLOCK_SIZE] = { 0xb7, 0x97, 0x2b, 0x39, 0x41, 0xc4, 0x4b, 0x90, 0xaf, 0xa7, 0xb2, 0x64, 0xbf, 0xba, 0x73, 0x87 }; -- char iv2[BLOCK_SIZE]; -- char key2[KEY_SIZE]; -+ uint8_t plaintext1_raw[BLOCK_SIZE + 63], *plaintext1; -+ uint8_t ciphertext1[BLOCK_SIZE] = { 0xdf, 0x55, 0x6a, 0x33, 0x43, 0x8d, 0xb8, 0x7b, 0xc4, 0x1b, 0x17, 0x52, 0xc5, 0x5e, 0x5e, 0x49 }; -+ uint8_t iv1[BLOCK_SIZE]; -+ uint8_t key1[KEY_SIZE] = { 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; -+ uint8_t plaintext2_data[BLOCK_SIZE] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00 }; -+ uint8_t plaintext2_raw[BLOCK_SIZE + 63], *plaintext2; -+ uint8_t ciphertext2[BLOCK_SIZE] = { 0xb7, 0x97, 0x2b, 0x39, 0x41, 0xc4, 0x4b, 0x90, 0xaf, 0xa7, 0xb2, 0x64, 0xbf, 0xba, 0x73, 0x87 }; -+ uint8_t iv2[BLOCK_SIZE]; -+ uint8_t key2[KEY_SIZE]; - - struct session_op sess; - #ifdef CIOCGSESSINFO -@@ -176,7 +177,7 @@ static int test_aes(int cfd) - perror("ioctl(CIOCGSESSINFO)"); - return 1; - } -- plaintext1 = (char *)(((unsigned long)plaintext1_raw + siop.alignmask) & ~siop.alignmask); -+ plaintext1 = (uint8_t *)(((unsigned long)plaintext1_raw + siop.alignmask) & ~siop.alignmask); - #else - plaintext1 = plaintext1_raw; - #endif -@@ -226,7 +227,7 @@ static int test_aes(int cfd) - printf("requested cipher CRYPTO_AES_CBC, got %s with driver %s\n", - siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); - -- plaintext2 = (char *)(((unsigned long)plaintext2_raw + siop.alignmask) & ~siop.alignmask); -+ plaintext2 = (uint8_t *)(((unsigned long)plaintext2_raw + siop.alignmask) & ~siop.alignmask); - #else - plaintext2 = plaintext2_raw; - #endif -diff --git a/tests/cipher_comp.c b/tests/cipher_comp.c -index b2bc5af..03f67bf 100644 ---- a/tests/cipher_comp.c -+++ b/tests/cipher_comp.c -@@ -24,12 +24,12 @@ - static int - test_crypto(int cfd, struct session_op *sess, int datalen) - { -- char *data, *encrypted; -- char *encrypted_comp; -+ uint8_t *data, *encrypted; -+ uint8_t *encrypted_comp; - -- char iv_in[BLOCK_SIZE]; -- char iv[BLOCK_SIZE]; -- char iv_comp[BLOCK_SIZE]; -+ uint8_t iv_in[BLOCK_SIZE]; -+ uint8_t iv[BLOCK_SIZE]; -+ uint8_t iv_comp[BLOCK_SIZE]; - - struct crypt_op cryp; - -@@ -90,7 +90,7 @@ main(int argc, char **argv) - { - int fd; - struct session_op sess; -- unsigned char key[KEY_SIZE]; -+ uint8_t key[KEY_SIZE]; - int datalen = BLOCK_SIZE; - int datalen_end = MAX_DATALEN; - int i; -diff --git a/tests/fullspeed.c b/tests/fullspeed.c -index 611859d..c025130 100644 ---- a/tests/fullspeed.c -+++ b/tests/fullspeed.c -@@ -25,6 +25,7 @@ - #include - #include - #include -+#include - - #include - -@@ -74,7 +75,7 @@ static void value2human(int si, double bytes, double time, double* data, double* - int encrypt_data(int algo, void* keybuf, int key_size, int fdc, int chunksize) - { - struct crypt_op cop; -- char *buffer, iv[32]; -+ uint8_t *buffer, iv[32]; - static int val = 23; - struct timeval start, end; - double total = 0; -diff --git a/tests/hash_comp.c b/tests/hash_comp.c -index 9e700a1..e6a4346 100644 ---- a/tests/hash_comp.c -+++ b/tests/hash_comp.c -@@ -30,11 +30,9 @@ static void printhex(unsigned char *buf, int buflen) - static int - test_crypto(int cfd, struct session_op *sess, int datalen) - { -- unsigned char *data; -- -- unsigned char mac[AALG_MAX_RESULT_LEN]; -- -- unsigned char mac_comp[AALG_MAX_RESULT_LEN]; -+ uint8_t *data; -+ uint8_t mac[AALG_MAX_RESULT_LEN]; -+ uint8_t mac_comp[AALG_MAX_RESULT_LEN]; - - struct crypt_op cryp; - -diff --git a/tests/hmac.c b/tests/hmac.c -index 1d9349e..80a2c42 100644 ---- a/tests/hmac.c -+++ b/tests/hmac.c -@@ -69,7 +69,7 @@ test_crypto(int cfd) - - cryp.ses = sess.ses; - cryp.len = sizeof("what do ya want for nothing?")-1; -- cryp.src = "what do ya want for nothing?"; -+ cryp.src = (uint8_t*)"what do ya want for nothing?"; - cryp.mac = mac; - cryp.op = COP_ENCRYPT; - if (ioctl(cfd, CIOCCRYPT, &cryp)) { -@@ -113,7 +113,7 @@ test_crypto(int cfd) - - cryp.ses = sess.ses; - cryp.len = sizeof("what do ya want for nothing?")-1; -- cryp.src = "what do ya want for nothing?"; -+ cryp.src = (uint8_t*)"what do ya want for nothing?"; - cryp.mac = mac; - cryp.op = COP_ENCRYPT; - if (ioctl(cfd, CIOCCRYPT, &cryp)) { -@@ -246,7 +246,7 @@ test_extras(int cfd) - - cryp.ses = sess.ses; - cryp.len = sizeof("what do")-1; -- cryp.src = "what do"; -+ cryp.src = (uint8_t*)"what do"; - cryp.mac = mac; - cryp.op = COP_ENCRYPT; - cryp.flags = COP_FLAG_UPDATE; -@@ -257,7 +257,7 @@ test_extras(int cfd) - - cryp.ses = sess.ses; - cryp.len = sizeof(" ya want for nothing?")-1; -- cryp.src = " ya want for nothing?"; -+ cryp.src = (uint8_t*)" ya want for nothing?"; - cryp.mac = mac; - cryp.op = COP_ENCRYPT; - cryp.flags = COP_FLAG_FINAL; -diff --git a/tests/speed.c b/tests/speed.c -index d2e1aed..0e2bbc3 100644 ---- a/tests/speed.c -+++ b/tests/speed.c -@@ -25,6 +25,7 @@ - #include - #include - #include -+#include - - #include - -@@ -75,7 +76,7 @@ int encrypt_data(struct session_op *sess, int fdc, int chunksize, int alignmask) - { - struct crypt_op cop; - char *buffer, iv[32]; -- char mac[HASH_MAX_LEN]; -+ uint8_t mac[HASH_MAX_LEN]; - static int val = 23; - struct timeval start, end; - double total = 0; --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0064-remove-not-used-local-variables.patch b/recipes-kernel/cryptodev/sdk_patches/0064-remove-not-used-local-variables.patch deleted file mode 100644 index 24eac13e..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0064-remove-not-used-local-variables.patch +++ /dev/null @@ -1,129 +0,0 @@ -From c31ba5b149428cbbcd48fab649331a2d38003209 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Wed, 26 Oct 2016 10:47:07 +0300 -Subject: [PATCH 064/104] remove not used local variables - -Signed-off-by: Cristian Stoica ---- - tests/async_hmac.c | 2 -- - tests/async_speed.c | 5 ----- - tests/cipher_comp.c | 2 +- - tests/hash_comp.c | 5 ++--- - tests/hmac.c | 2 -- - tests/sha_speed.c | 1 - - 6 files changed, 3 insertions(+), 14 deletions(-) - -diff --git a/tests/async_hmac.c b/tests/async_hmac.c -index 94a02c0..85d19c6 100644 ---- a/tests/async_hmac.c -+++ b/tests/async_hmac.c -@@ -185,8 +185,6 @@ test_extras(int cfd) - struct session_op sess; - struct crypt_op cryp; - uint8_t mac[AALG_MAX_RESULT_LEN]; -- uint8_t oldmac[AALG_MAX_RESULT_LEN]; -- uint8_t md5_hmac_out[] = "\x75\x0c\x78\x3e\x6a\xb0\xb5\x03\xea\xa8\x6e\x31\x0a\x5d\xb7\x38"; - uint8_t sha1_out[] = "\x8f\x82\x03\x94\xf9\x53\x35\x18\x20\x45\xda\x24\xf3\x4d\xe5\x2b\xf8\xbc\x34\x32"; - int i; - -diff --git a/tests/async_speed.c b/tests/async_speed.c -index dabbbc1..f2b9772 100644 ---- a/tests/async_speed.c -+++ b/tests/async_speed.c -@@ -284,8 +284,6 @@ int run_null(int fdc, struct test_params tp) - { - struct session_op sess; - char keybuf[32]; -- int alignmask; -- int i; - - fprintf(stderr, "Testing NULL cipher: \n"); - memset(&sess, 0, sizeof(sess)); -@@ -305,8 +303,6 @@ int run_aes_128_cbc(int fdc, struct test_params tp) - { - struct session_op sess; - char keybuf[32]; -- int alignmask; -- int i; - - memset(&sess, 0, sizeof(sess)); - sess.cipher = CRYPTO_AES_CBC; -@@ -390,7 +386,6 @@ int main(int argc, char **argv) - { - int i; - int c; -- int index; - bool alg_flag; - char *alg_name; - struct test_params tp; -diff --git a/tests/cipher_comp.c b/tests/cipher_comp.c -index 03f67bf..dbf9977 100644 ---- a/tests/cipher_comp.c -+++ b/tests/cipher_comp.c -@@ -33,7 +33,7 @@ test_crypto(int cfd, struct session_op *sess, int datalen) - - struct crypt_op cryp; - -- int ret = 0, fail = 0; -+ int ret = 0; - - data = malloc(datalen); - encrypted = malloc(datalen); -diff --git a/tests/hash_comp.c b/tests/hash_comp.c -index e6a4346..73f85ed 100644 ---- a/tests/hash_comp.c -+++ b/tests/hash_comp.c -@@ -36,7 +36,7 @@ test_crypto(int cfd, struct session_op *sess, int datalen) - - struct crypt_op cryp; - -- int ret = 0, fail = 0; -+ int ret = 0; - - data = malloc(datalen); - memset(data, datalen & 0xff, datalen); -@@ -66,7 +66,7 @@ test_crypto(int cfd, struct session_op *sess, int datalen) - - if (memcmp(mac, mac_comp, AALG_MAX_RESULT_LEN)) { - printf("fail for datalen %d, MACs do not match!\n", datalen); -- fail = 1; -+ ret = 1; - printf("wrong mac: "); - printhex(mac, 20); - printf("right mac: "); -@@ -88,7 +88,6 @@ main(int argc, char **argv) - struct session_op sess; - int datalen = BLOCK_SIZE; - int datalen_end = MAX_DATALEN; -- int i; - - if (argc > 1) { - datalen = min(max(atoi(argv[1]), BLOCK_SIZE), MAX_DATALEN); -diff --git a/tests/hmac.c b/tests/hmac.c -index 80a2c42..3b248f3 100644 ---- a/tests/hmac.c -+++ b/tests/hmac.c -@@ -212,8 +212,6 @@ test_extras(int cfd) - #endif - struct crypt_op cryp; - uint8_t mac[AALG_MAX_RESULT_LEN]; -- uint8_t oldmac[AALG_MAX_RESULT_LEN]; -- uint8_t md5_hmac_out[] = "\x75\x0c\x78\x3e\x6a\xb0\xb5\x03\xea\xa8\x6e\x31\x0a\x5d\xb7\x38"; - uint8_t sha1_out[] = "\x8f\x82\x03\x94\xf9\x53\x35\x18\x20\x45\xda\x24\xf3\x4d\xe5\x2b\xf8\xbc\x34\x32"; - int i; - -diff --git a/tests/sha_speed.c b/tests/sha_speed.c -index e5c6efe..9f2c8cc 100644 ---- a/tests/sha_speed.c -+++ b/tests/sha_speed.c -@@ -296,7 +296,6 @@ int main(void) - int fd; - int fdc; - int err; -- int i; - struct session_op sess; - - signal(SIGALRM, alarm_handler); --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0065-return-error-code-of-the-test-if-there-is-one.patch b/recipes-kernel/cryptodev/sdk_patches/0065-return-error-code-of-the-test-if-there-is-one.patch deleted file mode 100644 index 27752374..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0065-return-error-code-of-the-test-if-there-is-one.patch +++ /dev/null @@ -1,68 +0,0 @@ -From 58da37b93d2532e489514b810c63d735a165ff09 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Wed, 26 Oct 2016 10:47:58 +0300 -Subject: [PATCH 065/104] return error code of the test if there is one - -Signed-off-by: Cristian Stoica ---- - tests/async_speed.c | 15 +++++++++++---- - 1 file changed, 11 insertions(+), 4 deletions(-) - -diff --git a/tests/async_speed.c b/tests/async_speed.c -index f2b9772..d843c02 100644 ---- a/tests/async_speed.c -+++ b/tests/async_speed.c -@@ -239,6 +239,7 @@ int run_test(int id, struct test_params tp) - { - int fd; - int fdc; -+ int err; - - fd = open("/dev/crypto", O_RDWR, 0); - if (fd < 0) { -@@ -253,10 +254,12 @@ int run_test(int id, struct test_params tp) - if (!tp.mflag) { - fprintf(stderr, "Testing %s:\n", ciphers[id].name); - } -- ciphers[id].func(fdc, tp); -+ err = ciphers[id].func(fdc, tp); - - close(fdc); - close(fd); -+ -+ return err; - } - - void do_test_vectors(int fdc, struct test_params tp, struct session_op *sess) -@@ -384,6 +387,7 @@ int run_sha256(int fdc, struct test_params tp) - - int main(int argc, char **argv) - { -+ int err = 0; - int i; - int c; - bool alg_flag; -@@ -436,14 +440,17 @@ int main(int argc, char **argv) - - if (alg_flag) { - if (strcmp(alg_name, ciphers[i].name) == 0) { -- run_test(i, tp); -+ err = run_test(i, tp); - } - } else { -- run_test(i, tp); -+ err = run_test(i, tp); -+ if (err != 0) { -+ break; -+ } - } - } - -- return 0; -+ return err; - } - - #else --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0066-do-more-strict-code-checking-to-avoid-maintenance-is.patch b/recipes-kernel/cryptodev/sdk_patches/0066-do-more-strict-code-checking-to-avoid-maintenance-is.patch deleted file mode 100644 index 3255dd81..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0066-do-more-strict-code-checking-to-avoid-maintenance-is.patch +++ /dev/null @@ -1,25 +0,0 @@ -From af792c280ec5d76f473487cd1ed9335a6ec534de Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Wed, 26 Oct 2016 10:49:36 +0300 -Subject: [PATCH 066/104] do more strict code checking to avoid maintenance - issues - -Signed-off-by: Cristian Stoica ---- - tests/Makefile | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/tests/Makefile b/tests/Makefile -index 14ae2c7..a27cf9b 100644 ---- a/tests/Makefile -+++ b/tests/Makefile -@@ -1,5 +1,5 @@ - KERNEL_DIR ?= /lib/modules/$(shell uname -r)/build --CRYPTODEV_CFLAGS += -DENABLE_ASYNC -Wimplicit-function-declaration -+CRYPTODEV_CFLAGS += -DENABLE_ASYNC -Wall -Werror - KBUILD_CFLAGS += -I.. $(CRYPTODEV_CFLAGS) - CFLAGS += -I.. $(CRYPTODEV_CFLAGS) - --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0067-fix-issues-with-install-target.patch b/recipes-kernel/cryptodev/sdk_patches/0067-fix-issues-with-install-target.patch deleted file mode 100644 index e60e90a9..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0067-fix-issues-with-install-target.patch +++ /dev/null @@ -1,52 +0,0 @@ -From bd36f9cda9fb5eeebec23cc966a81e93b4fa8bf7 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Wed, 26 Oct 2016 12:53:11 +0300 -Subject: [PATCH 067/104] fix issues with install target - -Aparently, on some setups, 'sudo make' will clear the $PWD variable -on the first Makefile expansion. This leads to failures of "sudo make -install" or other issues when trying to preserve the environment with -sudo -E. - -There are two solutions to this problem: -1) Use $$PWD instead of $(PWD) to render `$PWD` as the actual string to -be used on the secondary Makefile expansion. -This is used (albeit inconsistently) in the Linux kernel guide for -external modules: -kernel https://www.kernel.org/doc/Documentation/kbuild/modules.txt - -2) A second solution is based on GNU make which sets CURDIR to the -pathname of current working directory. This variable is never touched -again by make. -This solution is choosen for it is just as clear as the PWD one would -have been had it worked in the first place. - -Signed-off-by: Cristian Stoica - - - ---- a/Makefileold 2017-04-18 13:55:30.740561749 +0800 -+++ b/Makefile 2017-04-18 13:58:04.348556431 +0800 -@@ -15,7 +15,7 @@ - - obj-m += cryptodev.o - --KERNEL_MAKE_OPTS := -C $(KERNEL_DIR) M=$(PWD) -+KERNEL_MAKE_OPTS := -C $(KERNEL_DIR) M=$(CURDIR) - ifneq ($(ARCH),) - KERNEL_MAKE_OPTS += ARCH=$(ARCH) - endif -@@ -32,11 +32,11 @@ - install: modules_install - - modules_install: -- $(MAKE) -C $(KERNEL_DIR) M=$(PWD) modules_install -+ $(MAKE) $(KERNEL_MAKE_OPTS) modules_install - install -m 644 -D crypto/cryptodev.h $(DESTDIR)/$(includedir)/crypto/cryptodev.h - - clean: -- $(MAKE) -C $(KERNEL_DIR) M=$(PWD) clean -+ $(MAKE) $(KERNEL_MAKE_OPTS) clean - rm -f $(hostprogs) *~ - CFLAGS=$(CRYPTODEV_CFLAGS) KERNEL_DIR=$(KERNEL_DIR) $(MAKE) -C tests clean - diff --git a/recipes-kernel/cryptodev/sdk_patches/0068-setting-KERNEL_DIR-is-not-necessary-to-build-tests.patch b/recipes-kernel/cryptodev/sdk_patches/0068-setting-KERNEL_DIR-is-not-necessary-to-build-tests.patch deleted file mode 100644 index 07156a6f..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0068-setting-KERNEL_DIR-is-not-necessary-to-build-tests.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 39f0c5ae656f4b487a0950235e2371e4dd840594 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Wed, 26 Oct 2016 13:11:11 +0300 -Subject: [PATCH 068/104] setting KERNEL_DIR is not necessary to build tests - -Signed-off-by: Cristian Stoica ---- - tests/Makefile | 2 -- - 1 file changed, 2 deletions(-) - -diff --git a/tests/Makefile b/tests/Makefile -index a27cf9b..e7a60cb 100644 ---- a/tests/Makefile -+++ b/tests/Makefile -@@ -1,6 +1,4 @@ --KERNEL_DIR ?= /lib/modules/$(shell uname -r)/build - CRYPTODEV_CFLAGS += -DENABLE_ASYNC -Wall -Werror --KBUILD_CFLAGS += -I.. $(CRYPTODEV_CFLAGS) - CFLAGS += -I.. $(CRYPTODEV_CFLAGS) - - comp_progs := cipher_comp hash_comp hmac_comp --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0069-fix-the-reported-unit.patch b/recipes-kernel/cryptodev/sdk_patches/0069-fix-the-reported-unit.patch deleted file mode 100644 index 91a3c0db..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0069-fix-the-reported-unit.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 99ce54741ccbbe8581ab83b73ab11d2dae4f01b1 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Wed, 26 Oct 2016 14:55:28 +0300 -Subject: [PATCH 069/104] fix the reported unit - -1GiB = 1024*1024*1024 -1GB = 1000000000 - -Signed-off-by: Cristian Stoica ---- - tests/async_speed_multi.sh | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh -index 331158b..bf5f1c6 100755 ---- a/tests/async_speed_multi.sh -+++ b/tests/async_speed_multi.sh -@@ -93,7 +93,7 @@ function run_parallel - echo - echo "buffer size : $nvalue" - echo "running time : $runtime" -- echo "avg_speed : $avg_speed GiB/s" -+ echo "avg_speed : $avg_speed GB/s" - echo "all_cpu idle : $cpu_idle %" - echo - } --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0070-remove-old-results-to-avoid-incorrect-reports.patch b/recipes-kernel/cryptodev/sdk_patches/0070-remove-old-results-to-avoid-incorrect-reports.patch deleted file mode 100644 index 270b69e1..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0070-remove-old-results-to-avoid-incorrect-reports.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 73748415251dbf3d6e3fc9531e38b8e61ff63e20 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Wed, 26 Oct 2016 15:09:04 +0300 -Subject: [PATCH 070/104] remove old results to avoid incorrect reports - -Signed-off-by: Cristian Stoica ---- - tests/async_speed_multi.sh | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh -index bf5f1c6..10b2348 100755 ---- a/tests/async_speed_multi.sh -+++ b/tests/async_speed_multi.sh -@@ -108,6 +108,9 @@ function main - { - [ ! -e "/dev/crypto" ] && sudo modprobe cryptodev || modprobe cryptodev || exit 1 - -+ rm -f ${OUT_BASENAME}_* -+ rm -f ${MPSTAT_OUT} -+ - while getopts hm:t:n: option - do - case "$option" in --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0071-fix-the-scale-of-the-runtime-value.patch b/recipes-kernel/cryptodev/sdk_patches/0071-fix-the-scale-of-the-runtime-value.patch deleted file mode 100644 index f52e09a8..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0071-fix-the-scale-of-the-runtime-value.patch +++ /dev/null @@ -1,29 +0,0 @@ -From d9de6a0f342b2291e2f2d82b594fbb3b8ed7f468 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Thu, 27 Oct 2016 09:29:24 +0300 -Subject: [PATCH 071/104] fix the scale of the runtime value - -Subtraction operation does not honor the scale variable. Only -division does. - -Signed-off-by: Cristian Stoica ---- - tests/async_speed_multi.sh | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh -index 10b2348..659be0e 100755 ---- a/tests/async_speed_multi.sh -+++ b/tests/async_speed_multi.sh -@@ -85,7 +85,7 @@ function run_parallel - - wait $MPSTAT_PID - -- runtime=$(echo "scale=2; $end - $start" | bc -l ) -+ runtime=$(echo "scale=2; ($end - $start) / 1" | bc -l ) - total_data=`cat ${OUT_BASENAME}_* | cut -f 1 | SUM` - avg_speed=$(echo "scale=2; $total_data / $runtime / 1000000000" | bc -l) - cpu_idle=`get_cpu_idle` --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0072-use-.-instead-of-.-for-consistency.patch b/recipes-kernel/cryptodev/sdk_patches/0072-use-.-instead-of-.-for-consistency.patch deleted file mode 100644 index 0cf2a0c2..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0072-use-.-instead-of-.-for-consistency.patch +++ /dev/null @@ -1,82 +0,0 @@ -From abcf5983f6d69c5ff35e77fb79ea7afe2149411a Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Thu, 27 Oct 2016 09:33:11 +0300 -Subject: [PATCH 072/104] use $(...) instead of `...` for consistency - -Signed-off-by: Cristian Stoica ---- - tests/async_speed_multi.sh | 24 ++++++++++++------------ - 1 file changed, 12 insertions(+), 12 deletions(-) - -diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh -index 659be0e..e10dc0d 100755 ---- a/tests/async_speed_multi.sh -+++ b/tests/async_speed_multi.sh -@@ -19,7 +19,7 @@ - - # no user-configurable options below this line - --NUM_CORES=`nproc` -+NUM_CORES=$(nproc) - OUT_BASENAME="async_speed" - S_TIME_FORMAT=ISO - MPSTAT_OUT="mpstat_out" -@@ -44,9 +44,9 @@ function SUM { - - function get_cpu_idle - { -- header_line=`grep %idle ${MPSTAT_OUT} | head -n 1 | sed 's/\s\+/ /g'` -- idle_column=`echo $header_line | wc -w` -- average_idle=`grep Average ${MPSTAT_OUT} | sed 's/\s\+/ /g' | cut -d' ' -f ${idle_column} | tail -n 1` -+ header_line=$(grep %idle ${MPSTAT_OUT} | head -n 1 | sed 's/\s\+/ /g') -+ idle_column=$(echo $header_line | wc -w) -+ average_idle=$(grep Average ${MPSTAT_OUT} | sed 's/\s\+/ /g' | cut -d' ' -f ${idle_column} | tail -n 1) - - echo $average_idle - } -@@ -66,9 +66,9 @@ function run_parallel - MPSTAT_PID=$! - - PIDS="" -- start=`date +%s.%N` -+ start=$(date +%s.%N) - -- for i in `seq 0 $(($mvalue-1))` -+ for i in $(seq 0 $(($mvalue-1))) - do - CMD_OUT="${OUT_BASENAME}_${i}" - -@@ -81,14 +81,14 @@ function run_parallel - done - - wait $PIDS -- end=`date +%s.%N` -+ end=$(date +%s.%N) - - wait $MPSTAT_PID - - runtime=$(echo "scale=2; ($end - $start) / 1" | bc -l ) -- total_data=`cat ${OUT_BASENAME}_* | cut -f 1 | SUM` -+ total_data=$(cat ${OUT_BASENAME}_* | cut -f 1 | SUM) - avg_speed=$(echo "scale=2; $total_data / $runtime / 1000000000" | bc -l) -- cpu_idle=`get_cpu_idle` -+ cpu_idle=$(get_cpu_idle) - - echo - echo "buffer size : $nvalue" -@@ -124,9 +124,9 @@ function main - shift $((OPTIND-1)) - alg_name=$1 - -- [ -z "$tvalue" ] && tvalue=10 # 10 seconds per test by default -- [ -z "$mvalue" ] && mvalue=`nproc` # thread count defaults to nproc -- [ -z "$nvalue" ] && nvalue=256 # 256 bytes default buffer size -+ [ -z "$tvalue" ] && tvalue=10 # 10 seconds per test by default -+ [ -z "$mvalue" ] && mvalue=$NUM_CORES # thread count defaults to nproc -+ [ -z "$nvalue" ] && nvalue=256 # 256 bytes default buffer size - - [ "$tvalue" -lt 5 ] && tvalue=5 - --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0073-really-fix-again.-the-mpstat-issue.patch b/recipes-kernel/cryptodev/sdk_patches/0073-really-fix-again.-the-mpstat-issue.patch deleted file mode 100644 index 54108701..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0073-really-fix-again.-the-mpstat-issue.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 787cbdf6b032964df00c4379d9a81ba4384a492e Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Thu, 27 Oct 2016 10:06:08 +0300 -Subject: [PATCH 073/104] really fix (again...) the mpstat issue - -Signed-off-by: Cristian Stoica ---- - tests/async_speed_multi.sh | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh -index e10dc0d..22a12cb 100755 ---- a/tests/async_speed_multi.sh -+++ b/tests/async_speed_multi.sh -@@ -21,7 +21,6 @@ - - NUM_CORES=$(nproc) - OUT_BASENAME="async_speed" --S_TIME_FORMAT=ISO - MPSTAT_OUT="mpstat_out" - - function usage -@@ -62,7 +61,7 @@ function run_parallel - echo "Running $tvalue seconds $mvalue threads in parallel:" - echo " $CMD" - -- (sleep 1; mpstat 1 $(($tvalue-2))) &> $MPSTAT_OUT & -+ (sleep 1; S_TIME_FORMAT=ISO mpstat 1 $(($tvalue-2))) &> $MPSTAT_OUT & - MPSTAT_PID=$! - - PIDS="" --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0074-make-default-output-tabular.patch b/recipes-kernel/cryptodev/sdk_patches/0074-make-default-output-tabular.patch deleted file mode 100644 index 16eadacd..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0074-make-default-output-tabular.patch +++ /dev/null @@ -1,83 +0,0 @@ -From 826f2feb22f5391e985930af40782b2fb980e028 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Thu, 27 Oct 2016 10:12:25 +0300 -Subject: [PATCH 074/104] make default output tabular - -Signed-off-by: Cristian Stoica ---- - tests/async_speed_multi.sh | 33 +++++++++++++++++++++++---------- - 1 file changed, 23 insertions(+), 10 deletions(-) - -diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh -index 22a12cb..b509c25 100755 ---- a/tests/async_speed_multi.sh -+++ b/tests/async_speed_multi.sh -@@ -31,6 +31,7 @@ Usage: `basename $0` [OPTIONS] - -m number of threads to run with (defaults to number of cores) - -t time to run each test (default 10 secs) - -n size of the test buffer (default 256 bytes) -+ -v make output more verbose (default tabular) - -h show this help - - alg_name: null, aes-128-cbc, aes-256-xts, sha1, sha256, crc32c -@@ -57,9 +58,12 @@ function run_parallel - OPTIONS="-t $tvalue -n $nvalue -m" - CMD="async_speed $OPTIONS $alg_name" - -- echo -- echo "Running $tvalue seconds $mvalue threads in parallel:" -- echo " $CMD" -+ if [ ! -z "$vvalue" ] -+ then -+ echo -+ echo "Running $tvalue seconds $mvalue threads in parallel:" -+ echo " $CMD" -+ fi - - (sleep 1; S_TIME_FORMAT=ISO mpstat 1 $(($tvalue-2))) &> $MPSTAT_OUT & - MPSTAT_PID=$! -@@ -89,12 +93,20 @@ function run_parallel - avg_speed=$(echo "scale=2; $total_data / $runtime / 1000000000" | bc -l) - cpu_idle=$(get_cpu_idle) - -- echo -- echo "buffer size : $nvalue" -- echo "running time : $runtime" -- echo "avg_speed : $avg_speed GB/s" -- echo "all_cpu idle : $cpu_idle %" -- echo -+ if [ ! -z "$vvalue" ] -+ then -+ echo -+ echo "buffer size : $nvalue" -+ echo "running time : $runtime" -+ echo "avg_speed : $avg_speed GB/s" -+ echo "all_cpu idle : $cpu_idle %" -+ echo -+ else -+ echo -e "algorithm\t""threads\t""runtime\t"\ -+ "buf_size\t""GB/s\t""%cpu_idle" -+ echo -e "${alg_name}\t${mvalue}\t${runtime}\t"\ -+ "${nvalue}\t${avg_speed}\t${cpu_idle}" -+ fi - } - - function control_c -@@ -110,12 +122,13 @@ function main - rm -f ${OUT_BASENAME}_* - rm -f ${MPSTAT_OUT} - -- while getopts hm:t:n: option -+ while getopts vhm:t:n: option - do - case "$option" in - m) mvalue="$OPTARG";; - t) tvalue="$OPTARG";; - n) nvalue="$OPTARG";; -+ v) vvalue="verbose";; - *) usage $0; exit 1;; - esac - done --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0075-fix-incorrect-handling-of-error-cases.patch b/recipes-kernel/cryptodev/sdk_patches/0075-fix-incorrect-handling-of-error-cases.patch deleted file mode 100644 index 79ca7d2f..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0075-fix-incorrect-handling-of-error-cases.patch +++ /dev/null @@ -1,27 +0,0 @@ -From fbf88220797a95281457680a18e9241b3af1f3fb Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Thu, 27 Oct 2016 10:27:16 +0300 -Subject: [PATCH 075/104] fix incorrect handling of error cases... - -Signed-off-by: Cristian Stoica ---- - tests/async_speed_multi.sh | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh -index b509c25..862f39d 100755 ---- a/tests/async_speed_multi.sh -+++ b/tests/async_speed_multi.sh -@@ -117,7 +117,8 @@ function control_c - - function main - { -- [ ! -e "/dev/crypto" ] && sudo modprobe cryptodev || modprobe cryptodev || exit 1 -+ [ ! -e "/dev/crypto" ] && -+ (sudo modprobe cryptodev || modprobe cryptodev || exit 1) - - rm -f ${OUT_BASENAME}_* - rm -f ${MPSTAT_OUT} --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0076-exit-early-if-cryptodev-tests-are-not-installed.patch b/recipes-kernel/cryptodev/sdk_patches/0076-exit-early-if-cryptodev-tests-are-not-installed.patch deleted file mode 100644 index 0570e1a2..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0076-exit-early-if-cryptodev-tests-are-not-installed.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 87214642cbfc6dbd43948940b5d1ce9528f451bd Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Thu, 27 Oct 2016 10:46:01 +0300 -Subject: [PATCH 076/104] exit early if cryptodev tests are not installed - -Signed-off-by: Cristian Stoica ---- - tests/async_speed_multi.sh | 10 +++++++++- - 1 file changed, 9 insertions(+), 1 deletion(-) - -diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh -index 862f39d..62c4759 100755 ---- a/tests/async_speed_multi.sh -+++ b/tests/async_speed_multi.sh -@@ -20,6 +20,7 @@ - # no user-configurable options below this line - - NUM_CORES=$(nproc) -+CMD_BIN="async_speed" - OUT_BASENAME="async_speed" - MPSTAT_OUT="mpstat_out" - -@@ -56,7 +57,7 @@ function run_parallel - trap control_c SIGINT - - OPTIONS="-t $tvalue -n $nvalue -m" -- CMD="async_speed $OPTIONS $alg_name" -+ CMD="$CMD_BIN $OPTIONS $alg_name" - - if [ ! -z "$vvalue" ] - then -@@ -120,6 +121,13 @@ function main - [ ! -e "/dev/crypto" ] && - (sudo modprobe cryptodev || modprobe cryptodev || exit 1) - -+ $(which ${CMD_BIN} &> /dev/null) -+ if (($? != 0)) -+ then -+ echo "${CMD_BIN} test is not installed" -+ exit 1 -+ fi -+ - rm -f ${OUT_BASENAME}_* - rm -f ${MPSTAT_OUT} - --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0077-the-C-standard-used-by-cryptodev-is-C90-with-GNU-ext.patch b/recipes-kernel/cryptodev/sdk_patches/0077-the-C-standard-used-by-cryptodev-is-C90-with-GNU-ext.patch deleted file mode 100644 index b4ab34ce..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0077-the-C-standard-used-by-cryptodev-is-C90-with-GNU-ext.patch +++ /dev/null @@ -1,66 +0,0 @@ -From 76de6db1bc69b2239d8fb91fd65b74610cb8e22f Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Thu, 27 Oct 2016 16:41:10 +0300 -Subject: [PATCH 077/104] the C standard used by cryptodev is C90 with GNU - extensions - -This avoids some problems with gcc>=5.0 which chaged the default to C11. -The choice for gnu90 is based on the C standard used by Linux kernel which -is gnu90 as well. - -Signed-off-by: Cristian Stoica ---- - Makefile | 6 +++--- - lib/Makefile | 2 +- - tests/Makefile | 2 +- - 3 files changed, 5 insertions(+), 5 deletions(-) - -diff --git a/Makefile b/Makefile -index 90e86d9..80439f6 100644 ---- a/Makefile -+++ b/Makefile -@@ -3,7 +3,7 @@ - # disabled by default. To re-enable it uncomment the - # corresponding CFLAG. - # --CRYPTODEV_CFLAGS += -DENABLE_ASYNC -+CRYPTODEV_CFLAGS += -DENABLE_ASYNC -std=gnu90 - KBUILD_CFLAGS += -I$(src) $(CRYPTODEV_CFLAGS) - KERNEL_DIR ?= /lib/modules/$(shell uname -r)/build - VERSION = 1.8 -@@ -38,10 +38,10 @@ modules_install: - clean: - $(MAKE) $(KERNEL_MAKE_OPTS) clean - rm -f $(hostprogs) *~ -- CFLAGS=$(CRYPTODEV_CFLAGS) KERNEL_DIR=$(KERNEL_DIR) $(MAKE) -C tests clean -+ CFLAGS="$(CRYPTODEV_CFLAGS)" KERNEL_DIR="$(KERNEL_DIR)" $(MAKE) -C tests clean - - check: -- CFLAGS=$(CRYPTODEV_CFLAGS) KERNEL_DIR=$(KERNEL_DIR) $(MAKE) -C tests check -+ CFLAGS="$(CRYPTODEV_CFLAGS)" KERNEL_DIR="$(KERNEL_DIR)" $(MAKE) -C tests check - - testprogs: - KERNEL_DIR=$(KERNEL_DIR) $(MAKE) -C tests all -diff --git a/lib/Makefile b/lib/Makefile -index 3bedc34..0044613 100644 ---- a/lib/Makefile -+++ b/lib/Makefile -@@ -1,4 +1,4 @@ --CFLAGS=-g -O2 -Wall -+CFLAGS=-g -O2 -Wall -std=gnu90 - - all: benchmark - -diff --git a/tests/Makefile b/tests/Makefile -index e7a60cb..23d67f9 100644 ---- a/tests/Makefile -+++ b/tests/Makefile -@@ -1,4 +1,4 @@ --CRYPTODEV_CFLAGS += -DENABLE_ASYNC -Wall -Werror -+CRYPTODEV_CFLAGS += -DENABLE_ASYNC -std=gnu90 -Wall -Werror - CFLAGS += -I.. $(CRYPTODEV_CFLAGS) - - comp_progs := cipher_comp hash_comp hmac_comp --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0078-remove-output-line-because-it-does-not-add-clarity-t.patch b/recipes-kernel/cryptodev/sdk_patches/0078-remove-output-line-because-it-does-not-add-clarity-t.patch deleted file mode 100644 index 3b474a38..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0078-remove-output-line-because-it-does-not-add-clarity-t.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 0bd3dada58288792f587712c95a1f125a7655535 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Fri, 28 Oct 2016 09:05:26 +0300 -Subject: [PATCH 078/104] remove output line because it does not add clarity to - the results - -Signed-off-by: Cristian Stoica ---- - tests/async_speed_multi.sh | 7 ------- - 1 file changed, 7 deletions(-) - -diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh -index 62c4759..991e190 100755 ---- a/tests/async_speed_multi.sh -+++ b/tests/async_speed_multi.sh -@@ -59,13 +59,6 @@ function run_parallel - OPTIONS="-t $tvalue -n $nvalue -m" - CMD="$CMD_BIN $OPTIONS $alg_name" - -- if [ ! -z "$vvalue" ] -- then -- echo -- echo "Running $tvalue seconds $mvalue threads in parallel:" -- echo " $CMD" -- fi -- - (sleep 1; S_TIME_FORMAT=ISO mpstat 1 $(($tvalue-2))) &> $MPSTAT_OUT & - MPSTAT_PID=$! - --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0079-fix-typo-use-consistent-spacing.patch b/recipes-kernel/cryptodev/sdk_patches/0079-fix-typo-use-consistent-spacing.patch deleted file mode 100644 index 7003692b..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0079-fix-typo-use-consistent-spacing.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 9c8d7ce749931de6c7604b3b8be44d4a17bcd7d1 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Fri, 28 Oct 2016 09:11:13 +0300 -Subject: [PATCH 079/104] fix typo, use consistent spacing - -Signed-off-by: Cristian Stoica ---- - tests/async_speed_multi.sh | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh -index 991e190..125d45c 100755 ---- a/tests/async_speed_multi.sh -+++ b/tests/async_speed_multi.sh -@@ -96,8 +96,8 @@ function run_parallel - echo "all_cpu idle : $cpu_idle %" - echo - else -- echo -e "algorithm\t""threads\t""runtime\t"\ -- "buf_size\t""GB/s\t""%cpu_idle" -+ echo -e "algorithm\t""threads\t""run time\t"\ -+ "buffer size\t""GB/s\t""%cpu idle" - echo -e "${alg_name}\t${mvalue}\t${runtime}\t"\ - "${nvalue}\t${avg_speed}\t${cpu_idle}" - fi --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0080-graceful-exit-if-cryptodev-is-not-built-with-ASYNC-f.patch b/recipes-kernel/cryptodev/sdk_patches/0080-graceful-exit-if-cryptodev-is-not-built-with-ASYNC-f.patch deleted file mode 100644 index 64450df9..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0080-graceful-exit-if-cryptodev-is-not-built-with-ASYNC-f.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 9a486f5ebf648971db9bdbd30f7e52251a659ddd Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Fri, 28 Oct 2016 12:01:00 +0300 -Subject: [PATCH 080/104] graceful exit if cryptodev is not built with ASYNC - flags - ---- - tests/async_speed_multi.sh | 7 +++++++ - 1 file changed, 7 insertions(+) - -diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh -index 125d45c..f2a8ba6 100755 ---- a/tests/async_speed_multi.sh -+++ b/tests/async_speed_multi.sh -@@ -82,6 +82,13 @@ function run_parallel - - wait $MPSTAT_PID - -+ grep "ioctl" ${OUT_BASENAME}_* &> /dev/null -+ if (($? == 0)) -+ then -+ echo "cryptodev is not built with -DENABLE_ASYNC flag" -+ exit 1 -+ fi -+ - runtime=$(echo "scale=2; ($end - $start) / 1" | bc -l ) - total_data=$(cat ${OUT_BASENAME}_* | cut -f 1 | SUM) - avg_speed=$(echo "scale=2; $total_data / $runtime / 1000000000" | bc -l) --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0081-add-sync-speed-tests-with-the-same-format-as-async-o.patch b/recipes-kernel/cryptodev/sdk_patches/0081-add-sync-speed-tests-with-the-same-format-as-async-o.patch deleted file mode 100644 index 5e8893b6..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0081-add-sync-speed-tests-with-the-same-format-as-async-o.patch +++ /dev/null @@ -1,718 +0,0 @@ -From b13160357e683b9d42ba513433b4c09456a8332b Mon Sep 17 00:00:00 2001 -From: Alexe Radu -Date: Fri, 28 Oct 2016 13:39:50 +0300 -Subject: [PATCH 081/104] add sync speed tests with the same format as async - ones - -The file speed.c was removed because has the same functionality -as sync_speed.c - -Signed-off-by: Alexe Radu ---- - tests/Makefile | 4 +- - tests/speed.c | 265 ----------------------------------- - tests/sync_speed.c | 399 +++++++++++++++++++++++++++++++++++++++++++++++++++++ - 3 files changed, 401 insertions(+), 267 deletions(-) - delete mode 100644 tests/speed.c - create mode 100644 tests/sync_speed.c - -diff --git a/tests/Makefile b/tests/Makefile -index 23d67f9..400fb7a 100644 ---- a/tests/Makefile -+++ b/tests/Makefile -@@ -3,14 +3,14 @@ CFLAGS += -I.. $(CRYPTODEV_CFLAGS) - - comp_progs := cipher_comp hash_comp hmac_comp - --hostprogs := cipher cipher-aead hmac speed async_cipher async_hmac \ -+hostprogs := cipher cipher-aead hmac sync_speed async_cipher async_hmac \ - async_speed sha_speed hashcrypt_speed fullspeed cipher-gcm \ - cipher-aead-srtp $(comp_progs) - - example-cipher-objs := cipher.o - example-cipher-aead-objs := cipher-aead.o - example-hmac-objs := hmac.o --example-speed-objs := speed.c -+example-speed-objs := sync_speed.o - example-fullspeed-objs := fullspeed.c - example-sha-speed-objs := sha_speed.c - example-async-cipher-objs := async_cipher.o -diff --git a/tests/speed.c b/tests/speed.c -deleted file mode 100644 -index 0e2bbc3..0000000 ---- a/tests/speed.c -+++ /dev/null -@@ -1,265 +0,0 @@ --/* cryptodev_test - simple benchmark tool for cryptodev -- * -- * Copyright (C) 2010 by Phil Sutter -- * -- * This program is free software; you can redistribute it and/or modify -- * it under the terms of the GNU General Public License as published by -- * the Free Software Foundation; either version 2 of the License, or -- * (at your option) any later version. -- * -- * This program is distributed in the hope that it will be useful, -- * but WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- * GNU General Public License for more details. -- * -- * You should have received a copy of the GNU General Public License -- * along with this program; if not, write to the Free Software -- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -- */ --#include --#include --#include --#include --#include --#include --#include --#include --#include --#include -- --#include -- --static int si = 1; /* SI by default */ -- --static double udifftimeval(struct timeval start, struct timeval end) --{ -- return (double)(end.tv_usec - start.tv_usec) + -- (double)(end.tv_sec - start.tv_sec) * 1000 * 1000; --} -- --static int must_finish = 0; -- --static void alarm_handler(int signo) --{ -- must_finish = 1; --} -- --static char *units[] = { "", "Ki", "Mi", "Gi", "Ti", 0}; --static char *si_units[] = { "", "K", "M", "G", "T", 0}; -- --static void value2human(int si, double bytes, double time, double* data, double* speed,char* metric) --{ -- int unit = 0; -- -- *data = bytes; -- -- if (si) { -- while (*data > 1000 && si_units[unit + 1]) { -- *data /= 1000; -- unit++; -- } -- *speed = *data / time; -- sprintf(metric, "%sB", si_units[unit]); -- } else { -- while (*data > 1024 && units[unit + 1]) { -- *data /= 1024; -- unit++; -- } -- *speed = *data / time; -- sprintf(metric, "%sB", units[unit]); -- } --} -- --#define MAX(x,y) ((x)>(y)?(x):(y)) -- --int encrypt_data(struct session_op *sess, int fdc, int chunksize, int alignmask) --{ -- struct crypt_op cop; -- char *buffer, iv[32]; -- uint8_t mac[HASH_MAX_LEN]; -- static int val = 23; -- struct timeval start, end; -- double total = 0; -- double secs, ddata, dspeed; -- char metric[16]; -- int min_alignmask = sizeof(void*) - 1; -- -- if (alignmask) { -- alignmask = ((alignmask < min_alignmask) ? min_alignmask : alignmask); -- if (posix_memalign((void **)&buffer, MAX(alignmask + 1, sizeof(void*)), chunksize)) { -- printf("posix_memalign() failed! (mask %x, size: %d)\n", alignmask+1, chunksize); -- return 1; -- } -- } else { -- if (!(buffer = malloc(chunksize))) { -- perror("malloc()"); -- return 1; -- } -- } -- -- memset(iv, 0x23, 32); -- -- printf("\tEncrypting in chunks of %d bytes: ", chunksize); -- fflush(stdout); -- -- memset(buffer, val++, chunksize); -- -- must_finish = 0; -- alarm(5); -- -- gettimeofday(&start, NULL); -- do { -- memset(&cop, 0, sizeof(cop)); -- cop.ses = sess->ses; -- cop.len = chunksize; -- cop.iv = (unsigned char *)iv; -- cop.op = COP_ENCRYPT; -- cop.src = cop.dst = (unsigned char *)buffer; -- cop.mac = mac; -- -- if (ioctl(fdc, CIOCCRYPT, &cop)) { -- perror("ioctl(CIOCCRYPT)"); -- return 1; -- } -- total+=chunksize; -- } while(must_finish==0); -- gettimeofday(&end, NULL); -- -- secs = udifftimeval(start, end)/ 1000000.0; -- -- value2human(si, total, secs, &ddata, &dspeed, metric); -- printf ("done. %.2f %s in %.2f secs: ", ddata, metric, secs); -- printf ("%.2f %s/sec\n", dspeed, metric); -- -- free(buffer); -- return 0; --} -- --int main(int argc, char** argv) --{ -- int fd, i, fdc = -1, alignmask = 0; -- struct session_op sess; --#ifdef CIOCGSESSINFO -- struct session_info_op siop; --#endif -- char keybuf[32]; -- -- signal(SIGALRM, alarm_handler); -- -- if (argc > 1) { -- if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0) { -- printf("Usage: speed [--kib]\n"); -- exit(0); -- } -- if (strcmp(argv[1], "--kib") == 0) { -- si = 0; -- } -- } -- -- if ((fd = open("/dev/crypto", O_RDWR, 0)) < 0) { -- perror("open()"); -- return 1; -- } -- if (ioctl(fd, CRIOGET, &fdc)) { -- perror("ioctl(CRIOGET)"); -- return 1; -- } -- -- fprintf(stderr, "Testing NULL cipher: \n"); -- memset(&sess, 0, sizeof(sess)); -- sess.cipher = CRYPTO_NULL; -- sess.keylen = 0; -- sess.key = (unsigned char *)keybuf; -- if (ioctl(fdc, CIOCGSESSION, &sess)) { -- perror("ioctl(CIOCGSESSION)"); -- return 1; -- } --#ifdef CIOCGSESSINFO -- siop.ses = sess.ses; -- if (ioctl(fdc, CIOCGSESSINFO, &siop)) { -- perror("ioctl(CIOCGSESSINFO)"); -- return 1; -- } -- alignmask = siop.alignmask; --#endif -- -- for (i = 512; i <= (64 * 1024); i *= 2) { -- if (encrypt_data(&sess, fdc, i, alignmask)) -- break; -- } -- -- fprintf(stderr, "\nTesting AES-128-CBC cipher: \n"); -- memset(&sess, 0, sizeof(sess)); -- sess.cipher = CRYPTO_AES_CBC; -- sess.keylen = 16; -- memset(keybuf, 0x42, 16); -- sess.key = (unsigned char *)keybuf; -- if (ioctl(fdc, CIOCGSESSION, &sess)) { -- perror("ioctl(CIOCGSESSION)"); -- return 1; -- } --#ifdef CIOCGSESSINFO -- siop.ses = sess.ses; -- if (ioctl(fdc, CIOCGSESSINFO, &siop)) { -- perror("ioctl(CIOCGSESSINFO)"); -- return 1; -- } -- alignmask = siop.alignmask; --#endif -- -- for (i = 512; i <= (64 * 1024); i *= 2) { -- if (encrypt_data(&sess, fdc, i, alignmask)) -- break; -- } -- -- fprintf(stderr, "\nTesting AES-256-XTS cipher: \n"); -- memset(&sess, 0, sizeof(sess)); -- sess.cipher = CRYPTO_AES_XTS; -- sess.keylen = 32; -- memset(keybuf, 0x42, sess.keylen); -- sess.key = (unsigned char *)keybuf; -- if (ioctl(fdc, CIOCGSESSION, &sess)) { -- perror("ioctl(CIOCGSESSION)"); -- return 1; -- } --#ifdef CIOCGSESSINFO -- siop.ses = sess.ses; -- if (ioctl(fdc, CIOCGSESSINFO, &siop)) { -- perror("ioctl(CIOCGSESSINFO)"); -- return 1; -- } -- alignmask = siop.alignmask; --#endif -- -- for (i = 512; i <= (64 * 1024); i *= 2) { -- if (encrypt_data(&sess, fdc, i, alignmask)) -- break; -- } -- -- fprintf(stderr, "\nTesting CRC32C hash: \n"); -- memset(&sess, 0, sizeof(sess)); -- sess.mac = CRYPTO_CRC32C; -- if (ioctl(fdc, CIOCGSESSION, &sess)) { -- perror("ioctl(CIOCGSESSION)"); -- return 1; -- } --#ifdef CIOCGSESSINFO -- siop.ses = sess.ses; -- if (ioctl(fdc, CIOCGSESSINFO, &siop)) { -- perror("ioctl(CIOCGSESSINFO)"); -- return 1; -- } -- printf("requested hash CRYPTO_CRC32C, got %s with driver %s\n", -- siop.hash_info.cra_name, siop.hash_info.cra_driver_name); -- alignmask = siop.alignmask; --#endif -- -- for (i = 512; i <= (64 * 1024); i *= 2) { -- if (encrypt_data(&sess, fdc, i, alignmask)) -- break; -- } -- -- close(fdc); -- close(fd); -- return 0; --} -diff --git a/tests/sync_speed.c b/tests/sync_speed.c -new file mode 100644 -index 0000000..b0cb9ad ---- /dev/null -+++ b/tests/sync_speed.c -@@ -0,0 +1,399 @@ -+/* cryptodev_test - simple benchmark tool for cryptodev -+ * -+ * Copyright (C) 2010 by Phil Sutter -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -+ */ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+struct test_params { -+ bool tflag; -+ bool nflag; -+ int tvalue; -+ int nvalue; -+}; -+ -+const char usage_str[] = "Usage: %s [OPTION]... |\n" -+ "Run benchmark test for cipher or hash\n\n" -+ " -t \t" "time to run each test (default 10 secs)\n" -+ " -n \t" "size of the test buffer\n" -+ " -h\t\t" "show this help\n" -+; -+ -+int run_null(int fdc, struct test_params tp); -+int run_aes_cbc(int fdc, struct test_params tp); -+int run_aes_xts(int fdc, struct test_params tp); -+int run_crc32c(int fdc, struct test_params tp); -+int run_sha1(int fdc, struct test_params tp); -+int run_sha256(int fdc, struct test_params tp); -+int get_alignmask(int fdc, struct session_op *sess); -+ -+#define ALG_COUNT 6 -+struct { -+ char *name; -+ int (*func)(int, struct test_params); -+} ciphers[ALG_COUNT] = { -+ {"null", run_null}, -+ {"aes-cbc", run_aes_cbc}, -+ {"aes-xts", run_aes_xts}, -+ {"crc32c", run_crc32c}, -+ {"sha1", run_sha1}, -+ {"sha256", run_sha256}, -+}; -+ -+static double udifftimeval(struct timeval start, struct timeval end) -+{ -+ return (double)(end.tv_usec - start.tv_usec) + -+ (double)(end.tv_sec - start.tv_sec) * 1000 * 1000; -+} -+ -+static int must_finish = 0; -+static int must_exit = 0; -+ -+static void alarm_handler(int signo) -+{ -+ must_finish = 1; -+} -+ -+static void exit_handler(int signo) -+{ -+ must_exit = 1; -+ printf("\nexit requested by user through ctrl+c \n"); -+} -+ -+static char *units[] = { "", "Ki", "Mi", "Gi", "Ti", 0}; -+ -+static void value2human(double bytes, double time, double* data, double* speed,char* metric) -+{ -+ int unit = 0; -+ -+ *data = bytes; -+ while (*data > 1024 && units[unit + 1]) { -+ *data /= 1024; -+ unit++; -+ } -+ *speed = *data / time; -+ sprintf(metric, "%sB", units[unit]); -+} -+ -+static int encrypt_data(int fdc, struct test_params tp, struct session_op *sess) -+{ -+ struct crypt_op cop; -+ char *buffer, iv[32]; -+ char mac[HASH_MAX_LEN]; -+ static int val = 23; -+ struct timeval start, end; -+ double total = 0; -+ double secs, ddata, dspeed; -+ char metric[16]; -+ int alignmask; -+ int min_alignmask = sizeof(void*) - 1; -+ -+ memset(iv, 0x23, 32); -+ -+ printf("\tEncrypting in chunks of %d bytes: ", tp.nvalue); -+ fflush(stdout); -+ -+ alignmask = get_alignmask(fdc, sess); -+ if (alignmask) { -+ alignmask = ((alignmask < min_alignmask) ? min_alignmask : alignmask); -+ if (posix_memalign((void **)(&buffer), alignmask + 1, tp.nvalue)) { -+ printf("posix_memalign() failed!\n"); -+ return 1; -+ } -+ } else { -+ if (!(buffer = malloc(tp.nvalue))) { -+ perror("malloc()"); -+ return 1; -+ } -+ } -+ memset(buffer, val++, tp.nvalue); -+ -+ must_finish = 0; -+ alarm(tp.tvalue); -+ -+ gettimeofday(&start, NULL); -+ do { -+ memset(&cop, 0, sizeof(cop)); -+ cop.ses = sess->ses; -+ cop.len = tp.nvalue; -+ cop.iv = (unsigned char *)iv; -+ cop.op = COP_ENCRYPT; -+ cop.src = cop.dst = (unsigned char *)buffer; -+ cop.mac = (unsigned char *)mac; -+ -+ if (ioctl(fdc, CIOCCRYPT, &cop)) { -+ perror("ioctl(CIOCCRYPT)"); -+ return 1; -+ } -+ total += cop.len; -+ } while(!must_finish); -+ gettimeofday(&end, NULL); -+ -+ secs = udifftimeval(start, end)/ 1000000.0; -+ -+ value2human(total, secs, &ddata, &dspeed, metric); -+ printf ("done. %.2f %s in %.2f secs: ", ddata, metric, secs); -+ printf ("%.2f %s/sec\n", dspeed, metric); -+ -+ free(buffer); -+ return 0; -+} -+ -+void usage(char *cmd_name) -+{ -+ printf(usage_str, cmd_name); -+} -+ -+int run_test(int id, struct test_params tp) -+{ -+ int fd; -+ int fdc; -+ -+ fd = open("/dev/crypto", O_RDWR, 0); -+ if (fd < 0) { -+ perror("open()"); -+ return fd; -+ } -+ if (ioctl(fd, CRIOGET, &fdc)) { -+ perror("ioctl(CRIOGET)"); -+ return -EINVAL; -+ } -+ -+ ciphers[id].func(fdc, tp); -+ -+ close(fdc); -+ close(fd); -+ -+ return 0; -+} -+ -+int get_alignmask(int fdc, struct session_op *sess) -+{ -+ int alignmask; -+ -+#ifdef CIOCGSESSINFO -+ struct session_info_op siop; -+ -+ siop.ses = sess->ses; -+ if (ioctl(fdc, CIOCGSESSINFO, &siop)) { -+ perror("ioctl(CIOCGSESSINFO)"); -+ return -EINVAL; -+ } -+ alignmask = siop.alignmask; -+#else -+ alignmask = 0; -+#endif -+ -+ return alignmask; -+} -+ -+void do_test_vectors(int fdc, struct test_params tp, struct session_op *sess) -+{ -+ int i; -+ -+ if (tp.nflag) { -+ encrypt_data(fdc, tp, sess); -+ } else { -+ for (i = 256; i <= (64 * 1024); i *= 2) { -+ if (must_exit) -+ break; -+ -+ tp.nvalue = i; -+ if (encrypt_data(fdc, tp, sess)) { -+ break; -+ } -+ } -+ } -+} -+ -+ -+int run_null(int fdc, struct test_params tp) -+{ -+ struct session_op sess; -+ char keybuf[32]; -+ -+ fprintf(stderr, "Testing NULL cipher: \n"); -+ memset(&sess, 0, sizeof(sess)); -+ sess.cipher = CRYPTO_NULL; -+ sess.keylen = 0; -+ sess.key = (unsigned char *)keybuf; -+ if (ioctl(fdc, CIOCGSESSION, &sess)) { -+ perror("ioctl(CIOCGSESSION)"); -+ return -EINVAL; -+ } -+ -+ do_test_vectors(fdc, tp, &sess); -+ return 0; -+} -+ -+int run_aes_cbc(int fdc, struct test_params tp) -+{ -+ struct session_op sess; -+ char keybuf[32]; -+ -+ fprintf(stderr, "\nTesting AES-128-CBC cipher: \n"); -+ memset(&sess, 0, sizeof(sess)); -+ sess.cipher = CRYPTO_AES_CBC; -+ sess.keylen = 16; -+ memset(keybuf, 0x42, 16); -+ sess.key = (unsigned char *)keybuf; -+ if (ioctl(fdc, CIOCGSESSION, &sess)) { -+ perror("ioctl(CIOCGSESSION)"); -+ return -EINVAL; -+ } -+ -+ do_test_vectors(fdc, tp, &sess); -+ return 0; -+} -+ -+int run_aes_xts(int fdc, struct test_params tp) -+{ -+ struct session_op sess; -+ char keybuf[32]; -+ -+ fprintf(stderr, "\nTesting AES-256-XTS cipher: \n"); -+ memset(&sess, 0, sizeof(sess)); -+ sess.cipher = CRYPTO_AES_XTS; -+ sess.keylen = 32; -+ memset(keybuf, 0x42, sess.keylen); -+ sess.key = (unsigned char *)keybuf; -+ if (ioctl(fdc, CIOCGSESSION, &sess)) { -+ perror("ioctl(CIOCGSESSION)"); -+ return -EINVAL; -+ } -+ -+ do_test_vectors(fdc, tp, &sess); -+ return 0; -+} -+ -+int run_crc32c(int fdc, struct test_params tp) -+{ -+ struct session_op sess; -+ -+ fprintf(stderr, "\nTesting CRC32C hash: \n"); -+ memset(&sess, 0, sizeof(sess)); -+ sess.mac = CRYPTO_CRC32C; -+ if (ioctl(fdc, CIOCGSESSION, &sess)) { -+ perror("ioctl(CIOCGSESSION)"); -+ return 1; -+ } -+ -+ do_test_vectors(fdc, tp, &sess); -+ return 0; -+} -+ -+int run_sha1(int fdc, struct test_params tp) -+{ -+ struct session_op sess; -+ -+ fprintf(stderr, "\nTesting SHA-1 hash: \n"); -+ memset(&sess, 0, sizeof(sess)); -+ sess.mac = CRYPTO_SHA1; -+ if (ioctl(fdc, CIOCGSESSION, &sess)) { -+ perror("ioctl(CIOCGSESSION)"); -+ return 1; -+ } -+ -+ do_test_vectors(fdc, tp, &sess); -+ return 0; -+} -+ -+int run_sha256(int fdc, struct test_params tp) -+{ -+ struct session_op sess; -+ -+ fprintf(stderr, "\nTesting SHA2-256 hash: \n"); -+ memset(&sess, 0, sizeof(sess)); -+ sess.mac = CRYPTO_SHA2_256; -+ if (ioctl(fdc, CIOCGSESSION, &sess)) { -+ perror("ioctl(CIOCGSESSION)"); -+ return 1; -+ } -+ -+ do_test_vectors(fdc, tp, &sess); -+ return 0; -+} -+ -+int main(int argc, char **argv) -+{ -+ int i; -+ int c; -+ bool alg_flag; -+ char *alg_name; -+ struct test_params tp; -+ -+ tp.tflag = false; -+ tp.nflag = false; -+ alg_flag = false; -+ opterr = 0; -+ while ((c = getopt(argc, argv, "hn:t:")) != -1) { -+ switch (c) { -+ case 'n': -+ tp.nvalue = atoi(optarg); -+ tp.nflag = true; -+ break; -+ case 't': -+ tp.tvalue = atoi(optarg); -+ tp.tflag = true; -+ break; -+ case 'h': /* no break */ -+ default: -+ usage(argv[0]); -+ exit(1); -+ } -+ } -+ -+ /* the name of a specific test asked on the command line */ -+ if (optind < argc) { -+ alg_name = argv[optind]; -+ alg_flag = true; -+ } -+ -+ /* default test time */ -+ if (!tp.tflag) { -+ tp.tvalue = 5; -+ } -+ -+ signal(SIGALRM, alarm_handler); -+ signal(SIGINT, exit_handler); -+ -+ for (i = 0; i < ALG_COUNT; i++) { -+ if (must_exit) -+ break; -+ -+ if (alg_flag) { -+ if (strcmp(alg_name, ciphers[i].name) == 0) { -+ run_test(i, tp); -+ } -+ } else { -+ run_test(i, tp); -+ } -+ } -+ -+ return 0; -+} --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0082-force-LC_TIME-value-to-avoid-mpstat-not-using-ISO860.patch b/recipes-kernel/cryptodev/sdk_patches/0082-force-LC_TIME-value-to-avoid-mpstat-not-using-ISO860.patch deleted file mode 100644 index 6f3df511..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0082-force-LC_TIME-value-to-avoid-mpstat-not-using-ISO860.patch +++ /dev/null @@ -1,31 +0,0 @@ -From eee8668c6f0e558e77533edb80c1ca7d4dc486e2 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Fri, 28 Oct 2016 17:00:29 +0300 -Subject: [PATCH 082/104] force LC_TIME value to avoid mpstat not using ISO8601 - format - -(not everybody has this locale - silent warnings on some systems) - -Signed-off-by: Cristian Stoica ---- - tests/async_speed_multi.sh | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh -index f2a8ba6..1901620 100755 ---- a/tests/async_speed_multi.sh -+++ b/tests/async_speed_multi.sh -@@ -24,6 +24,10 @@ CMD_BIN="async_speed" - OUT_BASENAME="async_speed" - MPSTAT_OUT="mpstat_out" - -+# A bigger hammer for mpstat to use ISO8601 time format (fixed in 11.2.2) -+export LC_TIME=en_GB.UTF-8 &> /dev/null -+ -+ - function usage - { - cat << EOF --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0083-use-the-same-algorithm-names-in-sync_speed-as-in-asy.patch b/recipes-kernel/cryptodev/sdk_patches/0083-use-the-same-algorithm-names-in-sync_speed-as-in-asy.patch deleted file mode 100644 index 13dde817..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0083-use-the-same-algorithm-names-in-sync_speed-as-in-asy.patch +++ /dev/null @@ -1,58 +0,0 @@ -From a6e777aba434533f726bc9d34b074b7f36429126 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Fri, 28 Oct 2016 17:23:27 +0300 -Subject: [PATCH 083/104] use the same algorithm names in sync_speed as in - async_speed - -Signed-off-by: Cristian Stoica ---- - tests/sync_speed.c | 12 ++++++------ - 1 file changed, 6 insertions(+), 6 deletions(-) - -diff --git a/tests/sync_speed.c b/tests/sync_speed.c -index b0cb9ad..56cd3aa 100644 ---- a/tests/sync_speed.c -+++ b/tests/sync_speed.c -@@ -45,8 +45,8 @@ const char usage_str[] = "Usage: %s [OPTION]... |\n" - ; - - int run_null(int fdc, struct test_params tp); --int run_aes_cbc(int fdc, struct test_params tp); --int run_aes_xts(int fdc, struct test_params tp); -+int run_aes_128_cbc(int fdc, struct test_params tp); -+int run_aes_256_xts(int fdc, struct test_params tp); - int run_crc32c(int fdc, struct test_params tp); - int run_sha1(int fdc, struct test_params tp); - int run_sha256(int fdc, struct test_params tp); -@@ -58,8 +58,8 @@ struct { - int (*func)(int, struct test_params); - } ciphers[ALG_COUNT] = { - {"null", run_null}, -- {"aes-cbc", run_aes_cbc}, -- {"aes-xts", run_aes_xts}, -+ {"aes-128-cbc", run_aes_128_cbc}, -+ {"aes-256-xts", run_aes_256_xts}, - {"crc32c", run_crc32c}, - {"sha1", run_sha1}, - {"sha256", run_sha256}, -@@ -251,7 +251,7 @@ int run_null(int fdc, struct test_params tp) - return 0; - } - --int run_aes_cbc(int fdc, struct test_params tp) -+int run_aes_128_cbc(int fdc, struct test_params tp) - { - struct session_op sess; - char keybuf[32]; -@@ -271,7 +271,7 @@ int run_aes_cbc(int fdc, struct test_params tp) - return 0; - } - --int run_aes_xts(int fdc, struct test_params tp) -+int run_aes_256_xts(int fdc, struct test_params tp) - { - struct session_op sess; - char keybuf[32]; --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0084-fix-ignored-SIGALRM-signals-on-some-platforms.patch b/recipes-kernel/cryptodev/sdk_patches/0084-fix-ignored-SIGALRM-signals-on-some-platforms.patch deleted file mode 100644 index aa05f98f..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0084-fix-ignored-SIGALRM-signals-on-some-platforms.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 1bcef054cfc094e51c9c3cb1048b8bf909326082 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Fri, 28 Oct 2016 17:41:09 +0300 -Subject: [PATCH 084/104] fix ignored SIGALRM signals on some platforms - -Signed-off-by: Cristian Stoica ---- - tests/async_speed.c | 4 ++-- - tests/sync_speed.c | 4 ++-- - 2 files changed, 4 insertions(+), 4 deletions(-) - -diff --git a/tests/async_speed.c b/tests/async_speed.c -index d843c02..eb8468d 100644 ---- a/tests/async_speed.c -+++ b/tests/async_speed.c -@@ -76,8 +76,8 @@ static double udifftimeval(struct timeval start, struct timeval end) - (double)(end.tv_sec - start.tv_sec) * 1000 * 1000; - } - --static int must_finish = 0; --static int must_exit = 0; -+static volatile int must_finish; -+static volatile int must_exit; - static struct pollfd pfd; - - static void alarm_handler(int signo) -diff --git a/tests/sync_speed.c b/tests/sync_speed.c -index 56cd3aa..ba1d170 100644 ---- a/tests/sync_speed.c -+++ b/tests/sync_speed.c -@@ -71,8 +71,8 @@ static double udifftimeval(struct timeval start, struct timeval end) - (double)(end.tv_sec - start.tv_sec) * 1000 * 1000; - } - --static int must_finish = 0; --static int must_exit = 0; -+static volatile int must_finish; -+static volatile int must_exit; - - static void alarm_handler(int signo) - { --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0085-add-notes-about-configured-limits-in-SEC-driver.patch b/recipes-kernel/cryptodev/sdk_patches/0085-add-notes-about-configured-limits-in-SEC-driver.patch deleted file mode 100644 index 23f4b544..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0085-add-notes-about-configured-limits-in-SEC-driver.patch +++ /dev/null @@ -1,56 +0,0 @@ -From b682119d432af1190699c56039f6584ac83ae7b9 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Fri, 28 Oct 2016 18:03:07 +0300 -Subject: [PATCH 085/104] add notes about configured limits in SEC driver - -Signed-off-by: Cristian Stoica ---- - tests/async_speed.c | 3 ++- - tests/async_speed_multi.sh | 2 ++ - tests/sync_speed.c | 3 ++- - 3 files changed, 6 insertions(+), 2 deletions(-) - -diff --git a/tests/async_speed.c b/tests/async_speed.c -index eb8468d..d16d17e 100644 ---- a/tests/async_speed.c -+++ b/tests/async_speed.c -@@ -47,7 +47,8 @@ const char usage_str[] = "Usage: %s [OPTION]... |\n" - " -t \t" "time to run each test (default 10 secs)\n" - " -n \t" "size of the test buffer\n" - " -m\t\t" "output in a machine readable format\n" -- " -h\t\t" "show this help\n" -+ " -h\t\t" "show this help\n\n" -+ "Note: SEC driver is configured to support buffers smaller than 512K\n" - ; - - int run_null(int fdc, struct test_params tp); -diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh -index 1901620..f83e362 100755 ---- a/tests/async_speed_multi.sh -+++ b/tests/async_speed_multi.sh -@@ -40,6 +40,8 @@ Usage: `basename $0` [OPTIONS] - -h show this help - - alg_name: null, aes-128-cbc, aes-256-xts, sha1, sha256, crc32c -+ -+Note: SEC driver is configured to support buffers smaller than 512K - EOF - } - -diff --git a/tests/sync_speed.c b/tests/sync_speed.c -index ba1d170..ceae645 100644 ---- a/tests/sync_speed.c -+++ b/tests/sync_speed.c -@@ -41,7 +41,8 @@ const char usage_str[] = "Usage: %s [OPTION]... |\n" - "Run benchmark test for cipher or hash\n\n" - " -t \t" "time to run each test (default 10 secs)\n" - " -n \t" "size of the test buffer\n" -- " -h\t\t" "show this help\n" -+ " -h\t\t" "show this help\n\n" -+ "Note: SEC driver is configured to support buffers smaller than 512K\n" - ; - - int run_null(int fdc, struct test_params tp); --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0086-add-a-wrapper-script-for-running-all-tests.patch b/recipes-kernel/cryptodev/sdk_patches/0086-add-a-wrapper-script-for-running-all-tests.patch deleted file mode 100644 index 3e781aa3..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0086-add-a-wrapper-script-for-running-all-tests.patch +++ /dev/null @@ -1,58 +0,0 @@ -From fc04b5a05fd4ab1fc0f581b52d52db7c709dfc6a Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Fri, 28 Oct 2016 18:55:09 +0300 -Subject: [PATCH 086/104] add a wrapper script for running all tests - -Signed-off-by: Cristian Stoica ---- - tests/Makefile | 1 + - tests/run_crypto_tests.sh | 25 +++++++++++++++++++++++++ - 2 files changed, 26 insertions(+) - create mode 100644 tests/run_crypto_tests.sh - -diff --git a/tests/Makefile b/tests/Makefile -index 400fb7a..51469e8 100644 ---- a/tests/Makefile -+++ b/tests/Makefile -@@ -39,6 +39,7 @@ install: - install -m 755 $$prog $(DESTDIR)/$(bindir)/tests_cryptodev/; \ - done - install -m 755 async_speed_multi.sh $(DESTDIR)/$(bindir) -+ install -m 755 run_crypto_tests.sh $(DESTDIR)/$(bindir) - - clean: - rm -f *.o *~ $(hostprogs) -diff --git a/tests/run_crypto_tests.sh b/tests/run_crypto_tests.sh -new file mode 100644 -index 0000000..32ab8e2 ---- /dev/null -+++ b/tests/run_crypto_tests.sh -@@ -0,0 +1,25 @@ -+#!/bin/bash -+ -+ -+BUF_SIZE="8192 16384 65536 131072 262144" -+THREAD_CNT="1 8 12" -+ALG_NAMES="aes-128-cbc aes-256-xts sha1 sha256 crc32c" -+ -+#restool dpseci create --num-queues=8 --priorities=1,2,3,4,5,6,7,8 -+#restool dprc assign dprc.1 --object=dpseci.0 --plugged=1 -+ -+ -+#grep DPIO /proc/interrupts -+for alg_name in ${ALG_NAMES} -+do -+ for multi in ${THREAD_CNT} -+ do -+ for bsize in ${BUF_SIZE} -+ do -+ async_speed_multi.sh -t 10 -n $bsize -m ${multi} ${alg_name} | -+ tail -n 1 -+ done -+ done -+done -+ -+#grep DPIO /proc/interrupts --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0087-add-to-cpu-idle-for-convenience.patch b/recipes-kernel/cryptodev/sdk_patches/0087-add-to-cpu-idle-for-convenience.patch deleted file mode 100644 index edd47f7d..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0087-add-to-cpu-idle-for-convenience.patch +++ /dev/null @@ -1,26 +0,0 @@ -From a2894f645e972b7dfc97b59ea1c1e91e741c04d1 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Fri, 28 Oct 2016 19:07:29 +0300 -Subject: [PATCH 087/104] add % to cpu idle for convenience - -Signed-off-by: Cristian Stoica ---- - tests/async_speed_multi.sh | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh -index f83e362..90f9b72 100755 ---- a/tests/async_speed_multi.sh -+++ b/tests/async_speed_multi.sh -@@ -112,7 +112,7 @@ function run_parallel - echo -e "algorithm\t""threads\t""run time\t"\ - "buffer size\t""GB/s\t""%cpu idle" - echo -e "${alg_name}\t${mvalue}\t${runtime}\t"\ -- "${nvalue}\t${avg_speed}\t${cpu_idle}" -+ "${nvalue}\t${avg_speed}\t${cpu_idle}%" - fi - } - --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0088-merge-sync-and-async-benchmarks-into-a-single-progra.patch b/recipes-kernel/cryptodev/sdk_patches/0088-merge-sync-and-async-benchmarks-into-a-single-progra.patch deleted file mode 100644 index 9f7709bb..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0088-merge-sync-and-async-benchmarks-into-a-single-progra.patch +++ /dev/null @@ -1,1858 +0,0 @@ -From a7e42a9c9a2cd4b4ffd369ae57dfbd207536766a Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Tue, 1 Nov 2016 12:01:33 +0200 -Subject: [PATCH 088/104] merge sync and async benchmarks into a single program - -Signed-off-by: Cristian Stoica ---- - tests/Makefile | 9 +- - tests/async_speed.c | 463 -------------------------------------- - tests/async_speed_multi.sh | 172 -------------- - tests/run_crypto_tests.sh | 2 +- - tests/speed.c | 546 +++++++++++++++++++++++++++++++++++++++++++++ - tests/speed_multi.sh | 174 +++++++++++++++ - tests/sync_speed.c | 400 --------------------------------- - 7 files changed, 725 insertions(+), 1041 deletions(-) - delete mode 100644 tests/async_speed.c - delete mode 100755 tests/async_speed_multi.sh - create mode 100644 tests/speed.c - create mode 100755 tests/speed_multi.sh - delete mode 100644 tests/sync_speed.c - -diff --git a/tests/Makefile b/tests/Makefile -index 51469e8..88f5040 100644 ---- a/tests/Makefile -+++ b/tests/Makefile -@@ -3,19 +3,18 @@ CFLAGS += -I.. $(CRYPTODEV_CFLAGS) - - comp_progs := cipher_comp hash_comp hmac_comp - --hostprogs := cipher cipher-aead hmac sync_speed async_cipher async_hmac \ -- async_speed sha_speed hashcrypt_speed fullspeed cipher-gcm \ -+hostprogs := cipher cipher-aead hmac async_cipher async_hmac \ -+ speed sha_speed hashcrypt_speed fullspeed cipher-gcm \ - cipher-aead-srtp $(comp_progs) - - example-cipher-objs := cipher.o - example-cipher-aead-objs := cipher-aead.o - example-hmac-objs := hmac.o --example-speed-objs := sync_speed.o - example-fullspeed-objs := fullspeed.c - example-sha-speed-objs := sha_speed.c - example-async-cipher-objs := async_cipher.o - example-async-hmac-objs := async_hmac.o --example-async-speed-objs := async_speed.o -+example-async-speed-objs := speed.o - example-hashcrypt-speed-objs := hashcrypt_speed.c - - prefix ?= /usr/local -@@ -38,7 +37,7 @@ install: - for prog in $(hostprogs); do \ - install -m 755 $$prog $(DESTDIR)/$(bindir)/tests_cryptodev/; \ - done -- install -m 755 async_speed_multi.sh $(DESTDIR)/$(bindir) -+ install -m 755 speed_multi.sh $(DESTDIR)/$(bindir) - install -m 755 run_crypto_tests.sh $(DESTDIR)/$(bindir) - - clean: -diff --git a/tests/async_speed.c b/tests/async_speed.c -deleted file mode 100644 -index d16d17e..0000000 ---- a/tests/async_speed.c -+++ /dev/null -@@ -1,463 +0,0 @@ --/* cryptodev_test - simple benchmark tool for cryptodev -- * -- * Copyright (C) 2010 by Phil Sutter -- * -- * This program is free software; you can redistribute it and/or modify -- * it under the terms of the GNU General Public License as published by -- * the Free Software Foundation; either version 2 of the License, or -- * (at your option) any later version. -- * -- * This program is distributed in the hope that it will be useful, -- * but WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- * GNU General Public License for more details. -- * -- * You should have received a copy of the GNU General Public License -- * along with this program; if not, write to the Free Software -- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -- */ --#include --#include --#include --#include --#include --#include --#include --#include --#include --#include --#include --#include --#include --#include --#include -- --#ifdef ENABLE_ASYNC -- --struct test_params { -- bool tflag; -- bool nflag; -- bool mflag; -- int tvalue; -- int nvalue; --}; -- --const char usage_str[] = "Usage: %s [OPTION]... |\n" -- "Run benchmark test for cipher or hash\n\n" -- " -t \t" "time to run each test (default 10 secs)\n" -- " -n \t" "size of the test buffer\n" -- " -m\t\t" "output in a machine readable format\n" -- " -h\t\t" "show this help\n\n" -- "Note: SEC driver is configured to support buffers smaller than 512K\n" --; -- --int run_null(int fdc, struct test_params tp); --int run_aes_128_cbc(int fdc, struct test_params tp); --int run_aes_256_xts(int fdc, struct test_params tp); --int run_crc32c(int fdc, struct test_params tp); --int run_sha1(int fdc, struct test_params tp); --int run_sha256(int fdc, struct test_params tp); -- --#define ALG_COUNT 6 --struct { -- char *name; -- int (*func)(int, struct test_params); --} ciphers[ALG_COUNT] = { -- {"null", run_null}, -- {"aes-128-cbc", run_aes_128_cbc}, -- {"aes-256-xts", run_aes_256_xts}, -- {"crc32c", run_crc32c}, -- {"sha1", run_sha1}, -- {"sha256", run_sha256}, --}; -- --static double udifftimeval(struct timeval start, struct timeval end) --{ -- return (double)(end.tv_usec - start.tv_usec) + -- (double)(end.tv_sec - start.tv_sec) * 1000 * 1000; --} -- --static volatile int must_finish; --static volatile int must_exit; --static struct pollfd pfd; -- --static void alarm_handler(int signo) --{ -- must_finish = 1; -- pfd.events = POLLIN; --} -- --static void exit_handler(int signo) --{ -- must_exit = 1; -- printf("\nexit requested by user through ctrl+c \n"); --} -- --static char *units[] = { "", "Ki", "Mi", "Gi", "Ti", 0}; -- --static void value2human(uint64_t bytes, double time, double* data, double* speed,char* metric) --{ -- int unit = 0; -- -- *data = bytes; -- while (*data > 1024 && units[unit + 1]) { -- *data /= 1024; -- unit++; -- } -- *speed = *data / time; -- sprintf(metric, "%sB", units[unit]); --} -- --static void value2machine(uint64_t bytes, double time, double* speed) --{ -- *speed = bytes / time; --} -- --int get_alignmask(int fdc, struct session_op *sess) --{ -- int alignmask; -- int min_alignmask = sizeof(void*) - 1; -- --#ifdef CIOCGSESSINFO -- struct session_info_op siop; -- -- siop.ses = sess->ses; -- if (ioctl(fdc, CIOCGSESSINFO, &siop)) { -- perror("ioctl(CIOCGSESSINFO)"); -- return -EINVAL; -- } -- alignmask = siop.alignmask; -- if (alignmask < min_alignmask) { -- alignmask = min_alignmask; -- } --#else -- alignmask = 0; --#endif -- -- return alignmask; --} -- --int encrypt_data(int fdc, struct test_params tp, struct session_op *sess) --{ -- struct crypt_op cop; -- char *buffer[64], iv[32]; -- uint8_t mac[64][HASH_MAX_LEN]; -- static int val = 23; -- struct timeval start, end; -- uint64_t total = 0; -- double secs, ddata, dspeed; -- char metric[16]; -- int rc, wqueue = 0, bufidx = 0; -- int alignmask; -- -- memset(iv, 0x23, 32); -- -- if (!tp.mflag) { -- printf("\tBuffer size %d bytes: ", tp.nvalue); -- fflush(stdout); -- } -- -- alignmask = get_alignmask(fdc, sess); -- for (rc = 0; rc < 64; rc++) { -- if (alignmask) { -- if (posix_memalign((void **)(buffer + rc), alignmask + 1, tp.nvalue)) { -- printf("posix_memalign() failed!\n"); -- return 1; -- } -- } else { -- if (!(buffer[rc] = malloc(tp.nvalue))) { -- perror("malloc()"); -- return 1; -- } -- } -- memset(buffer[rc], val++, tp.nvalue); -- } -- pfd.fd = fdc; -- pfd.events = POLLOUT | POLLIN; -- -- must_finish = 0; -- alarm(tp.tvalue); -- -- gettimeofday(&start, NULL); -- do { -- if ((rc = poll(&pfd, 1, 100)) < 0) { -- if (errno & (ERESTART | EINTR)) -- continue; -- fprintf(stderr, "errno = %d ", errno); -- perror("poll()"); -- return 1; -- } -- -- if (pfd.revents & POLLOUT) { -- memset(&cop, 0, sizeof(cop)); -- cop.ses = sess->ses; -- cop.len = tp.nvalue; -- cop.iv = (unsigned char *)iv; -- cop.op = COP_ENCRYPT; -- cop.src = cop.dst = (unsigned char *)buffer[bufidx]; -- cop.mac = mac[bufidx]; -- bufidx = (bufidx + 1) % 64; -- -- if (ioctl(fdc, CIOCASYNCCRYPT, &cop)) { -- perror("ioctl(CIOCASYNCCRYPT)"); -- return 1; -- } -- wqueue++; -- } -- if (pfd.revents & POLLIN) { -- if (ioctl(fdc, CIOCASYNCFETCH, &cop)) { -- perror("ioctl(CIOCASYNCFETCH)"); -- return 1; -- } -- wqueue--; -- total += cop.len; -- } -- } while(!must_finish || wqueue); -- gettimeofday(&end, NULL); -- -- secs = udifftimeval(start, end)/ 1000000.0; -- -- if (tp.mflag) { -- value2machine(total, secs, &dspeed); -- printf("%" PRIu64 "\t%.2f\t%.2f\n", total, secs, dspeed); -- } else { -- value2human(total, secs, &ddata, &dspeed, metric); -- printf ("done. %.2f %s in %.2f secs: ", ddata, metric, secs); -- printf ("%.2f %s/sec\n", dspeed, metric); -- } -- -- for (rc = 0; rc < 64; rc++) -- free(buffer[rc]); -- return 0; --} -- --void usage(char *cmd_name) --{ -- printf(usage_str, cmd_name); --} -- --int run_test(int id, struct test_params tp) --{ -- int fd; -- int fdc; -- int err; -- -- fd = open("/dev/crypto", O_RDWR, 0); -- if (fd < 0) { -- perror("open()"); -- return fd; -- } -- if (ioctl(fd, CRIOGET, &fdc)) { -- perror("ioctl(CRIOGET)"); -- return -EINVAL; -- } -- -- if (!tp.mflag) { -- fprintf(stderr, "Testing %s:\n", ciphers[id].name); -- } -- err = ciphers[id].func(fdc, tp); -- -- close(fdc); -- close(fd); -- -- return err; --} -- --void do_test_vectors(int fdc, struct test_params tp, struct session_op *sess) --{ -- int i; -- -- if (tp.nflag) { -- encrypt_data(fdc, tp, sess); -- } else { -- for (i = 256; i <= (64 * 1024); i *= 2) { -- if (must_exit) { -- break; -- } -- -- tp.nvalue = i; -- if (encrypt_data(fdc, tp, sess)) { -- break; -- } -- } -- } --} -- -- --int run_null(int fdc, struct test_params tp) --{ -- struct session_op sess; -- char keybuf[32]; -- -- fprintf(stderr, "Testing NULL cipher: \n"); -- memset(&sess, 0, sizeof(sess)); -- sess.cipher = CRYPTO_NULL; -- sess.keylen = 0; -- sess.key = (unsigned char *)keybuf; -- if (ioctl(fdc, CIOCGSESSION, &sess)) { -- perror("ioctl(CIOCGSESSION)"); -- return -EINVAL; -- } -- -- do_test_vectors(fdc, tp, &sess); -- return 0; --} -- --int run_aes_128_cbc(int fdc, struct test_params tp) --{ -- struct session_op sess; -- char keybuf[32]; -- -- memset(&sess, 0, sizeof(sess)); -- sess.cipher = CRYPTO_AES_CBC; -- sess.keylen = 16; -- memset(keybuf, 0x42, 16); -- sess.key = (unsigned char *)keybuf; -- if (ioctl(fdc, CIOCGSESSION, &sess)) { -- perror("ioctl(CIOCGSESSION)"); -- return -EINVAL; -- } -- -- do_test_vectors(fdc, tp, &sess); -- return 0; --} -- --int run_aes_256_xts(int fdc, struct test_params tp) --{ -- struct session_op sess; -- char keybuf[32]; -- -- memset(&sess, 0, sizeof(sess)); -- sess.cipher = CRYPTO_AES_XTS; -- sess.keylen = 32; -- memset(keybuf, 0x42, sess.keylen); -- sess.key = (unsigned char *)keybuf; -- if (ioctl(fdc, CIOCGSESSION, &sess)) { -- perror("ioctl(CIOCGSESSION)"); -- return -EINVAL; -- } -- -- do_test_vectors(fdc, tp, &sess); -- return 0; --} -- --int run_crc32c(int fdc, struct test_params tp) --{ -- struct session_op sess; -- -- memset(&sess, 0, sizeof(sess)); -- sess.mac = CRYPTO_CRC32C; -- if (ioctl(fdc, CIOCGSESSION, &sess)) { -- perror("ioctl(CIOCGSESSION)"); -- return 1; -- } -- -- do_test_vectors(fdc, tp, &sess); -- return 0; --} -- --int run_sha1(int fdc, struct test_params tp) --{ -- struct session_op sess; -- -- memset(&sess, 0, sizeof(sess)); -- sess.mac = CRYPTO_SHA1; -- if (ioctl(fdc, CIOCGSESSION, &sess)) { -- perror("ioctl(CIOCGSESSION)"); -- return 1; -- } -- -- do_test_vectors(fdc, tp, &sess); -- return 0; --} -- --int run_sha256(int fdc, struct test_params tp) --{ -- struct session_op sess; -- -- memset(&sess, 0, sizeof(sess)); -- sess.mac = CRYPTO_SHA2_256; -- if (ioctl(fdc, CIOCGSESSION, &sess)) { -- perror("ioctl(CIOCGSESSION)"); -- return 1; -- } -- -- do_test_vectors(fdc, tp, &sess); -- return 0; --} -- --int main(int argc, char **argv) --{ -- int err = 0; -- int i; -- int c; -- bool alg_flag; -- char *alg_name; -- struct test_params tp; -- -- tp.tflag = false; -- tp.nflag = false; -- tp.mflag = false; -- alg_flag = false; -- opterr = 0; -- while ((c = getopt(argc, argv, "hn:t:m")) != -1) { -- switch (c) { -- case 'n': -- tp.nvalue = atoi(optarg); -- tp.nflag = true; -- break; -- case 't': -- tp.tvalue = atoi(optarg); -- tp.tflag = true; -- break; -- case 'm': -- tp.mflag = true; -- break; -- case 'h': /* no break */ -- default: -- usage(argv[0]); -- exit(1); -- } -- } -- -- /* the name of a specific test asked on the command line */ -- if (optind < argc) { -- alg_name = argv[optind]; -- alg_flag = true; -- } -- -- /* default test time */ -- if (!tp.tflag) { -- tp.tvalue = 5; -- } -- -- signal(SIGALRM, alarm_handler); -- signal(SIGINT, exit_handler); -- -- for (i = 0; i < ALG_COUNT; i++) { -- if (must_exit) { -- break; -- } -- -- if (alg_flag) { -- if (strcmp(alg_name, ciphers[i].name) == 0) { -- err = run_test(i, tp); -- } -- } else { -- err = run_test(i, tp); -- if (err != 0) { -- break; -- } -- } -- } -- -- return err; --} -- --#else --int --main(int argc, char** argv) --{ -- return (0); --} --#endif -diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh -deleted file mode 100755 -index 90f9b72..0000000 ---- a/tests/async_speed_multi.sh -+++ /dev/null -@@ -1,172 +0,0 @@ --#!/bin/bash --# --# Copyright 2016 NXP Semiconductors --# --# This program is free software: you can redistribute it and/or modify --# it under the terms of the GNU General Public License as published by --# the Free Software Foundation, either version 2 of the License, or --# (at your option) any later version. --# --# This program is distributed in the hope that it will be useful, --# but WITHOUT ANY WARRANTY; without even the implied warranty of --# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --# GNU General Public License for more details. --# --# You should have received a copy of the GNU General Public License --# along with this program. If not, see . -- -- -- --# no user-configurable options below this line -- --NUM_CORES=$(nproc) --CMD_BIN="async_speed" --OUT_BASENAME="async_speed" --MPSTAT_OUT="mpstat_out" -- --# A bigger hammer for mpstat to use ISO8601 time format (fixed in 11.2.2) --export LC_TIME=en_GB.UTF-8 &> /dev/null -- -- --function usage --{ --cat << EOF --Usage: `basename $0` [OPTIONS] -- -- -m number of threads to run with (defaults to number of cores) -- -t time to run each test (default 10 secs) -- -n size of the test buffer (default 256 bytes) -- -v make output more verbose (default tabular) -- -h show this help -- --alg_name: null, aes-128-cbc, aes-256-xts, sha1, sha256, crc32c -- --Note: SEC driver is configured to support buffers smaller than 512K --EOF --} -- --function SUM { -- paste -sd+ - | bc -l --} -- --function get_cpu_idle --{ -- header_line=$(grep %idle ${MPSTAT_OUT} | head -n 1 | sed 's/\s\+/ /g') -- idle_column=$(echo $header_line | wc -w) -- average_idle=$(grep Average ${MPSTAT_OUT} | sed 's/\s\+/ /g' | cut -d' ' -f ${idle_column} | tail -n 1) -- -- echo $average_idle --} -- --function run_parallel --{ -- trap control_c SIGINT -- -- OPTIONS="-t $tvalue -n $nvalue -m" -- CMD="$CMD_BIN $OPTIONS $alg_name" -- -- (sleep 1; S_TIME_FORMAT=ISO mpstat 1 $(($tvalue-2))) &> $MPSTAT_OUT & -- MPSTAT_PID=$! -- -- PIDS="" -- start=$(date +%s.%N) -- -- for i in $(seq 0 $(($mvalue-1))) -- do -- CMD_OUT="${OUT_BASENAME}_${i}" -- -- $CMD &> $CMD_OUT & -- PID=$! -- AFFINITY=$(($i % $NUM_CORES)) -- taskset -pc $AFFINITY $PID > /dev/null -- -- PIDS="$PID $PIDS" -- done -- -- wait $PIDS -- end=$(date +%s.%N) -- -- wait $MPSTAT_PID -- -- grep "ioctl" ${OUT_BASENAME}_* &> /dev/null -- if (($? == 0)) -- then -- echo "cryptodev is not built with -DENABLE_ASYNC flag" -- exit 1 -- fi -- -- runtime=$(echo "scale=2; ($end - $start) / 1" | bc -l ) -- total_data=$(cat ${OUT_BASENAME}_* | cut -f 1 | SUM) -- avg_speed=$(echo "scale=2; $total_data / $runtime / 1000000000" | bc -l) -- cpu_idle=$(get_cpu_idle) -- -- if [ ! -z "$vvalue" ] -- then -- echo -- echo "buffer size : $nvalue" -- echo "running time : $runtime" -- echo "avg_speed : $avg_speed GB/s" -- echo "all_cpu idle : $cpu_idle %" -- echo -- else -- echo -e "algorithm\t""threads\t""run time\t"\ -- "buffer size\t""GB/s\t""%cpu idle" -- echo -e "${alg_name}\t${mvalue}\t${runtime}\t"\ -- "${nvalue}\t${avg_speed}\t${cpu_idle}%" -- fi --} -- --function control_c --{ -- killall async_speed > /dev/null -- killall mpstat > /dev/null --} -- --function main --{ -- [ ! -e "/dev/crypto" ] && -- (sudo modprobe cryptodev || modprobe cryptodev || exit 1) -- -- $(which ${CMD_BIN} &> /dev/null) -- if (($? != 0)) -- then -- echo "${CMD_BIN} test is not installed" -- exit 1 -- fi -- -- rm -f ${OUT_BASENAME}_* -- rm -f ${MPSTAT_OUT} -- -- while getopts vhm:t:n: option -- do -- case "$option" in -- m) mvalue="$OPTARG";; -- t) tvalue="$OPTARG";; -- n) nvalue="$OPTARG";; -- v) vvalue="verbose";; -- *) usage $0; exit 1;; -- esac -- done -- -- shift $((OPTIND-1)) -- alg_name=$1 -- -- [ -z "$tvalue" ] && tvalue=10 # 10 seconds per test by default -- [ -z "$mvalue" ] && mvalue=$NUM_CORES # thread count defaults to nproc -- [ -z "$nvalue" ] && nvalue=256 # 256 bytes default buffer size -- -- [ "$tvalue" -lt 5 ] && tvalue=5 -- -- case "$alg_name" in -- "null" |\ -- "aes-128-cbc" |\ -- "aes-256-xts" |\ -- "sha1" |\ -- "sha256" |\ -- "crc32c" ) run_parallel;; -- * ) usage && exit 1;; -- esac --} -- --main "$@" -- -diff --git a/tests/run_crypto_tests.sh b/tests/run_crypto_tests.sh -index 32ab8e2..e128637 100644 ---- a/tests/run_crypto_tests.sh -+++ b/tests/run_crypto_tests.sh -@@ -16,7 +16,7 @@ do - do - for bsize in ${BUF_SIZE} - do -- async_speed_multi.sh -t 10 -n $bsize -m ${multi} ${alg_name} | -+ speed_multi.sh -t 10 -n $bsize -m ${multi} ${alg_name} | - tail -n 1 - done - done -diff --git a/tests/speed.c b/tests/speed.c -new file mode 100644 -index 0000000..3b36db1 ---- /dev/null -+++ b/tests/speed.c -@@ -0,0 +1,546 @@ -+/* cryptodev_test - simple benchmark tool for cryptodev -+ * -+ * Copyright (C) 2010 by Phil Sutter -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -+ */ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+ -+struct test_params { -+ bool tflag; -+ bool nflag; -+ bool mflag; -+ bool aflag; -+ int tvalue; -+ int nvalue; -+}; -+ -+const char usage_str[] = "Usage: %s [OPTION]... |\n" -+ "Run benchmark test for cipher or hash\n\n" -+ " -t \t" "time to run each test (default 10 secs)\n" -+ " -n \t" "size of the test buffer\n" -+ " -m\t\t" "output in a machine readable format\n" -+ " -a\t\t" "run the async tests (default sync)\n" -+ " -h\t\t" "show this help\n\n" -+ "Note: SEC driver is configured to support buffers smaller than 512K\n" -+; -+ -+int run_null(int fdc, struct test_params tp); -+int run_aes_128_cbc(int fdc, struct test_params tp); -+int run_aes_256_xts(int fdc, struct test_params tp); -+int run_crc32c(int fdc, struct test_params tp); -+int run_sha1(int fdc, struct test_params tp); -+int run_sha256(int fdc, struct test_params tp); -+ -+#define ALG_COUNT 6 -+struct { -+ char *name; -+ int (*func)(int, struct test_params); -+} ciphers[ALG_COUNT] = { -+ {"null", run_null}, -+ {"aes-128-cbc", run_aes_128_cbc}, -+ {"aes-256-xts", run_aes_256_xts}, -+ {"crc32c", run_crc32c}, -+ {"sha1", run_sha1}, -+ {"sha256", run_sha256}, -+}; -+ -+static double udifftimeval(struct timeval start, struct timeval end) -+{ -+ return (double)(end.tv_usec - start.tv_usec) + -+ (double)(end.tv_sec - start.tv_sec) * 1000 * 1000; -+} -+ -+static volatile int must_finish; -+static volatile int must_exit; -+static struct pollfd pfd; -+ -+static void alarm_handler(int signo) -+{ -+ must_finish = 1; -+ pfd.events = POLLIN; -+} -+ -+static void exit_handler(int signo) -+{ -+ must_exit = 1; -+ printf("\nexit requested by user through ctrl+c \n"); -+} -+ -+static char *units[] = { "", "Ki", "Mi", "Gi", "Ti", 0}; -+ -+static void value2human(uint64_t bytes, double time, double* data, double* speed,char* metric) -+{ -+ int unit = 0; -+ -+ *data = bytes; -+ while (*data > 1024 && units[unit + 1]) { -+ *data /= 1024; -+ unit++; -+ } -+ *speed = *data / time; -+ sprintf(metric, "%sB", units[unit]); -+} -+ -+static void value2machine(uint64_t bytes, double time, double* speed) -+{ -+ *speed = bytes / time; -+} -+ -+int get_alignmask(int fdc, struct session_op *sess) -+{ -+ int alignmask; -+ int min_alignmask = sizeof(void*) - 1; -+ -+#ifdef CIOCGSESSINFO -+ struct session_info_op siop; -+ -+ siop.ses = sess->ses; -+ if (ioctl(fdc, CIOCGSESSINFO, &siop)) { -+ perror("ioctl(CIOCGSESSINFO)"); -+ return -EINVAL; -+ } -+ alignmask = siop.alignmask; -+ if (alignmask < min_alignmask) { -+ alignmask = min_alignmask; -+ } -+#else -+ alignmask = 0; -+#endif -+ -+ return alignmask; -+} -+ -+int encrypt_async(int fdc, struct test_params tp, struct session_op *sess) -+{ -+ struct crypt_op cop; -+ char *buffer[64], iv[32]; -+ uint8_t mac[64][HASH_MAX_LEN]; -+ static int val = 23; -+ struct timeval start, end; -+ uint64_t total = 0; -+ double secs, ddata, dspeed; -+ char metric[16]; -+ int rc, wqueue = 0, bufidx = 0; -+ int alignmask; -+ -+ memset(iv, 0x23, 32); -+ -+ if (!tp.mflag) { -+ printf("\tBuffer size %d bytes: ", tp.nvalue); -+ fflush(stdout); -+ } -+ -+ alignmask = get_alignmask(fdc, sess); -+ for (rc = 0; rc < 64; rc++) { -+ if (alignmask) { -+ if (posix_memalign((void **)(buffer + rc), alignmask + 1, tp.nvalue)) { -+ printf("posix_memalign() failed!\n"); -+ return 1; -+ } -+ } else { -+ if (!(buffer[rc] = malloc(tp.nvalue))) { -+ perror("malloc()"); -+ return 1; -+ } -+ } -+ memset(buffer[rc], val++, tp.nvalue); -+ } -+ pfd.fd = fdc; -+ pfd.events = POLLOUT | POLLIN; -+ -+ must_finish = 0; -+ alarm(tp.tvalue); -+ -+ gettimeofday(&start, NULL); -+ do { -+ if ((rc = poll(&pfd, 1, 100)) < 0) { -+ if (errno & (ERESTART | EINTR)) -+ continue; -+ fprintf(stderr, "errno = %d ", errno); -+ perror("poll()"); -+ return 1; -+ } -+ -+ if (pfd.revents & POLLOUT) { -+ memset(&cop, 0, sizeof(cop)); -+ cop.ses = sess->ses; -+ cop.len = tp.nvalue; -+ cop.iv = (unsigned char *)iv; -+ cop.op = COP_ENCRYPT; -+ cop.src = cop.dst = (unsigned char *)buffer[bufidx]; -+ cop.mac = mac[bufidx]; -+ bufidx = (bufidx + 1) % 64; -+ -+ if (ioctl(fdc, CIOCASYNCCRYPT, &cop)) { -+ perror("ioctl(CIOCASYNCCRYPT)"); -+ return 1; -+ } -+ wqueue++; -+ } -+ if (pfd.revents & POLLIN) { -+ if (ioctl(fdc, CIOCASYNCFETCH, &cop)) { -+ perror("ioctl(CIOCASYNCFETCH)"); -+ return 1; -+ } -+ wqueue--; -+ total += cop.len; -+ } -+ } while(!must_finish || wqueue); -+ gettimeofday(&end, NULL); -+ -+ secs = udifftimeval(start, end)/ 1000000.0; -+ -+ if (tp.mflag) { -+ value2machine(total, secs, &dspeed); -+ printf("%" PRIu64 "\t%.2f\t%.2f\n", total, secs, dspeed); -+ } else { -+ value2human(total, secs, &ddata, &dspeed, metric); -+ printf ("done. %.2f %s in %.2f secs: ", ddata, metric, secs); -+ printf ("%.2f %s/sec\n", dspeed, metric); -+ } -+ -+ for (rc = 0; rc < 64; rc++) -+ free(buffer[rc]); -+ return 0; -+} -+ -+ -+static int encrypt_sync(int fdc, struct test_params tp, struct session_op *sess) -+{ -+ struct crypt_op cop; -+ char *buffer, iv[32]; -+ char mac[HASH_MAX_LEN]; -+ static int val = 23; -+ struct timeval start, end; -+ uint64_t total = 0; -+ double secs, ddata, dspeed; -+ char metric[16]; -+ int alignmask; -+ int min_alignmask = sizeof(void*) - 1; -+ -+ memset(iv, 0x23, 32); -+ -+ if (!tp.mflag) { -+ printf("\tBuffer size %d bytes: ", tp.nvalue); -+ fflush(stdout); -+ } -+ -+ alignmask = get_alignmask(fdc, sess); -+ if (alignmask) { -+ alignmask = ((alignmask < min_alignmask) ? min_alignmask : alignmask); -+ if (posix_memalign((void **)(&buffer), alignmask + 1, tp.nvalue)) { -+ printf("posix_memalign() failed!\n"); -+ return 1; -+ } -+ } else { -+ if (!(buffer = malloc(tp.nvalue))) { -+ perror("malloc()"); -+ return 1; -+ } -+ } -+ memset(buffer, val++, tp.nvalue); -+ -+ must_finish = 0; -+ alarm(tp.tvalue); -+ -+ gettimeofday(&start, NULL); -+ do { -+ memset(&cop, 0, sizeof(cop)); -+ cop.ses = sess->ses; -+ cop.len = tp.nvalue; -+ cop.iv = (unsigned char *)iv; -+ cop.op = COP_ENCRYPT; -+ cop.src = cop.dst = (unsigned char *)buffer; -+ cop.mac = (unsigned char *)mac; -+ -+ if (ioctl(fdc, CIOCCRYPT, &cop)) { -+ perror("ioctl(CIOCCRYPT)"); -+ return 1; -+ } -+ total += cop.len; -+ } while(!must_finish); -+ gettimeofday(&end, NULL); -+ -+ secs = udifftimeval(start, end)/ 1000000.0; -+ -+ if (tp.mflag) { -+ value2machine(total, secs, &dspeed); -+ printf("%" PRIu64 "\t%.2f\t%.2f\n", total, secs, dspeed); -+ } else { -+ value2human(total, secs, &ddata, &dspeed, metric); -+ printf ("done. %.2f %s in %.2f secs: ", ddata, metric, secs); -+ printf ("%.2f %s/sec\n", dspeed, metric); -+ } -+ -+ free(buffer); -+ return 0; -+} -+ -+void usage(char *cmd_name) -+{ -+ printf(usage_str, cmd_name); -+} -+ -+int run_test(int id, struct test_params tp) -+{ -+ int fd; -+ int fdc; -+ int err; -+ -+ fd = open("/dev/crypto", O_RDWR, 0); -+ if (fd < 0) { -+ perror("open()"); -+ return fd; -+ } -+ if (ioctl(fd, CRIOGET, &fdc)) { -+ perror("ioctl(CRIOGET)"); -+ return -EINVAL; -+ } -+ -+ if (!tp.mflag) { -+ char *type; -+ type = tp.aflag ? "async" : "sync"; -+ -+ fprintf(stderr, "Testing %s %s:\n", type, ciphers[id].name); -+ } -+ err = ciphers[id].func(fdc, tp); -+ -+ close(fdc); -+ close(fd); -+ -+ return err; -+} -+ -+void do_test_vectors(int fdc, struct test_params tp, struct session_op *sess) -+{ -+ int i; -+ int err; -+ -+ if (tp.nflag) { -+ if (tp.aflag) { -+ encrypt_async(fdc, tp, sess); -+ } else { -+ encrypt_sync(fdc, tp, sess); -+ } -+ } else { -+ for (i = 256; i <= (64 * 1024); i *= 2) { -+ if (must_exit) { -+ break; -+ } -+ -+ tp.nvalue = i; -+ if (tp.aflag) { -+ err = encrypt_async(fdc, tp, sess); -+ } else { -+ err = encrypt_sync(fdc, tp, sess); -+ } -+ -+ if (err != 0) { -+ break; -+ } -+ } -+ } -+} -+ -+ -+int run_null(int fdc, struct test_params tp) -+{ -+ struct session_op sess; -+ char keybuf[32]; -+ -+ fprintf(stderr, "Testing NULL cipher: \n"); -+ memset(&sess, 0, sizeof(sess)); -+ sess.cipher = CRYPTO_NULL; -+ sess.keylen = 0; -+ sess.key = (unsigned char *)keybuf; -+ if (ioctl(fdc, CIOCGSESSION, &sess)) { -+ perror("ioctl(CIOCGSESSION)"); -+ return -EINVAL; -+ } -+ -+ do_test_vectors(fdc, tp, &sess); -+ return 0; -+} -+ -+int run_aes_128_cbc(int fdc, struct test_params tp) -+{ -+ struct session_op sess; -+ char keybuf[32]; -+ -+ memset(&sess, 0, sizeof(sess)); -+ sess.cipher = CRYPTO_AES_CBC; -+ sess.keylen = 16; -+ memset(keybuf, 0x42, 16); -+ sess.key = (unsigned char *)keybuf; -+ if (ioctl(fdc, CIOCGSESSION, &sess)) { -+ perror("ioctl(CIOCGSESSION)"); -+ return -EINVAL; -+ } -+ -+ do_test_vectors(fdc, tp, &sess); -+ return 0; -+} -+ -+int run_aes_256_xts(int fdc, struct test_params tp) -+{ -+ struct session_op sess; -+ char keybuf[32]; -+ -+ memset(&sess, 0, sizeof(sess)); -+ sess.cipher = CRYPTO_AES_XTS; -+ sess.keylen = 32; -+ memset(keybuf, 0x42, sess.keylen); -+ sess.key = (unsigned char *)keybuf; -+ if (ioctl(fdc, CIOCGSESSION, &sess)) { -+ perror("ioctl(CIOCGSESSION)"); -+ return -EINVAL; -+ } -+ -+ do_test_vectors(fdc, tp, &sess); -+ return 0; -+} -+ -+int run_crc32c(int fdc, struct test_params tp) -+{ -+ struct session_op sess; -+ -+ memset(&sess, 0, sizeof(sess)); -+ sess.mac = CRYPTO_CRC32C; -+ if (ioctl(fdc, CIOCGSESSION, &sess)) { -+ perror("ioctl(CIOCGSESSION)"); -+ return 1; -+ } -+ -+ do_test_vectors(fdc, tp, &sess); -+ return 0; -+} -+ -+int run_sha1(int fdc, struct test_params tp) -+{ -+ struct session_op sess; -+ -+ memset(&sess, 0, sizeof(sess)); -+ sess.mac = CRYPTO_SHA1; -+ if (ioctl(fdc, CIOCGSESSION, &sess)) { -+ perror("ioctl(CIOCGSESSION)"); -+ return 1; -+ } -+ -+ do_test_vectors(fdc, tp, &sess); -+ return 0; -+} -+ -+int run_sha256(int fdc, struct test_params tp) -+{ -+ struct session_op sess; -+ -+ memset(&sess, 0, sizeof(sess)); -+ sess.mac = CRYPTO_SHA2_256; -+ if (ioctl(fdc, CIOCGSESSION, &sess)) { -+ perror("ioctl(CIOCGSESSION)"); -+ return 1; -+ } -+ -+ do_test_vectors(fdc, tp, &sess); -+ return 0; -+} -+ -+int main(int argc, char **argv) -+{ -+ int err = 0; -+ int i; -+ int c; -+ bool alg_flag; -+ char *alg_name; -+ struct test_params tp; -+ -+ tp.tflag = false; -+ tp.nflag = false; -+ tp.mflag = false; -+ tp.aflag = false; -+ alg_flag = false; -+ opterr = 0; -+ while ((c = getopt(argc, argv, "ahn:t:m")) != -1) { -+ switch (c) { -+ case 'n': -+ tp.nvalue = atoi(optarg); -+ tp.nflag = true; -+ break; -+ case 't': -+ tp.tvalue = atoi(optarg); -+ tp.tflag = true; -+ break; -+ case 'm': -+ tp.mflag = true; -+ break; -+ case 'a': -+ tp.aflag = true; -+ break; -+ case 'h': /* no break */ -+ default: -+ usage(argv[0]); -+ exit(1); -+ } -+ } -+ -+ /* the name of a specific test asked on the command line */ -+ if (optind < argc) { -+ alg_name = argv[optind]; -+ alg_flag = true; -+ } -+ -+ /* default test time */ -+ if (!tp.tflag) { -+ tp.tvalue = 5; -+ } -+ -+ signal(SIGALRM, alarm_handler); -+ signal(SIGINT, exit_handler); -+ -+ for (i = 0; i < ALG_COUNT; i++) { -+ if (must_exit) { -+ break; -+ } -+ -+ if (alg_flag) { -+ if (strcmp(alg_name, ciphers[i].name) == 0) { -+ err = run_test(i, tp); -+ } -+ } else { -+ err = run_test(i, tp); -+ if (err != 0) { -+ break; -+ } -+ } -+ } -+ -+ return err; -+} -diff --git a/tests/speed_multi.sh b/tests/speed_multi.sh -new file mode 100755 -index 0000000..b116483 ---- /dev/null -+++ b/tests/speed_multi.sh -@@ -0,0 +1,174 @@ -+#!/bin/bash -+# -+# Copyright 2016 NXP Semiconductors -+# -+# This program is free software: you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation, either version 2 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . -+ -+ -+ -+# no user-configurable options below this line -+ -+NUM_CORES=$(nproc) -+CMD_BIN="speed" -+OUT_BASENAME="speed" -+MPSTAT_OUT="mpstat_out" -+ -+# A bigger hammer for mpstat to use ISO8601 time format (fixed in 11.2.2) -+export LC_TIME=en_GB.UTF-8 &> /dev/null -+ -+ -+function usage -+{ -+cat << EOF -+Usage: `basename $0` [OPTIONS] -+ -+ -m number of threads to run with (defaults to number of cores) -+ -t time to run each test (default 10 secs) -+ -n size of the test buffer (default 256 bytes) -+ -v make output more verbose (default tabular) -+ -a run async version of the benchmark (default sync) -+ -h show this help -+ -+alg_name: null, aes-128-cbc, aes-256-xts, sha1, sha256, crc32c -+ -+Note: SEC driver is configured to support buffers smaller than 512K -+EOF -+} -+ -+function SUM { -+ paste -sd+ - | bc -l -+} -+ -+function get_cpu_idle -+{ -+ header_line=$(grep %idle ${MPSTAT_OUT} | head -n 1 | sed 's/\s\+/ /g') -+ idle_column=$(echo $header_line | wc -w) -+ average_idle=$(grep Average ${MPSTAT_OUT} | sed 's/\s\+/ /g' | cut -d' ' -f ${idle_column} | tail -n 1) -+ -+ echo $average_idle -+} -+ -+function run_parallel -+{ -+ trap control_c SIGINT -+ -+ OPTIONS="-t $tvalue -n $nvalue -m $aflag" -+ CMD="$CMD_BIN $OPTIONS $alg_name" -+ -+ (sleep 1; S_TIME_FORMAT=ISO mpstat 1 $(($tvalue-2))) &> $MPSTAT_OUT & -+ MPSTAT_PID=$! -+ -+ PIDS="" -+ start=$(date +%s.%N) -+ -+ for i in $(seq 0 $(($mvalue-1))) -+ do -+ CMD_OUT="${OUT_BASENAME}_${i}" -+ -+ $CMD &> $CMD_OUT & -+ PID=$! -+ AFFINITY=$(($i % $NUM_CORES)) -+ taskset -pc $AFFINITY $PID > /dev/null -+ -+ PIDS="$PID $PIDS" -+ done -+ -+ wait $PIDS -+ end=$(date +%s.%N) -+ -+ wait $MPSTAT_PID -+ -+ grep "ioctl" ${OUT_BASENAME}_* &> /dev/null -+ if (($? == 0)) -+ then -+ echo "cryptodev is not built with -DENABLE_ASYNC flag" -+ exit 1 -+ fi -+ -+ runtime=$(echo "scale=2; ($end - $start) / 1" | bc -l ) -+ total_data=$(cat ${OUT_BASENAME}_* | cut -f 1 | SUM) -+ avg_speed=$(echo "scale=2; $total_data / $runtime / 1000000000" | bc -l) -+ cpu_idle=$(get_cpu_idle) -+ -+ if [ ! -z "$vflag" ] -+ then -+ echo -+ echo "buffer size : $nvalue" -+ echo "running time : $runtime" -+ echo "avg_speed : $avg_speed GB/s" -+ echo "all_cpu idle : $cpu_idle %" -+ echo -+ else -+ echo -e "algorithm\t""threads\t""run time\t"\ -+ "buffer size\t""GB/s\t""%cpu idle" -+ echo -e "${alg_name}\t${mvalue}\t${runtime}\t"\ -+ "${nvalue}\t${avg_speed}\t${cpu_idle}%" -+ fi -+} -+ -+function control_c -+{ -+ killall $CMD_BIN > /dev/null -+ killall mpstat > /dev/null -+} -+ -+function main -+{ -+ [ ! -e "/dev/crypto" ] && -+ (sudo modprobe cryptodev || modprobe cryptodev || exit 1) -+ -+ $(which ${CMD_BIN} &> /dev/null) -+ if (($? != 0)) -+ then -+ echo "${CMD_BIN} test is not installed" -+ exit 1 -+ fi -+ -+ rm -f ${OUT_BASENAME}_* -+ rm -f ${MPSTAT_OUT} -+ -+ while getopts avhm:t:n: option -+ do -+ case "$option" in -+ m) mvalue="$OPTARG";; -+ t) tvalue="$OPTARG";; -+ n) nvalue="$OPTARG";; -+ v) vflag="verbose";; -+ a) aflag="-a";; -+ *) usage $0; exit 1;; -+ esac -+ done -+ -+ shift $((OPTIND-1)) -+ alg_name=$1 -+ -+ [ -z "$tvalue" ] && tvalue=10 # 10 seconds per test by default -+ [ -z "$mvalue" ] && mvalue=$NUM_CORES # thread count defaults to nproc -+ [ -z "$nvalue" ] && nvalue=256 # 256 bytes default buffer size -+ -+ [ "$tvalue" -lt 5 ] && tvalue=5 -+ -+ case "$alg_name" in -+ "null" |\ -+ "aes-128-cbc" |\ -+ "aes-256-xts" |\ -+ "sha1" |\ -+ "sha256" |\ -+ "crc32c" ) run_parallel;; -+ * ) usage && exit 1;; -+ esac -+} -+ -+main "$@" -+ -diff --git a/tests/sync_speed.c b/tests/sync_speed.c -deleted file mode 100644 -index ceae645..0000000 ---- a/tests/sync_speed.c -+++ /dev/null -@@ -1,400 +0,0 @@ --/* cryptodev_test - simple benchmark tool for cryptodev -- * -- * Copyright (C) 2010 by Phil Sutter -- * -- * This program is free software; you can redistribute it and/or modify -- * it under the terms of the GNU General Public License as published by -- * the Free Software Foundation; either version 2 of the License, or -- * (at your option) any later version. -- * -- * This program is distributed in the hope that it will be useful, -- * but WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- * GNU General Public License for more details. -- * -- * You should have received a copy of the GNU General Public License -- * along with this program; if not, write to the Free Software -- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -- */ --#include --#include --#include --#include --#include --#include --#include --#include --#include --#include --#include --#include --#include -- --struct test_params { -- bool tflag; -- bool nflag; -- int tvalue; -- int nvalue; --}; -- --const char usage_str[] = "Usage: %s [OPTION]... |\n" -- "Run benchmark test for cipher or hash\n\n" -- " -t \t" "time to run each test (default 10 secs)\n" -- " -n \t" "size of the test buffer\n" -- " -h\t\t" "show this help\n\n" -- "Note: SEC driver is configured to support buffers smaller than 512K\n" --; -- --int run_null(int fdc, struct test_params tp); --int run_aes_128_cbc(int fdc, struct test_params tp); --int run_aes_256_xts(int fdc, struct test_params tp); --int run_crc32c(int fdc, struct test_params tp); --int run_sha1(int fdc, struct test_params tp); --int run_sha256(int fdc, struct test_params tp); --int get_alignmask(int fdc, struct session_op *sess); -- --#define ALG_COUNT 6 --struct { -- char *name; -- int (*func)(int, struct test_params); --} ciphers[ALG_COUNT] = { -- {"null", run_null}, -- {"aes-128-cbc", run_aes_128_cbc}, -- {"aes-256-xts", run_aes_256_xts}, -- {"crc32c", run_crc32c}, -- {"sha1", run_sha1}, -- {"sha256", run_sha256}, --}; -- --static double udifftimeval(struct timeval start, struct timeval end) --{ -- return (double)(end.tv_usec - start.tv_usec) + -- (double)(end.tv_sec - start.tv_sec) * 1000 * 1000; --} -- --static volatile int must_finish; --static volatile int must_exit; -- --static void alarm_handler(int signo) --{ -- must_finish = 1; --} -- --static void exit_handler(int signo) --{ -- must_exit = 1; -- printf("\nexit requested by user through ctrl+c \n"); --} -- --static char *units[] = { "", "Ki", "Mi", "Gi", "Ti", 0}; -- --static void value2human(double bytes, double time, double* data, double* speed,char* metric) --{ -- int unit = 0; -- -- *data = bytes; -- while (*data > 1024 && units[unit + 1]) { -- *data /= 1024; -- unit++; -- } -- *speed = *data / time; -- sprintf(metric, "%sB", units[unit]); --} -- --static int encrypt_data(int fdc, struct test_params tp, struct session_op *sess) --{ -- struct crypt_op cop; -- char *buffer, iv[32]; -- char mac[HASH_MAX_LEN]; -- static int val = 23; -- struct timeval start, end; -- double total = 0; -- double secs, ddata, dspeed; -- char metric[16]; -- int alignmask; -- int min_alignmask = sizeof(void*) - 1; -- -- memset(iv, 0x23, 32); -- -- printf("\tEncrypting in chunks of %d bytes: ", tp.nvalue); -- fflush(stdout); -- -- alignmask = get_alignmask(fdc, sess); -- if (alignmask) { -- alignmask = ((alignmask < min_alignmask) ? min_alignmask : alignmask); -- if (posix_memalign((void **)(&buffer), alignmask + 1, tp.nvalue)) { -- printf("posix_memalign() failed!\n"); -- return 1; -- } -- } else { -- if (!(buffer = malloc(tp.nvalue))) { -- perror("malloc()"); -- return 1; -- } -- } -- memset(buffer, val++, tp.nvalue); -- -- must_finish = 0; -- alarm(tp.tvalue); -- -- gettimeofday(&start, NULL); -- do { -- memset(&cop, 0, sizeof(cop)); -- cop.ses = sess->ses; -- cop.len = tp.nvalue; -- cop.iv = (unsigned char *)iv; -- cop.op = COP_ENCRYPT; -- cop.src = cop.dst = (unsigned char *)buffer; -- cop.mac = (unsigned char *)mac; -- -- if (ioctl(fdc, CIOCCRYPT, &cop)) { -- perror("ioctl(CIOCCRYPT)"); -- return 1; -- } -- total += cop.len; -- } while(!must_finish); -- gettimeofday(&end, NULL); -- -- secs = udifftimeval(start, end)/ 1000000.0; -- -- value2human(total, secs, &ddata, &dspeed, metric); -- printf ("done. %.2f %s in %.2f secs: ", ddata, metric, secs); -- printf ("%.2f %s/sec\n", dspeed, metric); -- -- free(buffer); -- return 0; --} -- --void usage(char *cmd_name) --{ -- printf(usage_str, cmd_name); --} -- --int run_test(int id, struct test_params tp) --{ -- int fd; -- int fdc; -- -- fd = open("/dev/crypto", O_RDWR, 0); -- if (fd < 0) { -- perror("open()"); -- return fd; -- } -- if (ioctl(fd, CRIOGET, &fdc)) { -- perror("ioctl(CRIOGET)"); -- return -EINVAL; -- } -- -- ciphers[id].func(fdc, tp); -- -- close(fdc); -- close(fd); -- -- return 0; --} -- --int get_alignmask(int fdc, struct session_op *sess) --{ -- int alignmask; -- --#ifdef CIOCGSESSINFO -- struct session_info_op siop; -- -- siop.ses = sess->ses; -- if (ioctl(fdc, CIOCGSESSINFO, &siop)) { -- perror("ioctl(CIOCGSESSINFO)"); -- return -EINVAL; -- } -- alignmask = siop.alignmask; --#else -- alignmask = 0; --#endif -- -- return alignmask; --} -- --void do_test_vectors(int fdc, struct test_params tp, struct session_op *sess) --{ -- int i; -- -- if (tp.nflag) { -- encrypt_data(fdc, tp, sess); -- } else { -- for (i = 256; i <= (64 * 1024); i *= 2) { -- if (must_exit) -- break; -- -- tp.nvalue = i; -- if (encrypt_data(fdc, tp, sess)) { -- break; -- } -- } -- } --} -- -- --int run_null(int fdc, struct test_params tp) --{ -- struct session_op sess; -- char keybuf[32]; -- -- fprintf(stderr, "Testing NULL cipher: \n"); -- memset(&sess, 0, sizeof(sess)); -- sess.cipher = CRYPTO_NULL; -- sess.keylen = 0; -- sess.key = (unsigned char *)keybuf; -- if (ioctl(fdc, CIOCGSESSION, &sess)) { -- perror("ioctl(CIOCGSESSION)"); -- return -EINVAL; -- } -- -- do_test_vectors(fdc, tp, &sess); -- return 0; --} -- --int run_aes_128_cbc(int fdc, struct test_params tp) --{ -- struct session_op sess; -- char keybuf[32]; -- -- fprintf(stderr, "\nTesting AES-128-CBC cipher: \n"); -- memset(&sess, 0, sizeof(sess)); -- sess.cipher = CRYPTO_AES_CBC; -- sess.keylen = 16; -- memset(keybuf, 0x42, 16); -- sess.key = (unsigned char *)keybuf; -- if (ioctl(fdc, CIOCGSESSION, &sess)) { -- perror("ioctl(CIOCGSESSION)"); -- return -EINVAL; -- } -- -- do_test_vectors(fdc, tp, &sess); -- return 0; --} -- --int run_aes_256_xts(int fdc, struct test_params tp) --{ -- struct session_op sess; -- char keybuf[32]; -- -- fprintf(stderr, "\nTesting AES-256-XTS cipher: \n"); -- memset(&sess, 0, sizeof(sess)); -- sess.cipher = CRYPTO_AES_XTS; -- sess.keylen = 32; -- memset(keybuf, 0x42, sess.keylen); -- sess.key = (unsigned char *)keybuf; -- if (ioctl(fdc, CIOCGSESSION, &sess)) { -- perror("ioctl(CIOCGSESSION)"); -- return -EINVAL; -- } -- -- do_test_vectors(fdc, tp, &sess); -- return 0; --} -- --int run_crc32c(int fdc, struct test_params tp) --{ -- struct session_op sess; -- -- fprintf(stderr, "\nTesting CRC32C hash: \n"); -- memset(&sess, 0, sizeof(sess)); -- sess.mac = CRYPTO_CRC32C; -- if (ioctl(fdc, CIOCGSESSION, &sess)) { -- perror("ioctl(CIOCGSESSION)"); -- return 1; -- } -- -- do_test_vectors(fdc, tp, &sess); -- return 0; --} -- --int run_sha1(int fdc, struct test_params tp) --{ -- struct session_op sess; -- -- fprintf(stderr, "\nTesting SHA-1 hash: \n"); -- memset(&sess, 0, sizeof(sess)); -- sess.mac = CRYPTO_SHA1; -- if (ioctl(fdc, CIOCGSESSION, &sess)) { -- perror("ioctl(CIOCGSESSION)"); -- return 1; -- } -- -- do_test_vectors(fdc, tp, &sess); -- return 0; --} -- --int run_sha256(int fdc, struct test_params tp) --{ -- struct session_op sess; -- -- fprintf(stderr, "\nTesting SHA2-256 hash: \n"); -- memset(&sess, 0, sizeof(sess)); -- sess.mac = CRYPTO_SHA2_256; -- if (ioctl(fdc, CIOCGSESSION, &sess)) { -- perror("ioctl(CIOCGSESSION)"); -- return 1; -- } -- -- do_test_vectors(fdc, tp, &sess); -- return 0; --} -- --int main(int argc, char **argv) --{ -- int i; -- int c; -- bool alg_flag; -- char *alg_name; -- struct test_params tp; -- -- tp.tflag = false; -- tp.nflag = false; -- alg_flag = false; -- opterr = 0; -- while ((c = getopt(argc, argv, "hn:t:")) != -1) { -- switch (c) { -- case 'n': -- tp.nvalue = atoi(optarg); -- tp.nflag = true; -- break; -- case 't': -- tp.tvalue = atoi(optarg); -- tp.tflag = true; -- break; -- case 'h': /* no break */ -- default: -- usage(argv[0]); -- exit(1); -- } -- } -- -- /* the name of a specific test asked on the command line */ -- if (optind < argc) { -- alg_name = argv[optind]; -- alg_flag = true; -- } -- -- /* default test time */ -- if (!tp.tflag) { -- tp.tvalue = 5; -- } -- -- signal(SIGALRM, alarm_handler); -- signal(SIGINT, exit_handler); -- -- for (i = 0; i < ALG_COUNT; i++) { -- if (must_exit) -- break; -- -- if (alg_flag) { -- if (strcmp(alg_name, ciphers[i].name) == 0) { -- run_test(i, tp); -- } -- } else { -- run_test(i, tp); -- } -- } -- -- return 0; --} --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0089-add-async-option-to-run_crypto_tests.sh.patch b/recipes-kernel/cryptodev/sdk_patches/0089-add-async-option-to-run_crypto_tests.sh.patch deleted file mode 100644 index 50799f8d..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0089-add-async-option-to-run_crypto_tests.sh.patch +++ /dev/null @@ -1,62 +0,0 @@ -From bccc3add64bfd4a048bf7e5a2935b2fc719d8e13 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Tue, 1 Nov 2016 13:28:40 +0200 -Subject: [PATCH 089/104] add -async option to run_crypto_tests.sh - -Signed-off-by: Cristian Stoica ---- - tests/run_crypto_tests.sh | 31 ++++++++++++++++++++++++++++++- - 1 file changed, 30 insertions(+), 1 deletion(-) - -diff --git a/tests/run_crypto_tests.sh b/tests/run_crypto_tests.sh -index e128637..321b013 100644 ---- a/tests/run_crypto_tests.sh -+++ b/tests/run_crypto_tests.sh -@@ -4,6 +4,31 @@ - BUF_SIZE="8192 16384 65536 131072 262144" - THREAD_CNT="1 8 12" - ALG_NAMES="aes-128-cbc aes-256-xts sha1 sha256 crc32c" -+TIME=10 -+ -+############################ -+ -+function usage -+{ -+cat << EOF -+Usage: `basename $0` [OPTIONS] -+ -+ -a run async version of the benchmark (default sync) -+ -h show this help -+ -+Run in sequence benchmarks for several crypto algorithms: -+$ALG_NAMES -+EOF -+} -+ -+while getopts ah option -+do -+ case "$option" in -+ a) aflag="-a";; -+ *) usage $0; exit 1;; -+ esac -+done -+ - - #restool dpseci create --num-queues=8 --priorities=1,2,3,4,5,6,7,8 - #restool dprc assign dprc.1 --object=dpseci.0 --plugged=1 -@@ -16,7 +41,11 @@ do - do - for bsize in ${BUF_SIZE} - do -- speed_multi.sh -t 10 -n $bsize -m ${multi} ${alg_name} | -+ speed_multi.sh -t ${TIME}\ -+ -n ${bsize}\ -+ -m ${multi}\ -+ ${aflag}\ -+ ${alg_name} | - tail -n 1 - done - done --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0090-Adjust-to-recent-user-page-API-changes.patch b/recipes-kernel/cryptodev/sdk_patches/0090-Adjust-to-recent-user-page-API-changes.patch deleted file mode 100644 index 95959299..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0090-Adjust-to-recent-user-page-API-changes.patch +++ /dev/null @@ -1,55 +0,0 @@ -From d40bcfdfb2c2c5aa4c47b5653fdea3ee317d234b Mon Sep 17 00:00:00 2001 -From: Michael Weiser -Date: Fri, 5 Aug 2016 18:43:55 +0200 -Subject: [PATCH 090/104] Adjust to recent user page API changes - -4.6.0 basically renamed get_user_pages() to get_user_pages_remote() and -introduced a new get_user_pages() that always works on the current -task.[1] Distinguish the two APIs based on kernel version we're -compiling for. - -Also, there seems to have been a massive cleansing of -page_cache_release(page) in favour of put_page(page)[2] which was an -alias for put_page(page)[3] since 2.6.0. Before that beginning with -2.4.0 both page_cache_release(page) and put_page(page) have been aliases -for __free_page(page). So using put_page() instead of -page_cache_release(page) will produce identical code for anything after -2.4.0. - -[1] https://lkml.org/lkml/2016/2/10/555 -[2] https://www.spinics.net/lists/linux-fsdevel/msg95923.html -[3] https://www.spinics.net/lists/linux-fsdevel/msg95922.html ---- - zc.c | 9 +++++++-- - 1 file changed, 7 insertions(+), 2 deletions(-) - -diff --git a/zc.c b/zc.c -index 29b0501..a97b49f 100644 ---- a/zc.c -+++ b/zc.c -@@ -59,7 +59,12 @@ int __get_userbuf(uint8_t __user *addr, uint32_t len, int write, - } - - down_read(&mm->mmap_sem); -- ret = get_user_pages(task, mm, -+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)) -+ ret = get_user_pages_remote( -+#else -+ ret = get_user_pages( -+#endif -+ task, mm, - (unsigned long)addr, pgcount, write, 0, pg, NULL); - up_read(&mm->mmap_sem); - if (ret != pgcount) -@@ -119,7 +124,7 @@ void release_user_pages(struct csession *ses) - else - ses->readonly_pages--; - -- page_cache_release(ses->pages[i]); -+ put_page(ses->pages[i]); - } - ses->used_pages = 0; - } --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0091-Fix-test-compile-time-warnings.patch b/recipes-kernel/cryptodev/sdk_patches/0091-Fix-test-compile-time-warnings.patch deleted file mode 100644 index 639fe0fd..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0091-Fix-test-compile-time-warnings.patch +++ /dev/null @@ -1,65 +0,0 @@ -From a715480416b33b0bacd2b58ec42b9c64bdb21c0c Mon Sep 17 00:00:00 2001 -From: Michael Weiser -Date: Fri, 19 Aug 2016 10:24:40 +0100 -Subject: [PATCH 091/104] Fix test compile time warnings -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -A number of tests cause compiler warnings like this: - -hashcrypt_speed.c: In function ‘hash_data’: -hashcrypt_speed.c:101:2: warning: implicit declaration of function ‘alarm’ [-Wimplicit-function-declaration] - alarm(5); - ^~~~~ -hashcrypt_speed.c: In function ‘main’: -hashcrypt_speed.c:203:2: warning: implicit declaration of function ‘close’ [-Wimplicit-function-declaration] - close(fdc); - ^~~~~ - -Fix by including unistd.h. ---- - tests/hashcrypt_speed.c | 1 + - tests/sha_speed.c | 1 + - tests/speed.c | 1 + - 3 files changed, 3 insertions(+) - -diff --git a/tests/hashcrypt_speed.c b/tests/hashcrypt_speed.c -index 045bf8e..10c9f00 100644 ---- a/tests/hashcrypt_speed.c -+++ b/tests/hashcrypt_speed.c -@@ -21,6 +21,7 @@ - #include - #include - #include -+#include - #include - #include - #include -diff --git a/tests/sha_speed.c b/tests/sha_speed.c -index 9f2c8cc..30b40f5 100644 ---- a/tests/sha_speed.c -+++ b/tests/sha_speed.c -@@ -21,6 +21,7 @@ - #include - #include - #include -+#include - #include - #include - #include -diff --git a/tests/speed.c b/tests/speed.c -index 3b36db1..fc38a63 100644 ---- a/tests/speed.c -+++ b/tests/speed.c -@@ -22,6 +22,7 @@ - #include - #include - #include -+#include - #include - #include - #include --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0092-Support-skcipher-in-addition-to-ablkcipher-API.patch b/recipes-kernel/cryptodev/sdk_patches/0092-Support-skcipher-in-addition-to-ablkcipher-API.patch deleted file mode 100644 index 4a82955e..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0092-Support-skcipher-in-addition-to-ablkcipher-API.patch +++ /dev/null @@ -1,281 +0,0 @@ -From e41e73551c886366d741b5e401a3c4c661aa3020 Mon Sep 17 00:00:00 2001 -From: Michael Weiser -Date: Fri, 5 Aug 2016 17:26:27 +0200 -Subject: [PATCH 092/104] Support skcipher in addition to ablkcipher API - -The ablkcipher API is being phased out[1]. The unified skcipher API -seems to have made its entry with 4.3.[3, 4] By what can be seen from -migration patches[1.ff.], it's a drop-in replacement. - -Also, deallocators such as crypto_free_skcipher() are NULL-safe now[2]. - -Add a new header cipherapi.h to aid migration from ablkcipher to skcipher and -retain support for old kernels. Make it decide which API to use and provide -appropriate function calls and type definitions. Since the ablkcipher and -skcipher APIs are so similar, those are mainly defines for corresponding -pseudo-functions in namespace cryptodev_ derived directly from their API -counterparts. - -Compiles and works (i.e. checks pass) with Debian testing 4.6.4 kernel -as well as 4.8-rc2+ Linus git tree as of today. (Both require a fix for -changed page access API[5].) - -[1] https://www.spinics.net/lists/linux-crypto/msg18133.html -[2] https://www.spinics.net/lists/linux-crypto/msg18154.html, line 120 -[3] https://www.spinics.net/lists/linux-crypto/msg16373.html -[4] https://www.spinics.net/lists/linux-crypto/msg16294.html -[5] https://github.com/cryptodev-linux/cryptodev-linux/pull/14 ---- - cipherapi.h | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - cryptlib.c | 40 ++++++++++++++++++---------------------- - cryptlib.h | 6 ++++-- - ioctl.c | 4 ++-- - 4 files changed, 84 insertions(+), 26 deletions(-) - create mode 100644 cipherapi.h - -diff --git a/cipherapi.h b/cipherapi.h -new file mode 100644 -index 0000000..07d9923 ---- /dev/null -+++ b/cipherapi.h -@@ -0,0 +1,60 @@ -+#ifndef CIPHERAPI_H -+# define CIPHERAPI_H -+ -+#include -+ -+#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) -+# include -+ -+typedef struct ablkcipher_alg cryptodev_blkcipher_alg_t; -+typedef struct crypto_ablkcipher cryptodev_crypto_blkcipher_t; -+typedef struct ablkcipher_request cryptodev_blkcipher_request_t; -+ -+# define cryptodev_crypto_alloc_blkcipher crypto_alloc_ablkcipher -+# define cryptodev_crypto_blkcipher_alg crypto_ablkcipher_alg -+# define cryptodev_crypto_blkcipher_blocksize crypto_ablkcipher_blocksize -+# define cryptodev_crypto_blkcipher_ivsize crypto_ablkcipher_ivsize -+# define cryptodev_crypto_blkcipher_alignmask crypto_ablkcipher_alignmask -+# define cryptodev_crypto_blkcipher_setkey crypto_ablkcipher_setkey -+ -+static inline void cryptodev_crypto_free_blkcipher(cryptodev_crypto_blkcipher_t *c) { -+ if (c) -+ crypto_free_ablkcipher(c); -+} -+ -+# define cryptodev_blkcipher_request_alloc ablkcipher_request_alloc -+# define cryptodev_blkcipher_request_set_callback ablkcipher_request_set_callback -+ -+static inline void cryptodev_blkcipher_request_free(cryptodev_blkcipher_request_t *r) { -+ if (r) -+ ablkcipher_request_free(r); -+} -+ -+# define cryptodev_blkcipher_request_set_crypt ablkcipher_request_set_crypt -+# define cryptodev_crypto_blkcipher_encrypt crypto_ablkcipher_encrypt -+# define cryptodev_crypto_blkcipher_decrypt crypto_ablkcipher_decrypt -+# define cryptodev_crypto_blkcipher_tfm crypto_ablkcipher_tfm -+#else -+#include -+ -+typedef struct skcipher_alg cryptodev_blkcipher_alg_t; -+typedef struct crypto_skcipher cryptodev_crypto_blkcipher_t; -+typedef struct skcipher_request cryptodev_blkcipher_request_t; -+ -+# define cryptodev_crypto_alloc_blkcipher crypto_alloc_skcipher -+# define cryptodev_crypto_blkcipher_alg crypto_skcipher_alg -+# define cryptodev_crypto_blkcipher_blocksize crypto_skcipher_blocksize -+# define cryptodev_crypto_blkcipher_ivsize crypto_skcipher_ivsize -+# define cryptodev_crypto_blkcipher_alignmask crypto_skcipher_alignmask -+# define cryptodev_crypto_blkcipher_setkey crypto_skcipher_setkey -+# define cryptodev_crypto_free_blkcipher crypto_free_skcipher -+# define cryptodev_blkcipher_request_alloc skcipher_request_alloc -+# define cryptodev_blkcipher_request_set_callback skcipher_request_set_callback -+# define cryptodev_blkcipher_request_free skcipher_request_free -+# define cryptodev_blkcipher_request_set_crypt skcipher_request_set_crypt -+# define cryptodev_crypto_blkcipher_encrypt crypto_skcipher_encrypt -+# define cryptodev_crypto_blkcipher_decrypt crypto_skcipher_decrypt -+# define cryptodev_crypto_blkcipher_tfm crypto_skcipher_tfm -+#endif -+ -+#endif -diff --git a/cryptlib.c b/cryptlib.c -index 5d1a5a9..558d4b8 100644 ---- a/cryptlib.c -+++ b/cryptlib.c -@@ -24,7 +24,6 @@ - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - --#include - #include - #include - #include -@@ -38,6 +37,7 @@ - #include - #include - #include "cryptodev_int.h" -+#include "cipherapi.h" - - - static void cryptodev_complete(struct crypto_async_request *req, int err) -@@ -129,15 +129,15 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, - int ret; - - if (aead == 0) { -- struct ablkcipher_alg *alg; -+ cryptodev_blkcipher_alg_t *alg; - -- out->async.s = crypto_alloc_ablkcipher(alg_name, 0, 0); -+ out->async.s = cryptodev_crypto_alloc_blkcipher(alg_name, 0, 0); - if (unlikely(IS_ERR(out->async.s))) { - ddebug(1, "Failed to load cipher %s", alg_name); - return -EINVAL; - } - -- alg = crypto_ablkcipher_alg(out->async.s); -+ alg = cryptodev_crypto_blkcipher_alg(out->async.s); - if (alg != NULL) { - /* Was correct key length supplied? */ - if (alg->max_keysize > 0 && -@@ -150,11 +150,11 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, - } - } - -- out->blocksize = crypto_ablkcipher_blocksize(out->async.s); -- out->ivsize = crypto_ablkcipher_ivsize(out->async.s); -- out->alignmask = crypto_ablkcipher_alignmask(out->async.s); -+ out->blocksize = cryptodev_crypto_blkcipher_blocksize(out->async.s); -+ out->ivsize = cryptodev_crypto_blkcipher_ivsize(out->async.s); -+ out->alignmask = cryptodev_crypto_blkcipher_alignmask(out->async.s); - -- ret = crypto_ablkcipher_setkey(out->async.s, keyp, keylen); -+ ret = cryptodev_crypto_blkcipher_setkey(out->async.s, keyp, keylen); - } else { - out->async.as = crypto_alloc_aead(alg_name, 0, 0); - if (unlikely(IS_ERR(out->async.as))) { -@@ -181,14 +181,14 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, - init_completion(&out->async.result.completion); - - if (aead == 0) { -- out->async.request = ablkcipher_request_alloc(out->async.s, GFP_KERNEL); -+ out->async.request = cryptodev_blkcipher_request_alloc(out->async.s, GFP_KERNEL); - if (unlikely(!out->async.request)) { - derr(1, "error allocating async crypto request"); - ret = -ENOMEM; - goto error; - } - -- ablkcipher_request_set_callback(out->async.request, 0, -+ cryptodev_blkcipher_request_set_callback(out->async.request, 0, - cryptodev_complete, &out->async.result); - } else { - out->async.arequest = aead_request_alloc(out->async.as, GFP_KERNEL); -@@ -206,10 +206,8 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, - return 0; - error: - if (aead == 0) { -- if (out->async.request) -- ablkcipher_request_free(out->async.request); -- if (out->async.s) -- crypto_free_ablkcipher(out->async.s); -+ cryptodev_blkcipher_request_free(out->async.request); -+ cryptodev_crypto_free_blkcipher(out->async.s); - } else { - if (out->async.arequest) - aead_request_free(out->async.arequest); -@@ -224,10 +222,8 @@ void cryptodev_cipher_deinit(struct cipher_data *cdata) - { - if (cdata->init) { - if (cdata->aead == 0) { -- if (cdata->async.request) -- ablkcipher_request_free(cdata->async.request); -- if (cdata->async.s) -- crypto_free_ablkcipher(cdata->async.s); -+ cryptodev_blkcipher_request_free(cdata->async.request); -+ cryptodev_crypto_free_blkcipher(cdata->async.s); - } else { - if (cdata->async.arequest) - aead_request_free(cdata->async.arequest); -@@ -274,10 +270,10 @@ ssize_t cryptodev_cipher_encrypt(struct cipher_data *cdata, - reinit_completion(&cdata->async.result.completion); - - if (cdata->aead == 0) { -- ablkcipher_request_set_crypt(cdata->async.request, -+ cryptodev_blkcipher_request_set_crypt(cdata->async.request, - (struct scatterlist *)src, dst, - len, cdata->async.iv); -- ret = crypto_ablkcipher_encrypt(cdata->async.request); -+ ret = cryptodev_crypto_blkcipher_encrypt(cdata->async.request); - } else { - aead_request_set_crypt(cdata->async.arequest, - (struct scatterlist *)src, dst, -@@ -296,10 +292,10 @@ ssize_t cryptodev_cipher_decrypt(struct cipher_data *cdata, - - reinit_completion(&cdata->async.result.completion); - if (cdata->aead == 0) { -- ablkcipher_request_set_crypt(cdata->async.request, -+ cryptodev_blkcipher_request_set_crypt(cdata->async.request, - (struct scatterlist *)src, dst, - len, cdata->async.iv); -- ret = crypto_ablkcipher_decrypt(cdata->async.request); -+ ret = cryptodev_crypto_blkcipher_decrypt(cdata->async.request); - } else { - aead_request_set_crypt(cdata->async.arequest, - (struct scatterlist *)src, dst, -diff --git a/cryptlib.h b/cryptlib.h -index d8e8046..8200a1d 100644 ---- a/cryptlib.h -+++ b/cryptlib.h -@@ -11,6 +11,8 @@ struct cryptodev_result { - int err; - }; - -+#include "cipherapi.h" -+ - struct cipher_data { - int init; /* 0 uninitialized */ - int blocksize; -@@ -20,8 +22,8 @@ struct cipher_data { - int alignmask; - struct { - /* block ciphers */ -- struct crypto_ablkcipher *s; -- struct ablkcipher_request *request; -+ cryptodev_crypto_blkcipher_t *s; -+ cryptodev_blkcipher_request_t *request; - - /* AEAD ciphers */ - struct crypto_aead *as; -diff --git a/ioctl.c b/ioctl.c -index 2e2bdeb..e3b8af1 100644 ---- a/ioctl.c -+++ b/ioctl.c -@@ -35,7 +35,6 @@ - */ - - #include --#include - #include - #include - #include -@@ -54,6 +53,7 @@ - #include "cryptodev_int.h" - #include "zc.h" - #include "version.h" -+#include "cipherapi.h" - - MODULE_AUTHOR("Nikos Mavrogiannopoulos "); - MODULE_DESCRIPTION("CryptoDev driver"); -@@ -1052,7 +1052,7 @@ static int get_session_info(struct fcrypt *fcr, struct session_info_op *siop) - - if (ses_ptr->cdata.init) { - if (ses_ptr->cdata.aead == 0) -- tfm = crypto_ablkcipher_tfm(ses_ptr->cdata.async.s); -+ tfm = cryptodev_crypto_blkcipher_tfm(ses_ptr->cdata.async.s); - else - tfm = crypto_aead_tfm(ses_ptr->cdata.async.as); - tfm_info_to_alg_info(&siop->cipher_info, tfm); --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0093-Fix-ablkcipher-algorithms-usage-in-v4.8-kernels.patch b/recipes-kernel/cryptodev/sdk_patches/0093-Fix-ablkcipher-algorithms-usage-in-v4.8-kernels.patch deleted file mode 100644 index fcf2a3ee..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0093-Fix-ablkcipher-algorithms-usage-in-v4.8-kernels.patch +++ /dev/null @@ -1,147 +0,0 @@ -From 871ecc5c5ebfbb9c6e1b17a7ff7a531ed1fab644 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Horia=20Geant=C4=83?= -Date: Wed, 16 Nov 2016 15:38:39 +0200 -Subject: [PATCH 093/104] Fix ablkcipher algorithms usage in v4.8+ kernels -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -ablkcipher API is not completely removed from kernels <= v4.9. -Thus it's still valid to use ablkcipher algorithms. - -Fix the case when implementers register ablkcipher algorithms -and cryptodev casts them to skcipher without checking their type. - -Note: alg returned by crypto_ablkcipher_alg() is no longer checked -to be non-NULL. This is guaranteed by the fact that ablkcipher_tfm -(out->async.s) is valid. - -Fixes: cb186f682679 ("Support skcipher in addition to ablkcipher API") -Signed-off-by: Horia Geantă ---- - cipherapi.h | 4 ---- - cryptlib.c | 56 ++++++++++++++++++++++++++++++++++++++++++++------------ - 2 files changed, 44 insertions(+), 16 deletions(-) - -diff --git a/cipherapi.h b/cipherapi.h -index 07d9923..b6ed6c2 100644 ---- a/cipherapi.h -+++ b/cipherapi.h -@@ -6,12 +6,10 @@ - #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) - # include - --typedef struct ablkcipher_alg cryptodev_blkcipher_alg_t; - typedef struct crypto_ablkcipher cryptodev_crypto_blkcipher_t; - typedef struct ablkcipher_request cryptodev_blkcipher_request_t; - - # define cryptodev_crypto_alloc_blkcipher crypto_alloc_ablkcipher --# define cryptodev_crypto_blkcipher_alg crypto_ablkcipher_alg - # define cryptodev_crypto_blkcipher_blocksize crypto_ablkcipher_blocksize - # define cryptodev_crypto_blkcipher_ivsize crypto_ablkcipher_ivsize - # define cryptodev_crypto_blkcipher_alignmask crypto_ablkcipher_alignmask -@@ -37,12 +35,10 @@ static inline void cryptodev_blkcipher_request_free(cryptodev_blkcipher_request_ - #else - #include - --typedef struct skcipher_alg cryptodev_blkcipher_alg_t; - typedef struct crypto_skcipher cryptodev_crypto_blkcipher_t; - typedef struct skcipher_request cryptodev_blkcipher_request_t; - - # define cryptodev_crypto_alloc_blkcipher crypto_alloc_skcipher --# define cryptodev_crypto_blkcipher_alg crypto_skcipher_alg - # define cryptodev_crypto_blkcipher_blocksize crypto_skcipher_blocksize - # define cryptodev_crypto_blkcipher_ivsize crypto_skcipher_ivsize - # define cryptodev_crypto_blkcipher_alignmask crypto_skcipher_alignmask -diff --git a/cryptlib.c b/cryptlib.c -index 558d4b8..dcac3ec 100644 ---- a/cryptlib.c -+++ b/cryptlib.c -@@ -39,6 +39,7 @@ - #include "cryptodev_int.h" - #include "cipherapi.h" - -+extern const struct crypto_type crypto_givcipher_type; - - static void cryptodev_complete(struct crypto_async_request *req, int err) - { -@@ -122,6 +123,19 @@ error: - return ret; - } - -+/* Was correct key length supplied? */ -+static int check_key_size(size_t keylen, const char *alg_name, -+ unsigned int min_keysize, unsigned int max_keysize) -+{ -+ if (max_keysize > 0 && unlikely((keylen < min_keysize) || -+ (keylen > max_keysize))) { -+ ddebug(1, "Wrong keylen '%zu' for algorithm '%s'. Use %u to %u.", -+ keylen, alg_name, min_keysize, max_keysize); -+ return -EINVAL; -+ } -+ -+ return 0; -+} - - int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, - uint8_t *keyp, size_t keylen, int stream, int aead) -@@ -129,7 +143,12 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, - int ret; - - if (aead == 0) { -- cryptodev_blkcipher_alg_t *alg; -+ unsigned int min_keysize, max_keysize; -+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) -+ struct crypto_tfm *tfm; -+#else -+ struct ablkcipher_alg *alg; -+#endif - - out->async.s = cryptodev_crypto_alloc_blkcipher(alg_name, 0, 0); - if (unlikely(IS_ERR(out->async.s))) { -@@ -137,18 +156,31 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, - return -EINVAL; - } - -- alg = cryptodev_crypto_blkcipher_alg(out->async.s); -- if (alg != NULL) { -- /* Was correct key length supplied? */ -- if (alg->max_keysize > 0 && -- unlikely((keylen < alg->min_keysize) || -- (keylen > alg->max_keysize))) { -- ddebug(1, "Wrong keylen '%zu' for algorithm '%s'. Use %u to %u.", -- keylen, alg_name, alg->min_keysize, alg->max_keysize); -- ret = -EINVAL; -- goto error; -- } -+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) -+ tfm = crypto_skcipher_tfm(out->async.s); -+ if ((tfm->__crt_alg->cra_type == &crypto_ablkcipher_type) || -+ (tfm->__crt_alg->cra_type == &crypto_givcipher_type)) { -+ struct ablkcipher_alg *alg; -+ -+ alg = &tfm->__crt_alg->cra_ablkcipher; -+ min_keysize = alg->min_keysize; -+ max_keysize = alg->max_keysize; -+ } else { -+ struct skcipher_alg *alg; -+ -+ alg = crypto_skcipher_alg(out->async.s); -+ min_keysize = alg->min_keysize; -+ max_keysize = alg->max_keysize; - } -+#else -+ alg = crypto_ablkcipher_alg(out->async.s); -+ min_keysize = alg->min_keysize; -+ max_keysize = alg->max_keysize; -+#endif -+ ret = check_key_size(keylen, alg_name, min_keysize, -+ max_keysize); -+ if (ret) -+ goto error; - - out->blocksize = cryptodev_crypto_blkcipher_blocksize(out->async.s); - out->ivsize = cryptodev_crypto_blkcipher_ivsize(out->async.s); --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0094-Adjust-to-another-change-in-the-user-page-API.patch b/recipes-kernel/cryptodev/sdk_patches/0094-Adjust-to-another-change-in-the-user-page-API.patch deleted file mode 100644 index 9483d0c6..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0094-Adjust-to-another-change-in-the-user-page-API.patch +++ /dev/null @@ -1,36 +0,0 @@ -From b7783948df06674da12352ff4f55c6e7c4213026 Mon Sep 17 00:00:00 2001 -From: Michael Weiser -Date: Fri, 11 Nov 2016 18:09:32 +0100 -Subject: [PATCH 094/104] Adjust to another change in the user page API - -4.9.0 will replace the write and force flags of get_user_pages_remote() -with a gup_flags parameter[1]. Distinguish the two APIs based on kernel -version we're compiling for. - -[1] https://github.com/torvalds/linux/commit/9beae1ea89305a9667ceaab6d0bf46a045ad71e7 ---- - zc.c | 8 +++++++- - 1 file changed, 7 insertions(+), 1 deletion(-) - -diff --git a/zc.c b/zc.c -index a97b49f..e766ee3 100644 ---- a/zc.c -+++ b/zc.c -@@ -65,7 +65,13 @@ int __get_userbuf(uint8_t __user *addr, uint32_t len, int write, - ret = get_user_pages( - #endif - task, mm, -- (unsigned long)addr, pgcount, write, 0, pg, NULL); -+ (unsigned long)addr, pgcount, -+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)) -+ write ? FOLL_WRITE : 0, -+#else -+ write, 0, -+#endif -+ pg, NULL); - up_read(&mm->mmap_sem); - if (ret != pgcount) - return -EINVAL; --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0095-rename-header-file-to-clarify-purpose.patch b/recipes-kernel/cryptodev/sdk_patches/0095-rename-header-file-to-clarify-purpose.patch deleted file mode 100644 index d2784b1c..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0095-rename-header-file-to-clarify-purpose.patch +++ /dev/null @@ -1,173 +0,0 @@ -From 1fff269afd1925f4e4c7e37cc8c52187c407bc56 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Tue, 29 Nov 2016 13:37:21 +0200 -Subject: [PATCH 095/104] rename header file to clarify purpose - -testhelper.h suggests a common repository of utility functions but -current content targets only async tests. If we include it in non-async -tests we are forced to include as well. - -Rename this header file to clarify that it targets only async tests - -Signed-off-by: Cristian Stoica ---- - tests/async_cipher.c | 2 +- - tests/async_hmac.c | 2 +- - tests/asynchelper.h | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ - tests/testhelper.h | 57 ---------------------------------------------------- - 4 files changed, 56 insertions(+), 59 deletions(-) - create mode 100644 tests/asynchelper.h - delete mode 100644 tests/testhelper.h - -diff --git a/tests/async_cipher.c b/tests/async_cipher.c -index dd08403..db6fb06 100644 ---- a/tests/async_cipher.c -+++ b/tests/async_cipher.c -@@ -13,7 +13,7 @@ - #include - #include - --#include "testhelper.h" -+#include "asynchelper.h" - - #ifdef ENABLE_ASYNC - -diff --git a/tests/async_hmac.c b/tests/async_hmac.c -index 85d19c6..1bdaad3 100644 ---- a/tests/async_hmac.c -+++ b/tests/async_hmac.c -@@ -14,7 +14,7 @@ - #include - #include - --#include "testhelper.h" -+#include "asynchelper.h" - - #ifdef ENABLE_ASYNC - -diff --git a/tests/asynchelper.h b/tests/asynchelper.h -new file mode 100644 -index 0000000..b5ab16c ---- /dev/null -+++ b/tests/asynchelper.h -@@ -0,0 +1,54 @@ -+#ifndef __ASYNCHELPER_H -+#define __ASYNCHELPER_H -+ -+/* poll until POLLOUT, then call CIOCASYNCCRYPT */ -+inline int do_async_crypt(int cfd, struct crypt_op *cryp) -+{ -+ struct pollfd pfd; -+ -+ pfd.fd = cfd; -+ pfd.events = POLLOUT; -+ -+ if (poll(&pfd, 1, -1) < 1) { -+ perror("poll()"); -+ return 1; -+ } -+ -+ if (ioctl(cfd, CIOCASYNCCRYPT, cryp)) { -+ perror("ioctl(CIOCCRYPT)"); -+ return 1; -+ } -+ return 0; -+} -+ -+/* poll until POLLIN, then call CIOCASYNCFETCH */ -+inline int do_async_fetch(int cfd, struct crypt_op *cryp) -+{ -+ struct pollfd pfd; -+ -+ pfd.fd = cfd; -+ pfd.events = POLLIN; -+ -+ if (poll(&pfd, 1, -1) < 1) { -+ perror("poll()"); -+ return 1; -+ } -+ -+ if (ioctl(cfd, CIOCASYNCFETCH, cryp)) { -+ perror("ioctl(CIOCCRYPT)"); -+ return 1; -+ } -+ return 0; -+} -+ -+/* Check return value of stmt for identity with goodval. If they -+ * don't match, call return with the value of stmt. */ -+#define DO_OR_DIE(stmt, goodval) { \ -+ int __rc_val; \ -+ if ((__rc_val = stmt) != goodval) { \ -+ perror("DO_OR_DIE(" #stmt "," #goodval ")"); \ -+ return __rc_val; \ -+ } \ -+} -+ -+#endif /* __ASYNCHELPER_H */ -diff --git a/tests/testhelper.h b/tests/testhelper.h -deleted file mode 100644 -index ea0b100..0000000 ---- a/tests/testhelper.h -+++ /dev/null -@@ -1,57 +0,0 @@ --/* -- * Some helper stuff shared between the sample programs. -- */ --#ifndef _TESTHELPER_H --#define _TESTHELPER_H -- --/* poll until POLLOUT, then call CIOCASYNCCRYPT */ --inline int do_async_crypt(int cfd, struct crypt_op *cryp) --{ -- struct pollfd pfd; -- -- pfd.fd = cfd; -- pfd.events = POLLOUT; -- -- if (poll(&pfd, 1, -1) < 1) { -- perror("poll()"); -- return 1; -- } -- -- if (ioctl(cfd, CIOCASYNCCRYPT, cryp)) { -- perror("ioctl(CIOCCRYPT)"); -- return 1; -- } -- return 0; --} -- --/* poll until POLLIN, then call CIOCASYNCFETCH */ --inline int do_async_fetch(int cfd, struct crypt_op *cryp) --{ -- struct pollfd pfd; -- -- pfd.fd = cfd; -- pfd.events = POLLIN; -- -- if (poll(&pfd, 1, -1) < 1) { -- perror("poll()"); -- return 1; -- } -- -- if (ioctl(cfd, CIOCASYNCFETCH, cryp)) { -- perror("ioctl(CIOCCRYPT)"); -- return 1; -- } -- return 0; --} -- --/* Check return value of stmt for identity with goodval. If they -- * don't match, call return with the value of stmt. */ --#define DO_OR_DIE(stmt, goodval) { \ -- int __rc_val; \ -- if ((__rc_val = stmt) != goodval) { \ -- perror("DO_OR_DIE(" #stmt "," #goodval ")"); \ -- return __rc_val; \ -- } \ --} -- --#endif /* _TESTHELPER_H */ --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0096-use-buf_align-macro-to-reduce-code-duplication.patch b/recipes-kernel/cryptodev/sdk_patches/0096-use-buf_align-macro-to-reduce-code-duplication.patch deleted file mode 100644 index 83d0be12..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0096-use-buf_align-macro-to-reduce-code-duplication.patch +++ /dev/null @@ -1,248 +0,0 @@ -From 6f4589ae57d141ea6257ae16df1709781d0fb8e4 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Tue, 29 Nov 2016 13:37:22 +0200 -Subject: [PATCH 096/104] use buf_align macro to reduce code duplication - -Signed-off-by: Cristian Stoica ---- - tests/async_cipher.c | 9 +++++---- - tests/cipher-aead-srtp.c | 13 +++++++------ - tests/cipher-aead.c | 13 +++++++------ - tests/cipher-gcm.c | 17 +++++------------ - tests/cipher.c | 9 +++++---- - tests/testhelper.h | 9 +++++++++ - 6 files changed, 38 insertions(+), 32 deletions(-) - create mode 100644 tests/testhelper.h - -diff --git a/tests/async_cipher.c b/tests/async_cipher.c -index db6fb06..7a184e5 100644 ---- a/tests/async_cipher.c -+++ b/tests/async_cipher.c -@@ -14,6 +14,7 @@ - #include - - #include "asynchelper.h" -+#include "testhelper.h" - - #ifdef ENABLE_ASYNC - -@@ -62,8 +63,8 @@ test_crypto(int cfd) - perror("ioctl(CIOCGSESSINFO)"); - return 1; - } -- plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); -- ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); -+ plaintext = buf_align(plaintext_raw, siop.alignmask); -+ ciphertext = buf_align(ciphertext_raw, siop.alignmask); - #else - plaintext = plaintext_raw; - ciphertext = ciphertext_raw; -@@ -162,7 +163,7 @@ static int test_aes(int cfd) - perror("ioctl(CIOCGSESSINFO)"); - return 1; - } -- plaintext1 = (uint8_t *)(((unsigned long)plaintext1_raw + siop1.alignmask) & ~siop1.alignmask); -+ plaintext1 = buf_align(plaintext1_raw, siop1.alignmask); - #else - plaintext1 = plaintext1_raw; - #endif -@@ -185,7 +186,7 @@ static int test_aes(int cfd) - perror("ioctl(CIOCGSESSINFO)"); - return 1; - } -- plaintext2 = (uint8_t *)(((unsigned long)plaintext2_raw + siop2.alignmask) & ~siop2.alignmask); -+ plaintext2 = buf_align(plaintext2_raw, siop2.alignmask); - #else - plaintext2 = plaintext2_raw; - #endif -diff --git a/tests/cipher-aead-srtp.c b/tests/cipher-aead-srtp.c -index c44877d..578d2f7 100644 ---- a/tests/cipher-aead-srtp.c -+++ b/tests/cipher-aead-srtp.c -@@ -12,6 +12,7 @@ - - #include - #include -+#include "testhelper.h" - - #define DATA_SIZE (8*1024) - #define HEADER_SIZE 193 -@@ -122,8 +123,8 @@ test_crypto(int cfd) - printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", - siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); - -- plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); -- ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); -+ plaintext = buf_align(plaintext_raw, siop.alignmask); -+ ciphertext = buf_align(ciphertext_raw, siop.alignmask); - - memset(plaintext, 0x15, HEADER_SIZE); /* header */ - memset(&plaintext[HEADER_SIZE], 0x17, PLAINTEXT_SIZE); /* payload */ -@@ -265,8 +266,8 @@ test_encrypt_decrypt(int cfd) - // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", - // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); - -- plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); -- ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); -+ plaintext = buf_align(plaintext_raw, siop.alignmask); -+ ciphertext = buf_align(ciphertext_raw, siop.alignmask); - - memset(plaintext, 0x15, HEADER_SIZE); /* header */ - memset(&plaintext[HEADER_SIZE], 0x17, PLAINTEXT_SIZE); /* payload */ -@@ -407,8 +408,8 @@ test_encrypt_decrypt_error(int cfd, int err) - // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", - // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); - -- plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); -- ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); -+ plaintext = buf_align(plaintext_raw, siop.alignmask); -+ ciphertext = buf_align(ciphertext_raw, siop.alignmask); - - memset(plaintext, 0x15, HEADER_SIZE); /* header */ - memset(&plaintext[HEADER_SIZE], 0x17, PLAINTEXT_SIZE); /* payload */ -diff --git a/tests/cipher-aead.c b/tests/cipher-aead.c -index da43aa6..b329d12 100644 ---- a/tests/cipher-aead.c -+++ b/tests/cipher-aead.c -@@ -12,6 +12,7 @@ - - #include - #include -+#include "testhelper.h" - - #define DATA_SIZE (8*1024) - #define AUTH_SIZE 31 -@@ -133,8 +134,8 @@ test_crypto(int cfd) - printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", - siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); - -- plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); -- ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); -+ plaintext = buf_align(plaintext_raw, siop.alignmask); -+ ciphertext = buf_align(ciphertext_raw, siop.alignmask); - memset(plaintext, 0x15, DATA_SIZE); - - if (get_sha1_hmac(cfd, sess.mackey, sess.mackeylen, auth, sizeof(auth), plaintext, DATA_SIZE, sha1mac) != 0) { -@@ -285,8 +286,8 @@ test_encrypt_decrypt(int cfd) - // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", - // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); - -- plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); -- ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); -+ plaintext = buf_align(plaintext_raw, siop.alignmask); -+ ciphertext = buf_align(ciphertext_raw, siop.alignmask); - - memset(plaintext, 0x15, DATA_SIZE); - -@@ -434,8 +435,8 @@ test_encrypt_decrypt_error(int cfd, int err) - // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", - // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); - -- plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); -- ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); -+ plaintext = buf_align(plaintext_raw, siop.alignmask); -+ ciphertext = buf_align(ciphertext_raw, siop.alignmask); - memset(plaintext, 0x15, DATA_SIZE); - - if (get_sha1_hmac(cfd, sess.mackey, sess.mackeylen, auth, sizeof(auth), plaintext, DATA_SIZE, sha1mac) != 0) { -diff --git a/tests/cipher-gcm.c b/tests/cipher-gcm.c -index 3f6cc7b..d5f8486 100644 ---- a/tests/cipher-gcm.c -+++ b/tests/cipher-gcm.c -@@ -12,6 +12,7 @@ - - #include - #include -+#include "testhelper.h" - - #define DATA_SIZE (8*1024) - #define AUTH_SIZE 31 -@@ -232,12 +233,8 @@ static int test_encrypt_decrypt(int cfd) - // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", - // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); - -- plaintext = -- (uint8_t *) (((unsigned long) plaintext_raw + siop.alignmask) & -- ~siop.alignmask); -- ciphertext = -- (uint8_t *) (((unsigned long) ciphertext_raw + siop.alignmask) & -- ~siop.alignmask); -+ plaintext = (__u8 *)buf_align(plaintext_raw, siop.alignmask); -+ ciphertext = (__u8 *)buf_align(ciphertext_raw, siop.alignmask); - - memset(plaintext, 0x15, DATA_SIZE); - -@@ -385,12 +382,8 @@ static int test_encrypt_decrypt_error(int cfd, int err) - // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", - // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); - -- plaintext = -- (uint8_t *) (((unsigned long) plaintext_raw + siop.alignmask) & -- ~siop.alignmask); -- ciphertext = -- (uint8_t *) (((unsigned long) ciphertext_raw + siop.alignmask) & -- ~siop.alignmask); -+ plaintext = (__u8 *)buf_align(plaintext_raw, siop.alignmask); -+ ciphertext = (__u8 *)buf_align(ciphertext_raw, siop.alignmask); - - memset(plaintext, 0x15, DATA_SIZE); - memcpy(ciphertext, plaintext, DATA_SIZE); -diff --git a/tests/cipher.c b/tests/cipher.c -index f3ca2f0..222f095 100644 ---- a/tests/cipher.c -+++ b/tests/cipher.c -@@ -12,6 +12,7 @@ - - #include - #include -+#include "testhelper.h" - - static int debug = 0; - -@@ -58,8 +59,8 @@ test_crypto(int cfd) - printf("requested cipher CRYPTO_AES_CBC, got %s with driver %s\n", - siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); - -- plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); -- ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); -+ plaintext = buf_align(plaintext_raw, siop.alignmask); -+ ciphertext = buf_align(ciphertext_raw, siop.alignmask); - #else - plaintext = plaintext_raw; - ciphertext = ciphertext_raw; -@@ -177,7 +178,7 @@ static int test_aes(int cfd) - perror("ioctl(CIOCGSESSINFO)"); - return 1; - } -- plaintext1 = (uint8_t *)(((unsigned long)plaintext1_raw + siop.alignmask) & ~siop.alignmask); -+ plaintext1 = buf_align(plaintext1_raw, siop.alignmask); - #else - plaintext1 = plaintext1_raw; - #endif -@@ -227,7 +228,7 @@ static int test_aes(int cfd) - printf("requested cipher CRYPTO_AES_CBC, got %s with driver %s\n", - siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); - -- plaintext2 = (uint8_t *)(((unsigned long)plaintext2_raw + siop.alignmask) & ~siop.alignmask); -+ plaintext2 = buf_align(plaintext2_raw, siop.alignmask); - #else - plaintext2 = plaintext2_raw; - #endif -diff --git a/tests/testhelper.h b/tests/testhelper.h -new file mode 100644 -index 0000000..800d10d ---- /dev/null -+++ b/tests/testhelper.h -@@ -0,0 +1,9 @@ -+/* -+ * Some helper stuff shared between the sample programs. -+ */ -+#ifndef __TESTHELPER_H -+#define __TESTHELPER_H -+ -+#define buf_align(buf, align) (void *)(((unsigned long)(buf) + (align)) & ~(align)) -+ -+#endif /* __TESTHELPER_H */ --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0097-avoid-implicit-conversion-between-signed-and-unsigne.patch b/recipes-kernel/cryptodev/sdk_patches/0097-avoid-implicit-conversion-between-signed-and-unsigne.patch deleted file mode 100644 index afd97515..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0097-avoid-implicit-conversion-between-signed-and-unsigne.patch +++ /dev/null @@ -1,304 +0,0 @@ -From 4843f76a74558b85944dbf923cf699bfd5b354eb Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Tue, 29 Nov 2016 13:37:23 +0200 -Subject: [PATCH 097/104] avoid implicit conversion between signed and unsigned - char - -Use uint8_t type for all variables with this problem and avoid casting -from char in assignments. With uint8_t we also convey the information -that we're using small numbers rather than strings. - -Although cryptodev.h uses the synonym type __u8, we use uint8_t -for consistency with other files in tests directory and also because it -is a standard POSIX type. - -Signed-off-by: Cristian Stoica ---- - tests/async_hmac.c | 12 ++++++------ - tests/cipher-aead.c | 10 +++++----- - tests/cipher-gcm.c | 40 ++++++++++++++++++++-------------------- - tests/cipher.c | 1 - - tests/fullspeed.c | 1 + - tests/hmac.c | 12 ++++++------ - 6 files changed, 38 insertions(+), 38 deletions(-) - -diff --git a/tests/async_hmac.c b/tests/async_hmac.c -index 1bdaad3..014b8ed 100644 ---- a/tests/async_hmac.c -+++ b/tests/async_hmac.c -@@ -61,7 +61,7 @@ test_crypto(int cfd) - - cryp.ses = sess.ses; - cryp.len = sizeof("what do ya want for nothing?")-1; -- cryp.src = (uint8_t*)"what do ya want for nothing?"; -+ cryp.src = (uint8_t *)"what do ya want for nothing?"; - cryp.mac = mac; - cryp.op = COP_ENCRYPT; - -@@ -88,7 +88,7 @@ test_crypto(int cfd) - memset(mac, 0, sizeof(mac)); - - sess.cipher = 0; -- sess.mackey = (uint8_t*)"Jefe"; -+ sess.mackey = (uint8_t *)"Jefe"; - sess.mackeylen = 4; - sess.mac = CRYPTO_MD5_HMAC; - if (ioctl(cfd, CIOCGSESSION, &sess)) { -@@ -98,7 +98,7 @@ test_crypto(int cfd) - - cryp.ses = sess.ses; - cryp.len = sizeof("what do ya want for nothing?")-1; -- cryp.src = (uint8_t*)"what do ya want for nothing?"; -+ cryp.src = (uint8_t *)"what do ya want for nothing?"; - cryp.mac = mac; - cryp.op = COP_ENCRYPT; - -@@ -127,7 +127,7 @@ test_crypto(int cfd) - sess.keylen = KEY_SIZE; - sess.key = data.key; - sess.mackeylen = 16; -- sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; -+ sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; - if (ioctl(cfd, CIOCGSESSION, &sess)) { - perror("ioctl(CIOCGSESSION)"); - return 1; -@@ -206,7 +206,7 @@ test_extras(int cfd) - - cryp.ses = sess.ses; - cryp.len = sizeof("what do")-1; -- cryp.src = (uint8_t*)"what do"; -+ cryp.src = (uint8_t *)"what do"; - cryp.mac = mac; - cryp.op = COP_ENCRYPT; - cryp.flags = COP_FLAG_UPDATE; -@@ -216,7 +216,7 @@ test_extras(int cfd) - - cryp.ses = sess.ses; - cryp.len = sizeof(" ya want for nothing?")-1; -- cryp.src = (uint8_t*)" ya want for nothing?"; -+ cryp.src = (uint8_t *)" ya want for nothing?"; - cryp.mac = mac; - cryp.op = COP_ENCRYPT; - cryp.flags = COP_FLAG_FINAL; -diff --git a/tests/cipher-aead.c b/tests/cipher-aead.c -index b329d12..305b720 100644 ---- a/tests/cipher-aead.c -+++ b/tests/cipher-aead.c -@@ -118,7 +118,7 @@ test_crypto(int cfd) - - sess.mac = CRYPTO_SHA1_HMAC; - sess.mackeylen = 16; -- sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; -+ sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; - - if (ioctl(cfd, CIOCGSESSION, &sess)) { - perror("ioctl(CIOCGSESSION)"); -@@ -271,7 +271,7 @@ test_encrypt_decrypt(int cfd) - - sess.mac = CRYPTO_SHA1_HMAC; - sess.mackeylen = 16; -- sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; -+ sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; - - if (ioctl(cfd, CIOCGSESSION, &sess)) { - perror("ioctl(CIOCGSESSION)"); -@@ -329,7 +329,7 @@ test_encrypt_decrypt(int cfd) - sess.key = key; - sess.mac = CRYPTO_SHA1_HMAC; - sess.mackeylen = 16; -- sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; -+ sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; - - if (ioctl(cfd, CIOCGSESSION, &sess)) { - perror("ioctl(CIOCGSESSION)"); -@@ -420,7 +420,7 @@ test_encrypt_decrypt_error(int cfd, int err) - - sess.mac = CRYPTO_SHA1_HMAC; - sess.mackeylen = 16; -- sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; -+ sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; - - if (ioctl(cfd, CIOCGSESSION, &sess)) { - perror("ioctl(CIOCGSESSION)"); -@@ -477,7 +477,7 @@ test_encrypt_decrypt_error(int cfd, int err) - sess.key = key; - sess.mac = CRYPTO_SHA1_HMAC; - sess.mackeylen = 16; -- sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; -+ sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; - - if (ioctl(cfd, CIOCGSESSION, &sess)) { - perror("ioctl(CIOCGSESSION)"); -diff --git a/tests/cipher-gcm.c b/tests/cipher-gcm.c -index d5f8486..36c827a 100644 ---- a/tests/cipher-gcm.c -+++ b/tests/cipher-gcm.c -@@ -46,45 +46,45 @@ struct aes_gcm_vectors_st { - - struct aes_gcm_vectors_st aes_gcm_vectors[] = { - { -- .key = (uint8_t*) -+ .key = (uint8_t *) - "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", - .auth = NULL, - .auth_size = 0, -- .plaintext = (uint8_t*) -+ .plaintext = (uint8_t *) - "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", - .plaintext_size = 16, -- .ciphertext = (uint8_t*) -+ .ciphertext = (uint8_t *) - "\x03\x88\xda\xce\x60\xb6\xa3\x92\xf3\x28\xc2\xb9\x71\xb2\xfe\x78", -- .iv = (uint8_t*)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", -- .tag = (uint8_t*) -+ .iv = (uint8_t *)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", -+ .tag = (uint8_t *) - "\xab\x6e\x47\xd4\x2c\xec\x13\xbd\xf5\x3a\x67\xb2\x12\x57\xbd\xdf" - }, - { -- .key = (uint8_t*) -+ .key = (uint8_t *) - "\xfe\xff\xe9\x92\x86\x65\x73\x1c\x6d\x6a\x8f\x94\x67\x30\x83\x08", - .auth = NULL, - .auth_size = 0, -- .plaintext = (uint8_t*) -+ .plaintext = (uint8_t *) - "\xd9\x31\x32\x25\xf8\x84\x06\xe5\xa5\x59\x09\xc5\xaf\xf5\x26\x9a\x86\xa7\xa9\x53\x15\x34\xf7\xda\x2e\x4c\x30\x3d\x8a\x31\x8a\x72\x1c\x3c\x0c\x95\x95\x68\x09\x53\x2f\xcf\x0e\x24\x49\xa6\xb5\x25\xb1\x6a\xed\xf5\xaa\x0d\xe6\x57\xba\x63\x7b\x39\x1a\xaf\xd2\x55", - .plaintext_size = 64, -- .ciphertext = (uint8_t*) -+ .ciphertext = (uint8_t *) - "\x42\x83\x1e\xc2\x21\x77\x74\x24\x4b\x72\x21\xb7\x84\xd0\xd4\x9c\xe3\xaa\x21\x2f\x2c\x02\xa4\xe0\x35\xc1\x7e\x23\x29\xac\xa1\x2e\x21\xd5\x14\xb2\x54\x66\x93\x1c\x7d\x8f\x6a\x5a\xac\x84\xaa\x05\x1b\xa3\x0b\x39\x6a\x0a\xac\x97\x3d\x58\xe0\x91\x47\x3f\x59\x85", -- .iv = (uint8_t*)"\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88", -- .tag = (uint8_t*)"\x4d\x5c\x2a\xf3\x27\xcd\x64\xa6\x2c\xf3\x5a\xbd\x2b\xa6\xfa\xb4" -+ .iv = (uint8_t *)"\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88", -+ .tag = (uint8_t *)"\x4d\x5c\x2a\xf3\x27\xcd\x64\xa6\x2c\xf3\x5a\xbd\x2b\xa6\xfa\xb4" - }, - { -- .key = (uint8_t*) -+ .key = (uint8_t *) - "\xfe\xff\xe9\x92\x86\x65\x73\x1c\x6d\x6a\x8f\x94\x67\x30\x83\x08", -- .auth = (uint8_t*) -+ .auth = (uint8_t *) - "\xfe\xed\xfa\xce\xde\xad\xbe\xef\xfe\xed\xfa\xce\xde\xad\xbe\xef\xab\xad\xda\xd2", - .auth_size = 20, -- .plaintext = (uint8_t*) -+ .plaintext = (uint8_t *) - "\xd9\x31\x32\x25\xf8\x84\x06\xe5\xa5\x59\x09\xc5\xaf\xf5\x26\x9a\x86\xa7\xa9\x53\x15\x34\xf7\xda\x2e\x4c\x30\x3d\x8a\x31\x8a\x72\x1c\x3c\x0c\x95\x95\x68\x09\x53\x2f\xcf\x0e\x24\x49\xa6\xb5\x25\xb1\x6a\xed\xf5\xaa\x0d\xe6\x57\xba\x63\x7b\x39", - .plaintext_size = 60, -- .ciphertext = (uint8_t*) -+ .ciphertext = (uint8_t *) - "\x42\x83\x1e\xc2\x21\x77\x74\x24\x4b\x72\x21\xb7\x84\xd0\xd4\x9c\xe3\xaa\x21\x2f\x2c\x02\xa4\xe0\x35\xc1\x7e\x23\x29\xac\xa1\x2e\x21\xd5\x14\xb2\x54\x66\x93\x1c\x7d\x8f\x6a\x5a\xac\x84\xaa\x05\x1b\xa3\x0b\x39\x6a\x0a\xac\x97\x3d\x58\xe0\x91", -- .iv = (uint8_t*)"\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88", -- .tag = (uint8_t*) -+ .iv = (uint8_t *)"\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88", -+ .tag = (uint8_t *) - "\x5b\xc9\x4f\xbc\x32\x21\xa5\xdb\x94\xfa\xe9\x5a\xe7\x12\x1a\x47" - } - }; -@@ -233,8 +233,8 @@ static int test_encrypt_decrypt(int cfd) - // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", - // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); - -- plaintext = (__u8 *)buf_align(plaintext_raw, siop.alignmask); -- ciphertext = (__u8 *)buf_align(ciphertext_raw, siop.alignmask); -+ plaintext = (uint8_t *)buf_align(plaintext_raw, siop.alignmask); -+ ciphertext = (uint8_t *)buf_align(ciphertext_raw, siop.alignmask); - - memset(plaintext, 0x15, DATA_SIZE); - -@@ -382,8 +382,8 @@ static int test_encrypt_decrypt_error(int cfd, int err) - // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", - // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); - -- plaintext = (__u8 *)buf_align(plaintext_raw, siop.alignmask); -- ciphertext = (__u8 *)buf_align(ciphertext_raw, siop.alignmask); -+ plaintext = (uint8_t *)buf_align(plaintext_raw, siop.alignmask); -+ ciphertext = (uint8_t *)buf_align(ciphertext_raw, siop.alignmask); - - memset(plaintext, 0x15, DATA_SIZE); - memcpy(ciphertext, plaintext, DATA_SIZE); -diff --git a/tests/cipher.c b/tests/cipher.c -index 222f095..fab3de6 100644 ---- a/tests/cipher.c -+++ b/tests/cipher.c -@@ -9,7 +9,6 @@ - #include - #include - #include -- - #include - #include - #include "testhelper.h" -diff --git a/tests/fullspeed.c b/tests/fullspeed.c -index c025130..ae873e2 100644 ---- a/tests/fullspeed.c -+++ b/tests/fullspeed.c -@@ -24,6 +24,7 @@ - #include - #include - #include -+#include - #include - #include - -diff --git a/tests/hmac.c b/tests/hmac.c -index 3b248f3..8d6492e 100644 ---- a/tests/hmac.c -+++ b/tests/hmac.c -@@ -69,7 +69,7 @@ test_crypto(int cfd) - - cryp.ses = sess.ses; - cryp.len = sizeof("what do ya want for nothing?")-1; -- cryp.src = (uint8_t*)"what do ya want for nothing?"; -+ cryp.src = (uint8_t *)"what do ya want for nothing?"; - cryp.mac = mac; - cryp.op = COP_ENCRYPT; - if (ioctl(cfd, CIOCCRYPT, &cryp)) { -@@ -92,7 +92,7 @@ test_crypto(int cfd) - memset(mac, 0, sizeof(mac)); - - sess.cipher = 0; -- sess.mackey = (uint8_t*)"Jefe"; -+ sess.mackey = (uint8_t *)"Jefe"; - sess.mackeylen = 4; - sess.mac = CRYPTO_MD5_HMAC; - if (ioctl(cfd, CIOCGSESSION, &sess)) { -@@ -113,7 +113,7 @@ test_crypto(int cfd) - - cryp.ses = sess.ses; - cryp.len = sizeof("what do ya want for nothing?")-1; -- cryp.src = (uint8_t*)"what do ya want for nothing?"; -+ cryp.src = (uint8_t *)"what do ya want for nothing?"; - cryp.mac = mac; - cryp.op = COP_ENCRYPT; - if (ioctl(cfd, CIOCCRYPT, &cryp)) { -@@ -138,7 +138,7 @@ test_crypto(int cfd) - sess.keylen = KEY_SIZE; - sess.key = data.key; - sess.mackeylen = 16; -- sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; -+ sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; - if (ioctl(cfd, CIOCGSESSION, &sess)) { - perror("ioctl(CIOCGSESSION)"); - return 1; -@@ -244,7 +244,7 @@ test_extras(int cfd) - - cryp.ses = sess.ses; - cryp.len = sizeof("what do")-1; -- cryp.src = (uint8_t*)"what do"; -+ cryp.src = (uint8_t *)"what do"; - cryp.mac = mac; - cryp.op = COP_ENCRYPT; - cryp.flags = COP_FLAG_UPDATE; -@@ -255,7 +255,7 @@ test_extras(int cfd) - - cryp.ses = sess.ses; - cryp.len = sizeof(" ya want for nothing?")-1; -- cryp.src = (uint8_t*)" ya want for nothing?"; -+ cryp.src = (uint8_t *)" ya want for nothing?"; - cryp.mac = mac; - cryp.op = COP_ENCRYPT; - cryp.flags = COP_FLAG_FINAL; --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0098-reduce-tests-Makefile-distance-with-upstream.patch b/recipes-kernel/cryptodev/sdk_patches/0098-reduce-tests-Makefile-distance-with-upstream.patch deleted file mode 100644 index 42b5cbe1..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0098-reduce-tests-Makefile-distance-with-upstream.patch +++ /dev/null @@ -1,25 +0,0 @@ -From badd002fe5bdcaf7a7d856f174e2abb10b939467 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Tue, 29 Nov 2016 13:37:24 +0200 -Subject: [PATCH 098/104] reduce tests/Makefile distance with upstream - -Signed-off-by: Cristian Stoica ---- - tests/Makefile | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/tests/Makefile b/tests/Makefile -index 88f5040..5a09414 100644 ---- a/tests/Makefile -+++ b/tests/Makefile -@@ -1,5 +1,5 @@ --CRYPTODEV_CFLAGS += -DENABLE_ASYNC -std=gnu90 -Wall -Werror --CFLAGS += -I.. $(CRYPTODEV_CFLAGS) -+CRYPTODEV_CFLAGS += -DENABLE_ASYNC -std=gnu90 -+CFLAGS += -I.. $(CRYPTODEV_CFLAGS) -Wall -Werror - - comp_progs := cipher_comp hash_comp hmac_comp - --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0099-add-support-for-authenc-hmac-sha1-cbc-aes-speed-test.patch b/recipes-kernel/cryptodev/sdk_patches/0099-add-support-for-authenc-hmac-sha1-cbc-aes-speed-test.patch deleted file mode 100644 index f65979af..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0099-add-support-for-authenc-hmac-sha1-cbc-aes-speed-test.patch +++ /dev/null @@ -1,288 +0,0 @@ -From d2cb6745bb166818b6bd9e9011990453fedbccef Mon Sep 17 00:00:00 2001 -From: Alexe Radu -Date: Fri, 9 Dec 2016 15:25:20 +0200 -Subject: [PATCH 099/104] add support for authenc(hmac(sha1), cbc(aes)) speed - tests - -Signed-off-by: Alexe Radu ---- - crypto/cryptodev.h | 1 + - ioctl.c | 5 ++ - tests/speed.c | 155 +++++++++++++++++++++++++++++++++++++++++++++++------ - 3 files changed, 146 insertions(+), 15 deletions(-) - -diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h -index 05221a4..05dc57b 100644 ---- a/crypto/cryptodev.h -+++ b/crypto/cryptodev.h -@@ -62,6 +62,7 @@ enum cryptodev_crypto_op_t { - CRYPTO_TLS12_3DES_CBC_HMAC_SHA1, - CRYPTO_TLS12_AES_CBC_HMAC_SHA1, - CRYPTO_TLS12_AES_CBC_HMAC_SHA256, -+ CRYPTO_AUTHENC_HMAC_SHA1_CBC_AES, - CRYPTO_ALGORITHM_ALL, /* Keep updated - see below */ - }; - -diff --git a/ioctl.c b/ioctl.c -index e3b8af1..7288ffc 100644 ---- a/ioctl.c -+++ b/ioctl.c -@@ -222,6 +222,11 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) - stream = 0; - aead = 1; - break; -+ case CRYPTO_AUTHENC_HMAC_SHA1_CBC_AES: -+ alg_name = "authenc(hmac(sha1),cbc(aes))"; -+ stream = 0; -+ aead = 1; -+ break; - case CRYPTO_NULL: - alg_name = "ecb(cipher_null)"; - stream = 1; -diff --git a/tests/speed.c b/tests/speed.c -index fc38a63..61259b9 100644 ---- a/tests/speed.c -+++ b/tests/speed.c -@@ -33,12 +33,15 @@ - #include - #include - -+#define AUTH_SIZE 31 -+#define TAG_LEN 20 - - struct test_params { - bool tflag; - bool nflag; - bool mflag; - bool aflag; -+ bool authflag; - int tvalue; - int nvalue; - }; -@@ -59,8 +62,9 @@ int run_aes_256_xts(int fdc, struct test_params tp); - int run_crc32c(int fdc, struct test_params tp); - int run_sha1(int fdc, struct test_params tp); - int run_sha256(int fdc, struct test_params tp); -+int run_authenc(int fdc, struct test_params tp); - --#define ALG_COUNT 6 -+#define ALG_COUNT 7 - struct { - char *name; - int (*func)(int, struct test_params); -@@ -71,6 +75,7 @@ struct { - {"crc32c", run_crc32c}, - {"sha1", run_sha1}, - {"sha256", run_sha256}, -+ {"authenc", run_authenc}, - }; - - static double udifftimeval(struct timeval start, struct timeval end) -@@ -269,7 +274,7 @@ static int encrypt_sync(int fdc, struct test_params tp, struct session_op *sess) - } - memset(buffer, val++, tp.nvalue); - -- must_finish = 0; -+ must_finish = 1; - alarm(tp.tvalue); - - gettimeofday(&start, NULL); -@@ -305,6 +310,84 @@ static int encrypt_sync(int fdc, struct test_params tp, struct session_op *sess) - return 0; - } - -+static int encrypt_auth(int fdc, struct test_params tp, struct session_op *sess) -+{ -+ struct crypt_auth_op cao; -+ char *buffer, iv[32]; -+ uint8_t auth[AUTH_SIZE]; -+ static int val = 23; -+ struct timeval start, end; -+ uint64_t total = 0; -+ double secs, ddata, dspeed; -+ char metric[16]; -+ int alignmask; -+ int min_alignmask = sizeof(void*) - 1; -+ int alloc_size; -+ -+ memset(iv, 0x23, 32); -+ memset(auth, 0xf1, sizeof(auth)); -+ -+ if (!tp.mflag) { -+ printf("\tBuffer size %d bytes: ", tp.nvalue); -+ fflush(stdout); -+ } -+ -+ alloc_size = tp.nvalue + TAG_LEN; -+ alignmask = get_alignmask(fdc, sess); -+ if (alignmask) { -+ alignmask = ((alignmask < min_alignmask) ? min_alignmask : alignmask); -+ if (posix_memalign((void **)(&buffer), alignmask + 1, alloc_size)) { -+ printf("posix_memalign() failed!\n"); -+ return 1; -+ } -+ } else { -+ if (!(buffer = malloc(alloc_size))) { -+ perror("malloc()"); -+ return 1; -+ } -+ } -+ memset(buffer, val++, tp.nvalue); -+ -+ must_finish = 0; -+ alarm(tp.tvalue); -+ -+ gettimeofday(&start, NULL); -+ do { -+ memset(&cao, 0, sizeof(cao)); -+ cao.ses = sess->ses; -+ cao.auth_src = auth; -+ cao.auth_len = sizeof(auth); -+ cao.len = tp.nvalue; -+ cao.iv = (unsigned char *)iv; -+ cao.op = COP_ENCRYPT; -+ cao.src = (unsigned char *)buffer; -+ cao.dst = cao.src; -+ cao.tag_len = TAG_LEN; -+ cao.flags = COP_FLAG_AEAD_TLS_TYPE; -+ -+ if (ioctl(fdc, CIOCAUTHCRYPT, &cao)) { -+ perror("ioctl(CIOCAUTHCRYPT)"); -+ return 1; -+ } -+ total += cao.len; -+ } while(!must_finish); -+ gettimeofday(&end, NULL); -+ -+ secs = udifftimeval(start, end)/ 1000000.0; -+ -+ if (tp.mflag) { -+ value2machine(total, secs, &dspeed); -+ printf("%" PRIu64 "\t%.2f\t%.2f\n", total, secs, dspeed); -+ } else { -+ value2human(total, secs, &ddata, &dspeed, metric); -+ printf ("done. %.2f %s in %.2f secs: ", ddata, metric, secs); -+ printf ("%.2f %s/sec\n", dspeed, metric); -+ } -+ -+ free(buffer); -+ return 0; -+} -+ - void usage(char *cmd_name) - { - printf(usage_str, cmd_name); -@@ -326,11 +409,19 @@ int run_test(int id, struct test_params tp) - return -EINVAL; - } - -+ if (strcmp("authenc", ciphers[id].name) == 0) { -+ tp.authflag = true; -+ } -+ - if (!tp.mflag) { -- char *type; -- type = tp.aflag ? "async" : "sync"; -+ if (tp.authflag) { -+ fprintf(stderr, "Testing %s:\n", ciphers[id].name); -+ } else { -+ char *type; -+ type = tp.aflag ? "async" : "sync"; - -- fprintf(stderr, "Testing %s %s:\n", type, ciphers[id].name); -+ fprintf(stderr, "Testing %s %s:\n", type, ciphers[id].name); -+ } - } - err = ciphers[id].func(fdc, tp); - -@@ -340,17 +431,30 @@ int run_test(int id, struct test_params tp) - return err; - } - --void do_test_vectors(int fdc, struct test_params tp, struct session_op *sess) -+static int start_test (int fdc, struct test_params tp, struct session_op *sess) - { -- int i; - int err; - -- if (tp.nflag) { -+ if (tp.authflag) { -+ err = encrypt_auth(fdc, tp, sess); -+ } else { - if (tp.aflag) { -- encrypt_async(fdc, tp, sess); -+ err = encrypt_async(fdc, tp, sess); - } else { -- encrypt_sync(fdc, tp, sess); -+ err = encrypt_sync(fdc, tp, sess); - } -+ } -+ -+ return err; -+} -+ -+void do_test_vectors(int fdc, struct test_params tp, struct session_op *sess) -+{ -+ int i; -+ int err; -+ -+ if (tp.nflag) { -+ err = start_test(fdc, tp, sess); - } else { - for (i = 256; i <= (64 * 1024); i *= 2) { - if (must_exit) { -@@ -358,11 +462,7 @@ void do_test_vectors(int fdc, struct test_params tp, struct session_op *sess) - } - - tp.nvalue = i; -- if (tp.aflag) { -- err = encrypt_async(fdc, tp, sess); -- } else { -- err = encrypt_sync(fdc, tp, sess); -- } -+ err = start_test(fdc, tp, sess); - - if (err != 0) { - break; -@@ -474,6 +574,30 @@ int run_sha256(int fdc, struct test_params tp) - return 0; - } - -+int run_authenc(int fdc, struct test_params tp) -+{ -+ struct session_op sess; -+ char *mkeybuf = "\x00\x00\x00\x00\x00\x00\x00\x00" -+ "\x00\x00\x00\x00\x00\x00\x00\x00" -+ "\x00\x00\x00\x00"; -+ char *ckeybuf = "\x06\xa9\x21\x40\x36\xb8\xa1\x5b" -+ "\x51\x2e\x03\xd5\x34\x12\x00\x06"; -+ -+ memset(&sess, 0, sizeof(sess)); -+ sess.cipher = CRYPTO_AUTHENC_HMAC_SHA1_CBC_AES; -+ sess.keylen = 16; -+ sess.key = (unsigned char *)ckeybuf; -+ sess.mackeylen = 20; -+ sess.mackey = (unsigned char *)mkeybuf; -+ if (ioctl(fdc, CIOCGSESSION, &sess)) { -+ perror("ioctl(CIOCGSESSION)"); -+ return -EINVAL; -+ } -+ -+ do_test_vectors(fdc, tp, &sess); -+ return 0; -+} -+ - int main(int argc, char **argv) - { - int err = 0; -@@ -487,6 +611,7 @@ int main(int argc, char **argv) - tp.nflag = false; - tp.mflag = false; - tp.aflag = false; -+ tp.authflag = false; - alg_flag = false; - opterr = 0; - while ((c = getopt(argc, argv, "ahn:t:m")) != -1) { --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0100-close-the-session-after-every-test.patch b/recipes-kernel/cryptodev/sdk_patches/0100-close-the-session-after-every-test.patch deleted file mode 100644 index a108b9d0..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0100-close-the-session-after-every-test.patch +++ /dev/null @@ -1,108 +0,0 @@ -From 3ca93181fbcaa0acac01588738eb50270cf4999a Mon Sep 17 00:00:00 2001 -From: Alexe Radu -Date: Fri, 9 Dec 2016 16:05:56 +0200 -Subject: [PATCH 100/104] close the session after every test - -Signed-off-by: Alexe Radu ---- - tests/speed.c | 42 ++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 42 insertions(+) - -diff --git a/tests/speed.c b/tests/speed.c -index 61259b9..99ef75b 100644 ---- a/tests/speed.c -+++ b/tests/speed.c -@@ -488,6 +488,12 @@ int run_null(int fdc, struct test_params tp) - } - - do_test_vectors(fdc, tp, &sess); -+ -+ if (ioctl(fdc, CIOCFSESSION, &sess)) { -+ perror("ioctl(CIOCFSESSION)"); -+ return -EINVAL; -+ } -+ - return 0; - } - -@@ -507,6 +513,12 @@ int run_aes_128_cbc(int fdc, struct test_params tp) - } - - do_test_vectors(fdc, tp, &sess); -+ -+ if (ioctl(fdc, CIOCFSESSION, &sess)) { -+ perror("ioctl(CIOCFSESSION)"); -+ return -EINVAL; -+ } -+ - return 0; - } - -@@ -526,6 +538,12 @@ int run_aes_256_xts(int fdc, struct test_params tp) - } - - do_test_vectors(fdc, tp, &sess); -+ -+ if (ioctl(fdc, CIOCFSESSION, &sess)) { -+ perror("ioctl(CIOCFSESSION)"); -+ return -EINVAL; -+ } -+ - return 0; - } - -@@ -541,6 +559,12 @@ int run_crc32c(int fdc, struct test_params tp) - } - - do_test_vectors(fdc, tp, &sess); -+ -+ if (ioctl(fdc, CIOCFSESSION, &sess)) { -+ perror("ioctl(CIOCFSESSION)"); -+ return -EINVAL; -+ } -+ - return 0; - } - -@@ -556,6 +580,12 @@ int run_sha1(int fdc, struct test_params tp) - } - - do_test_vectors(fdc, tp, &sess); -+ -+ if (ioctl(fdc, CIOCFSESSION, &sess)) { -+ perror("ioctl(CIOCFSESSION)"); -+ return -EINVAL; -+ } -+ - return 0; - } - -@@ -571,6 +601,12 @@ int run_sha256(int fdc, struct test_params tp) - } - - do_test_vectors(fdc, tp, &sess); -+ -+ if (ioctl(fdc, CIOCFSESSION, &sess)) { -+ perror("ioctl(CIOCFSESSION)"); -+ return -EINVAL; -+ } -+ - return 0; - } - -@@ -595,6 +631,12 @@ int run_authenc(int fdc, struct test_params tp) - } - - do_test_vectors(fdc, tp, &sess); -+ -+ if (ioctl(fdc, CIOCFSESSION, &sess)) { -+ perror("ioctl(CIOCFSESSION)"); -+ return -EINVAL; -+ } -+ - return 0; - } - --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0101-add-support-for-rsa-speed-tests.patch b/recipes-kernel/cryptodev/sdk_patches/0101-add-support-for-rsa-speed-tests.patch deleted file mode 100644 index a70f3685..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0101-add-support-for-rsa-speed-tests.patch +++ /dev/null @@ -1,179 +0,0 @@ -From d67b28fb68f1ea56fdf794f516816b6c3ef5649a Mon Sep 17 00:00:00 2001 -From: Radu Alexe -Date: Thu, 12 Jan 2017 19:44:57 +0200 -Subject: [PATCH 101/104] add support for rsa speed tests - -Tests are only for rsa 1024 and 2048 and only sync variant. - -Signed-off-by: Radu Alexe ---- - tests/speed.c | 138 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- - 1 file changed, 137 insertions(+), 1 deletion(-) - -diff --git a/tests/speed.c b/tests/speed.c -index 99ef75b..b52938c 100644 ---- a/tests/speed.c -+++ b/tests/speed.c -@@ -63,8 +63,9 @@ int run_crc32c(int fdc, struct test_params tp); - int run_sha1(int fdc, struct test_params tp); - int run_sha256(int fdc, struct test_params tp); - int run_authenc(int fdc, struct test_params tp); -+int run_rsa(int fdc, struct test_params tp); - --#define ALG_COUNT 7 -+#define ALG_COUNT 8 - struct { - char *name; - int (*func)(int, struct test_params); -@@ -76,6 +77,7 @@ struct { - {"sha1", run_sha1}, - {"sha256", run_sha256}, - {"authenc", run_authenc}, -+ {"rsa", run_rsa}, - }; - - static double udifftimeval(struct timeval start, struct timeval end) -@@ -640,6 +642,140 @@ int run_authenc(int fdc, struct test_params tp) - return 0; - } - -+char *n_2048 = "\xFA\xBE\x23\x01\x5D\x11\x50\xAA\xAB\xED\x50\xA7\x9B\x93\x7B\xCE" -+ "\x1E\x11\xAE\xC1\x05\xAF\xBA\x57\x18\x6B\xE3\x27\x85\x3A\xFA\xB9" -+ "\x15\x5A\x39\xB2\x38\x60\xB8\x5B\xDF\xD0\x8F\xA3\x37\xEE\xE5\xFD" -+ "\xE2\x98\xF9\x40\xD2\x0A\xE9\x15\x69\x8A\x9D\xBC\x1F\x00\x0B\x95" -+ "\x5A\x19\x14\x4C\x14\x19\x38\x47\x30\x96\x17\xCB\x28\x1C\x1C\x09" -+ "\x14\x79\x55\x26\xAF\x6E\x38\x41\x91\x9D\xF5\x31\x6C\xFB\xCC\x68" -+ "\x08\xA2\x60\xA2\xA4\xE0\x68\x59\x24\xF5\xEB\x57\x88\x5C\x3D\xA3" -+ "\x41\x95\xFF\xD1\x03\xBA\xAE\x18\x55\x5D\xF4\x93\x57\x4D\x02\x11" -+ "\x66\xD8\x44\xF8\x63\x9D\x70\xBE\x98\x93\x43\xE0\x1F\x80\x7A\xE1" -+ "\x6D\xA0\x5D\xC3\xE5\x56\x1C\xDA\x96\x16\xB1\xD8\xBD\x62\x1E\x51" -+ "\x28\xF7\x06\xB7\x6D\xB0\x5A\x5F\x09\x28\xEF\x9B\x33\xA3\x04\x02" -+ "\x08\x4D\xD7\x2C\x22\x77\x3D\x9B\x2E\x45\xE7\x78\x5C\x64\x50\xF3" -+ "\x5B\x98\x6E\x0F\xDE\xA6\xDC\x19\x4D\xFF\xAB\xBE\x6D\xC7\xB1\x55" -+ "\x36\xDD\x40\x07\xEF\x78\xCC\xA1\x8D\x96\x6B\xDA\x48\x4C\x40\x29" -+ "\x46\x7C\xF0\x1A\x6B\xC5\xBB\x8B\xD1\xB0\x6F\x9B\xB7\xC0\x06\xF5" -+ "\x3B\x6F\x2B\x45\xEA\x17\x4C\x16\x2A\xC5\x5E\xB6\x1C\xCB\x3B\xFB"; -+ -+char *f_2048 = "\x69\xeb\xb3\xb3\x68\xc1\xbf\x17\x57\x63\xca\xa2\x21\xee\x1f\x56" -+ "\x8c\xee\x58\x96\x86\x86\x95\x44\xc7\xff\x75\xeb\xb4\xe8\xf6\x55" -+ "\x20\xa0\xad\x62\x50\xe4\x83\x07\x31\xe9\x41\x03\xf3\x69\x9b\x9b" -+ "\x0d\x68\xf3\x6e\x21\x02\x79\xc5\xa4\xd1\xe5\x11\x56\x9a\x2c\xb8" -+ "\xf5\x76\xab\x04\x03\xcc\x6d\xa3\xf1\xa3\x6a\x57\xfd\x6e\x87\x82" -+ "\xcf\x19\xf8\x0f\x97\x4d\x6e\xb5\xa0\x10\x27\x40\x12\x8b\x9f\x24" -+ "\xb4\x4a\x95\xbe\x6a\x49\x49\x67\xb0\x8f\x77\x5f\x1d\x56\x22\xc6" -+ "\x7d\xb3\x2f\x9e\x62\x4a\x0b\xf2\xca\x9e\xd1\x57\xf8\xf4\x25\x36" -+ "\x54\xe9\x4a\xcd\x4d\x9b\x14\xd5\xe5\x35\x59\x6b\xf5\xd0\x50\x69" -+ "\x5c\xde\x21\x32\xc9\x31\x8f\x21\x66\xda\x32\xb8\x45\x18\x18\x57" -+ "\xb0\x37\xff\xea\xee\x7a\xd5\x01\x36\x72\xb3\xfb\x23\xe2\x5c\xa2" -+ "\x10\xb9\xf3\x8b\xda\x37\x46\x7e\xac\xf5\x6c\xae\x18\x69\xbc\x9d" -+ "\x6e\xd7\x61\x7c\x85\x63\x41\x5e\x8b\xab\x12\xbe\x37\x1a\x67\xdd" -+ "\x86\xf2\xf9\xc8\x3a\xd7\xcd\x92\x72\xaf\xad\x46\xb0\x5b\x33\xd9" -+ "\x1c\x32\x02\x3c\xae\xe0\x5d\x87\xde\x95\x59\x10\x4e\xa7\xdf\x7f" -+ "\x94\x2d\xea\x9b\x7a\x53\x54\xc7\xf9\x66\xd1\x14\x0b\xd7\xef\x00"; -+ -+char *n_1024 = "\xF8\x99\x5E\xC7\xED\x60\x4B\xBA\x77\x0A\x52\xD0\xFF\xE6\x45\x47" -+ "\x04\xDE\xB3\x40\x16\x23\xB4\x58\x0A\xFF\xAF\x0D\x26\x1B\x5E\x0D" -+ "\x61\xA2\x4A\x7B\x2E\x70\x2A\x54\x21\xCB\x01\x31\xBC\xBE\xAE\xC9" -+ "\x5B\x3B\x20\x0B\x95\x06\x41\x03\xDB\xEF\x81\xE2\xFB\x42\xE8\x02" -+ "\x1D\xD2\xA7\xFD\xC3\xA0\x3F\x74\x6D\x99\x8D\x60\xBA\x43\x82\x6C" -+ "\x96\x24\x1D\xE5\xE3\x2C\xB7\x66\xAB\x2B\x4C\xFD\x23\xFF\xE0\x09" -+ "\x17\x3E\x01\xCB\xDC\xB2\xD2\xA9\x98\x99\x01\x91\x16\xAB\x77\xD7" -+ "\x97\x52\xBD\x49\xB2\xAF\x61\x95\xE8\xA2\x34\x9C\xC4\x00\xCC\x17"; -+ -+char *f_1024 = "\x8f\x2d\x06\x83\xee\x08\x97\xa4\x86\x3a\xf2\xa3\xd1\x6d\x33\x10" -+ "\x49\x1d\xb6\xd0\xe3\x7b\x16\x5a\x1a\x5c\x98\x36\xab\xd2\xa9\x82" -+ "\x5c\x1b\xc1\x9e\xdc\x50\x45\x05\xe0\x2e\x14\x83\x86\x47\x21\xc5" -+ "\x27\xad\xb1\x74\x5d\x7b\xe2\x92\xfc\x15\xf0\x14\x6c\x8d\x80\xe5" -+ "\x85\x72\x26\xc7\xa3\xd8\xc7\x5a\x10\xcd\x64\xde\x5d\x82\xc1\x53" -+ "\xd7\x2e\x03\xe0\xe2\xe6\xc6\x85\xcc\x07\x25\xa9\x61\xf7\x52\x3f" -+ "\x63\xb1\x54\x6e\x23\xbe\xf0\x6c\xa4\x93\x8c\x39\xe2\xdb\xcb\x1c" -+ "\x4b\x95\x3d\x57\x06\xc9\xce\x44\xe5\xaf\xac\x6b\x67\xdb\x92\x00"; -+ -+int run_rsa(int fdc, struct test_params tp) -+{ -+ struct timeval start, end; -+ double secs, ddata, dspeed; -+ uint64_t total = 0; -+ char metric[16]; -+ struct crypt_kop kop; -+ char *n, *f; -+ char *e = "\x01\x00\x01"; -+ char g[256]; -+ -+ if (!tp.nflag) -+ tp.nvalue = 2048; -+ -+ switch (tp.nvalue) { -+ case 2048: -+ n = n_2048; -+ f = f_2048; -+ break; -+ -+ case 1024: -+ n = n_1024; -+ f = f_1024; -+ break; -+ -+ default: -+ if (!tp.mflag) { -+ printf("Error: rsa-%d not supported\n", tp.nvalue); -+ fflush(stdout); -+ } -+ -+ return 1; -+ } -+ -+ kop.crk_op = CRK_MOD_EXP; -+ kop.crk_iparams = 3; -+ kop.crk_oparams = 1; -+ -+ kop.crk_param[0].crp_p = (__u8*)f; -+ kop.crk_param[0].crp_nbits = tp.nvalue; -+ -+ kop.crk_param[1].crp_p = (__u8*)e; -+ kop.crk_param[1].crp_nbits = 24; -+ -+ kop.crk_param[2].crp_p = (__u8*)n; -+ kop.crk_param[2].crp_nbits = tp.nvalue; -+ -+ kop.crk_param[3].crp_p = (__u8*)g; -+ kop.crk_param[3].crp_nbits = sizeof(g) << 3; -+ -+ if (!tp.mflag) { -+ printf("\trsa %d: ", tp.nvalue); -+ fflush(stdout); -+ } -+ -+ must_finish = 0; -+ alarm(tp.tvalue); -+ -+ gettimeofday(&start, NULL); -+ do { -+ if (ioctl(fdc, CIOCKEY, &kop)) { -+ perror("ioctl(CIOCKEY)"); -+ return -EINVAL; -+ } -+ total += (tp.nvalue >> 3); -+ } while (!must_finish); -+ gettimeofday(&end, NULL); -+ -+ secs = udifftimeval(start, end)/ 1000000.0; -+ -+ if (tp.mflag) { -+ value2machine(total, secs, &dspeed); -+ printf("%" PRIu64 "\t%.2f\t%.2f\n", total, secs, dspeed); -+ } else { -+ value2human(total, secs, &ddata, &dspeed, metric); -+ printf ("done. %.2f %s in %.2f secs: ", ddata, metric, secs); -+ printf ("%.2f %s/sec\n", dspeed, metric); -+ } -+ -+ return 0; -+} -+ - int main(int argc, char **argv) - { - int err = 0; --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0102-adjust-to-API-changes-in-kernel-4.10.patch b/recipes-kernel/cryptodev/sdk_patches/0102-adjust-to-API-changes-in-kernel-4.10.patch deleted file mode 100644 index 5ffc4508..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0102-adjust-to-API-changes-in-kernel-4.10.patch +++ /dev/null @@ -1,57 +0,0 @@ -From 008516c6a1dd0afe0eadff3ad00c1200c198983f Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Wed, 8 Feb 2017 10:19:34 +0200 -Subject: [PATCH 102/104] adjust to API changes in kernel >=4.10 - -There are many changes related to get_user_pages and the code is rewritten -for clarity. - -Signed-off-by: Cristian Stoica ---- - zc.c | 28 +++++++++++++++++----------- - 1 file changed, 17 insertions(+), 11 deletions(-) - -diff --git a/zc.c b/zc.c -index e766ee3..2f4ea99 100644 ---- a/zc.c -+++ b/zc.c -@@ -59,19 +59,25 @@ int __get_userbuf(uint8_t __user *addr, uint32_t len, int write, - } - - down_read(&mm->mmap_sem); --#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)) -- ret = get_user_pages_remote( -+#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)) -+ ret = get_user_pages(task, mm, -+ (unsigned long)addr, pgcount, write, 0, pg, NULL); - #else -- ret = get_user_pages( --#endif -- task, mm, -- (unsigned long)addr, pgcount, --#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)) -- write ? FOLL_WRITE : 0, --#else -- write, 0, --#endif -+# if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)) -+ ret = get_user_pages_remote(task, mm, -+ (unsigned long)addr, pgcount, write, 0, pg, NULL); -+# else -+# if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)) -+ ret = get_user_pages_remote(task, mm, -+ (unsigned long)addr, pgcount, write ? FOLL_WRITE : 0, - pg, NULL); -+# else -+ ret = get_user_pages_remote(task, mm, -+ (unsigned long)addr, pgcount, write ? FOLL_WRITE : 0, -+ pg, NULL, NULL); -+# endif -+# endif -+#endif - up_read(&mm->mmap_sem); - if (ret != pgcount) - return -EINVAL; --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0103-zc-Use-the-power-of-elif.patch b/recipes-kernel/cryptodev/sdk_patches/0103-zc-Use-the-power-of-elif.patch deleted file mode 100644 index 5c121077..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0103-zc-Use-the-power-of-elif.patch +++ /dev/null @@ -1,51 +0,0 @@ -From e2fa367d968926500584912e98cf7b17bd9487a6 Mon Sep 17 00:00:00 2001 -From: Phil Sutter -Date: Thu, 9 Feb 2017 11:40:46 +0100 -Subject: [PATCH 103/104] zc: Use the power of #elif - -While here, get rid of that trailing newline as well. - -Fixes: 2b29be8ac4141 ("adjust to API changes in kernel >=4.10") -Suggested-by: Frediano Ziglio -Signed-off-by: Phil Sutter ---- - zc.c | 11 +++-------- - 1 file changed, 3 insertions(+), 8 deletions(-) - -diff --git a/zc.c b/zc.c -index 2f4ea99..ae464ff 100644 ---- a/zc.c -+++ b/zc.c -@@ -62,21 +62,17 @@ int __get_userbuf(uint8_t __user *addr, uint32_t len, int write, - #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)) - ret = get_user_pages(task, mm, - (unsigned long)addr, pgcount, write, 0, pg, NULL); --#else --# if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)) -+#elif (LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)) - ret = get_user_pages_remote(task, mm, - (unsigned long)addr, pgcount, write, 0, pg, NULL); --# else --# if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)) -+#elif (LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)) - ret = get_user_pages_remote(task, mm, - (unsigned long)addr, pgcount, write ? FOLL_WRITE : 0, - pg, NULL); --# else -+#else - ret = get_user_pages_remote(task, mm, - (unsigned long)addr, pgcount, write ? FOLL_WRITE : 0, - pg, NULL, NULL); --# endif --# endif - #endif - up_read(&mm->mmap_sem); - if (ret != pgcount) -@@ -222,4 +218,3 @@ int get_userbuf(struct csession *ses, - } - return 0; - } -- --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0104-fix-reset-finish-condition-before-test-start.patch b/recipes-kernel/cryptodev/sdk_patches/0104-fix-reset-finish-condition-before-test-start.patch deleted file mode 100644 index 1038bed2..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0104-fix-reset-finish-condition-before-test-start.patch +++ /dev/null @@ -1,29 +0,0 @@ -From a4b33ea30c86fb727c1d3ac3531c5548b6c194ba Mon Sep 17 00:00:00 2001 -From: Radu Alexe -Date: Tue, 14 Feb 2017 12:52:33 +0200 -Subject: [PATCH 104/104] fix: reset finish condition before test start - -Typo from previous commit: ba494703 -"add support for authenc(hmac(sha1), cbc(aes)) speed tests" - -Signed-off-by: Radu Alexe ---- - tests/speed.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/tests/speed.c b/tests/speed.c -index b52938c..ae0b658 100644 ---- a/tests/speed.c -+++ b/tests/speed.c -@@ -276,7 +276,7 @@ static int encrypt_sync(int fdc, struct test_params tp, struct session_op *sess) - } - memset(buffer, val++, tp.nvalue); - -- must_finish = 1; -+ must_finish = 0; - alarm(tp.tvalue); - - gettimeofday(&start, NULL); --- -2.10.2 - diff --git a/recipes-kernel/cryptodev/sdk_patches/0105-update-copyright-notes.patch b/recipes-kernel/cryptodev/sdk_patches/0105-update-copyright-notes.patch deleted file mode 100644 index f2cd9065..00000000 --- a/recipes-kernel/cryptodev/sdk_patches/0105-update-copyright-notes.patch +++ /dev/null @@ -1,77 +0,0 @@ -From 6c2b61c17681d0e6ddc44b0438c9712fb2810ba6 Mon Sep 17 00:00:00 2001 -From: Cristian Stoica -Date: Tue, 28 Mar 2017 13:16:14 +0300 -Subject: [PATCH] update copyright notes - -Signed-off-by: Cristian Stoica ---- - tests/run_crypto_tests.sh | 16 ++++++++++++++++ - tests/sha_speed.c | 1 + - tests/speed.c | 1 + - zc.c | 1 + - 4 files changed, 19 insertions(+) - -diff --git a/tests/run_crypto_tests.sh b/tests/run_crypto_tests.sh -index 321b013..225ad7a 100644 ---- a/tests/run_crypto_tests.sh -+++ b/tests/run_crypto_tests.sh -@@ -1,4 +1,20 @@ - #!/bin/bash -+# -+# Copyright 2016 NXP Semiconductors -+# -+# This program is free software: you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation, either version 2 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . -+ - - - BUF_SIZE="8192 16384 65536 131072 262144" -diff --git a/tests/sha_speed.c b/tests/sha_speed.c -index 30b40f5..e6a2ac5 100644 ---- a/tests/sha_speed.c -+++ b/tests/sha_speed.c -@@ -1,6 +1,7 @@ - /* sha_speed - simple SHA benchmark tool for cryptodev - * - * Copyright (C) 2011 by Phil Sutter -+ * Copyright 2016 NXP - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by -diff --git a/tests/speed.c b/tests/speed.c -index ae0b658..6e18960 100644 ---- a/tests/speed.c -+++ b/tests/speed.c -@@ -1,6 +1,7 @@ - /* cryptodev_test - simple benchmark tool for cryptodev - * - * Copyright (C) 2010 by Phil Sutter -+ * Copyright 2016-2017 NXP - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by -diff --git a/zc.c b/zc.c -index ae464ff..63e7c23 100644 ---- a/zc.c -+++ b/zc.c -@@ -4,6 +4,7 @@ - * Copyright (c) 2009-2013 Nikos Mavrogiannopoulos - * Copyright (c) 2010 Phil Sutter - * Copyright (c) 2011, 2012 OpenSSL Software Foundation, Inc. -+ * Copyright 2017 NXP - * - * This file is part of linux cryptodev. - * --- -1.9.2 - -- 2.40.1