diff options
author | Chunrong Guo <chunrong.guo@nxp.com> | 2017-07-28 15:44:09 +0800 |
---|---|---|
committer | Otavio Salvador <otavio@ossystems.com.br> | 2017-08-07 11:42:29 -0300 |
commit | ece24e8f9a042561f188d8f09c60b146dd081c94 (patch) | |
tree | 1f9b832c30fa2740f16363187493814aca21a3c2 | |
parent | d586bfdde75ab6cae4f2dcdb63c068e07f4c188e (diff) | |
download | meta-freescale-ece24e8f9a042561f188d8f09c60b146dd081c94.tar.gz |
cryptodev-qoriq: update to v1.9
Signed-off-by: Chunrong Guo <B40290@freescale.com>
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
119 files changed, 1047 insertions, 14195 deletions
diff --git a/recipes-kernel/cryptodev/cryptodev-qoriq-linux_1.8.bb b/recipes-kernel/cryptodev/cryptodev-qoriq-linux_1.9.bb index 58db5053..58db5053 100644 --- a/recipes-kernel/cryptodev/cryptodev-qoriq-linux_1.8.bb +++ b/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 index 412bb0e5..412bb0e5 100644 --- a/recipes-kernel/cryptodev/cryptodev-qoriq-module_1.8.bb +++ b/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 index f7d0b61b..f7d0b61b 100644 --- a/recipes-kernel/cryptodev/cryptodev-qoriq-tests_1.8.bb +++ b/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 @@ | |||
1 | HOMEPAGE = "http://cryptodev-linux.org/" | ||
2 | |||
3 | LICENSE = "GPLv2" | ||
4 | LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263" | ||
5 | |||
6 | python() { | ||
7 | pkgs = d.getVar('PACKAGES', True).split() | ||
8 | for p in pkgs: | ||
9 | if 'cryptodev-qoriq' in p: | ||
10 | d.appendVar("RPROVIDES_%s" % p, p.replace('cryptodev-qoriq', 'cryptodev')) | ||
11 | d.appendVar("RCONFLICTS_%s" % p, p.replace('cryptodev-qoriq', 'cryptodev')) | ||
12 | d.appendVar("RREPLACES_%s" % p, p.replace('cryptodev-qoriq', 'cryptodev')) | ||
13 | } | ||
14 | |||
15 | FILESEXTRAPATHS_prepend := "${THISDIR}/sdk_patches:" | ||
16 | FILESEXTRAPATHS_prepend := "${THISDIR}/yocto_patches:" | ||
17 | |||
18 | SRC_URI = "http://download.gna.org/cryptodev-linux/cryptodev-linux-${PV}.tar.gz" | ||
19 | |||
20 | SRC_URI[md5sum] = "02644cc4cd02301e0b503a332eb2f0b5" | ||
21 | SRC_URI[sha256sum] = "67fabde9fb67b286a96c4f45b594b0eccd0f761b495705c18f2ae9461b831376" | ||
22 | |||
23 | # SDK patches | ||
24 | SRC_URI_append = " file://0001-add-support-for-composite-TLS10-SHA1-AES-algorithm-o.patch \ | ||
25 | file://0002-add-support-for-COMPAT_CIOCAUTHCRYPT-ioctl.patch \ | ||
26 | file://0003-PKC-support-added-in-cryptodev-module.patch \ | ||
27 | file://0004-Compat-versions-of-PKC-IOCTLs.patch \ | ||
28 | file://0005-Asynchronous-interface-changes-in-cryptodev.patch \ | ||
29 | file://0006-ECC_KEYGEN-and-DLC_KEYGEN-supported-in-cryptodev-mod.patch \ | ||
30 | file://0007-RCU-stall-fixed-in-PKC-asynchronous-interface.patch \ | ||
31 | file://0008-Add-RSA-Key-generation-offloading.patch \ | ||
32 | file://0009-Fixed-compilation-error-of-openssl-with-fsl-cryptode.patch \ | ||
33 | file://0010-add-support-for-composite-TLS10-SHA1-3DES-algorithm-.patch \ | ||
34 | file://0011-add-support-for-TLSv1.1-record-offload.patch \ | ||
35 | file://0012-add-support-for-TLSv1.2-record-offload.patch \ | ||
36 | file://0013-clean-up-code-layout.patch \ | ||
37 | file://0014-remove-redundant-data-copy-for-pkc-operations.patch \ | ||
38 | file://0015-fix-pkc-request-deallocation.patch \ | ||
39 | file://0016-add-basic-detection-of-asym-features.patch \ | ||
40 | file://0017-remove-dead-code.patch \ | ||
41 | file://0018-fix-compat-warnings.patch \ | ||
42 | file://0019-fix-size_t-print-format.patch \ | ||
43 | file://0020-fix-uninitialized-variable-compiler-warning.patch \ | ||
44 | file://0021-check-return-codes-for-copy-to-from-user-functions.patch \ | ||
45 | file://0022-fix-double-free-pkc-req-on-error.patch \ | ||
46 | file://0023-remove-MAY_BACKLOG-flag-from-requests.patch \ | ||
47 | file://0024-fix-COMPAT_CIOCKEY-ioctl-command-number.patch \ | ||
48 | file://0025-fix-benchmarks-linking.patch \ | ||
49 | file://0026-fix-Makefile-to-allow-parallel-make-with-j-option.patch \ | ||
50 | file://0027-use-Linux-kernel-conventions-for-Makefile-variables.patch \ | ||
51 | file://0028-for-consistency-use-.-instead-of-.-in-makefiles.patch \ | ||
52 | file://0029-fix-clean-up-on-error-path-for-crypto_create_session.patch \ | ||
53 | file://0030-remove-code-duplication-in-cryptodev_hash_init.patch \ | ||
54 | file://0031-fix-comment-typo.patch \ | ||
55 | file://0032-avoid-calls-to-kmalloc-on-hotpaths.patch \ | ||
56 | file://0033-avoid-unnecessary-checks-for-hash-clean-up.patch \ | ||
57 | file://0034-extend-API-with-CIOCHASH-to-support-direct-hash-oper.patch \ | ||
58 | file://0035-use-directly-crypto-API-digest-operation-for-CIOCHAS.patch \ | ||
59 | file://0036-add-compat-for-CIOCHASH-operation.patch \ | ||
60 | file://0037-rewrite-sha_speed.c-to-reduce-code-duplication.patch \ | ||
61 | file://0038-extend-sha_speed.c-to-test-CIOCHASH.patch \ | ||
62 | file://0039-fix-memory-leaks-on-error-path-for-CIOCHASH.patch \ | ||
63 | file://0040-fix-structure-init-in-sha_speed-test.patch \ | ||
64 | file://0041-add-separate-target-for-building-tests.patch \ | ||
65 | file://0042-fix-destination-for-staged-installs.patch \ | ||
66 | file://0043-add-install-target-for-tests.patch \ | ||
67 | file://0044-add-aes-256-xts-support-for-async-speed-test.patch \ | ||
68 | file://0045-add-support-for-crc32c-hash-async-speed-test.patch \ | ||
69 | file://0046-add-support-for-sha1-hash-async-speed-test.patch \ | ||
70 | file://0047-add-support-for-sha2-256-hash-async-speed-test.patch \ | ||
71 | file://0048-add-support-for-aes-256-xts-sync-speed-test.patch \ | ||
72 | file://0049-add-support-for-crc32c-hash-sync-speed-test.patch \ | ||
73 | file://0050-add-basic-optargs-support-for-async_speed-test.patch \ | ||
74 | file://0051-enable-async-code-by-default.patch \ | ||
75 | file://0052-add-flag-to-report-in-a-machine-friendly-format.patch \ | ||
76 | file://0053-honor-the-m-flag-in-async_speed.patch \ | ||
77 | file://0054-rename-algorithm-names-for-clarity.patch \ | ||
78 | file://0055-add-multithreaded-wrapper-for-async-speed-test.patch \ | ||
79 | file://0056-fix-set-min-value-when-allocating-alligned-memory-bu.patch \ | ||
80 | file://0057-gracefull-stop-for-async-speed-tests.patch \ | ||
81 | file://0058-sanity-check-on-dev-crypto-availability.patch \ | ||
82 | file://0059-fix-some-issues-with-parsing-mpstat-output.patch \ | ||
83 | file://0060-more-precision-in-running-mpstat.patch \ | ||
84 | file://0061-add-a-little-space-in-the-output-for-clarity.patch \ | ||
85 | file://0062-fix-build-warnings-on-implicit-function-declarations.patch \ | ||
86 | file://0063-avoid-implicit-conversion-between-signed-and-unsigne.patch \ | ||
87 | file://0064-remove-not-used-local-variables.patch \ | ||
88 | file://0065-return-error-code-of-the-test-if-there-is-one.patch \ | ||
89 | file://0066-do-more-strict-code-checking-to-avoid-maintenance-is.patch \ | ||
90 | file://0067-fix-issues-with-install-target.patch \ | ||
91 | file://0068-setting-KERNEL_DIR-is-not-necessary-to-build-tests.patch \ | ||
92 | file://0069-fix-the-reported-unit.patch \ | ||
93 | file://0070-remove-old-results-to-avoid-incorrect-reports.patch \ | ||
94 | file://0071-fix-the-scale-of-the-runtime-value.patch \ | ||
95 | file://0072-use-.-instead-of-.-for-consistency.patch \ | ||
96 | file://0073-really-fix-again.-the-mpstat-issue.patch \ | ||
97 | file://0074-make-default-output-tabular.patch \ | ||
98 | file://0075-fix-incorrect-handling-of-error-cases.patch \ | ||
99 | file://0076-exit-early-if-cryptodev-tests-are-not-installed.patch \ | ||
100 | file://0077-the-C-standard-used-by-cryptodev-is-C90-with-GNU-ext.patch \ | ||
101 | file://0078-remove-output-line-because-it-does-not-add-clarity-t.patch \ | ||
102 | file://0079-fix-typo-use-consistent-spacing.patch \ | ||
103 | file://0080-graceful-exit-if-cryptodev-is-not-built-with-ASYNC-f.patch \ | ||
104 | file://0081-add-sync-speed-tests-with-the-same-format-as-async-o.patch \ | ||
105 | file://0082-force-LC_TIME-value-to-avoid-mpstat-not-using-ISO860.patch \ | ||
106 | file://0083-use-the-same-algorithm-names-in-sync_speed-as-in-asy.patch \ | ||
107 | file://0084-fix-ignored-SIGALRM-signals-on-some-platforms.patch \ | ||
108 | file://0085-add-notes-about-configured-limits-in-SEC-driver.patch \ | ||
109 | file://0086-add-a-wrapper-script-for-running-all-tests.patch \ | ||
110 | file://0087-add-to-cpu-idle-for-convenience.patch \ | ||
111 | file://0088-merge-sync-and-async-benchmarks-into-a-single-progra.patch \ | ||
112 | file://0089-add-async-option-to-run_crypto_tests.sh.patch \ | ||
113 | file://0090-Adjust-to-recent-user-page-API-changes.patch \ | ||
114 | file://0091-Fix-test-compile-time-warnings.patch \ | ||
115 | file://0092-Support-skcipher-in-addition-to-ablkcipher-API.patch \ | ||
116 | file://0093-Fix-ablkcipher-algorithms-usage-in-v4.8-kernels.patch \ | ||
117 | file://0094-Adjust-to-another-change-in-the-user-page-API.patch \ | ||
118 | file://0095-rename-header-file-to-clarify-purpose.patch \ | ||
119 | file://0096-use-buf_align-macro-to-reduce-code-duplication.patch \ | ||
120 | file://0097-avoid-implicit-conversion-between-signed-and-unsigne.patch \ | ||
121 | file://0098-reduce-tests-Makefile-distance-with-upstream.patch \ | ||
122 | file://0099-add-support-for-authenc-hmac-sha1-cbc-aes-speed-test.patch \ | ||
123 | file://0100-close-the-session-after-every-test.patch \ | ||
124 | file://0101-add-support-for-rsa-speed-tests.patch \ | ||
125 | file://0102-adjust-to-API-changes-in-kernel-4.10.patch \ | ||
126 | file://0103-zc-Use-the-power-of-elif.patch \ | ||
127 | file://0104-fix-reset-finish-condition-before-test-start.patch \ | ||
128 | file://0105-update-copyright-notes.patch \ | ||
129 | " | ||
130 | SRC_URI_append = " file://0003-update-the-install-path-for-cryptodev-tests.patch" | ||
131 | |||
132 | # NOTE: remove this patch and all traces of DISTRO_FEATURE c29x_pkc | ||
133 | # if pkc-host does not need customized cryptodev patches anymore | ||
134 | SRC_URI_append = "${@bb.utils.contains('DISTRO_FEATURES', 'c29x_pkc', ' file://0001-don-t-advertise-RSA-keygen.patch', '', d)}" | ||
135 | |||
136 | S = "${WORKDIR}/cryptodev-linux-${PV}" | ||
137 | |||
138 | 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 @@ | |||
1 | HOMEPAGE = "http://cryptodev-linux.org/" | ||
2 | |||
3 | LICENSE = "GPLv2" | ||
4 | LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263" | ||
5 | |||
6 | python() { | ||
7 | pkgs = d.getVar('PACKAGES', True).split() | ||
8 | for p in pkgs: | ||
9 | if 'cryptodev-qoriq' in p: | ||
10 | d.appendVar("RPROVIDES_%s" % p, p.replace('cryptodev-qoriq', 'cryptodev')) | ||
11 | d.appendVar("RCONFLICTS_%s" % p, p.replace('cryptodev-qoriq', 'cryptodev')) | ||
12 | d.appendVar("RREPLACES_%s" % p, p.replace('cryptodev-qoriq', 'cryptodev')) | ||
13 | } | ||
14 | |||
15 | FILESEXTRAPATHS_prepend := "${THISDIR}/sdk_patches:" | ||
16 | FILESEXTRAPATHS_prepend := "${THISDIR}/yocto_patches:" | ||
17 | |||
18 | SRC_URI = "http://nwl.cc/pub/cryptodev-linux/cryptodev-linux-${PV}.tar.gz" | ||
19 | |||
20 | SRC_URI[md5sum] = "cb4e0ed9e5937716c7c8a7be84895b6d" | ||
21 | SRC_URI[sha256sum] = "9f4c0b49b30e267d776f79455d09c70cc9c12c86eee400a0d0a0cd1d8e467950" | ||
22 | |||
23 | # SDK patches | ||
24 | SRC_URI_append = " file://0001-refactoring-split-big-function-to-simplify-maintaina.patch \ | ||
25 | file://0002-refactoring-relocate-code-to-simplify-later-patches.patch \ | ||
26 | file://0003-convert-to-new-AEAD-interface-in-kernels-v4.2.patch \ | ||
27 | file://0004-fix-type-of-returned-value.patch \ | ||
28 | file://0005-remove-unnecessary-header-inclusion.patch \ | ||
29 | file://0006-move-structure-definition-to-cryptodev_int.h.patch \ | ||
30 | file://0007-add-support-for-RSA-public-and-private-key-operation.patch \ | ||
31 | file://0008-check-session-flags-early-to-avoid-incorrect-failure.patch \ | ||
32 | file://0009-add-support-for-composite-TLS10-SHA1-AES-algorithm-o.patch \ | ||
33 | " | ||
34 | #SRC_URI_append = " file://0003-update-the-install-path-for-cryptodev-tests.patch" | ||
35 | |||
36 | # NOTE: remove this patch and all traces of DISTRO_FEATURE c29x_pkc | ||
37 | # if pkc-host does not need customized cryptodev patches anymore | ||
38 | #SRC_URI_append = "${@bb.utils.contains('DISTRO_FEATURES', 'c29x_pkc', ' file://0001-don-t-advertise-RSA-keygen.patch', '', d)}" | ||
39 | |||
40 | S = "${WORKDIR}/cryptodev-linux-${PV}" | ||
41 | |||
42 | 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 @@ | |||
1 | From d30c9c64aca4a7905e1b7eb3e28e1c616191bd34 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@freescale.com> | ||
3 | Date: Tue, 9 Dec 2014 16:41:25 +0200 | ||
4 | Subject: [PATCH] don't advertise RSA keygen | ||
5 | |||
6 | Disable RSA keygen operations when they are not available. | ||
7 | |||
8 | Currently no testing can be done and this patch should be applied | ||
9 | selectively on platforms that have incomplete support for RSA operations | ||
10 | (for example pkc driver on C293) | ||
11 | |||
12 | Change-Id: Ic8df014623410c3cf4b0b217a246efcea8f2eeef | ||
13 | Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> | ||
14 | --- | ||
15 | ioctl.c | 2 +- | ||
16 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
17 | |||
18 | diff --git a/ioctl.c b/ioctl.c | ||
19 | index 53dbf64..27dc66e 100644 | ||
20 | --- a/ioctl.c | ||
21 | +++ b/ioctl.c | ||
22 | @@ -979,7 +979,7 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | ||
23 | case CIOCASYMFEAT: | ||
24 | ses = 0; | ||
25 | if (crypto_has_alg("pkc(rsa)", 0, 0)) | ||
26 | - ses = CRF_MOD_EXP_CRT | CRF_MOD_EXP | CRF_RSA_GENERATE_KEY; | ||
27 | + ses = CRF_MOD_EXP_CRT | CRF_MOD_EXP ; | ||
28 | if (crypto_has_alg("pkc(dsa)", 0, 0)) | ||
29 | ses |= CRF_DSA_SIGN | CRF_DSA_VERIFY | CRF_DSA_GENERATE_KEY; | ||
30 | if (crypto_has_alg("pkc(dh)", 0, 0)) | ||
31 | -- | ||
32 | 2.3.5 | ||
33 | |||
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 @@ | |||
1 | From 20dcf071bc3076ee7db9d603cfbe6a06e86c7d5f Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Thu, 4 May 2017 15:06:20 +0300 | ||
4 | Subject: [PATCH 1/9] refactoring: split big function to simplify maintainance | ||
5 | |||
6 | The setup of auth_buf in tls and aead is now duplicated but this | ||
7 | is temporary and allows necessary corrections for the aead case | ||
8 | with v4.2+ kernels. | ||
9 | |||
10 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
11 | --- | ||
12 | authenc.c | 197 ++++++++++++++++++++++++++++++++++++++++---------------------- | ||
13 | 1 file changed, 126 insertions(+), 71 deletions(-) | ||
14 | |||
15 | diff --git a/authenc.c b/authenc.c | ||
16 | index 1bd7377..28eb0f9 100644 | ||
17 | --- a/authenc.c | ||
18 | +++ b/authenc.c | ||
19 | @@ -609,96 +609,151 @@ auth_n_crypt(struct csession *ses_ptr, struct kernel_crypt_auth_op *kcaop, | ||
20 | return 0; | ||
21 | } | ||
22 | |||
23 | -/* This is the main crypto function - zero-copy edition */ | ||
24 | -static int | ||
25 | -__crypto_auth_run_zc(struct csession *ses_ptr, struct kernel_crypt_auth_op *kcaop) | ||
26 | +static int crypto_auth_zc_srtp(struct csession *ses_ptr, struct kernel_crypt_auth_op *kcaop) | ||
27 | { | ||
28 | - struct scatterlist *dst_sg, *auth_sg, *src_sg; | ||
29 | + struct scatterlist *dst_sg, *auth_sg; | ||
30 | struct crypt_auth_op *caop = &kcaop->caop; | ||
31 | - int ret = 0; | ||
32 | + int ret; | ||
33 | |||
34 | - if (caop->flags & COP_FLAG_AEAD_SRTP_TYPE) { | ||
35 | - if (unlikely(ses_ptr->cdata.init != 0 && | ||
36 | - (ses_ptr->cdata.stream == 0 || | ||
37 | - ses_ptr->cdata.aead != 0))) { | ||
38 | - derr(0, "Only stream modes are allowed in SRTP mode (but not AEAD)"); | ||
39 | - return -EINVAL; | ||
40 | - } | ||
41 | + if (unlikely(ses_ptr->cdata.init != 0 && | ||
42 | + (ses_ptr->cdata.stream == 0 || ses_ptr->cdata.aead != 0))) { | ||
43 | + derr(0, "Only stream modes are allowed in SRTP mode (but not AEAD)"); | ||
44 | + return -EINVAL; | ||
45 | + } | ||
46 | |||
47 | - ret = get_userbuf_srtp(ses_ptr, kcaop, &auth_sg, &dst_sg); | ||
48 | - if (unlikely(ret)) { | ||
49 | - derr(1, "get_userbuf_srtp(): Error getting user pages."); | ||
50 | - return ret; | ||
51 | - } | ||
52 | + ret = get_userbuf_srtp(ses_ptr, kcaop, &auth_sg, &dst_sg); | ||
53 | + if (unlikely(ret)) { | ||
54 | + derr(1, "get_userbuf_srtp(): Error getting user pages."); | ||
55 | + return ret; | ||
56 | + } | ||
57 | |||
58 | - ret = srtp_auth_n_crypt(ses_ptr, kcaop, auth_sg, caop->auth_len, | ||
59 | - dst_sg, caop->len); | ||
60 | + ret = srtp_auth_n_crypt(ses_ptr, kcaop, auth_sg, caop->auth_len, | ||
61 | + dst_sg, caop->len); | ||
62 | |||
63 | - release_user_pages(ses_ptr); | ||
64 | - } else { /* TLS and normal cases. Here auth data are usually small | ||
65 | - * so we just copy them to a free page, instead of trying | ||
66 | - * to map them. | ||
67 | - */ | ||
68 | - unsigned char *auth_buf = NULL; | ||
69 | - struct scatterlist tmp; | ||
70 | + release_user_pages(ses_ptr); | ||
71 | |||
72 | - if (unlikely(caop->auth_len > PAGE_SIZE)) { | ||
73 | - derr(1, "auth data len is excessive."); | ||
74 | - return -EINVAL; | ||
75 | - } | ||
76 | + return ret; | ||
77 | +} | ||
78 | |||
79 | - auth_buf = (char *)__get_free_page(GFP_KERNEL); | ||
80 | - if (unlikely(!auth_buf)) { | ||
81 | - derr(1, "unable to get a free page."); | ||
82 | - return -ENOMEM; | ||
83 | - } | ||
84 | +static int crypto_auth_zc_tls(struct csession *ses_ptr, struct kernel_crypt_auth_op *kcaop) | ||
85 | +{ | ||
86 | + struct crypt_auth_op *caop = &kcaop->caop; | ||
87 | + struct scatterlist *dst_sg, *auth_sg; | ||
88 | + unsigned char *auth_buf = NULL; | ||
89 | + struct scatterlist tmp; | ||
90 | + int ret; | ||
91 | |||
92 | - if (caop->auth_src && caop->auth_len > 0) { | ||
93 | - if (unlikely(copy_from_user(auth_buf, caop->auth_src, caop->auth_len))) { | ||
94 | - derr(1, "unable to copy auth data from userspace."); | ||
95 | - ret = -EFAULT; | ||
96 | - goto free_auth_buf; | ||
97 | - } | ||
98 | + if (unlikely(ses_ptr->cdata.aead != 0)) { | ||
99 | + return -EINVAL; | ||
100 | + } | ||
101 | + | ||
102 | + if (unlikely(caop->auth_len > PAGE_SIZE)) { | ||
103 | + derr(1, "auth data len is excessive."); | ||
104 | + return -EINVAL; | ||
105 | + } | ||
106 | + | ||
107 | + auth_buf = (char *)__get_free_page(GFP_KERNEL); | ||
108 | + if (unlikely(!auth_buf)) { | ||
109 | + derr(1, "unable to get a free page."); | ||
110 | + return -ENOMEM; | ||
111 | + } | ||
112 | |||
113 | - sg_init_one(&tmp, auth_buf, caop->auth_len); | ||
114 | - auth_sg = &tmp; | ||
115 | - } else { | ||
116 | - auth_sg = NULL; | ||
117 | + if (caop->auth_src && caop->auth_len > 0) { | ||
118 | + if (unlikely(copy_from_user(auth_buf, caop->auth_src, caop->auth_len))) { | ||
119 | + derr(1, "unable to copy auth data from userspace."); | ||
120 | + ret = -EFAULT; | ||
121 | + goto free_auth_buf; | ||
122 | } | ||
123 | |||
124 | - if (caop->flags & COP_FLAG_AEAD_TLS_TYPE && ses_ptr->cdata.aead == 0) { | ||
125 | - ret = get_userbuf_tls(ses_ptr, kcaop, &dst_sg); | ||
126 | - if (unlikely(ret)) { | ||
127 | - derr(1, "get_userbuf_tls(): Error getting user pages."); | ||
128 | - goto free_auth_buf; | ||
129 | - } | ||
130 | + sg_init_one(&tmp, auth_buf, caop->auth_len); | ||
131 | + auth_sg = &tmp; | ||
132 | + } else { | ||
133 | + auth_sg = NULL; | ||
134 | + } | ||
135 | |||
136 | - ret = tls_auth_n_crypt(ses_ptr, kcaop, auth_sg, caop->auth_len, | ||
137 | - dst_sg, caop->len); | ||
138 | - } else { | ||
139 | - if (unlikely(ses_ptr->cdata.init == 0 || | ||
140 | - (ses_ptr->cdata.stream == 0 && | ||
141 | - ses_ptr->cdata.aead == 0))) { | ||
142 | - derr(0, "Only stream and AEAD ciphers are allowed for authenc"); | ||
143 | - ret = -EINVAL; | ||
144 | - goto free_auth_buf; | ||
145 | - } | ||
146 | + ret = get_userbuf_tls(ses_ptr, kcaop, &dst_sg); | ||
147 | + if (unlikely(ret)) { | ||
148 | + derr(1, "get_userbuf_tls(): Error getting user pages."); | ||
149 | + goto free_auth_buf; | ||
150 | + } | ||
151 | |||
152 | - ret = get_userbuf(ses_ptr, caop->src, caop->len, caop->dst, kcaop->dst_len, | ||
153 | - kcaop->task, kcaop->mm, &src_sg, &dst_sg); | ||
154 | - if (unlikely(ret)) { | ||
155 | - derr(1, "get_userbuf(): Error getting user pages."); | ||
156 | - goto free_auth_buf; | ||
157 | - } | ||
158 | + ret = tls_auth_n_crypt(ses_ptr, kcaop, auth_sg, caop->auth_len, | ||
159 | + dst_sg, caop->len); | ||
160 | + release_user_pages(ses_ptr); | ||
161 | + | ||
162 | +free_auth_buf: | ||
163 | + free_page((unsigned long)auth_buf); | ||
164 | + return ret; | ||
165 | +} | ||
166 | + | ||
167 | +static int crypto_auth_zc_aead(struct csession *ses_ptr, struct kernel_crypt_auth_op *kcaop) | ||
168 | +{ | ||
169 | + struct scatterlist *dst_sg, *auth_sg, *src_sg; | ||
170 | + struct crypt_auth_op *caop = &kcaop->caop; | ||
171 | + unsigned char *auth_buf = NULL; | ||
172 | + struct scatterlist tmp; | ||
173 | + int ret; | ||
174 | |||
175 | - ret = auth_n_crypt(ses_ptr, kcaop, auth_sg, caop->auth_len, | ||
176 | - src_sg, dst_sg, caop->len); | ||
177 | + if (unlikely(ses_ptr->cdata.init == 0 || | ||
178 | + (ses_ptr->cdata.stream == 0 && ses_ptr->cdata.aead == 0))) { | ||
179 | + derr(0, "Only stream and AEAD ciphers are allowed for authenc"); | ||
180 | + return -EINVAL; | ||
181 | + } | ||
182 | + | ||
183 | + if (unlikely(caop->auth_len > PAGE_SIZE)) { | ||
184 | + derr(1, "auth data len is excessive."); | ||
185 | + return -EINVAL; | ||
186 | + } | ||
187 | + | ||
188 | + auth_buf = (char *)__get_free_page(GFP_KERNEL); | ||
189 | + if (unlikely(!auth_buf)) { | ||
190 | + derr(1, "unable to get a free page."); | ||
191 | + return -ENOMEM; | ||
192 | + } | ||
193 | + | ||
194 | + if (caop->auth_src && caop->auth_len > 0) { | ||
195 | + if (unlikely(copy_from_user(auth_buf, caop->auth_src, caop->auth_len))) { | ||
196 | + derr(1, "unable to copy auth data from userspace."); | ||
197 | + ret = -EFAULT; | ||
198 | + goto free_auth_buf; | ||
199 | } | ||
200 | |||
201 | - release_user_pages(ses_ptr); | ||
202 | + sg_init_one(&tmp, auth_buf, caop->auth_len); | ||
203 | + auth_sg = &tmp; | ||
204 | + } else { | ||
205 | + auth_sg = NULL; | ||
206 | + } | ||
207 | + | ||
208 | + ret = get_userbuf(ses_ptr, caop->src, caop->len, caop->dst, kcaop->dst_len, | ||
209 | + kcaop->task, kcaop->mm, &src_sg, &dst_sg); | ||
210 | + if (unlikely(ret)) { | ||
211 | + derr(1, "get_userbuf(): Error getting user pages."); | ||
212 | + goto free_auth_buf; | ||
213 | + } | ||
214 | + | ||
215 | + ret = auth_n_crypt(ses_ptr, kcaop, auth_sg, caop->auth_len, | ||
216 | + src_sg, dst_sg, caop->len); | ||
217 | + | ||
218 | + release_user_pages(ses_ptr); | ||
219 | |||
220 | free_auth_buf: | ||
221 | - free_page((unsigned long)auth_buf); | ||
222 | + free_page((unsigned long)auth_buf); | ||
223 | + | ||
224 | + return ret; | ||
225 | +} | ||
226 | + | ||
227 | +static int | ||
228 | +__crypto_auth_run_zc(struct csession *ses_ptr, struct kernel_crypt_auth_op *kcaop) | ||
229 | +{ | ||
230 | + struct crypt_auth_op *caop = &kcaop->caop; | ||
231 | + int ret; | ||
232 | + | ||
233 | + if (caop->flags & COP_FLAG_AEAD_SRTP_TYPE) { | ||
234 | + ret = crypto_auth_zc_srtp(ses_ptr, kcaop); | ||
235 | + } else if (caop->flags & COP_FLAG_AEAD_TLS_TYPE) { | ||
236 | + ret = crypto_auth_zc_tls(ses_ptr, kcaop); | ||
237 | + } else { | ||
238 | + ret = crypto_auth_zc_aead(ses_ptr, kcaop); | ||
239 | } | ||
240 | |||
241 | return ret; | ||
242 | -- | ||
243 | 2.7.4 | ||
244 | |||
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 @@ | |||
1 | From d9f27d08708556e22e1b1dc87b0495896879ca66 Mon Sep 17 00:00:00 2001 | ||
2 | From: Horia Geanta <horia.geanta@freescale.com> | ||
3 | Date: Wed, 4 Dec 2013 15:43:41 +0200 | ||
4 | Subject: [PATCH 02/38] add support for COMPAT_CIOCAUTHCRYPT ioctl() | ||
5 | |||
6 | Upstream-status: Pending | ||
7 | |||
8 | Needed for 64b kernel with 32b user space. | ||
9 | |||
10 | Change-Id: I44a999a4164e7ae7122dee6ed0716b2f25cadbc1 | ||
11 | Signed-off-by: Horia Geanta <horia.geanta@freescale.com> | ||
12 | Tested-by: Cristian Stoica <cristian.stoica@freescale.com> | ||
13 | --- | ||
14 | authenc.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
15 | cryptodev_int.h | 40 +++++++++++++++++++++++++++++ | ||
16 | ioctl.c | 16 ++++++++++++ | ||
17 | 3 files changed, 134 insertions(+) | ||
18 | |||
19 | diff --git a/authenc.c b/authenc.c | ||
20 | index 1bd7377..ef0d3db 100644 | ||
21 | --- a/authenc.c | ||
22 | +++ b/authenc.c | ||
23 | @@ -272,6 +272,84 @@ static int fill_caop_from_kcaop(struct kernel_crypt_auth_op *kcaop, struct fcryp | ||
24 | return 0; | ||
25 | } | ||
26 | |||
27 | +/* compatibility code for 32bit userlands */ | ||
28 | +#ifdef CONFIG_COMPAT | ||
29 | + | ||
30 | +static inline void | ||
31 | +compat_to_crypt_auth_op(struct compat_crypt_auth_op *compat, | ||
32 | + struct crypt_auth_op *caop) | ||
33 | +{ | ||
34 | + caop->ses = compat->ses; | ||
35 | + caop->op = compat->op; | ||
36 | + caop->flags = compat->flags; | ||
37 | + caop->len = compat->len; | ||
38 | + caop->auth_len = compat->auth_len; | ||
39 | + caop->tag_len = compat->tag_len; | ||
40 | + caop->iv_len = compat->iv_len; | ||
41 | + | ||
42 | + caop->auth_src = compat_ptr(compat->auth_src); | ||
43 | + caop->src = compat_ptr(compat->src); | ||
44 | + caop->dst = compat_ptr(compat->dst); | ||
45 | + caop->tag = compat_ptr(compat->tag); | ||
46 | + caop->iv = compat_ptr(compat->iv); | ||
47 | +} | ||
48 | + | ||
49 | +static inline void | ||
50 | +crypt_auth_op_to_compat(struct crypt_auth_op *caop, | ||
51 | + struct compat_crypt_auth_op *compat) | ||
52 | +{ | ||
53 | + compat->ses = caop->ses; | ||
54 | + compat->op = caop->op; | ||
55 | + compat->flags = caop->flags; | ||
56 | + compat->len = caop->len; | ||
57 | + compat->auth_len = caop->auth_len; | ||
58 | + compat->tag_len = caop->tag_len; | ||
59 | + compat->iv_len = caop->iv_len; | ||
60 | + | ||
61 | + compat->auth_src = ptr_to_compat(caop->auth_src); | ||
62 | + compat->src = ptr_to_compat(caop->src); | ||
63 | + compat->dst = ptr_to_compat(caop->dst); | ||
64 | + compat->tag = ptr_to_compat(caop->tag); | ||
65 | + compat->iv = ptr_to_compat(caop->iv); | ||
66 | +} | ||
67 | + | ||
68 | +int compat_kcaop_from_user(struct kernel_crypt_auth_op *kcaop, | ||
69 | + struct fcrypt *fcr, void __user *arg) | ||
70 | +{ | ||
71 | + struct compat_crypt_auth_op compat_caop; | ||
72 | + | ||
73 | + if (unlikely(copy_from_user(&compat_caop, arg, sizeof(compat_caop)))) { | ||
74 | + dprintk(1, KERN_ERR, "Error in copying from userspace\n"); | ||
75 | + return -EFAULT; | ||
76 | + } | ||
77 | + | ||
78 | + compat_to_crypt_auth_op(&compat_caop, &kcaop->caop); | ||
79 | + | ||
80 | + return fill_kcaop_from_caop(kcaop, fcr); | ||
81 | +} | ||
82 | + | ||
83 | +int compat_kcaop_to_user(struct kernel_crypt_auth_op *kcaop, | ||
84 | + struct fcrypt *fcr, void __user *arg) | ||
85 | +{ | ||
86 | + int ret; | ||
87 | + struct compat_crypt_auth_op compat_caop; | ||
88 | + | ||
89 | + ret = fill_caop_from_kcaop(kcaop, fcr); | ||
90 | + if (unlikely(ret)) { | ||
91 | + dprintk(1, KERN_ERR, "fill_caop_from_kcaop\n"); | ||
92 | + return ret; | ||
93 | + } | ||
94 | + | ||
95 | + crypt_auth_op_to_compat(&kcaop->caop, &compat_caop); | ||
96 | + | ||
97 | + if (unlikely(copy_to_user(arg, &compat_caop, sizeof(compat_caop)))) { | ||
98 | + dprintk(1, KERN_ERR, "Error in copying to userspace\n"); | ||
99 | + return -EFAULT; | ||
100 | + } | ||
101 | + return 0; | ||
102 | +} | ||
103 | + | ||
104 | +#endif /* CONFIG_COMPAT */ | ||
105 | |||
106 | int kcaop_from_user(struct kernel_crypt_auth_op *kcaop, | ||
107 | struct fcrypt *fcr, void __user *arg) | ||
108 | diff --git a/cryptodev_int.h b/cryptodev_int.h | ||
109 | index d7660fa..8e687e7 100644 | ||
110 | --- a/cryptodev_int.h | ||
111 | +++ b/cryptodev_int.h | ||
112 | @@ -73,11 +73,42 @@ struct compat_crypt_op { | ||
113 | compat_uptr_t iv;/* initialization vector for encryption operations */ | ||
114 | }; | ||
115 | |||
116 | + /* input of CIOCAUTHCRYPT */ | ||
117 | +struct compat_crypt_auth_op { | ||
118 | + uint32_t ses; /* session identifier */ | ||
119 | + uint16_t op; /* COP_ENCRYPT or COP_DECRYPT */ | ||
120 | + uint16_t flags; /* see COP_FLAG_AEAD_* */ | ||
121 | + uint32_t len; /* length of source data */ | ||
122 | + uint32_t auth_len; /* length of auth data */ | ||
123 | + compat_uptr_t auth_src; /* authenticated-only data */ | ||
124 | + | ||
125 | + /* The current implementation is more efficient if data are | ||
126 | + * encrypted in-place (src==dst). */ | ||
127 | + compat_uptr_t src; /* data to be encrypted and | ||
128 | + authenticated */ | ||
129 | + compat_uptr_t dst; /* pointer to output data. Must have | ||
130 | + * space for tag. For TLS this should be | ||
131 | + * at least len + tag_size + block_size | ||
132 | + * for padding */ | ||
133 | + | ||
134 | + compat_uptr_t tag; /* where the tag will be copied to. TLS | ||
135 | + * mode doesn't use that as tag is | ||
136 | + * copied to dst. | ||
137 | + * SRTP mode copies tag there. */ | ||
138 | + uint32_t tag_len; /* the length of the tag. Use zero for | ||
139 | + * digest size or max tag. */ | ||
140 | + | ||
141 | + /* initialization vector for encryption operations */ | ||
142 | + compat_uptr_t iv; | ||
143 | + uint32_t iv_len; | ||
144 | +}; | ||
145 | + | ||
146 | /* compat ioctls, defined for the above structs */ | ||
147 | #define COMPAT_CIOCGSESSION _IOWR('c', 102, struct compat_session_op) | ||
148 | #define COMPAT_CIOCCRYPT _IOWR('c', 104, struct compat_crypt_op) | ||
149 | #define COMPAT_CIOCASYNCCRYPT _IOW('c', 107, struct compat_crypt_op) | ||
150 | #define COMPAT_CIOCASYNCFETCH _IOR('c', 108, struct compat_crypt_op) | ||
151 | +#define COMPAT_CIOCAUTHCRYPT _IOWR('c', 109, struct compat_crypt_auth_op) | ||
152 | |||
153 | #endif /* CONFIG_COMPAT */ | ||
154 | |||
155 | @@ -108,6 +139,15 @@ struct kernel_crypt_auth_op { | ||
156 | |||
157 | /* auth */ | ||
158 | |||
159 | +#ifdef CONFIG_COMPAT | ||
160 | +int compat_kcaop_from_user(struct kernel_crypt_auth_op *kcaop, | ||
161 | + struct fcrypt *fcr, void __user *arg); | ||
162 | + | ||
163 | +int compat_kcaop_to_user(struct kernel_crypt_auth_op *kcaop, | ||
164 | + struct fcrypt *fcr, void __user *arg); | ||
165 | +#endif /* CONFIG_COMPAT */ | ||
166 | + | ||
167 | + | ||
168 | int kcaop_from_user(struct kernel_crypt_auth_op *kcop, | ||
169 | struct fcrypt *fcr, void __user *arg); | ||
170 | int kcaop_to_user(struct kernel_crypt_auth_op *kcaop, | ||
171 | diff --git a/ioctl.c b/ioctl.c | ||
172 | index a3f8379..5a44807 100644 | ||
173 | --- a/ioctl.c | ||
174 | +++ b/ioctl.c | ||
175 | @@ -998,6 +998,7 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) | ||
176 | struct session_op sop; | ||
177 | struct compat_session_op compat_sop; | ||
178 | struct kernel_crypt_op kcop; | ||
179 | + struct kernel_crypt_auth_op kcaop; | ||
180 | int ret; | ||
181 | |||
182 | if (unlikely(!pcr)) | ||
183 | @@ -1040,6 +1041,21 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) | ||
184 | return ret; | ||
185 | |||
186 | return compat_kcop_to_user(&kcop, fcr, arg); | ||
187 | + | ||
188 | + case COMPAT_CIOCAUTHCRYPT: | ||
189 | + if (unlikely(ret = compat_kcaop_from_user(&kcaop, fcr, arg))) { | ||
190 | + dprintk(1, KERN_WARNING, "Error copying from user\n"); | ||
191 | + return ret; | ||
192 | + } | ||
193 | + | ||
194 | + ret = crypto_auth_run(fcr, &kcaop); | ||
195 | + if (unlikely(ret)) { | ||
196 | + dprintk(1, KERN_WARNING, "Error in crypto_auth_run\n"); | ||
197 | + return ret; | ||
198 | + } | ||
199 | + | ||
200 | + return compat_kcaop_to_user(&kcaop, fcr, arg); | ||
201 | + | ||
202 | #ifdef ENABLE_ASYNC | ||
203 | case COMPAT_CIOCASYNCCRYPT: | ||
204 | if (unlikely(ret = compat_kcop_from_user(&kcop, fcr, arg))) | ||
205 | -- | ||
206 | 2.7.0 | ||
207 | |||
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 @@ | |||
1 | From c2bf0e42b1d9fda60cde4a3a682784d349ef1c0b Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Thu, 4 May 2017 15:06:21 +0300 | ||
4 | Subject: [PATCH 2/9] refactoring: relocate code to simplify later patches | ||
5 | |||
6 | This code move will simplify the conversion to new AEAD interface in | ||
7 | next patches | ||
8 | |||
9 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
10 | --- | ||
11 | authenc.c | 17 +++++++++-------- | ||
12 | 1 file changed, 9 insertions(+), 8 deletions(-) | ||
13 | |||
14 | diff --git a/authenc.c b/authenc.c | ||
15 | index 28eb0f9..95727b4 100644 | ||
16 | --- a/authenc.c | ||
17 | +++ b/authenc.c | ||
18 | @@ -711,11 +711,18 @@ static int crypto_auth_zc_aead(struct csession *ses_ptr, struct kernel_crypt_aut | ||
19 | return -ENOMEM; | ||
20 | } | ||
21 | |||
22 | + ret = get_userbuf(ses_ptr, caop->src, caop->len, caop->dst, kcaop->dst_len, | ||
23 | + kcaop->task, kcaop->mm, &src_sg, &dst_sg); | ||
24 | + if (unlikely(ret)) { | ||
25 | + derr(1, "get_userbuf(): Error getting user pages."); | ||
26 | + goto free_auth_buf; | ||
27 | + } | ||
28 | + | ||
29 | if (caop->auth_src && caop->auth_len > 0) { | ||
30 | if (unlikely(copy_from_user(auth_buf, caop->auth_src, caop->auth_len))) { | ||
31 | derr(1, "unable to copy auth data from userspace."); | ||
32 | ret = -EFAULT; | ||
33 | - goto free_auth_buf; | ||
34 | + goto free_pages; | ||
35 | } | ||
36 | |||
37 | sg_init_one(&tmp, auth_buf, caop->auth_len); | ||
38 | @@ -724,16 +731,10 @@ static int crypto_auth_zc_aead(struct csession *ses_ptr, struct kernel_crypt_aut | ||
39 | auth_sg = NULL; | ||
40 | } | ||
41 | |||
42 | - ret = get_userbuf(ses_ptr, caop->src, caop->len, caop->dst, kcaop->dst_len, | ||
43 | - kcaop->task, kcaop->mm, &src_sg, &dst_sg); | ||
44 | - if (unlikely(ret)) { | ||
45 | - derr(1, "get_userbuf(): Error getting user pages."); | ||
46 | - goto free_auth_buf; | ||
47 | - } | ||
48 | - | ||
49 | ret = auth_n_crypt(ses_ptr, kcaop, auth_sg, caop->auth_len, | ||
50 | src_sg, dst_sg, caop->len); | ||
51 | |||
52 | +free_pages: | ||
53 | release_user_pages(ses_ptr); | ||
54 | |||
55 | free_auth_buf: | ||
56 | -- | ||
57 | 2.7.4 | ||
58 | |||
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 @@ | |||
1 | From 2bda43095b511e0052b3bc27b216ff9909cc03d2 Mon Sep 17 00:00:00 2001 | ||
2 | From: Yashpal Dutta <yashpal.dutta@freescale.com> | ||
3 | Date: Fri, 7 Mar 2014 06:16:09 +0545 | ||
4 | Subject: [PATCH 03/38] PKC support added in cryptodev module | ||
5 | |||
6 | Upstream-status: Pending | ||
7 | |||
8 | Signed-off-by: Yashpal Dutta <yashpal.dutta@freescale.com> | ||
9 | --- | ||
10 | cryptlib.c | 66 +++++++++- | ||
11 | cryptlib.h | 28 ++++ | ||
12 | crypto/cryptodev.h | 15 ++- | ||
13 | cryptodev_int.h | 20 ++- | ||
14 | ioctl.c | 196 +++++++++++++++++++++++++-- | ||
15 | main.c | 378 +++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
16 | 6 files changed, 685 insertions(+), 18 deletions(-) | ||
17 | |||
18 | diff --git a/cryptlib.c b/cryptlib.c | ||
19 | index 44ce763..6900028 100644 | ||
20 | --- a/cryptlib.c | ||
21 | +++ b/cryptlib.c | ||
22 | @@ -5,6 +5,8 @@ | ||
23 | * Portions Copyright (c) 2010 Michael Weiser | ||
24 | * Portions Copyright (c) 2010 Phil Sutter | ||
25 | * | ||
26 | + * Copyright 2012 Freescale Semiconductor, Inc. | ||
27 | + * | ||
28 | * This file is part of linux cryptodev. | ||
29 | * | ||
30 | * This program is free software; you can redistribute it and/or | ||
31 | @@ -39,11 +41,6 @@ | ||
32 | #include "cryptodev_int.h" | ||
33 | |||
34 | |||
35 | -struct cryptodev_result { | ||
36 | - struct completion completion; | ||
37 | - int err; | ||
38 | -}; | ||
39 | - | ||
40 | static void cryptodev_complete(struct crypto_async_request *req, int err) | ||
41 | { | ||
42 | struct cryptodev_result *res = req->data; | ||
43 | @@ -259,7 +256,6 @@ static inline int waitfor(struct cryptodev_result *cr, ssize_t ret) | ||
44 | case 0: | ||
45 | break; | ||
46 | case -EINPROGRESS: | ||
47 | - case -EBUSY: | ||
48 | wait_for_completion(&cr->completion); | ||
49 | /* At this point we known for sure the request has finished, | ||
50 | * because wait_for_completion above was not interruptible. | ||
51 | @@ -439,3 +435,61 @@ int cryptodev_hash_final(struct hash_data *hdata, void *output) | ||
52 | return waitfor(hdata->async.result, ret); | ||
53 | } | ||
54 | |||
55 | +int cryptodev_pkc_offload(struct cryptodev_pkc *pkc) | ||
56 | +{ | ||
57 | + int ret = 0; | ||
58 | + struct pkc_request *pkc_req = &pkc->req, *pkc_requested; | ||
59 | + | ||
60 | + switch (pkc_req->type) { | ||
61 | + case RSA_PUB: | ||
62 | + case RSA_PRIV_FORM1: | ||
63 | + case RSA_PRIV_FORM2: | ||
64 | + case RSA_PRIV_FORM3: | ||
65 | + pkc->s = crypto_alloc_pkc("pkc(rsa)", | ||
66 | + CRYPTO_ALG_TYPE_PKC_RSA, 0); | ||
67 | + break; | ||
68 | + case DSA_SIGN: | ||
69 | + case DSA_VERIFY: | ||
70 | + case ECDSA_SIGN: | ||
71 | + case ECDSA_VERIFY: | ||
72 | + pkc->s = crypto_alloc_pkc("pkc(dsa)", | ||
73 | + CRYPTO_ALG_TYPE_PKC_DSA, 0); | ||
74 | + break; | ||
75 | + case DH_COMPUTE_KEY: | ||
76 | + case ECDH_COMPUTE_KEY: | ||
77 | + pkc->s = crypto_alloc_pkc("pkc(dh)", | ||
78 | + CRYPTO_ALG_TYPE_PKC_DH, 0); | ||
79 | + break; | ||
80 | + default: | ||
81 | + return -EINVAL; | ||
82 | + } | ||
83 | + | ||
84 | + if (IS_ERR_OR_NULL(pkc->s)) | ||
85 | + return -EINVAL; | ||
86 | + | ||
87 | + init_completion(&pkc->result.completion); | ||
88 | + pkc_requested = pkc_request_alloc(pkc->s, GFP_KERNEL); | ||
89 | + | ||
90 | + if (unlikely(IS_ERR_OR_NULL(pkc_requested))) { | ||
91 | + ret = -ENOMEM; | ||
92 | + goto error; | ||
93 | + } | ||
94 | + pkc_requested->type = pkc_req->type; | ||
95 | + pkc_requested->curve_type = pkc_req->curve_type; | ||
96 | + memcpy(&pkc_requested->req_u, &pkc_req->req_u, sizeof(pkc_req->req_u)); | ||
97 | + pkc_request_set_callback(pkc_requested, CRYPTO_TFM_REQ_MAY_BACKLOG, | ||
98 | + cryptodev_complete_asym, pkc); | ||
99 | + ret = crypto_pkc_op(pkc_requested); | ||
100 | + if (ret != -EINPROGRESS && ret != 0) | ||
101 | + goto error2; | ||
102 | + | ||
103 | + if (pkc->type == SYNCHRONOUS) | ||
104 | + ret = waitfor(&pkc->result, ret); | ||
105 | + | ||
106 | + return ret; | ||
107 | +error2: | ||
108 | + kfree(pkc_requested); | ||
109 | +error: | ||
110 | + crypto_free_pkc(pkc->s); | ||
111 | + return ret; | ||
112 | +} | ||
113 | diff --git a/cryptlib.h b/cryptlib.h | ||
114 | index a0a8a63..56d325a 100644 | ||
115 | --- a/cryptlib.h | ||
116 | +++ b/cryptlib.h | ||
117 | @@ -1,3 +1,6 @@ | ||
118 | +/* | ||
119 | + * Copyright 2012 Freescale Semiconductor, Inc. | ||
120 | + */ | ||
121 | #ifndef CRYPTLIB_H | ||
122 | # define CRYPTLIB_H | ||
123 | |||
124 | @@ -89,5 +92,30 @@ void cryptodev_hash_deinit(struct hash_data *hdata); | ||
125 | int cryptodev_hash_init(struct hash_data *hdata, const char *alg_name, | ||
126 | int hmac_mode, void *mackey, size_t mackeylen); | ||
127 | |||
128 | +/* Operation Type */ | ||
129 | +enum offload_type { | ||
130 | + SYNCHRONOUS, | ||
131 | + ASYNCHRONOUS | ||
132 | +}; | ||
133 | + | ||
134 | +struct cryptodev_result { | ||
135 | + struct completion completion; | ||
136 | + int err; | ||
137 | +}; | ||
138 | + | ||
139 | +struct cryptodev_pkc { | ||
140 | + struct list_head list; /* To maintain the Jobs in completed | ||
141 | + cryptodev lists */ | ||
142 | + struct kernel_crypt_kop kop; | ||
143 | + struct crypto_pkc *s; /* Transform pointer from CryptoAPI */ | ||
144 | + struct cryptodev_result result; /* Result to be updated by | ||
145 | + completion handler */ | ||
146 | + struct pkc_request req; /* PKC request structure allocated | ||
147 | + from CryptoAPI */ | ||
148 | + enum offload_type type; /* Synchronous Vs Asynchronous request */ | ||
149 | + void *cookie; /*Additional opaque cookie to be used in future */ | ||
150 | + struct crypt_priv *priv; | ||
151 | +}; | ||
152 | |||
153 | +int cryptodev_pkc_offload(struct cryptodev_pkc *); | ||
154 | #endif | ||
155 | diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h | ||
156 | index c0e8cd4..96675fe 100644 | ||
157 | --- a/crypto/cryptodev.h | ||
158 | +++ b/crypto/cryptodev.h | ||
159 | @@ -1,6 +1,10 @@ | ||
160 | -/* This is a source compatible implementation with the original API of | ||
161 | +/* | ||
162 | + * Copyright 2012 Freescale Semiconductor, Inc. | ||
163 | + * | ||
164 | + * This is a source compatible implementation with the original API of | ||
165 | * cryptodev by Angelos D. Keromytis, found at openbsd cryptodev.h. | ||
166 | - * Placed under public domain */ | ||
167 | + * Placed under public domain | ||
168 | + */ | ||
169 | |||
170 | #ifndef L_CRYPTODEV_H | ||
171 | #define L_CRYPTODEV_H | ||
172 | @@ -245,6 +249,9 @@ struct crypt_kop { | ||
173 | __u16 crk_oparams; | ||
174 | __u32 crk_pad1; | ||
175 | struct crparam crk_param[CRK_MAXPARAM]; | ||
176 | + enum curve_t curve_type; /* 0 == Discrete Log, | ||
177 | + 1 = EC_PRIME, 2 = EC_BINARY */ | ||
178 | + void *cookie; | ||
179 | }; | ||
180 | |||
181 | enum cryptodev_crk_op_t { | ||
182 | @@ -289,5 +296,7 @@ enum cryptodev_crk_op_t { | ||
183 | */ | ||
184 | #define CIOCASYNCCRYPT _IOW('c', 110, struct crypt_op) | ||
185 | #define CIOCASYNCFETCH _IOR('c', 111, struct crypt_op) | ||
186 | - | ||
187 | +/* additional ioctls for asynchronous operation for asymmetric ciphers*/ | ||
188 | +#define CIOCASYMASYNCRYPT _IOW('c', 112, struct crypt_kop) | ||
189 | +#define CIOCASYMASYNFETCH _IOR('c', 113, struct crypt_kop) | ||
190 | #endif /* L_CRYPTODEV_H */ | ||
191 | diff --git a/cryptodev_int.h b/cryptodev_int.h | ||
192 | index 8e687e7..fdbcc61 100644 | ||
193 | --- a/cryptodev_int.h | ||
194 | +++ b/cryptodev_int.h | ||
195 | @@ -1,4 +1,6 @@ | ||
196 | -/* cipher stuff */ | ||
197 | +/* cipher stuff | ||
198 | + * Copyright 2012 Freescale Semiconductor, Inc. | ||
199 | + */ | ||
200 | #ifndef CRYPTODEV_INT_H | ||
201 | # define CRYPTODEV_INT_H | ||
202 | |||
203 | @@ -112,6 +114,14 @@ struct compat_crypt_auth_op { | ||
204 | |||
205 | #endif /* CONFIG_COMPAT */ | ||
206 | |||
207 | +/* kernel-internal extension to struct crypt_kop */ | ||
208 | +struct kernel_crypt_kop { | ||
209 | + struct crypt_kop kop; | ||
210 | + | ||
211 | + struct task_struct *task; | ||
212 | + struct mm_struct *mm; | ||
213 | +}; | ||
214 | + | ||
215 | /* kernel-internal extension to struct crypt_op */ | ||
216 | struct kernel_crypt_op { | ||
217 | struct crypt_op cop; | ||
218 | @@ -157,6 +167,14 @@ int crypto_run(struct fcrypt *fcr, struct kernel_crypt_op *kcop); | ||
219 | |||
220 | #include <cryptlib.h> | ||
221 | |||
222 | +/* Cryptodev Key operation handler */ | ||
223 | +int crypto_bn_modexp(struct cryptodev_pkc *); | ||
224 | +int crypto_modexp_crt(struct cryptodev_pkc *); | ||
225 | +int crypto_kop_dsasign(struct cryptodev_pkc *); | ||
226 | +int crypto_kop_dsaverify(struct cryptodev_pkc *); | ||
227 | +int crypto_run_asym(struct cryptodev_pkc *); | ||
228 | +void cryptodev_complete_asym(struct crypto_async_request *, int); | ||
229 | + | ||
230 | /* other internal structs */ | ||
231 | struct csession { | ||
232 | struct list_head entry; | ||
233 | diff --git a/ioctl.c b/ioctl.c | ||
234 | index 5a44807..69980e3 100644 | ||
235 | --- a/ioctl.c | ||
236 | +++ b/ioctl.c | ||
237 | @@ -4,6 +4,7 @@ | ||
238 | * Copyright (c) 2004 Michal Ludvig <mludvig@logix.net.nz>, SuSE Labs | ||
239 | * Copyright (c) 2009,2010,2011 Nikos Mavrogiannopoulos <nmav@gnutls.org> | ||
240 | * Copyright (c) 2010 Phil Sutter | ||
241 | + * Copyright 2012 Freescale Semiconductor, Inc. | ||
242 | * | ||
243 | * This file is part of linux cryptodev. | ||
244 | * | ||
245 | @@ -89,8 +90,37 @@ struct crypt_priv { | ||
246 | int itemcount; | ||
247 | struct work_struct cryptask; | ||
248 | wait_queue_head_t user_waiter; | ||
249 | + /* List of pending cryptodev_pkc asym requests */ | ||
250 | + struct list_head asym_completed_list; | ||
251 | + /* For addition/removal of entry in pending list of asymmetric request*/ | ||
252 | + spinlock_t completion_lock; | ||
253 | }; | ||
254 | |||
255 | +/* Asymmetric request Completion handler */ | ||
256 | +void cryptodev_complete_asym(struct crypto_async_request *req, int err) | ||
257 | +{ | ||
258 | + struct cryptodev_pkc *pkc = req->data; | ||
259 | + struct cryptodev_result *res = &pkc->result; | ||
260 | + | ||
261 | + crypto_free_pkc(pkc->s); | ||
262 | + res->err = err; | ||
263 | + if (pkc->type == SYNCHRONOUS) { | ||
264 | + if (err == -EINPROGRESS) | ||
265 | + return; | ||
266 | + complete(&res->completion); | ||
267 | + } else { | ||
268 | + struct crypt_priv *pcr = pkc->priv; | ||
269 | + unsigned long flags; | ||
270 | + spin_lock_irqsave(&pcr->completion_lock, flags); | ||
271 | + list_add_tail(&pkc->list, &pcr->asym_completed_list); | ||
272 | + spin_unlock_irqrestore(&pcr->completion_lock, flags); | ||
273 | + /* wake for POLLIN */ | ||
274 | + wake_up_interruptible(&pcr->user_waiter); | ||
275 | + } | ||
276 | + | ||
277 | + kfree(req); | ||
278 | +} | ||
279 | + | ||
280 | #define FILL_SG(sg, ptr, len) \ | ||
281 | do { \ | ||
282 | (sg)->page = virt_to_page(ptr); \ | ||
283 | @@ -472,7 +502,8 @@ cryptodev_open(struct inode *inode, struct file *filp) | ||
284 | INIT_LIST_HEAD(&pcr->free.list); | ||
285 | INIT_LIST_HEAD(&pcr->todo.list); | ||
286 | INIT_LIST_HEAD(&pcr->done.list); | ||
287 | - | ||
288 | + INIT_LIST_HEAD(&pcr->asym_completed_list); | ||
289 | + spin_lock_init(&pcr->completion_lock); | ||
290 | INIT_WORK(&pcr->cryptask, cryptask_routine); | ||
291 | |||
292 | init_waitqueue_head(&pcr->user_waiter); | ||
293 | @@ -639,6 +670,79 @@ static int crypto_async_fetch(struct crypt_priv *pcr, | ||
294 | } | ||
295 | #endif | ||
296 | |||
297 | +/* get the first asym cipher completed job from the "done" queue | ||
298 | + * | ||
299 | + * returns: | ||
300 | + * -EBUSY if no completed jobs are ready (yet) | ||
301 | + * the return value otherwise */ | ||
302 | +static int crypto_async_fetch_asym(struct cryptodev_pkc *pkc) | ||
303 | +{ | ||
304 | + int ret = 0; | ||
305 | + struct kernel_crypt_kop *kop = &pkc->kop; | ||
306 | + struct crypt_kop *ckop = &kop->kop; | ||
307 | + struct pkc_request *pkc_req = &pkc->req; | ||
308 | + | ||
309 | + switch (ckop->crk_op) { | ||
310 | + case CRK_MOD_EXP: | ||
311 | + { | ||
312 | + struct rsa_pub_req_s *rsa_req = &pkc_req->req_u.rsa_pub_req; | ||
313 | + copy_to_user(ckop->crk_param[3].crp_p, rsa_req->g, | ||
314 | + rsa_req->g_len); | ||
315 | + } | ||
316 | + break; | ||
317 | + case CRK_MOD_EXP_CRT: | ||
318 | + { | ||
319 | + struct rsa_priv_frm3_req_s *rsa_req = | ||
320 | + &pkc_req->req_u.rsa_priv_f3; | ||
321 | + copy_to_user(ckop->crk_param[6].crp_p, | ||
322 | + rsa_req->f, rsa_req->f_len); | ||
323 | + } | ||
324 | + break; | ||
325 | + case CRK_DSA_SIGN: | ||
326 | + { | ||
327 | + struct dsa_sign_req_s *dsa_req = &pkc_req->req_u.dsa_sign; | ||
328 | + | ||
329 | + if (pkc_req->type == ECDSA_SIGN) { | ||
330 | + copy_to_user(ckop->crk_param[6].crp_p, | ||
331 | + dsa_req->c, dsa_req->d_len); | ||
332 | + copy_to_user(ckop->crk_param[7].crp_p, | ||
333 | + dsa_req->d, dsa_req->d_len); | ||
334 | + } else { | ||
335 | + copy_to_user(ckop->crk_param[5].crp_p, | ||
336 | + dsa_req->c, dsa_req->d_len); | ||
337 | + copy_to_user(ckop->crk_param[6].crp_p, | ||
338 | + dsa_req->d, dsa_req->d_len); | ||
339 | + } | ||
340 | + } | ||
341 | + break; | ||
342 | + case CRK_DSA_VERIFY: | ||
343 | + break; | ||
344 | + case CRK_DH_COMPUTE_KEY: | ||
345 | + { | ||
346 | + struct dh_key_req_s *dh_req = &pkc_req->req_u.dh_req; | ||
347 | + if (pkc_req->type == ECDH_COMPUTE_KEY) | ||
348 | + copy_to_user(ckop->crk_param[4].crp_p, | ||
349 | + dh_req->z, dh_req->z_len); | ||
350 | + else | ||
351 | + copy_to_user(ckop->crk_param[3].crp_p, | ||
352 | + dh_req->z, dh_req->z_len); | ||
353 | + } | ||
354 | + break; | ||
355 | + default: | ||
356 | + ret = -EINVAL; | ||
357 | + } | ||
358 | + kfree(pkc->cookie); | ||
359 | + return ret; | ||
360 | +} | ||
361 | + | ||
362 | +/* this function has to be called from process context */ | ||
363 | +static int fill_kop_from_cop(struct kernel_crypt_kop *kop) | ||
364 | +{ | ||
365 | + kop->task = current; | ||
366 | + kop->mm = current->mm; | ||
367 | + return 0; | ||
368 | +} | ||
369 | + | ||
370 | /* this function has to be called from process context */ | ||
371 | static int fill_kcop_from_cop(struct kernel_crypt_op *kcop, struct fcrypt *fcr) | ||
372 | { | ||
373 | @@ -662,11 +766,8 @@ static int fill_kcop_from_cop(struct kernel_crypt_op *kcop, struct fcrypt *fcr) | ||
374 | |||
375 | if (cop->iv) { | ||
376 | rc = copy_from_user(kcop->iv, cop->iv, kcop->ivlen); | ||
377 | - if (unlikely(rc)) { | ||
378 | - derr(1, "error copying IV (%d bytes), copy_from_user returned %d for address %p", | ||
379 | - kcop->ivlen, rc, cop->iv); | ||
380 | + if (unlikely(rc)) | ||
381 | return -EFAULT; | ||
382 | - } | ||
383 | } | ||
384 | |||
385 | return 0; | ||
386 | @@ -692,6 +793,25 @@ static int fill_cop_from_kcop(struct kernel_crypt_op *kcop, struct fcrypt *fcr) | ||
387 | return 0; | ||
388 | } | ||
389 | |||
390 | +static int kop_from_user(struct kernel_crypt_kop *kop, | ||
391 | + void __user *arg) | ||
392 | +{ | ||
393 | + if (unlikely(copy_from_user(&kop->kop, arg, sizeof(kop->kop)))) | ||
394 | + return -EFAULT; | ||
395 | + | ||
396 | + return fill_kop_from_cop(kop); | ||
397 | +} | ||
398 | + | ||
399 | +static int kop_to_user(struct kernel_crypt_kop *kop, | ||
400 | + void __user *arg) | ||
401 | +{ | ||
402 | + if (unlikely(copy_to_user(arg, &kop->kop, sizeof(kop->kop)))) { | ||
403 | + dprintk(1, KERN_ERR, "Cannot copy to userspace\n"); | ||
404 | + return -EFAULT; | ||
405 | + } | ||
406 | + return 0; | ||
407 | +} | ||
408 | + | ||
409 | static int kcop_from_user(struct kernel_crypt_op *kcop, | ||
410 | struct fcrypt *fcr, void __user *arg) | ||
411 | { | ||
412 | @@ -821,7 +941,8 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | ||
413 | |||
414 | switch (cmd) { | ||
415 | case CIOCASYMFEAT: | ||
416 | - return put_user(0, p); | ||
417 | + return put_user(CRF_MOD_EXP_CRT | CRF_MOD_EXP | | ||
418 | + CRF_DSA_SIGN | CRF_DSA_VERIFY | CRF_DH_COMPUTE_KEY, p); | ||
419 | case CRIOGET: | ||
420 | fd = clonefd(filp); | ||
421 | ret = put_user(fd, p); | ||
422 | @@ -857,6 +978,24 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | ||
423 | if (unlikely(ret)) | ||
424 | return ret; | ||
425 | return copy_to_user(arg, &siop, sizeof(siop)); | ||
426 | + case CIOCKEY: | ||
427 | + { | ||
428 | + struct cryptodev_pkc *pkc = | ||
429 | + kzalloc(sizeof(struct cryptodev_pkc), GFP_KERNEL); | ||
430 | + | ||
431 | + if (!pkc) | ||
432 | + return -ENOMEM; | ||
433 | + | ||
434 | + ret = kop_from_user(&pkc->kop, arg); | ||
435 | + if (unlikely(ret)) { | ||
436 | + kfree(pkc); | ||
437 | + return ret; | ||
438 | + } | ||
439 | + pkc->type = SYNCHRONOUS; | ||
440 | + ret = crypto_run_asym(pkc); | ||
441 | + kfree(pkc); | ||
442 | + } | ||
443 | + return ret; | ||
444 | case CIOCCRYPT: | ||
445 | if (unlikely(ret = kcop_from_user(&kcop, fcr, arg))) { | ||
446 | dwarning(1, "Error copying from user"); | ||
447 | @@ -895,6 +1034,45 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | ||
448 | |||
449 | return kcop_to_user(&kcop, fcr, arg); | ||
450 | #endif | ||
451 | + case CIOCASYMASYNCRYPT: | ||
452 | + { | ||
453 | + struct cryptodev_pkc *pkc = | ||
454 | + kzalloc(sizeof(struct cryptodev_pkc), GFP_KERNEL); | ||
455 | + ret = kop_from_user(&pkc->kop, arg); | ||
456 | + | ||
457 | + if (unlikely(ret)) | ||
458 | + return -EINVAL; | ||
459 | + | ||
460 | + /* Store associated FD priv data with asymmetric request */ | ||
461 | + pkc->priv = pcr; | ||
462 | + pkc->type = ASYNCHRONOUS; | ||
463 | + ret = crypto_run_asym(pkc); | ||
464 | + if (ret == -EINPROGRESS) | ||
465 | + ret = 0; | ||
466 | + } | ||
467 | + return ret; | ||
468 | + case CIOCASYMASYNFETCH: | ||
469 | + { | ||
470 | + struct cryptodev_pkc *pkc; | ||
471 | + unsigned long flags; | ||
472 | + | ||
473 | + spin_lock_irqsave(&pcr->completion_lock, flags); | ||
474 | + if (list_empty(&pcr->asym_completed_list)) { | ||
475 | + spin_unlock_irqrestore(&pcr->completion_lock, flags); | ||
476 | + return -ENOMEM; | ||
477 | + } | ||
478 | + pkc = list_first_entry(&pcr->asym_completed_list, | ||
479 | + struct cryptodev_pkc, list); | ||
480 | + list_del(&pkc->list); | ||
481 | + spin_unlock_irqrestore(&pcr->completion_lock, flags); | ||
482 | + ret = crypto_async_fetch_asym(pkc); | ||
483 | + | ||
484 | + /* Reflect the updated request to user-space */ | ||
485 | + if (!ret) | ||
486 | + kop_to_user(&pkc->kop, arg); | ||
487 | + kfree(pkc); | ||
488 | + } | ||
489 | + return ret; | ||
490 | default: | ||
491 | return -EINVAL; | ||
492 | } | ||
493 | @@ -1083,9 +1261,11 @@ static unsigned int cryptodev_poll(struct file *file, poll_table *wait) | ||
494 | |||
495 | poll_wait(file, &pcr->user_waiter, wait); | ||
496 | |||
497 | - if (!list_empty_careful(&pcr->done.list)) | ||
498 | + if (!list_empty_careful(&pcr->done.list) || | ||
499 | + !list_empty_careful(&pcr->asym_completed_list)) | ||
500 | ret |= POLLIN | POLLRDNORM; | ||
501 | - if (!list_empty_careful(&pcr->free.list) || pcr->itemcount < MAX_COP_RINGSIZE) | ||
502 | + if (!list_empty_careful(&pcr->free.list) || | ||
503 | + pcr->itemcount < MAX_COP_RINGSIZE) | ||
504 | ret |= POLLOUT | POLLWRNORM; | ||
505 | |||
506 | return ret; | ||
507 | diff --git a/main.c b/main.c | ||
508 | index 57e5c38..0b7951e 100644 | ||
509 | --- a/main.c | ||
510 | +++ b/main.c | ||
511 | @@ -181,6 +181,384 @@ __crypto_run_zc(struct csession *ses_ptr, struct kernel_crypt_op *kcop) | ||
512 | return ret; | ||
513 | } | ||
514 | |||
515 | +int crypto_kop_dsasign(struct cryptodev_pkc *pkc) | ||
516 | +{ | ||
517 | + struct kernel_crypt_kop *kop = &pkc->kop; | ||
518 | + struct crypt_kop *cop = &kop->kop; | ||
519 | + struct pkc_request *pkc_req = &pkc->req; | ||
520 | + struct dsa_sign_req_s *dsa_req = &pkc_req->req_u.dsa_sign; | ||
521 | + int rc, buf_size; | ||
522 | + uint8_t *buf; | ||
523 | + | ||
524 | + if (!cop->crk_param[0].crp_nbits || !cop->crk_param[1].crp_nbits || | ||
525 | + !cop->crk_param[2].crp_nbits || !cop->crk_param[3].crp_nbits || | ||
526 | + !cop->crk_param[4].crp_nbits || !cop->crk_param[5].crp_nbits || | ||
527 | + !cop->crk_param[6].crp_nbits || (cop->crk_iparams == 6 && | ||
528 | + !cop->crk_param[7].crp_nbits)) | ||
529 | + return -EINVAL; | ||
530 | + | ||
531 | + dsa_req->m_len = (cop->crk_param[0].crp_nbits + 7)/8; | ||
532 | + dsa_req->q_len = (cop->crk_param[1].crp_nbits + 7)/8; | ||
533 | + dsa_req->r_len = (cop->crk_param[2].crp_nbits + 7)/8; | ||
534 | + dsa_req->g_len = (cop->crk_param[3].crp_nbits + 7)/8; | ||
535 | + dsa_req->priv_key_len = (cop->crk_param[4].crp_nbits + 7)/8; | ||
536 | + dsa_req->d_len = (cop->crk_param[6].crp_nbits + 7)/8; | ||
537 | + buf_size = dsa_req->m_len + dsa_req->q_len + dsa_req->r_len + | ||
538 | + dsa_req->g_len + dsa_req->priv_key_len + dsa_req->d_len + | ||
539 | + dsa_req->d_len; | ||
540 | + if (cop->crk_iparams == 6) { | ||
541 | + dsa_req->ab_len = (cop->crk_param[5].crp_nbits + 7)/8; | ||
542 | + buf_size += dsa_req->ab_len; | ||
543 | + pkc_req->type = ECDSA_SIGN; | ||
544 | + pkc_req->curve_type = cop->curve_type; | ||
545 | + } else { | ||
546 | + pkc_req->type = DSA_SIGN; | ||
547 | + } | ||
548 | + | ||
549 | + buf = kzalloc(buf_size, GFP_DMA); | ||
550 | + | ||
551 | + dsa_req->q = buf; | ||
552 | + dsa_req->r = dsa_req->q + dsa_req->q_len; | ||
553 | + dsa_req->g = dsa_req->r + dsa_req->r_len; | ||
554 | + dsa_req->priv_key = dsa_req->g + dsa_req->g_len; | ||
555 | + dsa_req->m = dsa_req->priv_key + dsa_req->priv_key_len; | ||
556 | + dsa_req->c = dsa_req->m + dsa_req->m_len; | ||
557 | + dsa_req->d = dsa_req->c + dsa_req->d_len; | ||
558 | + copy_from_user(dsa_req->m, cop->crk_param[0].crp_p, dsa_req->m_len); | ||
559 | + copy_from_user(dsa_req->q, cop->crk_param[1].crp_p, dsa_req->q_len); | ||
560 | + copy_from_user(dsa_req->r, cop->crk_param[2].crp_p, dsa_req->r_len); | ||
561 | + copy_from_user(dsa_req->g, cop->crk_param[3].crp_p, dsa_req->g_len); | ||
562 | + copy_from_user(dsa_req->priv_key, cop->crk_param[4].crp_p, | ||
563 | + dsa_req->priv_key_len); | ||
564 | + if (cop->crk_iparams == 6) { | ||
565 | + dsa_req->ab = dsa_req->d + dsa_req->d_len; | ||
566 | + copy_from_user(dsa_req->ab, cop->crk_param[5].crp_p, | ||
567 | + dsa_req->ab_len); | ||
568 | + } | ||
569 | + rc = cryptodev_pkc_offload(pkc); | ||
570 | + if (pkc->type == SYNCHRONOUS) { | ||
571 | + if (rc) | ||
572 | + goto err; | ||
573 | + if (cop->crk_iparams == 6) { | ||
574 | + copy_to_user(cop->crk_param[6].crp_p, dsa_req->c, | ||
575 | + dsa_req->d_len); | ||
576 | + copy_to_user(cop->crk_param[7].crp_p, dsa_req->d, | ||
577 | + dsa_req->d_len); | ||
578 | + } else { | ||
579 | + copy_to_user(cop->crk_param[5].crp_p, dsa_req->c, | ||
580 | + dsa_req->d_len); | ||
581 | + copy_to_user(cop->crk_param[6].crp_p, dsa_req->d, | ||
582 | + dsa_req->d_len); | ||
583 | + } | ||
584 | + } else { | ||
585 | + if (rc != -EINPROGRESS && rc != 0) | ||
586 | + goto err; | ||
587 | + | ||
588 | + pkc->cookie = buf; | ||
589 | + return rc; | ||
590 | + } | ||
591 | +err: | ||
592 | + kfree(buf); | ||
593 | + return rc; | ||
594 | +} | ||
595 | + | ||
596 | +int crypto_kop_dsaverify(struct cryptodev_pkc *pkc) | ||
597 | +{ | ||
598 | + struct kernel_crypt_kop *kop = &pkc->kop; | ||
599 | + struct crypt_kop *cop = &kop->kop; | ||
600 | + struct pkc_request *pkc_req; | ||
601 | + struct dsa_verify_req_s *dsa_req; | ||
602 | + int rc, buf_size; | ||
603 | + uint8_t *buf; | ||
604 | + | ||
605 | + if (!cop->crk_param[0].crp_nbits || !cop->crk_param[1].crp_nbits || | ||
606 | + !cop->crk_param[2].crp_nbits || !cop->crk_param[3].crp_nbits || | ||
607 | + !cop->crk_param[4].crp_nbits || !cop->crk_param[5].crp_nbits || | ||
608 | + !cop->crk_param[6].crp_nbits || (cop->crk_iparams == 8 && | ||
609 | + !cop->crk_param[7].crp_nbits)) | ||
610 | + return -EINVAL; | ||
611 | + | ||
612 | + pkc_req = &pkc->req; | ||
613 | + dsa_req = &pkc_req->req_u.dsa_verify; | ||
614 | + dsa_req->m_len = (cop->crk_param[0].crp_nbits + 7)/8; | ||
615 | + dsa_req->q_len = (cop->crk_param[1].crp_nbits + 7)/8; | ||
616 | + dsa_req->r_len = (cop->crk_param[2].crp_nbits + 7)/8; | ||
617 | + dsa_req->g_len = (cop->crk_param[3].crp_nbits + 7)/8; | ||
618 | + dsa_req->pub_key_len = (cop->crk_param[4].crp_nbits + 7)/8; | ||
619 | + dsa_req->d_len = (cop->crk_param[6].crp_nbits + 7)/8; | ||
620 | + buf_size = dsa_req->m_len + dsa_req->q_len + dsa_req->r_len + | ||
621 | + dsa_req->g_len + dsa_req->pub_key_len + dsa_req->d_len + | ||
622 | + dsa_req->d_len; | ||
623 | + if (cop->crk_iparams == 8) { | ||
624 | + dsa_req->ab_len = (cop->crk_param[5].crp_nbits + 7)/8; | ||
625 | + buf_size += dsa_req->ab_len; | ||
626 | + pkc_req->type = ECDSA_VERIFY; | ||
627 | + pkc_req->curve_type = cop->curve_type; | ||
628 | + } else { | ||
629 | + pkc_req->type = DSA_VERIFY; | ||
630 | + } | ||
631 | + | ||
632 | + buf = kzalloc(buf_size, GFP_DMA); | ||
633 | + | ||
634 | + dsa_req->q = buf; | ||
635 | + dsa_req->r = dsa_req->q + dsa_req->q_len; | ||
636 | + dsa_req->g = dsa_req->r + dsa_req->r_len; | ||
637 | + dsa_req->pub_key = dsa_req->g + dsa_req->g_len; | ||
638 | + dsa_req->m = dsa_req->pub_key + dsa_req->pub_key_len; | ||
639 | + dsa_req->c = dsa_req->m + dsa_req->m_len; | ||
640 | + dsa_req->d = dsa_req->c + dsa_req->d_len; | ||
641 | + copy_from_user(dsa_req->m, cop->crk_param[0].crp_p, dsa_req->m_len); | ||
642 | + copy_from_user(dsa_req->q, cop->crk_param[1].crp_p, dsa_req->q_len); | ||
643 | + copy_from_user(dsa_req->r, cop->crk_param[2].crp_p, dsa_req->r_len); | ||
644 | + copy_from_user(dsa_req->g, cop->crk_param[3].crp_p, dsa_req->g_len); | ||
645 | + copy_from_user(dsa_req->pub_key, cop->crk_param[4].crp_p, | ||
646 | + dsa_req->pub_key_len); | ||
647 | + if (cop->crk_iparams == 8) { | ||
648 | + dsa_req->ab = dsa_req->d + dsa_req->d_len; | ||
649 | + copy_from_user(dsa_req->ab, cop->crk_param[5].crp_p, | ||
650 | + dsa_req->ab_len); | ||
651 | + copy_from_user(dsa_req->c, cop->crk_param[6].crp_p, | ||
652 | + dsa_req->d_len); | ||
653 | + copy_from_user(dsa_req->d, cop->crk_param[7].crp_p, | ||
654 | + dsa_req->d_len); | ||
655 | + } else { | ||
656 | + copy_from_user(dsa_req->c, cop->crk_param[5].crp_p, | ||
657 | + dsa_req->d_len); | ||
658 | + copy_from_user(dsa_req->d, cop->crk_param[6].crp_p, | ||
659 | + dsa_req->d_len); | ||
660 | + } | ||
661 | + rc = cryptodev_pkc_offload(pkc); | ||
662 | + if (pkc->type == SYNCHRONOUS) { | ||
663 | + if (rc) | ||
664 | + goto err; | ||
665 | + } else { | ||
666 | + if (rc != -EINPROGRESS && !rc) | ||
667 | + goto err; | ||
668 | + pkc->cookie = buf; | ||
669 | + return rc; | ||
670 | + } | ||
671 | +err: | ||
672 | + kfree(buf); | ||
673 | + return rc; | ||
674 | +} | ||
675 | + | ||
676 | +int crypto_kop_dh_key(struct cryptodev_pkc *pkc) | ||
677 | +{ | ||
678 | + struct kernel_crypt_kop *kop = &pkc->kop; | ||
679 | + struct crypt_kop *cop = &kop->kop; | ||
680 | + struct pkc_request *pkc_req; | ||
681 | + struct dh_key_req_s *dh_req; | ||
682 | + int buf_size; | ||
683 | + uint8_t *buf; | ||
684 | + int rc = -EINVAL; | ||
685 | + | ||
686 | + pkc_req = &pkc->req; | ||
687 | + dh_req = &pkc_req->req_u.dh_req; | ||
688 | + dh_req->s_len = (cop->crk_param[0].crp_nbits + 7)/8; | ||
689 | + dh_req->pub_key_len = (cop->crk_param[1].crp_nbits + 7)/8; | ||
690 | + dh_req->q_len = (cop->crk_param[2].crp_nbits + 7)/8; | ||
691 | + buf_size = dh_req->q_len + dh_req->pub_key_len + dh_req->s_len; | ||
692 | + if (cop->crk_iparams == 4) { | ||
693 | + pkc_req->type = ECDH_COMPUTE_KEY; | ||
694 | + dh_req->ab_len = (cop->crk_param[3].crp_nbits + 7)/8; | ||
695 | + dh_req->z_len = (cop->crk_param[4].crp_nbits + 7)/8; | ||
696 | + buf_size += dh_req->ab_len; | ||
697 | + } else { | ||
698 | + dh_req->z_len = (cop->crk_param[3].crp_nbits + 7)/8; | ||
699 | + pkc_req->type = DH_COMPUTE_KEY; | ||
700 | + } | ||
701 | + buf_size += dh_req->z_len; | ||
702 | + buf = kzalloc(buf_size, GFP_DMA); | ||
703 | + dh_req->q = buf; | ||
704 | + dh_req->s = dh_req->q + dh_req->q_len; | ||
705 | + dh_req->pub_key = dh_req->s + dh_req->s_len; | ||
706 | + dh_req->z = dh_req->pub_key + dh_req->pub_key_len; | ||
707 | + if (cop->crk_iparams == 4) { | ||
708 | + dh_req->ab = dh_req->z + dh_req->z_len; | ||
709 | + pkc_req->curve_type = cop->curve_type; | ||
710 | + copy_from_user(dh_req->ab, cop->crk_param[3].crp_p, | ||
711 | + dh_req->ab_len); | ||
712 | + } | ||
713 | + copy_from_user(dh_req->s, cop->crk_param[0].crp_p, dh_req->s_len); | ||
714 | + copy_from_user(dh_req->pub_key, cop->crk_param[1].crp_p, | ||
715 | + dh_req->pub_key_len); | ||
716 | + copy_from_user(dh_req->q, cop->crk_param[2].crp_p, dh_req->q_len); | ||
717 | + rc = cryptodev_pkc_offload(pkc); | ||
718 | + if (pkc->type == SYNCHRONOUS) { | ||
719 | + if (rc) | ||
720 | + goto err; | ||
721 | + if (cop->crk_iparams == 4) | ||
722 | + copy_to_user(cop->crk_param[4].crp_p, dh_req->z, | ||
723 | + dh_req->z_len); | ||
724 | + else | ||
725 | + copy_to_user(cop->crk_param[3].crp_p, dh_req->z, | ||
726 | + dh_req->z_len); | ||
727 | + } else { | ||
728 | + if (rc != -EINPROGRESS && rc != 0) | ||
729 | + goto err; | ||
730 | + | ||
731 | + pkc->cookie = buf; | ||
732 | + return rc; | ||
733 | + } | ||
734 | +err: | ||
735 | + kfree(buf); | ||
736 | + return rc; | ||
737 | +} | ||
738 | + | ||
739 | +int crypto_modexp_crt(struct cryptodev_pkc *pkc) | ||
740 | +{ | ||
741 | + struct kernel_crypt_kop *kop = &pkc->kop; | ||
742 | + struct crypt_kop *cop = &kop->kop; | ||
743 | + struct pkc_request *pkc_req; | ||
744 | + struct rsa_priv_frm3_req_s *rsa_req; | ||
745 | + int rc; | ||
746 | + uint8_t *buf; | ||
747 | + | ||
748 | + if (!cop->crk_param[0].crp_nbits || !cop->crk_param[1].crp_nbits || | ||
749 | + !cop->crk_param[2].crp_nbits || !cop->crk_param[3].crp_nbits || | ||
750 | + !cop->crk_param[4].crp_nbits || !cop->crk_param[5].crp_nbits) | ||
751 | + return -EINVAL; | ||
752 | + | ||
753 | + pkc_req = &pkc->req; | ||
754 | + pkc_req->type = RSA_PRIV_FORM3; | ||
755 | + rsa_req = &pkc_req->req_u.rsa_priv_f3; | ||
756 | + rsa_req->p_len = (cop->crk_param[0].crp_nbits + 7)/8; | ||
757 | + rsa_req->q_len = (cop->crk_param[1].crp_nbits + 7)/8; | ||
758 | + rsa_req->g_len = (cop->crk_param[2].crp_nbits + 7)/8; | ||
759 | + rsa_req->dp_len = (cop->crk_param[3].crp_nbits + 7)/8; | ||
760 | + rsa_req->dq_len = (cop->crk_param[4].crp_nbits + 7)/8; | ||
761 | + rsa_req->c_len = (cop->crk_param[5].crp_nbits + 7)/8; | ||
762 | + rsa_req->f_len = (cop->crk_param[6].crp_nbits + 7)/8; | ||
763 | + buf = kzalloc(rsa_req->p_len + rsa_req->q_len + rsa_req->f_len + | ||
764 | + rsa_req->dp_len + rsa_req->dp_len + rsa_req->c_len + | ||
765 | + rsa_req->g_len, GFP_DMA); | ||
766 | + rsa_req->p = buf; | ||
767 | + rsa_req->q = rsa_req->p + rsa_req->p_len; | ||
768 | + rsa_req->g = rsa_req->q + rsa_req->q_len; | ||
769 | + rsa_req->dp = rsa_req->g + rsa_req->g_len; | ||
770 | + rsa_req->dq = rsa_req->dp + rsa_req->dp_len; | ||
771 | + rsa_req->c = rsa_req->dq + rsa_req->dq_len; | ||
772 | + rsa_req->f = rsa_req->c + rsa_req->c_len; | ||
773 | + copy_from_user(rsa_req->p, cop->crk_param[0].crp_p, rsa_req->p_len); | ||
774 | + copy_from_user(rsa_req->q, cop->crk_param[1].crp_p, rsa_req->q_len); | ||
775 | + copy_from_user(rsa_req->g, cop->crk_param[2].crp_p, rsa_req->g_len); | ||
776 | + copy_from_user(rsa_req->dp, cop->crk_param[3].crp_p, rsa_req->dp_len); | ||
777 | + copy_from_user(rsa_req->dq, cop->crk_param[4].crp_p, rsa_req->dq_len); | ||
778 | + copy_from_user(rsa_req->c, cop->crk_param[5].crp_p, rsa_req->c_len); | ||
779 | + rc = cryptodev_pkc_offload(pkc); | ||
780 | + | ||
781 | + if (pkc->type == SYNCHRONOUS) { | ||
782 | + if (rc) | ||
783 | + goto err; | ||
784 | + copy_to_user(cop->crk_param[6].crp_p, rsa_req->f, | ||
785 | + rsa_req->f_len); | ||
786 | + } else { | ||
787 | + if (rc != -EINPROGRESS && rc != 0) | ||
788 | + goto err; | ||
789 | + | ||
790 | + pkc->cookie = buf; | ||
791 | + return rc; | ||
792 | + } | ||
793 | +err: | ||
794 | + kfree(buf); | ||
795 | + return rc; | ||
796 | +} | ||
797 | + | ||
798 | +int crypto_bn_modexp(struct cryptodev_pkc *pkc) | ||
799 | +{ | ||
800 | + struct pkc_request *pkc_req; | ||
801 | + struct rsa_pub_req_s *rsa_req; | ||
802 | + int rc; | ||
803 | + struct kernel_crypt_kop *kop = &pkc->kop; | ||
804 | + struct crypt_kop *cop = &kop->kop; | ||
805 | + uint8_t *buf; | ||
806 | + | ||
807 | + if (!cop->crk_param[0].crp_nbits || !cop->crk_param[1].crp_nbits || | ||
808 | + !cop->crk_param[2].crp_nbits || !cop->crk_param[3].crp_nbits) | ||
809 | + return -EINVAL; | ||
810 | + | ||
811 | + pkc_req = &pkc->req; | ||
812 | + pkc_req->type = RSA_PUB; | ||
813 | + rsa_req = &pkc_req->req_u.rsa_pub_req; | ||
814 | + rsa_req->f_len = (cop->crk_param[0].crp_nbits + 7)/8; | ||
815 | + rsa_req->e_len = (cop->crk_param[1].crp_nbits + 7)/8; | ||
816 | + rsa_req->n_len = (cop->crk_param[2].crp_nbits + 7)/8; | ||
817 | + rsa_req->g_len = (cop->crk_param[3].crp_nbits + 7)/8; | ||
818 | + buf = kzalloc(rsa_req->f_len + rsa_req->e_len + rsa_req->n_len | ||
819 | + + rsa_req->g_len, GFP_DMA); | ||
820 | + if (!buf) | ||
821 | + return -ENOMEM; | ||
822 | + | ||
823 | + rsa_req->e = buf; | ||
824 | + rsa_req->f = rsa_req->e + rsa_req->e_len; | ||
825 | + rsa_req->g = rsa_req->f + rsa_req->f_len; | ||
826 | + rsa_req->n = rsa_req->g + rsa_req->g_len; | ||
827 | + copy_from_user(rsa_req->f, cop->crk_param[0].crp_p, rsa_req->f_len); | ||
828 | + copy_from_user(rsa_req->e, cop->crk_param[1].crp_p, rsa_req->e_len); | ||
829 | + copy_from_user(rsa_req->n, cop->crk_param[2].crp_p, rsa_req->n_len); | ||
830 | + rc = cryptodev_pkc_offload(pkc); | ||
831 | + if (pkc->type == SYNCHRONOUS) { | ||
832 | + if (rc) | ||
833 | + goto err; | ||
834 | + | ||
835 | + copy_to_user(cop->crk_param[3].crp_p, rsa_req->g, | ||
836 | + rsa_req->g_len); | ||
837 | + } else { | ||
838 | + if (rc != -EINPROGRESS && rc != 0) | ||
839 | + goto err; | ||
840 | + | ||
841 | + /* This one will be freed later in fetch handler */ | ||
842 | + pkc->cookie = buf; | ||
843 | + return rc; | ||
844 | + } | ||
845 | +err: | ||
846 | + kfree(buf); | ||
847 | + return rc; | ||
848 | +} | ||
849 | + | ||
850 | +int crypto_run_asym(struct cryptodev_pkc *pkc) | ||
851 | +{ | ||
852 | + int ret = -EINVAL; | ||
853 | + struct kernel_crypt_kop *kop = &pkc->kop; | ||
854 | + | ||
855 | + switch (kop->kop.crk_op) { | ||
856 | + case CRK_MOD_EXP: | ||
857 | + if (kop->kop.crk_iparams != 3 && kop->kop.crk_oparams != 1) | ||
858 | + goto err; | ||
859 | + | ||
860 | + ret = crypto_bn_modexp(pkc); | ||
861 | + break; | ||
862 | + case CRK_MOD_EXP_CRT: | ||
863 | + if (kop->kop.crk_iparams != 6 && kop->kop.crk_oparams != 1) | ||
864 | + goto err; | ||
865 | + | ||
866 | + ret = crypto_modexp_crt(pkc); | ||
867 | + break; | ||
868 | + case CRK_DSA_SIGN: | ||
869 | + if ((kop->kop.crk_iparams != 5 && kop->kop.crk_iparams != 6) || | ||
870 | + kop->kop.crk_oparams != 2) | ||
871 | + goto err; | ||
872 | + | ||
873 | + ret = crypto_kop_dsasign(pkc); | ||
874 | + break; | ||
875 | + case CRK_DSA_VERIFY: | ||
876 | + if ((kop->kop.crk_iparams != 7 && kop->kop.crk_iparams != 8) || | ||
877 | + kop->kop.crk_oparams != 0) | ||
878 | + goto err; | ||
879 | + | ||
880 | + ret = crypto_kop_dsaverify(pkc); | ||
881 | + break; | ||
882 | + case CRK_DH_COMPUTE_KEY: | ||
883 | + if ((kop->kop.crk_iparams != 3 && kop->kop.crk_iparams != 4) || | ||
884 | + kop->kop.crk_oparams != 1) | ||
885 | + goto err; | ||
886 | + ret = crypto_kop_dh_key(pkc); | ||
887 | + break; | ||
888 | + } | ||
889 | +err: | ||
890 | + return ret; | ||
891 | +} | ||
892 | + | ||
893 | int crypto_run(struct fcrypt *fcr, struct kernel_crypt_op *kcop) | ||
894 | { | ||
895 | struct csession *ses_ptr; | ||
896 | -- | ||
897 | 2.7.0 | ||
898 | |||
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 @@ | |||
1 | From a705360197260d28535746ae98c461ba2cfb7a9e Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Thu, 4 May 2017 15:06:22 +0300 | ||
4 | Subject: [PATCH 3/9] convert to new AEAD interface in kernels v4.2+ | ||
5 | |||
6 | The crypto API for AEAD ciphers changed in recent kernels so that | ||
7 | associated data is now part of both source and destination scatter | ||
8 | gathers. The source, destination and associated data buffers need | ||
9 | to be stiched accordingly for the operations to succeed: | ||
10 | |||
11 | src_sg: auth_buf + src_buf | ||
12 | dst_sg: auth_buf + (dst_buf + tag space) | ||
13 | |||
14 | This patch fixes a kernel crash observed with cipher-gcm test. | ||
15 | |||
16 | See also kernel patch: 81c4c35eb61a69c229871c490b011c1171511d5a | ||
17 | crypto: ccm - Convert to new AEAD interface | ||
18 | |||
19 | Reported-by: Phil Sutter <phil@nwl.cc> | ||
20 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
21 | --- | ||
22 | authenc.c | 40 ++++++++++++++++++++++++++++++++++++++-- | ||
23 | 1 file changed, 38 insertions(+), 2 deletions(-) | ||
24 | |||
25 | diff --git a/authenc.c b/authenc.c | ||
26 | index 95727b4..692951f 100644 | ||
27 | --- a/authenc.c | ||
28 | +++ b/authenc.c | ||
29 | @@ -688,12 +688,20 @@ free_auth_buf: | ||
30 | |||
31 | static int crypto_auth_zc_aead(struct csession *ses_ptr, struct kernel_crypt_auth_op *kcaop) | ||
32 | { | ||
33 | - struct scatterlist *dst_sg, *auth_sg, *src_sg; | ||
34 | + struct scatterlist *dst_sg; | ||
35 | + struct scatterlist *src_sg; | ||
36 | struct crypt_auth_op *caop = &kcaop->caop; | ||
37 | unsigned char *auth_buf = NULL; | ||
38 | - struct scatterlist tmp; | ||
39 | int ret; | ||
40 | |||
41 | +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0)) | ||
42 | + struct scatterlist tmp; | ||
43 | + struct scatterlist *auth_sg; | ||
44 | +#else | ||
45 | + struct scatterlist auth1[2]; | ||
46 | + struct scatterlist auth2[2]; | ||
47 | +#endif | ||
48 | + | ||
49 | if (unlikely(ses_ptr->cdata.init == 0 || | ||
50 | (ses_ptr->cdata.stream == 0 && ses_ptr->cdata.aead == 0))) { | ||
51 | derr(0, "Only stream and AEAD ciphers are allowed for authenc"); | ||
52 | @@ -718,6 +726,7 @@ static int crypto_auth_zc_aead(struct csession *ses_ptr, struct kernel_crypt_aut | ||
53 | goto free_auth_buf; | ||
54 | } | ||
55 | |||
56 | +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0)) | ||
57 | if (caop->auth_src && caop->auth_len > 0) { | ||
58 | if (unlikely(copy_from_user(auth_buf, caop->auth_src, caop->auth_len))) { | ||
59 | derr(1, "unable to copy auth data from userspace."); | ||
60 | @@ -733,6 +742,33 @@ static int crypto_auth_zc_aead(struct csession *ses_ptr, struct kernel_crypt_aut | ||
61 | |||
62 | ret = auth_n_crypt(ses_ptr, kcaop, auth_sg, caop->auth_len, | ||
63 | src_sg, dst_sg, caop->len); | ||
64 | +#else | ||
65 | + if (caop->auth_src && caop->auth_len > 0) { | ||
66 | + if (unlikely(copy_from_user(auth_buf, caop->auth_src, caop->auth_len))) { | ||
67 | + derr(1, "unable to copy auth data from userspace."); | ||
68 | + ret = -EFAULT; | ||
69 | + goto free_pages; | ||
70 | + } | ||
71 | + | ||
72 | + sg_init_table(auth1, 2); | ||
73 | + sg_set_buf(auth1, auth_buf, caop->auth_len); | ||
74 | + sg_chain(auth1, 2, src_sg); | ||
75 | + | ||
76 | + if (src_sg == dst_sg) { | ||
77 | + src_sg = auth1; | ||
78 | + dst_sg = auth1; | ||
79 | + } else { | ||
80 | + sg_init_table(auth2, 2); | ||
81 | + sg_set_buf(auth2, auth_buf, caop->auth_len); | ||
82 | + sg_chain(auth2, 2, dst_sg); | ||
83 | + src_sg = auth1; | ||
84 | + dst_sg = auth2; | ||
85 | + } | ||
86 | + } | ||
87 | + | ||
88 | + ret = auth_n_crypt(ses_ptr, kcaop, NULL, caop->auth_len, | ||
89 | + src_sg, dst_sg, caop->len); | ||
90 | +#endif | ||
91 | |||
92 | free_pages: | ||
93 | release_user_pages(ses_ptr); | ||
94 | -- | ||
95 | 2.7.4 | ||
96 | |||
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 @@ | |||
1 | From e0e5c1bfb21888bf9f87f72ac8cdf7eee951f619 Mon Sep 17 00:00:00 2001 | ||
2 | From: Yashpal Dutta <yashpal.dutta@freescale.com> | ||
3 | Date: Fri, 7 Mar 2014 06:52:13 +0545 | ||
4 | Subject: [PATCH 04/38] Compat versions of PKC IOCTLs | ||
5 | |||
6 | Upstream-status: Pending | ||
7 | |||
8 | Signed-off-by: Yashpal Dutta <yashpal.dutta@freescale.com> | ||
9 | --- | ||
10 | cryptodev_int.h | 20 ++++++++++ | ||
11 | ioctl.c | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
12 | 2 files changed, 140 insertions(+) | ||
13 | |||
14 | diff --git a/cryptodev_int.h b/cryptodev_int.h | ||
15 | index fdbcc61..cf54dac 100644 | ||
16 | --- a/cryptodev_int.h | ||
17 | +++ b/cryptodev_int.h | ||
18 | @@ -75,6 +75,24 @@ struct compat_crypt_op { | ||
19 | compat_uptr_t iv;/* initialization vector for encryption operations */ | ||
20 | }; | ||
21 | |||
22 | +/* input of CIOCKEY */ | ||
23 | +struct compat_crparam { | ||
24 | + compat_uptr_t crp_p; | ||
25 | + uint32_t crp_nbits; | ||
26 | +}; | ||
27 | + | ||
28 | +struct compat_crypt_kop { | ||
29 | + uint32_t crk_op; /* cryptodev_crk_ot_t */ | ||
30 | + uint32_t crk_status; | ||
31 | + uint16_t crk_iparams; | ||
32 | + uint16_t crk_oparams; | ||
33 | + uint32_t crk_pad1; | ||
34 | + struct compat_crparam crk_param[CRK_MAXPARAM]; | ||
35 | + enum curve_t curve_type; /* 0 == Discrete Log, 1 = EC_PRIME, | ||
36 | + 2 = EC_BINARY */ | ||
37 | + compat_uptr_t cookie; | ||
38 | +}; | ||
39 | + | ||
40 | /* input of CIOCAUTHCRYPT */ | ||
41 | struct compat_crypt_auth_op { | ||
42 | uint32_t ses; /* session identifier */ | ||
43 | @@ -111,6 +129,8 @@ struct compat_crypt_auth_op { | ||
44 | #define COMPAT_CIOCASYNCCRYPT _IOW('c', 107, struct compat_crypt_op) | ||
45 | #define COMPAT_CIOCASYNCFETCH _IOR('c', 108, struct compat_crypt_op) | ||
46 | #define COMPAT_CIOCAUTHCRYPT _IOWR('c', 109, struct compat_crypt_auth_op) | ||
47 | +#define COMPAT_CIOCASYMASYNCRYPT _IOW('c', 110, struct compat_crypt_kop) | ||
48 | +#define COMPAT_CIOCASYMASYNFETCH _IOR('c', 111, struct compat_crypt_kop) | ||
49 | |||
50 | #endif /* CONFIG_COMPAT */ | ||
51 | |||
52 | diff --git a/ioctl.c b/ioctl.c | ||
53 | index 69980e3..9431025 100644 | ||
54 | --- a/ioctl.c | ||
55 | +++ b/ioctl.c | ||
56 | @@ -1081,6 +1081,68 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | ||
57 | /* compatibility code for 32bit userlands */ | ||
58 | #ifdef CONFIG_COMPAT | ||
59 | |||
60 | +static inline void compat_to_crypt_kop(struct compat_crypt_kop *compat, | ||
61 | + struct crypt_kop *kop) | ||
62 | +{ | ||
63 | + int i; | ||
64 | + kop->crk_op = compat->crk_op; | ||
65 | + kop->crk_status = compat->crk_status; | ||
66 | + kop->crk_iparams = compat->crk_iparams; | ||
67 | + kop->crk_oparams = compat->crk_oparams; | ||
68 | + | ||
69 | + for (i = 0; i < CRK_MAXPARAM; i++) { | ||
70 | + kop->crk_param[i].crp_p = | ||
71 | + compat_ptr(compat->crk_param[i].crp_p); | ||
72 | + kop->crk_param[i].crp_nbits = compat->crk_param[i].crp_nbits; | ||
73 | + } | ||
74 | + | ||
75 | + kop->curve_type = compat->curve_type; | ||
76 | + kop->cookie = compat->cookie; | ||
77 | +} | ||
78 | + | ||
79 | +static int compat_kop_from_user(struct kernel_crypt_kop *kop, | ||
80 | + void __user *arg) | ||
81 | +{ | ||
82 | + struct compat_crypt_kop compat_kop; | ||
83 | + | ||
84 | + if (unlikely(copy_from_user(&compat_kop, arg, sizeof(compat_kop)))) | ||
85 | + return -EFAULT; | ||
86 | + | ||
87 | + compat_to_crypt_kop(&compat_kop, &kop->kop); | ||
88 | + return fill_kop_from_cop(kop); | ||
89 | +} | ||
90 | + | ||
91 | +static inline void crypt_kop_to_compat(struct crypt_kop *kop, | ||
92 | + struct compat_crypt_kop *compat) | ||
93 | +{ | ||
94 | + int i; | ||
95 | + | ||
96 | + compat->crk_op = kop->crk_op; | ||
97 | + compat->crk_status = kop->crk_status; | ||
98 | + compat->crk_iparams = kop->crk_iparams; | ||
99 | + compat->crk_oparams = kop->crk_oparams; | ||
100 | + | ||
101 | + for (i = 0; i < CRK_MAXPARAM; i++) { | ||
102 | + compat->crk_param[i].crp_p = | ||
103 | + ptr_to_compat(kop->crk_param[i].crp_p); | ||
104 | + compat->crk_param[i].crp_nbits = kop->crk_param[i].crp_nbits; | ||
105 | + } | ||
106 | + compat->cookie = kop->cookie; | ||
107 | + compat->curve_type = kop->curve_type; | ||
108 | +} | ||
109 | + | ||
110 | +static int compat_kop_to_user(struct kernel_crypt_kop *kop, void __user *arg) | ||
111 | +{ | ||
112 | + struct compat_crypt_kop compat_kop; | ||
113 | + | ||
114 | + crypt_kop_to_compat(&kop->kop, &compat_kop); | ||
115 | + if (unlikely(copy_to_user(arg, &compat_kop, sizeof(compat_kop)))) { | ||
116 | + dprintk(1, KERN_ERR, "Cannot copy to userspace\n"); | ||
117 | + return -EFAULT; | ||
118 | + } | ||
119 | + return 0; | ||
120 | +} | ||
121 | + | ||
122 | static inline void | ||
123 | compat_to_session_op(struct compat_session_op *compat, struct session_op *sop) | ||
124 | { | ||
125 | @@ -1208,7 +1270,26 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) | ||
126 | return -EFAULT; | ||
127 | } | ||
128 | return ret; | ||
129 | + case COMPAT_CIOCKEY: | ||
130 | + { | ||
131 | + struct cryptodev_pkc *pkc = | ||
132 | + kzalloc(sizeof(struct cryptodev_pkc), GFP_KERNEL); | ||
133 | + | ||
134 | + if (!pkc) | ||
135 | + return -ENOMEM; | ||
136 | + | ||
137 | + ret = compat_kop_from_user(&pkc->kop, arg); | ||
138 | + | ||
139 | + if (unlikely(ret)) { | ||
140 | + kfree(pkc); | ||
141 | + return ret; | ||
142 | + } | ||
143 | |||
144 | + pkc->type = SYNCHRONOUS; | ||
145 | + ret = crypto_run_asym(pkc); | ||
146 | + kfree(pkc); | ||
147 | + } | ||
148 | + return ret; | ||
149 | case COMPAT_CIOCCRYPT: | ||
150 | ret = compat_kcop_from_user(&kcop, fcr, arg); | ||
151 | if (unlikely(ret)) | ||
152 | @@ -1247,6 +1328,45 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) | ||
153 | |||
154 | return compat_kcop_to_user(&kcop, fcr, arg); | ||
155 | #endif | ||
156 | + case COMPAT_CIOCASYMASYNCRYPT: | ||
157 | + { | ||
158 | + struct cryptodev_pkc *pkc = | ||
159 | + kzalloc(sizeof(struct cryptodev_pkc), GFP_KERNEL); | ||
160 | + | ||
161 | + ret = compat_kop_from_user(&pkc->kop, arg); | ||
162 | + if (unlikely(ret)) | ||
163 | + return -EINVAL; | ||
164 | + | ||
165 | + /* Store associated FD priv data with asymmetric request */ | ||
166 | + pkc->priv = pcr; | ||
167 | + pkc->type = ASYNCHRONOUS; | ||
168 | + ret = crypto_run_asym(pkc); | ||
169 | + if (ret == -EINPROGRESS) | ||
170 | + ret = 0; | ||
171 | + } | ||
172 | + return ret; | ||
173 | + case COMPAT_CIOCASYMASYNFETCH: | ||
174 | + { | ||
175 | + struct cryptodev_pkc *pkc; | ||
176 | + unsigned long flags; | ||
177 | + | ||
178 | + spin_lock_irqsave(&pcr->completion_lock, flags); | ||
179 | + if (list_empty(&pcr->asym_completed_list)) { | ||
180 | + spin_unlock_irqrestore(&pcr->completion_lock, flags); | ||
181 | + return -ENOMEM; | ||
182 | + } | ||
183 | + pkc = list_first_entry(&pcr->asym_completed_list, | ||
184 | + struct cryptodev_pkc, list); | ||
185 | + list_del(&pkc->list); | ||
186 | + spin_unlock_irqrestore(&pcr->completion_lock, flags); | ||
187 | + ret = crypto_async_fetch_asym(pkc); | ||
188 | + | ||
189 | + /* Reflect the updated request to user-space */ | ||
190 | + if (!ret) | ||
191 | + compat_kop_to_user(&pkc->kop, arg); | ||
192 | + kfree(pkc); | ||
193 | + } | ||
194 | + return ret; | ||
195 | default: | ||
196 | return -EINVAL; | ||
197 | } | ||
198 | -- | ||
199 | 2.7.0 | ||
200 | |||
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 @@ | |||
1 | From 1d7c84838445981a06812869f8906bdef52e69eb Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Mon, 15 Feb 2016 18:27:35 +0200 | ||
4 | Subject: [PATCH 4/9] fix type of returned value | ||
5 | |||
6 | The function is declared as unsigned int so we return an | ||
7 | unsigned int as well | ||
8 | |||
9 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
10 | --- | ||
11 | ioctl.c | 2 +- | ||
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
13 | |||
14 | diff --git a/ioctl.c b/ioctl.c | ||
15 | index 0385203..db7207a 100644 | ||
16 | --- a/ioctl.c | ||
17 | +++ b/ioctl.c | ||
18 | @@ -1065,7 +1065,7 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) | ||
19 | static unsigned int cryptodev_poll(struct file *file, poll_table *wait) | ||
20 | { | ||
21 | struct crypt_priv *pcr = file->private_data; | ||
22 | - int ret = 0; | ||
23 | + unsigned int ret = 0; | ||
24 | |||
25 | poll_wait(file, &pcr->user_waiter, wait); | ||
26 | |||
27 | -- | ||
28 | 2.7.4 | ||
29 | |||
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 @@ | |||
1 | From d98f979d76c30058da24e62220f19c5b8c627819 Mon Sep 17 00:00:00 2001 | ||
2 | From: Yashpal Dutta <yashpal.dutta@freescale.com> | ||
3 | Date: Fri, 7 Mar 2014 07:24:00 +0545 | ||
4 | Subject: [PATCH 05/38] Asynchronous interface changes in cryptodev | ||
5 | |||
6 | Upstream-status: Pending | ||
7 | |||
8 | Signed-off-by: Yashpal Dutta <yashpal.dutta@freescale.com> | ||
9 | --- | ||
10 | cryptlib.h | 7 ++++- | ||
11 | crypto/cryptodev.h | 10 ++++++- | ||
12 | cryptodev_int.h | 10 ++++++- | ||
13 | ioctl.c | 76 +++++++++++++++++++++++++++++++++++++----------------- | ||
14 | 4 files changed, 76 insertions(+), 27 deletions(-) | ||
15 | |||
16 | diff --git a/cryptlib.h b/cryptlib.h | ||
17 | index 56d325a..7ffa54c 100644 | ||
18 | --- a/cryptlib.h | ||
19 | +++ b/cryptlib.h | ||
20 | @@ -113,7 +113,12 @@ struct cryptodev_pkc { | ||
21 | struct pkc_request req; /* PKC request structure allocated | ||
22 | from CryptoAPI */ | ||
23 | enum offload_type type; /* Synchronous Vs Asynchronous request */ | ||
24 | - void *cookie; /*Additional opaque cookie to be used in future */ | ||
25 | + /* | ||
26 | + * cookie used for transfering tranparent information from async | ||
27 | + * submission to async fetch. Currently some dynamic allocated | ||
28 | + * buffers are maintained which will be freed later during fetch | ||
29 | + */ | ||
30 | + void *cookie; | ||
31 | struct crypt_priv *priv; | ||
32 | }; | ||
33 | |||
34 | diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h | ||
35 | index 96675fe..4436fbf 100644 | ||
36 | --- a/crypto/cryptodev.h | ||
37 | +++ b/crypto/cryptodev.h | ||
38 | @@ -254,6 +254,14 @@ struct crypt_kop { | ||
39 | void *cookie; | ||
40 | }; | ||
41 | |||
42 | +#define MAX_COOKIES 4 | ||
43 | + | ||
44 | +struct pkc_cookie_list_s { | ||
45 | + int cookie_available; | ||
46 | + void *cookie[MAX_COOKIES]; | ||
47 | + int status[MAX_COOKIES]; | ||
48 | +}; | ||
49 | + | ||
50 | enum cryptodev_crk_op_t { | ||
51 | CRK_MOD_EXP = 0, | ||
52 | CRK_MOD_EXP_CRT = 1, | ||
53 | @@ -298,5 +306,5 @@ enum cryptodev_crk_op_t { | ||
54 | #define CIOCASYNCFETCH _IOR('c', 111, struct crypt_op) | ||
55 | /* additional ioctls for asynchronous operation for asymmetric ciphers*/ | ||
56 | #define CIOCASYMASYNCRYPT _IOW('c', 112, struct crypt_kop) | ||
57 | -#define CIOCASYMASYNFETCH _IOR('c', 113, struct crypt_kop) | ||
58 | +#define CIOCASYMFETCHCOOKIE _IOR('c', 113, struct pkc_cookie_list_s) | ||
59 | #endif /* L_CRYPTODEV_H */ | ||
60 | diff --git a/cryptodev_int.h b/cryptodev_int.h | ||
61 | index cf54dac..5347cae 100644 | ||
62 | --- a/cryptodev_int.h | ||
63 | +++ b/cryptodev_int.h | ||
64 | @@ -93,6 +93,12 @@ struct compat_crypt_kop { | ||
65 | compat_uptr_t cookie; | ||
66 | }; | ||
67 | |||
68 | +struct compat_pkc_cookie_list_s { | ||
69 | + int cookie_available; | ||
70 | + compat_uptr_t cookie[MAX_COOKIES]; | ||
71 | + int status[MAX_COOKIES]; | ||
72 | +}; | ||
73 | + | ||
74 | /* input of CIOCAUTHCRYPT */ | ||
75 | struct compat_crypt_auth_op { | ||
76 | uint32_t ses; /* session identifier */ | ||
77 | @@ -126,11 +132,13 @@ struct compat_crypt_auth_op { | ||
78 | /* compat ioctls, defined for the above structs */ | ||
79 | #define COMPAT_CIOCGSESSION _IOWR('c', 102, struct compat_session_op) | ||
80 | #define COMPAT_CIOCCRYPT _IOWR('c', 104, struct compat_crypt_op) | ||
81 | +#define COMPAT_CIOCKEY _IOW('c', 105, struct compat_crypt_kop) | ||
82 | #define COMPAT_CIOCASYNCCRYPT _IOW('c', 107, struct compat_crypt_op) | ||
83 | #define COMPAT_CIOCASYNCFETCH _IOR('c', 108, struct compat_crypt_op) | ||
84 | #define COMPAT_CIOCAUTHCRYPT _IOWR('c', 109, struct compat_crypt_auth_op) | ||
85 | #define COMPAT_CIOCASYMASYNCRYPT _IOW('c', 110, struct compat_crypt_kop) | ||
86 | -#define COMPAT_CIOCASYMASYNFETCH _IOR('c', 111, struct compat_crypt_kop) | ||
87 | +#define COMPAT_CIOCASYMFETCHCOOKIE _IOR('c', 111, \ | ||
88 | + struct compat_pkc_cookie_list_s) | ||
89 | |||
90 | #endif /* CONFIG_COMPAT */ | ||
91 | |||
92 | diff --git a/ioctl.c b/ioctl.c | ||
93 | index 9431025..e2f407f 100644 | ||
94 | --- a/ioctl.c | ||
95 | +++ b/ioctl.c | ||
96 | @@ -105,8 +105,6 @@ void cryptodev_complete_asym(struct crypto_async_request *req, int err) | ||
97 | crypto_free_pkc(pkc->s); | ||
98 | res->err = err; | ||
99 | if (pkc->type == SYNCHRONOUS) { | ||
100 | - if (err == -EINPROGRESS) | ||
101 | - return; | ||
102 | complete(&res->completion); | ||
103 | } else { | ||
104 | struct crypt_priv *pcr = pkc->priv; | ||
105 | @@ -1051,26 +1049,41 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | ||
106 | ret = 0; | ||
107 | } | ||
108 | return ret; | ||
109 | - case CIOCASYMASYNFETCH: | ||
110 | + case CIOCASYMFETCHCOOKIE: | ||
111 | { | ||
112 | struct cryptodev_pkc *pkc; | ||
113 | unsigned long flags; | ||
114 | + int i; | ||
115 | + struct pkc_cookie_list_s cookie_list; | ||
116 | |||
117 | spin_lock_irqsave(&pcr->completion_lock, flags); | ||
118 | - if (list_empty(&pcr->asym_completed_list)) { | ||
119 | - spin_unlock_irqrestore(&pcr->completion_lock, flags); | ||
120 | - return -ENOMEM; | ||
121 | + cookie_list.cookie_available = 0; | ||
122 | + for (i = 0; i < MAX_COOKIES; i++) { | ||
123 | + if (!list_empty(&pcr->asym_completed_list)) { | ||
124 | + /* Run a loop in the list for upto elements | ||
125 | + and copy their response back */ | ||
126 | + pkc = | ||
127 | + list_first_entry(&pcr->asym_completed_list, | ||
128 | + struct cryptodev_pkc, list); | ||
129 | + list_del(&pkc->list); | ||
130 | + ret = crypto_async_fetch_asym(pkc); | ||
131 | + if (!ret) { | ||
132 | + cookie_list.cookie_available++; | ||
133 | + cookie_list.cookie[i] = | ||
134 | + pkc->kop.kop.cookie; | ||
135 | + cookie_list.status[i] = pkc->result.err; | ||
136 | + } | ||
137 | + kfree(pkc); | ||
138 | + } else { | ||
139 | + break; | ||
140 | + } | ||
141 | } | ||
142 | - pkc = list_first_entry(&pcr->asym_completed_list, | ||
143 | - struct cryptodev_pkc, list); | ||
144 | - list_del(&pkc->list); | ||
145 | spin_unlock_irqrestore(&pcr->completion_lock, flags); | ||
146 | - ret = crypto_async_fetch_asym(pkc); | ||
147 | |||
148 | /* Reflect the updated request to user-space */ | ||
149 | - if (!ret) | ||
150 | - kop_to_user(&pkc->kop, arg); | ||
151 | - kfree(pkc); | ||
152 | + if (cookie_list.cookie_available) | ||
153 | + copy_to_user(arg, &cookie_list, | ||
154 | + sizeof(struct pkc_cookie_list_s)); | ||
155 | } | ||
156 | return ret; | ||
157 | default: | ||
158 | @@ -1345,26 +1358,41 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) | ||
159 | ret = 0; | ||
160 | } | ||
161 | return ret; | ||
162 | - case COMPAT_CIOCASYMASYNFETCH: | ||
163 | + case COMPAT_CIOCASYMFETCHCOOKIE: | ||
164 | { | ||
165 | struct cryptodev_pkc *pkc; | ||
166 | unsigned long flags; | ||
167 | + int i = 0; | ||
168 | + struct compat_pkc_cookie_list_s cookie_list; | ||
169 | |||
170 | spin_lock_irqsave(&pcr->completion_lock, flags); | ||
171 | - if (list_empty(&pcr->asym_completed_list)) { | ||
172 | - spin_unlock_irqrestore(&pcr->completion_lock, flags); | ||
173 | - return -ENOMEM; | ||
174 | + cookie_list.cookie_available = 0; | ||
175 | + | ||
176 | + for (i = 0; i < MAX_COOKIES; i++) { | ||
177 | + if (!list_empty(&pcr->asym_completed_list)) { | ||
178 | + /* Run a loop in the list for upto elements | ||
179 | + and copy their response back */ | ||
180 | + pkc = | ||
181 | + list_first_entry(&pcr->asym_completed_list, | ||
182 | + struct cryptodev_pkc, list); | ||
183 | + list_del(&pkc->list); | ||
184 | + ret = crypto_async_fetch_asym(pkc); | ||
185 | + if (!ret) { | ||
186 | + cookie_list.cookie_available++; | ||
187 | + cookie_list.cookie[i] = | ||
188 | + pkc->kop.kop.cookie; | ||
189 | + } | ||
190 | + kfree(pkc); | ||
191 | + } else { | ||
192 | + break; | ||
193 | + } | ||
194 | } | ||
195 | - pkc = list_first_entry(&pcr->asym_completed_list, | ||
196 | - struct cryptodev_pkc, list); | ||
197 | - list_del(&pkc->list); | ||
198 | spin_unlock_irqrestore(&pcr->completion_lock, flags); | ||
199 | - ret = crypto_async_fetch_asym(pkc); | ||
200 | |||
201 | /* Reflect the updated request to user-space */ | ||
202 | - if (!ret) | ||
203 | - compat_kop_to_user(&pkc->kop, arg); | ||
204 | - kfree(pkc); | ||
205 | + if (cookie_list.cookie_available) | ||
206 | + copy_to_user(arg, &cookie_list, | ||
207 | + sizeof(struct compat_pkc_cookie_list_s)); | ||
208 | } | ||
209 | return ret; | ||
210 | default: | ||
211 | -- | ||
212 | 2.7.0 | ||
213 | |||
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 @@ | |||
1 | From 00a686189f7e05d70a7184cd6218f7424ab21b0d Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Tue, 23 May 2017 15:28:58 +0300 | ||
4 | Subject: [PATCH 5/9] remove unnecessary header inclusion | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | zc.h | 2 -- | ||
9 | 1 file changed, 2 deletions(-) | ||
10 | |||
11 | diff --git a/zc.h b/zc.h | ||
12 | index 6f975d6..666c4a5 100644 | ||
13 | --- a/zc.h | ||
14 | +++ b/zc.h | ||
15 | @@ -1,8 +1,6 @@ | ||
16 | #ifndef ZC_H | ||
17 | # define ZC_H | ||
18 | |||
19 | -#include "cryptodev_int.h" | ||
20 | - | ||
21 | /* For zero copy */ | ||
22 | int __get_userbuf(uint8_t __user *addr, uint32_t len, int write, | ||
23 | unsigned int pgcount, struct page **pg, struct scatterlist *sg, | ||
24 | -- | ||
25 | 2.7.4 | ||
26 | |||
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 @@ | |||
1 | From b92d23a790d9634d52db3b9a5e1882fde620b073 Mon Sep 17 00:00:00 2001 | ||
2 | From: Yashpal Dutta <yashpal.dutta@freescale.com> | ||
3 | Date: Fri, 7 Mar 2014 07:53:53 +0545 | ||
4 | Subject: [PATCH 06/38] ECC_KEYGEN and DLC_KEYGEN supported in cryptodev module | ||
5 | |||
6 | Upstream-status: Pending | ||
7 | |||
8 | Signed-off-by: Yashpal Dutta <yashpal.dutta@freescale.com> | ||
9 | --- | ||
10 | cryptlib.c | 2 ++ | ||
11 | crypto/cryptodev.h | 5 +++- | ||
12 | ioctl.c | 29 +++++++++++++++++-- | ||
13 | main.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
14 | 4 files changed, 118 insertions(+), 3 deletions(-) | ||
15 | |||
16 | diff --git a/cryptlib.c b/cryptlib.c | ||
17 | index 6900028..47cd568 100644 | ||
18 | --- a/cryptlib.c | ||
19 | +++ b/cryptlib.c | ||
20 | @@ -452,6 +452,8 @@ int cryptodev_pkc_offload(struct cryptodev_pkc *pkc) | ||
21 | case DSA_VERIFY: | ||
22 | case ECDSA_SIGN: | ||
23 | case ECDSA_VERIFY: | ||
24 | + case DLC_KEYGEN: | ||
25 | + case ECC_KEYGEN: | ||
26 | pkc->s = crypto_alloc_pkc("pkc(dsa)", | ||
27 | CRYPTO_ALG_TYPE_PKC_DSA, 0); | ||
28 | break; | ||
29 | diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h | ||
30 | index 4436fbf..275a55c 100644 | ||
31 | --- a/crypto/cryptodev.h | ||
32 | +++ b/crypto/cryptodev.h | ||
33 | @@ -268,6 +268,8 @@ enum cryptodev_crk_op_t { | ||
34 | CRK_DSA_SIGN = 2, | ||
35 | CRK_DSA_VERIFY = 3, | ||
36 | CRK_DH_COMPUTE_KEY = 4, | ||
37 | + CRK_DSA_GENERATE_KEY = 5, | ||
38 | + CRK_DH_GENERATE_KEY = 6, | ||
39 | CRK_ALGORITHM_ALL | ||
40 | }; | ||
41 | |||
42 | @@ -280,7 +282,8 @@ enum cryptodev_crk_op_t { | ||
43 | #define CRF_DSA_SIGN (1 << CRK_DSA_SIGN) | ||
44 | #define CRF_DSA_VERIFY (1 << CRK_DSA_VERIFY) | ||
45 | #define CRF_DH_COMPUTE_KEY (1 << CRK_DH_COMPUTE_KEY) | ||
46 | - | ||
47 | +#define CRF_DSA_GENERATE_KEY (1 << CRK_DSA_GENERATE_KEY) | ||
48 | +#define CRF_DH_GENERATE_KEY (1 << CRK_DH_GENERATE_KEY) | ||
49 | |||
50 | /* ioctl's. Compatible with old linux cryptodev.h | ||
51 | */ | ||
52 | diff --git a/ioctl.c b/ioctl.c | ||
53 | index e2f407f..1f0741a 100644 | ||
54 | --- a/ioctl.c | ||
55 | +++ b/ioctl.c | ||
56 | @@ -726,6 +726,23 @@ static int crypto_async_fetch_asym(struct cryptodev_pkc *pkc) | ||
57 | dh_req->z, dh_req->z_len); | ||
58 | } | ||
59 | break; | ||
60 | + case CRK_DSA_GENERATE_KEY: | ||
61 | + case CRK_DH_GENERATE_KEY: | ||
62 | + { | ||
63 | + struct keygen_req_s *key_req = &pkc_req->req_u.keygen; | ||
64 | + | ||
65 | + if (pkc_req->type == ECC_KEYGEN) { | ||
66 | + copy_to_user(ckop->crk_param[4].crp_p, key_req->pub_key, | ||
67 | + key_req->pub_key_len); | ||
68 | + copy_to_user(ckop->crk_param[5].crp_p, | ||
69 | + key_req->priv_key, key_req->priv_key_len); | ||
70 | + } else { | ||
71 | + copy_to_user(ckop->crk_param[3].crp_p, | ||
72 | + key_req->pub_key, key_req->pub_key_len); | ||
73 | + copy_to_user(ckop->crk_param[4].crp_p, | ||
74 | + key_req->priv_key, key_req->priv_key_len); | ||
75 | + } | ||
76 | + } | ||
77 | default: | ||
78 | ret = -EINVAL; | ||
79 | } | ||
80 | @@ -939,8 +956,9 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | ||
81 | |||
82 | switch (cmd) { | ||
83 | case CIOCASYMFEAT: | ||
84 | - return put_user(CRF_MOD_EXP_CRT | CRF_MOD_EXP | | ||
85 | - CRF_DSA_SIGN | CRF_DSA_VERIFY | CRF_DH_COMPUTE_KEY, p); | ||
86 | + return put_user(CRF_MOD_EXP_CRT | CRF_MOD_EXP | CRF_DSA_SIGN | | ||
87 | + CRF_DSA_VERIFY | CRF_DH_COMPUTE_KEY | | ||
88 | + CRF_DSA_GENERATE_KEY, p); | ||
89 | case CRIOGET: | ||
90 | fd = clonefd(filp); | ||
91 | ret = put_user(fd, p); | ||
92 | @@ -1084,7 +1102,14 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | ||
93 | if (cookie_list.cookie_available) | ||
94 | copy_to_user(arg, &cookie_list, | ||
95 | sizeof(struct pkc_cookie_list_s)); | ||
96 | + else { | ||
97 | + struct pkc_cookie_list_s *user_ck_list = (void *)arg; | ||
98 | + | ||
99 | + put_user(0, &(user_ck_list->cookie_available)); | ||
100 | + } | ||
101 | + ret = cookie_list.cookie_available; | ||
102 | } | ||
103 | + | ||
104 | return ret; | ||
105 | default: | ||
106 | return -EINVAL; | ||
107 | diff --git a/main.c b/main.c | ||
108 | index 0b7951e..c901bc7 100644 | ||
109 | --- a/main.c | ||
110 | +++ b/main.c | ||
111 | @@ -342,6 +342,85 @@ err: | ||
112 | return rc; | ||
113 | } | ||
114 | |||
115 | +int crypto_kop_keygen(struct cryptodev_pkc *pkc) | ||
116 | +{ | ||
117 | + struct kernel_crypt_kop *kop = &pkc->kop; | ||
118 | + struct crypt_kop *cop = &kop->kop; | ||
119 | + struct pkc_request *pkc_req; | ||
120 | + struct keygen_req_s *key_req; | ||
121 | + int rc, buf_size; | ||
122 | + uint8_t *buf; | ||
123 | + | ||
124 | + if (!cop->crk_param[0].crp_nbits || !cop->crk_param[1].crp_nbits || | ||
125 | + !cop->crk_param[2].crp_nbits || !cop->crk_param[3].crp_nbits || | ||
126 | + !cop->crk_param[4].crp_nbits) | ||
127 | + return -EINVAL; | ||
128 | + | ||
129 | + pkc_req = &pkc->req; | ||
130 | + key_req = &pkc_req->req_u.keygen; | ||
131 | + key_req->q_len = (cop->crk_param[0].crp_nbits + 7)/8; | ||
132 | + key_req->r_len = (cop->crk_param[1].crp_nbits + 7)/8; | ||
133 | + key_req->g_len = (cop->crk_param[2].crp_nbits + 7)/8; | ||
134 | + if (cop->crk_iparams == 3) { | ||
135 | + key_req->pub_key_len = (cop->crk_param[3].crp_nbits + 7)/8; | ||
136 | + key_req->priv_key_len = (cop->crk_param[4].crp_nbits + 7)/8; | ||
137 | + buf_size = key_req->q_len + key_req->r_len + key_req->g_len + | ||
138 | + key_req->pub_key_len + key_req->priv_key_len; | ||
139 | + pkc_req->type = DLC_KEYGEN; | ||
140 | + } else { | ||
141 | + key_req->ab_len = (cop->crk_param[3].crp_nbits + 7)/8; | ||
142 | + key_req->pub_key_len = (cop->crk_param[4].crp_nbits + 7)/8; | ||
143 | + key_req->priv_key_len = (cop->crk_param[5].crp_nbits + 7)/8; | ||
144 | + buf_size = key_req->q_len + key_req->r_len + key_req->g_len + | ||
145 | + key_req->pub_key_len + key_req->priv_key_len + | ||
146 | + key_req->ab_len; | ||
147 | + pkc_req->type = ECC_KEYGEN; | ||
148 | + pkc_req->curve_type = cop->curve_type; | ||
149 | + } | ||
150 | + | ||
151 | + buf = kzalloc(buf_size, GFP_DMA); | ||
152 | + if (!buf) | ||
153 | + return -ENOMEM; | ||
154 | + | ||
155 | + key_req->q = buf; | ||
156 | + key_req->r = key_req->q + key_req->q_len; | ||
157 | + key_req->g = key_req->r + key_req->r_len; | ||
158 | + key_req->pub_key = key_req->g + key_req->g_len; | ||
159 | + key_req->priv_key = key_req->pub_key + key_req->pub_key_len; | ||
160 | + copy_from_user(key_req->q, cop->crk_param[0].crp_p, key_req->q_len); | ||
161 | + copy_from_user(key_req->r, cop->crk_param[1].crp_p, key_req->r_len); | ||
162 | + copy_from_user(key_req->g, cop->crk_param[2].crp_p, key_req->g_len); | ||
163 | + if (cop->crk_iparams == 3) { | ||
164 | + copy_from_user(key_req->pub_key, cop->crk_param[3].crp_p, | ||
165 | + key_req->pub_key_len); | ||
166 | + copy_from_user(key_req->priv_key, cop->crk_param[4].crp_p, | ||
167 | + key_req->priv_key_len); | ||
168 | + } else { | ||
169 | + key_req->ab = key_req->priv_key + key_req->priv_key_len; | ||
170 | + copy_from_user(key_req->ab, cop->crk_param[3].crp_p, | ||
171 | + key_req->ab_len); | ||
172 | + copy_from_user(key_req->pub_key, cop->crk_param[4].crp_p, | ||
173 | + key_req->pub_key_len); | ||
174 | + copy_from_user(key_req->priv_key, cop->crk_param[5].crp_p, | ||
175 | + key_req->priv_key_len); | ||
176 | + } | ||
177 | + | ||
178 | + rc = cryptodev_pkc_offload(pkc); | ||
179 | + if (pkc->type == SYNCHRONOUS) { | ||
180 | + if (rc) | ||
181 | + goto err; | ||
182 | + } else { | ||
183 | + if (rc != -EINPROGRESS && !rc) | ||
184 | + goto err; | ||
185 | + | ||
186 | + pkc->cookie = buf; | ||
187 | + return rc; | ||
188 | + } | ||
189 | +err: | ||
190 | + kfree(buf); | ||
191 | + return rc; | ||
192 | +} | ||
193 | + | ||
194 | int crypto_kop_dh_key(struct cryptodev_pkc *pkc) | ||
195 | { | ||
196 | struct kernel_crypt_kop *kop = &pkc->kop; | ||
197 | @@ -554,6 +633,12 @@ int crypto_run_asym(struct cryptodev_pkc *pkc) | ||
198 | goto err; | ||
199 | ret = crypto_kop_dh_key(pkc); | ||
200 | break; | ||
201 | + case CRK_DH_GENERATE_KEY: | ||
202 | + case CRK_DSA_GENERATE_KEY: | ||
203 | + if ((kop->kop.crk_iparams != 3 && kop->kop.crk_iparams != 4)) | ||
204 | + goto err; | ||
205 | + ret = crypto_kop_keygen(pkc); | ||
206 | + break; | ||
207 | } | ||
208 | err: | ||
209 | return ret; | ||
210 | -- | ||
211 | 2.7.0 | ||
212 | |||
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 @@ | |||
1 | From 3245b0f9ed2085f6167068409fb344166093808c Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Tue, 23 May 2017 15:50:40 +0300 | ||
4 | Subject: [PATCH 6/9] move structure definition to cryptodev_int.h | ||
5 | |||
6 | This is necessary for the rsa patch and makes this data structure | ||
7 | visible to kernel_crypt_pkop structure which will be defined in | ||
8 | cryptodev_int.h as well. | ||
9 | |||
10 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
11 | --- | ||
12 | cryptlib.h | 6 ------ | ||
13 | cryptodev_int.h | 5 +++++ | ||
14 | 2 files changed, 5 insertions(+), 6 deletions(-) | ||
15 | |||
16 | diff --git a/cryptlib.h b/cryptlib.h | ||
17 | index 8e8aa71..48fe9bd 100644 | ||
18 | --- a/cryptlib.h | ||
19 | +++ b/cryptlib.h | ||
20 | @@ -2,12 +2,6 @@ | ||
21 | # define CRYPTLIB_H | ||
22 | |||
23 | #include <linux/version.h> | ||
24 | - | ||
25 | -struct cryptodev_result { | ||
26 | - struct completion completion; | ||
27 | - int err; | ||
28 | -}; | ||
29 | - | ||
30 | #include "cipherapi.h" | ||
31 | |||
32 | struct cipher_data { | ||
33 | diff --git a/cryptodev_int.h b/cryptodev_int.h | ||
34 | index d7660fa..c1879fd 100644 | ||
35 | --- a/cryptodev_int.h | ||
36 | +++ b/cryptodev_int.h | ||
37 | @@ -35,6 +35,11 @@ | ||
38 | #define ddebug(level, format, a...) dprintk(level, KERN_DEBUG, format, ##a) | ||
39 | |||
40 | |||
41 | +struct cryptodev_result { | ||
42 | + struct completion completion; | ||
43 | + int err; | ||
44 | +}; | ||
45 | + | ||
46 | extern int cryptodev_verbosity; | ||
47 | |||
48 | struct fcrypt { | ||
49 | -- | ||
50 | 2.7.4 | ||
51 | |||
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 @@ | |||
1 | From 00a8ac310a33767eac0a07e32597c1a6f467315f Mon Sep 17 00:00:00 2001 | ||
2 | From: Yashpal Dutta <yashpal.dutta@freescale.com> | ||
3 | Date: Fri, 7 Mar 2014 08:49:15 +0545 | ||
4 | Subject: [PATCH 07/38] RCU stall fixed in PKC asynchronous interface | ||
5 | |||
6 | Upstream-status: Pending | ||
7 | |||
8 | Signed-off-by: Yashpal Dutta <yashpal.dutta@freescale.com> | ||
9 | --- | ||
10 | ioctl.c | 23 +++++++++++------------ | ||
11 | main.c | 43 +++++++++++++++++++++++++++---------------- | ||
12 | 2 files changed, 38 insertions(+), 28 deletions(-) | ||
13 | |||
14 | diff --git a/ioctl.c b/ioctl.c | ||
15 | index 1f0741a..e4e16a8 100644 | ||
16 | --- a/ioctl.c | ||
17 | +++ b/ioctl.c | ||
18 | @@ -108,10 +108,9 @@ void cryptodev_complete_asym(struct crypto_async_request *req, int err) | ||
19 | complete(&res->completion); | ||
20 | } else { | ||
21 | struct crypt_priv *pcr = pkc->priv; | ||
22 | - unsigned long flags; | ||
23 | - spin_lock_irqsave(&pcr->completion_lock, flags); | ||
24 | + spin_lock_bh(&pcr->completion_lock); | ||
25 | list_add_tail(&pkc->list, &pcr->asym_completed_list); | ||
26 | - spin_unlock_irqrestore(&pcr->completion_lock, flags); | ||
27 | + spin_unlock_bh(&pcr->completion_lock); | ||
28 | /* wake for POLLIN */ | ||
29 | wake_up_interruptible(&pcr->user_waiter); | ||
30 | } | ||
31 | @@ -958,7 +957,7 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | ||
32 | case CIOCASYMFEAT: | ||
33 | return put_user(CRF_MOD_EXP_CRT | CRF_MOD_EXP | CRF_DSA_SIGN | | ||
34 | CRF_DSA_VERIFY | CRF_DH_COMPUTE_KEY | | ||
35 | - CRF_DSA_GENERATE_KEY, p); | ||
36 | + CRF_DSA_GENERATE_KEY | CRF_DH_GENERATE_KEY, p); | ||
37 | case CRIOGET: | ||
38 | fd = clonefd(filp); | ||
39 | ret = put_user(fd, p); | ||
40 | @@ -997,7 +996,7 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | ||
41 | case CIOCKEY: | ||
42 | { | ||
43 | struct cryptodev_pkc *pkc = | ||
44 | - kzalloc(sizeof(struct cryptodev_pkc), GFP_KERNEL); | ||
45 | + kmalloc(sizeof(struct cryptodev_pkc), GFP_KERNEL); | ||
46 | |||
47 | if (!pkc) | ||
48 | return -ENOMEM; | ||
49 | @@ -1053,7 +1052,7 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | ||
50 | case CIOCASYMASYNCRYPT: | ||
51 | { | ||
52 | struct cryptodev_pkc *pkc = | ||
53 | - kzalloc(sizeof(struct cryptodev_pkc), GFP_KERNEL); | ||
54 | + kmalloc(sizeof(struct cryptodev_pkc), GFP_KERNEL); | ||
55 | ret = kop_from_user(&pkc->kop, arg); | ||
56 | |||
57 | if (unlikely(ret)) | ||
58 | @@ -1070,13 +1069,12 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | ||
59 | case CIOCASYMFETCHCOOKIE: | ||
60 | { | ||
61 | struct cryptodev_pkc *pkc; | ||
62 | - unsigned long flags; | ||
63 | int i; | ||
64 | struct pkc_cookie_list_s cookie_list; | ||
65 | |||
66 | - spin_lock_irqsave(&pcr->completion_lock, flags); | ||
67 | cookie_list.cookie_available = 0; | ||
68 | for (i = 0; i < MAX_COOKIES; i++) { | ||
69 | + spin_lock_bh(&pcr->completion_lock); | ||
70 | if (!list_empty(&pcr->asym_completed_list)) { | ||
71 | /* Run a loop in the list for upto elements | ||
72 | and copy their response back */ | ||
73 | @@ -1084,6 +1082,7 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | ||
74 | list_first_entry(&pcr->asym_completed_list, | ||
75 | struct cryptodev_pkc, list); | ||
76 | list_del(&pkc->list); | ||
77 | + spin_unlock_bh(&pcr->completion_lock); | ||
78 | ret = crypto_async_fetch_asym(pkc); | ||
79 | if (!ret) { | ||
80 | cookie_list.cookie_available++; | ||
81 | @@ -1093,10 +1092,10 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | ||
82 | } | ||
83 | kfree(pkc); | ||
84 | } else { | ||
85 | + spin_unlock_bh(&pcr->completion_lock); | ||
86 | break; | ||
87 | } | ||
88 | } | ||
89 | - spin_unlock_irqrestore(&pcr->completion_lock, flags); | ||
90 | |||
91 | /* Reflect the updated request to user-space */ | ||
92 | if (cookie_list.cookie_available) | ||
93 | @@ -1386,14 +1385,13 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) | ||
94 | case COMPAT_CIOCASYMFETCHCOOKIE: | ||
95 | { | ||
96 | struct cryptodev_pkc *pkc; | ||
97 | - unsigned long flags; | ||
98 | int i = 0; | ||
99 | struct compat_pkc_cookie_list_s cookie_list; | ||
100 | |||
101 | - spin_lock_irqsave(&pcr->completion_lock, flags); | ||
102 | cookie_list.cookie_available = 0; | ||
103 | |||
104 | for (i = 0; i < MAX_COOKIES; i++) { | ||
105 | + spin_lock_bh(&pcr->completion_lock); | ||
106 | if (!list_empty(&pcr->asym_completed_list)) { | ||
107 | /* Run a loop in the list for upto elements | ||
108 | and copy their response back */ | ||
109 | @@ -1401,6 +1399,7 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) | ||
110 | list_first_entry(&pcr->asym_completed_list, | ||
111 | struct cryptodev_pkc, list); | ||
112 | list_del(&pkc->list); | ||
113 | + spin_unlock_bh(&pcr->completion_lock); | ||
114 | ret = crypto_async_fetch_asym(pkc); | ||
115 | if (!ret) { | ||
116 | cookie_list.cookie_available++; | ||
117 | @@ -1409,10 +1408,10 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) | ||
118 | } | ||
119 | kfree(pkc); | ||
120 | } else { | ||
121 | + spin_unlock_bh(&pcr->completion_lock); | ||
122 | break; | ||
123 | } | ||
124 | } | ||
125 | - spin_unlock_irqrestore(&pcr->completion_lock, flags); | ||
126 | |||
127 | /* Reflect the updated request to user-space */ | ||
128 | if (cookie_list.cookie_available) | ||
129 | diff --git a/main.c b/main.c | ||
130 | index c901bc7..2747706 100644 | ||
131 | --- a/main.c | ||
132 | +++ b/main.c | ||
133 | @@ -215,7 +215,9 @@ int crypto_kop_dsasign(struct cryptodev_pkc *pkc) | ||
134 | pkc_req->type = DSA_SIGN; | ||
135 | } | ||
136 | |||
137 | - buf = kzalloc(buf_size, GFP_DMA); | ||
138 | + buf = kmalloc(buf_size, GFP_DMA); | ||
139 | + if (!buf) | ||
140 | + return -ENOMEM; | ||
141 | |||
142 | dsa_req->q = buf; | ||
143 | dsa_req->r = dsa_req->q + dsa_req->q_len; | ||
144 | @@ -298,7 +300,9 @@ int crypto_kop_dsaverify(struct cryptodev_pkc *pkc) | ||
145 | pkc_req->type = DSA_VERIFY; | ||
146 | } | ||
147 | |||
148 | - buf = kzalloc(buf_size, GFP_DMA); | ||
149 | + buf = kmalloc(buf_size, GFP_DMA); | ||
150 | + if (!buf) | ||
151 | + return -ENOMEM; | ||
152 | |||
153 | dsa_req->q = buf; | ||
154 | dsa_req->r = dsa_req->q + dsa_req->q_len; | ||
155 | @@ -378,7 +382,7 @@ int crypto_kop_keygen(struct cryptodev_pkc *pkc) | ||
156 | pkc_req->curve_type = cop->curve_type; | ||
157 | } | ||
158 | |||
159 | - buf = kzalloc(buf_size, GFP_DMA); | ||
160 | + buf = kmalloc(buf_size, GFP_DMA); | ||
161 | if (!buf) | ||
162 | return -ENOMEM; | ||
163 | |||
164 | @@ -390,25 +394,28 @@ int crypto_kop_keygen(struct cryptodev_pkc *pkc) | ||
165 | copy_from_user(key_req->q, cop->crk_param[0].crp_p, key_req->q_len); | ||
166 | copy_from_user(key_req->r, cop->crk_param[1].crp_p, key_req->r_len); | ||
167 | copy_from_user(key_req->g, cop->crk_param[2].crp_p, key_req->g_len); | ||
168 | - if (cop->crk_iparams == 3) { | ||
169 | - copy_from_user(key_req->pub_key, cop->crk_param[3].crp_p, | ||
170 | - key_req->pub_key_len); | ||
171 | - copy_from_user(key_req->priv_key, cop->crk_param[4].crp_p, | ||
172 | - key_req->priv_key_len); | ||
173 | - } else { | ||
174 | + if (cop->crk_iparams == 4) { | ||
175 | key_req->ab = key_req->priv_key + key_req->priv_key_len; | ||
176 | copy_from_user(key_req->ab, cop->crk_param[3].crp_p, | ||
177 | key_req->ab_len); | ||
178 | - copy_from_user(key_req->pub_key, cop->crk_param[4].crp_p, | ||
179 | - key_req->pub_key_len); | ||
180 | - copy_from_user(key_req->priv_key, cop->crk_param[5].crp_p, | ||
181 | - key_req->priv_key_len); | ||
182 | } | ||
183 | |||
184 | rc = cryptodev_pkc_offload(pkc); | ||
185 | if (pkc->type == SYNCHRONOUS) { | ||
186 | if (rc) | ||
187 | goto err; | ||
188 | + | ||
189 | + if (cop->crk_iparams == 4) { | ||
190 | + copy_to_user(cop->crk_param[4].crp_p, key_req->pub_key, | ||
191 | + key_req->pub_key_len); | ||
192 | + copy_to_user(cop->crk_param[5].crp_p, key_req->priv_key, | ||
193 | + key_req->priv_key_len); | ||
194 | + } else { | ||
195 | + copy_to_user(cop->crk_param[3].crp_p, key_req->pub_key, | ||
196 | + key_req->pub_key_len); | ||
197 | + copy_to_user(cop->crk_param[4].crp_p, | ||
198 | + key_req->priv_key, key_req->priv_key_len); | ||
199 | + } | ||
200 | } else { | ||
201 | if (rc != -EINPROGRESS && !rc) | ||
202 | goto err; | ||
203 | @@ -447,7 +454,9 @@ int crypto_kop_dh_key(struct cryptodev_pkc *pkc) | ||
204 | pkc_req->type = DH_COMPUTE_KEY; | ||
205 | } | ||
206 | buf_size += dh_req->z_len; | ||
207 | - buf = kzalloc(buf_size, GFP_DMA); | ||
208 | + buf = kmalloc(buf_size, GFP_DMA); | ||
209 | + if (!buf) | ||
210 | + return -ENOMEM; | ||
211 | dh_req->q = buf; | ||
212 | dh_req->s = dh_req->q + dh_req->q_len; | ||
213 | dh_req->pub_key = dh_req->s + dh_req->s_len; | ||
214 | @@ -508,9 +517,11 @@ int crypto_modexp_crt(struct cryptodev_pkc *pkc) | ||
215 | rsa_req->dq_len = (cop->crk_param[4].crp_nbits + 7)/8; | ||
216 | rsa_req->c_len = (cop->crk_param[5].crp_nbits + 7)/8; | ||
217 | rsa_req->f_len = (cop->crk_param[6].crp_nbits + 7)/8; | ||
218 | - buf = kzalloc(rsa_req->p_len + rsa_req->q_len + rsa_req->f_len + | ||
219 | + buf = kmalloc(rsa_req->p_len + rsa_req->q_len + rsa_req->f_len + | ||
220 | rsa_req->dp_len + rsa_req->dp_len + rsa_req->c_len + | ||
221 | rsa_req->g_len, GFP_DMA); | ||
222 | + if (!buf) | ||
223 | + return -ENOMEM; | ||
224 | rsa_req->p = buf; | ||
225 | rsa_req->q = rsa_req->p + rsa_req->p_len; | ||
226 | rsa_req->g = rsa_req->q + rsa_req->q_len; | ||
227 | @@ -563,7 +574,7 @@ int crypto_bn_modexp(struct cryptodev_pkc *pkc) | ||
228 | rsa_req->e_len = (cop->crk_param[1].crp_nbits + 7)/8; | ||
229 | rsa_req->n_len = (cop->crk_param[2].crp_nbits + 7)/8; | ||
230 | rsa_req->g_len = (cop->crk_param[3].crp_nbits + 7)/8; | ||
231 | - buf = kzalloc(rsa_req->f_len + rsa_req->e_len + rsa_req->n_len | ||
232 | + buf = kmalloc(rsa_req->f_len + rsa_req->e_len + rsa_req->n_len | ||
233 | + rsa_req->g_len, GFP_DMA); | ||
234 | if (!buf) | ||
235 | return -ENOMEM; | ||
236 | -- | ||
237 | 2.7.0 | ||
238 | |||
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 @@ | |||
1 | From 6213ae5228a2ff0bb3521474ae37effda95a5d46 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Fri, 12 May 2017 17:04:40 +0300 | ||
4 | Subject: [PATCH 7/9] add support for RSA public and private key operations | ||
5 | |||
6 | Only form 1 support is added with this patch. To maintain | ||
7 | compatibility with OpenBSD we need to reverse bignum buffers before | ||
8 | giving them to the kernel. This adds an artificial performance | ||
9 | penalty that can be resolved only with a CIOCKEY extension in | ||
10 | cryptodev API. | ||
11 | |||
12 | As of Linux kernel 4.12 it is not possible to give to the kernel | ||
13 | directly a pointer to a RSA key structure and must resort to a BER | ||
14 | encoding scheme. | ||
15 | |||
16 | Support for private keys in form 3 (CRT) must wait for updates and | ||
17 | fixes in Linux kernel crypto API. | ||
18 | |||
19 | Known issue: | ||
20 | Kernels <= v4.7 strip leading zeros from the result and we get padding | ||
21 | errors from Openssl: RSA_EAY_PUBLIC_DECRYPT: padding check failed | ||
22 | (Fixed with kernel commit "crypto: rsa - Generate fixed-length output" | ||
23 | 9b45b7bba3d22de52e09df63c50f390a193a3f53) | ||
24 | |||
25 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
26 | --- | ||
27 | cryptlib.c | 234 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
28 | cryptlib.h | 4 +- | ||
29 | cryptodev_int.h | 17 ++++ | ||
30 | ioctl.c | 17 +++- | ||
31 | main.c | 42 ++++++++++ | ||
32 | 5 files changed, 312 insertions(+), 2 deletions(-) | ||
33 | |||
34 | diff --git a/cryptlib.c b/cryptlib.c | ||
35 | index 2c6028e..1c044a4 100644 | ||
36 | --- a/cryptlib.c | ||
37 | +++ b/cryptlib.c | ||
38 | @@ -37,6 +37,10 @@ | ||
39 | #include <crypto/authenc.h> | ||
40 | #include "cryptodev_int.h" | ||
41 | #include "cipherapi.h" | ||
42 | +#if (LINUX_VERSION_CODE > KERNEL_VERSION(4, 3, 0)) | ||
43 | +#include <linux/asn1_ber_bytecode.h> | ||
44 | +#include <crypto/akcipher.h> | ||
45 | +#endif | ||
46 | |||
47 | extern const struct crypto_type crypto_givcipher_type; | ||
48 | |||
49 | @@ -435,3 +439,233 @@ int cryptodev_hash_final(struct hash_data *hdata, void *output) | ||
50 | return waitfor(&hdata->async.result, ret); | ||
51 | } | ||
52 | |||
53 | +#if (LINUX_VERSION_CODE > KERNEL_VERSION(4, 3, 0)) | ||
54 | +/* This function is necessary because the bignums in Linux kernel are MSB first | ||
55 | + * (big endian) as opposed to LSB first as OpenBSD crypto layer uses */ | ||
56 | +void reverse_buf(uint8_t *buf, size_t sz) | ||
57 | +{ | ||
58 | + int i; | ||
59 | + uint8_t *end; | ||
60 | + uint8_t tmp; | ||
61 | + | ||
62 | + end = buf + sz; | ||
63 | + | ||
64 | + for (i = 0; i < sz/2; i++) { | ||
65 | + end--; | ||
66 | + | ||
67 | + tmp = *buf; | ||
68 | + *buf = *end; | ||
69 | + *end = tmp; | ||
70 | + | ||
71 | + buf++; | ||
72 | + } | ||
73 | +} | ||
74 | + | ||
75 | +int ber_wr_tag(uint8_t **ber_ptr, uint8_t tag) | ||
76 | +{ | ||
77 | + **ber_ptr = tag; | ||
78 | + *ber_ptr += 1; | ||
79 | + | ||
80 | + return 0; | ||
81 | +} | ||
82 | + | ||
83 | +int ber_wr_len(uint8_t **ber_ptr, size_t len, size_t sz) | ||
84 | +{ | ||
85 | + if (len < 127) { | ||
86 | + **ber_ptr = len; | ||
87 | + *ber_ptr += 1; | ||
88 | + } else { | ||
89 | + size_t sz_save = sz; | ||
90 | + | ||
91 | + sz--; | ||
92 | + **ber_ptr = 0x80 | sz; | ||
93 | + | ||
94 | + while (sz > 0) { | ||
95 | + *(*ber_ptr + sz) = len & 0xff; | ||
96 | + len >>= 8; | ||
97 | + sz--; | ||
98 | + } | ||
99 | + *ber_ptr += sz_save; | ||
100 | + } | ||
101 | + | ||
102 | + return 0; | ||
103 | +} | ||
104 | + | ||
105 | +int ber_wr_int(uint8_t **ber_ptr, uint8_t *crp_p, size_t sz) | ||
106 | +{ | ||
107 | + int ret; | ||
108 | + | ||
109 | + ret = copy_from_user(*ber_ptr, crp_p, sz); | ||
110 | + reverse_buf(*ber_ptr, sz); | ||
111 | + | ||
112 | + *ber_ptr += sz; | ||
113 | + | ||
114 | + return ret; | ||
115 | +} | ||
116 | + | ||
117 | +/* calculate the size of the length field itself in BER encoding */ | ||
118 | +size_t ber_enc_len(size_t len) | ||
119 | +{ | ||
120 | + size_t sz; | ||
121 | + | ||
122 | + sz = 1; | ||
123 | + if (len > 127) { /* long encoding */ | ||
124 | + while (len != 0) { | ||
125 | + len >>= 8; | ||
126 | + sz++; | ||
127 | + } | ||
128 | + } | ||
129 | + | ||
130 | + return sz; | ||
131 | +} | ||
132 | + | ||
133 | +void *cryptodev_alloc_rsa_pub_key(struct kernel_crypt_pkop *pkop, | ||
134 | + uint32_t *key_len) | ||
135 | +{ | ||
136 | + struct crypt_kop *cop = &pkop->pkop; | ||
137 | + uint8_t *ber_key; | ||
138 | + uint8_t *ber_ptr; | ||
139 | + uint32_t ber_key_len; | ||
140 | + size_t s_sz; | ||
141 | + size_t e_sz; | ||
142 | + size_t n_sz; | ||
143 | + size_t s_enc_len; | ||
144 | + size_t e_enc_len; | ||
145 | + size_t n_enc_len; | ||
146 | + int err; | ||
147 | + | ||
148 | + /* BER public key format: | ||
149 | + * SEQUENCE TAG 1 byte | ||
150 | + * SEQUENCE LENGTH s_enc_len bytes | ||
151 | + * INTEGER TAG 1 byte | ||
152 | + * INTEGER LENGTH n_enc_len bytes | ||
153 | + * INTEGER (n modulus) n_sz bytes | ||
154 | + * INTEGER TAG 1 byte | ||
155 | + * INTEGER LENGTH e_enc_len bytes | ||
156 | + * INTEGER (e exponent) e_sz bytes | ||
157 | + */ | ||
158 | + | ||
159 | + e_sz = (cop->crk_param[1].crp_nbits + 7)/8; | ||
160 | + n_sz = (cop->crk_param[2].crp_nbits + 7)/8; | ||
161 | + | ||
162 | + e_enc_len = ber_enc_len(e_sz); | ||
163 | + n_enc_len = ber_enc_len(n_sz); | ||
164 | + | ||
165 | + /* | ||
166 | + * Sequence length is the size of all the fields following the sequence | ||
167 | + * tag, added together. The two added bytes account for the two INT | ||
168 | + * tags in the Public Key sequence | ||
169 | + */ | ||
170 | + s_sz = e_sz + e_enc_len + n_sz + n_enc_len + 2; | ||
171 | + s_enc_len = ber_enc_len(s_sz); | ||
172 | + | ||
173 | + /* The added byte accounts for the SEQ tag at the start of the key */ | ||
174 | + ber_key_len = s_sz + s_enc_len + 1; | ||
175 | + | ||
176 | + /* Linux asn1_ber_decoder doesn't like keys that are too large */ | ||
177 | + if (ber_key_len > 65535) { | ||
178 | + return NULL; | ||
179 | + } | ||
180 | + | ||
181 | + ber_key = kmalloc(ber_key_len, GFP_DMA); | ||
182 | + if (!ber_key) { | ||
183 | + return NULL; | ||
184 | + } | ||
185 | + | ||
186 | + ber_ptr = ber_key; | ||
187 | + | ||
188 | + err = ber_wr_tag(&ber_ptr, _tag(UNIV, CONS, SEQ)) || | ||
189 | + ber_wr_len(&ber_ptr, s_sz, s_enc_len) || | ||
190 | + ber_wr_tag(&ber_ptr, _tag(UNIV, PRIM, INT)) || | ||
191 | + ber_wr_len(&ber_ptr, n_sz, n_enc_len) || | ||
192 | + ber_wr_int(&ber_ptr, cop->crk_param[2].crp_p, n_sz) || | ||
193 | + ber_wr_tag(&ber_ptr, _tag(UNIV, PRIM, INT)) || | ||
194 | + ber_wr_len(&ber_ptr, e_sz, e_enc_len) || | ||
195 | + ber_wr_int(&ber_ptr, cop->crk_param[1].crp_p, e_sz); | ||
196 | + if (err != 0) { | ||
197 | + goto free_key; | ||
198 | + } | ||
199 | + | ||
200 | + *key_len = ber_key_len; | ||
201 | + return ber_key; | ||
202 | + | ||
203 | +free_key: | ||
204 | + kfree(ber_key); | ||
205 | + return NULL; | ||
206 | +} | ||
207 | + | ||
208 | +int crypto_bn_modexp(struct kernel_crypt_pkop *pkop) | ||
209 | +{ | ||
210 | + struct crypt_kop *cop = &pkop->pkop; | ||
211 | + uint8_t *ber_key; | ||
212 | + uint32_t ber_key_len; | ||
213 | + size_t m_sz; | ||
214 | + size_t c_sz; | ||
215 | + size_t c_sz_max; | ||
216 | + uint8_t *m_buf; | ||
217 | + uint8_t *c_buf; | ||
218 | + struct scatterlist src; | ||
219 | + struct scatterlist dst; | ||
220 | + int err; | ||
221 | + | ||
222 | + ber_key = cryptodev_alloc_rsa_pub_key(pkop, &ber_key_len); | ||
223 | + if (!ber_key) { | ||
224 | + return -ENOMEM; | ||
225 | + } | ||
226 | + | ||
227 | + err = crypto_akcipher_set_pub_key(pkop->s, ber_key, ber_key_len); | ||
228 | + if (err != 0) { | ||
229 | + goto free_key; | ||
230 | + } | ||
231 | + | ||
232 | + m_sz = (cop->crk_param[0].crp_nbits + 7)/8; | ||
233 | + c_sz = (cop->crk_param[3].crp_nbits + 7)/8; | ||
234 | + | ||
235 | + m_buf = kmalloc(m_sz, GFP_DMA); | ||
236 | + if (!m_buf) { | ||
237 | + err = -ENOMEM; | ||
238 | + goto free_key; | ||
239 | + } | ||
240 | + | ||
241 | + err = copy_from_user(m_buf, cop->crk_param[0].crp_p, m_sz); | ||
242 | + if (err != 0) { | ||
243 | + goto free_m_buf; | ||
244 | + } | ||
245 | + reverse_buf(m_buf, m_sz); | ||
246 | + | ||
247 | + c_sz_max = crypto_akcipher_maxsize(pkop->s); | ||
248 | + if (c_sz > c_sz_max) { | ||
249 | + err = -EINVAL; | ||
250 | + goto free_m_buf; | ||
251 | + } | ||
252 | + | ||
253 | + c_buf = kzalloc(c_sz_max, GFP_KERNEL); | ||
254 | + if (!c_buf) { | ||
255 | + goto free_m_buf; | ||
256 | + } | ||
257 | + | ||
258 | + sg_init_one(&src, m_buf, m_sz); | ||
259 | + sg_init_one(&dst, c_buf, c_sz); | ||
260 | + | ||
261 | + init_completion(&pkop->result.completion); | ||
262 | + akcipher_request_set_callback(pkop->req, 0, | ||
263 | + cryptodev_complete, &pkop->result); | ||
264 | + akcipher_request_set_crypt(pkop->req, &src, &dst, m_sz, c_sz); | ||
265 | + | ||
266 | + err = crypto_akcipher_encrypt(pkop->req); | ||
267 | + err = waitfor(&pkop->result, err); | ||
268 | + | ||
269 | + if (err == 0) { | ||
270 | + reverse_buf(c_buf, c_sz); | ||
271 | + err = copy_to_user(cop->crk_param[3].crp_p, c_buf, c_sz); | ||
272 | + } | ||
273 | + | ||
274 | + kfree(c_buf); | ||
275 | +free_m_buf: | ||
276 | + kfree(m_buf); | ||
277 | +free_key: | ||
278 | + kfree(ber_key); | ||
279 | + | ||
280 | + return err; | ||
281 | +} | ||
282 | +#endif | ||
283 | diff --git a/cryptlib.h b/cryptlib.h | ||
284 | index 48fe9bd..f909c34 100644 | ||
285 | --- a/cryptlib.h | ||
286 | +++ b/cryptlib.h | ||
287 | @@ -95,6 +95,8 @@ int cryptodev_hash_reset(struct hash_data *hdata); | ||
288 | void cryptodev_hash_deinit(struct hash_data *hdata); | ||
289 | int cryptodev_hash_init(struct hash_data *hdata, const char *alg_name, | ||
290 | int hmac_mode, void *mackey, size_t mackeylen); | ||
291 | - | ||
292 | +#if (LINUX_VERSION_CODE > KERNEL_VERSION(4, 3, 0)) | ||
293 | +int crypto_bn_modexp(struct kernel_crypt_pkop *pkop); | ||
294 | +#endif | ||
295 | |||
296 | #endif | ||
297 | diff --git a/cryptodev_int.h b/cryptodev_int.h | ||
298 | index c1879fd..7860c39 100644 | ||
299 | --- a/cryptodev_int.h | ||
300 | +++ b/cryptodev_int.h | ||
301 | @@ -19,6 +19,10 @@ | ||
302 | #include <linux/scatterlist.h> | ||
303 | #include <crypto/cryptodev.h> | ||
304 | #include <crypto/aead.h> | ||
305 | +#if (LINUX_VERSION_CODE > KERNEL_VERSION(4, 3, 0)) | ||
306 | +#include <crypto/internal/rsa.h> | ||
307 | +#endif | ||
308 | + | ||
309 | |||
310 | #define PFX "cryptodev: " | ||
311 | #define dprintk(level, severity, format, a...) \ | ||
312 | @@ -111,6 +115,18 @@ struct kernel_crypt_auth_op { | ||
313 | struct mm_struct *mm; | ||
314 | }; | ||
315 | |||
316 | +#if (LINUX_VERSION_CODE > KERNEL_VERSION(4, 3, 0)) | ||
317 | +struct kernel_crypt_pkop { | ||
318 | + struct crypt_kop pkop; | ||
319 | + | ||
320 | + struct crypto_akcipher *s; /* Transform pointer from CryptoAPI */ | ||
321 | + struct akcipher_request *req; /* PKC request allocated from CryptoAPI */ | ||
322 | + struct cryptodev_result result; /* updated by completion handler */ | ||
323 | +}; | ||
324 | + | ||
325 | +int crypto_run_asym(struct kernel_crypt_pkop *pkop); | ||
326 | +#endif | ||
327 | + | ||
328 | /* auth */ | ||
329 | |||
330 | int kcaop_from_user(struct kernel_crypt_auth_op *kcop, | ||
331 | @@ -122,6 +138,7 @@ int crypto_run(struct fcrypt *fcr, struct kernel_crypt_op *kcop); | ||
332 | |||
333 | #include <cryptlib.h> | ||
334 | |||
335 | + | ||
336 | /* other internal structs */ | ||
337 | struct csession { | ||
338 | struct list_head entry; | ||
339 | diff --git a/ioctl.c b/ioctl.c | ||
340 | index db7207a..8b0df4e 100644 | ||
341 | --- a/ioctl.c | ||
342 | +++ b/ioctl.c | ||
343 | @@ -810,6 +810,9 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | ||
344 | struct session_op sop; | ||
345 | struct kernel_crypt_op kcop; | ||
346 | struct kernel_crypt_auth_op kcaop; | ||
347 | +#if (LINUX_VERSION_CODE > KERNEL_VERSION(4, 3, 0)) | ||
348 | + struct kernel_crypt_pkop pkop; | ||
349 | +#endif | ||
350 | struct crypt_priv *pcr = filp->private_data; | ||
351 | struct fcrypt *fcr; | ||
352 | struct session_info_op siop; | ||
353 | @@ -823,7 +826,11 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | ||
354 | |||
355 | switch (cmd) { | ||
356 | case CIOCASYMFEAT: | ||
357 | - return put_user(0, p); | ||
358 | + ses = 0; | ||
359 | + if (crypto_has_alg("rsa", 0, 0)) { | ||
360 | + ses = CRF_MOD_EXP; | ||
361 | + } | ||
362 | + return put_user(ses, p); | ||
363 | case CRIOGET: | ||
364 | fd = clonefd(filp); | ||
365 | ret = put_user(fd, p); | ||
366 | @@ -859,6 +866,14 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | ||
367 | if (unlikely(ret)) | ||
368 | return ret; | ||
369 | return copy_to_user(arg, &siop, sizeof(siop)); | ||
370 | +#if (LINUX_VERSION_CODE > KERNEL_VERSION(4, 3, 0)) | ||
371 | + case CIOCKEY: | ||
372 | + ret = copy_from_user(&pkop.pkop, arg, sizeof(struct crypt_kop)); | ||
373 | + if (ret == 0) { | ||
374 | + ret = crypto_run_asym(&pkop); | ||
375 | + } | ||
376 | + return ret; | ||
377 | +#endif | ||
378 | case CIOCCRYPT: | ||
379 | if (unlikely(ret = kcop_from_user(&kcop, fcr, arg))) { | ||
380 | dwarning(1, "Error copying from user"); | ||
381 | diff --git a/main.c b/main.c | ||
382 | index 57e5c38..2bfe6f0 100644 | ||
383 | --- a/main.c | ||
384 | +++ b/main.c | ||
385 | @@ -48,6 +48,9 @@ | ||
386 | #include "zc.h" | ||
387 | #include "cryptlib.h" | ||
388 | #include "version.h" | ||
389 | +#if (LINUX_VERSION_CODE > KERNEL_VERSION(4, 3, 0)) | ||
390 | +#include <crypto/akcipher.h> | ||
391 | +#endif | ||
392 | |||
393 | /* This file contains the traditional operations of encryption | ||
394 | * and hashing of /dev/crypto. | ||
395 | @@ -265,3 +268,42 @@ out_unlock: | ||
396 | crypto_put_session(ses_ptr); | ||
397 | return ret; | ||
398 | } | ||
399 | + | ||
400 | +#if (LINUX_VERSION_CODE > KERNEL_VERSION(4, 3, 0)) | ||
401 | +int crypto_run_asym(struct kernel_crypt_pkop *pkop) | ||
402 | +{ | ||
403 | + int err; | ||
404 | + | ||
405 | + pkop->s = crypto_alloc_akcipher("rsa", 0, 0); | ||
406 | + if (IS_ERR(pkop->s)) { | ||
407 | + return PTR_ERR(pkop->s); | ||
408 | + } | ||
409 | + | ||
410 | + pkop->req = akcipher_request_alloc(pkop->s, GFP_KERNEL); | ||
411 | + if (pkop->req == NULL) { | ||
412 | + err = -ENOMEM; | ||
413 | + goto out_free_tfm; | ||
414 | + } | ||
415 | + | ||
416 | + switch (pkop->pkop.crk_op) { | ||
417 | + case CRK_MOD_EXP: /* RSA_PUB or PRIV form 1 */ | ||
418 | + if (pkop->pkop.crk_iparams != 3 && pkop->pkop.crk_oparams != 1) { | ||
419 | + err = -EINVAL; | ||
420 | + goto out_free_req; | ||
421 | + } | ||
422 | + err = crypto_bn_modexp(pkop); | ||
423 | + break; | ||
424 | + default: | ||
425 | + err = -EINVAL; | ||
426 | + break; | ||
427 | + } | ||
428 | + | ||
429 | +out_free_req: | ||
430 | + kfree(pkop->req); | ||
431 | + | ||
432 | +out_free_tfm: | ||
433 | + crypto_free_akcipher(pkop->s); | ||
434 | + | ||
435 | + return err; | ||
436 | +} | ||
437 | +#endif | ||
438 | -- | ||
439 | 2.7.4 | ||
440 | |||
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 @@ | |||
1 | From a2cbb5fcc2d6f3734b5ed2826e828d852cfdf8ba Mon Sep 17 00:00:00 2001 | ||
2 | From: Hou Zhiqiang <B48286@freescale.com> | ||
3 | Date: Wed, 19 Mar 2014 14:02:46 +0800 | ||
4 | Subject: [PATCH 08/38] Add RSA Key generation offloading | ||
5 | |||
6 | Upstream-status: Pending | ||
7 | |||
8 | Signed-off-by: Hou Zhiqiang <B48286@freescale.com> | ||
9 | Tested-by: Cristian Stoica <cristian.stoica@freescale.com> | ||
10 | --- | ||
11 | cryptlib.c | 1 + | ||
12 | crypto/cryptodev.h | 2 ++ | ||
13 | ioctl.c | 3 +- | ||
14 | main.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++- | ||
15 | 4 files changed, 84 insertions(+), 2 deletions(-) | ||
16 | |||
17 | diff --git a/cryptlib.c b/cryptlib.c | ||
18 | index 47cd568..4dd1847 100644 | ||
19 | --- a/cryptlib.c | ||
20 | +++ b/cryptlib.c | ||
21 | @@ -441,6 +441,7 @@ int cryptodev_pkc_offload(struct cryptodev_pkc *pkc) | ||
22 | struct pkc_request *pkc_req = &pkc->req, *pkc_requested; | ||
23 | |||
24 | switch (pkc_req->type) { | ||
25 | + case RSA_KEYGEN: | ||
26 | case RSA_PUB: | ||
27 | case RSA_PRIV_FORM1: | ||
28 | case RSA_PRIV_FORM2: | ||
29 | diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h | ||
30 | index 275a55c..d0cc542 100644 | ||
31 | --- a/crypto/cryptodev.h | ||
32 | +++ b/crypto/cryptodev.h | ||
33 | @@ -270,6 +270,7 @@ enum cryptodev_crk_op_t { | ||
34 | CRK_DH_COMPUTE_KEY = 4, | ||
35 | CRK_DSA_GENERATE_KEY = 5, | ||
36 | CRK_DH_GENERATE_KEY = 6, | ||
37 | + CRK_RSA_GENERATE_KEY = 7, | ||
38 | CRK_ALGORITHM_ALL | ||
39 | }; | ||
40 | |||
41 | @@ -279,6 +280,7 @@ enum cryptodev_crk_op_t { | ||
42 | */ | ||
43 | #define CRF_MOD_EXP (1 << CRK_MOD_EXP) | ||
44 | #define CRF_MOD_EXP_CRT (1 << CRK_MOD_EXP_CRT) | ||
45 | +#define CRF_RSA_GENERATE_KEY (1 << CRK_RSA_GENERATE_KEY) | ||
46 | #define CRF_DSA_SIGN (1 << CRK_DSA_SIGN) | ||
47 | #define CRF_DSA_VERIFY (1 << CRK_DSA_VERIFY) | ||
48 | #define CRF_DH_COMPUTE_KEY (1 << CRK_DH_COMPUTE_KEY) | ||
49 | diff --git a/ioctl.c b/ioctl.c | ||
50 | index e4e16a8..3762a47 100644 | ||
51 | --- a/ioctl.c | ||
52 | +++ b/ioctl.c | ||
53 | @@ -957,7 +957,8 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | ||
54 | case CIOCASYMFEAT: | ||
55 | return put_user(CRF_MOD_EXP_CRT | CRF_MOD_EXP | CRF_DSA_SIGN | | ||
56 | CRF_DSA_VERIFY | CRF_DH_COMPUTE_KEY | | ||
57 | - CRF_DSA_GENERATE_KEY | CRF_DH_GENERATE_KEY, p); | ||
58 | + CRF_DSA_GENERATE_KEY | CRF_DH_GENERATE_KEY | | ||
59 | + CRF_RSA_GENERATE_KEY, p); | ||
60 | case CRIOGET: | ||
61 | fd = clonefd(filp); | ||
62 | ret = put_user(fd, p); | ||
63 | diff --git a/main.c b/main.c | ||
64 | index 2747706..14dcf40 100644 | ||
65 | --- a/main.c | ||
66 | +++ b/main.c | ||
67 | @@ -346,6 +346,82 @@ err: | ||
68 | return rc; | ||
69 | } | ||
70 | |||
71 | +int crypto_kop_rsa_keygen(struct cryptodev_pkc *pkc) | ||
72 | +{ | ||
73 | + struct kernel_crypt_kop *kop = &pkc->kop; | ||
74 | + struct crypt_kop *cop = &kop->kop; | ||
75 | + struct pkc_request *pkc_req; | ||
76 | + struct rsa_keygen_req_s *key_req; | ||
77 | + int rc, buf_size; | ||
78 | + uint8_t *buf; | ||
79 | + | ||
80 | + if (!cop->crk_param[0].crp_nbits || !cop->crk_param[1].crp_nbits || | ||
81 | + !cop->crk_param[2].crp_nbits || !cop->crk_param[3].crp_nbits || | ||
82 | + !cop->crk_param[4].crp_nbits || !cop->crk_param[5].crp_nbits || | ||
83 | + !cop->crk_param[6].crp_nbits) | ||
84 | + return -EINVAL; | ||
85 | + | ||
86 | + pkc_req = &pkc->req; | ||
87 | + pkc_req->type = RSA_KEYGEN; | ||
88 | + key_req = &pkc_req->req_u.rsa_keygen; | ||
89 | + key_req->n_len = (cop->crk_param[2].crp_nbits + 7)/8; | ||
90 | + key_req->p_len = (cop->crk_param[0].crp_nbits + 7) / 8; | ||
91 | + key_req->q_len = (cop->crk_param[1].crp_nbits + 7) / 8; | ||
92 | + key_req->n_len = (cop->crk_param[2].crp_nbits + 7) / 8; | ||
93 | + key_req->d_len = (cop->crk_param[3].crp_nbits + 7) / 8; | ||
94 | + key_req->dp_len = (cop->crk_param[4].crp_nbits + 7) / 8; | ||
95 | + key_req->dq_len = (cop->crk_param[5].crp_nbits + 7) / 8; | ||
96 | + key_req->c_len = (cop->crk_param[6].crp_nbits + 7) / 8; | ||
97 | + | ||
98 | + buf_size = key_req->p_len + key_req->q_len + key_req->n_len + | ||
99 | + key_req->d_len + key_req->dp_len + | ||
100 | + key_req->dq_len + key_req->c_len; | ||
101 | + | ||
102 | + buf = kmalloc(buf_size, GFP_DMA); | ||
103 | + if (!buf) | ||
104 | + return -ENOMEM; | ||
105 | + key_req->p = buf; | ||
106 | + key_req->q = key_req->p + key_req->p_len; | ||
107 | + key_req->n = key_req->q + key_req->q_len; | ||
108 | + key_req->d = key_req->n + key_req->n_len; | ||
109 | + key_req->dp = key_req->d + key_req->d_len; | ||
110 | + key_req->dq = key_req->dp + key_req->dp_len; | ||
111 | + key_req->c = key_req->dq + key_req->dq_len; | ||
112 | + | ||
113 | + rc = cryptodev_pkc_offload(pkc); | ||
114 | + | ||
115 | + if (pkc->type == SYNCHRONOUS) { | ||
116 | + if (rc) | ||
117 | + goto err; | ||
118 | + | ||
119 | + copy_to_user(cop->crk_param[0].crp_p, | ||
120 | + key_req->p, key_req->p_len); | ||
121 | + copy_to_user(cop->crk_param[1].crp_p, | ||
122 | + key_req->q, key_req->q_len); | ||
123 | + copy_to_user(cop->crk_param[2].crp_p, | ||
124 | + key_req->n, key_req->n_len); | ||
125 | + copy_to_user(cop->crk_param[3].crp_p, | ||
126 | + key_req->d, key_req->d_len); | ||
127 | + copy_to_user(cop->crk_param[4].crp_p, | ||
128 | + key_req->dp, key_req->dp_len); | ||
129 | + copy_to_user(cop->crk_param[5].crp_p, | ||
130 | + key_req->dq, key_req->dq_len); | ||
131 | + copy_to_user(cop->crk_param[6].crp_p, | ||
132 | + key_req->c, key_req->c_len); | ||
133 | + } else { | ||
134 | + if (rc != -EINPROGRESS && !rc) { | ||
135 | + printk("%s: Failed\n", __func__); | ||
136 | + goto err; | ||
137 | + } | ||
138 | + pkc->cookie = buf; | ||
139 | + return rc; | ||
140 | + } | ||
141 | +err: | ||
142 | + kfree(buf); | ||
143 | + return rc; | ||
144 | + | ||
145 | +} | ||
146 | + | ||
147 | int crypto_kop_keygen(struct cryptodev_pkc *pkc) | ||
148 | { | ||
149 | struct kernel_crypt_kop *kop = &pkc->kop; | ||
150 | @@ -385,7 +461,6 @@ int crypto_kop_keygen(struct cryptodev_pkc *pkc) | ||
151 | buf = kmalloc(buf_size, GFP_DMA); | ||
152 | if (!buf) | ||
153 | return -ENOMEM; | ||
154 | - | ||
155 | key_req->q = buf; | ||
156 | key_req->r = key_req->q + key_req->q_len; | ||
157 | key_req->g = key_req->r + key_req->r_len; | ||
158 | @@ -650,6 +725,9 @@ int crypto_run_asym(struct cryptodev_pkc *pkc) | ||
159 | goto err; | ||
160 | ret = crypto_kop_keygen(pkc); | ||
161 | break; | ||
162 | + case CRK_RSA_GENERATE_KEY: | ||
163 | + ret = crypto_kop_rsa_keygen(pkc); | ||
164 | + break; | ||
165 | } | ||
166 | err: | ||
167 | return ret; | ||
168 | -- | ||
169 | 2.7.0 | ||
170 | |||
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 @@ | |||
1 | From ec2529027a6565fdede79e7bda4a0232757acf70 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Wed, 14 Jun 2017 11:23:18 +0300 | ||
4 | Subject: [PATCH 8/9] check session flags early to avoid incorrect failure | ||
5 | modes | ||
6 | |||
7 | This verification of aead flag was incorrectly removed in | ||
8 | "refactoring: split big function to simplify maintainance" | ||
9 | 20dcf071bc3076ee7db9d603cfbe6a06e86c7d5f | ||
10 | resulting in an incorrect dispatching of functions. | ||
11 | |||
12 | Add back this check and at the same time remove the second check from | ||
13 | the called function which now becomes redundant. | ||
14 | Add another guard check for aead modes and reject not supported combinations. | ||
15 | |||
16 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
17 | --- | ||
18 | authenc.c | 11 +++++------ | ||
19 | 1 file changed, 5 insertions(+), 6 deletions(-) | ||
20 | |||
21 | diff --git a/authenc.c b/authenc.c | ||
22 | index 692951f..fc32f43 100644 | ||
23 | --- a/authenc.c | ||
24 | +++ b/authenc.c | ||
25 | @@ -643,10 +643,6 @@ static int crypto_auth_zc_tls(struct csession *ses_ptr, struct kernel_crypt_auth | ||
26 | struct scatterlist tmp; | ||
27 | int ret; | ||
28 | |||
29 | - if (unlikely(ses_ptr->cdata.aead != 0)) { | ||
30 | - return -EINVAL; | ||
31 | - } | ||
32 | - | ||
33 | if (unlikely(caop->auth_len > PAGE_SIZE)) { | ||
34 | derr(1, "auth data len is excessive."); | ||
35 | return -EINVAL; | ||
36 | @@ -787,10 +783,13 @@ __crypto_auth_run_zc(struct csession *ses_ptr, struct kernel_crypt_auth_op *kcao | ||
37 | |||
38 | if (caop->flags & COP_FLAG_AEAD_SRTP_TYPE) { | ||
39 | ret = crypto_auth_zc_srtp(ses_ptr, kcaop); | ||
40 | - } else if (caop->flags & COP_FLAG_AEAD_TLS_TYPE) { | ||
41 | + } else if (caop->flags & COP_FLAG_AEAD_TLS_TYPE && | ||
42 | + ses_ptr->cdata.aead == 0) { | ||
43 | ret = crypto_auth_zc_tls(ses_ptr, kcaop); | ||
44 | - } else { | ||
45 | + } else if (ses_ptr->cdata.aead) { | ||
46 | ret = crypto_auth_zc_aead(ses_ptr, kcaop); | ||
47 | + } else { | ||
48 | + ret = -EINVAL; | ||
49 | } | ||
50 | |||
51 | return ret; | ||
52 | -- | ||
53 | 2.7.4 | ||
54 | |||
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 @@ | |||
1 | From 263483d1023f6c1c35b5488b9b79796ee2605e9b Mon Sep 17 00:00:00 2001 | ||
2 | From: Yashpal Dutta <yashpal.dutta@freescale.com> | ||
3 | Date: Thu, 17 Apr 2014 07:08:47 +0545 | ||
4 | Subject: [PATCH 09/38] Fixed compilation error of openssl with fsl cryptodev | ||
5 | |||
6 | Upstream-status: Pending | ||
7 | |||
8 | Signed-off-by: Yashpal Dutta <yashpal.dutta@freescale.com> | ||
9 | Tested-by: Cristian Stoica <cristian.stoica@freescale.com> | ||
10 | --- | ||
11 | authenc.c | 1 + | ||
12 | cryptlib.c | 9 ++++----- | ||
13 | crypto/cryptodev.h | 9 ++++++++- | ||
14 | cryptodev_int.h | 2 +- | ||
15 | ioctl.c | 8 ++++++-- | ||
16 | main.c | 1 + | ||
17 | 6 files changed, 21 insertions(+), 9 deletions(-) | ||
18 | |||
19 | diff --git a/authenc.c b/authenc.c | ||
20 | index ef0d3db..2aa4d38 100644 | ||
21 | --- a/authenc.c | ||
22 | +++ b/authenc.c | ||
23 | @@ -2,6 +2,7 @@ | ||
24 | * Driver for /dev/crypto device (aka CryptoDev) | ||
25 | * | ||
26 | * Copyright (c) 2011, 2012 OpenSSL Software Foundation, Inc. | ||
27 | + * Copyright (c) 2014 Freescale Semiconductor, Inc. | ||
28 | * | ||
29 | * Author: Nikos Mavrogiannopoulos | ||
30 | * | ||
31 | diff --git a/cryptlib.c b/cryptlib.c | ||
32 | index 4dd1847..ec6693e 100644 | ||
33 | --- a/cryptlib.c | ||
34 | +++ b/cryptlib.c | ||
35 | @@ -4,8 +4,7 @@ | ||
36 | * Copyright (c) 2010,2011 Nikos Mavrogiannopoulos <nmav@gnutls.org> | ||
37 | * Portions Copyright (c) 2010 Michael Weiser | ||
38 | * Portions Copyright (c) 2010 Phil Sutter | ||
39 | - * | ||
40 | - * Copyright 2012 Freescale Semiconductor, Inc. | ||
41 | + * Copyright 2012-2014 Freescale Semiconductor, Inc. | ||
42 | * | ||
43 | * This file is part of linux cryptodev. | ||
44 | * | ||
45 | @@ -144,7 +143,7 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, | ||
46 | if (alg->max_keysize > 0 && | ||
47 | unlikely((keylen < alg->min_keysize) || | ||
48 | (keylen > alg->max_keysize))) { | ||
49 | - ddebug(1, "Wrong keylen '%zu' for algorithm '%s'. Use %u to %u.", | ||
50 | + ddebug(1, "Wrong keylen '%u' for algorithm '%s'. Use %u to %u.", | ||
51 | keylen, alg_name, alg->min_keysize, alg->max_keysize); | ||
52 | ret = -EINVAL; | ||
53 | goto error; | ||
54 | @@ -171,7 +170,7 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, | ||
55 | } | ||
56 | |||
57 | if (unlikely(ret)) { | ||
58 | - ddebug(1, "Setting key failed for %s-%zu.", alg_name, keylen*8); | ||
59 | + ddebug(1, "Setting key failed for %s-%u.", alg_name, keylen*8); | ||
60 | ret = -EINVAL; | ||
61 | goto error; | ||
62 | } | ||
63 | @@ -338,7 +337,7 @@ int cryptodev_hash_init(struct hash_data *hdata, const char *alg_name, | ||
64 | if (hmac_mode != 0) { | ||
65 | ret = crypto_ahash_setkey(hdata->async.s, mackey, mackeylen); | ||
66 | if (unlikely(ret)) { | ||
67 | - ddebug(1, "Setting hmac key failed for %s-%zu.", | ||
68 | + ddebug(1, "Setting hmac key failed for %s-%u.", | ||
69 | alg_name, mackeylen*8); | ||
70 | ret = -EINVAL; | ||
71 | goto error; | ||
72 | diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h | ||
73 | index d0cc542..e7edd97 100644 | ||
74 | --- a/crypto/cryptodev.h | ||
75 | +++ b/crypto/cryptodev.h | ||
76 | @@ -234,6 +234,13 @@ struct crypt_auth_op { | ||
77 | #define CRYPTO_ALG_FLAG_RNG_ENABLE 2 | ||
78 | #define CRYPTO_ALG_FLAG_DSA_SHA 4 | ||
79 | |||
80 | +enum ec_curve_t { | ||
81 | + EC_DISCRETE_LOG, | ||
82 | + EC_PRIME, | ||
83 | + EC_BINARY, | ||
84 | + MAX_EC_TYPE | ||
85 | +}; | ||
86 | + | ||
87 | struct crparam { | ||
88 | __u8 *crp_p; | ||
89 | __u32 crp_nbits; | ||
90 | @@ -249,7 +256,7 @@ struct crypt_kop { | ||
91 | __u16 crk_oparams; | ||
92 | __u32 crk_pad1; | ||
93 | struct crparam crk_param[CRK_MAXPARAM]; | ||
94 | - enum curve_t curve_type; /* 0 == Discrete Log, | ||
95 | + enum ec_curve_t curve_type; /* 0 == Discrete Log, | ||
96 | 1 = EC_PRIME, 2 = EC_BINARY */ | ||
97 | void *cookie; | ||
98 | }; | ||
99 | diff --git a/cryptodev_int.h b/cryptodev_int.h | ||
100 | index 5347cae..c83c885 100644 | ||
101 | --- a/cryptodev_int.h | ||
102 | +++ b/cryptodev_int.h | ||
103 | @@ -88,7 +88,7 @@ struct compat_crypt_kop { | ||
104 | uint16_t crk_oparams; | ||
105 | uint32_t crk_pad1; | ||
106 | struct compat_crparam crk_param[CRK_MAXPARAM]; | ||
107 | - enum curve_t curve_type; /* 0 == Discrete Log, 1 = EC_PRIME, | ||
108 | + enum ec_curve_t curve_type; /* 0 == Discrete Log, 1 = EC_PRIME, | ||
109 | 2 = EC_BINARY */ | ||
110 | compat_uptr_t cookie; | ||
111 | }; | ||
112 | diff --git a/ioctl.c b/ioctl.c | ||
113 | index 3762a47..c97320b 100644 | ||
114 | --- a/ioctl.c | ||
115 | +++ b/ioctl.c | ||
116 | @@ -4,7 +4,7 @@ | ||
117 | * Copyright (c) 2004 Michal Ludvig <mludvig@logix.net.nz>, SuSE Labs | ||
118 | * Copyright (c) 2009,2010,2011 Nikos Mavrogiannopoulos <nmav@gnutls.org> | ||
119 | * Copyright (c) 2010 Phil Sutter | ||
120 | - * Copyright 2012 Freescale Semiconductor, Inc. | ||
121 | + * Copyright 2012-2014 Freescale Semiconductor, Inc. | ||
122 | * | ||
123 | * This file is part of linux cryptodev. | ||
124 | * | ||
125 | @@ -501,6 +501,7 @@ cryptodev_open(struct inode *inode, struct file *filp) | ||
126 | INIT_LIST_HEAD(&pcr->done.list); | ||
127 | INIT_LIST_HEAD(&pcr->asym_completed_list); | ||
128 | spin_lock_init(&pcr->completion_lock); | ||
129 | + | ||
130 | INIT_WORK(&pcr->cryptask, cryptask_routine); | ||
131 | |||
132 | init_waitqueue_head(&pcr->user_waiter); | ||
133 | @@ -780,8 +781,11 @@ static int fill_kcop_from_cop(struct kernel_crypt_op *kcop, struct fcrypt *fcr) | ||
134 | |||
135 | if (cop->iv) { | ||
136 | rc = copy_from_user(kcop->iv, cop->iv, kcop->ivlen); | ||
137 | - if (unlikely(rc)) | ||
138 | + if (unlikely(rc)) { | ||
139 | + derr(1, "error copying IV (%d bytes), copy_from_user returned %d for address %p", | ||
140 | + kcop->ivlen, rc, cop->iv); | ||
141 | return -EFAULT; | ||
142 | + } | ||
143 | } | ||
144 | |||
145 | return 0; | ||
146 | diff --git a/main.c b/main.c | ||
147 | index 14dcf40..6365911 100644 | ||
148 | --- a/main.c | ||
149 | +++ b/main.c | ||
150 | @@ -3,6 +3,7 @@ | ||
151 | * | ||
152 | * Copyright (c) 2004 Michal Ludvig <mludvig@logix.net.nz>, SuSE Labs | ||
153 | * Copyright (c) 2009-2013 Nikos Mavrogiannopoulos <nmav@gnutls.org> | ||
154 | + * Copyright (c) 2014 Freescale Semiconductor, Inc. | ||
155 | * | ||
156 | * This file is part of linux cryptodev. | ||
157 | * | ||
158 | -- | ||
159 | 2.7.0 | ||
160 | |||
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 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 @@ | |||
1 | From 25a68839e3aab5acebcbe51f7fbe9d2d26216bc0 Mon Sep 17 00:00:00 2001 | 1 | From f365c69d7852d6579952825c9f90a27129f92d22 Mon Sep 17 00:00:00 2001 |
2 | From: Cristian Stoica <cristian.stoica@freescale.com> | 2 | From: Cristian Stoica <cristian.stoica@nxp.com> |
3 | Date: Thu, 29 Aug 2013 16:52:30 +0300 | 3 | Date: Tue, 13 Jun 2017 11:13:33 +0300 |
4 | Subject: [PATCH 01/38] add support for composite TLS10(SHA1,AES) algorithm | 4 | Subject: [PATCH 9/9] add support for composite TLS10(SHA1,AES) algorithm |
5 | offload | 5 | offload |
6 | 6 | ||
7 | This adds support for composite algorithm offload as a primitive | 7 | 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 | |||
11 | provided either in software or accelerated by hardware such as | 11 | provided either in software or accelerated by hardware such as |
12 | Freescale B*, P* and T* platforms. | 12 | Freescale B*, P* and T* platforms. |
13 | 13 | ||
14 | Change-Id: Ia1c605da3860e91e681295dfc8df7c09eb4006cf | 14 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> |
15 | Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> | ||
16 | Reviewed-on: http://git.am.freescale.net:8181/17218 | ||
17 | --- | 15 | --- |
18 | crypto/cryptodev.h | 1 + | 16 | crypto/cryptodev.h | 1 + |
19 | ioctl.c | 5 +++++ | 17 | ioctl.c | 5 +++++ |
@@ -32,7 +30,7 @@ index 7fb9c7d..c0e8cd4 100644 | |||
32 | }; | 30 | }; |
33 | 31 | ||
34 | diff --git a/ioctl.c b/ioctl.c | 32 | diff --git a/ioctl.c b/ioctl.c |
35 | index b23f5fd..a3f8379 100644 | 33 | index 8b0df4e..998f51a 100644 |
36 | --- a/ioctl.c | 34 | --- a/ioctl.c |
37 | +++ b/ioctl.c | 35 | +++ b/ioctl.c |
38 | @@ -159,6 +159,11 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) | 36 | @@ -159,6 +159,11 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) |
@@ -48,5 +46,5 @@ index b23f5fd..a3f8379 100644 | |||
48 | alg_name = "ecb(cipher_null)"; | 46 | alg_name = "ecb(cipher_null)"; |
49 | stream = 1; | 47 | stream = 1; |
50 | -- | 48 | -- |
51 | 2.7.0 | 49 | 2.7.4 |
52 | 50 | ||
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 @@ | |||
1 | From 269564f4e00fa907388ccfa046b930b3c4eef4dc Mon Sep 17 00:00:00 2001 | ||
2 | From: Tudor Ambarus <tudor.ambarus@freescale.com> | ||
3 | Date: Tue, 10 Jun 2014 08:27:59 +0300 | ||
4 | Subject: [PATCH 10/38] add support for composite TLS10(SHA1,3DES) algorithm | ||
5 | offload | ||
6 | |||
7 | This adds support for composite algorithm offload in a single crypto | ||
8 | (cipher + hmac) operation. | ||
9 | |||
10 | It requires either software or hardware TLS support in the Linux kernel | ||
11 | and can be used with Freescale B*, P* and T* platforms that have support | ||
12 | for hardware TLS acceleration. | ||
13 | |||
14 | Change-Id: Ibce0ceb4174809c9c96b453cd3202bc5220ff084 | ||
15 | Signed-off-by: Tudor Ambarus <tudor.ambarus@freescale.com> | ||
16 | Reviewed-on: http://git.am.freescale.net:8181/34000 | ||
17 | Reviewed-by: Cristian Stoica <cristian.stoica@freescale.com> | ||
18 | Tested-by: Cristian Stoica <cristian.stoica@freescale.com> | ||
19 | --- | ||
20 | crypto/cryptodev.h | 1 + | ||
21 | ioctl.c | 5 +++++ | ||
22 | 2 files changed, 6 insertions(+) | ||
23 | |||
24 | diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h | ||
25 | index e7edd97..07f40b2 100644 | ||
26 | --- a/crypto/cryptodev.h | ||
27 | +++ b/crypto/cryptodev.h | ||
28 | @@ -55,6 +55,7 @@ enum cryptodev_crypto_op_t { | ||
29 | CRYPTO_SHA2_512, | ||
30 | CRYPTO_SHA2_224_HMAC, | ||
31 | CRYPTO_TLS10_AES_CBC_HMAC_SHA1, | ||
32 | + CRYPTO_TLS10_3DES_CBC_HMAC_SHA1, | ||
33 | CRYPTO_ALGORITHM_ALL, /* Keep updated - see below */ | ||
34 | }; | ||
35 | |||
36 | diff --git a/ioctl.c b/ioctl.c | ||
37 | index c97320b..574e913 100644 | ||
38 | --- a/ioctl.c | ||
39 | +++ b/ioctl.c | ||
40 | @@ -191,6 +191,11 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) | ||
41 | stream = 0; | ||
42 | aead = 1; | ||
43 | break; | ||
44 | + case CRYPTO_TLS10_3DES_CBC_HMAC_SHA1: | ||
45 | + alg_name = "tls10(hmac(sha1),cbc(des3_ede))"; | ||
46 | + stream = 0; | ||
47 | + aead = 1; | ||
48 | + break; | ||
49 | case CRYPTO_NULL: | ||
50 | alg_name = "ecb(cipher_null)"; | ||
51 | stream = 1; | ||
52 | -- | ||
53 | 2.7.0 | ||
54 | |||
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 @@ | |||
1 | From 73c20be9ae1ed57d8c428c86471f42d953e79fba Mon Sep 17 00:00:00 2001 | ||
2 | From: Tudor Ambarus <tudor.ambarus@freescale.com> | ||
3 | Date: Tue, 31 Mar 2015 16:15:47 +0300 | ||
4 | Subject: [PATCH 11/38] add support for TLSv1.1 record offload | ||
5 | |||
6 | This adds support for composite algorithm offload in a single crypto | ||
7 | (cipher + hmac) operation. | ||
8 | |||
9 | Supported cipher suites: | ||
10 | - 3des-ede-cbc-sha | ||
11 | - aes-128-cbc-hmac-sha | ||
12 | - aes-256-cbc-hmac-sha | ||
13 | |||
14 | It requires either software or hardware TLS support in the Linux kernel | ||
15 | and can be used with Freescale B*, P* and T* platforms that have support | ||
16 | for hardware TLS acceleration. | ||
17 | |||
18 | Signed-off-by: Tudor Ambarus <tudor.ambarus@freescale.com> | ||
19 | Change-Id: Ia5f3fa7ec090d5643d71b0f608c68a274ec6b51f | ||
20 | Reviewed-on: http://git.am.freescale.net:8181/33998 | ||
21 | Reviewed-by: Cristian Stoica <cristian.stoica@freescale.com> | ||
22 | Tested-by: Cristian Stoica <cristian.stoica@freescale.com> | ||
23 | --- | ||
24 | crypto/cryptodev.h | 4 +++- | ||
25 | ioctl.c | 14 ++++++++++++-- | ||
26 | 2 files changed, 15 insertions(+), 3 deletions(-) | ||
27 | |||
28 | diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h | ||
29 | index 07f40b2..61e8599 100644 | ||
30 | --- a/crypto/cryptodev.h | ||
31 | +++ b/crypto/cryptodev.h | ||
32 | @@ -54,8 +54,10 @@ enum cryptodev_crypto_op_t { | ||
33 | CRYPTO_SHA2_384, | ||
34 | CRYPTO_SHA2_512, | ||
35 | CRYPTO_SHA2_224_HMAC, | ||
36 | - CRYPTO_TLS10_AES_CBC_HMAC_SHA1, | ||
37 | CRYPTO_TLS10_3DES_CBC_HMAC_SHA1, | ||
38 | + CRYPTO_TLS10_AES_CBC_HMAC_SHA1, | ||
39 | + CRYPTO_TLS11_3DES_CBC_HMAC_SHA1, | ||
40 | + CRYPTO_TLS11_AES_CBC_HMAC_SHA1, | ||
41 | CRYPTO_ALGORITHM_ALL, /* Keep updated - see below */ | ||
42 | }; | ||
43 | |||
44 | diff --git a/ioctl.c b/ioctl.c | ||
45 | index 574e913..ba82387 100644 | ||
46 | --- a/ioctl.c | ||
47 | +++ b/ioctl.c | ||
48 | @@ -186,13 +186,23 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) | ||
49 | stream = 1; | ||
50 | aead = 1; | ||
51 | break; | ||
52 | + case CRYPTO_TLS10_3DES_CBC_HMAC_SHA1: | ||
53 | + alg_name = "tls10(hmac(sha1),cbc(des3_ede))"; | ||
54 | + stream = 0; | ||
55 | + aead = 1; | ||
56 | + break; | ||
57 | case CRYPTO_TLS10_AES_CBC_HMAC_SHA1: | ||
58 | alg_name = "tls10(hmac(sha1),cbc(aes))"; | ||
59 | stream = 0; | ||
60 | aead = 1; | ||
61 | break; | ||
62 | - case CRYPTO_TLS10_3DES_CBC_HMAC_SHA1: | ||
63 | - alg_name = "tls10(hmac(sha1),cbc(des3_ede))"; | ||
64 | + case CRYPTO_TLS11_3DES_CBC_HMAC_SHA1: | ||
65 | + alg_name = "tls11(hmac(sha1),cbc(des3_ede))"; | ||
66 | + stream = 0; | ||
67 | + aead = 1; | ||
68 | + break; | ||
69 | + case CRYPTO_TLS11_AES_CBC_HMAC_SHA1: | ||
70 | + alg_name = "tls11(hmac(sha1),cbc(aes))"; | ||
71 | stream = 0; | ||
72 | aead = 1; | ||
73 | break; | ||
74 | -- | ||
75 | 2.7.0 | ||
76 | |||
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 @@ | |||
1 | From f1a519d9eed072bd45a45d251603c64f942814fb Mon Sep 17 00:00:00 2001 | ||
2 | From: Tudor Ambarus <tudor.ambarus@freescale.com> | ||
3 | Date: Tue, 31 Mar 2015 16:16:28 +0300 | ||
4 | Subject: [PATCH 12/38] add support for TLSv1.2 record offload | ||
5 | |||
6 | This adds support for composite algorithm offload in a single crypto | ||
7 | (cipher + hmac) operation. | ||
8 | |||
9 | Supported cipher suites: | ||
10 | - 3des-ede-cbc-sha | ||
11 | - aes-128-cbc-hmac-sha | ||
12 | - aes-256-cbc-hmac-sha | ||
13 | - aes-128-cbc-hmac-sha256 | ||
14 | - aes-256-cbc-hmac-sha256 | ||
15 | |||
16 | It requires either software or hardware TLS support in the Linux kernel | ||
17 | and can be used with Freescale B*, P* and T* platforms that have support | ||
18 | for hardware TLS acceleration. | ||
19 | |||
20 | Signed-off-by: Tudor Ambarus <tudor.ambarus@freescale.com> | ||
21 | Change-Id: I21f45993505fc3dad09848a13aa20f778a7c2de0 | ||
22 | Reviewed-on: http://git.am.freescale.net:8181/33999 | ||
23 | Reviewed-by: Cristian Stoica <cristian.stoica@freescale.com> | ||
24 | Tested-by: Cristian Stoica <cristian.stoica@freescale.com> | ||
25 | --- | ||
26 | crypto/cryptodev.h | 3 +++ | ||
27 | ioctl.c | 15 +++++++++++++++ | ||
28 | 2 files changed, 18 insertions(+) | ||
29 | |||
30 | diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h | ||
31 | index 61e8599..f6058ca 100644 | ||
32 | --- a/crypto/cryptodev.h | ||
33 | +++ b/crypto/cryptodev.h | ||
34 | @@ -58,6 +58,9 @@ enum cryptodev_crypto_op_t { | ||
35 | CRYPTO_TLS10_AES_CBC_HMAC_SHA1, | ||
36 | CRYPTO_TLS11_3DES_CBC_HMAC_SHA1, | ||
37 | CRYPTO_TLS11_AES_CBC_HMAC_SHA1, | ||
38 | + CRYPTO_TLS12_3DES_CBC_HMAC_SHA1, | ||
39 | + CRYPTO_TLS12_AES_CBC_HMAC_SHA1, | ||
40 | + CRYPTO_TLS12_AES_CBC_HMAC_SHA256, | ||
41 | CRYPTO_ALGORITHM_ALL, /* Keep updated - see below */ | ||
42 | }; | ||
43 | |||
44 | diff --git a/ioctl.c b/ioctl.c | ||
45 | index ba82387..fb4c4e3 100644 | ||
46 | --- a/ioctl.c | ||
47 | +++ b/ioctl.c | ||
48 | @@ -206,6 +206,21 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) | ||
49 | stream = 0; | ||
50 | aead = 1; | ||
51 | break; | ||
52 | + case CRYPTO_TLS12_3DES_CBC_HMAC_SHA1: | ||
53 | + alg_name = "tls12(hmac(sha1),cbc(des3_ede))"; | ||
54 | + stream = 0; | ||
55 | + aead = 1; | ||
56 | + break; | ||
57 | + case CRYPTO_TLS12_AES_CBC_HMAC_SHA1: | ||
58 | + alg_name = "tls12(hmac(sha1),cbc(aes))"; | ||
59 | + stream = 0; | ||
60 | + aead = 1; | ||
61 | + break; | ||
62 | + case CRYPTO_TLS12_AES_CBC_HMAC_SHA256: | ||
63 | + alg_name = "tls12(hmac(sha256),cbc(aes))"; | ||
64 | + stream = 0; | ||
65 | + aead = 1; | ||
66 | + break; | ||
67 | case CRYPTO_NULL: | ||
68 | alg_name = "ecb(cipher_null)"; | ||
69 | stream = 1; | ||
70 | -- | ||
71 | 2.7.0 | ||
72 | |||
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 @@ | |||
1 | From 5a87b9d5f2295ed0fd36a41c8376e01eb0df62b2 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@freescale.com> | ||
3 | Date: Fri, 20 Feb 2015 12:46:58 +0200 | ||
4 | Subject: [PATCH 13/38] clean-up code layout | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> | ||
7 | Change-Id: I92c2f4baeed9470a2c3c42b592d878e65918b0af | ||
8 | Reviewed-on: http://git.am.freescale.net:8181/34222 | ||
9 | --- | ||
10 | cryptlib.c | 11 ++++------- | ||
11 | ioctl.c | 55 +++++++++++++++++++++---------------------------------- | ||
12 | main.c | 4 +--- | ||
13 | 3 files changed, 26 insertions(+), 44 deletions(-) | ||
14 | |||
15 | diff --git a/cryptlib.c b/cryptlib.c | ||
16 | index ec6693e..21e691b 100644 | ||
17 | --- a/cryptlib.c | ||
18 | +++ b/cryptlib.c | ||
19 | @@ -434,7 +434,7 @@ int cryptodev_hash_final(struct hash_data *hdata, void *output) | ||
20 | return waitfor(hdata->async.result, ret); | ||
21 | } | ||
22 | |||
23 | -int cryptodev_pkc_offload(struct cryptodev_pkc *pkc) | ||
24 | +int cryptodev_pkc_offload(struct cryptodev_pkc *pkc) | ||
25 | { | ||
26 | int ret = 0; | ||
27 | struct pkc_request *pkc_req = &pkc->req, *pkc_requested; | ||
28 | @@ -445,8 +445,7 @@ int cryptodev_pkc_offload(struct cryptodev_pkc *pkc) | ||
29 | case RSA_PRIV_FORM1: | ||
30 | case RSA_PRIV_FORM2: | ||
31 | case RSA_PRIV_FORM3: | ||
32 | - pkc->s = crypto_alloc_pkc("pkc(rsa)", | ||
33 | - CRYPTO_ALG_TYPE_PKC_RSA, 0); | ||
34 | + pkc->s = crypto_alloc_pkc("pkc(rsa)", CRYPTO_ALG_TYPE_PKC_RSA, 0); | ||
35 | break; | ||
36 | case DSA_SIGN: | ||
37 | case DSA_VERIFY: | ||
38 | @@ -454,13 +453,11 @@ int cryptodev_pkc_offload(struct cryptodev_pkc *pkc) | ||
39 | case ECDSA_VERIFY: | ||
40 | case DLC_KEYGEN: | ||
41 | case ECC_KEYGEN: | ||
42 | - pkc->s = crypto_alloc_pkc("pkc(dsa)", | ||
43 | - CRYPTO_ALG_TYPE_PKC_DSA, 0); | ||
44 | + pkc->s = crypto_alloc_pkc("pkc(dsa)", CRYPTO_ALG_TYPE_PKC_DSA, 0); | ||
45 | break; | ||
46 | case DH_COMPUTE_KEY: | ||
47 | case ECDH_COMPUTE_KEY: | ||
48 | - pkc->s = crypto_alloc_pkc("pkc(dh)", | ||
49 | - CRYPTO_ALG_TYPE_PKC_DH, 0); | ||
50 | + pkc->s = crypto_alloc_pkc("pkc(dh)", CRYPTO_ALG_TYPE_PKC_DH, 0); | ||
51 | break; | ||
52 | default: | ||
53 | return -EINVAL; | ||
54 | diff --git a/ioctl.c b/ioctl.c | ||
55 | index fb4c4e3..ee0486c 100644 | ||
56 | --- a/ioctl.c | ||
57 | +++ b/ioctl.c | ||
58 | @@ -714,16 +714,13 @@ static int crypto_async_fetch_asym(struct cryptodev_pkc *pkc) | ||
59 | case CRK_MOD_EXP: | ||
60 | { | ||
61 | struct rsa_pub_req_s *rsa_req = &pkc_req->req_u.rsa_pub_req; | ||
62 | - copy_to_user(ckop->crk_param[3].crp_p, rsa_req->g, | ||
63 | - rsa_req->g_len); | ||
64 | + copy_to_user(ckop->crk_param[3].crp_p, rsa_req->g, rsa_req->g_len); | ||
65 | } | ||
66 | break; | ||
67 | case CRK_MOD_EXP_CRT: | ||
68 | { | ||
69 | - struct rsa_priv_frm3_req_s *rsa_req = | ||
70 | - &pkc_req->req_u.rsa_priv_f3; | ||
71 | - copy_to_user(ckop->crk_param[6].crp_p, | ||
72 | - rsa_req->f, rsa_req->f_len); | ||
73 | + struct rsa_priv_frm3_req_s *rsa_req = &pkc_req->req_u.rsa_priv_f3; | ||
74 | + copy_to_user(ckop->crk_param[6].crp_p, rsa_req->f, rsa_req->f_len); | ||
75 | } | ||
76 | break; | ||
77 | case CRK_DSA_SIGN: | ||
78 | @@ -731,15 +728,11 @@ static int crypto_async_fetch_asym(struct cryptodev_pkc *pkc) | ||
79 | struct dsa_sign_req_s *dsa_req = &pkc_req->req_u.dsa_sign; | ||
80 | |||
81 | if (pkc_req->type == ECDSA_SIGN) { | ||
82 | - copy_to_user(ckop->crk_param[6].crp_p, | ||
83 | - dsa_req->c, dsa_req->d_len); | ||
84 | - copy_to_user(ckop->crk_param[7].crp_p, | ||
85 | - dsa_req->d, dsa_req->d_len); | ||
86 | + copy_to_user(ckop->crk_param[6].crp_p, dsa_req->c, dsa_req->d_len); | ||
87 | + copy_to_user(ckop->crk_param[7].crp_p, dsa_req->d, dsa_req->d_len); | ||
88 | } else { | ||
89 | - copy_to_user(ckop->crk_param[5].crp_p, | ||
90 | - dsa_req->c, dsa_req->d_len); | ||
91 | - copy_to_user(ckop->crk_param[6].crp_p, | ||
92 | - dsa_req->d, dsa_req->d_len); | ||
93 | + copy_to_user(ckop->crk_param[5].crp_p, dsa_req->c, dsa_req->d_len); | ||
94 | + copy_to_user(ckop->crk_param[6].crp_p, dsa_req->d, dsa_req->d_len); | ||
95 | } | ||
96 | } | ||
97 | break; | ||
98 | @@ -749,11 +742,9 @@ static int crypto_async_fetch_asym(struct cryptodev_pkc *pkc) | ||
99 | { | ||
100 | struct dh_key_req_s *dh_req = &pkc_req->req_u.dh_req; | ||
101 | if (pkc_req->type == ECDH_COMPUTE_KEY) | ||
102 | - copy_to_user(ckop->crk_param[4].crp_p, | ||
103 | - dh_req->z, dh_req->z_len); | ||
104 | + copy_to_user(ckop->crk_param[4].crp_p, dh_req->z, dh_req->z_len); | ||
105 | else | ||
106 | - copy_to_user(ckop->crk_param[3].crp_p, | ||
107 | - dh_req->z, dh_req->z_len); | ||
108 | + copy_to_user(ckop->crk_param[3].crp_p, dh_req->z, dh_req->z_len); | ||
109 | } | ||
110 | break; | ||
111 | case CRK_DSA_GENERATE_KEY: | ||
112 | @@ -763,14 +754,14 @@ static int crypto_async_fetch_asym(struct cryptodev_pkc *pkc) | ||
113 | |||
114 | if (pkc_req->type == ECC_KEYGEN) { | ||
115 | copy_to_user(ckop->crk_param[4].crp_p, key_req->pub_key, | ||
116 | - key_req->pub_key_len); | ||
117 | - copy_to_user(ckop->crk_param[5].crp_p, | ||
118 | - key_req->priv_key, key_req->priv_key_len); | ||
119 | + key_req->pub_key_len); | ||
120 | + copy_to_user(ckop->crk_param[5].crp_p, key_req->priv_key, | ||
121 | + key_req->priv_key_len); | ||
122 | } else { | ||
123 | - copy_to_user(ckop->crk_param[3].crp_p, | ||
124 | - key_req->pub_key, key_req->pub_key_len); | ||
125 | - copy_to_user(ckop->crk_param[4].crp_p, | ||
126 | - key_req->priv_key, key_req->priv_key_len); | ||
127 | + copy_to_user(ckop->crk_param[3].crp_p, key_req->pub_key, | ||
128 | + key_req->pub_key_len); | ||
129 | + copy_to_user(ckop->crk_param[4].crp_p, key_req->priv_key, | ||
130 | + key_req->priv_key_len); | ||
131 | } | ||
132 | } | ||
133 | default: | ||
134 | @@ -1113,16 +1104,14 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | ||
135 | if (!list_empty(&pcr->asym_completed_list)) { | ||
136 | /* Run a loop in the list for upto elements | ||
137 | and copy their response back */ | ||
138 | - pkc = | ||
139 | - list_first_entry(&pcr->asym_completed_list, | ||
140 | + pkc = list_first_entry(&pcr->asym_completed_list, | ||
141 | struct cryptodev_pkc, list); | ||
142 | list_del(&pkc->list); | ||
143 | spin_unlock_bh(&pcr->completion_lock); | ||
144 | ret = crypto_async_fetch_asym(pkc); | ||
145 | if (!ret) { | ||
146 | cookie_list.cookie_available++; | ||
147 | - cookie_list.cookie[i] = | ||
148 | - pkc->kop.kop.cookie; | ||
149 | + cookie_list.cookie[i] = pkc->kop.kop.cookie; | ||
150 | cookie_list.status[i] = pkc->result.err; | ||
151 | } | ||
152 | kfree(pkc); | ||
153 | @@ -1133,12 +1122,10 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | ||
154 | } | ||
155 | |||
156 | /* Reflect the updated request to user-space */ | ||
157 | - if (cookie_list.cookie_available) | ||
158 | - copy_to_user(arg, &cookie_list, | ||
159 | - sizeof(struct pkc_cookie_list_s)); | ||
160 | - else { | ||
161 | + if (cookie_list.cookie_available) { | ||
162 | + copy_to_user(arg, &cookie_list, sizeof(struct pkc_cookie_list_s)); | ||
163 | + } else { | ||
164 | struct pkc_cookie_list_s *user_ck_list = (void *)arg; | ||
165 | - | ||
166 | put_user(0, &(user_ck_list->cookie_available)); | ||
167 | } | ||
168 | ret = cookie_list.cookie_available; | ||
169 | diff --git a/main.c b/main.c | ||
170 | index 6365911..af66553 100644 | ||
171 | --- a/main.c | ||
172 | +++ b/main.c | ||
173 | @@ -666,9 +666,7 @@ int crypto_bn_modexp(struct cryptodev_pkc *pkc) | ||
174 | if (pkc->type == SYNCHRONOUS) { | ||
175 | if (rc) | ||
176 | goto err; | ||
177 | - | ||
178 | - copy_to_user(cop->crk_param[3].crp_p, rsa_req->g, | ||
179 | - rsa_req->g_len); | ||
180 | + copy_to_user(cop->crk_param[3].crp_p, rsa_req->g, rsa_req->g_len); | ||
181 | } else { | ||
182 | if (rc != -EINPROGRESS && rc != 0) | ||
183 | goto err; | ||
184 | -- | ||
185 | 2.7.0 | ||
186 | |||
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 @@ | |||
1 | From a4d88e5379ddb7d9bceac3141f508b8173d1e902 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@freescale.com> | ||
3 | Date: Mon, 23 Feb 2015 12:14:07 +0200 | ||
4 | Subject: [PATCH 14/38] remove redundant data copy for pkc operations | ||
5 | |||
6 | This patch removes a copy of a pkc request that was | ||
7 | allocated on the hot-path. The copy was not necessary | ||
8 | and was just slowing things down. | ||
9 | |||
10 | Change-Id: I3ad85f78c188f100ab9fc03a5777bb704a9dcb63 | ||
11 | Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> | ||
12 | Reviewed-on: http://git.am.freescale.net:8181/34223 | ||
13 | --- | ||
14 | cryptlib.c | 49 +++---------------- | ||
15 | cryptlib.h | 3 +- | ||
16 | ioctl.c | 17 +++---- | ||
17 | main.c | 162 +++++++++++++++++++++++++++++++++++++------------------------ | ||
18 | 4 files changed, 113 insertions(+), 118 deletions(-) | ||
19 | |||
20 | diff --git a/cryptlib.c b/cryptlib.c | ||
21 | index 21e691b..5882a30 100644 | ||
22 | --- a/cryptlib.c | ||
23 | +++ b/cryptlib.c | ||
24 | @@ -436,59 +436,22 @@ int cryptodev_hash_final(struct hash_data *hdata, void *output) | ||
25 | |||
26 | int cryptodev_pkc_offload(struct cryptodev_pkc *pkc) | ||
27 | { | ||
28 | - int ret = 0; | ||
29 | - struct pkc_request *pkc_req = &pkc->req, *pkc_requested; | ||
30 | - | ||
31 | - switch (pkc_req->type) { | ||
32 | - case RSA_KEYGEN: | ||
33 | - case RSA_PUB: | ||
34 | - case RSA_PRIV_FORM1: | ||
35 | - case RSA_PRIV_FORM2: | ||
36 | - case RSA_PRIV_FORM3: | ||
37 | - pkc->s = crypto_alloc_pkc("pkc(rsa)", CRYPTO_ALG_TYPE_PKC_RSA, 0); | ||
38 | - break; | ||
39 | - case DSA_SIGN: | ||
40 | - case DSA_VERIFY: | ||
41 | - case ECDSA_SIGN: | ||
42 | - case ECDSA_VERIFY: | ||
43 | - case DLC_KEYGEN: | ||
44 | - case ECC_KEYGEN: | ||
45 | - pkc->s = crypto_alloc_pkc("pkc(dsa)", CRYPTO_ALG_TYPE_PKC_DSA, 0); | ||
46 | - break; | ||
47 | - case DH_COMPUTE_KEY: | ||
48 | - case ECDH_COMPUTE_KEY: | ||
49 | - pkc->s = crypto_alloc_pkc("pkc(dh)", CRYPTO_ALG_TYPE_PKC_DH, 0); | ||
50 | - break; | ||
51 | - default: | ||
52 | - return -EINVAL; | ||
53 | - } | ||
54 | - | ||
55 | - if (IS_ERR_OR_NULL(pkc->s)) | ||
56 | - return -EINVAL; | ||
57 | + int ret; | ||
58 | |||
59 | init_completion(&pkc->result.completion); | ||
60 | - pkc_requested = pkc_request_alloc(pkc->s, GFP_KERNEL); | ||
61 | - | ||
62 | - if (unlikely(IS_ERR_OR_NULL(pkc_requested))) { | ||
63 | - ret = -ENOMEM; | ||
64 | - goto error; | ||
65 | - } | ||
66 | - pkc_requested->type = pkc_req->type; | ||
67 | - pkc_requested->curve_type = pkc_req->curve_type; | ||
68 | - memcpy(&pkc_requested->req_u, &pkc_req->req_u, sizeof(pkc_req->req_u)); | ||
69 | - pkc_request_set_callback(pkc_requested, CRYPTO_TFM_REQ_MAY_BACKLOG, | ||
70 | + pkc_request_set_callback(pkc->req, CRYPTO_TFM_REQ_MAY_BACKLOG, | ||
71 | cryptodev_complete_asym, pkc); | ||
72 | - ret = crypto_pkc_op(pkc_requested); | ||
73 | + ret = crypto_pkc_op(pkc->req); | ||
74 | if (ret != -EINPROGRESS && ret != 0) | ||
75 | - goto error2; | ||
76 | + goto error; | ||
77 | |||
78 | if (pkc->type == SYNCHRONOUS) | ||
79 | ret = waitfor(&pkc->result, ret); | ||
80 | |||
81 | return ret; | ||
82 | -error2: | ||
83 | - kfree(pkc_requested); | ||
84 | + | ||
85 | error: | ||
86 | + kfree(pkc->req); | ||
87 | crypto_free_pkc(pkc->s); | ||
88 | return ret; | ||
89 | } | ||
90 | diff --git a/cryptlib.h b/cryptlib.h | ||
91 | index 7ffa54c..4fac0c8 100644 | ||
92 | --- a/cryptlib.h | ||
93 | +++ b/cryptlib.h | ||
94 | @@ -110,8 +110,7 @@ struct cryptodev_pkc { | ||
95 | struct crypto_pkc *s; /* Transform pointer from CryptoAPI */ | ||
96 | struct cryptodev_result result; /* Result to be updated by | ||
97 | completion handler */ | ||
98 | - struct pkc_request req; /* PKC request structure allocated | ||
99 | - from CryptoAPI */ | ||
100 | + struct pkc_request *req; /* PKC request allocated from CryptoAPI */ | ||
101 | enum offload_type type; /* Synchronous Vs Asynchronous request */ | ||
102 | /* | ||
103 | * cookie used for transfering tranparent information from async | ||
104 | diff --git a/ioctl.c b/ioctl.c | ||
105 | index ee0486c..797b73c 100644 | ||
106 | --- a/ioctl.c | ||
107 | +++ b/ioctl.c | ||
108 | @@ -708,26 +708,25 @@ static int crypto_async_fetch_asym(struct cryptodev_pkc *pkc) | ||
109 | int ret = 0; | ||
110 | struct kernel_crypt_kop *kop = &pkc->kop; | ||
111 | struct crypt_kop *ckop = &kop->kop; | ||
112 | - struct pkc_request *pkc_req = &pkc->req; | ||
113 | |||
114 | switch (ckop->crk_op) { | ||
115 | case CRK_MOD_EXP: | ||
116 | { | ||
117 | - struct rsa_pub_req_s *rsa_req = &pkc_req->req_u.rsa_pub_req; | ||
118 | + struct rsa_pub_req_s *rsa_req = &pkc->req->req_u.rsa_pub_req; | ||
119 | copy_to_user(ckop->crk_param[3].crp_p, rsa_req->g, rsa_req->g_len); | ||
120 | } | ||
121 | break; | ||
122 | case CRK_MOD_EXP_CRT: | ||
123 | { | ||
124 | - struct rsa_priv_frm3_req_s *rsa_req = &pkc_req->req_u.rsa_priv_f3; | ||
125 | + struct rsa_priv_frm3_req_s *rsa_req = &pkc->req->req_u.rsa_priv_f3; | ||
126 | copy_to_user(ckop->crk_param[6].crp_p, rsa_req->f, rsa_req->f_len); | ||
127 | } | ||
128 | break; | ||
129 | case CRK_DSA_SIGN: | ||
130 | { | ||
131 | - struct dsa_sign_req_s *dsa_req = &pkc_req->req_u.dsa_sign; | ||
132 | + struct dsa_sign_req_s *dsa_req = &pkc->req->req_u.dsa_sign; | ||
133 | |||
134 | - if (pkc_req->type == ECDSA_SIGN) { | ||
135 | + if (pkc->req->type == ECDSA_SIGN) { | ||
136 | copy_to_user(ckop->crk_param[6].crp_p, dsa_req->c, dsa_req->d_len); | ||
137 | copy_to_user(ckop->crk_param[7].crp_p, dsa_req->d, dsa_req->d_len); | ||
138 | } else { | ||
139 | @@ -740,8 +739,8 @@ static int crypto_async_fetch_asym(struct cryptodev_pkc *pkc) | ||
140 | break; | ||
141 | case CRK_DH_COMPUTE_KEY: | ||
142 | { | ||
143 | - struct dh_key_req_s *dh_req = &pkc_req->req_u.dh_req; | ||
144 | - if (pkc_req->type == ECDH_COMPUTE_KEY) | ||
145 | + struct dh_key_req_s *dh_req = &pkc->req->req_u.dh_req; | ||
146 | + if (pkc->req->type == ECDH_COMPUTE_KEY) | ||
147 | copy_to_user(ckop->crk_param[4].crp_p, dh_req->z, dh_req->z_len); | ||
148 | else | ||
149 | copy_to_user(ckop->crk_param[3].crp_p, dh_req->z, dh_req->z_len); | ||
150 | @@ -750,9 +749,9 @@ static int crypto_async_fetch_asym(struct cryptodev_pkc *pkc) | ||
151 | case CRK_DSA_GENERATE_KEY: | ||
152 | case CRK_DH_GENERATE_KEY: | ||
153 | { | ||
154 | - struct keygen_req_s *key_req = &pkc_req->req_u.keygen; | ||
155 | + struct keygen_req_s *key_req = &pkc->req->req_u.keygen; | ||
156 | |||
157 | - if (pkc_req->type == ECC_KEYGEN) { | ||
158 | + if (pkc->req->type == ECC_KEYGEN) { | ||
159 | copy_to_user(ckop->crk_param[4].crp_p, key_req->pub_key, | ||
160 | key_req->pub_key_len); | ||
161 | copy_to_user(ckop->crk_param[5].crp_p, key_req->priv_key, | ||
162 | diff --git a/main.c b/main.c | ||
163 | index af66553..ed1c69a 100644 | ||
164 | --- a/main.c | ||
165 | +++ b/main.c | ||
166 | @@ -186,8 +186,7 @@ int crypto_kop_dsasign(struct cryptodev_pkc *pkc) | ||
167 | { | ||
168 | struct kernel_crypt_kop *kop = &pkc->kop; | ||
169 | struct crypt_kop *cop = &kop->kop; | ||
170 | - struct pkc_request *pkc_req = &pkc->req; | ||
171 | - struct dsa_sign_req_s *dsa_req = &pkc_req->req_u.dsa_sign; | ||
172 | + struct dsa_sign_req_s *dsa_req = &pkc->req->req_u.dsa_sign; | ||
173 | int rc, buf_size; | ||
174 | uint8_t *buf; | ||
175 | |||
176 | @@ -210,10 +209,7 @@ int crypto_kop_dsasign(struct cryptodev_pkc *pkc) | ||
177 | if (cop->crk_iparams == 6) { | ||
178 | dsa_req->ab_len = (cop->crk_param[5].crp_nbits + 7)/8; | ||
179 | buf_size += dsa_req->ab_len; | ||
180 | - pkc_req->type = ECDSA_SIGN; | ||
181 | - pkc_req->curve_type = cop->curve_type; | ||
182 | - } else { | ||
183 | - pkc_req->type = DSA_SIGN; | ||
184 | + pkc->req->curve_type = cop->curve_type; | ||
185 | } | ||
186 | |||
187 | buf = kmalloc(buf_size, GFP_DMA); | ||
188 | @@ -269,7 +265,6 @@ int crypto_kop_dsaverify(struct cryptodev_pkc *pkc) | ||
189 | { | ||
190 | struct kernel_crypt_kop *kop = &pkc->kop; | ||
191 | struct crypt_kop *cop = &kop->kop; | ||
192 | - struct pkc_request *pkc_req; | ||
193 | struct dsa_verify_req_s *dsa_req; | ||
194 | int rc, buf_size; | ||
195 | uint8_t *buf; | ||
196 | @@ -281,8 +276,7 @@ int crypto_kop_dsaverify(struct cryptodev_pkc *pkc) | ||
197 | !cop->crk_param[7].crp_nbits)) | ||
198 | return -EINVAL; | ||
199 | |||
200 | - pkc_req = &pkc->req; | ||
201 | - dsa_req = &pkc_req->req_u.dsa_verify; | ||
202 | + dsa_req = &pkc->req->req_u.dsa_verify; | ||
203 | dsa_req->m_len = (cop->crk_param[0].crp_nbits + 7)/8; | ||
204 | dsa_req->q_len = (cop->crk_param[1].crp_nbits + 7)/8; | ||
205 | dsa_req->r_len = (cop->crk_param[2].crp_nbits + 7)/8; | ||
206 | @@ -295,10 +289,7 @@ int crypto_kop_dsaverify(struct cryptodev_pkc *pkc) | ||
207 | if (cop->crk_iparams == 8) { | ||
208 | dsa_req->ab_len = (cop->crk_param[5].crp_nbits + 7)/8; | ||
209 | buf_size += dsa_req->ab_len; | ||
210 | - pkc_req->type = ECDSA_VERIFY; | ||
211 | - pkc_req->curve_type = cop->curve_type; | ||
212 | - } else { | ||
213 | - pkc_req->type = DSA_VERIFY; | ||
214 | + pkc->req->curve_type = cop->curve_type; | ||
215 | } | ||
216 | |||
217 | buf = kmalloc(buf_size, GFP_DMA); | ||
218 | @@ -351,7 +342,6 @@ int crypto_kop_rsa_keygen(struct cryptodev_pkc *pkc) | ||
219 | { | ||
220 | struct kernel_crypt_kop *kop = &pkc->kop; | ||
221 | struct crypt_kop *cop = &kop->kop; | ||
222 | - struct pkc_request *pkc_req; | ||
223 | struct rsa_keygen_req_s *key_req; | ||
224 | int rc, buf_size; | ||
225 | uint8_t *buf; | ||
226 | @@ -362,9 +352,7 @@ int crypto_kop_rsa_keygen(struct cryptodev_pkc *pkc) | ||
227 | !cop->crk_param[6].crp_nbits) | ||
228 | return -EINVAL; | ||
229 | |||
230 | - pkc_req = &pkc->req; | ||
231 | - pkc_req->type = RSA_KEYGEN; | ||
232 | - key_req = &pkc_req->req_u.rsa_keygen; | ||
233 | + key_req = &pkc->req->req_u.rsa_keygen; | ||
234 | key_req->n_len = (cop->crk_param[2].crp_nbits + 7)/8; | ||
235 | key_req->p_len = (cop->crk_param[0].crp_nbits + 7) / 8; | ||
236 | key_req->q_len = (cop->crk_param[1].crp_nbits + 7) / 8; | ||
237 | @@ -427,7 +415,6 @@ int crypto_kop_keygen(struct cryptodev_pkc *pkc) | ||
238 | { | ||
239 | struct kernel_crypt_kop *kop = &pkc->kop; | ||
240 | struct crypt_kop *cop = &kop->kop; | ||
241 | - struct pkc_request *pkc_req; | ||
242 | struct keygen_req_s *key_req; | ||
243 | int rc, buf_size; | ||
244 | uint8_t *buf; | ||
245 | @@ -437,8 +424,7 @@ int crypto_kop_keygen(struct cryptodev_pkc *pkc) | ||
246 | !cop->crk_param[4].crp_nbits) | ||
247 | return -EINVAL; | ||
248 | |||
249 | - pkc_req = &pkc->req; | ||
250 | - key_req = &pkc_req->req_u.keygen; | ||
251 | + key_req = &pkc->req->req_u.keygen; | ||
252 | key_req->q_len = (cop->crk_param[0].crp_nbits + 7)/8; | ||
253 | key_req->r_len = (cop->crk_param[1].crp_nbits + 7)/8; | ||
254 | key_req->g_len = (cop->crk_param[2].crp_nbits + 7)/8; | ||
255 | @@ -447,7 +433,6 @@ int crypto_kop_keygen(struct cryptodev_pkc *pkc) | ||
256 | key_req->priv_key_len = (cop->crk_param[4].crp_nbits + 7)/8; | ||
257 | buf_size = key_req->q_len + key_req->r_len + key_req->g_len + | ||
258 | key_req->pub_key_len + key_req->priv_key_len; | ||
259 | - pkc_req->type = DLC_KEYGEN; | ||
260 | } else { | ||
261 | key_req->ab_len = (cop->crk_param[3].crp_nbits + 7)/8; | ||
262 | key_req->pub_key_len = (cop->crk_param[4].crp_nbits + 7)/8; | ||
263 | @@ -455,8 +440,7 @@ int crypto_kop_keygen(struct cryptodev_pkc *pkc) | ||
264 | buf_size = key_req->q_len + key_req->r_len + key_req->g_len + | ||
265 | key_req->pub_key_len + key_req->priv_key_len + | ||
266 | key_req->ab_len; | ||
267 | - pkc_req->type = ECC_KEYGEN; | ||
268 | - pkc_req->curve_type = cop->curve_type; | ||
269 | + pkc->req->curve_type = cop->curve_type; | ||
270 | } | ||
271 | |||
272 | buf = kmalloc(buf_size, GFP_DMA); | ||
273 | @@ -508,26 +492,22 @@ int crypto_kop_dh_key(struct cryptodev_pkc *pkc) | ||
274 | { | ||
275 | struct kernel_crypt_kop *kop = &pkc->kop; | ||
276 | struct crypt_kop *cop = &kop->kop; | ||
277 | - struct pkc_request *pkc_req; | ||
278 | struct dh_key_req_s *dh_req; | ||
279 | int buf_size; | ||
280 | uint8_t *buf; | ||
281 | int rc = -EINVAL; | ||
282 | |||
283 | - pkc_req = &pkc->req; | ||
284 | - dh_req = &pkc_req->req_u.dh_req; | ||
285 | + dh_req = &pkc->req->req_u.dh_req; | ||
286 | dh_req->s_len = (cop->crk_param[0].crp_nbits + 7)/8; | ||
287 | dh_req->pub_key_len = (cop->crk_param[1].crp_nbits + 7)/8; | ||
288 | dh_req->q_len = (cop->crk_param[2].crp_nbits + 7)/8; | ||
289 | buf_size = dh_req->q_len + dh_req->pub_key_len + dh_req->s_len; | ||
290 | if (cop->crk_iparams == 4) { | ||
291 | - pkc_req->type = ECDH_COMPUTE_KEY; | ||
292 | dh_req->ab_len = (cop->crk_param[3].crp_nbits + 7)/8; | ||
293 | dh_req->z_len = (cop->crk_param[4].crp_nbits + 7)/8; | ||
294 | buf_size += dh_req->ab_len; | ||
295 | } else { | ||
296 | dh_req->z_len = (cop->crk_param[3].crp_nbits + 7)/8; | ||
297 | - pkc_req->type = DH_COMPUTE_KEY; | ||
298 | } | ||
299 | buf_size += dh_req->z_len; | ||
300 | buf = kmalloc(buf_size, GFP_DMA); | ||
301 | @@ -539,7 +519,7 @@ int crypto_kop_dh_key(struct cryptodev_pkc *pkc) | ||
302 | dh_req->z = dh_req->pub_key + dh_req->pub_key_len; | ||
303 | if (cop->crk_iparams == 4) { | ||
304 | dh_req->ab = dh_req->z + dh_req->z_len; | ||
305 | - pkc_req->curve_type = cop->curve_type; | ||
306 | + pkc->req->curve_type = cop->curve_type; | ||
307 | copy_from_user(dh_req->ab, cop->crk_param[3].crp_p, | ||
308 | dh_req->ab_len); | ||
309 | } | ||
310 | @@ -573,7 +553,6 @@ int crypto_modexp_crt(struct cryptodev_pkc *pkc) | ||
311 | { | ||
312 | struct kernel_crypt_kop *kop = &pkc->kop; | ||
313 | struct crypt_kop *cop = &kop->kop; | ||
314 | - struct pkc_request *pkc_req; | ||
315 | struct rsa_priv_frm3_req_s *rsa_req; | ||
316 | int rc; | ||
317 | uint8_t *buf; | ||
318 | @@ -583,9 +562,7 @@ int crypto_modexp_crt(struct cryptodev_pkc *pkc) | ||
319 | !cop->crk_param[4].crp_nbits || !cop->crk_param[5].crp_nbits) | ||
320 | return -EINVAL; | ||
321 | |||
322 | - pkc_req = &pkc->req; | ||
323 | - pkc_req->type = RSA_PRIV_FORM3; | ||
324 | - rsa_req = &pkc_req->req_u.rsa_priv_f3; | ||
325 | + rsa_req = &pkc->req->req_u.rsa_priv_f3; | ||
326 | rsa_req->p_len = (cop->crk_param[0].crp_nbits + 7)/8; | ||
327 | rsa_req->q_len = (cop->crk_param[1].crp_nbits + 7)/8; | ||
328 | rsa_req->g_len = (cop->crk_param[2].crp_nbits + 7)/8; | ||
329 | @@ -632,7 +609,6 @@ err: | ||
330 | |||
331 | int crypto_bn_modexp(struct cryptodev_pkc *pkc) | ||
332 | { | ||
333 | - struct pkc_request *pkc_req; | ||
334 | struct rsa_pub_req_s *rsa_req; | ||
335 | int rc; | ||
336 | struct kernel_crypt_kop *kop = &pkc->kop; | ||
337 | @@ -643,9 +619,7 @@ int crypto_bn_modexp(struct cryptodev_pkc *pkc) | ||
338 | !cop->crk_param[2].crp_nbits || !cop->crk_param[3].crp_nbits) | ||
339 | return -EINVAL; | ||
340 | |||
341 | - pkc_req = &pkc->req; | ||
342 | - pkc_req->type = RSA_PUB; | ||
343 | - rsa_req = &pkc_req->req_u.rsa_pub_req; | ||
344 | + rsa_req = &pkc->req->req_u.rsa_pub_req; | ||
345 | rsa_req->f_len = (cop->crk_param[0].crp_nbits + 7)/8; | ||
346 | rsa_req->e_len = (cop->crk_param[1].crp_nbits + 7)/8; | ||
347 | rsa_req->n_len = (cop->crk_param[2].crp_nbits + 7)/8; | ||
348 | @@ -680,56 +654,116 @@ err: | ||
349 | return rc; | ||
350 | } | ||
351 | |||
352 | +static struct { | ||
353 | + char *alg_name; | ||
354 | + u32 type; | ||
355 | + u32 mask; | ||
356 | +} pkc_alg_list[] = { | ||
357 | + {"pkc(rsa)", CRYPTO_ALG_TYPE_PKC_RSA, 0}, | ||
358 | + {"pkc(dsa)", CRYPTO_ALG_TYPE_PKC_DSA, 0}, | ||
359 | + {"pkc(dh)", CRYPTO_ALG_TYPE_PKC_DH, 0}, | ||
360 | +}; | ||
361 | + | ||
362 | int crypto_run_asym(struct cryptodev_pkc *pkc) | ||
363 | { | ||
364 | - int ret = -EINVAL; | ||
365 | + int err = -EINVAL; | ||
366 | + int id; | ||
367 | struct kernel_crypt_kop *kop = &pkc->kop; | ||
368 | + enum pkc_req_type pkc_req_type; | ||
369 | + int (*call_next_action)(struct cryptodev_pkc *pkc); | ||
370 | |||
371 | switch (kop->kop.crk_op) { | ||
372 | case CRK_MOD_EXP: | ||
373 | if (kop->kop.crk_iparams != 3 && kop->kop.crk_oparams != 1) | ||
374 | - goto err; | ||
375 | - | ||
376 | - ret = crypto_bn_modexp(pkc); | ||
377 | + return err; | ||
378 | + pkc_req_type = RSA_PUB; | ||
379 | + id = 0; | ||
380 | + call_next_action = crypto_bn_modexp; | ||
381 | break; | ||
382 | case CRK_MOD_EXP_CRT: | ||
383 | if (kop->kop.crk_iparams != 6 && kop->kop.crk_oparams != 1) | ||
384 | - goto err; | ||
385 | - | ||
386 | - ret = crypto_modexp_crt(pkc); | ||
387 | + return err; | ||
388 | + pkc_req_type = RSA_PRIV_FORM3; | ||
389 | + id = 0; | ||
390 | + call_next_action = crypto_modexp_crt; | ||
391 | break; | ||
392 | case CRK_DSA_SIGN: | ||
393 | - if ((kop->kop.crk_iparams != 5 && kop->kop.crk_iparams != 6) || | ||
394 | - kop->kop.crk_oparams != 2) | ||
395 | - goto err; | ||
396 | - | ||
397 | - ret = crypto_kop_dsasign(pkc); | ||
398 | + if (kop->kop.crk_oparams != 2) | ||
399 | + return err; | ||
400 | + else if (kop->kop.crk_iparams == 5) | ||
401 | + pkc_req_type = DSA_SIGN; | ||
402 | + else if (kop->kop.crk_iparams == 6) | ||
403 | + pkc_req_type = ECDSA_SIGN; | ||
404 | + else | ||
405 | + return err; | ||
406 | + id = 1; | ||
407 | + call_next_action = crypto_kop_dsasign; | ||
408 | break; | ||
409 | case CRK_DSA_VERIFY: | ||
410 | - if ((kop->kop.crk_iparams != 7 && kop->kop.crk_iparams != 8) || | ||
411 | - kop->kop.crk_oparams != 0) | ||
412 | - goto err; | ||
413 | - | ||
414 | - ret = crypto_kop_dsaverify(pkc); | ||
415 | + if (kop->kop.crk_oparams != 0) | ||
416 | + return err; | ||
417 | + else if (kop->kop.crk_iparams == 7) | ||
418 | + pkc_req_type = DSA_VERIFY; | ||
419 | + else if (kop->kop.crk_iparams == 8) | ||
420 | + pkc_req_type = ECDSA_VERIFY; | ||
421 | + else | ||
422 | + return err; | ||
423 | + id = 1; | ||
424 | + call_next_action = crypto_kop_dsaverify; | ||
425 | break; | ||
426 | case CRK_DH_COMPUTE_KEY: | ||
427 | - if ((kop->kop.crk_iparams != 3 && kop->kop.crk_iparams != 4) || | ||
428 | - kop->kop.crk_oparams != 1) | ||
429 | - goto err; | ||
430 | - ret = crypto_kop_dh_key(pkc); | ||
431 | + if (kop->kop.crk_oparams != 1) | ||
432 | + return err; | ||
433 | + else if (kop->kop.crk_iparams == 3) | ||
434 | + pkc_req_type = DH_COMPUTE_KEY; | ||
435 | + else if (kop->kop.crk_iparams == 4) | ||
436 | + pkc_req_type = ECDH_COMPUTE_KEY; | ||
437 | + else | ||
438 | + return err; | ||
439 | + id = 2; | ||
440 | + call_next_action = crypto_kop_dh_key; | ||
441 | break; | ||
442 | case CRK_DH_GENERATE_KEY: | ||
443 | case CRK_DSA_GENERATE_KEY: | ||
444 | - if ((kop->kop.crk_iparams != 3 && kop->kop.crk_iparams != 4)) | ||
445 | - goto err; | ||
446 | - ret = crypto_kop_keygen(pkc); | ||
447 | + if (kop->kop.crk_iparams == 3) | ||
448 | + pkc_req_type = DLC_KEYGEN; | ||
449 | + else if (kop->kop.crk_iparams == 4) | ||
450 | + pkc_req_type = ECC_KEYGEN; | ||
451 | + else | ||
452 | + return err; | ||
453 | + id = 1; | ||
454 | + call_next_action = crypto_kop_keygen; | ||
455 | break; | ||
456 | case CRK_RSA_GENERATE_KEY: | ||
457 | - ret = crypto_kop_rsa_keygen(pkc); | ||
458 | + pkc_req_type = RSA_KEYGEN; | ||
459 | + id = 0; | ||
460 | + call_next_action = crypto_kop_rsa_keygen; | ||
461 | break; | ||
462 | + default: | ||
463 | + return err; | ||
464 | } | ||
465 | -err: | ||
466 | - return ret; | ||
467 | + err = -ENOMEM; | ||
468 | + pkc->s = crypto_alloc_pkc(pkc_alg_list[id].alg_name, | ||
469 | + pkc_alg_list[id].type, | ||
470 | + pkc_alg_list[id].mask); | ||
471 | + if (IS_ERR_OR_NULL(pkc->s)) | ||
472 | + return err; | ||
473 | + | ||
474 | + pkc->req = pkc_request_alloc(pkc->s, GFP_KERNEL); | ||
475 | + if (IS_ERR_OR_NULL(pkc->req)) | ||
476 | + goto out_free_tfm; | ||
477 | + | ||
478 | + /* todo - fix alloc-free on error path */ | ||
479 | + pkc->req->type = pkc_req_type; | ||
480 | + err = call_next_action(pkc); | ||
481 | + if (pkc->type == SYNCHRONOUS) | ||
482 | + kfree(pkc->req); | ||
483 | + | ||
484 | + return err; | ||
485 | + | ||
486 | +out_free_tfm: | ||
487 | + crypto_free_pkc(pkc->s); | ||
488 | + return err; | ||
489 | } | ||
490 | |||
491 | int crypto_run(struct fcrypt *fcr, struct kernel_crypt_op *kcop) | ||
492 | -- | ||
493 | 2.7.0 | ||
494 | |||
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 @@ | |||
1 | From 212e418fa7b70c8ba79446006001c574cb9d42f8 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@freescale.com> | ||
3 | Date: Mon, 23 Feb 2015 15:28:22 +0200 | ||
4 | Subject: [PATCH 15/38] fix pkc request deallocation | ||
5 | |||
6 | The request to be freed is actually pkc->req, and should be done inside | ||
7 | the fetch ioctl for ASYNC (this patch) and in crypt ioctl for SYNC | ||
8 | operations. | ||
9 | |||
10 | Change-Id: I6f046f2ebeae4cb513a419996ca96b52e37468ed | ||
11 | Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> | ||
12 | Reviewed-on: http://git.am.freescale.net:8181/34224 | ||
13 | --- | ||
14 | ioctl.c | 3 +-- | ||
15 | 1 file changed, 1 insertion(+), 2 deletions(-) | ||
16 | |||
17 | diff --git a/ioctl.c b/ioctl.c | ||
18 | index 797b73c..da3a842 100644 | ||
19 | --- a/ioctl.c | ||
20 | +++ b/ioctl.c | ||
21 | @@ -114,8 +114,6 @@ void cryptodev_complete_asym(struct crypto_async_request *req, int err) | ||
22 | /* wake for POLLIN */ | ||
23 | wake_up_interruptible(&pcr->user_waiter); | ||
24 | } | ||
25 | - | ||
26 | - kfree(req); | ||
27 | } | ||
28 | |||
29 | #define FILL_SG(sg, ptr, len) \ | ||
30 | @@ -1113,6 +1111,7 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | ||
31 | cookie_list.cookie[i] = pkc->kop.kop.cookie; | ||
32 | cookie_list.status[i] = pkc->result.err; | ||
33 | } | ||
34 | + kfree(pkc->req); | ||
35 | kfree(pkc); | ||
36 | } else { | ||
37 | spin_unlock_bh(&pcr->completion_lock); | ||
38 | -- | ||
39 | 2.7.0 | ||
40 | |||
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 @@ | |||
1 | From 4ce4081d9abef651473e9d7e089a0748f77db631 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@freescale.com> | ||
3 | Date: Mon, 20 Apr 2015 13:18:47 +0300 | ||
4 | Subject: [PATCH 16/38] add basic detection of asym features | ||
5 | |||
6 | Change-Id: I3b3ba8664bf631a63be1f11e715024509e20f841 | ||
7 | Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> | ||
8 | --- | ||
9 | ioctl.c | 12 ++++++++---- | ||
10 | 1 file changed, 8 insertions(+), 4 deletions(-) | ||
11 | |||
12 | diff --git a/ioctl.c b/ioctl.c | ||
13 | index da3a842..53dbf64 100644 | ||
14 | --- a/ioctl.c | ||
15 | +++ b/ioctl.c | ||
16 | @@ -977,10 +977,14 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | ||
17 | |||
18 | switch (cmd) { | ||
19 | case CIOCASYMFEAT: | ||
20 | - return put_user(CRF_MOD_EXP_CRT | CRF_MOD_EXP | CRF_DSA_SIGN | | ||
21 | - CRF_DSA_VERIFY | CRF_DH_COMPUTE_KEY | | ||
22 | - CRF_DSA_GENERATE_KEY | CRF_DH_GENERATE_KEY | | ||
23 | - CRF_RSA_GENERATE_KEY, p); | ||
24 | + ses = 0; | ||
25 | + if (crypto_has_alg("pkc(rsa)", 0, 0)) | ||
26 | + ses = CRF_MOD_EXP_CRT | CRF_MOD_EXP | CRF_RSA_GENERATE_KEY; | ||
27 | + if (crypto_has_alg("pkc(dsa)", 0, 0)) | ||
28 | + ses |= CRF_DSA_SIGN | CRF_DSA_VERIFY | CRF_DSA_GENERATE_KEY; | ||
29 | + if (crypto_has_alg("pkc(dh)", 0, 0)) | ||
30 | + ses |= CRF_DH_COMPUTE_KEY |CRF_DH_GENERATE_KEY; | ||
31 | + return put_user(ses, p); | ||
32 | case CRIOGET: | ||
33 | fd = clonefd(filp); | ||
34 | ret = put_user(fd, p); | ||
35 | -- | ||
36 | 2.7.0 | ||
37 | |||
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 @@ | |||
1 | From 0ca641091b4113d73e75d30ef530c88836849308 Mon Sep 17 00:00:00 2001 | ||
2 | From: Tudor Ambarus <tudor.ambarus@freescale.com> | ||
3 | Date: Fri, 29 May 2015 15:28:47 +0300 | ||
4 | Subject: [PATCH 17/38] remove dead code | ||
5 | |||
6 | Functions kop_to_user and compat_kop_to_user are never used. Delete them | ||
7 | to avoid compiler warnings. | ||
8 | |||
9 | |||
10 | crypto/../../cryptodev-linux/ioctl.c:841:12: warning: 'kop_to_user' defined but not used [-Wunused-function] | ||
11 | static int kop_to_user(struct kernel_crypt_kop *kop, | ||
12 | ^ | ||
13 | crypto/../../cryptodev-linux/ioctl.c: At top level: | ||
14 | crypto/../../cryptodev-linux/ioctl.c:1195:12: warning: 'compat_kop_to_user' defined but not used [-Wunused-function] | ||
15 | static int compat_kop_to_user(struct kernel_crypt_kop *kop, void __user *arg) | ||
16 | ^ | ||
17 | Signed-off-by: Tudor Ambarus <tudor.ambarus@freescale.com> | ||
18 | Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> | ||
19 | Change-Id: I6bd8a7eb6144224a20cd400813ab15a7a192dbb1 | ||
20 | Reviewed-on: http://git.am.freescale.net:8181/37440 | ||
21 | --- | ||
22 | ioctl.c | 22 ---------------------- | ||
23 | 1 file changed, 22 deletions(-) | ||
24 | |||
25 | diff --git a/ioctl.c b/ioctl.c | ||
26 | index 53dbf64..39635a4 100644 | ||
27 | --- a/ioctl.c | ||
28 | +++ b/ioctl.c | ||
29 | @@ -838,16 +838,6 @@ static int kop_from_user(struct kernel_crypt_kop *kop, | ||
30 | return fill_kop_from_cop(kop); | ||
31 | } | ||
32 | |||
33 | -static int kop_to_user(struct kernel_crypt_kop *kop, | ||
34 | - void __user *arg) | ||
35 | -{ | ||
36 | - if (unlikely(copy_to_user(arg, &kop->kop, sizeof(kop->kop)))) { | ||
37 | - dprintk(1, KERN_ERR, "Cannot copy to userspace\n"); | ||
38 | - return -EFAULT; | ||
39 | - } | ||
40 | - return 0; | ||
41 | -} | ||
42 | - | ||
43 | static int kcop_from_user(struct kernel_crypt_op *kcop, | ||
44 | struct fcrypt *fcr, void __user *arg) | ||
45 | { | ||
46 | @@ -1192,18 +1182,6 @@ static inline void crypt_kop_to_compat(struct crypt_kop *kop, | ||
47 | compat->curve_type = kop->curve_type; | ||
48 | } | ||
49 | |||
50 | -static int compat_kop_to_user(struct kernel_crypt_kop *kop, void __user *arg) | ||
51 | -{ | ||
52 | - struct compat_crypt_kop compat_kop; | ||
53 | - | ||
54 | - crypt_kop_to_compat(&kop->kop, &compat_kop); | ||
55 | - if (unlikely(copy_to_user(arg, &compat_kop, sizeof(compat_kop)))) { | ||
56 | - dprintk(1, KERN_ERR, "Cannot copy to userspace\n"); | ||
57 | - return -EFAULT; | ||
58 | - } | ||
59 | - return 0; | ||
60 | -} | ||
61 | - | ||
62 | static inline void | ||
63 | compat_to_session_op(struct compat_session_op *compat, struct session_op *sop) | ||
64 | { | ||
65 | -- | ||
66 | 2.7.0 | ||
67 | |||
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 @@ | |||
1 | From 596378a22532908487f2c5e4d717c5ae618c4c7d Mon Sep 17 00:00:00 2001 | ||
2 | From: Tudor Ambarus <tudor.ambarus@freescale.com> | ||
3 | Date: Tue, 2 Jun 2015 10:44:12 +0300 | ||
4 | Subject: [PATCH 18/38] fix compat warnings | ||
5 | |||
6 | CC [M] crypto/../../cryptodev-linux/ioctl.o | ||
7 | crypto/../../cryptodev-linux/ioctl.c: In function 'compat_to_crypt_kop': | ||
8 | crypto/../../cryptodev-linux/ioctl.c:1161:14: warning: assignment makes pointer from integer without a cast | ||
9 | kop->cookie = compat->cookie; | ||
10 | ^ | ||
11 | crypto/../../cryptodev-linux/ioctl.c: In function 'crypt_kop_to_compat': | ||
12 | crypto/../../cryptodev-linux/ioctl.c:1191:17: warning: assignment makes integer from pointer without a cast | ||
13 | compat->cookie = kop->cookie; | ||
14 | ^ | ||
15 | crypto/../../cryptodev-linux/ioctl.c: In function 'cryptodev_compat_ioctl': | ||
16 | crypto/../../cryptodev-linux/ioctl.c:1430:28: warning: assignment makes integer from pointer without a cast | ||
17 | cookie_list.cookie[i] = | ||
18 | ^ | ||
19 | |||
20 | Signed-off-by: Tudor Ambarus <tudor.ambarus@freescale.com> | ||
21 | Change-Id: Id851408c0c743c01447f3b0ced38fbc1ae94d4db | ||
22 | Reviewed-on: http://git.am.freescale.net:8181/37442 | ||
23 | Reviewed-by: Cristian Stoica <cristian.stoica@freescale.com> | ||
24 | Tested-by: Cristian Stoica <cristian.stoica@freescale.com> | ||
25 | --- | ||
26 | ioctl.c | 8 ++++---- | ||
27 | 1 file changed, 4 insertions(+), 4 deletions(-) | ||
28 | |||
29 | diff --git a/ioctl.c b/ioctl.c | ||
30 | index 39635a4..f3ce2f6 100644 | ||
31 | --- a/ioctl.c | ||
32 | +++ b/ioctl.c | ||
33 | @@ -1148,7 +1148,7 @@ static inline void compat_to_crypt_kop(struct compat_crypt_kop *compat, | ||
34 | } | ||
35 | |||
36 | kop->curve_type = compat->curve_type; | ||
37 | - kop->cookie = compat->cookie; | ||
38 | + kop->cookie = compat_ptr(compat->cookie); | ||
39 | } | ||
40 | |||
41 | static int compat_kop_from_user(struct kernel_crypt_kop *kop, | ||
42 | @@ -1178,7 +1178,7 @@ static inline void crypt_kop_to_compat(struct crypt_kop *kop, | ||
43 | ptr_to_compat(kop->crk_param[i].crp_p); | ||
44 | compat->crk_param[i].crp_nbits = kop->crk_param[i].crp_nbits; | ||
45 | } | ||
46 | - compat->cookie = kop->cookie; | ||
47 | + compat->cookie = ptr_to_compat(kop->cookie); | ||
48 | compat->curve_type = kop->curve_type; | ||
49 | } | ||
50 | |||
51 | @@ -1405,8 +1405,8 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) | ||
52 | ret = crypto_async_fetch_asym(pkc); | ||
53 | if (!ret) { | ||
54 | cookie_list.cookie_available++; | ||
55 | - cookie_list.cookie[i] = | ||
56 | - pkc->kop.kop.cookie; | ||
57 | + cookie_list.cookie[i] = ptr_to_compat( | ||
58 | + pkc->kop.kop.cookie); | ||
59 | } | ||
60 | kfree(pkc); | ||
61 | } else { | ||
62 | -- | ||
63 | 2.7.0 | ||
64 | |||
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 @@ | |||
1 | From 1d10f06bef0f07980a08b387850c1daf1d3a8e87 Mon Sep 17 00:00:00 2001 | ||
2 | From: Tudor Ambarus <tudor.ambarus@freescale.com> | ||
3 | Date: Tue, 2 Jun 2015 12:11:12 +0300 | ||
4 | Subject: [PATCH 19/38] fix size_t print format | ||
5 | |||
6 | CC [M] crypto/../../cryptodev-linux/cryptlib.o | ||
7 | crypto/../../cryptodev-linux/cryptlib.c: In function 'cryptodev_cipher_init': | ||
8 | crypto/../../cryptodev-linux/cryptlib.c:146:5: warning: format '%u' expects argument of type 'unsigned int', but argument 6 has type 'size_t' [-Wformat=] | ||
9 | ddebug(1, "Wrong keylen '%u' for algorithm '%s'. Use %u to %u.", | ||
10 | ^ | ||
11 | crypto/../../cryptodev-linux/cryptlib.c:173:3: warning: format '%u' expects argument of type 'unsigned int', but argument 7 has type 'size_t' [-Wformat=] | ||
12 | ddebug(1, "Setting key failed for %s-%u.", alg_name, keylen*8); | ||
13 | ^ | ||
14 | crypto/../../cryptodev-linux/cryptlib.c: In function 'cryptodev_hash_init': | ||
15 | crypto/../../cryptodev-linux/cryptlib.c:340:4: warning: format '%u' expects argument of type 'unsigned int', but argument 7 has type 'size_t' [-Wformat=] | ||
16 | ddebug(1, "Setting hmac key failed for %s-%u.", | ||
17 | ^ | ||
18 | |||
19 | Signed-off-by: Tudor Ambarus <tudor.ambarus@freescale.com> | ||
20 | Change-Id: I67f2d79f68b4d62b598073c6a918a110523fadfd | ||
21 | Reviewed-on: http://git.am.freescale.net:8181/37443 | ||
22 | Reviewed-by: Cristian Stoica <cristian.stoica@freescale.com> | ||
23 | Tested-by: Cristian Stoica <cristian.stoica@freescale.com> | ||
24 | --- | ||
25 | cryptlib.c | 6 +++--- | ||
26 | 1 file changed, 3 insertions(+), 3 deletions(-) | ||
27 | |||
28 | diff --git a/cryptlib.c b/cryptlib.c | ||
29 | index 5882a30..10f5e1a 100644 | ||
30 | --- a/cryptlib.c | ||
31 | +++ b/cryptlib.c | ||
32 | @@ -143,7 +143,7 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, | ||
33 | if (alg->max_keysize > 0 && | ||
34 | unlikely((keylen < alg->min_keysize) || | ||
35 | (keylen > alg->max_keysize))) { | ||
36 | - ddebug(1, "Wrong keylen '%u' for algorithm '%s'. Use %u to %u.", | ||
37 | + ddebug(1, "Wrong keylen '%zu' for algorithm '%s'. Use %u to %u.", | ||
38 | keylen, alg_name, alg->min_keysize, alg->max_keysize); | ||
39 | ret = -EINVAL; | ||
40 | goto error; | ||
41 | @@ -170,7 +170,7 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, | ||
42 | } | ||
43 | |||
44 | if (unlikely(ret)) { | ||
45 | - ddebug(1, "Setting key failed for %s-%u.", alg_name, keylen*8); | ||
46 | + ddebug(1, "Setting key failed for %s-%zu.", alg_name, keylen*8); | ||
47 | ret = -EINVAL; | ||
48 | goto error; | ||
49 | } | ||
50 | @@ -337,7 +337,7 @@ int cryptodev_hash_init(struct hash_data *hdata, const char *alg_name, | ||
51 | if (hmac_mode != 0) { | ||
52 | ret = crypto_ahash_setkey(hdata->async.s, mackey, mackeylen); | ||
53 | if (unlikely(ret)) { | ||
54 | - ddebug(1, "Setting hmac key failed for %s-%u.", | ||
55 | + ddebug(1, "Setting hmac key failed for %s-%zu.", | ||
56 | alg_name, mackeylen*8); | ||
57 | ret = -EINVAL; | ||
58 | goto error; | ||
59 | -- | ||
60 | 2.7.0 | ||
61 | |||
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 @@ | |||
1 | From be9f6a0dc90847dbb00307d23f47b8b3fc3ff130 Mon Sep 17 00:00:00 2001 | ||
2 | From: Tudor Ambarus <tudor.ambarus@freescale.com> | ||
3 | Date: Fri, 29 May 2015 15:49:22 +0300 | ||
4 | Subject: [PATCH 20/38] fix uninitialized variable compiler warning | ||
5 | |||
6 | crypto/../../cryptodev-linux/ioctl.c: In function 'cryptodev_compat_ioctl': | ||
7 | crypto/../../cryptodev-linux/ioctl.c:1445:2: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized] | ||
8 | return ret; | ||
9 | ^ | ||
10 | |||
11 | Signed-off-by: Tudor Ambarus <tudor.ambarus@freescale.com> | ||
12 | Change-Id: Id5226fc97a3bb880ca6db86df58957122bbaa428 | ||
13 | Reviewed-on: http://git.am.freescale.net:8181/37441 | ||
14 | Reviewed-by: Cristian Stoica <cristian.stoica@freescale.com> | ||
15 | Tested-by: Cristian Stoica <cristian.stoica@freescale.com> | ||
16 | --- | ||
17 | ioctl.c | 3 ++- | ||
18 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
19 | |||
20 | diff --git a/ioctl.c b/ioctl.c | ||
21 | index f3ce2f6..7cd3c56 100644 | ||
22 | --- a/ioctl.c | ||
23 | +++ b/ioctl.c | ||
24 | @@ -1387,9 +1387,10 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) | ||
25 | case COMPAT_CIOCASYMFETCHCOOKIE: | ||
26 | { | ||
27 | struct cryptodev_pkc *pkc; | ||
28 | - int i = 0; | ||
29 | + int i; | ||
30 | struct compat_pkc_cookie_list_s cookie_list; | ||
31 | |||
32 | + ret = 0; | ||
33 | cookie_list.cookie_available = 0; | ||
34 | |||
35 | for (i = 0; i < MAX_COOKIES; i++) { | ||
36 | -- | ||
37 | 2.7.0 | ||
38 | |||
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 @@ | |||
1 | From 4078382cfc69c0f5e582d485fe8cc778f9e458d1 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@freescale.com> | ||
3 | Date: Mon, 21 Sep 2015 16:39:52 +0300 | ||
4 | Subject: [PATCH 21/38] check return codes for copy to/from user functions | ||
5 | |||
6 | - these functions may fail and we should check their return codes. | ||
7 | - fix an unintended fall-through in CRK_DSA_GENERATE_KEY | ||
8 | - fix incorrect return code for CIOCASYMFETCHCOOKIE | ||
9 | |||
10 | Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> | ||
11 | --- | ||
12 | ioctl.c | 42 +++++++-------- | ||
13 | main.c | 183 ++++++++++++++++++++++++++++++---------------------------------- | ||
14 | 2 files changed, 108 insertions(+), 117 deletions(-) | ||
15 | |||
16 | diff --git a/ioctl.c b/ioctl.c | ||
17 | index 7cd3c56..8fa3e5c 100644 | ||
18 | --- a/ioctl.c | ||
19 | +++ b/ioctl.c | ||
20 | @@ -711,13 +711,13 @@ static int crypto_async_fetch_asym(struct cryptodev_pkc *pkc) | ||
21 | case CRK_MOD_EXP: | ||
22 | { | ||
23 | struct rsa_pub_req_s *rsa_req = &pkc->req->req_u.rsa_pub_req; | ||
24 | - copy_to_user(ckop->crk_param[3].crp_p, rsa_req->g, rsa_req->g_len); | ||
25 | + ret = copy_to_user(ckop->crk_param[3].crp_p, rsa_req->g, rsa_req->g_len); | ||
26 | } | ||
27 | break; | ||
28 | case CRK_MOD_EXP_CRT: | ||
29 | { | ||
30 | struct rsa_priv_frm3_req_s *rsa_req = &pkc->req->req_u.rsa_priv_f3; | ||
31 | - copy_to_user(ckop->crk_param[6].crp_p, rsa_req->f, rsa_req->f_len); | ||
32 | + ret = copy_to_user(ckop->crk_param[6].crp_p, rsa_req->f, rsa_req->f_len); | ||
33 | } | ||
34 | break; | ||
35 | case CRK_DSA_SIGN: | ||
36 | @@ -725,11 +725,11 @@ static int crypto_async_fetch_asym(struct cryptodev_pkc *pkc) | ||
37 | struct dsa_sign_req_s *dsa_req = &pkc->req->req_u.dsa_sign; | ||
38 | |||
39 | if (pkc->req->type == ECDSA_SIGN) { | ||
40 | - copy_to_user(ckop->crk_param[6].crp_p, dsa_req->c, dsa_req->d_len); | ||
41 | - copy_to_user(ckop->crk_param[7].crp_p, dsa_req->d, dsa_req->d_len); | ||
42 | + ret = copy_to_user(ckop->crk_param[6].crp_p, dsa_req->c, dsa_req->d_len) || | ||
43 | + copy_to_user(ckop->crk_param[7].crp_p, dsa_req->d, dsa_req->d_len); | ||
44 | } else { | ||
45 | - copy_to_user(ckop->crk_param[5].crp_p, dsa_req->c, dsa_req->d_len); | ||
46 | - copy_to_user(ckop->crk_param[6].crp_p, dsa_req->d, dsa_req->d_len); | ||
47 | + ret = copy_to_user(ckop->crk_param[5].crp_p, dsa_req->c, dsa_req->d_len) || | ||
48 | + copy_to_user(ckop->crk_param[6].crp_p, dsa_req->d, dsa_req->d_len); | ||
49 | } | ||
50 | } | ||
51 | break; | ||
52 | @@ -739,9 +739,9 @@ static int crypto_async_fetch_asym(struct cryptodev_pkc *pkc) | ||
53 | { | ||
54 | struct dh_key_req_s *dh_req = &pkc->req->req_u.dh_req; | ||
55 | if (pkc->req->type == ECDH_COMPUTE_KEY) | ||
56 | - copy_to_user(ckop->crk_param[4].crp_p, dh_req->z, dh_req->z_len); | ||
57 | + ret = copy_to_user(ckop->crk_param[4].crp_p, dh_req->z, dh_req->z_len); | ||
58 | else | ||
59 | - copy_to_user(ckop->crk_param[3].crp_p, dh_req->z, dh_req->z_len); | ||
60 | + ret = copy_to_user(ckop->crk_param[3].crp_p, dh_req->z, dh_req->z_len); | ||
61 | } | ||
62 | break; | ||
63 | case CRK_DSA_GENERATE_KEY: | ||
64 | @@ -750,16 +750,17 @@ static int crypto_async_fetch_asym(struct cryptodev_pkc *pkc) | ||
65 | struct keygen_req_s *key_req = &pkc->req->req_u.keygen; | ||
66 | |||
67 | if (pkc->req->type == ECC_KEYGEN) { | ||
68 | - copy_to_user(ckop->crk_param[4].crp_p, key_req->pub_key, | ||
69 | - key_req->pub_key_len); | ||
70 | - copy_to_user(ckop->crk_param[5].crp_p, key_req->priv_key, | ||
71 | + ret = copy_to_user(ckop->crk_param[4].crp_p, key_req->pub_key, | ||
72 | + key_req->pub_key_len) || | ||
73 | + copy_to_user(ckop->crk_param[5].crp_p, key_req->priv_key, | ||
74 | key_req->priv_key_len); | ||
75 | } else { | ||
76 | - copy_to_user(ckop->crk_param[3].crp_p, key_req->pub_key, | ||
77 | - key_req->pub_key_len); | ||
78 | - copy_to_user(ckop->crk_param[4].crp_p, key_req->priv_key, | ||
79 | + ret = copy_to_user(ckop->crk_param[3].crp_p, key_req->pub_key, | ||
80 | + key_req->pub_key_len) || | ||
81 | + copy_to_user(ckop->crk_param[4].crp_p, key_req->priv_key, | ||
82 | key_req->priv_key_len); | ||
83 | } | ||
84 | + break; | ||
85 | } | ||
86 | default: | ||
87 | ret = -EINVAL; | ||
88 | @@ -1115,14 +1116,12 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | ||
89 | |||
90 | /* Reflect the updated request to user-space */ | ||
91 | if (cookie_list.cookie_available) { | ||
92 | - copy_to_user(arg, &cookie_list, sizeof(struct pkc_cookie_list_s)); | ||
93 | + ret = copy_to_user(arg, &cookie_list, sizeof(struct pkc_cookie_list_s)); | ||
94 | } else { | ||
95 | struct pkc_cookie_list_s *user_ck_list = (void *)arg; | ||
96 | - put_user(0, &(user_ck_list->cookie_available)); | ||
97 | + ret = put_user(0, &(user_ck_list->cookie_available)); | ||
98 | } | ||
99 | - ret = cookie_list.cookie_available; | ||
100 | } | ||
101 | - | ||
102 | return ret; | ||
103 | default: | ||
104 | return -EINVAL; | ||
105 | @@ -1417,9 +1416,10 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) | ||
106 | } | ||
107 | |||
108 | /* Reflect the updated request to user-space */ | ||
109 | - if (cookie_list.cookie_available) | ||
110 | - copy_to_user(arg, &cookie_list, | ||
111 | - sizeof(struct compat_pkc_cookie_list_s)); | ||
112 | + if (cookie_list.cookie_available) { | ||
113 | + ret = copy_to_user(arg, &cookie_list, | ||
114 | + sizeof(struct compat_pkc_cookie_list_s)); | ||
115 | + } | ||
116 | } | ||
117 | return ret; | ||
118 | default: | ||
119 | diff --git a/main.c b/main.c | ||
120 | index ed1c69a..e5adb93 100644 | ||
121 | --- a/main.c | ||
122 | +++ b/main.c | ||
123 | @@ -223,31 +223,29 @@ int crypto_kop_dsasign(struct cryptodev_pkc *pkc) | ||
124 | dsa_req->m = dsa_req->priv_key + dsa_req->priv_key_len; | ||
125 | dsa_req->c = dsa_req->m + dsa_req->m_len; | ||
126 | dsa_req->d = dsa_req->c + dsa_req->d_len; | ||
127 | - copy_from_user(dsa_req->m, cop->crk_param[0].crp_p, dsa_req->m_len); | ||
128 | - copy_from_user(dsa_req->q, cop->crk_param[1].crp_p, dsa_req->q_len); | ||
129 | - copy_from_user(dsa_req->r, cop->crk_param[2].crp_p, dsa_req->r_len); | ||
130 | - copy_from_user(dsa_req->g, cop->crk_param[3].crp_p, dsa_req->g_len); | ||
131 | - copy_from_user(dsa_req->priv_key, cop->crk_param[4].crp_p, | ||
132 | - dsa_req->priv_key_len); | ||
133 | + rc = copy_from_user(dsa_req->m, cop->crk_param[0].crp_p, dsa_req->m_len) || | ||
134 | + copy_from_user(dsa_req->q, cop->crk_param[1].crp_p, dsa_req->q_len) || | ||
135 | + copy_from_user(dsa_req->r, cop->crk_param[2].crp_p, dsa_req->r_len) || | ||
136 | + copy_from_user(dsa_req->g, cop->crk_param[3].crp_p, dsa_req->g_len) || | ||
137 | + copy_from_user(dsa_req->priv_key, cop->crk_param[4].crp_p, dsa_req->priv_key_len); | ||
138 | if (cop->crk_iparams == 6) { | ||
139 | dsa_req->ab = dsa_req->d + dsa_req->d_len; | ||
140 | - copy_from_user(dsa_req->ab, cop->crk_param[5].crp_p, | ||
141 | + rc = rc || copy_from_user(dsa_req->ab, cop->crk_param[5].crp_p, | ||
142 | dsa_req->ab_len); | ||
143 | } | ||
144 | + if (rc) | ||
145 | + goto err; | ||
146 | + | ||
147 | rc = cryptodev_pkc_offload(pkc); | ||
148 | if (pkc->type == SYNCHRONOUS) { | ||
149 | - if (rc) | ||
150 | - goto err; | ||
151 | if (cop->crk_iparams == 6) { | ||
152 | - copy_to_user(cop->crk_param[6].crp_p, dsa_req->c, | ||
153 | - dsa_req->d_len); | ||
154 | - copy_to_user(cop->crk_param[7].crp_p, dsa_req->d, | ||
155 | - dsa_req->d_len); | ||
156 | + rc = rc || | ||
157 | + copy_to_user(cop->crk_param[6].crp_p, dsa_req->c, dsa_req->d_len) || | ||
158 | + copy_to_user(cop->crk_param[7].crp_p, dsa_req->d, dsa_req->d_len); | ||
159 | } else { | ||
160 | - copy_to_user(cop->crk_param[5].crp_p, dsa_req->c, | ||
161 | - dsa_req->d_len); | ||
162 | - copy_to_user(cop->crk_param[6].crp_p, dsa_req->d, | ||
163 | - dsa_req->d_len); | ||
164 | + rc = rc || | ||
165 | + copy_to_user(cop->crk_param[5].crp_p, dsa_req->c, dsa_req->d_len) || | ||
166 | + copy_to_user(cop->crk_param[6].crp_p, dsa_req->d, dsa_req->d_len); | ||
167 | } | ||
168 | } else { | ||
169 | if (rc != -EINPROGRESS && rc != 0) | ||
170 | @@ -303,31 +301,28 @@ int crypto_kop_dsaverify(struct cryptodev_pkc *pkc) | ||
171 | dsa_req->m = dsa_req->pub_key + dsa_req->pub_key_len; | ||
172 | dsa_req->c = dsa_req->m + dsa_req->m_len; | ||
173 | dsa_req->d = dsa_req->c + dsa_req->d_len; | ||
174 | - copy_from_user(dsa_req->m, cop->crk_param[0].crp_p, dsa_req->m_len); | ||
175 | - copy_from_user(dsa_req->q, cop->crk_param[1].crp_p, dsa_req->q_len); | ||
176 | - copy_from_user(dsa_req->r, cop->crk_param[2].crp_p, dsa_req->r_len); | ||
177 | - copy_from_user(dsa_req->g, cop->crk_param[3].crp_p, dsa_req->g_len); | ||
178 | - copy_from_user(dsa_req->pub_key, cop->crk_param[4].crp_p, | ||
179 | - dsa_req->pub_key_len); | ||
180 | + rc = copy_from_user(dsa_req->m, cop->crk_param[0].crp_p, dsa_req->m_len) || | ||
181 | + copy_from_user(dsa_req->q, cop->crk_param[1].crp_p, dsa_req->q_len) || | ||
182 | + copy_from_user(dsa_req->r, cop->crk_param[2].crp_p, dsa_req->r_len) || | ||
183 | + copy_from_user(dsa_req->g, cop->crk_param[3].crp_p, dsa_req->g_len) || | ||
184 | + copy_from_user(dsa_req->pub_key, cop->crk_param[4].crp_p, dsa_req->pub_key_len); | ||
185 | if (cop->crk_iparams == 8) { | ||
186 | dsa_req->ab = dsa_req->d + dsa_req->d_len; | ||
187 | - copy_from_user(dsa_req->ab, cop->crk_param[5].crp_p, | ||
188 | - dsa_req->ab_len); | ||
189 | - copy_from_user(dsa_req->c, cop->crk_param[6].crp_p, | ||
190 | - dsa_req->d_len); | ||
191 | - copy_from_user(dsa_req->d, cop->crk_param[7].crp_p, | ||
192 | - dsa_req->d_len); | ||
193 | + rc = rc || | ||
194 | + copy_from_user(dsa_req->ab, cop->crk_param[5].crp_p, dsa_req->ab_len) || | ||
195 | + copy_from_user(dsa_req->c, cop->crk_param[6].crp_p, dsa_req->d_len) || | ||
196 | + copy_from_user(dsa_req->d, cop->crk_param[7].crp_p, dsa_req->d_len); | ||
197 | } else { | ||
198 | - copy_from_user(dsa_req->c, cop->crk_param[5].crp_p, | ||
199 | - dsa_req->d_len); | ||
200 | - copy_from_user(dsa_req->d, cop->crk_param[6].crp_p, | ||
201 | - dsa_req->d_len); | ||
202 | + rc = rc || | ||
203 | + copy_from_user(dsa_req->c, cop->crk_param[5].crp_p, dsa_req->d_len) || | ||
204 | + copy_from_user(dsa_req->d, cop->crk_param[6].crp_p, dsa_req->d_len); | ||
205 | } | ||
206 | + | ||
207 | + if (rc) | ||
208 | + goto err; | ||
209 | + | ||
210 | rc = cryptodev_pkc_offload(pkc); | ||
211 | - if (pkc->type == SYNCHRONOUS) { | ||
212 | - if (rc) | ||
213 | - goto err; | ||
214 | - } else { | ||
215 | + if (pkc->type != SYNCHRONOUS) { | ||
216 | if (rc != -EINPROGRESS && !rc) | ||
217 | goto err; | ||
218 | pkc->cookie = buf; | ||
219 | @@ -380,24 +375,15 @@ int crypto_kop_rsa_keygen(struct cryptodev_pkc *pkc) | ||
220 | rc = cryptodev_pkc_offload(pkc); | ||
221 | |||
222 | if (pkc->type == SYNCHRONOUS) { | ||
223 | - if (rc) | ||
224 | - goto err; | ||
225 | - | ||
226 | - copy_to_user(cop->crk_param[0].crp_p, | ||
227 | - key_req->p, key_req->p_len); | ||
228 | - copy_to_user(cop->crk_param[1].crp_p, | ||
229 | - key_req->q, key_req->q_len); | ||
230 | - copy_to_user(cop->crk_param[2].crp_p, | ||
231 | - key_req->n, key_req->n_len); | ||
232 | - copy_to_user(cop->crk_param[3].crp_p, | ||
233 | - key_req->d, key_req->d_len); | ||
234 | - copy_to_user(cop->crk_param[4].crp_p, | ||
235 | - key_req->dp, key_req->dp_len); | ||
236 | - copy_to_user(cop->crk_param[5].crp_p, | ||
237 | - key_req->dq, key_req->dq_len); | ||
238 | - copy_to_user(cop->crk_param[6].crp_p, | ||
239 | - key_req->c, key_req->c_len); | ||
240 | - } else { | ||
241 | + rc = rc || | ||
242 | + copy_to_user(cop->crk_param[0].crp_p, key_req->p, key_req->p_len) || | ||
243 | + copy_to_user(cop->crk_param[1].crp_p, key_req->q, key_req->q_len) || | ||
244 | + copy_to_user(cop->crk_param[2].crp_p, key_req->n, key_req->n_len) || | ||
245 | + copy_to_user(cop->crk_param[3].crp_p, key_req->d, key_req->d_len) || | ||
246 | + copy_to_user(cop->crk_param[4].crp_p, key_req->dp, key_req->dp_len) || | ||
247 | + copy_to_user(cop->crk_param[5].crp_p, key_req->dq, key_req->dq_len) || | ||
248 | + copy_to_user(cop->crk_param[6].crp_p, key_req->c, key_req->c_len); | ||
249 | + } else { | ||
250 | if (rc != -EINPROGRESS && !rc) { | ||
251 | printk("%s: Failed\n", __func__); | ||
252 | goto err; | ||
253 | @@ -451,30 +437,33 @@ int crypto_kop_keygen(struct cryptodev_pkc *pkc) | ||
254 | key_req->g = key_req->r + key_req->r_len; | ||
255 | key_req->pub_key = key_req->g + key_req->g_len; | ||
256 | key_req->priv_key = key_req->pub_key + key_req->pub_key_len; | ||
257 | - copy_from_user(key_req->q, cop->crk_param[0].crp_p, key_req->q_len); | ||
258 | - copy_from_user(key_req->r, cop->crk_param[1].crp_p, key_req->r_len); | ||
259 | - copy_from_user(key_req->g, cop->crk_param[2].crp_p, key_req->g_len); | ||
260 | + rc = copy_from_user(key_req->q, cop->crk_param[0].crp_p, key_req->q_len) || | ||
261 | + copy_from_user(key_req->r, cop->crk_param[1].crp_p, key_req->r_len) || | ||
262 | + copy_from_user(key_req->g, cop->crk_param[2].crp_p, key_req->g_len); | ||
263 | + | ||
264 | if (cop->crk_iparams == 4) { | ||
265 | key_req->ab = key_req->priv_key + key_req->priv_key_len; | ||
266 | - copy_from_user(key_req->ab, cop->crk_param[3].crp_p, | ||
267 | + rc = rc || copy_from_user(key_req->ab, cop->crk_param[3].crp_p, | ||
268 | key_req->ab_len); | ||
269 | } | ||
270 | |||
271 | + if (rc) | ||
272 | + goto err; | ||
273 | + | ||
274 | rc = cryptodev_pkc_offload(pkc); | ||
275 | if (pkc->type == SYNCHRONOUS) { | ||
276 | - if (rc) | ||
277 | - goto err; | ||
278 | - | ||
279 | if (cop->crk_iparams == 4) { | ||
280 | - copy_to_user(cop->crk_param[4].crp_p, key_req->pub_key, | ||
281 | - key_req->pub_key_len); | ||
282 | - copy_to_user(cop->crk_param[5].crp_p, key_req->priv_key, | ||
283 | + rc = rc || | ||
284 | + copy_to_user(cop->crk_param[4].crp_p, key_req->pub_key, | ||
285 | + key_req->pub_key_len) || | ||
286 | + copy_to_user(cop->crk_param[5].crp_p, key_req->priv_key, | ||
287 | key_req->priv_key_len); | ||
288 | } else { | ||
289 | - copy_to_user(cop->crk_param[3].crp_p, key_req->pub_key, | ||
290 | - key_req->pub_key_len); | ||
291 | - copy_to_user(cop->crk_param[4].crp_p, | ||
292 | - key_req->priv_key, key_req->priv_key_len); | ||
293 | + rc = rc || | ||
294 | + copy_to_user(cop->crk_param[3].crp_p, key_req->pub_key, | ||
295 | + key_req->pub_key_len) || | ||
296 | + copy_to_user(cop->crk_param[4].crp_p, key_req->priv_key, | ||
297 | + key_req->priv_key_len); | ||
298 | } | ||
299 | } else { | ||
300 | if (rc != -EINPROGRESS && !rc) | ||
301 | @@ -495,7 +484,7 @@ int crypto_kop_dh_key(struct cryptodev_pkc *pkc) | ||
302 | struct dh_key_req_s *dh_req; | ||
303 | int buf_size; | ||
304 | uint8_t *buf; | ||
305 | - int rc = -EINVAL; | ||
306 | + int rc = 0; | ||
307 | |||
308 | dh_req = &pkc->req->req_u.dh_req; | ||
309 | dh_req->s_len = (cop->crk_param[0].crp_nbits + 7)/8; | ||
310 | @@ -520,22 +509,23 @@ int crypto_kop_dh_key(struct cryptodev_pkc *pkc) | ||
311 | if (cop->crk_iparams == 4) { | ||
312 | dh_req->ab = dh_req->z + dh_req->z_len; | ||
313 | pkc->req->curve_type = cop->curve_type; | ||
314 | - copy_from_user(dh_req->ab, cop->crk_param[3].crp_p, | ||
315 | - dh_req->ab_len); | ||
316 | + rc = copy_from_user(dh_req->ab, cop->crk_param[3].crp_p, dh_req->ab_len); | ||
317 | } | ||
318 | - copy_from_user(dh_req->s, cop->crk_param[0].crp_p, dh_req->s_len); | ||
319 | - copy_from_user(dh_req->pub_key, cop->crk_param[1].crp_p, | ||
320 | - dh_req->pub_key_len); | ||
321 | - copy_from_user(dh_req->q, cop->crk_param[2].crp_p, dh_req->q_len); | ||
322 | + | ||
323 | + rc = rc || | ||
324 | + copy_from_user(dh_req->s, cop->crk_param[0].crp_p, dh_req->s_len) || | ||
325 | + copy_from_user(dh_req->pub_key, cop->crk_param[1].crp_p, dh_req->pub_key_len) || | ||
326 | + copy_from_user(dh_req->q, cop->crk_param[2].crp_p, dh_req->q_len); | ||
327 | + if (rc) | ||
328 | + goto err; | ||
329 | + | ||
330 | rc = cryptodev_pkc_offload(pkc); | ||
331 | if (pkc->type == SYNCHRONOUS) { | ||
332 | - if (rc) | ||
333 | - goto err; | ||
334 | if (cop->crk_iparams == 4) | ||
335 | - copy_to_user(cop->crk_param[4].crp_p, dh_req->z, | ||
336 | + rc = rc || copy_to_user(cop->crk_param[4].crp_p, dh_req->z, | ||
337 | dh_req->z_len); | ||
338 | else | ||
339 | - copy_to_user(cop->crk_param[3].crp_p, dh_req->z, | ||
340 | + rc = rc || copy_to_user(cop->crk_param[3].crp_p, dh_req->z, | ||
341 | dh_req->z_len); | ||
342 | } else { | ||
343 | if (rc != -EINPROGRESS && rc != 0) | ||
344 | @@ -582,19 +572,19 @@ int crypto_modexp_crt(struct cryptodev_pkc *pkc) | ||
345 | rsa_req->dq = rsa_req->dp + rsa_req->dp_len; | ||
346 | rsa_req->c = rsa_req->dq + rsa_req->dq_len; | ||
347 | rsa_req->f = rsa_req->c + rsa_req->c_len; | ||
348 | - copy_from_user(rsa_req->p, cop->crk_param[0].crp_p, rsa_req->p_len); | ||
349 | - copy_from_user(rsa_req->q, cop->crk_param[1].crp_p, rsa_req->q_len); | ||
350 | - copy_from_user(rsa_req->g, cop->crk_param[2].crp_p, rsa_req->g_len); | ||
351 | - copy_from_user(rsa_req->dp, cop->crk_param[3].crp_p, rsa_req->dp_len); | ||
352 | - copy_from_user(rsa_req->dq, cop->crk_param[4].crp_p, rsa_req->dq_len); | ||
353 | - copy_from_user(rsa_req->c, cop->crk_param[5].crp_p, rsa_req->c_len); | ||
354 | + rc = copy_from_user(rsa_req->p, cop->crk_param[0].crp_p, rsa_req->p_len) || | ||
355 | + copy_from_user(rsa_req->q, cop->crk_param[1].crp_p, rsa_req->q_len) || | ||
356 | + copy_from_user(rsa_req->g, cop->crk_param[2].crp_p, rsa_req->g_len) || | ||
357 | + copy_from_user(rsa_req->dp, cop->crk_param[3].crp_p, rsa_req->dp_len) || | ||
358 | + copy_from_user(rsa_req->dq, cop->crk_param[4].crp_p, rsa_req->dq_len) || | ||
359 | + copy_from_user(rsa_req->c, cop->crk_param[5].crp_p, rsa_req->c_len); | ||
360 | + if (rc) | ||
361 | + goto err; | ||
362 | + | ||
363 | rc = cryptodev_pkc_offload(pkc); | ||
364 | |||
365 | if (pkc->type == SYNCHRONOUS) { | ||
366 | - if (rc) | ||
367 | - goto err; | ||
368 | - copy_to_user(cop->crk_param[6].crp_p, rsa_req->f, | ||
369 | - rsa_req->f_len); | ||
370 | + rc = rc || copy_to_user(cop->crk_param[6].crp_p, rsa_req->f, rsa_req->f_len); | ||
371 | } else { | ||
372 | if (rc != -EINPROGRESS && rc != 0) | ||
373 | goto err; | ||
374 | @@ -633,14 +623,15 @@ int crypto_bn_modexp(struct cryptodev_pkc *pkc) | ||
375 | rsa_req->f = rsa_req->e + rsa_req->e_len; | ||
376 | rsa_req->g = rsa_req->f + rsa_req->f_len; | ||
377 | rsa_req->n = rsa_req->g + rsa_req->g_len; | ||
378 | - copy_from_user(rsa_req->f, cop->crk_param[0].crp_p, rsa_req->f_len); | ||
379 | - copy_from_user(rsa_req->e, cop->crk_param[1].crp_p, rsa_req->e_len); | ||
380 | - copy_from_user(rsa_req->n, cop->crk_param[2].crp_p, rsa_req->n_len); | ||
381 | + rc = copy_from_user(rsa_req->f, cop->crk_param[0].crp_p, rsa_req->f_len) || | ||
382 | + copy_from_user(rsa_req->e, cop->crk_param[1].crp_p, rsa_req->e_len) || | ||
383 | + copy_from_user(rsa_req->n, cop->crk_param[2].crp_p, rsa_req->n_len); | ||
384 | + if (rc) | ||
385 | + goto err; | ||
386 | + | ||
387 | rc = cryptodev_pkc_offload(pkc); | ||
388 | if (pkc->type == SYNCHRONOUS) { | ||
389 | - if (rc) | ||
390 | - goto err; | ||
391 | - copy_to_user(cop->crk_param[3].crp_p, rsa_req->g, rsa_req->g_len); | ||
392 | + rc = rc || copy_to_user(cop->crk_param[3].crp_p, rsa_req->g, rsa_req->g_len); | ||
393 | } else { | ||
394 | if (rc != -EINPROGRESS && rc != 0) | ||
395 | goto err; | ||
396 | -- | ||
397 | 2.7.0 | ||
398 | |||
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 @@ | |||
1 | From 85146b8429ba11bd0be68c24c17dd77b21ec8c25 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@freescale.com> | ||
3 | Date: Mon, 12 Oct 2015 23:03:28 +0300 | ||
4 | Subject: [PATCH 22/38] fix double free pkc->req on error | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> | ||
7 | --- | ||
8 | main.c | 2 +- | ||
9 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
10 | |||
11 | diff --git a/main.c b/main.c | ||
12 | index e5adb93..ec11129 100644 | ||
13 | --- a/main.c | ||
14 | +++ b/main.c | ||
15 | @@ -747,7 +747,7 @@ int crypto_run_asym(struct cryptodev_pkc *pkc) | ||
16 | /* todo - fix alloc-free on error path */ | ||
17 | pkc->req->type = pkc_req_type; | ||
18 | err = call_next_action(pkc); | ||
19 | - if (pkc->type == SYNCHRONOUS) | ||
20 | + if (err == 0 && pkc->type == SYNCHRONOUS) | ||
21 | kfree(pkc->req); | ||
22 | |||
23 | return err; | ||
24 | -- | ||
25 | 2.7.0 | ||
26 | |||
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 @@ | |||
1 | From 7d0d0deb255f8c59b0cf6d3944ee2e3be4133b4c Mon Sep 17 00:00:00 2001 | ||
2 | From: Alex Porosanu <alexandru.porosanu@freescale.com> | ||
3 | Date: Mon, 19 Oct 2015 11:53:11 +0300 | ||
4 | Subject: [PATCH 23/38] remove MAY_BACKLOG flag from requests | ||
5 | |||
6 | cryptodev doesn't implement the backlogging mechanism properly, | ||
7 | since it misses the possibility of sleeping and waiting for | ||
8 | wake-up when the crypto driver below starts working on the | ||
9 | submitted backloggable request. | ||
10 | In case the crypto driver below implements backlogging mechanisms, | ||
11 | this can lead to side-effects such as working on previously-free'ed | ||
12 | data. | ||
13 | This patch removes the MAY_BACKLOG flag from the requests. | ||
14 | |||
15 | Change-Id: Ia3d822b1abfc1a51e2ce3e9682476b2c99d19c5a | ||
16 | Signed-off-by: Alex Porosanu <alexandru.porosanu@freescale.com> | ||
17 | --- | ||
18 | cryptlib.c | 14 +++++--------- | ||
19 | 1 file changed, 5 insertions(+), 9 deletions(-) | ||
20 | |||
21 | diff --git a/cryptlib.c b/cryptlib.c | ||
22 | index 10f5e1a..eba4616 100644 | ||
23 | --- a/cryptlib.c | ||
24 | +++ b/cryptlib.c | ||
25 | @@ -194,8 +194,7 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, | ||
26 | goto error; | ||
27 | } | ||
28 | |||
29 | - ablkcipher_request_set_callback(out->async.request, | ||
30 | - CRYPTO_TFM_REQ_MAY_BACKLOG, | ||
31 | + ablkcipher_request_set_callback(out->async.request, 0, | ||
32 | cryptodev_complete, out->async.result); | ||
33 | } else { | ||
34 | out->async.arequest = aead_request_alloc(out->async.as, GFP_KERNEL); | ||
35 | @@ -205,8 +204,7 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, | ||
36 | goto error; | ||
37 | } | ||
38 | |||
39 | - aead_request_set_callback(out->async.arequest, | ||
40 | - CRYPTO_TFM_REQ_MAY_BACKLOG, | ||
41 | + aead_request_set_callback(out->async.arequest, 0, | ||
42 | cryptodev_complete, out->async.result); | ||
43 | } | ||
44 | |||
45 | @@ -362,9 +360,8 @@ int cryptodev_hash_init(struct hash_data *hdata, const char *alg_name, | ||
46 | goto error; | ||
47 | } | ||
48 | |||
49 | - ahash_request_set_callback(hdata->async.request, | ||
50 | - CRYPTO_TFM_REQ_MAY_BACKLOG, | ||
51 | - cryptodev_complete, hdata->async.result); | ||
52 | + ahash_request_set_callback(hdata->async.request, 0, | ||
53 | + cryptodev_complete, hdata->async.result); | ||
54 | |||
55 | ret = crypto_ahash_init(hdata->async.request); | ||
56 | if (unlikely(ret)) { | ||
57 | @@ -439,8 +436,7 @@ int cryptodev_pkc_offload(struct cryptodev_pkc *pkc) | ||
58 | int ret; | ||
59 | |||
60 | init_completion(&pkc->result.completion); | ||
61 | - pkc_request_set_callback(pkc->req, CRYPTO_TFM_REQ_MAY_BACKLOG, | ||
62 | - cryptodev_complete_asym, pkc); | ||
63 | + pkc_request_set_callback(pkc->req, 0, cryptodev_complete_asym, pkc); | ||
64 | ret = crypto_pkc_op(pkc->req); | ||
65 | if (ret != -EINPROGRESS && ret != 0) | ||
66 | goto error; | ||
67 | -- | ||
68 | 2.7.0 | ||
69 | |||
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 @@ | |||
1 | From 53e4d0fe4a334dae3df32b2053e4ebdfda2e9148 Mon Sep 17 00:00:00 2001 | ||
2 | From: Tudor Ambarus <tudor.ambarus@freescale.com> | ||
3 | Date: Tue, 27 Oct 2015 15:51:02 +0200 | ||
4 | Subject: [PATCH 24/38] fix COMPAT_CIOCKEY ioctl command number | ||
5 | |||
6 | CIOCKEY and COMPAT_CIOCKEY had different command numbers, | ||
7 | so that 32-bit applications got EINVAL error on 64-bit kernel. | ||
8 | |||
9 | Signed-off-by: Tudor Ambarus <tudor.ambarus@freescale.com> | ||
10 | --- | ||
11 | cryptodev_int.h | 2 +- | ||
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
13 | |||
14 | diff --git a/cryptodev_int.h b/cryptodev_int.h | ||
15 | index c83c885..cb005d7 100644 | ||
16 | --- a/cryptodev_int.h | ||
17 | +++ b/cryptodev_int.h | ||
18 | @@ -132,7 +132,7 @@ struct compat_crypt_auth_op { | ||
19 | /* compat ioctls, defined for the above structs */ | ||
20 | #define COMPAT_CIOCGSESSION _IOWR('c', 102, struct compat_session_op) | ||
21 | #define COMPAT_CIOCCRYPT _IOWR('c', 104, struct compat_crypt_op) | ||
22 | -#define COMPAT_CIOCKEY _IOW('c', 105, struct compat_crypt_kop) | ||
23 | +#define COMPAT_CIOCKEY _IOWR('c', 105, struct compat_crypt_kop) | ||
24 | #define COMPAT_CIOCASYNCCRYPT _IOW('c', 107, struct compat_crypt_op) | ||
25 | #define COMPAT_CIOCASYNCFETCH _IOR('c', 108, struct compat_crypt_op) | ||
26 | #define COMPAT_CIOCAUTHCRYPT _IOWR('c', 109, struct compat_crypt_auth_op) | ||
27 | -- | ||
28 | 2.7.0 | ||
29 | |||
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 @@ | |||
1 | From 978cfcf9253c409520c0f168f8caa249f50a8843 Mon Sep 17 00:00:00 2001 | ||
2 | From: Fridolin Pokorny <fpokorny@redhat.com> | ||
3 | Date: Fri, 8 Jan 2016 09:38:29 +0100 | ||
4 | Subject: [PATCH 25/38] fix benchmarks linking | ||
5 | |||
6 | --- | ||
7 | lib/Makefile | 2 +- | ||
8 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
9 | |||
10 | diff --git a/lib/Makefile b/lib/Makefile | ||
11 | index af87795..3bedc34 100644 | ||
12 | --- a/lib/Makefile | ||
13 | +++ b/lib/Makefile | ||
14 | @@ -3,7 +3,7 @@ CFLAGS=-g -O2 -Wall | ||
15 | all: benchmark | ||
16 | |||
17 | benchmark: main.c libthreshold.a | ||
18 | - gcc $(CFLAGS) -DDEBUG -o $@ $^ -lssl libthreshold.a | ||
19 | + gcc $(CFLAGS) -DDEBUG -o $@ $^ -lssl -lcrypto libthreshold.a | ||
20 | |||
21 | .o: | ||
22 | gcc $(CCFLAGS) -c $< -o $@ | ||
23 | -- | ||
24 | 2.7.0 | ||
25 | |||
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 @@ | |||
1 | From d96ae48c87f80af1a202c2d2e837bf477edc0fb7 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Thu, 10 Dec 2015 12:42:18 +0200 | ||
4 | Subject: [PATCH 26/38] fix Makefile to allow parallel make with -j option | ||
5 | MIME-Version: 1.0 | ||
6 | Content-Type: text/plain; charset=UTF-8 | ||
7 | Content-Transfer-Encoding: 8bit | ||
8 | |||
9 | Recursive make commands should always use the variable MAKE, not the | ||
10 | explicit command name ‘make’ | ||
11 | |||
12 | Documented in section "5.7.1 How the MAKE Variable Works" of GNU Make manual | ||
13 | |||
14 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
15 | --- | ||
16 | Makefile | 10 +++++----- | ||
17 | 1 file changed, 5 insertions(+), 5 deletions(-) | ||
18 | |||
19 | diff --git a/Makefile b/Makefile | ||
20 | index 9e56e9d..2f50210 100644 | ||
21 | --- a/Makefile | ||
22 | +++ b/Makefile | ||
23 | @@ -22,7 +22,7 @@ KERNEL_MAKE_OPTS += CROSS_COMPILE=${CROSS_COMPILE} | ||
24 | endif | ||
25 | |||
26 | build: version.h | ||
27 | - make ${KERNEL_MAKE_OPTS} modules | ||
28 | + $(MAKE) $(KERNEL_MAKE_OPTS) modules | ||
29 | |||
30 | version.h: Makefile | ||
31 | @echo "#define VERSION \"$(VERSION)\"" > version.h | ||
32 | @@ -30,17 +30,17 @@ version.h: Makefile | ||
33 | install: modules_install | ||
34 | |||
35 | modules_install: | ||
36 | - make -C $(KERNEL_DIR) SUBDIRS=`pwd` modules_install | ||
37 | + $(MAKE) -C $(KERNEL_DIR) SUBDIRS=`pwd` modules_install | ||
38 | @echo "Installing cryptodev.h in $(PREFIX)/usr/include/crypto ..." | ||
39 | @install -D crypto/cryptodev.h $(PREFIX)/usr/include/crypto/cryptodev.h | ||
40 | |||
41 | clean: | ||
42 | - make -C $(KERNEL_DIR) SUBDIRS=`pwd` clean | ||
43 | + $(MAKE) -C $(KERNEL_DIR) SUBDIRS=`pwd` clean | ||
44 | rm -f $(hostprogs) *~ | ||
45 | - CFLAGS=$(CRYPTODEV_CFLAGS) KERNEL_DIR=$(KERNEL_DIR) make -C tests clean | ||
46 | + CFLAGS=$(CRYPTODEV_CFLAGS) KERNEL_DIR=$(KERNEL_DIR) $(MAKE) -C tests clean | ||
47 | |||
48 | check: | ||
49 | - CFLAGS=$(CRYPTODEV_CFLAGS) KERNEL_DIR=$(KERNEL_DIR) make -C tests check | ||
50 | + CFLAGS=$(CRYPTODEV_CFLAGS) KERNEL_DIR=$(KERNEL_DIR) $(MAKE) -C tests check | ||
51 | |||
52 | CPOPTS = | ||
53 | ifneq (${SHOW_TYPES},) | ||
54 | -- | ||
55 | 2.7.0 | ||
56 | |||
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 @@ | |||
1 | From e51bf208fbd3796238ff4d721e8d070f711f8c56 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Thu, 10 Dec 2015 12:42:19 +0200 | ||
4 | Subject: [PATCH 27/38] use Linux kernel conventions for Makefile variables | ||
5 | |||
6 | The kernel Makefile specifies to use M=... instead of SUBDIR=... for | ||
7 | external modules. | ||
8 | |||
9 | PWD variable is already set in a POSIX system and calling `pwd` to find | ||
10 | it is redundant. | ||
11 | |||
12 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
13 | --- | ||
14 | Makefile | 6 +++--- | ||
15 | 1 file changed, 3 insertions(+), 3 deletions(-) | ||
16 | |||
17 | diff --git a/Makefile b/Makefile | ||
18 | index 2f50210..7c7e193 100644 | ||
19 | --- a/Makefile | ||
20 | +++ b/Makefile | ||
21 | @@ -13,7 +13,7 @@ cryptodev-objs = ioctl.o main.o cryptlib.o authenc.o zc.o util.o | ||
22 | |||
23 | obj-m += cryptodev.o | ||
24 | |||
25 | -KERNEL_MAKE_OPTS := -C ${KERNEL_DIR} SUBDIRS=`pwd` | ||
26 | +KERNEL_MAKE_OPTS := -C $(KERNEL_DIR) M=$(PWD) | ||
27 | ifneq (${ARCH},) | ||
28 | KERNEL_MAKE_OPTS += ARCH=${ARCH} | ||
29 | endif | ||
30 | @@ -30,12 +30,12 @@ version.h: Makefile | ||
31 | install: modules_install | ||
32 | |||
33 | modules_install: | ||
34 | - $(MAKE) -C $(KERNEL_DIR) SUBDIRS=`pwd` modules_install | ||
35 | + $(MAKE) -C $(KERNEL_DIR) M=$(PWD) modules_install | ||
36 | @echo "Installing cryptodev.h in $(PREFIX)/usr/include/crypto ..." | ||
37 | @install -D crypto/cryptodev.h $(PREFIX)/usr/include/crypto/cryptodev.h | ||
38 | |||
39 | clean: | ||
40 | - $(MAKE) -C $(KERNEL_DIR) SUBDIRS=`pwd` clean | ||
41 | + $(MAKE) -C $(KERNEL_DIR) M=$(PWD) clean | ||
42 | rm -f $(hostprogs) *~ | ||
43 | CFLAGS=$(CRYPTODEV_CFLAGS) KERNEL_DIR=$(KERNEL_DIR) $(MAKE) -C tests clean | ||
44 | |||
45 | -- | ||
46 | 2.7.0 | ||
47 | |||
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 @@ | |||
1 | From 22b63631de17507c12355c30e408dbd88350bb3a Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Thu, 10 Dec 2015 12:42:20 +0200 | ||
4 | Subject: [PATCH 28/38] for consistency, use $(...) instead of ${...} in | ||
5 | makefiles | ||
6 | |||
7 | Both syntax rules are equaly valid and mixing them is permitted but | ||
8 | looks inconsistent. | ||
9 | |||
10 | See section "6.1 Basics of Variable References" of GNU make manual | ||
11 | |||
12 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
13 | --- | ||
14 | Makefile | 16 ++++++++-------- | ||
15 | tests/Makefile | 2 +- | ||
16 | 2 files changed, 9 insertions(+), 9 deletions(-) | ||
17 | |||
18 | diff --git a/Makefile b/Makefile | ||
19 | index 7c7e193..7f8df37 100644 | ||
20 | --- a/Makefile | ||
21 | +++ b/Makefile | ||
22 | @@ -14,11 +14,11 @@ cryptodev-objs = ioctl.o main.o cryptlib.o authenc.o zc.o util.o | ||
23 | obj-m += cryptodev.o | ||
24 | |||
25 | KERNEL_MAKE_OPTS := -C $(KERNEL_DIR) M=$(PWD) | ||
26 | -ifneq (${ARCH},) | ||
27 | -KERNEL_MAKE_OPTS += ARCH=${ARCH} | ||
28 | +ifneq ($(ARCH),) | ||
29 | +KERNEL_MAKE_OPTS += ARCH=$(ARCH) | ||
30 | endif | ||
31 | -ifneq (${CROSS_COMPILE},) | ||
32 | -KERNEL_MAKE_OPTS += CROSS_COMPILE=${CROSS_COMPILE} | ||
33 | +ifneq ($(CROSS_COMPILE),) | ||
34 | +KERNEL_MAKE_OPTS += CROSS_COMPILE=$(CROSS_COMPILE) | ||
35 | endif | ||
36 | |||
37 | build: version.h | ||
38 | @@ -43,15 +43,15 @@ check: | ||
39 | CFLAGS=$(CRYPTODEV_CFLAGS) KERNEL_DIR=$(KERNEL_DIR) $(MAKE) -C tests check | ||
40 | |||
41 | CPOPTS = | ||
42 | -ifneq (${SHOW_TYPES},) | ||
43 | +ifneq ($(SHOW_TYPES),) | ||
44 | CPOPTS += --show-types | ||
45 | endif | ||
46 | -ifneq (${IGNORE_TYPES},) | ||
47 | -CPOPTS += --ignore ${IGNORE_TYPES} | ||
48 | +ifneq ($(IGNORE_TYPES),) | ||
49 | +CPOPTS += --ignore $(IGNORE_TYPES) | ||
50 | endif | ||
51 | |||
52 | checkpatch: | ||
53 | - $(KERNEL_DIR)/scripts/checkpatch.pl ${CPOPTS} --file *.c *.h | ||
54 | + $(KERNEL_DIR)/scripts/checkpatch.pl $(CPOPTS) --file *.c *.h | ||
55 | |||
56 | VERSIONTAG = refs/tags/cryptodev-linux-$(VERSION) | ||
57 | FILEBASE = cryptodev-linux-$(VERSION) | ||
58 | diff --git a/tests/Makefile b/tests/Makefile | ||
59 | index 20c52ba..3155da9 100644 | ||
60 | --- a/tests/Makefile | ||
61 | +++ b/tests/Makefile | ||
62 | @@ -6,7 +6,7 @@ comp_progs := cipher_comp hash_comp hmac_comp | ||
63 | |||
64 | hostprogs := cipher cipher-aead hmac speed async_cipher async_hmac \ | ||
65 | async_speed sha_speed hashcrypt_speed fullspeed cipher-gcm \ | ||
66 | - cipher-aead-srtp ${comp_progs} | ||
67 | + cipher-aead-srtp $(comp_progs) | ||
68 | |||
69 | example-cipher-objs := cipher.o | ||
70 | example-cipher-aead-objs := cipher-aead.o | ||
71 | -- | ||
72 | 2.7.0 | ||
73 | |||
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 @@ | |||
1 | From 294abaaa4540ec340ed6046a784c9789c8724420 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Mon, 11 Jan 2016 17:45:50 +0200 | ||
4 | Subject: [PATCH 29/38] fix clean-up on error path for crypto_create_session | ||
5 | |||
6 | This patch fixes clean-up on error path for failed allocations of | ||
7 | ses_new->pages or ses_new->sg. In these cases, allocations made in | ||
8 | cryptodev_hash_init have not been undone resulting in possible memory | ||
9 | leaks. | ||
10 | |||
11 | We take advantage of the initializations with zeros of the session | ||
12 | structure to trim the code to a single clean-up path. | ||
13 | |||
14 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
15 | --- | ||
16 | ioctl.c | 28 +++++++++++++++------------- | ||
17 | 1 file changed, 15 insertions(+), 13 deletions(-) | ||
18 | |||
19 | diff --git a/ioctl.c b/ioctl.c | ||
20 | index b23f5fd..c781f9d 100644 | ||
21 | --- a/ioctl.c | ||
22 | +++ b/ioctl.c | ||
23 | @@ -228,7 +228,8 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) | ||
24 | return -EINVAL; | ||
25 | } | ||
26 | |||
27 | - /* Create a session and put it to the list. */ | ||
28 | + /* Create a session and put it to the list. Zeroing the structure helps | ||
29 | + * also with a single exit point in case of errors */ | ||
30 | ses_new = kzalloc(sizeof(*ses_new), GFP_KERNEL); | ||
31 | if (!ses_new) | ||
32 | return -ENOMEM; | ||
33 | @@ -240,19 +241,19 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) | ||
34 | if (unlikely(ret < 0)) { | ||
35 | ddebug(1, "Setting key failed for %s-%zu.", | ||
36 | alg_name, (size_t)sop->keylen*8); | ||
37 | - goto error_cipher; | ||
38 | + goto session_error; | ||
39 | } | ||
40 | |||
41 | ret = cryptodev_get_cipher_key(keys.ckey, sop, aead); | ||
42 | if (unlikely(ret < 0)) | ||
43 | - goto error_cipher; | ||
44 | + goto session_error; | ||
45 | |||
46 | ret = cryptodev_cipher_init(&ses_new->cdata, alg_name, keys.ckey, | ||
47 | keylen, stream, aead); | ||
48 | if (ret < 0) { | ||
49 | ddebug(1, "Failed to load cipher for %s", alg_name); | ||
50 | ret = -EINVAL; | ||
51 | - goto error_cipher; | ||
52 | + goto session_error; | ||
53 | } | ||
54 | } | ||
55 | |||
56 | @@ -261,13 +262,13 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) | ||
57 | ddebug(1, "Setting key failed for %s-%zu.", | ||
58 | hash_name, (size_t)sop->mackeylen*8); | ||
59 | ret = -EINVAL; | ||
60 | - goto error_hash; | ||
61 | + goto session_error; | ||
62 | } | ||
63 | |||
64 | if (sop->mackey && unlikely(copy_from_user(keys.mkey, sop->mackey, | ||
65 | sop->mackeylen))) { | ||
66 | ret = -EFAULT; | ||
67 | - goto error_hash; | ||
68 | + goto session_error; | ||
69 | } | ||
70 | |||
71 | ret = cryptodev_hash_init(&ses_new->hdata, hash_name, hmac_mode, | ||
72 | @@ -275,7 +276,7 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) | ||
73 | if (ret != 0) { | ||
74 | ddebug(1, "Failed to load hash for %s", hash_name); | ||
75 | ret = -EINVAL; | ||
76 | - goto error_hash; | ||
77 | + goto session_error; | ||
78 | } | ||
79 | } | ||
80 | |||
81 | @@ -292,7 +293,7 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) | ||
82 | if (ses_new->sg == NULL || ses_new->pages == NULL) { | ||
83 | ddebug(0, "Memory error"); | ||
84 | ret = -ENOMEM; | ||
85 | - goto error_hash; | ||
86 | + goto session_error; | ||
87 | } | ||
88 | |||
89 | /* put the new session to the list */ | ||
90 | @@ -316,18 +317,19 @@ restart: | ||
91 | |||
92 | /* Fill in some values for the user. */ | ||
93 | sop->ses = ses_new->sid; | ||
94 | - | ||
95 | return 0; | ||
96 | |||
97 | -error_hash: | ||
98 | + /* We count on ses_new to be initialized with zeroes | ||
99 | + * Since hdata and cdata are embedded within ses_new, it follows that | ||
100 | + * hdata->init and cdata->init are either zero or one as they have been | ||
101 | + * initialized or not */ | ||
102 | +session_error: | ||
103 | + cryptodev_hash_deinit(&ses_new->hdata); | ||
104 | cryptodev_cipher_deinit(&ses_new->cdata); | ||
105 | kfree(ses_new->sg); | ||
106 | kfree(ses_new->pages); | ||
107 | -error_cipher: | ||
108 | kfree(ses_new); | ||
109 | - | ||
110 | return ret; | ||
111 | - | ||
112 | } | ||
113 | |||
114 | /* Everything that needs to be done when remowing a session. */ | ||
115 | -- | ||
116 | 2.7.0 | ||
117 | |||
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 @@ | |||
1 | From f4534df637b078fce275763bd8bc2a83bfad25e0 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Mon, 11 Jan 2016 18:01:06 +0200 | ||
4 | Subject: [PATCH 30/38] remove code duplication in cryptodev_hash_init | ||
5 | |||
6 | cryptodev_hash_init is concerned mostly with allocating data structures | ||
7 | for hash operations. | ||
8 | This patch replaces the call it makes to crypto_ahash_init with | ||
9 | one to cryptodev_hash_reset to avoid code duplication. This call is made | ||
10 | now outside of the original function to increase modularity. | ||
11 | |||
12 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
13 | --- | ||
14 | cryptlib.c | 9 --------- | ||
15 | ioctl.c | 5 +++++ | ||
16 | 2 files changed, 5 insertions(+), 9 deletions(-) | ||
17 | |||
18 | diff --git a/cryptlib.c b/cryptlib.c | ||
19 | index eba4616..4fd29eb 100644 | ||
20 | --- a/cryptlib.c | ||
21 | +++ b/cryptlib.c | ||
22 | @@ -362,18 +362,9 @@ int cryptodev_hash_init(struct hash_data *hdata, const char *alg_name, | ||
23 | |||
24 | ahash_request_set_callback(hdata->async.request, 0, | ||
25 | cryptodev_complete, hdata->async.result); | ||
26 | - | ||
27 | - ret = crypto_ahash_init(hdata->async.request); | ||
28 | - if (unlikely(ret)) { | ||
29 | - derr(0, "error in crypto_hash_init()"); | ||
30 | - goto error_request; | ||
31 | - } | ||
32 | - | ||
33 | hdata->init = 1; | ||
34 | return 0; | ||
35 | |||
36 | -error_request: | ||
37 | - ahash_request_free(hdata->async.request); | ||
38 | error: | ||
39 | kfree(hdata->async.result); | ||
40 | crypto_free_ahash(hdata->async.s); | ||
41 | diff --git a/ioctl.c b/ioctl.c | ||
42 | index b36dd03..a537886 100644 | ||
43 | --- a/ioctl.c | ||
44 | +++ b/ioctl.c | ||
45 | @@ -338,6 +338,11 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) | ||
46 | ret = -EINVAL; | ||
47 | goto session_error; | ||
48 | } | ||
49 | + | ||
50 | + ret = cryptodev_hash_reset(&ses_new->hdata); | ||
51 | + if (ret != 0) { | ||
52 | + goto session_error; | ||
53 | + } | ||
54 | } | ||
55 | |||
56 | ses_new->alignmask = max(ses_new->cdata.alignmask, | ||
57 | -- | ||
58 | 2.7.0 | ||
59 | |||
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 @@ | |||
1 | From 73a2489ba634503a0cc2bb6e84627ceeda0f059f Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Tue, 12 Jan 2016 17:15:56 +0200 | ||
4 | Subject: [PATCH 31/38] fix comment typo | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | ioctl.c | 2 +- | ||
9 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
10 | |||
11 | diff --git a/ioctl.c b/ioctl.c | ||
12 | index a537886..7adde75 100644 | ||
13 | --- a/ioctl.c | ||
14 | +++ b/ioctl.c | ||
15 | @@ -397,7 +397,7 @@ session_error: | ||
16 | return ret; | ||
17 | } | ||
18 | |||
19 | -/* Everything that needs to be done when remowing a session. */ | ||
20 | +/* Everything that needs to be done when removing a session. */ | ||
21 | static inline void | ||
22 | crypto_destroy_session(struct csession *ses_ptr) | ||
23 | { | ||
24 | -- | ||
25 | 2.7.0 | ||
26 | |||
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 @@ | |||
1 | From 9b513838035c35fd3706bb824edd17d705641439 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Tue, 12 Jan 2016 15:13:15 +0200 | ||
4 | Subject: [PATCH 32/38] avoid calls to kmalloc on hotpaths | ||
5 | |||
6 | We replace a pointer to a small structure with the structure itself to | ||
7 | avoid unnecessary dynamic allocations at runtime. The embedding | ||
8 | structure is itself dynamically allocated and we get a slight increase | ||
9 | in performance from elimination of unnecessary code. | ||
10 | |||
11 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
12 | --- | ||
13 | cryptlib.c | 42 +++++++++++++----------------------------- | ||
14 | cryptlib.h | 14 +++++++------- | ||
15 | 2 files changed, 20 insertions(+), 36 deletions(-) | ||
16 | |||
17 | diff --git a/cryptlib.c b/cryptlib.c | ||
18 | index 4fd29eb..5972fc2 100644 | ||
19 | --- a/cryptlib.c | ||
20 | +++ b/cryptlib.c | ||
21 | @@ -178,13 +178,7 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, | ||
22 | out->stream = stream; | ||
23 | out->aead = aead; | ||
24 | |||
25 | - out->async.result = kzalloc(sizeof(*out->async.result), GFP_KERNEL); | ||
26 | - if (unlikely(!out->async.result)) { | ||
27 | - ret = -ENOMEM; | ||
28 | - goto error; | ||
29 | - } | ||
30 | - | ||
31 | - init_completion(&out->async.result->completion); | ||
32 | + init_completion(&out->async.result.completion); | ||
33 | |||
34 | if (aead == 0) { | ||
35 | out->async.request = ablkcipher_request_alloc(out->async.s, GFP_KERNEL); | ||
36 | @@ -195,7 +189,7 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, | ||
37 | } | ||
38 | |||
39 | ablkcipher_request_set_callback(out->async.request, 0, | ||
40 | - cryptodev_complete, out->async.result); | ||
41 | + cryptodev_complete, &out->async.result); | ||
42 | } else { | ||
43 | out->async.arequest = aead_request_alloc(out->async.as, GFP_KERNEL); | ||
44 | if (unlikely(!out->async.arequest)) { | ||
45 | @@ -205,7 +199,7 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, | ||
46 | } | ||
47 | |||
48 | aead_request_set_callback(out->async.arequest, 0, | ||
49 | - cryptodev_complete, out->async.result); | ||
50 | + cryptodev_complete, &out->async.result); | ||
51 | } | ||
52 | |||
53 | out->init = 1; | ||
54 | @@ -222,7 +216,6 @@ error: | ||
55 | if (out->async.as) | ||
56 | crypto_free_aead(out->async.as); | ||
57 | } | ||
58 | - kfree(out->async.result); | ||
59 | |||
60 | return ret; | ||
61 | } | ||
62 | @@ -242,7 +235,6 @@ void cryptodev_cipher_deinit(struct cipher_data *cdata) | ||
63 | crypto_free_aead(cdata->async.as); | ||
64 | } | ||
65 | |||
66 | - kfree(cdata->async.result); | ||
67 | cdata->init = 0; | ||
68 | } | ||
69 | } | ||
70 | @@ -279,7 +271,7 @@ ssize_t cryptodev_cipher_encrypt(struct cipher_data *cdata, | ||
71 | { | ||
72 | int ret; | ||
73 | |||
74 | - reinit_completion(&cdata->async.result->completion); | ||
75 | + reinit_completion(&cdata->async.result.completion); | ||
76 | |||
77 | if (cdata->aead == 0) { | ||
78 | ablkcipher_request_set_crypt(cdata->async.request, | ||
79 | @@ -293,7 +285,7 @@ ssize_t cryptodev_cipher_encrypt(struct cipher_data *cdata, | ||
80 | ret = crypto_aead_encrypt(cdata->async.arequest); | ||
81 | } | ||
82 | |||
83 | - return waitfor(cdata->async.result, ret); | ||
84 | + return waitfor(&cdata->async.result, ret); | ||
85 | } | ||
86 | |||
87 | ssize_t cryptodev_cipher_decrypt(struct cipher_data *cdata, | ||
88 | @@ -302,7 +294,7 @@ ssize_t cryptodev_cipher_decrypt(struct cipher_data *cdata, | ||
89 | { | ||
90 | int ret; | ||
91 | |||
92 | - reinit_completion(&cdata->async.result->completion); | ||
93 | + reinit_completion(&cdata->async.result.completion); | ||
94 | if (cdata->aead == 0) { | ||
95 | ablkcipher_request_set_crypt(cdata->async.request, | ||
96 | (struct scatterlist *)src, dst, | ||
97 | @@ -315,7 +307,7 @@ ssize_t cryptodev_cipher_decrypt(struct cipher_data *cdata, | ||
98 | ret = crypto_aead_decrypt(cdata->async.arequest); | ||
99 | } | ||
100 | |||
101 | - return waitfor(cdata->async.result, ret); | ||
102 | + return waitfor(&cdata->async.result, ret); | ||
103 | } | ||
104 | |||
105 | /* Hash functions */ | ||
106 | @@ -345,13 +337,7 @@ int cryptodev_hash_init(struct hash_data *hdata, const char *alg_name, | ||
107 | hdata->digestsize = crypto_ahash_digestsize(hdata->async.s); | ||
108 | hdata->alignmask = crypto_ahash_alignmask(hdata->async.s); | ||
109 | |||
110 | - hdata->async.result = kzalloc(sizeof(*hdata->async.result), GFP_KERNEL); | ||
111 | - if (unlikely(!hdata->async.result)) { | ||
112 | - ret = -ENOMEM; | ||
113 | - goto error; | ||
114 | - } | ||
115 | - | ||
116 | - init_completion(&hdata->async.result->completion); | ||
117 | + init_completion(&hdata->async.result.completion); | ||
118 | |||
119 | hdata->async.request = ahash_request_alloc(hdata->async.s, GFP_KERNEL); | ||
120 | if (unlikely(!hdata->async.request)) { | ||
121 | @@ -361,12 +347,11 @@ int cryptodev_hash_init(struct hash_data *hdata, const char *alg_name, | ||
122 | } | ||
123 | |||
124 | ahash_request_set_callback(hdata->async.request, 0, | ||
125 | - cryptodev_complete, hdata->async.result); | ||
126 | + cryptodev_complete, &hdata->async.result); | ||
127 | hdata->init = 1; | ||
128 | return 0; | ||
129 | |||
130 | error: | ||
131 | - kfree(hdata->async.result); | ||
132 | crypto_free_ahash(hdata->async.s); | ||
133 | return ret; | ||
134 | } | ||
135 | @@ -376,7 +361,6 @@ void cryptodev_hash_deinit(struct hash_data *hdata) | ||
136 | if (hdata->init) { | ||
137 | if (hdata->async.request) | ||
138 | ahash_request_free(hdata->async.request); | ||
139 | - kfree(hdata->async.result); | ||
140 | if (hdata->async.s) | ||
141 | crypto_free_ahash(hdata->async.s); | ||
142 | hdata->init = 0; | ||
143 | @@ -402,24 +386,24 @@ ssize_t cryptodev_hash_update(struct hash_data *hdata, | ||
144 | { | ||
145 | int ret; | ||
146 | |||
147 | - reinit_completion(&hdata->async.result->completion); | ||
148 | + reinit_completion(&hdata->async.result.completion); | ||
149 | ahash_request_set_crypt(hdata->async.request, sg, NULL, len); | ||
150 | |||
151 | ret = crypto_ahash_update(hdata->async.request); | ||
152 | |||
153 | - return waitfor(hdata->async.result, ret); | ||
154 | + return waitfor(&hdata->async.result, ret); | ||
155 | } | ||
156 | |||
157 | int cryptodev_hash_final(struct hash_data *hdata, void *output) | ||
158 | { | ||
159 | int ret; | ||
160 | |||
161 | - reinit_completion(&hdata->async.result->completion); | ||
162 | + reinit_completion(&hdata->async.result.completion); | ||
163 | ahash_request_set_crypt(hdata->async.request, NULL, output, 0); | ||
164 | |||
165 | ret = crypto_ahash_final(hdata->async.request); | ||
166 | |||
167 | - return waitfor(hdata->async.result, ret); | ||
168 | + return waitfor(&hdata->async.result, ret); | ||
169 | } | ||
170 | |||
171 | int cryptodev_pkc_offload(struct cryptodev_pkc *pkc) | ||
172 | diff --git a/cryptlib.h b/cryptlib.h | ||
173 | index e1c4e3e..d8e8046 100644 | ||
174 | --- a/cryptlib.h | ||
175 | +++ b/cryptlib.h | ||
176 | @@ -6,6 +6,11 @@ | ||
177 | |||
178 | #include <linux/version.h> | ||
179 | |||
180 | +struct cryptodev_result { | ||
181 | + struct completion completion; | ||
182 | + int err; | ||
183 | +}; | ||
184 | + | ||
185 | struct cipher_data { | ||
186 | int init; /* 0 uninitialized */ | ||
187 | int blocksize; | ||
188 | @@ -22,7 +27,7 @@ struct cipher_data { | ||
189 | struct crypto_aead *as; | ||
190 | struct aead_request *arequest; | ||
191 | |||
192 | - struct cryptodev_result *result; | ||
193 | + struct cryptodev_result result; | ||
194 | uint8_t iv[EALG_MAX_BLOCK_LEN]; | ||
195 | } async; | ||
196 | }; | ||
197 | @@ -85,7 +90,7 @@ struct hash_data { | ||
198 | int alignmask; | ||
199 | struct { | ||
200 | struct crypto_ahash *s; | ||
201 | - struct cryptodev_result *result; | ||
202 | + struct cryptodev_result result; | ||
203 | struct ahash_request *request; | ||
204 | } async; | ||
205 | }; | ||
206 | @@ -104,11 +109,6 @@ enum offload_type { | ||
207 | ASYNCHRONOUS | ||
208 | }; | ||
209 | |||
210 | -struct cryptodev_result { | ||
211 | - struct completion completion; | ||
212 | - int err; | ||
213 | -}; | ||
214 | - | ||
215 | struct cryptodev_pkc { | ||
216 | struct list_head list; /* To maintain the Jobs in completed | ||
217 | cryptodev lists */ | ||
218 | -- | ||
219 | 2.7.0 | ||
220 | |||
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 @@ | |||
1 | From 774c6bd169b683ed54ebad164d0ff541e1381a64 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Tue, 12 Jan 2016 17:09:33 +0200 | ||
4 | Subject: [PATCH 33/38] avoid unnecessary checks for hash clean-up | ||
5 | |||
6 | hdata->init is set only after all necessary allocations succeed. On | ||
7 | clean-up is no longer necessary to make the allocation checks. | ||
8 | |||
9 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
10 | --- | ||
11 | cryptlib.c | 6 ++---- | ||
12 | 1 file changed, 2 insertions(+), 4 deletions(-) | ||
13 | |||
14 | diff --git a/cryptlib.c b/cryptlib.c | ||
15 | index 5972fc2..5d1a5a9 100644 | ||
16 | --- a/cryptlib.c | ||
17 | +++ b/cryptlib.c | ||
18 | @@ -359,10 +359,8 @@ error: | ||
19 | void cryptodev_hash_deinit(struct hash_data *hdata) | ||
20 | { | ||
21 | if (hdata->init) { | ||
22 | - if (hdata->async.request) | ||
23 | - ahash_request_free(hdata->async.request); | ||
24 | - if (hdata->async.s) | ||
25 | - crypto_free_ahash(hdata->async.s); | ||
26 | + ahash_request_free(hdata->async.request); | ||
27 | + crypto_free_ahash(hdata->async.s); | ||
28 | hdata->init = 0; | ||
29 | } | ||
30 | } | ||
31 | -- | ||
32 | 2.7.0 | ||
33 | |||
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 @@ | |||
1 | From c43fa74b9ed11f0183d25b21486b71fe02d84de7 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Tue, 15 Dec 2015 15:31:47 +0200 | ||
4 | Subject: [PATCH 34/38] extend API with CIOCHASH to support direct hash | ||
5 | operations | ||
6 | |||
7 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
8 | --- | ||
9 | crypto/cryptodev.h | 16 ++++++++++++++++ | ||
10 | ioctl.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ | ||
11 | 2 files changed, 65 insertions(+) | ||
12 | |||
13 | diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h | ||
14 | index f6058ca..c6083f7 100644 | ||
15 | --- a/crypto/cryptodev.h | ||
16 | +++ b/crypto/cryptodev.h | ||
17 | @@ -167,6 +167,19 @@ struct crypt_auth_op { | ||
18 | __u32 iv_len; | ||
19 | }; | ||
20 | |||
21 | +/* data container for CIOCHASH operations */ | ||
22 | +struct hash_op_data { | ||
23 | + __u32 ses; /* session identifier */ | ||
24 | + __u32 mac_op; /* cryptodev_crypto_op_t */ | ||
25 | + __u8 *mackey; | ||
26 | + __u32 mackeylen; | ||
27 | + | ||
28 | + __u16 flags; /* see COP_FLAG_* */ | ||
29 | + __u32 len; /* length of source data */ | ||
30 | + __u8 *src; /* source data */ | ||
31 | + __u8 *mac_result; | ||
32 | +}; | ||
33 | + | ||
34 | /* In plain AEAD mode the following are required: | ||
35 | * flags : 0 | ||
36 | * iv : the initialization vector (12 bytes) | ||
37 | @@ -325,4 +338,7 @@ enum cryptodev_crk_op_t { | ||
38 | /* additional ioctls for asynchronous operation for asymmetric ciphers*/ | ||
39 | #define CIOCASYMASYNCRYPT _IOW('c', 112, struct crypt_kop) | ||
40 | #define CIOCASYMFETCHCOOKIE _IOR('c', 113, struct pkc_cookie_list_s) | ||
41 | + | ||
42 | +#define CIOCHASH _IOWR('c', 114, struct hash_op_data) | ||
43 | + | ||
44 | #endif /* L_CRYPTODEV_H */ | ||
45 | diff --git a/ioctl.c b/ioctl.c | ||
46 | index 7adde75..3763954 100644 | ||
47 | --- a/ioctl.c | ||
48 | +++ b/ioctl.c | ||
49 | @@ -960,6 +960,7 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | ||
50 | void __user *arg = (void __user *)arg_; | ||
51 | int __user *p = arg; | ||
52 | struct session_op sop; | ||
53 | + struct hash_op_data hash_op; | ||
54 | struct kernel_crypt_op kcop; | ||
55 | struct kernel_crypt_auth_op kcaop; | ||
56 | struct crypt_priv *pcr = filp->private_data; | ||
57 | @@ -1049,6 +1050,54 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | ||
58 | } | ||
59 | |||
60 | return kcop_to_user(&kcop, fcr, arg); | ||
61 | + case CIOCHASH: | ||
62 | + /* get session */ | ||
63 | + if (unlikely(copy_from_user(&hash_op, arg, sizeof(struct hash_op_data)))) { | ||
64 | + pr_err("copy from user fault\n"); | ||
65 | + return -EFAULT; | ||
66 | + } | ||
67 | + | ||
68 | + sop.cipher = 0; | ||
69 | + sop.mac = hash_op.mac_op; | ||
70 | + sop.mackey = hash_op.mackey; | ||
71 | + sop.mackeylen = hash_op.mackeylen; | ||
72 | + | ||
73 | + /* writes sop.ses as a side-effect */ | ||
74 | + ret = crypto_create_session(fcr, &sop); | ||
75 | + if (unlikely(ret)) { | ||
76 | + pr_err("can't get session\n"); | ||
77 | + return ret; | ||
78 | + } | ||
79 | + | ||
80 | + /* do hashing */ | ||
81 | + kcop.cop.ses = sop.ses; | ||
82 | + kcop.cop.flags = hash_op.flags; | ||
83 | + kcop.cop.len = hash_op.len; | ||
84 | + kcop.cop.src = hash_op.src; | ||
85 | + kcop.cop.mac = hash_op.mac_result; | ||
86 | + kcop.cop.dst = 0; | ||
87 | + kcop.cop.op = 0; | ||
88 | + kcop.cop.iv = 0; | ||
89 | + kcop.ivlen = 0; | ||
90 | + kcop.digestsize = 0; /* will be updated during operation */ | ||
91 | + kcop.task = current; | ||
92 | + kcop.mm = current->mm; | ||
93 | + | ||
94 | + ret = crypto_run(fcr, &kcop); | ||
95 | + if (unlikely(ret)) { | ||
96 | + dwarning(1, "Error in hash run"); | ||
97 | + return ret; | ||
98 | + } | ||
99 | + | ||
100 | + ret = copy_to_user(kcop.cop.mac, kcop.hash_output, kcop.digestsize); | ||
101 | + if (unlikely(ret)) { | ||
102 | + dwarning(1, "Error in copy to user"); | ||
103 | + return ret; | ||
104 | + } | ||
105 | + | ||
106 | + /* put session */ | ||
107 | + ret = crypto_finish_session(fcr, sop.ses); | ||
108 | + return 0; | ||
109 | case CIOCAUTHCRYPT: | ||
110 | if (unlikely(ret = kcaop_from_user(&kcaop, fcr, arg))) { | ||
111 | dwarning(1, "Error copying from user"); | ||
112 | -- | ||
113 | 2.7.0 | ||
114 | |||
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 @@ | |||
1 | From f123f38532ae022e818312a9bc04cdb287e9623f Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Thu, 17 Dec 2015 10:34:20 +0200 | ||
4 | Subject: [PATCH 35/38] use directly crypto API 'digest' operation for CIOCHASH | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | crypto/cryptodev.h | 2 +- | ||
9 | cryptodev_int.h | 10 ++++ | ||
10 | ioctl.c | 158 ++++++++++++++++++++++++++++++++++++++++++++--------- | ||
11 | main.c | 39 ++++++++++++- | ||
12 | 4 files changed, 179 insertions(+), 30 deletions(-) | ||
13 | |||
14 | diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h | ||
15 | index c6083f7..9ade102 100644 | ||
16 | --- a/crypto/cryptodev.h | ||
17 | +++ b/crypto/cryptodev.h | ||
18 | @@ -169,7 +169,7 @@ struct crypt_auth_op { | ||
19 | |||
20 | /* data container for CIOCHASH operations */ | ||
21 | struct hash_op_data { | ||
22 | - __u32 ses; /* session identifier */ | ||
23 | + struct csession *ses; /* session identifier */ | ||
24 | __u32 mac_op; /* cryptodev_crypto_op_t */ | ||
25 | __u8 *mackey; | ||
26 | __u32 mackeylen; | ||
27 | diff --git a/cryptodev_int.h b/cryptodev_int.h | ||
28 | index cb005d7..74c295a 100644 | ||
29 | --- a/cryptodev_int.h | ||
30 | +++ b/cryptodev_int.h | ||
31 | @@ -164,6 +164,15 @@ struct kernel_crypt_op { | ||
32 | struct mm_struct *mm; | ||
33 | }; | ||
34 | |||
35 | +struct kernel_hash_op { | ||
36 | + struct hash_op_data hash_op; | ||
37 | + | ||
38 | + int digestsize; | ||
39 | + uint8_t hash_output[AALG_MAX_RESULT_LEN]; | ||
40 | + struct task_struct *task; | ||
41 | + struct mm_struct *mm; | ||
42 | +}; | ||
43 | + | ||
44 | struct kernel_crypt_auth_op { | ||
45 | struct crypt_auth_op caop; | ||
46 | |||
47 | @@ -192,6 +201,7 @@ int kcaop_to_user(struct kernel_crypt_auth_op *kcaop, | ||
48 | struct fcrypt *fcr, void __user *arg); | ||
49 | int crypto_auth_run(struct fcrypt *fcr, struct kernel_crypt_auth_op *kcaop); | ||
50 | int crypto_run(struct fcrypt *fcr, struct kernel_crypt_op *kcop); | ||
51 | +int hash_run(struct kernel_hash_op *khop); | ||
52 | |||
53 | #include <cryptlib.h> | ||
54 | |||
55 | diff --git a/ioctl.c b/ioctl.c | ||
56 | index 3763954..a052614 100644 | ||
57 | --- a/ioctl.c | ||
58 | +++ b/ioctl.c | ||
59 | @@ -397,7 +397,128 @@ session_error: | ||
60 | return ret; | ||
61 | } | ||
62 | |||
63 | -/* Everything that needs to be done when removing a session. */ | ||
64 | +static inline void hash_destroy_session(struct csession *ses_ptr) | ||
65 | +{ | ||
66 | + cryptodev_hash_deinit(&ses_ptr->hdata); | ||
67 | + kfree(ses_ptr->pages); | ||
68 | + kfree(ses_ptr->sg); | ||
69 | + kfree(ses_ptr); | ||
70 | +} | ||
71 | + | ||
72 | +static int hash_create_session(struct hash_op_data *hash_op) | ||
73 | +{ | ||
74 | + struct csession *ses; | ||
75 | + int ret = 0; | ||
76 | + const char *hash_name; | ||
77 | + int hmac_mode = 1; | ||
78 | + uint8_t mkey[CRYPTO_HMAC_MAX_KEY_LEN]; | ||
79 | + | ||
80 | + switch (hash_op->mac_op) { | ||
81 | + case CRYPTO_MD5_HMAC: | ||
82 | + hash_name = "hmac(md5)"; | ||
83 | + break; | ||
84 | + case CRYPTO_RIPEMD160_HMAC: | ||
85 | + hash_name = "hmac(rmd160)"; | ||
86 | + break; | ||
87 | + case CRYPTO_SHA1_HMAC: | ||
88 | + hash_name = "hmac(sha1)"; | ||
89 | + break; | ||
90 | + case CRYPTO_SHA2_224_HMAC: | ||
91 | + hash_name = "hmac(sha224)"; | ||
92 | + break; | ||
93 | + case CRYPTO_SHA2_256_HMAC: | ||
94 | + hash_name = "hmac(sha256)"; | ||
95 | + break; | ||
96 | + case CRYPTO_SHA2_384_HMAC: | ||
97 | + hash_name = "hmac(sha384)"; | ||
98 | + break; | ||
99 | + case CRYPTO_SHA2_512_HMAC: | ||
100 | + hash_name = "hmac(sha512)"; | ||
101 | + break; | ||
102 | + /* non-hmac cases */ | ||
103 | + case CRYPTO_MD5: | ||
104 | + hash_name = "md5"; | ||
105 | + hmac_mode = 0; | ||
106 | + break; | ||
107 | + case CRYPTO_RIPEMD160: | ||
108 | + hash_name = "rmd160"; | ||
109 | + hmac_mode = 0; | ||
110 | + break; | ||
111 | + case CRYPTO_SHA1: | ||
112 | + hash_name = "sha1"; | ||
113 | + hmac_mode = 0; | ||
114 | + break; | ||
115 | + case CRYPTO_SHA2_224: | ||
116 | + hash_name = "sha224"; | ||
117 | + hmac_mode = 0; | ||
118 | + break; | ||
119 | + case CRYPTO_SHA2_256: | ||
120 | + hash_name = "sha256"; | ||
121 | + hmac_mode = 0; | ||
122 | + break; | ||
123 | + case CRYPTO_SHA2_384: | ||
124 | + hash_name = "sha384"; | ||
125 | + hmac_mode = 0; | ||
126 | + break; | ||
127 | + case CRYPTO_SHA2_512: | ||
128 | + hash_name = "sha512"; | ||
129 | + hmac_mode = 0; | ||
130 | + break; | ||
131 | + default: | ||
132 | + ddebug(1, "bad mac: %d", hash_op->mac_op); | ||
133 | + return -EINVAL; | ||
134 | + } | ||
135 | + | ||
136 | + ses = kzalloc(sizeof(*ses), GFP_KERNEL); | ||
137 | + if (!ses) { | ||
138 | + return -ENOMEM; | ||
139 | + } | ||
140 | + | ||
141 | + if (unlikely(hash_op->mackeylen > CRYPTO_HMAC_MAX_KEY_LEN)) { | ||
142 | + ddebug(1, "Setting key failed for %s-%zu.", hash_name, | ||
143 | + (size_t)hash_op->mackeylen * 8); | ||
144 | + ret = -EINVAL; | ||
145 | + goto error_hash; | ||
146 | + } | ||
147 | + | ||
148 | + if (hash_op->mackey && | ||
149 | + unlikely(copy_from_user(mkey, hash_op->mackey, hash_op->mackeylen))) { | ||
150 | + ret = -EFAULT; | ||
151 | + goto error_hash; | ||
152 | + } | ||
153 | + | ||
154 | + ret = cryptodev_hash_init(&ses->hdata, hash_name, hmac_mode, | ||
155 | + mkey, hash_op->mackeylen); | ||
156 | + if (ret != 0) { | ||
157 | + ddebug(1, "Failed to load hash for %s", hash_name); | ||
158 | + ret = -EINVAL; | ||
159 | + goto error_hash; | ||
160 | + } | ||
161 | + | ||
162 | + ses->alignmask = ses->hdata.alignmask; | ||
163 | + ddebug(2, "got alignmask %d", ses->alignmask); | ||
164 | + | ||
165 | + ses->array_size = DEFAULT_PREALLOC_PAGES; | ||
166 | + ddebug(2, "preallocating for %d user pages", ses->array_size); | ||
167 | + | ||
168 | + ses->pages = kzalloc(ses->array_size * sizeof(struct page *), GFP_KERNEL); | ||
169 | + ses->sg = kzalloc(ses->array_size * sizeof(struct scatterlist), GFP_KERNEL); | ||
170 | + if (ses->sg == NULL || ses->pages == NULL) { | ||
171 | + ddebug(0, "Memory error"); | ||
172 | + ret = -ENOMEM; | ||
173 | + goto error_hash; | ||
174 | + } | ||
175 | + | ||
176 | + hash_op->ses = ses; | ||
177 | + return 0; | ||
178 | + | ||
179 | +error_hash: | ||
180 | + hash_destroy_session(ses); | ||
181 | + return ret; | ||
182 | +} | ||
183 | + | ||
184 | + | ||
185 | +/* Everything that needs to be done when remowing a session. */ | ||
186 | static inline void | ||
187 | crypto_destroy_session(struct csession *ses_ptr) | ||
188 | { | ||
189 | @@ -960,7 +1081,7 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | ||
190 | void __user *arg = (void __user *)arg_; | ||
191 | int __user *p = arg; | ||
192 | struct session_op sop; | ||
193 | - struct hash_op_data hash_op; | ||
194 | + struct kernel_hash_op khop; | ||
195 | struct kernel_crypt_op kcop; | ||
196 | struct kernel_crypt_auth_op kcaop; | ||
197 | struct crypt_priv *pcr = filp->private_data; | ||
198 | @@ -1051,52 +1172,35 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | ||
199 | |||
200 | return kcop_to_user(&kcop, fcr, arg); | ||
201 | case CIOCHASH: | ||
202 | - /* get session */ | ||
203 | - if (unlikely(copy_from_user(&hash_op, arg, sizeof(struct hash_op_data)))) { | ||
204 | + if (unlikely(copy_from_user(&khop.hash_op, arg, sizeof(struct hash_op_data)))) { | ||
205 | pr_err("copy from user fault\n"); | ||
206 | return -EFAULT; | ||
207 | } | ||
208 | + khop.task = current; | ||
209 | + khop.mm = current->mm; | ||
210 | |||
211 | - sop.cipher = 0; | ||
212 | - sop.mac = hash_op.mac_op; | ||
213 | - sop.mackey = hash_op.mackey; | ||
214 | - sop.mackeylen = hash_op.mackeylen; | ||
215 | - | ||
216 | - /* writes sop.ses as a side-effect */ | ||
217 | - ret = crypto_create_session(fcr, &sop); | ||
218 | + /* get session */ | ||
219 | + ret = hash_create_session(&khop.hash_op); | ||
220 | if (unlikely(ret)) { | ||
221 | pr_err("can't get session\n"); | ||
222 | return ret; | ||
223 | } | ||
224 | |||
225 | /* do hashing */ | ||
226 | - kcop.cop.ses = sop.ses; | ||
227 | - kcop.cop.flags = hash_op.flags; | ||
228 | - kcop.cop.len = hash_op.len; | ||
229 | - kcop.cop.src = hash_op.src; | ||
230 | - kcop.cop.mac = hash_op.mac_result; | ||
231 | - kcop.cop.dst = 0; | ||
232 | - kcop.cop.op = 0; | ||
233 | - kcop.cop.iv = 0; | ||
234 | - kcop.ivlen = 0; | ||
235 | - kcop.digestsize = 0; /* will be updated during operation */ | ||
236 | - kcop.task = current; | ||
237 | - kcop.mm = current->mm; | ||
238 | - | ||
239 | - ret = crypto_run(fcr, &kcop); | ||
240 | + ret = hash_run(&khop); | ||
241 | if (unlikely(ret)) { | ||
242 | dwarning(1, "Error in hash run"); | ||
243 | return ret; | ||
244 | } | ||
245 | |||
246 | - ret = copy_to_user(kcop.cop.mac, kcop.hash_output, kcop.digestsize); | ||
247 | + ret = copy_to_user(khop.hash_op.mac_result, khop.hash_output, khop.digestsize); | ||
248 | if (unlikely(ret)) { | ||
249 | dwarning(1, "Error in copy to user"); | ||
250 | return ret; | ||
251 | } | ||
252 | |||
253 | /* put session */ | ||
254 | - ret = crypto_finish_session(fcr, sop.ses); | ||
255 | + hash_destroy_session(khop.hash_op.ses); | ||
256 | return 0; | ||
257 | case CIOCAUTHCRYPT: | ||
258 | if (unlikely(ret = kcaop_from_user(&kcaop, fcr, arg))) { | ||
259 | diff --git a/main.c b/main.c | ||
260 | index ec11129..095aea5 100644 | ||
261 | --- a/main.c | ||
262 | +++ b/main.c | ||
263 | @@ -159,8 +159,6 @@ __crypto_run_std(struct csession *ses_ptr, struct crypt_op *cop) | ||
264 | return ret; | ||
265 | } | ||
266 | |||
267 | - | ||
268 | - | ||
269 | /* This is the main crypto function - zero-copy edition */ | ||
270 | static int | ||
271 | __crypto_run_zc(struct csession *ses_ptr, struct kernel_crypt_op *kcop) | ||
272 | @@ -841,3 +839,40 @@ out_unlock: | ||
273 | crypto_put_session(ses_ptr); | ||
274 | return ret; | ||
275 | } | ||
276 | + | ||
277 | +int hash_run(struct kernel_hash_op *khop) | ||
278 | +{ | ||
279 | + struct hash_op_data *hash_op = &khop->hash_op; | ||
280 | + struct csession *ses_ptr = hash_op->ses; | ||
281 | + struct hash_data *hdata = &ses_ptr->hdata; | ||
282 | + int ret; | ||
283 | + struct scatterlist *src_sg; | ||
284 | + struct scatterlist *dst_sg; /* required by get_userbuf but not used */ | ||
285 | + | ||
286 | + if (hash_op->len == 0) { | ||
287 | + src_sg = NULL; | ||
288 | + } else { | ||
289 | + ret = get_userbuf(ses_ptr, hash_op->src, hash_op->len, NULL, 0, | ||
290 | + khop->task, khop->mm, &src_sg, &dst_sg); | ||
291 | + if (unlikely(ret)) { | ||
292 | + derr(1, "Error getting user pages"); | ||
293 | + return ret; | ||
294 | + } | ||
295 | + } | ||
296 | + | ||
297 | + ahash_request_set_crypt(hdata->async.request, src_sg, khop->hash_output, hash_op->len); | ||
298 | + | ||
299 | + ret = crypto_ahash_digest(hdata->async.request); | ||
300 | + if (ret == -EINPROGRESS || ret == -EBUSY) { | ||
301 | + wait_for_completion(&hdata->async.result.completion); | ||
302 | + ret = hdata->async.result.err; | ||
303 | + if (ret != 0) { | ||
304 | + derr(0, "CryptoAPI failure: %d", ret); | ||
305 | + } | ||
306 | + } | ||
307 | + | ||
308 | + khop->digestsize = ses_ptr->hdata.digestsize; | ||
309 | + | ||
310 | + release_user_pages(ses_ptr); | ||
311 | + return ret; | ||
312 | +} | ||
313 | -- | ||
314 | 2.7.0 | ||
315 | |||
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 @@ | |||
1 | From 711529cc7b8743ae8c9c0db4980ac15f7acb8618 Mon Sep 17 00:00:00 2001 | ||
2 | From: Alex Porosanu <alexandru.porosanu@nxp.com> | ||
3 | Date: Tue, 12 Jan 2016 14:51:00 +0200 | ||
4 | Subject: [PATCH 36/38] add compat for CIOCHASH operation | ||
5 | |||
6 | This patch adds the necessary ioctl for using the CIOCHASH | ||
7 | operation for different userspace & kernel (i.e. 32b userspace | ||
8 | and 64b kernel). | ||
9 | |||
10 | Signed-off-by: Alex Porosanu <alexandru.porosanu@nxp.com> | ||
11 | --- | ||
12 | cryptodev_int.h | 14 +++++++++++++- | ||
13 | ioctl.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
14 | 2 files changed, 63 insertions(+), 1 deletion(-) | ||
15 | |||
16 | diff --git a/cryptodev_int.h b/cryptodev_int.h | ||
17 | index 74c295a..6dcfd69 100644 | ||
18 | --- a/cryptodev_int.h | ||
19 | +++ b/cryptodev_int.h | ||
20 | @@ -129,6 +129,18 @@ struct compat_crypt_auth_op { | ||
21 | uint32_t iv_len; | ||
22 | }; | ||
23 | |||
24 | +struct compat_hash_op_data { | ||
25 | + compat_uptr_t ses; | ||
26 | + uint32_t mac_op; /* cryptodev_crypto_op_t */ | ||
27 | + compat_uptr_t mackey; | ||
28 | + uint32_t mackeylen; | ||
29 | + | ||
30 | + uint16_t flags; /* see COP_FLAG_* */ | ||
31 | + uint32_t len; /* length of source data */ | ||
32 | + compat_uptr_t src; /* source data */ | ||
33 | + compat_uptr_t mac_result; | ||
34 | +}; | ||
35 | + | ||
36 | /* compat ioctls, defined for the above structs */ | ||
37 | #define COMPAT_CIOCGSESSION _IOWR('c', 102, struct compat_session_op) | ||
38 | #define COMPAT_CIOCCRYPT _IOWR('c', 104, struct compat_crypt_op) | ||
39 | @@ -139,7 +151,7 @@ struct compat_crypt_auth_op { | ||
40 | #define COMPAT_CIOCASYMASYNCRYPT _IOW('c', 110, struct compat_crypt_kop) | ||
41 | #define COMPAT_CIOCASYMFETCHCOOKIE _IOR('c', 111, \ | ||
42 | struct compat_pkc_cookie_list_s) | ||
43 | - | ||
44 | +#define COMPAT_CIOCHASH _IOWR('c', 114, struct compat_hash_op_data) | ||
45 | #endif /* CONFIG_COMPAT */ | ||
46 | |||
47 | /* kernel-internal extension to struct crypt_kop */ | ||
48 | diff --git a/ioctl.c b/ioctl.c | ||
49 | index a052614..ff3de44 100644 | ||
50 | --- a/ioctl.c | ||
51 | +++ b/ioctl.c | ||
52 | @@ -1435,8 +1435,11 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) | ||
53 | struct fcrypt *fcr; | ||
54 | struct session_op sop; | ||
55 | struct compat_session_op compat_sop; | ||
56 | + struct kernel_hash_op khop; | ||
57 | struct kernel_crypt_op kcop; | ||
58 | struct kernel_crypt_auth_op kcaop; | ||
59 | + struct compat_hash_op_data compat_hash_op_data; | ||
60 | + | ||
61 | int ret; | ||
62 | |||
63 | if (unlikely(!pcr)) | ||
64 | @@ -1499,6 +1502,53 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) | ||
65 | |||
66 | return compat_kcop_to_user(&kcop, fcr, arg); | ||
67 | |||
68 | + case COMPAT_CIOCHASH: | ||
69 | + /* get session */ | ||
70 | + if (unlikely(copy_from_user(&compat_hash_op_data, arg, | ||
71 | + sizeof(struct compat_hash_op_data)))) { | ||
72 | + pr_err("copy from user fault\n"); | ||
73 | + return -EFAULT; | ||
74 | + } | ||
75 | + | ||
76 | + khop.task = current; | ||
77 | + khop.mm = current->mm; | ||
78 | + | ||
79 | + khop.hash_op.mac_op = compat_hash_op_data.mac_op; | ||
80 | + khop.hash_op.mackey = compat_ptr(compat_hash_op_data.mackey); | ||
81 | + khop.hash_op.mackeylen = compat_hash_op_data.mackeylen; | ||
82 | + khop.hash_op.flags = compat_hash_op_data.flags; | ||
83 | + khop.hash_op.len = compat_hash_op_data.len; | ||
84 | + khop.hash_op.src = compat_ptr(compat_hash_op_data.src); | ||
85 | + khop.hash_op.mac_result = | ||
86 | + compat_ptr(compat_hash_op_data.mac_result); | ||
87 | + | ||
88 | + ret = hash_create_session(&khop.hash_op); | ||
89 | + if (unlikely(ret)) { | ||
90 | + pr_err("can't get session\n"); | ||
91 | + return ret; | ||
92 | + } | ||
93 | + | ||
94 | + /* do hashing */ | ||
95 | + ret = hash_run(&khop); | ||
96 | + if (unlikely(ret)) { | ||
97 | + dwarning(1, "Error in hash run"); | ||
98 | + return ret; | ||
99 | + } | ||
100 | + | ||
101 | + ret = copy_to_user(khop.hash_op.mac_result, khop.hash_output, | ||
102 | + khop.digestsize); | ||
103 | + if (unlikely(ret)) { | ||
104 | + dwarning(1, "Error in copy to user"); | ||
105 | + return ret; | ||
106 | + } | ||
107 | + | ||
108 | + copy_to_user(arg, &compat_hash_op_data, | ||
109 | + sizeof(struct compat_hash_op_data)); | ||
110 | + | ||
111 | + /* put session */ | ||
112 | + hash_destroy_session(khop.hash_op.ses); | ||
113 | + return 0; | ||
114 | + | ||
115 | case COMPAT_CIOCAUTHCRYPT: | ||
116 | if (unlikely(ret = compat_kcaop_from_user(&kcaop, fcr, arg))) { | ||
117 | dprintk(1, KERN_WARNING, "Error copying from user\n"); | ||
118 | -- | ||
119 | 2.7.0 | ||
120 | |||
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 @@ | |||
1 | From 344a0243e31f8fc467253404a548eedbb72b35d0 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Wed, 20 Jan 2016 17:11:49 +0200 | ||
4 | Subject: [PATCH 37/38] rewrite sha_speed.c to reduce code duplication | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/sha_speed.c | 131 ++++++++++++++++++++++++++++++++++-------------------- | ||
9 | 1 file changed, 84 insertions(+), 47 deletions(-) | ||
10 | |||
11 | diff --git a/tests/sha_speed.c b/tests/sha_speed.c | ||
12 | index e1dc54b..5f694bd 100644 | ||
13 | --- a/tests/sha_speed.c | ||
14 | +++ b/tests/sha_speed.c | ||
15 | @@ -28,6 +28,13 @@ | ||
16 | |||
17 | #include <crypto/cryptodev.h> | ||
18 | |||
19 | +/* Sizes of buffers to be hashed */ | ||
20 | +int buffer_lengths[] = {256, 512, 1024, 2048, 4096, 8192, 65536, 0}; | ||
21 | + | ||
22 | +/* Time in seconds allocated for each tested buffer lengths */ | ||
23 | +#define BUFFER_TEST_TIME 10 | ||
24 | + | ||
25 | + | ||
26 | static double udifftimeval(struct timeval start, struct timeval end) | ||
27 | { | ||
28 | return (double)(end.tv_usec - start.tv_usec) + | ||
29 | @@ -97,7 +104,7 @@ int hash_data(struct session_op *sess, int fdc, int chunksize, int alignmask) | ||
30 | memset(buffer, val++, chunksize); | ||
31 | |||
32 | must_finish = 0; | ||
33 | - alarm(5); | ||
34 | + alarm(BUFFER_TEST_TIME); | ||
35 | |||
36 | gettimeofday(&start, NULL); | ||
37 | do { | ||
38 | @@ -126,73 +133,103 @@ int hash_data(struct session_op *sess, int fdc, int chunksize, int alignmask) | ||
39 | return 0; | ||
40 | } | ||
41 | |||
42 | -int main(void) | ||
43 | -{ | ||
44 | - int fd, i, fdc = -1, alignmask = 0; | ||
45 | - struct session_op sess; | ||
46 | - char keybuf[32]; | ||
47 | + | ||
48 | #ifdef CIOCGSESSINFO | ||
49 | +int get_alignmask(struct session_op *sess, int fdc) | ||
50 | +{ | ||
51 | struct session_info_op siop; | ||
52 | + | ||
53 | + siop.ses = sess->ses; | ||
54 | + if (ioctl(fdc, CIOCGSESSINFO, &siop) < 0) { | ||
55 | + perror("ioctl(CIOCGSESSINFO)"); | ||
56 | + /* continue test ignoring CIOCGSESSINFO error */ | ||
57 | + return 0; | ||
58 | + } | ||
59 | + | ||
60 | + printf("using algorithm %s with driver %s\n", | ||
61 | + siop.hash_info.cra_name, siop.hash_info.cra_driver_name); | ||
62 | + | ||
63 | + return siop.alignmask; | ||
64 | +} | ||
65 | #endif | ||
66 | |||
67 | - signal(SIGALRM, alarm_handler); | ||
68 | |||
69 | - if ((fd = open("/dev/crypto", O_RDWR, 0)) < 0) { | ||
70 | - perror("open()"); | ||
71 | - return 1; | ||
72 | - } | ||
73 | - if (ioctl(fd, CRIOGET, &fdc)) { | ||
74 | - perror("ioctl(CRIOGET)"); | ||
75 | - return 1; | ||
76 | - } | ||
77 | +int hash_session(struct session_op *sess, int fdc) | ||
78 | +{ | ||
79 | + int i; | ||
80 | + int err; | ||
81 | + int alignmask; | ||
82 | |||
83 | - fprintf(stderr, "Testing SHA1 Hash: \n"); | ||
84 | - memset(&sess, 0, sizeof(sess)); | ||
85 | - sess.mac = CRYPTO_SHA1; | ||
86 | - if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
87 | + if (ioctl(fdc, CIOCGSESSION, sess)) { | ||
88 | perror("ioctl(CIOCGSESSION)"); | ||
89 | return 1; | ||
90 | } | ||
91 | + | ||
92 | #ifdef CIOCGSESSINFO | ||
93 | - siop.ses = sess.ses; | ||
94 | - if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
95 | - perror("ioctl(CIOCGSESSINFO)"); | ||
96 | - return 1; | ||
97 | - } | ||
98 | - printf("requested hash CRYPTO_SHA1, got %s with driver %s\n", | ||
99 | - siop.hash_info.cra_name, siop.hash_info.cra_driver_name); | ||
100 | - alignmask = siop.alignmask; | ||
101 | + alignmask = get_alignmask(sess, fdc); | ||
102 | +#else | ||
103 | + alignmask = 0; | ||
104 | #endif | ||
105 | |||
106 | - for (i = 256; i <= (64 * 1024); i *= 4) { | ||
107 | - if (hash_data(&sess, fdc, i, alignmask)) | ||
108 | - break; | ||
109 | + err = 0; | ||
110 | + for(i = 0; (err == 0) && (buffer_lengths[i] != 0); i++) { | ||
111 | + err = hash_data(sess, fdc, buffer_lengths[i], alignmask); | ||
112 | } | ||
113 | |||
114 | - fprintf(stderr, "\nTesting SHA256 Hash: \n"); | ||
115 | - memset(&sess, 0, sizeof(sess)); | ||
116 | - sess.mac = CRYPTO_SHA2_256; | ||
117 | - if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
118 | - perror("ioctl(CIOCGSESSION)"); | ||
119 | + if (ioctl(fdc, CIOCFSESSION, sess)) { | ||
120 | + perror("ioctl(CIOCFSESSION)"); | ||
121 | return 1; | ||
122 | } | ||
123 | -#ifdef CIOCGSESSINFO | ||
124 | - siop.ses = sess.ses; | ||
125 | - if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
126 | - perror("ioctl(CIOCGSESSINFO)"); | ||
127 | + | ||
128 | + return err; | ||
129 | +} | ||
130 | + | ||
131 | +int test_sha1(struct session_op *sess, int fdc) | ||
132 | +{ | ||
133 | + fprintf(stderr, "Testing SHA1 Hash: \n"); | ||
134 | + memset(sess, 0, sizeof(sess)); | ||
135 | + sess->mac = CRYPTO_SHA1; | ||
136 | + return hash_session(sess, fdc); | ||
137 | +} | ||
138 | + | ||
139 | + | ||
140 | +int test_sha256(struct session_op *sess, int fdc) | ||
141 | +{ | ||
142 | + fprintf(stderr, "Testing SHA256 Hash: \n"); | ||
143 | + memset(sess, 0, sizeof(sess)); | ||
144 | + sess->mac = CRYPTO_SHA2_256; | ||
145 | + return hash_session(sess, fdc); | ||
146 | +} | ||
147 | + | ||
148 | + | ||
149 | +int main(void) | ||
150 | +{ | ||
151 | + int fd; | ||
152 | + int fdc; | ||
153 | + int err; | ||
154 | + int i; | ||
155 | + struct session_op sess; | ||
156 | + | ||
157 | + signal(SIGALRM, alarm_handler); | ||
158 | + | ||
159 | + fd = open("/dev/crypto", O_RDWR, 0); | ||
160 | + if (fd < 0) { | ||
161 | + perror("open()"); | ||
162 | return 1; | ||
163 | } | ||
164 | - printf("requested hash CRYPTO_SHA2_256, got %s with driver %s\n", | ||
165 | - siop.hash_info.cra_name, siop.hash_info.cra_driver_name); | ||
166 | - alignmask = siop.alignmask; | ||
167 | -#endif | ||
168 | |||
169 | - for (i = 256; i <= (64 * 1024); i *= 4) { | ||
170 | - if (hash_data(&sess, fdc, i, alignmask)) | ||
171 | - break; | ||
172 | + err = ioctl(fd, CRIOGET, &fdc); | ||
173 | + if (err != 0) { | ||
174 | + perror("ioctl(CRIOGET)"); | ||
175 | + close(fd); | ||
176 | + return 1; | ||
177 | } | ||
178 | |||
179 | + /* run all tests but return an eventual error */ | ||
180 | + err |= test_sha1(&sess, fdc); | ||
181 | + err |= test_sha256(&sess, fdc); | ||
182 | + | ||
183 | close(fdc); | ||
184 | close(fd); | ||
185 | - return 0; | ||
186 | + return err; | ||
187 | } | ||
188 | -- | ||
189 | 2.7.0 | ||
190 | |||
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 @@ | |||
1 | From 65704ea24e80647e8c5f938300f51cb70af50c1c Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Thu, 21 Jan 2016 17:30:59 +0200 | ||
4 | Subject: [PATCH 38/38] extend sha_speed.c to test CIOCHASH | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/sha_speed.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
9 | 1 file changed, 90 insertions(+) | ||
10 | |||
11 | diff --git a/tests/sha_speed.c b/tests/sha_speed.c | ||
12 | index 5f694bd..d731c66 100644 | ||
13 | --- a/tests/sha_speed.c | ||
14 | +++ b/tests/sha_speed.c | ||
15 | @@ -133,6 +133,62 @@ int hash_data(struct session_op *sess, int fdc, int chunksize, int alignmask) | ||
16 | return 0; | ||
17 | } | ||
18 | |||
19 | +int digest_data(struct session_op *sess, int fdc, int chunksize, int alignmask) | ||
20 | +{ | ||
21 | + struct hash_op_data hash_op; | ||
22 | + char *buffer; | ||
23 | + static int val = 23; | ||
24 | + struct timeval start, end; | ||
25 | + double total = 0; | ||
26 | + double secs, ddata, dspeed; | ||
27 | + char metric[16]; | ||
28 | + uint8_t mac[AALG_MAX_RESULT_LEN]; | ||
29 | + | ||
30 | + if (alignmask) { | ||
31 | + if (posix_memalign((void **)&buffer, alignmask + 1, chunksize)) { | ||
32 | + printf("posix_memalign() failed!\n"); | ||
33 | + return 1; | ||
34 | + } | ||
35 | + } else { | ||
36 | + if (!(buffer = malloc(chunksize))) { | ||
37 | + perror("malloc()"); | ||
38 | + return 1; | ||
39 | + } | ||
40 | + } | ||
41 | + | ||
42 | + printf("\tEncrypting in chunks of %d bytes: ", chunksize); | ||
43 | + fflush(stdout); | ||
44 | + | ||
45 | + memset(buffer, val++, chunksize); | ||
46 | + | ||
47 | + must_finish = 0; | ||
48 | + alarm(BUFFER_TEST_TIME); | ||
49 | + | ||
50 | + gettimeofday(&start, NULL); | ||
51 | + do { | ||
52 | + memset(&hash_op, 0, sizeof(hash_op)); | ||
53 | + hash_op.mac_op = sess->mac; | ||
54 | + hash_op.len = chunksize; | ||
55 | + hash_op.src = (unsigned char *)buffer; | ||
56 | + hash_op.mac_result = mac; | ||
57 | + | ||
58 | + if (ioctl(fdc, CIOCHASH, hash_op) != 0) { | ||
59 | + perror("ioctl(CIOCHASH)"); | ||
60 | + return 1; | ||
61 | + } | ||
62 | + total += chunksize; | ||
63 | + } while(must_finish == 0); | ||
64 | + gettimeofday(&end, NULL); | ||
65 | + | ||
66 | + secs = udifftimeval(start, end)/ 1000000.0; | ||
67 | + | ||
68 | + value2human(1, total, secs, &ddata, &dspeed, metric); | ||
69 | + printf ("done. %.2f %s in %.2f secs: ", ddata, metric, secs); | ||
70 | + printf ("%.2f %s/sec\n", dspeed, metric); | ||
71 | + | ||
72 | + free(buffer); | ||
73 | + return 0; | ||
74 | +} | ||
75 | |||
76 | #ifdef CIOCGSESSINFO | ||
77 | int get_alignmask(struct session_op *sess, int fdc) | ||
78 | @@ -154,6 +210,20 @@ int get_alignmask(struct session_op *sess, int fdc) | ||
79 | #endif | ||
80 | |||
81 | |||
82 | +int ciochash_session(struct session_op *sess, int fdc) | ||
83 | +{ | ||
84 | + int i; | ||
85 | + int err = 0; | ||
86 | + | ||
87 | + err = 0; | ||
88 | + for(i = 0; (err == 0) && (buffer_lengths[i] != 0); i++) { | ||
89 | + err = digest_data(sess, fdc, buffer_lengths[i], 0); | ||
90 | + } | ||
91 | + | ||
92 | + return err; | ||
93 | +} | ||
94 | + | ||
95 | + | ||
96 | int hash_session(struct session_op *sess, int fdc) | ||
97 | { | ||
98 | int i; | ||
99 | @@ -193,6 +263,15 @@ int test_sha1(struct session_op *sess, int fdc) | ||
100 | } | ||
101 | |||
102 | |||
103 | +int test_sha1_ciochash(struct session_op *sess, int fdc) | ||
104 | +{ | ||
105 | + fprintf(stderr, "Testing SHA1 CIOCHASH: \n"); | ||
106 | + memset(sess, 0, sizeof(sess)); | ||
107 | + sess->mac = CRYPTO_SHA1; | ||
108 | + return ciochash_session(sess, fdc); | ||
109 | +} | ||
110 | + | ||
111 | + | ||
112 | int test_sha256(struct session_op *sess, int fdc) | ||
113 | { | ||
114 | fprintf(stderr, "Testing SHA256 Hash: \n"); | ||
115 | @@ -202,6 +281,15 @@ int test_sha256(struct session_op *sess, int fdc) | ||
116 | } | ||
117 | |||
118 | |||
119 | +int test_sha256_ciochash(struct session_op *sess, int fdc) | ||
120 | +{ | ||
121 | + fprintf(stderr, "Testing SHA256 CIOCHASH: \n"); | ||
122 | + memset(sess, 0, sizeof(sess)); | ||
123 | + sess->mac = CRYPTO_SHA2_256; | ||
124 | + return ciochash_session(sess, fdc); | ||
125 | +} | ||
126 | + | ||
127 | + | ||
128 | int main(void) | ||
129 | { | ||
130 | int fd; | ||
131 | @@ -227,7 +315,9 @@ int main(void) | ||
132 | |||
133 | /* run all tests but return an eventual error */ | ||
134 | err |= test_sha1(&sess, fdc); | ||
135 | + err |= test_sha1_ciochash(&sess, fdc); | ||
136 | err |= test_sha256(&sess, fdc); | ||
137 | + err |= test_sha256_ciochash(&sess, fdc); | ||
138 | |||
139 | close(fdc); | ||
140 | close(fd); | ||
141 | -- | ||
142 | 2.7.0 | ||
143 | |||
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 @@ | |||
1 | From 3e3996b40fd3a93cbe2e5ddee244280dd7de6c18 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@freescale.com> | ||
3 | Date: Tue, 9 Feb 2016 21:07:06 +0200 | ||
4 | Subject: [PATCH 39/40] fix memory leaks on error path for CIOCHASH | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> | ||
7 | --- | ||
8 | ioctl.c | 20 +++++++++++--------- | ||
9 | 1 file changed, 11 insertions(+), 9 deletions(-) | ||
10 | |||
11 | diff --git a/ioctl.c b/ioctl.c | ||
12 | index ff3de44..8d81b56 100644 | ||
13 | --- a/ioctl.c | ||
14 | +++ b/ioctl.c | ||
15 | @@ -1190,18 +1190,17 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | ||
16 | ret = hash_run(&khop); | ||
17 | if (unlikely(ret)) { | ||
18 | dwarning(1, "Error in hash run"); | ||
19 | - return ret; | ||
20 | + goto hash_err; | ||
21 | } | ||
22 | |||
23 | ret = copy_to_user(khop.hash_op.mac_result, khop.hash_output, khop.digestsize); | ||
24 | if (unlikely(ret)) { | ||
25 | dwarning(1, "Error in copy to user"); | ||
26 | - return ret; | ||
27 | } | ||
28 | |||
29 | - /* put session */ | ||
30 | + hash_err: | ||
31 | hash_destroy_session(khop.hash_op.ses); | ||
32 | - return 0; | ||
33 | + return ret; | ||
34 | case CIOCAUTHCRYPT: | ||
35 | if (unlikely(ret = kcaop_from_user(&kcaop, fcr, arg))) { | ||
36 | dwarning(1, "Error copying from user"); | ||
37 | @@ -1532,22 +1531,25 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) | ||
38 | ret = hash_run(&khop); | ||
39 | if (unlikely(ret)) { | ||
40 | dwarning(1, "Error in hash run"); | ||
41 | - return ret; | ||
42 | + goto hash_err; | ||
43 | } | ||
44 | |||
45 | ret = copy_to_user(khop.hash_op.mac_result, khop.hash_output, | ||
46 | khop.digestsize); | ||
47 | if (unlikely(ret)) { | ||
48 | dwarning(1, "Error in copy to user"); | ||
49 | - return ret; | ||
50 | + goto hash_err; | ||
51 | } | ||
52 | |||
53 | - copy_to_user(arg, &compat_hash_op_data, | ||
54 | + ret = copy_to_user(arg, &compat_hash_op_data, | ||
55 | sizeof(struct compat_hash_op_data)); | ||
56 | + if (unlikely(ret)) { | ||
57 | + dwarning(1, "Error in copy to user"); | ||
58 | + } | ||
59 | |||
60 | - /* put session */ | ||
61 | + hash_err: | ||
62 | hash_destroy_session(khop.hash_op.ses); | ||
63 | - return 0; | ||
64 | + return ret; | ||
65 | |||
66 | case COMPAT_CIOCAUTHCRYPT: | ||
67 | if (unlikely(ret = compat_kcaop_from_user(&kcaop, fcr, arg))) { | ||
68 | -- | ||
69 | 2.7.0 | ||
70 | |||
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 @@ | |||
1 | From 3eb9ed52743584949ff9b4844e810333c34a3a1f Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Fri, 12 Feb 2016 11:23:41 +0200 | ||
4 | Subject: [PATCH 40/40] fix structure init in sha_speed test | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/sha_speed.c | 8 ++++---- | ||
9 | 1 file changed, 4 insertions(+), 4 deletions(-) | ||
10 | |||
11 | diff --git a/tests/sha_speed.c b/tests/sha_speed.c | ||
12 | index d731c66..75d0f42 100644 | ||
13 | --- a/tests/sha_speed.c | ||
14 | +++ b/tests/sha_speed.c | ||
15 | @@ -257,7 +257,7 @@ int hash_session(struct session_op *sess, int fdc) | ||
16 | int test_sha1(struct session_op *sess, int fdc) | ||
17 | { | ||
18 | fprintf(stderr, "Testing SHA1 Hash: \n"); | ||
19 | - memset(sess, 0, sizeof(sess)); | ||
20 | + memset(sess, 0, sizeof(struct session_op)); | ||
21 | sess->mac = CRYPTO_SHA1; | ||
22 | return hash_session(sess, fdc); | ||
23 | } | ||
24 | @@ -266,7 +266,7 @@ int test_sha1(struct session_op *sess, int fdc) | ||
25 | int test_sha1_ciochash(struct session_op *sess, int fdc) | ||
26 | { | ||
27 | fprintf(stderr, "Testing SHA1 CIOCHASH: \n"); | ||
28 | - memset(sess, 0, sizeof(sess)); | ||
29 | + memset(sess, 0, sizeof(struct session_op)); | ||
30 | sess->mac = CRYPTO_SHA1; | ||
31 | return ciochash_session(sess, fdc); | ||
32 | } | ||
33 | @@ -275,7 +275,7 @@ int test_sha1_ciochash(struct session_op *sess, int fdc) | ||
34 | int test_sha256(struct session_op *sess, int fdc) | ||
35 | { | ||
36 | fprintf(stderr, "Testing SHA256 Hash: \n"); | ||
37 | - memset(sess, 0, sizeof(sess)); | ||
38 | + memset(sess, 0, sizeof(struct session_op)); | ||
39 | sess->mac = CRYPTO_SHA2_256; | ||
40 | return hash_session(sess, fdc); | ||
41 | } | ||
42 | @@ -284,7 +284,7 @@ int test_sha256(struct session_op *sess, int fdc) | ||
43 | int test_sha256_ciochash(struct session_op *sess, int fdc) | ||
44 | { | ||
45 | fprintf(stderr, "Testing SHA256 CIOCHASH: \n"); | ||
46 | - memset(sess, 0, sizeof(sess)); | ||
47 | + memset(sess, 0, sizeof(struct session_op)); | ||
48 | sess->mac = CRYPTO_SHA2_256; | ||
49 | return ciochash_session(sess, fdc); | ||
50 | } | ||
51 | -- | ||
52 | 2.7.0 | ||
53 | |||
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 @@ | |||
1 | From 0d58530f5c5970db9787a23aef4227c68f941fcc Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Wed, 10 Feb 2016 16:22:05 +0200 | ||
4 | Subject: [PATCH 41/43] add separate target for building tests | ||
5 | |||
6 | A separate target for build is useful with cross-compilation. In this | ||
7 | case it makes sense to build the tests without running them on the host | ||
8 | machine. | ||
9 | |||
10 | The default target is now 'all' and only builds the tests | ||
11 | |||
12 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
13 | --- | ||
14 | tests/Makefile | 4 ++++ | ||
15 | 1 file changed, 4 insertions(+) | ||
16 | |||
17 | diff --git a/tests/Makefile b/tests/Makefile | ||
18 | index 3155da9..89f88fe 100644 | ||
19 | --- a/tests/Makefile | ||
20 | +++ b/tests/Makefile | ||
21 | @@ -19,6 +19,8 @@ example-async-hmac-objs := async_hmac.o | ||
22 | example-async-speed-objs := async_speed.o | ||
23 | example-hashcrypt-speed-objs := hashcrypt_speed.c | ||
24 | |||
25 | +all: $(hostprogs) | ||
26 | + | ||
27 | check: $(hostprogs) | ||
28 | ./cipher | ||
29 | ./hmac | ||
30 | @@ -33,3 +35,5 @@ clean: | ||
31 | |||
32 | ${comp_progs}: LDLIBS += -lssl -lcrypto | ||
33 | ${comp_progs}: %: %.o openssl_wrapper.o | ||
34 | + | ||
35 | +.PHONY: all clean check | ||
36 | -- | ||
37 | 2.7.0 | ||
38 | |||
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 @@ | |||
1 | From dcb8fe0fcf71feac2a4f57c44a5153bfc404b4c3 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Thu, 11 Feb 2016 16:37:23 +0200 | ||
4 | Subject: [PATCH 42/43] fix destination for staged installs | ||
5 | |||
6 | The standard variable for staged installations is DESTDIR and it should | ||
7 | be set only by the user, outside of Makefile. This is consistent with | ||
8 | recommendations from both GNU Make and FreeBSD porters-handbook. | ||
9 | |||
10 | make DESTDIR=/tmp/stage install | ||
11 | |||
12 | $prefix and $PREFIX (in FreeBSD world) are used to specify where the | ||
13 | files will be installed. It defaults to /usr/local but can be /usr or | ||
14 | /opt or something else. | ||
15 | |||
16 | Usually one wants to do a stage installation when cross-building or for | ||
17 | other purposes. The convention is to use DESTDIR. | ||
18 | Changing $prefix is useful for installers. They can override its value | ||
19 | when calling make: | ||
20 | |||
21 | make prefix=/usr install | ||
22 | |||
23 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
24 | --- | ||
25 | Makefile | 7 ++++--- | ||
26 | 1 file changed, 4 insertions(+), 3 deletions(-) | ||
27 | |||
28 | diff --git a/Makefile b/Makefile | ||
29 | index 7f8df37..9871a8e 100644 | ||
30 | --- a/Makefile | ||
31 | +++ b/Makefile | ||
32 | @@ -7,7 +7,9 @@ CRYPTODEV_CFLAGS ?= #-DENABLE_ASYNC | ||
33 | KBUILD_CFLAGS += -I$(src) $(CRYPTODEV_CFLAGS) | ||
34 | KERNEL_DIR ?= /lib/modules/$(shell uname -r)/build | ||
35 | VERSION = 1.8 | ||
36 | -PREFIX ?= | ||
37 | + | ||
38 | +prefix ?= /usr/local | ||
39 | +includedir = $(prefix)/include | ||
40 | |||
41 | cryptodev-objs = ioctl.o main.o cryptlib.o authenc.o zc.o util.o | ||
42 | |||
43 | @@ -31,8 +33,7 @@ install: modules_install | ||
44 | |||
45 | modules_install: | ||
46 | $(MAKE) -C $(KERNEL_DIR) M=$(PWD) modules_install | ||
47 | - @echo "Installing cryptodev.h in $(PREFIX)/usr/include/crypto ..." | ||
48 | - @install -D crypto/cryptodev.h $(PREFIX)/usr/include/crypto/cryptodev.h | ||
49 | + install -m 644 -D crypto/cryptodev.h $(DESTDIR)/$(includedir)/crypto/cryptodev.h | ||
50 | |||
51 | clean: | ||
52 | $(MAKE) -C $(KERNEL_DIR) M=$(PWD) clean | ||
53 | -- | ||
54 | 2.7.0 | ||
55 | |||
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 @@ | |||
1 | From 44629033d47543d106299b6c8bed9e5c9fed1513 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Thu, 11 Feb 2016 16:48:53 +0200 | ||
4 | Subject: [PATCH 43/43] add install target for tests | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/Makefile | 12 +++++++++++- | ||
9 | 1 file changed, 11 insertions(+), 1 deletion(-) | ||
10 | |||
11 | diff --git a/tests/Makefile b/tests/Makefile | ||
12 | index 89f88fe..5e3111d 100644 | ||
13 | --- a/tests/Makefile | ||
14 | +++ b/tests/Makefile | ||
15 | @@ -19,6 +19,10 @@ example-async-hmac-objs := async_hmac.o | ||
16 | example-async-speed-objs := async_speed.o | ||
17 | example-hashcrypt-speed-objs := hashcrypt_speed.c | ||
18 | |||
19 | +prefix ?= /usr/local | ||
20 | +execprefix ?= $(prefix) | ||
21 | +bindir = $(execprefix)/bin | ||
22 | + | ||
23 | all: $(hostprogs) | ||
24 | |||
25 | check: $(hostprogs) | ||
26 | @@ -30,10 +34,16 @@ check: $(hostprogs) | ||
27 | ./cipher-gcm | ||
28 | ./cipher-aead | ||
29 | |||
30 | +install: | ||
31 | + install -d $(DESTDIR)/$(bindir) | ||
32 | + for prog in $(hostprogs); do \ | ||
33 | + install -m 755 $$prog $(DESTDIR)/$(bindir); \ | ||
34 | + done | ||
35 | + | ||
36 | clean: | ||
37 | rm -f *.o *~ $(hostprogs) | ||
38 | |||
39 | ${comp_progs}: LDLIBS += -lssl -lcrypto | ||
40 | ${comp_progs}: %: %.o openssl_wrapper.o | ||
41 | |||
42 | -.PHONY: all clean check | ||
43 | +.PHONY: all clean check install | ||
44 | -- | ||
45 | 2.7.0 | ||
46 | |||
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 @@ | |||
1 | From 6a89ac4c49068d4225f4c1cc94a1d20b3d174b3f Mon Sep 17 00:00:00 2001 | ||
2 | From: Radu Alexe <raduandrei.alexe@freescale.com> | ||
3 | Date: Sat, 22 Oct 2016 21:55:25 +0300 | ||
4 | Subject: [PATCH 044/104] add aes-256-xts support for async speed test | ||
5 | |||
6 | Signed-off-by: Radu Alexe <raduandrei.alexe@freescale.com> | ||
7 | --- | ||
8 | ioctl.c | 3 +++ | ||
9 | tests/async_speed.c | 25 +++++++++++++++++++++++++ | ||
10 | 2 files changed, 28 insertions(+) | ||
11 | |||
12 | diff --git a/ioctl.c b/ioctl.c | ||
13 | index 8d81b56..ca3c5ac 100644 | ||
14 | --- a/ioctl.c | ||
15 | +++ b/ioctl.c | ||
16 | @@ -172,6 +172,9 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) | ||
17 | case CRYPTO_AES_ECB: | ||
18 | alg_name = "ecb(aes)"; | ||
19 | break; | ||
20 | + case CRYPTO_AES_XTS: | ||
21 | + alg_name = "xts(aes)"; | ||
22 | + break; | ||
23 | case CRYPTO_CAMELLIA_CBC: | ||
24 | alg_name = "cbc(camellia)"; | ||
25 | break; | ||
26 | diff --git a/tests/async_speed.c b/tests/async_speed.c | ||
27 | index 1188599..39a3d23 100644 | ||
28 | --- a/tests/async_speed.c | ||
29 | +++ b/tests/async_speed.c | ||
30 | @@ -211,6 +211,31 @@ int main(void) | ||
31 | break; | ||
32 | } | ||
33 | |||
34 | + fprintf(stderr, "\nTesting AES-256-XTS cipher: \n"); | ||
35 | + memset(&sess, 0, sizeof(sess)); | ||
36 | + sess.cipher = CRYPTO_AES_XTS; | ||
37 | + sess.keylen = 32; | ||
38 | + memset(keybuf, 0x42, sess.keylen); | ||
39 | + sess.key = (unsigned char *)keybuf; | ||
40 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
41 | + perror("ioctl(CIOCGSESSION)"); | ||
42 | + return 1; | ||
43 | + } | ||
44 | +#ifdef CIOCGSESSINFO | ||
45 | + siop.ses = sess.ses; | ||
46 | + if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
47 | + perror("ioctl(CIOCGSESSION)"); | ||
48 | + return 1; | ||
49 | + } | ||
50 | + alignmask = siop.alignmask; | ||
51 | +#endif | ||
52 | + | ||
53 | + for (i = 256; i <= (64 * 1024); i *= 2) { | ||
54 | + if (encrypt_data(&sess, fdc, i, alignmask)) | ||
55 | + break; | ||
56 | + } | ||
57 | + | ||
58 | +end: | ||
59 | close(fdc); | ||
60 | close(fd); | ||
61 | return 0; | ||
62 | -- | ||
63 | 2.10.2 | ||
64 | |||
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 @@ | |||
1 | From aa329106f586f8d055ceaa919e327ebc99bdd6e3 Mon Sep 17 00:00:00 2001 | ||
2 | From: Alexe Radu <radu.alexe@nxp.com> | ||
3 | Date: Tue, 25 Oct 2016 11:15:37 +0300 | ||
4 | Subject: [PATCH 045/104] add support for crc32c hash async speed test | ||
5 | |||
6 | Signed-off-by: Alexe Radu <radu.alexe@nxp.com> | ||
7 | --- | ||
8 | crypto/cryptodev.h | 1 + | ||
9 | ioctl.c | 4 ++++ | ||
10 | tests/async_speed.c | 25 +++++++++++++++++++++++++ | ||
11 | 3 files changed, 30 insertions(+) | ||
12 | |||
13 | diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h | ||
14 | index 9ade102..05221a4 100644 | ||
15 | --- a/crypto/cryptodev.h | ||
16 | +++ b/crypto/cryptodev.h | ||
17 | @@ -46,6 +46,7 @@ enum cryptodev_crypto_op_t { | ||
18 | CRYPTO_AES_XTS = 22, | ||
19 | CRYPTO_AES_ECB = 23, | ||
20 | CRYPTO_AES_GCM = 50, | ||
21 | + CRYPTO_CRC32C, | ||
22 | |||
23 | CRYPTO_CAMELLIA_CBC = 101, | ||
24 | CRYPTO_RIPEMD160, | ||
25 | diff --git a/ioctl.c b/ioctl.c | ||
26 | index ca3c5ac..2e2bdeb 100644 | ||
27 | --- a/ioctl.c | ||
28 | +++ b/ioctl.c | ||
29 | @@ -286,6 +286,10 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) | ||
30 | hash_name = "sha512"; | ||
31 | hmac_mode = 0; | ||
32 | break; | ||
33 | + case CRYPTO_CRC32C: | ||
34 | + hash_name = "crc32c"; | ||
35 | + hmac_mode = 0; | ||
36 | + break; | ||
37 | default: | ||
38 | ddebug(1, "bad mac: %d", sop->mac); | ||
39 | return -EINVAL; | ||
40 | diff --git a/tests/async_speed.c b/tests/async_speed.c | ||
41 | index 39a3d23..8978b4b 100644 | ||
42 | --- a/tests/async_speed.c | ||
43 | +++ b/tests/async_speed.c | ||
44 | @@ -65,6 +65,7 @@ int encrypt_data(struct session_op *sess, int fdc, int chunksize, int alignmask) | ||
45 | { | ||
46 | struct crypt_op cop; | ||
47 | char *buffer[64], iv[32]; | ||
48 | + char mac[64][HASH_MAX_LEN]; | ||
49 | static int val = 23; | ||
50 | struct timeval start, end; | ||
51 | double total = 0; | ||
52 | @@ -114,6 +115,7 @@ int encrypt_data(struct session_op *sess, int fdc, int chunksize, int alignmask) | ||
53 | cop.iv = (unsigned char *)iv; | ||
54 | cop.op = COP_ENCRYPT; | ||
55 | cop.src = cop.dst = (unsigned char *)buffer[bufidx]; | ||
56 | + cop.mac = mac[bufidx]; | ||
57 | bufidx = (bufidx + 1) % 64; | ||
58 | |||
59 | if (ioctl(fdc, CIOCASYNCCRYPT, &cop)) { | ||
60 | @@ -235,6 +237,29 @@ int main(void) | ||
61 | break; | ||
62 | } | ||
63 | |||
64 | + fprintf(stderr, "\nTesting CRC32C hash: \n"); | ||
65 | + memset(&sess, 0, sizeof(sess)); | ||
66 | + sess.mac = CRYPTO_CRC32C; | ||
67 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
68 | + perror("ioctl(CIOCGSESSION)"); | ||
69 | + return 1; | ||
70 | + } | ||
71 | +#ifdef CIOCGSESSINFO | ||
72 | + siop.ses = sess.ses; | ||
73 | + if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
74 | + perror("ioctl(CIOCGSESSION)"); | ||
75 | + return 1; | ||
76 | + } | ||
77 | + printf("requested hash CRYPTO_CRC32C, got %s with driver %s\n", | ||
78 | + siop.hash_info.cra_name, siop.hash_info.cra_driver_name); | ||
79 | + alignmask = siop.alignmask; | ||
80 | +#endif | ||
81 | + | ||
82 | + for (i = 256; i <= (64 * 1024); i *= 2) { | ||
83 | + if (encrypt_data(&sess, fdc, i, alignmask)) | ||
84 | + break; | ||
85 | + } | ||
86 | + | ||
87 | end: | ||
88 | close(fdc); | ||
89 | close(fd); | ||
90 | -- | ||
91 | 2.10.2 | ||
92 | |||
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 @@ | |||
1 | From c2fed59ef63a1b9da26e8a5452004b07aad39261 Mon Sep 17 00:00:00 2001 | ||
2 | From: Alexe Radu <radu.alexe@nxp.com> | ||
3 | Date: Tue, 25 Oct 2016 11:21:47 +0300 | ||
4 | Subject: [PATCH 046/104] add support for sha1 hash async speed test | ||
5 | |||
6 | Signed-off-by: Alexe Radu <radu.alexe@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed.c | 23 +++++++++++++++++++++++ | ||
9 | 1 file changed, 23 insertions(+) | ||
10 | |||
11 | diff --git a/tests/async_speed.c b/tests/async_speed.c | ||
12 | index 8978b4b..64d5603 100644 | ||
13 | --- a/tests/async_speed.c | ||
14 | +++ b/tests/async_speed.c | ||
15 | @@ -260,6 +260,29 @@ int main(void) | ||
16 | break; | ||
17 | } | ||
18 | |||
19 | + fprintf(stderr, "\nTesting SHA-1 hash: \n"); | ||
20 | + memset(&sess, 0, sizeof(sess)); | ||
21 | + sess.mac = CRYPTO_SHA1; | ||
22 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
23 | + perror("ioctl(CIOCGSESSION)"); | ||
24 | + return 1; | ||
25 | + } | ||
26 | +#ifdef CIOCGSESSINFO | ||
27 | + siop.ses = sess.ses; | ||
28 | + if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
29 | + perror("ioctl(CIOCGSESSION)"); | ||
30 | + return 1; | ||
31 | + } | ||
32 | + printf("requested hash CRYPTO_SHA1, got %s with driver %s\n", | ||
33 | + siop.hash_info.cra_name, siop.hash_info.cra_driver_name); | ||
34 | + alignmask = siop.alignmask; | ||
35 | +#endif | ||
36 | + | ||
37 | + for (i = 256; i <= (64 * 1024); i *= 2) { | ||
38 | + if (encrypt_data(&sess, fdc, i, alignmask)) | ||
39 | + break; | ||
40 | + } | ||
41 | + | ||
42 | end: | ||
43 | close(fdc); | ||
44 | close(fd); | ||
45 | -- | ||
46 | 2.10.2 | ||
47 | |||
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 @@ | |||
1 | From 14c5355aa23f970c7941afa460b2335f8e67445f Mon Sep 17 00:00:00 2001 | ||
2 | From: Alexe Radu <radu.alexe@nxp.com> | ||
3 | Date: Tue, 25 Oct 2016 11:28:09 +0300 | ||
4 | Subject: [PATCH 047/104] add support for sha2-256 hash async speed test | ||
5 | |||
6 | Signed-off-by: Alexe Radu <radu.alexe@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed.c | 23 +++++++++++++++++++++++ | ||
9 | 1 file changed, 23 insertions(+) | ||
10 | |||
11 | diff --git a/tests/async_speed.c b/tests/async_speed.c | ||
12 | index 64d5603..15ab80c 100644 | ||
13 | --- a/tests/async_speed.c | ||
14 | +++ b/tests/async_speed.c | ||
15 | @@ -283,6 +283,29 @@ int main(void) | ||
16 | break; | ||
17 | } | ||
18 | |||
19 | + fprintf(stderr, "\nTesting SHA2-256 hash: \n"); | ||
20 | + memset(&sess, 0, sizeof(sess)); | ||
21 | + sess.mac = CRYPTO_SHA2_256; | ||
22 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
23 | + perror("ioctl(CIOCGSESSION)"); | ||
24 | + return 1; | ||
25 | + } | ||
26 | +#ifdef CIOCGSESSINFO | ||
27 | + siop.ses = sess.ses; | ||
28 | + if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
29 | + perror("ioctl(CIOCGSESSION)"); | ||
30 | + return 1; | ||
31 | + } | ||
32 | + printf("requested hash CRYPTO_SHA2_256, got %s with driver %s\n", | ||
33 | + siop.hash_info.cra_name, siop.hash_info.cra_driver_name); | ||
34 | + alignmask = siop.alignmask; | ||
35 | +#endif | ||
36 | + | ||
37 | + for (i = 256; i <= (64 * 1024); i *= 2) { | ||
38 | + if (encrypt_data(&sess, fdc, i, alignmask)) | ||
39 | + break; | ||
40 | + } | ||
41 | + | ||
42 | end: | ||
43 | close(fdc); | ||
44 | close(fd); | ||
45 | -- | ||
46 | 2.10.2 | ||
47 | |||
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 @@ | |||
1 | From 139268835b7d84472950e3ed866f41d79a0cb723 Mon Sep 17 00:00:00 2001 | ||
2 | From: Alexe Radu <radu.alexe@nxp.com> | ||
3 | Date: Tue, 25 Oct 2016 12:05:13 +0300 | ||
4 | Subject: [PATCH 048/104] add support for aes-256-xts sync speed test | ||
5 | |||
6 | Signed-off-by: Alexe Radu <radu.alexe@nxp.com> | ||
7 | --- | ||
8 | tests/speed.c | 24 ++++++++++++++++++++++++ | ||
9 | 1 file changed, 24 insertions(+) | ||
10 | |||
11 | diff --git a/tests/speed.c b/tests/speed.c | ||
12 | index 81c5a65..16ad7b7 100644 | ||
13 | --- a/tests/speed.c | ||
14 | +++ b/tests/speed.c | ||
15 | @@ -206,6 +206,30 @@ int main(int argc, char** argv) | ||
16 | break; | ||
17 | } | ||
18 | |||
19 | + fprintf(stderr, "\nTesting AES-256-XTS cipher: \n"); | ||
20 | + memset(&sess, 0, sizeof(sess)); | ||
21 | + sess.cipher = CRYPTO_AES_XTS; | ||
22 | + sess.keylen = 32; | ||
23 | + memset(keybuf, 0x42, sess.keylen); | ||
24 | + sess.key = (unsigned char *)keybuf; | ||
25 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
26 | + perror("ioctl(CIOCGSESSION)"); | ||
27 | + return 1; | ||
28 | + } | ||
29 | +#ifdef CIOCGSESSINFO | ||
30 | + siop.ses = sess.ses; | ||
31 | + if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
32 | + perror("ioctl(CIOCGSESSINFO)"); | ||
33 | + return 1; | ||
34 | + } | ||
35 | + alignmask = siop.alignmask; | ||
36 | +#endif | ||
37 | + | ||
38 | + for (i = 512; i <= (64 * 1024); i *= 2) { | ||
39 | + if (encrypt_data(&sess, fdc, i, alignmask)) | ||
40 | + break; | ||
41 | + } | ||
42 | + | ||
43 | close(fdc); | ||
44 | close(fd); | ||
45 | return 0; | ||
46 | -- | ||
47 | 2.10.2 | ||
48 | |||
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 @@ | |||
1 | From af3d42a68f1e356d21e52e72f3f5ebc7cfd90e81 Mon Sep 17 00:00:00 2001 | ||
2 | From: Alexe Radu <radu.alexe@nxp.com> | ||
3 | Date: Tue, 25 Oct 2016 12:13:58 +0300 | ||
4 | Subject: [PATCH 049/104] add support for crc32c hash sync speed test | ||
5 | |||
6 | Signed-off-by: Alexe Radu <radu.alexe@nxp.com> | ||
7 | --- | ||
8 | tests/speed.c | 25 +++++++++++++++++++++++++ | ||
9 | 1 file changed, 25 insertions(+) | ||
10 | |||
11 | diff --git a/tests/speed.c b/tests/speed.c | ||
12 | index 16ad7b7..bd6d2b2 100644 | ||
13 | --- a/tests/speed.c | ||
14 | +++ b/tests/speed.c | ||
15 | @@ -74,6 +74,7 @@ int encrypt_data(struct session_op *sess, int fdc, int chunksize, int alignmask) | ||
16 | { | ||
17 | struct crypt_op cop; | ||
18 | char *buffer, iv[32]; | ||
19 | + char mac[HASH_MAX_LEN]; | ||
20 | static int val = 23; | ||
21 | struct timeval start, end; | ||
22 | double total = 0; | ||
23 | @@ -110,6 +111,7 @@ int encrypt_data(struct session_op *sess, int fdc, int chunksize, int alignmask) | ||
24 | cop.iv = (unsigned char *)iv; | ||
25 | cop.op = COP_ENCRYPT; | ||
26 | cop.src = cop.dst = (unsigned char *)buffer; | ||
27 | + cop.mac = mac; | ||
28 | |||
29 | if (ioctl(fdc, CIOCCRYPT, &cop)) { | ||
30 | perror("ioctl(CIOCCRYPT)"); | ||
31 | @@ -230,6 +232,29 @@ int main(int argc, char** argv) | ||
32 | break; | ||
33 | } | ||
34 | |||
35 | + fprintf(stderr, "\nTesting CRC32C hash: \n"); | ||
36 | + memset(&sess, 0, sizeof(sess)); | ||
37 | + sess.mac = CRYPTO_CRC32C; | ||
38 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
39 | + perror("ioctl(CIOCGSESSION)"); | ||
40 | + return 1; | ||
41 | + } | ||
42 | +#ifdef CIOCGSESSINFO | ||
43 | + siop.ses = sess.ses; | ||
44 | + if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
45 | + perror("ioctl(CIOCGSESSINFO)"); | ||
46 | + return 1; | ||
47 | + } | ||
48 | + printf("requested hash CRYPTO_CRC32C, got %s with driver %s\n", | ||
49 | + siop.hash_info.cra_name, siop.hash_info.cra_driver_name); | ||
50 | + alignmask = siop.alignmask; | ||
51 | +#endif | ||
52 | + | ||
53 | + for (i = 512; i <= (64 * 1024); i *= 2) { | ||
54 | + if (encrypt_data(&sess, fdc, i, alignmask)) | ||
55 | + break; | ||
56 | + } | ||
57 | + | ||
58 | close(fdc); | ||
59 | close(fd); | ||
60 | return 0; | ||
61 | -- | ||
62 | 2.10.2 | ||
63 | |||
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 @@ | |||
1 | From 13cb1f2dcf8865b076a7e8290d8f864d91a2d7c7 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Mon, 24 Oct 2016 16:33:55 +0300 | ||
4 | Subject: [PATCH 050/104] add basic optargs support for async_speed test | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed.c | 302 +++++++++++++++++++++++++++++++++++----------------- | ||
9 | 1 file changed, 202 insertions(+), 100 deletions(-) | ||
10 | |||
11 | diff --git a/tests/async_speed.c b/tests/async_speed.c | ||
12 | index 15ab80c..fff3414 100644 | ||
13 | --- a/tests/async_speed.c | ||
14 | +++ b/tests/async_speed.c | ||
15 | @@ -27,9 +27,45 @@ | ||
16 | #include <sys/types.h> | ||
17 | #include <signal.h> | ||
18 | #include <crypto/cryptodev.h> | ||
19 | +#include <stdbool.h> | ||
20 | +#include <unistd.h> | ||
21 | |||
22 | #ifdef ENABLE_ASYNC | ||
23 | |||
24 | +struct test_params { | ||
25 | + bool tflag; | ||
26 | + bool nflag; | ||
27 | + int tvalue; | ||
28 | + int nvalue; | ||
29 | +}; | ||
30 | + | ||
31 | +const char usage_str[] = "Usage: %s [OPTION]... <cipher>|<hash>\n" | ||
32 | + "Run benchmark test for cipher or hash\n\n" | ||
33 | + " -t <secs>\t" "time to run each test (default 10 secs)\n" | ||
34 | + " -n <bytes>\t" "size of the test buffer\n" | ||
35 | + " -h\t\t" "show this help\n" | ||
36 | +; | ||
37 | + | ||
38 | +int run_null(int fdc, struct test_params tp); | ||
39 | +int run_aes_cbc(int fdc, struct test_params tp); | ||
40 | +int run_aes_xts(int fdc, struct test_params tp); | ||
41 | +int run_crc32c(int fdc, struct test_params tp); | ||
42 | +int run_sha1(int fdc, struct test_params tp); | ||
43 | +int run_sha256(int fdc, struct test_params tp); | ||
44 | + | ||
45 | +#define ALG_COUNT 6 | ||
46 | +struct { | ||
47 | + char *name; | ||
48 | + int (*func)(int, struct test_params); | ||
49 | +} ciphers[ALG_COUNT] = { | ||
50 | + {"null", run_null}, | ||
51 | + {"aes-cbc", run_aes_cbc}, | ||
52 | + {"aes-xts", run_aes_xts}, | ||
53 | + {"crc32c", run_crc32c}, | ||
54 | + {"sha1", run_sha1}, | ||
55 | + {"sha256", run_sha256}, | ||
56 | +}; | ||
57 | + | ||
58 | static double udifftimeval(struct timeval start, struct timeval end) | ||
59 | { | ||
60 | return (double)(end.tv_usec - start.tv_usec) + | ||
61 | @@ -61,7 +97,7 @@ static void value2human(double bytes, double time, double* data, double* speed,c | ||
62 | } | ||
63 | |||
64 | |||
65 | -int encrypt_data(struct session_op *sess, int fdc, int chunksize, int alignmask) | ||
66 | +int encrypt_data(int fdc, struct test_params tp, struct session_op *sess) | ||
67 | { | ||
68 | struct crypt_op cop; | ||
69 | char *buffer[64], iv[32]; | ||
70 | @@ -72,31 +108,33 @@ int encrypt_data(struct session_op *sess, int fdc, int chunksize, int alignmask) | ||
71 | double secs, ddata, dspeed; | ||
72 | char metric[16]; | ||
73 | int rc, wqueue = 0, bufidx = 0; | ||
74 | + int alignmask; | ||
75 | |||
76 | memset(iv, 0x23, 32); | ||
77 | |||
78 | - printf("\tEncrypting in chunks of %d bytes: ", chunksize); | ||
79 | + printf("\tEncrypting in chunks of %d bytes: ", tp.nvalue); | ||
80 | fflush(stdout); | ||
81 | |||
82 | + alignmask = get_alignmask(fdc, sess); | ||
83 | for (rc = 0; rc < 64; rc++) { | ||
84 | if (alignmask) { | ||
85 | - if (posix_memalign((void **)(buffer + rc), alignmask + 1, chunksize)) { | ||
86 | + if (posix_memalign((void **)(buffer + rc), alignmask + 1, tp.nvalue)) { | ||
87 | printf("posix_memalign() failed!\n"); | ||
88 | return 1; | ||
89 | } | ||
90 | } else { | ||
91 | - if (!(buffer[rc] = malloc(chunksize))) { | ||
92 | + if (!(buffer[rc] = malloc(tp.nvalue))) { | ||
93 | perror("malloc()"); | ||
94 | return 1; | ||
95 | } | ||
96 | } | ||
97 | - memset(buffer[rc], val++, chunksize); | ||
98 | + memset(buffer[rc], val++, tp.nvalue); | ||
99 | } | ||
100 | pfd.fd = fdc; | ||
101 | pfd.events = POLLOUT | POLLIN; | ||
102 | |||
103 | must_finish = 0; | ||
104 | - alarm(5); | ||
105 | + alarm(tp.tvalue); | ||
106 | |||
107 | gettimeofday(&start, NULL); | ||
108 | do { | ||
109 | @@ -111,7 +149,7 @@ int encrypt_data(struct session_op *sess, int fdc, int chunksize, int alignmask) | ||
110 | if (pfd.revents & POLLOUT) { | ||
111 | memset(&cop, 0, sizeof(cop)); | ||
112 | cop.ses = sess->ses; | ||
113 | - cop.len = chunksize; | ||
114 | + cop.len = tp.nvalue; | ||
115 | cop.iv = (unsigned char *)iv; | ||
116 | cop.op = COP_ENCRYPT; | ||
117 | cop.src = cop.dst = (unsigned char *)buffer[bufidx]; | ||
118 | @@ -146,25 +184,75 @@ int encrypt_data(struct session_op *sess, int fdc, int chunksize, int alignmask) | ||
119 | return 0; | ||
120 | } | ||
121 | |||
122 | -int main(void) | ||
123 | +void usage(char *cmd_name) | ||
124 | { | ||
125 | - int fd, i, fdc = -1, alignmask = 0; | ||
126 | - struct session_op sess; | ||
127 | -#ifdef CIOCGSESSINFO | ||
128 | - struct session_info_op siop; | ||
129 | -#endif | ||
130 | - char keybuf[32]; | ||
131 | + printf(usage_str, cmd_name); | ||
132 | +} | ||
133 | |||
134 | - signal(SIGALRM, alarm_handler); | ||
135 | +int run_test(int id, struct test_params tp) | ||
136 | +{ | ||
137 | + int fd; | ||
138 | + int fdc; | ||
139 | |||
140 | - if ((fd = open("/dev/crypto", O_RDWR, 0)) < 0) { | ||
141 | + fd = open("/dev/crypto", O_RDWR, 0); | ||
142 | + if (fd < 0) { | ||
143 | perror("open()"); | ||
144 | - return 1; | ||
145 | + return fd; | ||
146 | } | ||
147 | if (ioctl(fd, CRIOGET, &fdc)) { | ||
148 | perror("ioctl(CRIOGET)"); | ||
149 | - return 1; | ||
150 | + return -EINVAL; | ||
151 | + } | ||
152 | + | ||
153 | + ciphers[id].func(fdc, tp); | ||
154 | + | ||
155 | + close(fdc); | ||
156 | + close(fd); | ||
157 | +} | ||
158 | + | ||
159 | +int get_alignmask(int fdc, struct session_op *sess) | ||
160 | +{ | ||
161 | + int alignmask; | ||
162 | + | ||
163 | +#ifdef CIOCGSESSINFO | ||
164 | + struct session_info_op siop; | ||
165 | + | ||
166 | + siop.ses = sess->ses; | ||
167 | + if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
168 | + perror("ioctl(CIOCGSESSINFO)"); | ||
169 | + return -EINVAL; | ||
170 | + } | ||
171 | + alignmask = siop.alignmask; | ||
172 | +#else | ||
173 | + alignmask = 0; | ||
174 | +#endif | ||
175 | + | ||
176 | + return alignmask; | ||
177 | +} | ||
178 | + | ||
179 | +void do_test_vectors(int fdc, struct test_params tp, struct session_op *sess) | ||
180 | +{ | ||
181 | + int i; | ||
182 | + | ||
183 | + if (tp.nflag) { | ||
184 | + encrypt_data(fdc, tp, sess); | ||
185 | + } else { | ||
186 | + for (i = 256; i <= (64 * 1024); i *= 2) { | ||
187 | + tp.nvalue = i; | ||
188 | + if (encrypt_data(fdc, tp, sess)) { | ||
189 | + break; | ||
190 | + } | ||
191 | + } | ||
192 | } | ||
193 | +} | ||
194 | + | ||
195 | + | ||
196 | +int run_null(int fdc, struct test_params tp) | ||
197 | +{ | ||
198 | + struct session_op sess; | ||
199 | + char keybuf[32]; | ||
200 | + int alignmask; | ||
201 | + int i; | ||
202 | |||
203 | fprintf(stderr, "Testing NULL cipher: \n"); | ||
204 | memset(&sess, 0, sizeof(sess)); | ||
205 | @@ -173,21 +261,19 @@ int main(void) | ||
206 | sess.key = (unsigned char *)keybuf; | ||
207 | if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
208 | perror("ioctl(CIOCGSESSION)"); | ||
209 | - return 1; | ||
210 | - } | ||
211 | -#ifdef CIOCGSESSINFO | ||
212 | - siop.ses = sess.ses; | ||
213 | - if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
214 | - perror("ioctl(CIOCGSESSINFO)"); | ||
215 | - return 1; | ||
216 | + return -EINVAL; | ||
217 | } | ||
218 | - alignmask = siop.alignmask; | ||
219 | -#endif | ||
220 | |||
221 | - for (i = 256; i <= (64 * 4096); i *= 2) { | ||
222 | - if (encrypt_data(&sess, fdc, i, alignmask)) | ||
223 | - break; | ||
224 | - } | ||
225 | + do_test_vectors(fdc, tp, &sess); | ||
226 | + return 0; | ||
227 | +} | ||
228 | + | ||
229 | +int run_aes_cbc(int fdc, struct test_params tp) | ||
230 | +{ | ||
231 | + struct session_op sess; | ||
232 | + char keybuf[32]; | ||
233 | + int alignmask; | ||
234 | + int i; | ||
235 | |||
236 | fprintf(stderr, "\nTesting AES-128-CBC cipher: \n"); | ||
237 | memset(&sess, 0, sizeof(sess)); | ||
238 | @@ -197,21 +283,17 @@ int main(void) | ||
239 | sess.key = (unsigned char *)keybuf; | ||
240 | if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
241 | perror("ioctl(CIOCGSESSION)"); | ||
242 | - return 1; | ||
243 | - } | ||
244 | -#ifdef CIOCGSESSINFO | ||
245 | - siop.ses = sess.ses; | ||
246 | - if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
247 | - perror("ioctl(CIOCGSESSINFO)"); | ||
248 | - return 1; | ||
249 | + return -EINVAL; | ||
250 | } | ||
251 | - alignmask = siop.alignmask; | ||
252 | -#endif | ||
253 | |||
254 | - for (i = 256; i <= (64 * 1024); i *= 2) { | ||
255 | - if (encrypt_data(&sess, fdc, i, alignmask)) | ||
256 | - break; | ||
257 | - } | ||
258 | + do_test_vectors(fdc, tp, &sess); | ||
259 | + return 0; | ||
260 | +} | ||
261 | + | ||
262 | +int run_aes_xts(int fdc, struct test_params tp) | ||
263 | +{ | ||
264 | + struct session_op sess; | ||
265 | + char keybuf[32]; | ||
266 | |||
267 | fprintf(stderr, "\nTesting AES-256-XTS cipher: \n"); | ||
268 | memset(&sess, 0, sizeof(sess)); | ||
269 | @@ -221,21 +303,16 @@ int main(void) | ||
270 | sess.key = (unsigned char *)keybuf; | ||
271 | if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
272 | perror("ioctl(CIOCGSESSION)"); | ||
273 | - return 1; | ||
274 | + return -EINVAL; | ||
275 | } | ||
276 | -#ifdef CIOCGSESSINFO | ||
277 | - siop.ses = sess.ses; | ||
278 | - if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
279 | - perror("ioctl(CIOCGSESSION)"); | ||
280 | - return 1; | ||
281 | - } | ||
282 | - alignmask = siop.alignmask; | ||
283 | -#endif | ||
284 | |||
285 | - for (i = 256; i <= (64 * 1024); i *= 2) { | ||
286 | - if (encrypt_data(&sess, fdc, i, alignmask)) | ||
287 | - break; | ||
288 | - } | ||
289 | + do_test_vectors(fdc, tp, &sess); | ||
290 | + return 0; | ||
291 | +} | ||
292 | + | ||
293 | +int run_crc32c(int fdc, struct test_params tp) | ||
294 | +{ | ||
295 | + struct session_op sess; | ||
296 | |||
297 | fprintf(stderr, "\nTesting CRC32C hash: \n"); | ||
298 | memset(&sess, 0, sizeof(sess)); | ||
299 | @@ -244,21 +321,14 @@ int main(void) | ||
300 | perror("ioctl(CIOCGSESSION)"); | ||
301 | return 1; | ||
302 | } | ||
303 | -#ifdef CIOCGSESSINFO | ||
304 | - siop.ses = sess.ses; | ||
305 | - if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
306 | - perror("ioctl(CIOCGSESSION)"); | ||
307 | - return 1; | ||
308 | - } | ||
309 | - printf("requested hash CRYPTO_CRC32C, got %s with driver %s\n", | ||
310 | - siop.hash_info.cra_name, siop.hash_info.cra_driver_name); | ||
311 | - alignmask = siop.alignmask; | ||
312 | -#endif | ||
313 | |||
314 | - for (i = 256; i <= (64 * 1024); i *= 2) { | ||
315 | - if (encrypt_data(&sess, fdc, i, alignmask)) | ||
316 | - break; | ||
317 | - } | ||
318 | + do_test_vectors(fdc, tp, &sess); | ||
319 | + return 0; | ||
320 | +} | ||
321 | + | ||
322 | +int run_sha1(int fdc, struct test_params tp) | ||
323 | +{ | ||
324 | + struct session_op sess; | ||
325 | |||
326 | fprintf(stderr, "\nTesting SHA-1 hash: \n"); | ||
327 | memset(&sess, 0, sizeof(sess)); | ||
328 | @@ -267,21 +337,14 @@ int main(void) | ||
329 | perror("ioctl(CIOCGSESSION)"); | ||
330 | return 1; | ||
331 | } | ||
332 | -#ifdef CIOCGSESSINFO | ||
333 | - siop.ses = sess.ses; | ||
334 | - if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
335 | - perror("ioctl(CIOCGSESSION)"); | ||
336 | - return 1; | ||
337 | - } | ||
338 | - printf("requested hash CRYPTO_SHA1, got %s with driver %s\n", | ||
339 | - siop.hash_info.cra_name, siop.hash_info.cra_driver_name); | ||
340 | - alignmask = siop.alignmask; | ||
341 | -#endif | ||
342 | |||
343 | - for (i = 256; i <= (64 * 1024); i *= 2) { | ||
344 | - if (encrypt_data(&sess, fdc, i, alignmask)) | ||
345 | - break; | ||
346 | - } | ||
347 | + do_test_vectors(fdc, tp, &sess); | ||
348 | + return 0; | ||
349 | +} | ||
350 | + | ||
351 | +int run_sha256(int fdc, struct test_params tp) | ||
352 | +{ | ||
353 | + struct session_op sess; | ||
354 | |||
355 | fprintf(stderr, "\nTesting SHA2-256 hash: \n"); | ||
356 | memset(&sess, 0, sizeof(sess)); | ||
357 | @@ -290,25 +353,64 @@ int main(void) | ||
358 | perror("ioctl(CIOCGSESSION)"); | ||
359 | return 1; | ||
360 | } | ||
361 | -#ifdef CIOCGSESSINFO | ||
362 | - siop.ses = sess.ses; | ||
363 | - if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
364 | - perror("ioctl(CIOCGSESSION)"); | ||
365 | - return 1; | ||
366 | - } | ||
367 | - printf("requested hash CRYPTO_SHA2_256, got %s with driver %s\n", | ||
368 | - siop.hash_info.cra_name, siop.hash_info.cra_driver_name); | ||
369 | - alignmask = siop.alignmask; | ||
370 | -#endif | ||
371 | |||
372 | - for (i = 256; i <= (64 * 1024); i *= 2) { | ||
373 | - if (encrypt_data(&sess, fdc, i, alignmask)) | ||
374 | + do_test_vectors(fdc, tp, &sess); | ||
375 | + return 0; | ||
376 | +} | ||
377 | + | ||
378 | +int main(int argc, char **argv) | ||
379 | +{ | ||
380 | + int i; | ||
381 | + int c; | ||
382 | + int index; | ||
383 | + bool alg_flag; | ||
384 | + char *alg_name; | ||
385 | + struct test_params tp; | ||
386 | + | ||
387 | + tp.tflag = false; | ||
388 | + tp.nflag = false; | ||
389 | + alg_flag = false; | ||
390 | + opterr = 0; | ||
391 | + while ((c = getopt(argc, argv, "hn:t:")) != -1) { | ||
392 | + switch (c) { | ||
393 | + case 'n': | ||
394 | + tp.nvalue = atoi(optarg); | ||
395 | + tp.nflag = true; | ||
396 | + break; | ||
397 | + case 't': | ||
398 | + tp.tvalue = atoi(optarg); | ||
399 | + tp.tflag = true; | ||
400 | break; | ||
401 | + case 'h': /* no break */ | ||
402 | + default: | ||
403 | + usage(argv[0]); | ||
404 | + exit(1); | ||
405 | + } | ||
406 | + } | ||
407 | + | ||
408 | + /* the name of a specific test asked on the command line */ | ||
409 | + if (optind < argc) { | ||
410 | + alg_name = argv[optind]; | ||
411 | + alg_flag = true; | ||
412 | + } | ||
413 | + | ||
414 | + /* default test time */ | ||
415 | + if (!tp.tflag) { | ||
416 | + tp.tvalue = 5; | ||
417 | + } | ||
418 | + | ||
419 | + signal(SIGALRM, alarm_handler); | ||
420 | + | ||
421 | + for (i = 0; i < ALG_COUNT; i++) { | ||
422 | + if (alg_flag) { | ||
423 | + if (strcmp(alg_name, ciphers[i].name) == 0) { | ||
424 | + run_test(i, tp); | ||
425 | + } | ||
426 | + } else { | ||
427 | + run_test(i, tp); | ||
428 | + } | ||
429 | } | ||
430 | |||
431 | -end: | ||
432 | - close(fdc); | ||
433 | - close(fd); | ||
434 | return 0; | ||
435 | } | ||
436 | |||
437 | -- | ||
438 | 2.10.2 | ||
439 | |||
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 @@ | |||
1 | From 6b31215e77b89fd7bd4dcfb6e4e3a9ee53e7731d Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Tue, 25 Oct 2016 15:03:19 +0300 | ||
4 | Subject: [PATCH 051/104] enable async code by default | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | Makefile | 2 +- | ||
9 | tests/Makefile | 1 + | ||
10 | 2 files changed, 2 insertions(+), 1 deletion(-) | ||
11 | |||
12 | diff --git a/Makefile b/Makefile | ||
13 | index 9871a8e..3934e1f 100644 | ||
14 | --- a/Makefile | ||
15 | +++ b/Makefile | ||
16 | @@ -3,7 +3,7 @@ | ||
17 | # disabled by default. To re-enable it uncomment the | ||
18 | # corresponding CFLAG. | ||
19 | # | ||
20 | -CRYPTODEV_CFLAGS ?= #-DENABLE_ASYNC | ||
21 | +CRYPTODEV_CFLAGS += -DENABLE_ASYNC | ||
22 | KBUILD_CFLAGS += -I$(src) $(CRYPTODEV_CFLAGS) | ||
23 | KERNEL_DIR ?= /lib/modules/$(shell uname -r)/build | ||
24 | VERSION = 1.8 | ||
25 | diff --git a/tests/Makefile b/tests/Makefile | ||
26 | index 5e3111d..683f40b 100644 | ||
27 | --- a/tests/Makefile | ||
28 | +++ b/tests/Makefile | ||
29 | @@ -1,4 +1,5 @@ | ||
30 | KERNEL_DIR ?= /lib/modules/$(shell uname -r)/build | ||
31 | +CRYPTODEV_CFLAGS += -DENABLE_ASYNC | ||
32 | KBUILD_CFLAGS += -I.. $(CRYPTODEV_CFLAGS) | ||
33 | CFLAGS += -I.. $(CRYPTODEV_CFLAGS) | ||
34 | |||
35 | -- | ||
36 | 2.10.2 | ||
37 | |||
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 @@ | |||
1 | From 6d2e0927c2ed2795267d7652d9413d7e01da202e Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Tue, 25 Oct 2016 16:54:06 +0300 | ||
4 | Subject: [PATCH 052/104] add flag to report in a machine friendly format | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed.c | 8 +++++++- | ||
9 | 1 file changed, 7 insertions(+), 1 deletion(-) | ||
10 | |||
11 | diff --git a/tests/async_speed.c b/tests/async_speed.c | ||
12 | index fff3414..1941750 100644 | ||
13 | --- a/tests/async_speed.c | ||
14 | +++ b/tests/async_speed.c | ||
15 | @@ -35,6 +35,7 @@ | ||
16 | struct test_params { | ||
17 | bool tflag; | ||
18 | bool nflag; | ||
19 | + bool mflag; | ||
20 | int tvalue; | ||
21 | int nvalue; | ||
22 | }; | ||
23 | @@ -43,6 +44,7 @@ const char usage_str[] = "Usage: %s [OPTION]... <cipher>|<hash>\n" | ||
24 | "Run benchmark test for cipher or hash\n\n" | ||
25 | " -t <secs>\t" "time to run each test (default 10 secs)\n" | ||
26 | " -n <bytes>\t" "size of the test buffer\n" | ||
27 | + " -m\t\t" "output in a machine readable format\n" | ||
28 | " -h\t\t" "show this help\n" | ||
29 | ; | ||
30 | |||
31 | @@ -369,9 +371,10 @@ int main(int argc, char **argv) | ||
32 | |||
33 | tp.tflag = false; | ||
34 | tp.nflag = false; | ||
35 | + tp.mflag = false; | ||
36 | alg_flag = false; | ||
37 | opterr = 0; | ||
38 | - while ((c = getopt(argc, argv, "hn:t:")) != -1) { | ||
39 | + while ((c = getopt(argc, argv, "hn:t:m")) != -1) { | ||
40 | switch (c) { | ||
41 | case 'n': | ||
42 | tp.nvalue = atoi(optarg); | ||
43 | @@ -381,6 +384,9 @@ int main(int argc, char **argv) | ||
44 | tp.tvalue = atoi(optarg); | ||
45 | tp.tflag = true; | ||
46 | break; | ||
47 | + case 'm': | ||
48 | + tp.mflag = true; | ||
49 | + break; | ||
50 | case 'h': /* no break */ | ||
51 | default: | ||
52 | usage(argv[0]); | ||
53 | -- | ||
54 | 2.10.2 | ||
55 | |||
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 @@ | |||
1 | From 9aae91f24b42a9a812cd0518c0c4ef3f548d64d1 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Tue, 25 Oct 2016 17:02:29 +0300 | ||
4 | Subject: [PATCH 053/104] honor the -m flag in async_speed | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed.c | 36 ++++++++++++++++++++++++------------ | ||
9 | 1 file changed, 24 insertions(+), 12 deletions(-) | ||
10 | |||
11 | diff --git a/tests/async_speed.c b/tests/async_speed.c | ||
12 | index 1941750..73ec9d2 100644 | ||
13 | --- a/tests/async_speed.c | ||
14 | +++ b/tests/async_speed.c | ||
15 | @@ -29,6 +29,8 @@ | ||
16 | #include <crypto/cryptodev.h> | ||
17 | #include <stdbool.h> | ||
18 | #include <unistd.h> | ||
19 | +#include <stdint.h> | ||
20 | +#include <inttypes.h> | ||
21 | |||
22 | #ifdef ENABLE_ASYNC | ||
23 | |||
24 | @@ -85,7 +87,7 @@ static void alarm_handler(int signo) | ||
25 | |||
26 | static char *units[] = { "", "Ki", "Mi", "Gi", "Ti", 0}; | ||
27 | |||
28 | -static void value2human(double bytes, double time, double* data, double* speed,char* metric) | ||
29 | +static void value2human(uint64_t bytes, double time, double* data, double* speed,char* metric) | ||
30 | { | ||
31 | int unit = 0; | ||
32 | |||
33 | @@ -98,6 +100,11 @@ static void value2human(double bytes, double time, double* data, double* speed,c | ||
34 | sprintf(metric, "%sB", units[unit]); | ||
35 | } | ||
36 | |||
37 | +static void value2machine(uint64_t bytes, double time, double* speed) | ||
38 | +{ | ||
39 | + *speed = bytes / time; | ||
40 | +} | ||
41 | + | ||
42 | |||
43 | int encrypt_data(int fdc, struct test_params tp, struct session_op *sess) | ||
44 | { | ||
45 | @@ -106,7 +113,7 @@ int encrypt_data(int fdc, struct test_params tp, struct session_op *sess) | ||
46 | char mac[64][HASH_MAX_LEN]; | ||
47 | static int val = 23; | ||
48 | struct timeval start, end; | ||
49 | - double total = 0; | ||
50 | + uint64_t total = 0; | ||
51 | double secs, ddata, dspeed; | ||
52 | char metric[16]; | ||
53 | int rc, wqueue = 0, bufidx = 0; | ||
54 | @@ -114,8 +121,10 @@ int encrypt_data(int fdc, struct test_params tp, struct session_op *sess) | ||
55 | |||
56 | memset(iv, 0x23, 32); | ||
57 | |||
58 | - printf("\tEncrypting in chunks of %d bytes: ", tp.nvalue); | ||
59 | - fflush(stdout); | ||
60 | + if (!tp.mflag) { | ||
61 | + printf("\tBuffer size %d bytes: ", tp.nvalue); | ||
62 | + fflush(stdout); | ||
63 | + } | ||
64 | |||
65 | alignmask = get_alignmask(fdc, sess); | ||
66 | for (rc = 0; rc < 64; rc++) { | ||
67 | @@ -177,9 +186,14 @@ int encrypt_data(int fdc, struct test_params tp, struct session_op *sess) | ||
68 | |||
69 | secs = udifftimeval(start, end)/ 1000000.0; | ||
70 | |||
71 | - value2human(total, secs, &ddata, &dspeed, metric); | ||
72 | - printf ("done. %.2f %s in %.2f secs: ", ddata, metric, secs); | ||
73 | - printf ("%.2f %s/sec\n", dspeed, metric); | ||
74 | + if (tp.mflag) { | ||
75 | + value2machine(total, secs, &dspeed); | ||
76 | + printf("%" PRIu64 "\t%.2f\t%.2f\n", total, secs, dspeed); | ||
77 | + } else { | ||
78 | + value2human(total, secs, &ddata, &dspeed, metric); | ||
79 | + printf ("done. %.2f %s in %.2f secs: ", ddata, metric, secs); | ||
80 | + printf ("%.2f %s/sec\n", dspeed, metric); | ||
81 | + } | ||
82 | |||
83 | for (rc = 0; rc < 64; rc++) | ||
84 | free(buffer[rc]); | ||
85 | @@ -206,6 +220,9 @@ int run_test(int id, struct test_params tp) | ||
86 | return -EINVAL; | ||
87 | } | ||
88 | |||
89 | + if (!tp.mflag) { | ||
90 | + fprintf(stderr, "Testing %s:\n", ciphers[id].name); | ||
91 | + } | ||
92 | ciphers[id].func(fdc, tp); | ||
93 | |||
94 | close(fdc); | ||
95 | @@ -277,7 +294,6 @@ int run_aes_cbc(int fdc, struct test_params tp) | ||
96 | int alignmask; | ||
97 | int i; | ||
98 | |||
99 | - fprintf(stderr, "\nTesting AES-128-CBC cipher: \n"); | ||
100 | memset(&sess, 0, sizeof(sess)); | ||
101 | sess.cipher = CRYPTO_AES_CBC; | ||
102 | sess.keylen = 16; | ||
103 | @@ -297,7 +313,6 @@ int run_aes_xts(int fdc, struct test_params tp) | ||
104 | struct session_op sess; | ||
105 | char keybuf[32]; | ||
106 | |||
107 | - fprintf(stderr, "\nTesting AES-256-XTS cipher: \n"); | ||
108 | memset(&sess, 0, sizeof(sess)); | ||
109 | sess.cipher = CRYPTO_AES_XTS; | ||
110 | sess.keylen = 32; | ||
111 | @@ -316,7 +331,6 @@ int run_crc32c(int fdc, struct test_params tp) | ||
112 | { | ||
113 | struct session_op sess; | ||
114 | |||
115 | - fprintf(stderr, "\nTesting CRC32C hash: \n"); | ||
116 | memset(&sess, 0, sizeof(sess)); | ||
117 | sess.mac = CRYPTO_CRC32C; | ||
118 | if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
119 | @@ -332,7 +346,6 @@ int run_sha1(int fdc, struct test_params tp) | ||
120 | { | ||
121 | struct session_op sess; | ||
122 | |||
123 | - fprintf(stderr, "\nTesting SHA-1 hash: \n"); | ||
124 | memset(&sess, 0, sizeof(sess)); | ||
125 | sess.mac = CRYPTO_SHA1; | ||
126 | if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
127 | @@ -348,7 +361,6 @@ int run_sha256(int fdc, struct test_params tp) | ||
128 | { | ||
129 | struct session_op sess; | ||
130 | |||
131 | - fprintf(stderr, "\nTesting SHA2-256 hash: \n"); | ||
132 | memset(&sess, 0, sizeof(sess)); | ||
133 | sess.mac = CRYPTO_SHA2_256; | ||
134 | if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
135 | -- | ||
136 | 2.10.2 | ||
137 | |||
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 @@ | |||
1 | From f71ba99a8943767c39df5104e86054c9c0e76fd8 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Tue, 25 Oct 2016 17:31:40 +0300 | ||
4 | Subject: [PATCH 054/104] rename algorithm names for clarity | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed.c | 12 ++++++------ | ||
9 | 1 file changed, 6 insertions(+), 6 deletions(-) | ||
10 | |||
11 | diff --git a/tests/async_speed.c b/tests/async_speed.c | ||
12 | index 73ec9d2..263ead7 100644 | ||
13 | --- a/tests/async_speed.c | ||
14 | +++ b/tests/async_speed.c | ||
15 | @@ -51,8 +51,8 @@ const char usage_str[] = "Usage: %s [OPTION]... <cipher>|<hash>\n" | ||
16 | ; | ||
17 | |||
18 | int run_null(int fdc, struct test_params tp); | ||
19 | -int run_aes_cbc(int fdc, struct test_params tp); | ||
20 | -int run_aes_xts(int fdc, struct test_params tp); | ||
21 | +int run_aes_128_cbc(int fdc, struct test_params tp); | ||
22 | +int run_aes_256_xts(int fdc, struct test_params tp); | ||
23 | int run_crc32c(int fdc, struct test_params tp); | ||
24 | int run_sha1(int fdc, struct test_params tp); | ||
25 | int run_sha256(int fdc, struct test_params tp); | ||
26 | @@ -63,8 +63,8 @@ struct { | ||
27 | int (*func)(int, struct test_params); | ||
28 | } ciphers[ALG_COUNT] = { | ||
29 | {"null", run_null}, | ||
30 | - {"aes-cbc", run_aes_cbc}, | ||
31 | - {"aes-xts", run_aes_xts}, | ||
32 | + {"aes-128-cbc", run_aes_128_cbc}, | ||
33 | + {"aes-256-xts", run_aes_256_xts}, | ||
34 | {"crc32c", run_crc32c}, | ||
35 | {"sha1", run_sha1}, | ||
36 | {"sha256", run_sha256}, | ||
37 | @@ -287,7 +287,7 @@ int run_null(int fdc, struct test_params tp) | ||
38 | return 0; | ||
39 | } | ||
40 | |||
41 | -int run_aes_cbc(int fdc, struct test_params tp) | ||
42 | +int run_aes_128_cbc(int fdc, struct test_params tp) | ||
43 | { | ||
44 | struct session_op sess; | ||
45 | char keybuf[32]; | ||
46 | @@ -308,7 +308,7 @@ int run_aes_cbc(int fdc, struct test_params tp) | ||
47 | return 0; | ||
48 | } | ||
49 | |||
50 | -int run_aes_xts(int fdc, struct test_params tp) | ||
51 | +int run_aes_256_xts(int fdc, struct test_params tp) | ||
52 | { | ||
53 | struct session_op sess; | ||
54 | char keybuf[32]; | ||
55 | -- | ||
56 | 2.10.2 | ||
57 | |||
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 @@ | |||
1 | From 789d3c5ecda60a6dc5d5b3597047ad65c412f10d Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Tue, 25 Oct 2016 15:30:59 +0300 | ||
4 | Subject: [PATCH 055/104] add multithreaded wrapper for async speed test | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/Makefile | 1 + | ||
9 | tests/async_speed_multi.sh | 140 +++++++++++++++++++++++++++++++++++++++++++++ | ||
10 | 2 files changed, 141 insertions(+) | ||
11 | create mode 100755 tests/async_speed_multi.sh | ||
12 | |||
13 | diff --git a/tests/Makefile b/tests/Makefile | ||
14 | index 683f40b..6424c11 100644 | ||
15 | --- a/tests/Makefile | ||
16 | +++ b/tests/Makefile | ||
17 | @@ -40,6 +40,7 @@ install: | ||
18 | for prog in $(hostprogs); do \ | ||
19 | install -m 755 $$prog $(DESTDIR)/$(bindir)/tests_cryptodev/; \ | ||
20 | done | ||
21 | + install -m 755 async_speed_multi.sh $(DESTDIR)/$(bindir) | ||
22 | |||
23 | clean: | ||
24 | rm -f *.o *~ $(hostprogs) | ||
25 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
26 | new file mode 100755 | ||
27 | index 0000000..761c0cb | ||
28 | --- /dev/null | ||
29 | +++ b/tests/async_speed_multi.sh | ||
30 | @@ -0,0 +1,140 @@ | ||
31 | +#!/bin/bash | ||
32 | +# | ||
33 | +# Copyright 2016 NXP Semiconductors | ||
34 | +# | ||
35 | +# This program is free software: you can redistribute it and/or modify | ||
36 | +# it under the terms of the GNU General Public License as published by | ||
37 | +# the Free Software Foundation, either version 2 of the License, or | ||
38 | +# (at your option) any later version. | ||
39 | +# | ||
40 | +# This program is distributed in the hope that it will be useful, | ||
41 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
42 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
43 | +# GNU General Public License for more details. | ||
44 | +# | ||
45 | +# You should have received a copy of the GNU General Public License | ||
46 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
47 | + | ||
48 | + | ||
49 | + | ||
50 | +# no user-configurable options below this line | ||
51 | + | ||
52 | +NUM_CORES=`nproc` | ||
53 | +OUT_BASENAME="async_speed" | ||
54 | +MPSTAT="mpstat" | ||
55 | +MPSTAT_OUT="mpstat_out" | ||
56 | + | ||
57 | +function usage | ||
58 | +{ | ||
59 | +cat << EOF | ||
60 | +Usage: `basename $0` [OPTIONS] <alg_name> | ||
61 | + | ||
62 | + -m <threads> number of threads to run with (defaults to number of cores) | ||
63 | + -t <secs> time to run each test (default 10 secs) | ||
64 | + -n <bytes> size of the test buffer (default 256 bytes) | ||
65 | + -h show this help | ||
66 | + | ||
67 | +alg_name: null, aes-128-cbc, aes-256-xts, sha1, sha256, crc32c | ||
68 | +EOF | ||
69 | +} | ||
70 | + | ||
71 | +function SUM { | ||
72 | + paste -sd+ - | bc -l | ||
73 | +} | ||
74 | + | ||
75 | +function get_cpu_idle | ||
76 | +{ | ||
77 | + header_line=`grep %idle ${MPSTAT_OUT} | head -n 1 | sed 's/\s\+/ /g'` | ||
78 | + idle_column=`echo $header_line | wc -w` | ||
79 | + | ||
80 | + all_cpu_idle=`grep all ${MPSTAT_OUT} | tail -n +2 | sed 's/\s\+/ /g' | cut -d' ' -f ${idle_column} | SUM` | ||
81 | + mpstat_lines=`grep all ${MPSTAT_OUT} | tail -n +2 | wc -l` | ||
82 | + | ||
83 | + average_idle=`echo "scale=2; $all_cpu_idle / $mpstat_lines" | bc -l` | ||
84 | + echo $average_idle | ||
85 | +} | ||
86 | + | ||
87 | +function run_parallel | ||
88 | +{ | ||
89 | + trap control_c SIGINT | ||
90 | + | ||
91 | + OPTIONS="-t $tvalue -n $nvalue -m" | ||
92 | + CMD="async_speed $OPTIONS $alg_name" | ||
93 | + | ||
94 | + echo "Running $mvalue threads in parallel:" | ||
95 | + echo " $CMD" | ||
96 | + | ||
97 | + $MPSTAT 1 $(($tvalue-1)) &> $MPSTAT_OUT & | ||
98 | + MPSTAT_PID=$! | ||
99 | + | ||
100 | + PIDS="" | ||
101 | + start=`date +%s.%N` | ||
102 | + | ||
103 | + for i in `seq 0 $(($mvalue-1))` | ||
104 | + do | ||
105 | + CMD_OUT="${OUT_BASENAME}_${i}" | ||
106 | + | ||
107 | + $CMD &> $CMD_OUT & | ||
108 | + PID=$! | ||
109 | + AFFINITY=$(($i % $NUM_CORES)) | ||
110 | + taskset -pc $AFFINITY $PID > /dev/null | ||
111 | + | ||
112 | + PIDS="$PID $PIDS" | ||
113 | + done | ||
114 | + | ||
115 | + wait $PIDS | ||
116 | + end=`date +%s.%N` | ||
117 | + | ||
118 | + wait $MPSTAT_PID | ||
119 | + | ||
120 | + runtime=$(echo "scale=2; $end - $start" | bc -l ) | ||
121 | + total_data=`cat ${OUT_BASENAME}_* | cut -f 1 | SUM` | ||
122 | + avg_speed=$(echo "scale=2; $total_data / $runtime / 1000000000" | bc -l) | ||
123 | + cpu_idle=`get_cpu_idle` | ||
124 | + | ||
125 | + echo | ||
126 | + echo "buffer size : $nvalue" | ||
127 | + echo "running time : $runtime" | ||
128 | + echo "avg_speed : $avg_speed GiB/s" | ||
129 | + echo "all_cpu idle : $cpu_idle %" | ||
130 | + echo | ||
131 | +} | ||
132 | + | ||
133 | +function control_c | ||
134 | +{ | ||
135 | + killall async_speed > /dev/null | ||
136 | + killall mpstat > /dev/null | ||
137 | +} | ||
138 | + | ||
139 | +function main | ||
140 | +{ | ||
141 | + while getopts hm:t:n: option | ||
142 | + do | ||
143 | + case "$option" in | ||
144 | + m) mvalue="$OPTARG";; | ||
145 | + t) tvalue="$OPTARG";; | ||
146 | + n) nvalue="$OPTARG";; | ||
147 | + *) usage $0; exit 1;; | ||
148 | + esac | ||
149 | + done | ||
150 | + | ||
151 | + shift $((OPTIND-1)) | ||
152 | + alg_name=$1 | ||
153 | + | ||
154 | + [ -z "$tvalue" ] && tvalue=10 # 10 seconds per test by default | ||
155 | + [ -z "$mvalue" ] && mvalue=`nproc` # thread count defaults to nproc | ||
156 | + [ -z "$nvalue" ] && nvalue=256 # 256 bytes default buffer size | ||
157 | + | ||
158 | + case "$alg_name" in | ||
159 | + "null" |\ | ||
160 | + "aes-128-cbc" |\ | ||
161 | + "aes-256-xts" |\ | ||
162 | + "sha1" |\ | ||
163 | + "sha256" |\ | ||
164 | + "crc32c" ) run_parallel;; | ||
165 | + * ) usage && exit 1;; | ||
166 | + esac | ||
167 | +} | ||
168 | + | ||
169 | +main "$@" | ||
170 | + | ||
171 | -- | ||
172 | 2.10.2 | ||
173 | |||
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 @@ | |||
1 | From ad7fee26da24fca57efee5ba10756e001769b2ce Mon Sep 17 00:00:00 2001 | ||
2 | From: Alexe Radu <radu.alexe@nxp.com> | ||
3 | Date: Tue, 25 Oct 2016 16:46:11 +0300 | ||
4 | Subject: [PATCH 056/104] fix: set min value when allocating alligned memory | ||
5 | buffers | ||
6 | |||
7 | The function "posix_memalign()" requires that the alignment be at least | ||
8 | sizeof(void*). In some situations the alignmask for some crypto algorithms | ||
9 | is smaller then the minimum required. For ex. on 64-bit platforms where | ||
10 | the alignment may be 4 bytes. | ||
11 | |||
12 | Signed-off-by: Alexe Radu <radu.alexe@nxp.com> | ||
13 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
14 | --- | ||
15 | tests/async_speed.c | 4 ++++ | ||
16 | tests/speed.c | 2 ++ | ||
17 | 2 files changed, 6 insertions(+) | ||
18 | |||
19 | diff --git a/tests/async_speed.c b/tests/async_speed.c | ||
20 | index 263ead7..b895a85 100644 | ||
21 | --- a/tests/async_speed.c | ||
22 | +++ b/tests/async_speed.c | ||
23 | @@ -232,6 +232,7 @@ int run_test(int id, struct test_params tp) | ||
24 | int get_alignmask(int fdc, struct session_op *sess) | ||
25 | { | ||
26 | int alignmask; | ||
27 | + int min_alignmask = sizeof(void*) - 1; | ||
28 | |||
29 | #ifdef CIOCGSESSINFO | ||
30 | struct session_info_op siop; | ||
31 | @@ -242,6 +243,9 @@ int get_alignmask(int fdc, struct session_op *sess) | ||
32 | return -EINVAL; | ||
33 | } | ||
34 | alignmask = siop.alignmask; | ||
35 | + if (alignmask < min_alignmask) { | ||
36 | + alignmask = min_alignmask; | ||
37 | + } | ||
38 | #else | ||
39 | alignmask = 0; | ||
40 | #endif | ||
41 | diff --git a/tests/speed.c b/tests/speed.c | ||
42 | index bd6d2b2..0b14c88 100644 | ||
43 | --- a/tests/speed.c | ||
44 | +++ b/tests/speed.c | ||
45 | @@ -80,8 +80,10 @@ int encrypt_data(struct session_op *sess, int fdc, int chunksize, int alignmask) | ||
46 | double total = 0; | ||
47 | double secs, ddata, dspeed; | ||
48 | char metric[16]; | ||
49 | + int min_alignmask = sizeof(void*) - 1; | ||
50 | |||
51 | if (alignmask) { | ||
52 | + alignmask = ((alignmask < min_alignmask) ? min_alignmask : alignmask); | ||
53 | if (posix_memalign((void **)&buffer, MAX(alignmask + 1, sizeof(void*)), chunksize)) { | ||
54 | printf("posix_memalign() failed! (mask %x, size: %d)\n", alignmask+1, chunksize); | ||
55 | return 1; | ||
56 | -- | ||
57 | 2.10.2 | ||
58 | |||
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 @@ | |||
1 | From f7e3566382bf22fc73c5a0edfde5c5349a92f8ea Mon Sep 17 00:00:00 2001 | ||
2 | From: Alexe Radu <radu.alexe@nxp.com> | ||
3 | Date: Tue, 25 Oct 2016 18:35:13 +0300 | ||
4 | Subject: [PATCH 057/104] gracefull stop for async speed tests | ||
5 | |||
6 | Signed-off-by: Alexe Radu <radu.alexe@nxp.com> | ||
7 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
8 | --- | ||
9 | tests/async_speed.c | 16 ++++++++++++++++ | ||
10 | 1 file changed, 16 insertions(+) | ||
11 | |||
12 | diff --git a/tests/async_speed.c b/tests/async_speed.c | ||
13 | index b895a85..e6bbeed 100644 | ||
14 | --- a/tests/async_speed.c | ||
15 | +++ b/tests/async_speed.c | ||
16 | @@ -77,6 +77,7 @@ static double udifftimeval(struct timeval start, struct timeval end) | ||
17 | } | ||
18 | |||
19 | static int must_finish = 0; | ||
20 | +static int must_exit = 0; | ||
21 | static struct pollfd pfd; | ||
22 | |||
23 | static void alarm_handler(int signo) | ||
24 | @@ -85,6 +86,12 @@ static void alarm_handler(int signo) | ||
25 | pfd.events = POLLIN; | ||
26 | } | ||
27 | |||
28 | +static void exit_handler(int signo) | ||
29 | +{ | ||
30 | + must_exit = 1; | ||
31 | + printf("\nexit requested by user through ctrl+c \n"); | ||
32 | +} | ||
33 | + | ||
34 | static char *units[] = { "", "Ki", "Mi", "Gi", "Ti", 0}; | ||
35 | |||
36 | static void value2human(uint64_t bytes, double time, double* data, double* speed,char* metric) | ||
37 | @@ -261,6 +268,10 @@ void do_test_vectors(int fdc, struct test_params tp, struct session_op *sess) | ||
38 | encrypt_data(fdc, tp, sess); | ||
39 | } else { | ||
40 | for (i = 256; i <= (64 * 1024); i *= 2) { | ||
41 | + if (must_exit) { | ||
42 | + break; | ||
43 | + } | ||
44 | + | ||
45 | tp.nvalue = i; | ||
46 | if (encrypt_data(fdc, tp, sess)) { | ||
47 | break; | ||
48 | @@ -422,8 +433,13 @@ int main(int argc, char **argv) | ||
49 | } | ||
50 | |||
51 | signal(SIGALRM, alarm_handler); | ||
52 | + signal(SIGINT, exit_handler); | ||
53 | |||
54 | for (i = 0; i < ALG_COUNT; i++) { | ||
55 | + if (must_exit) { | ||
56 | + break; | ||
57 | + } | ||
58 | + | ||
59 | if (alg_flag) { | ||
60 | if (strcmp(alg_name, ciphers[i].name) == 0) { | ||
61 | run_test(i, tp); | ||
62 | -- | ||
63 | 2.10.2 | ||
64 | |||
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 @@ | |||
1 | From b04d0b7ccb9150d4f16c712a830f8a4e3bdd2d05 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Wed, 26 Oct 2016 09:29:36 +0300 | ||
4 | Subject: [PATCH 058/104] sanity check on /dev/crypto availability | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed_multi.sh | 2 ++ | ||
9 | 1 file changed, 2 insertions(+) | ||
10 | |||
11 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
12 | index 761c0cb..94c2312 100755 | ||
13 | --- a/tests/async_speed_multi.sh | ||
14 | +++ b/tests/async_speed_multi.sh | ||
15 | @@ -108,6 +108,8 @@ function control_c | ||
16 | |||
17 | function main | ||
18 | { | ||
19 | + [ ! -e "/dev/crypto" ] && sudo modprobe cryptodev || modprobe cryptodev || exit 1 | ||
20 | + | ||
21 | while getopts hm:t:n: option | ||
22 | do | ||
23 | case "$option" in | ||
24 | -- | ||
25 | 2.10.2 | ||
26 | |||
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 @@ | |||
1 | From 28c87b3dd5ed2ac90185b09bdc7233648d5d89b5 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Wed, 26 Oct 2016 09:14:28 +0300 | ||
4 | Subject: [PATCH 059/104] fix some issues with parsing mpstat output | ||
5 | |||
6 | - mpstat with 'count' parameter will average the results for us on the | ||
7 | last line so we don't need to do this ourselves. | ||
8 | - set time format to ISO to avoid incorrect parsing of the header line | ||
9 | |||
10 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
11 | --- | ||
12 | tests/async_speed_multi.sh | 7 +++---- | ||
13 | 1 file changed, 3 insertions(+), 4 deletions(-) | ||
14 | |||
15 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
16 | index 94c2312..a28f72d 100755 | ||
17 | --- a/tests/async_speed_multi.sh | ||
18 | +++ b/tests/async_speed_multi.sh | ||
19 | @@ -21,6 +21,7 @@ | ||
20 | |||
21 | NUM_CORES=`nproc` | ||
22 | OUT_BASENAME="async_speed" | ||
23 | +S_TIME_FORMAT=ISO | ||
24 | MPSTAT="mpstat" | ||
25 | MPSTAT_OUT="mpstat_out" | ||
26 | |||
27 | @@ -47,10 +48,8 @@ function get_cpu_idle | ||
28 | header_line=`grep %idle ${MPSTAT_OUT} | head -n 1 | sed 's/\s\+/ /g'` | ||
29 | idle_column=`echo $header_line | wc -w` | ||
30 | |||
31 | - all_cpu_idle=`grep all ${MPSTAT_OUT} | tail -n +2 | sed 's/\s\+/ /g' | cut -d' ' -f ${idle_column} | SUM` | ||
32 | - mpstat_lines=`grep all ${MPSTAT_OUT} | tail -n +2 | wc -l` | ||
33 | - | ||
34 | - average_idle=`echo "scale=2; $all_cpu_idle / $mpstat_lines" | bc -l` | ||
35 | + average_idle=`grep Average ${MPSTAT_OUT} | sed 's/\s\+/ /g' | cut -d' ' -f ${idle_column} | tail -n 1` | ||
36 | + | ||
37 | echo $average_idle | ||
38 | } | ||
39 | |||
40 | -- | ||
41 | 2.10.2 | ||
42 | |||
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 @@ | |||
1 | From 26291db7df602d3d3d5601817229822b13904fe9 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Wed, 26 Oct 2016 09:48:44 +0300 | ||
4 | Subject: [PATCH 060/104] more precision in running mpstat | ||
5 | |||
6 | Start mpstat one second later than the tests so we don't measure | ||
7 | transient issues. Likewise, stop mpstat just before the tests terminate | ||
8 | so we don't record incorrect CPU idle. | ||
9 | |||
10 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
11 | --- | ||
12 | tests/async_speed_multi.sh | 6 +++--- | ||
13 | 1 file changed, 3 insertions(+), 3 deletions(-) | ||
14 | |||
15 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
16 | index a28f72d..5268c86 100755 | ||
17 | --- a/tests/async_speed_multi.sh | ||
18 | +++ b/tests/async_speed_multi.sh | ||
19 | @@ -22,7 +22,6 @@ | ||
20 | NUM_CORES=`nproc` | ||
21 | OUT_BASENAME="async_speed" | ||
22 | S_TIME_FORMAT=ISO | ||
23 | -MPSTAT="mpstat" | ||
24 | MPSTAT_OUT="mpstat_out" | ||
25 | |||
26 | function usage | ||
27 | @@ -47,7 +46,6 @@ function get_cpu_idle | ||
28 | { | ||
29 | header_line=`grep %idle ${MPSTAT_OUT} | head -n 1 | sed 's/\s\+/ /g'` | ||
30 | idle_column=`echo $header_line | wc -w` | ||
31 | - | ||
32 | average_idle=`grep Average ${MPSTAT_OUT} | sed 's/\s\+/ /g' | cut -d' ' -f ${idle_column} | tail -n 1` | ||
33 | |||
34 | echo $average_idle | ||
35 | @@ -63,7 +61,7 @@ function run_parallel | ||
36 | echo "Running $mvalue threads in parallel:" | ||
37 | echo " $CMD" | ||
38 | |||
39 | - $MPSTAT 1 $(($tvalue-1)) &> $MPSTAT_OUT & | ||
40 | + (sleep 1; mpstat 1 $(($tvalue-2))) &> $MPSTAT_OUT & | ||
41 | MPSTAT_PID=$! | ||
42 | |||
43 | PIDS="" | ||
44 | @@ -126,6 +124,8 @@ function main | ||
45 | [ -z "$mvalue" ] && mvalue=`nproc` # thread count defaults to nproc | ||
46 | [ -z "$nvalue" ] && nvalue=256 # 256 bytes default buffer size | ||
47 | |||
48 | + [ "$tvalue" -lt 5 ] && tvalue=5 | ||
49 | + | ||
50 | case "$alg_name" in | ||
51 | "null" |\ | ||
52 | "aes-128-cbc" |\ | ||
53 | -- | ||
54 | 2.10.2 | ||
55 | |||
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 @@ | |||
1 | From 3bfdd0d1991a37c1adc82cc7e1938e2d9d175bd7 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Wed, 26 Oct 2016 10:01:57 +0300 | ||
4 | Subject: [PATCH 061/104] add a little space in the output for clarity | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed_multi.sh | 3 ++- | ||
9 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
10 | |||
11 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
12 | index 5268c86..331158b 100755 | ||
13 | --- a/tests/async_speed_multi.sh | ||
14 | +++ b/tests/async_speed_multi.sh | ||
15 | @@ -58,7 +58,8 @@ function run_parallel | ||
16 | OPTIONS="-t $tvalue -n $nvalue -m" | ||
17 | CMD="async_speed $OPTIONS $alg_name" | ||
18 | |||
19 | - echo "Running $mvalue threads in parallel:" | ||
20 | + echo | ||
21 | + echo "Running $tvalue seconds $mvalue threads in parallel:" | ||
22 | echo " $CMD" | ||
23 | |||
24 | (sleep 1; mpstat 1 $(($tvalue-2))) &> $MPSTAT_OUT & | ||
25 | -- | ||
26 | 2.10.2 | ||
27 | |||
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 @@ | |||
1 | From 0fd37b5225bd26182b20588b200a4fc0a3f415e5 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Wed, 26 Oct 2016 10:10:47 +0300 | ||
4 | Subject: [PATCH 062/104] fix build warnings on implicit function declarations | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/Makefile | 2 +- | ||
9 | tests/async_speed.c | 47 +++++++++++++++++++++++------------------------ | ||
10 | tests/hashcrypt_speed.c | 1 + | ||
11 | tests/sha_speed.c | 1 + | ||
12 | tests/speed.c | 1 + | ||
13 | 5 files changed, 27 insertions(+), 25 deletions(-) | ||
14 | |||
15 | diff --git a/tests/Makefile b/tests/Makefile | ||
16 | index 6424c11..14ae2c7 100644 | ||
17 | --- a/tests/Makefile | ||
18 | +++ b/tests/Makefile | ||
19 | @@ -1,5 +1,5 @@ | ||
20 | KERNEL_DIR ?= /lib/modules/$(shell uname -r)/build | ||
21 | -CRYPTODEV_CFLAGS += -DENABLE_ASYNC | ||
22 | +CRYPTODEV_CFLAGS += -DENABLE_ASYNC -Wimplicit-function-declaration | ||
23 | KBUILD_CFLAGS += -I.. $(CRYPTODEV_CFLAGS) | ||
24 | CFLAGS += -I.. $(CRYPTODEV_CFLAGS) | ||
25 | |||
26 | diff --git a/tests/async_speed.c b/tests/async_speed.c | ||
27 | index e6bbeed..a1a1b7e 100644 | ||
28 | --- a/tests/async_speed.c | ||
29 | +++ b/tests/async_speed.c | ||
30 | @@ -112,6 +112,29 @@ static void value2machine(uint64_t bytes, double time, double* speed) | ||
31 | *speed = bytes / time; | ||
32 | } | ||
33 | |||
34 | +int get_alignmask(int fdc, struct session_op *sess) | ||
35 | +{ | ||
36 | + int alignmask; | ||
37 | + int min_alignmask = sizeof(void*) - 1; | ||
38 | + | ||
39 | +#ifdef CIOCGSESSINFO | ||
40 | + struct session_info_op siop; | ||
41 | + | ||
42 | + siop.ses = sess->ses; | ||
43 | + if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
44 | + perror("ioctl(CIOCGSESSINFO)"); | ||
45 | + return -EINVAL; | ||
46 | + } | ||
47 | + alignmask = siop.alignmask; | ||
48 | + if (alignmask < min_alignmask) { | ||
49 | + alignmask = min_alignmask; | ||
50 | + } | ||
51 | +#else | ||
52 | + alignmask = 0; | ||
53 | +#endif | ||
54 | + | ||
55 | + return alignmask; | ||
56 | +} | ||
57 | |||
58 | int encrypt_data(int fdc, struct test_params tp, struct session_op *sess) | ||
59 | { | ||
60 | @@ -236,30 +259,6 @@ int run_test(int id, struct test_params tp) | ||
61 | close(fd); | ||
62 | } | ||
63 | |||
64 | -int get_alignmask(int fdc, struct session_op *sess) | ||
65 | -{ | ||
66 | - int alignmask; | ||
67 | - int min_alignmask = sizeof(void*) - 1; | ||
68 | - | ||
69 | -#ifdef CIOCGSESSINFO | ||
70 | - struct session_info_op siop; | ||
71 | - | ||
72 | - siop.ses = sess->ses; | ||
73 | - if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
74 | - perror("ioctl(CIOCGSESSINFO)"); | ||
75 | - return -EINVAL; | ||
76 | - } | ||
77 | - alignmask = siop.alignmask; | ||
78 | - if (alignmask < min_alignmask) { | ||
79 | - alignmask = min_alignmask; | ||
80 | - } | ||
81 | -#else | ||
82 | - alignmask = 0; | ||
83 | -#endif | ||
84 | - | ||
85 | - return alignmask; | ||
86 | -} | ||
87 | - | ||
88 | void do_test_vectors(int fdc, struct test_params tp, struct session_op *sess) | ||
89 | { | ||
90 | int i; | ||
91 | diff --git a/tests/hashcrypt_speed.c b/tests/hashcrypt_speed.c | ||
92 | index e60b73d..045bf8e 100644 | ||
93 | --- a/tests/hashcrypt_speed.c | ||
94 | +++ b/tests/hashcrypt_speed.c | ||
95 | @@ -25,6 +25,7 @@ | ||
96 | #include <sys/time.h> | ||
97 | #include <sys/types.h> | ||
98 | #include <signal.h> | ||
99 | +#include <unistd.h> | ||
100 | #include <crypto/cryptodev.h> | ||
101 | |||
102 | #define MAX(x,y) ((x)>(y)?(x):(y)) | ||
103 | diff --git a/tests/sha_speed.c b/tests/sha_speed.c | ||
104 | index 75d0f42..e5c6efe 100644 | ||
105 | --- a/tests/sha_speed.c | ||
106 | +++ b/tests/sha_speed.c | ||
107 | @@ -25,6 +25,7 @@ | ||
108 | #include <sys/time.h> | ||
109 | #include <sys/types.h> | ||
110 | #include <signal.h> | ||
111 | +#include <unistd.h> | ||
112 | |||
113 | #include <crypto/cryptodev.h> | ||
114 | |||
115 | diff --git a/tests/speed.c b/tests/speed.c | ||
116 | index 0b14c88..d2e1aed 100644 | ||
117 | --- a/tests/speed.c | ||
118 | +++ b/tests/speed.c | ||
119 | @@ -24,6 +24,7 @@ | ||
120 | #include <sys/time.h> | ||
121 | #include <sys/types.h> | ||
122 | #include <signal.h> | ||
123 | +#include <unistd.h> | ||
124 | |||
125 | #include <crypto/cryptodev.h> | ||
126 | |||
127 | -- | ||
128 | 2.10.2 | ||
129 | |||
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 @@ | |||
1 | From 5f3a9153f7685f6dde29f7cd2d58534126c5b9af Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Wed, 26 Oct 2016 10:45:40 +0300 | ||
4 | Subject: [PATCH 063/104] avoid implicit conversion between signed and unsigned | ||
5 | char | ||
6 | |||
7 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
8 | --- | ||
9 | tests/async_cipher.c | 36 ++++++++++++++-------------- | ||
10 | tests/async_hmac.c | 8 +++---- | ||
11 | tests/async_speed.c | 2 +- | ||
12 | tests/cipher-aead-srtp.c | 50 +++++++++++++++++++------------------- | ||
13 | tests/cipher-aead.c | 48 ++++++++++++++++++------------------- | ||
14 | tests/cipher-gcm.c | 62 ++++++++++++++++++++++++------------------------ | ||
15 | tests/cipher.c | 35 ++++++++++++++------------- | ||
16 | tests/cipher_comp.c | 12 +++++----- | ||
17 | tests/fullspeed.c | 3 ++- | ||
18 | tests/hash_comp.c | 8 +++---- | ||
19 | tests/hmac.c | 8 +++---- | ||
20 | tests/speed.c | 3 ++- | ||
21 | 12 files changed, 138 insertions(+), 137 deletions(-) | ||
22 | |||
23 | diff --git a/tests/async_cipher.c b/tests/async_cipher.c | ||
24 | index 162a695..dd08403 100644 | ||
25 | --- a/tests/async_cipher.c | ||
26 | +++ b/tests/async_cipher.c | ||
27 | @@ -9,7 +9,7 @@ | ||
28 | #include <string.h> | ||
29 | #include <unistd.h> | ||
30 | #include <fcntl.h> | ||
31 | - | ||
32 | +#include <stdint.h> | ||
33 | #include <sys/ioctl.h> | ||
34 | #include <crypto/cryptodev.h> | ||
35 | |||
36 | @@ -26,10 +26,10 @@ static int debug = 0; | ||
37 | static int | ||
38 | test_crypto(int cfd) | ||
39 | { | ||
40 | - char plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
41 | - char ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
42 | - char iv[BLOCK_SIZE]; | ||
43 | - char key[KEY_SIZE]; | ||
44 | + uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
45 | + uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
46 | + uint8_t iv[BLOCK_SIZE]; | ||
47 | + uint8_t key[KEY_SIZE]; | ||
48 | |||
49 | struct session_op sess; | ||
50 | #ifdef CIOCGSESSINFO | ||
51 | @@ -62,8 +62,8 @@ test_crypto(int cfd) | ||
52 | perror("ioctl(CIOCGSESSINFO)"); | ||
53 | return 1; | ||
54 | } | ||
55 | - plaintext = (char *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
56 | - ciphertext = (char *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
57 | + plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
58 | + ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
59 | #else | ||
60 | plaintext = plaintext_raw; | ||
61 | ciphertext = ciphertext_raw; | ||
62 | @@ -127,15 +127,15 @@ test_crypto(int cfd) | ||
63 | |||
64 | static int test_aes(int cfd) | ||
65 | { | ||
66 | - char plaintext1_raw[BLOCK_SIZE + 63], *plaintext1; | ||
67 | - char ciphertext1[BLOCK_SIZE] = { 0xdf, 0x55, 0x6a, 0x33, 0x43, 0x8d, 0xb8, 0x7b, 0xc4, 0x1b, 0x17, 0x52, 0xc5, 0x5e, 0x5e, 0x49 }; | ||
68 | - char iv1[BLOCK_SIZE]; | ||
69 | - char key1[KEY_SIZE] = { 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | ||
70 | - char plaintext2_data[BLOCK_SIZE] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00 }; | ||
71 | - char plaintext2_raw[BLOCK_SIZE + 63], *plaintext2; | ||
72 | - char ciphertext2[BLOCK_SIZE] = { 0xb7, 0x97, 0x2b, 0x39, 0x41, 0xc4, 0x4b, 0x90, 0xaf, 0xa7, 0xb2, 0x64, 0xbf, 0xba, 0x73, 0x87 }; | ||
73 | - char iv2[BLOCK_SIZE]; | ||
74 | - char key2[KEY_SIZE]; | ||
75 | + uint8_t plaintext1_raw[BLOCK_SIZE + 63], *plaintext1; | ||
76 | + uint8_t ciphertext1[BLOCK_SIZE] = { 0xdf, 0x55, 0x6a, 0x33, 0x43, 0x8d, 0xb8, 0x7b, 0xc4, 0x1b, 0x17, 0x52, 0xc5, 0x5e, 0x5e, 0x49 }; | ||
77 | + uint8_t iv1[BLOCK_SIZE]; | ||
78 | + uint8_t key1[KEY_SIZE] = { 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | ||
79 | + uint8_t plaintext2_data[BLOCK_SIZE] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00 }; | ||
80 | + uint8_t plaintext2_raw[BLOCK_SIZE + 63], *plaintext2; | ||
81 | + uint8_t ciphertext2[BLOCK_SIZE] = { 0xb7, 0x97, 0x2b, 0x39, 0x41, 0xc4, 0x4b, 0x90, 0xaf, 0xa7, 0xb2, 0x64, 0xbf, 0xba, 0x73, 0x87 }; | ||
82 | + uint8_t iv2[BLOCK_SIZE]; | ||
83 | + uint8_t key2[KEY_SIZE]; | ||
84 | |||
85 | struct session_op sess1, sess2; | ||
86 | #ifdef CIOCGSESSINFO | ||
87 | @@ -162,7 +162,7 @@ static int test_aes(int cfd) | ||
88 | perror("ioctl(CIOCGSESSINFO)"); | ||
89 | return 1; | ||
90 | } | ||
91 | - plaintext1 = (char *)(((unsigned long)plaintext1_raw + siop1.alignmask) & ~siop1.alignmask); | ||
92 | + plaintext1 = (uint8_t *)(((unsigned long)plaintext1_raw + siop1.alignmask) & ~siop1.alignmask); | ||
93 | #else | ||
94 | plaintext1 = plaintext1_raw; | ||
95 | #endif | ||
96 | @@ -185,7 +185,7 @@ static int test_aes(int cfd) | ||
97 | perror("ioctl(CIOCGSESSINFO)"); | ||
98 | return 1; | ||
99 | } | ||
100 | - plaintext2 = (char *)(((unsigned long)plaintext2_raw + siop2.alignmask) & ~siop2.alignmask); | ||
101 | + plaintext2 = (uint8_t *)(((unsigned long)plaintext2_raw + siop2.alignmask) & ~siop2.alignmask); | ||
102 | #else | ||
103 | plaintext2 = plaintext2_raw; | ||
104 | #endif | ||
105 | diff --git a/tests/async_hmac.c b/tests/async_hmac.c | ||
106 | index 97fd0c5..94a02c0 100644 | ||
107 | --- a/tests/async_hmac.c | ||
108 | +++ b/tests/async_hmac.c | ||
109 | @@ -61,7 +61,7 @@ test_crypto(int cfd) | ||
110 | |||
111 | cryp.ses = sess.ses; | ||
112 | cryp.len = sizeof("what do ya want for nothing?")-1; | ||
113 | - cryp.src = "what do ya want for nothing?"; | ||
114 | + cryp.src = (uint8_t*)"what do ya want for nothing?"; | ||
115 | cryp.mac = mac; | ||
116 | cryp.op = COP_ENCRYPT; | ||
117 | |||
118 | @@ -98,7 +98,7 @@ test_crypto(int cfd) | ||
119 | |||
120 | cryp.ses = sess.ses; | ||
121 | cryp.len = sizeof("what do ya want for nothing?")-1; | ||
122 | - cryp.src = "what do ya want for nothing?"; | ||
123 | + cryp.src = (uint8_t*)"what do ya want for nothing?"; | ||
124 | cryp.mac = mac; | ||
125 | cryp.op = COP_ENCRYPT; | ||
126 | |||
127 | @@ -208,7 +208,7 @@ test_extras(int cfd) | ||
128 | |||
129 | cryp.ses = sess.ses; | ||
130 | cryp.len = sizeof("what do")-1; | ||
131 | - cryp.src = "what do"; | ||
132 | + cryp.src = (uint8_t*)"what do"; | ||
133 | cryp.mac = mac; | ||
134 | cryp.op = COP_ENCRYPT; | ||
135 | cryp.flags = COP_FLAG_UPDATE; | ||
136 | @@ -218,7 +218,7 @@ test_extras(int cfd) | ||
137 | |||
138 | cryp.ses = sess.ses; | ||
139 | cryp.len = sizeof(" ya want for nothing?")-1; | ||
140 | - cryp.src = " ya want for nothing?"; | ||
141 | + cryp.src = (uint8_t*)" ya want for nothing?"; | ||
142 | cryp.mac = mac; | ||
143 | cryp.op = COP_ENCRYPT; | ||
144 | cryp.flags = COP_FLAG_FINAL; | ||
145 | diff --git a/tests/async_speed.c b/tests/async_speed.c | ||
146 | index a1a1b7e..dabbbc1 100644 | ||
147 | --- a/tests/async_speed.c | ||
148 | +++ b/tests/async_speed.c | ||
149 | @@ -140,7 +140,7 @@ int encrypt_data(int fdc, struct test_params tp, struct session_op *sess) | ||
150 | { | ||
151 | struct crypt_op cop; | ||
152 | char *buffer[64], iv[32]; | ||
153 | - char mac[64][HASH_MAX_LEN]; | ||
154 | + uint8_t mac[64][HASH_MAX_LEN]; | ||
155 | static int val = 23; | ||
156 | struct timeval start, end; | ||
157 | uint64_t total = 0; | ||
158 | diff --git a/tests/cipher-aead-srtp.c b/tests/cipher-aead-srtp.c | ||
159 | index fae04e7..c44877d 100644 | ||
160 | --- a/tests/cipher-aead-srtp.c | ||
161 | +++ b/tests/cipher-aead-srtp.c | ||
162 | @@ -77,13 +77,13 @@ int i; | ||
163 | static int | ||
164 | test_crypto(int cfd) | ||
165 | { | ||
166 | - char plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
167 | - char ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
168 | - char iv[BLOCK_SIZE]; | ||
169 | - char key[KEY_SIZE]; | ||
170 | - unsigned char sha1mac[20]; | ||
171 | - unsigned char tag[20]; | ||
172 | - unsigned char mackey[] = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
173 | + uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
174 | + uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
175 | + uint8_t iv[BLOCK_SIZE]; | ||
176 | + uint8_t key[KEY_SIZE]; | ||
177 | + uint8_t sha1mac[20]; | ||
178 | + uint8_t tag[20]; | ||
179 | + uint8_t mackey[] = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
180 | int mackey_len = 16; | ||
181 | |||
182 | struct session_op sess; | ||
183 | @@ -122,8 +122,8 @@ test_crypto(int cfd) | ||
184 | printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", | ||
185 | siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
186 | |||
187 | - plaintext = (char *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
188 | - ciphertext = (char *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
189 | + plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
190 | + ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
191 | |||
192 | memset(plaintext, 0x15, HEADER_SIZE); /* header */ | ||
193 | memset(&plaintext[HEADER_SIZE], 0x17, PLAINTEXT_SIZE); /* payload */ | ||
194 | @@ -225,12 +225,12 @@ test_crypto(int cfd) | ||
195 | static int | ||
196 | test_encrypt_decrypt(int cfd) | ||
197 | { | ||
198 | - char plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
199 | - char ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
200 | - char iv[BLOCK_SIZE]; | ||
201 | - char key[KEY_SIZE]; | ||
202 | - unsigned char tag[20]; | ||
203 | - unsigned char mackey[] = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
204 | + uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
205 | + uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
206 | + uint8_t iv[BLOCK_SIZE]; | ||
207 | + uint8_t key[KEY_SIZE]; | ||
208 | + uint8_t tag[20]; | ||
209 | + uint8_t mackey[] = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
210 | int mackey_len = 16; | ||
211 | |||
212 | struct session_op sess; | ||
213 | @@ -265,8 +265,8 @@ test_encrypt_decrypt(int cfd) | ||
214 | // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", | ||
215 | // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
216 | |||
217 | - plaintext = (char *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
218 | - ciphertext = (char *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
219 | + plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
220 | + ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
221 | |||
222 | memset(plaintext, 0x15, HEADER_SIZE); /* header */ | ||
223 | memset(&plaintext[HEADER_SIZE], 0x17, PLAINTEXT_SIZE); /* payload */ | ||
224 | @@ -367,12 +367,12 @@ test_encrypt_decrypt(int cfd) | ||
225 | static int | ||
226 | test_encrypt_decrypt_error(int cfd, int err) | ||
227 | { | ||
228 | - char plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
229 | - char ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
230 | - char iv[BLOCK_SIZE]; | ||
231 | - char key[KEY_SIZE]; | ||
232 | - unsigned char tag[20]; | ||
233 | - unsigned char mackey[] = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
234 | + uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
235 | + uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
236 | + uint8_t iv[BLOCK_SIZE]; | ||
237 | + uint8_t key[KEY_SIZE]; | ||
238 | + uint8_t tag[20]; | ||
239 | + uint8_t mackey[] = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
240 | int mackey_len = 16; | ||
241 | |||
242 | struct session_op sess; | ||
243 | @@ -407,8 +407,8 @@ test_encrypt_decrypt_error(int cfd, int err) | ||
244 | // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", | ||
245 | // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
246 | |||
247 | - plaintext = (char *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
248 | - ciphertext = (char *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
249 | + plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
250 | + ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
251 | |||
252 | memset(plaintext, 0x15, HEADER_SIZE); /* header */ | ||
253 | memset(&plaintext[HEADER_SIZE], 0x17, PLAINTEXT_SIZE); /* payload */ | ||
254 | diff --git a/tests/cipher-aead.c b/tests/cipher-aead.c | ||
255 | index 164327f..da43aa6 100644 | ||
256 | --- a/tests/cipher-aead.c | ||
257 | +++ b/tests/cipher-aead.c | ||
258 | @@ -89,12 +89,12 @@ int i; | ||
259 | static int | ||
260 | test_crypto(int cfd) | ||
261 | { | ||
262 | - char plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
263 | - char ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
264 | - char iv[BLOCK_SIZE]; | ||
265 | - char key[KEY_SIZE]; | ||
266 | - char auth[AUTH_SIZE]; | ||
267 | - unsigned char sha1mac[20]; | ||
268 | + uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
269 | + uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
270 | + uint8_t iv[BLOCK_SIZE]; | ||
271 | + uint8_t key[KEY_SIZE]; | ||
272 | + uint8_t auth[AUTH_SIZE]; | ||
273 | + uint8_t sha1mac[20]; | ||
274 | int pad, i; | ||
275 | |||
276 | struct session_op sess; | ||
277 | @@ -133,8 +133,8 @@ test_crypto(int cfd) | ||
278 | printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", | ||
279 | siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
280 | |||
281 | - plaintext = (char *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
282 | - ciphertext = (char *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
283 | + plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
284 | + ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
285 | memset(plaintext, 0x15, DATA_SIZE); | ||
286 | |||
287 | if (get_sha1_hmac(cfd, sess.mackey, sess.mackeylen, auth, sizeof(auth), plaintext, DATA_SIZE, sha1mac) != 0) { | ||
288 | @@ -242,12 +242,12 @@ test_crypto(int cfd) | ||
289 | static int | ||
290 | test_encrypt_decrypt(int cfd) | ||
291 | { | ||
292 | - char plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
293 | - char ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
294 | - char iv[BLOCK_SIZE]; | ||
295 | - char key[KEY_SIZE]; | ||
296 | - char auth[AUTH_SIZE]; | ||
297 | - unsigned char sha1mac[20]; | ||
298 | + uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
299 | + uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
300 | + uint8_t iv[BLOCK_SIZE]; | ||
301 | + uint8_t key[KEY_SIZE]; | ||
302 | + uint8_t auth[AUTH_SIZE]; | ||
303 | + uint8_t sha1mac[20]; | ||
304 | int enc_len; | ||
305 | |||
306 | struct session_op sess; | ||
307 | @@ -285,8 +285,8 @@ test_encrypt_decrypt(int cfd) | ||
308 | // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", | ||
309 | // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
310 | |||
311 | - plaintext = (char *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
312 | - ciphertext = (char *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
313 | + plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
314 | + ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
315 | |||
316 | memset(plaintext, 0x15, DATA_SIZE); | ||
317 | |||
318 | @@ -391,12 +391,12 @@ test_encrypt_decrypt(int cfd) | ||
319 | static int | ||
320 | test_encrypt_decrypt_error(int cfd, int err) | ||
321 | { | ||
322 | - char plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
323 | - char ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
324 | - char iv[BLOCK_SIZE]; | ||
325 | - char key[KEY_SIZE]; | ||
326 | - char auth[AUTH_SIZE]; | ||
327 | - unsigned char sha1mac[20]; | ||
328 | + uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
329 | + uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
330 | + uint8_t iv[BLOCK_SIZE]; | ||
331 | + uint8_t key[KEY_SIZE]; | ||
332 | + uint8_t auth[AUTH_SIZE]; | ||
333 | + uint8_t sha1mac[20]; | ||
334 | int enc_len; | ||
335 | |||
336 | struct session_op sess; | ||
337 | @@ -434,8 +434,8 @@ test_encrypt_decrypt_error(int cfd, int err) | ||
338 | // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", | ||
339 | // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
340 | |||
341 | - plaintext = (char *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
342 | - ciphertext = (char *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
343 | + plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
344 | + ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
345 | memset(plaintext, 0x15, DATA_SIZE); | ||
346 | |||
347 | if (get_sha1_hmac(cfd, sess.mackey, sess.mackeylen, auth, sizeof(auth), plaintext, DATA_SIZE, sha1mac) != 0) { | ||
348 | diff --git a/tests/cipher-gcm.c b/tests/cipher-gcm.c | ||
349 | index dfc3d84..3f6cc7b 100644 | ||
350 | --- a/tests/cipher-gcm.c | ||
351 | +++ b/tests/cipher-gcm.c | ||
352 | @@ -45,45 +45,45 @@ struct aes_gcm_vectors_st { | ||
353 | |||
354 | struct aes_gcm_vectors_st aes_gcm_vectors[] = { | ||
355 | { | ||
356 | - .key = | ||
357 | + .key = (uint8_t*) | ||
358 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", | ||
359 | .auth = NULL, | ||
360 | .auth_size = 0, | ||
361 | - .plaintext = | ||
362 | + .plaintext = (uint8_t*) | ||
363 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", | ||
364 | .plaintext_size = 16, | ||
365 | - .ciphertext = | ||
366 | + .ciphertext = (uint8_t*) | ||
367 | "\x03\x88\xda\xce\x60\xb6\xa3\x92\xf3\x28\xc2\xb9\x71\xb2\xfe\x78", | ||
368 | - .iv = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", | ||
369 | - .tag = | ||
370 | + .iv = (uint8_t*)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", | ||
371 | + .tag = (uint8_t*) | ||
372 | "\xab\x6e\x47\xd4\x2c\xec\x13\xbd\xf5\x3a\x67\xb2\x12\x57\xbd\xdf" | ||
373 | }, | ||
374 | { | ||
375 | - .key = | ||
376 | + .key = (uint8_t*) | ||
377 | "\xfe\xff\xe9\x92\x86\x65\x73\x1c\x6d\x6a\x8f\x94\x67\x30\x83\x08", | ||
378 | .auth = NULL, | ||
379 | .auth_size = 0, | ||
380 | - .plaintext = | ||
381 | + .plaintext = (uint8_t*) | ||
382 | "\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", | ||
383 | .plaintext_size = 64, | ||
384 | - .ciphertext = | ||
385 | + .ciphertext = (uint8_t*) | ||
386 | "\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", | ||
387 | - .iv = "\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88", | ||
388 | - .tag = "\x4d\x5c\x2a\xf3\x27\xcd\x64\xa6\x2c\xf3\x5a\xbd\x2b\xa6\xfa\xb4" | ||
389 | + .iv = (uint8_t*)"\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88", | ||
390 | + .tag = (uint8_t*)"\x4d\x5c\x2a\xf3\x27\xcd\x64\xa6\x2c\xf3\x5a\xbd\x2b\xa6\xfa\xb4" | ||
391 | }, | ||
392 | { | ||
393 | - .key = | ||
394 | + .key = (uint8_t*) | ||
395 | "\xfe\xff\xe9\x92\x86\x65\x73\x1c\x6d\x6a\x8f\x94\x67\x30\x83\x08", | ||
396 | - .auth = | ||
397 | + .auth = (uint8_t*) | ||
398 | "\xfe\xed\xfa\xce\xde\xad\xbe\xef\xfe\xed\xfa\xce\xde\xad\xbe\xef\xab\xad\xda\xd2", | ||
399 | .auth_size = 20, | ||
400 | - .plaintext = | ||
401 | + .plaintext = (uint8_t*) | ||
402 | "\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", | ||
403 | .plaintext_size = 60, | ||
404 | - .ciphertext = | ||
405 | + .ciphertext = (uint8_t*) | ||
406 | "\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", | ||
407 | - .iv = "\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88", | ||
408 | - .tag = | ||
409 | + .iv = (uint8_t*)"\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88", | ||
410 | + .tag = (uint8_t*) | ||
411 | "\x5b\xc9\x4f\xbc\x32\x21\xa5\xdb\x94\xfa\xe9\x5a\xe7\x12\x1a\x47" | ||
412 | } | ||
413 | }; | ||
414 | @@ -94,7 +94,7 @@ struct aes_gcm_vectors_st aes_gcm_vectors[] = { | ||
415 | static int test_crypto(int cfd) | ||
416 | { | ||
417 | int i; | ||
418 | - int8_t tmp[128]; | ||
419 | + uint8_t tmp[128]; | ||
420 | |||
421 | struct session_op sess; | ||
422 | struct crypt_auth_op cao; | ||
423 | @@ -191,11 +191,11 @@ static int test_crypto(int cfd) | ||
424 | */ | ||
425 | static int test_encrypt_decrypt(int cfd) | ||
426 | { | ||
427 | - char plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
428 | - char ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
429 | - char iv[BLOCK_SIZE]; | ||
430 | - char key[KEY_SIZE]; | ||
431 | - char auth[AUTH_SIZE]; | ||
432 | + uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
433 | + uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
434 | + uint8_t iv[BLOCK_SIZE]; | ||
435 | + uint8_t key[KEY_SIZE]; | ||
436 | + uint8_t auth[AUTH_SIZE]; | ||
437 | int enc_len; | ||
438 | |||
439 | struct session_op sess; | ||
440 | @@ -233,10 +233,10 @@ static int test_encrypt_decrypt(int cfd) | ||
441 | // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
442 | |||
443 | plaintext = | ||
444 | - (char *) (((unsigned long) plaintext_raw + siop.alignmask) & | ||
445 | + (uint8_t *) (((unsigned long) plaintext_raw + siop.alignmask) & | ||
446 | ~siop.alignmask); | ||
447 | ciphertext = | ||
448 | - (char *) (((unsigned long) ciphertext_raw + siop.alignmask) & | ||
449 | + (uint8_t *) (((unsigned long) ciphertext_raw + siop.alignmask) & | ||
450 | ~siop.alignmask); | ||
451 | |||
452 | memset(plaintext, 0x15, DATA_SIZE); | ||
453 | @@ -336,11 +336,11 @@ static int test_encrypt_decrypt(int cfd) | ||
454 | |||
455 | static int test_encrypt_decrypt_error(int cfd, int err) | ||
456 | { | ||
457 | - char plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
458 | - char ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
459 | - char iv[BLOCK_SIZE]; | ||
460 | - char key[KEY_SIZE]; | ||
461 | - char auth[AUTH_SIZE]; | ||
462 | + uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
463 | + uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
464 | + uint8_t iv[BLOCK_SIZE]; | ||
465 | + uint8_t key[KEY_SIZE]; | ||
466 | + uint8_t auth[AUTH_SIZE]; | ||
467 | int enc_len; | ||
468 | |||
469 | struct session_op sess; | ||
470 | @@ -386,10 +386,10 @@ static int test_encrypt_decrypt_error(int cfd, int err) | ||
471 | // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
472 | |||
473 | plaintext = | ||
474 | - (char *) (((unsigned long) plaintext_raw + siop.alignmask) & | ||
475 | + (uint8_t *) (((unsigned long) plaintext_raw + siop.alignmask) & | ||
476 | ~siop.alignmask); | ||
477 | ciphertext = | ||
478 | - (char *) (((unsigned long) ciphertext_raw + siop.alignmask) & | ||
479 | + (uint8_t *) (((unsigned long) ciphertext_raw + siop.alignmask) & | ||
480 | ~siop.alignmask); | ||
481 | |||
482 | memset(plaintext, 0x15, DATA_SIZE); | ||
483 | diff --git a/tests/cipher.c b/tests/cipher.c | ||
484 | index 07144f2..f3ca2f0 100644 | ||
485 | --- a/tests/cipher.c | ||
486 | +++ b/tests/cipher.c | ||
487 | @@ -8,6 +8,7 @@ | ||
488 | #include <string.h> | ||
489 | #include <unistd.h> | ||
490 | #include <fcntl.h> | ||
491 | +#include <stdint.h> | ||
492 | |||
493 | #include <sys/ioctl.h> | ||
494 | #include <crypto/cryptodev.h> | ||
495 | @@ -21,10 +22,10 @@ static int debug = 0; | ||
496 | static int | ||
497 | test_crypto(int cfd) | ||
498 | { | ||
499 | - char plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
500 | - char ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
501 | - char iv[BLOCK_SIZE]; | ||
502 | - char key[KEY_SIZE]; | ||
503 | + uint8_t plaintext_raw[DATA_SIZE + 63], *plaintext; | ||
504 | + uint8_t ciphertext_raw[DATA_SIZE + 63], *ciphertext; | ||
505 | + uint8_t iv[BLOCK_SIZE]; | ||
506 | + uint8_t key[KEY_SIZE]; | ||
507 | |||
508 | struct session_op sess; | ||
509 | #ifdef CIOCGSESSINFO | ||
510 | @@ -57,8 +58,8 @@ test_crypto(int cfd) | ||
511 | printf("requested cipher CRYPTO_AES_CBC, got %s with driver %s\n", | ||
512 | siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
513 | |||
514 | - plaintext = (char *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
515 | - ciphertext = (char *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
516 | + plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
517 | + ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
518 | #else | ||
519 | plaintext = plaintext_raw; | ||
520 | ciphertext = ciphertext_raw; | ||
521 | @@ -143,15 +144,15 @@ test_crypto(int cfd) | ||
522 | |||
523 | static int test_aes(int cfd) | ||
524 | { | ||
525 | - char plaintext1_raw[BLOCK_SIZE + 63], *plaintext1; | ||
526 | - char ciphertext1[BLOCK_SIZE] = { 0xdf, 0x55, 0x6a, 0x33, 0x43, 0x8d, 0xb8, 0x7b, 0xc4, 0x1b, 0x17, 0x52, 0xc5, 0x5e, 0x5e, 0x49 }; | ||
527 | - char iv1[BLOCK_SIZE]; | ||
528 | - char key1[KEY_SIZE] = { 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | ||
529 | - char plaintext2_data[BLOCK_SIZE] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00 }; | ||
530 | - char plaintext2_raw[BLOCK_SIZE + 63], *plaintext2; | ||
531 | - char ciphertext2[BLOCK_SIZE] = { 0xb7, 0x97, 0x2b, 0x39, 0x41, 0xc4, 0x4b, 0x90, 0xaf, 0xa7, 0xb2, 0x64, 0xbf, 0xba, 0x73, 0x87 }; | ||
532 | - char iv2[BLOCK_SIZE]; | ||
533 | - char key2[KEY_SIZE]; | ||
534 | + uint8_t plaintext1_raw[BLOCK_SIZE + 63], *plaintext1; | ||
535 | + uint8_t ciphertext1[BLOCK_SIZE] = { 0xdf, 0x55, 0x6a, 0x33, 0x43, 0x8d, 0xb8, 0x7b, 0xc4, 0x1b, 0x17, 0x52, 0xc5, 0x5e, 0x5e, 0x49 }; | ||
536 | + uint8_t iv1[BLOCK_SIZE]; | ||
537 | + uint8_t key1[KEY_SIZE] = { 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | ||
538 | + uint8_t plaintext2_data[BLOCK_SIZE] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00 }; | ||
539 | + uint8_t plaintext2_raw[BLOCK_SIZE + 63], *plaintext2; | ||
540 | + uint8_t ciphertext2[BLOCK_SIZE] = { 0xb7, 0x97, 0x2b, 0x39, 0x41, 0xc4, 0x4b, 0x90, 0xaf, 0xa7, 0xb2, 0x64, 0xbf, 0xba, 0x73, 0x87 }; | ||
541 | + uint8_t iv2[BLOCK_SIZE]; | ||
542 | + uint8_t key2[KEY_SIZE]; | ||
543 | |||
544 | struct session_op sess; | ||
545 | #ifdef CIOCGSESSINFO | ||
546 | @@ -176,7 +177,7 @@ static int test_aes(int cfd) | ||
547 | perror("ioctl(CIOCGSESSINFO)"); | ||
548 | return 1; | ||
549 | } | ||
550 | - plaintext1 = (char *)(((unsigned long)plaintext1_raw + siop.alignmask) & ~siop.alignmask); | ||
551 | + plaintext1 = (uint8_t *)(((unsigned long)plaintext1_raw + siop.alignmask) & ~siop.alignmask); | ||
552 | #else | ||
553 | plaintext1 = plaintext1_raw; | ||
554 | #endif | ||
555 | @@ -226,7 +227,7 @@ static int test_aes(int cfd) | ||
556 | printf("requested cipher CRYPTO_AES_CBC, got %s with driver %s\n", | ||
557 | siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
558 | |||
559 | - plaintext2 = (char *)(((unsigned long)plaintext2_raw + siop.alignmask) & ~siop.alignmask); | ||
560 | + plaintext2 = (uint8_t *)(((unsigned long)plaintext2_raw + siop.alignmask) & ~siop.alignmask); | ||
561 | #else | ||
562 | plaintext2 = plaintext2_raw; | ||
563 | #endif | ||
564 | diff --git a/tests/cipher_comp.c b/tests/cipher_comp.c | ||
565 | index b2bc5af..03f67bf 100644 | ||
566 | --- a/tests/cipher_comp.c | ||
567 | +++ b/tests/cipher_comp.c | ||
568 | @@ -24,12 +24,12 @@ | ||
569 | static int | ||
570 | test_crypto(int cfd, struct session_op *sess, int datalen) | ||
571 | { | ||
572 | - char *data, *encrypted; | ||
573 | - char *encrypted_comp; | ||
574 | + uint8_t *data, *encrypted; | ||
575 | + uint8_t *encrypted_comp; | ||
576 | |||
577 | - char iv_in[BLOCK_SIZE]; | ||
578 | - char iv[BLOCK_SIZE]; | ||
579 | - char iv_comp[BLOCK_SIZE]; | ||
580 | + uint8_t iv_in[BLOCK_SIZE]; | ||
581 | + uint8_t iv[BLOCK_SIZE]; | ||
582 | + uint8_t iv_comp[BLOCK_SIZE]; | ||
583 | |||
584 | struct crypt_op cryp; | ||
585 | |||
586 | @@ -90,7 +90,7 @@ main(int argc, char **argv) | ||
587 | { | ||
588 | int fd; | ||
589 | struct session_op sess; | ||
590 | - unsigned char key[KEY_SIZE]; | ||
591 | + uint8_t key[KEY_SIZE]; | ||
592 | int datalen = BLOCK_SIZE; | ||
593 | int datalen_end = MAX_DATALEN; | ||
594 | int i; | ||
595 | diff --git a/tests/fullspeed.c b/tests/fullspeed.c | ||
596 | index 611859d..c025130 100644 | ||
597 | --- a/tests/fullspeed.c | ||
598 | +++ b/tests/fullspeed.c | ||
599 | @@ -25,6 +25,7 @@ | ||
600 | #include <sys/types.h> | ||
601 | #include <signal.h> | ||
602 | #include <unistd.h> | ||
603 | +#include <stdint.h> | ||
604 | |||
605 | #include <crypto/cryptodev.h> | ||
606 | |||
607 | @@ -74,7 +75,7 @@ static void value2human(int si, double bytes, double time, double* data, double* | ||
608 | int encrypt_data(int algo, void* keybuf, int key_size, int fdc, int chunksize) | ||
609 | { | ||
610 | struct crypt_op cop; | ||
611 | - char *buffer, iv[32]; | ||
612 | + uint8_t *buffer, iv[32]; | ||
613 | static int val = 23; | ||
614 | struct timeval start, end; | ||
615 | double total = 0; | ||
616 | diff --git a/tests/hash_comp.c b/tests/hash_comp.c | ||
617 | index 9e700a1..e6a4346 100644 | ||
618 | --- a/tests/hash_comp.c | ||
619 | +++ b/tests/hash_comp.c | ||
620 | @@ -30,11 +30,9 @@ static void printhex(unsigned char *buf, int buflen) | ||
621 | static int | ||
622 | test_crypto(int cfd, struct session_op *sess, int datalen) | ||
623 | { | ||
624 | - unsigned char *data; | ||
625 | - | ||
626 | - unsigned char mac[AALG_MAX_RESULT_LEN]; | ||
627 | - | ||
628 | - unsigned char mac_comp[AALG_MAX_RESULT_LEN]; | ||
629 | + uint8_t *data; | ||
630 | + uint8_t mac[AALG_MAX_RESULT_LEN]; | ||
631 | + uint8_t mac_comp[AALG_MAX_RESULT_LEN]; | ||
632 | |||
633 | struct crypt_op cryp; | ||
634 | |||
635 | diff --git a/tests/hmac.c b/tests/hmac.c | ||
636 | index 1d9349e..80a2c42 100644 | ||
637 | --- a/tests/hmac.c | ||
638 | +++ b/tests/hmac.c | ||
639 | @@ -69,7 +69,7 @@ test_crypto(int cfd) | ||
640 | |||
641 | cryp.ses = sess.ses; | ||
642 | cryp.len = sizeof("what do ya want for nothing?")-1; | ||
643 | - cryp.src = "what do ya want for nothing?"; | ||
644 | + cryp.src = (uint8_t*)"what do ya want for nothing?"; | ||
645 | cryp.mac = mac; | ||
646 | cryp.op = COP_ENCRYPT; | ||
647 | if (ioctl(cfd, CIOCCRYPT, &cryp)) { | ||
648 | @@ -113,7 +113,7 @@ test_crypto(int cfd) | ||
649 | |||
650 | cryp.ses = sess.ses; | ||
651 | cryp.len = sizeof("what do ya want for nothing?")-1; | ||
652 | - cryp.src = "what do ya want for nothing?"; | ||
653 | + cryp.src = (uint8_t*)"what do ya want for nothing?"; | ||
654 | cryp.mac = mac; | ||
655 | cryp.op = COP_ENCRYPT; | ||
656 | if (ioctl(cfd, CIOCCRYPT, &cryp)) { | ||
657 | @@ -246,7 +246,7 @@ test_extras(int cfd) | ||
658 | |||
659 | cryp.ses = sess.ses; | ||
660 | cryp.len = sizeof("what do")-1; | ||
661 | - cryp.src = "what do"; | ||
662 | + cryp.src = (uint8_t*)"what do"; | ||
663 | cryp.mac = mac; | ||
664 | cryp.op = COP_ENCRYPT; | ||
665 | cryp.flags = COP_FLAG_UPDATE; | ||
666 | @@ -257,7 +257,7 @@ test_extras(int cfd) | ||
667 | |||
668 | cryp.ses = sess.ses; | ||
669 | cryp.len = sizeof(" ya want for nothing?")-1; | ||
670 | - cryp.src = " ya want for nothing?"; | ||
671 | + cryp.src = (uint8_t*)" ya want for nothing?"; | ||
672 | cryp.mac = mac; | ||
673 | cryp.op = COP_ENCRYPT; | ||
674 | cryp.flags = COP_FLAG_FINAL; | ||
675 | diff --git a/tests/speed.c b/tests/speed.c | ||
676 | index d2e1aed..0e2bbc3 100644 | ||
677 | --- a/tests/speed.c | ||
678 | +++ b/tests/speed.c | ||
679 | @@ -25,6 +25,7 @@ | ||
680 | #include <sys/types.h> | ||
681 | #include <signal.h> | ||
682 | #include <unistd.h> | ||
683 | +#include <stdint.h> | ||
684 | |||
685 | #include <crypto/cryptodev.h> | ||
686 | |||
687 | @@ -75,7 +76,7 @@ int encrypt_data(struct session_op *sess, int fdc, int chunksize, int alignmask) | ||
688 | { | ||
689 | struct crypt_op cop; | ||
690 | char *buffer, iv[32]; | ||
691 | - char mac[HASH_MAX_LEN]; | ||
692 | + uint8_t mac[HASH_MAX_LEN]; | ||
693 | static int val = 23; | ||
694 | struct timeval start, end; | ||
695 | double total = 0; | ||
696 | -- | ||
697 | 2.10.2 | ||
698 | |||
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 @@ | |||
1 | From c31ba5b149428cbbcd48fab649331a2d38003209 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Wed, 26 Oct 2016 10:47:07 +0300 | ||
4 | Subject: [PATCH 064/104] remove not used local variables | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_hmac.c | 2 -- | ||
9 | tests/async_speed.c | 5 ----- | ||
10 | tests/cipher_comp.c | 2 +- | ||
11 | tests/hash_comp.c | 5 ++--- | ||
12 | tests/hmac.c | 2 -- | ||
13 | tests/sha_speed.c | 1 - | ||
14 | 6 files changed, 3 insertions(+), 14 deletions(-) | ||
15 | |||
16 | diff --git a/tests/async_hmac.c b/tests/async_hmac.c | ||
17 | index 94a02c0..85d19c6 100644 | ||
18 | --- a/tests/async_hmac.c | ||
19 | +++ b/tests/async_hmac.c | ||
20 | @@ -185,8 +185,6 @@ test_extras(int cfd) | ||
21 | struct session_op sess; | ||
22 | struct crypt_op cryp; | ||
23 | uint8_t mac[AALG_MAX_RESULT_LEN]; | ||
24 | - uint8_t oldmac[AALG_MAX_RESULT_LEN]; | ||
25 | - uint8_t md5_hmac_out[] = "\x75\x0c\x78\x3e\x6a\xb0\xb5\x03\xea\xa8\x6e\x31\x0a\x5d\xb7\x38"; | ||
26 | uint8_t sha1_out[] = "\x8f\x82\x03\x94\xf9\x53\x35\x18\x20\x45\xda\x24\xf3\x4d\xe5\x2b\xf8\xbc\x34\x32"; | ||
27 | int i; | ||
28 | |||
29 | diff --git a/tests/async_speed.c b/tests/async_speed.c | ||
30 | index dabbbc1..f2b9772 100644 | ||
31 | --- a/tests/async_speed.c | ||
32 | +++ b/tests/async_speed.c | ||
33 | @@ -284,8 +284,6 @@ int run_null(int fdc, struct test_params tp) | ||
34 | { | ||
35 | struct session_op sess; | ||
36 | char keybuf[32]; | ||
37 | - int alignmask; | ||
38 | - int i; | ||
39 | |||
40 | fprintf(stderr, "Testing NULL cipher: \n"); | ||
41 | memset(&sess, 0, sizeof(sess)); | ||
42 | @@ -305,8 +303,6 @@ int run_aes_128_cbc(int fdc, struct test_params tp) | ||
43 | { | ||
44 | struct session_op sess; | ||
45 | char keybuf[32]; | ||
46 | - int alignmask; | ||
47 | - int i; | ||
48 | |||
49 | memset(&sess, 0, sizeof(sess)); | ||
50 | sess.cipher = CRYPTO_AES_CBC; | ||
51 | @@ -390,7 +386,6 @@ int main(int argc, char **argv) | ||
52 | { | ||
53 | int i; | ||
54 | int c; | ||
55 | - int index; | ||
56 | bool alg_flag; | ||
57 | char *alg_name; | ||
58 | struct test_params tp; | ||
59 | diff --git a/tests/cipher_comp.c b/tests/cipher_comp.c | ||
60 | index 03f67bf..dbf9977 100644 | ||
61 | --- a/tests/cipher_comp.c | ||
62 | +++ b/tests/cipher_comp.c | ||
63 | @@ -33,7 +33,7 @@ test_crypto(int cfd, struct session_op *sess, int datalen) | ||
64 | |||
65 | struct crypt_op cryp; | ||
66 | |||
67 | - int ret = 0, fail = 0; | ||
68 | + int ret = 0; | ||
69 | |||
70 | data = malloc(datalen); | ||
71 | encrypted = malloc(datalen); | ||
72 | diff --git a/tests/hash_comp.c b/tests/hash_comp.c | ||
73 | index e6a4346..73f85ed 100644 | ||
74 | --- a/tests/hash_comp.c | ||
75 | +++ b/tests/hash_comp.c | ||
76 | @@ -36,7 +36,7 @@ test_crypto(int cfd, struct session_op *sess, int datalen) | ||
77 | |||
78 | struct crypt_op cryp; | ||
79 | |||
80 | - int ret = 0, fail = 0; | ||
81 | + int ret = 0; | ||
82 | |||
83 | data = malloc(datalen); | ||
84 | memset(data, datalen & 0xff, datalen); | ||
85 | @@ -66,7 +66,7 @@ test_crypto(int cfd, struct session_op *sess, int datalen) | ||
86 | |||
87 | if (memcmp(mac, mac_comp, AALG_MAX_RESULT_LEN)) { | ||
88 | printf("fail for datalen %d, MACs do not match!\n", datalen); | ||
89 | - fail = 1; | ||
90 | + ret = 1; | ||
91 | printf("wrong mac: "); | ||
92 | printhex(mac, 20); | ||
93 | printf("right mac: "); | ||
94 | @@ -88,7 +88,6 @@ main(int argc, char **argv) | ||
95 | struct session_op sess; | ||
96 | int datalen = BLOCK_SIZE; | ||
97 | int datalen_end = MAX_DATALEN; | ||
98 | - int i; | ||
99 | |||
100 | if (argc > 1) { | ||
101 | datalen = min(max(atoi(argv[1]), BLOCK_SIZE), MAX_DATALEN); | ||
102 | diff --git a/tests/hmac.c b/tests/hmac.c | ||
103 | index 80a2c42..3b248f3 100644 | ||
104 | --- a/tests/hmac.c | ||
105 | +++ b/tests/hmac.c | ||
106 | @@ -212,8 +212,6 @@ test_extras(int cfd) | ||
107 | #endif | ||
108 | struct crypt_op cryp; | ||
109 | uint8_t mac[AALG_MAX_RESULT_LEN]; | ||
110 | - uint8_t oldmac[AALG_MAX_RESULT_LEN]; | ||
111 | - uint8_t md5_hmac_out[] = "\x75\x0c\x78\x3e\x6a\xb0\xb5\x03\xea\xa8\x6e\x31\x0a\x5d\xb7\x38"; | ||
112 | uint8_t sha1_out[] = "\x8f\x82\x03\x94\xf9\x53\x35\x18\x20\x45\xda\x24\xf3\x4d\xe5\x2b\xf8\xbc\x34\x32"; | ||
113 | int i; | ||
114 | |||
115 | diff --git a/tests/sha_speed.c b/tests/sha_speed.c | ||
116 | index e5c6efe..9f2c8cc 100644 | ||
117 | --- a/tests/sha_speed.c | ||
118 | +++ b/tests/sha_speed.c | ||
119 | @@ -296,7 +296,6 @@ int main(void) | ||
120 | int fd; | ||
121 | int fdc; | ||
122 | int err; | ||
123 | - int i; | ||
124 | struct session_op sess; | ||
125 | |||
126 | signal(SIGALRM, alarm_handler); | ||
127 | -- | ||
128 | 2.10.2 | ||
129 | |||
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 @@ | |||
1 | From 58da37b93d2532e489514b810c63d735a165ff09 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Wed, 26 Oct 2016 10:47:58 +0300 | ||
4 | Subject: [PATCH 065/104] return error code of the test if there is one | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed.c | 15 +++++++++++---- | ||
9 | 1 file changed, 11 insertions(+), 4 deletions(-) | ||
10 | |||
11 | diff --git a/tests/async_speed.c b/tests/async_speed.c | ||
12 | index f2b9772..d843c02 100644 | ||
13 | --- a/tests/async_speed.c | ||
14 | +++ b/tests/async_speed.c | ||
15 | @@ -239,6 +239,7 @@ int run_test(int id, struct test_params tp) | ||
16 | { | ||
17 | int fd; | ||
18 | int fdc; | ||
19 | + int err; | ||
20 | |||
21 | fd = open("/dev/crypto", O_RDWR, 0); | ||
22 | if (fd < 0) { | ||
23 | @@ -253,10 +254,12 @@ int run_test(int id, struct test_params tp) | ||
24 | if (!tp.mflag) { | ||
25 | fprintf(stderr, "Testing %s:\n", ciphers[id].name); | ||
26 | } | ||
27 | - ciphers[id].func(fdc, tp); | ||
28 | + err = ciphers[id].func(fdc, tp); | ||
29 | |||
30 | close(fdc); | ||
31 | close(fd); | ||
32 | + | ||
33 | + return err; | ||
34 | } | ||
35 | |||
36 | void do_test_vectors(int fdc, struct test_params tp, struct session_op *sess) | ||
37 | @@ -384,6 +387,7 @@ int run_sha256(int fdc, struct test_params tp) | ||
38 | |||
39 | int main(int argc, char **argv) | ||
40 | { | ||
41 | + int err = 0; | ||
42 | int i; | ||
43 | int c; | ||
44 | bool alg_flag; | ||
45 | @@ -436,14 +440,17 @@ int main(int argc, char **argv) | ||
46 | |||
47 | if (alg_flag) { | ||
48 | if (strcmp(alg_name, ciphers[i].name) == 0) { | ||
49 | - run_test(i, tp); | ||
50 | + err = run_test(i, tp); | ||
51 | } | ||
52 | } else { | ||
53 | - run_test(i, tp); | ||
54 | + err = run_test(i, tp); | ||
55 | + if (err != 0) { | ||
56 | + break; | ||
57 | + } | ||
58 | } | ||
59 | } | ||
60 | |||
61 | - return 0; | ||
62 | + return err; | ||
63 | } | ||
64 | |||
65 | #else | ||
66 | -- | ||
67 | 2.10.2 | ||
68 | |||
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 @@ | |||
1 | From af792c280ec5d76f473487cd1ed9335a6ec534de Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Wed, 26 Oct 2016 10:49:36 +0300 | ||
4 | Subject: [PATCH 066/104] do more strict code checking to avoid maintenance | ||
5 | issues | ||
6 | |||
7 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
8 | --- | ||
9 | tests/Makefile | 2 +- | ||
10 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
11 | |||
12 | diff --git a/tests/Makefile b/tests/Makefile | ||
13 | index 14ae2c7..a27cf9b 100644 | ||
14 | --- a/tests/Makefile | ||
15 | +++ b/tests/Makefile | ||
16 | @@ -1,5 +1,5 @@ | ||
17 | KERNEL_DIR ?= /lib/modules/$(shell uname -r)/build | ||
18 | -CRYPTODEV_CFLAGS += -DENABLE_ASYNC -Wimplicit-function-declaration | ||
19 | +CRYPTODEV_CFLAGS += -DENABLE_ASYNC -Wall -Werror | ||
20 | KBUILD_CFLAGS += -I.. $(CRYPTODEV_CFLAGS) | ||
21 | CFLAGS += -I.. $(CRYPTODEV_CFLAGS) | ||
22 | |||
23 | -- | ||
24 | 2.10.2 | ||
25 | |||
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 @@ | |||
1 | From bd36f9cda9fb5eeebec23cc966a81e93b4fa8bf7 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Wed, 26 Oct 2016 12:53:11 +0300 | ||
4 | Subject: [PATCH 067/104] fix issues with install target | ||
5 | |||
6 | Aparently, on some setups, 'sudo make' will clear the $PWD variable | ||
7 | on the first Makefile expansion. This leads to failures of "sudo make | ||
8 | install" or other issues when trying to preserve the environment with | ||
9 | sudo -E. | ||
10 | |||
11 | There are two solutions to this problem: | ||
12 | 1) Use $$PWD instead of $(PWD) to render `$PWD` as the actual string to | ||
13 | be used on the secondary Makefile expansion. | ||
14 | This is used (albeit inconsistently) in the Linux kernel guide for | ||
15 | external modules: | ||
16 | kernel https://www.kernel.org/doc/Documentation/kbuild/modules.txt | ||
17 | |||
18 | 2) A second solution is based on GNU make which sets CURDIR to the | ||
19 | pathname of current working directory. This variable is never touched | ||
20 | again by make. | ||
21 | This solution is choosen for it is just as clear as the PWD one would | ||
22 | have been had it worked in the first place. | ||
23 | |||
24 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
25 | |||
26 | |||
27 | |||
28 | --- a/Makefileold 2017-04-18 13:55:30.740561749 +0800 | ||
29 | +++ b/Makefile 2017-04-18 13:58:04.348556431 +0800 | ||
30 | @@ -15,7 +15,7 @@ | ||
31 | |||
32 | obj-m += cryptodev.o | ||
33 | |||
34 | -KERNEL_MAKE_OPTS := -C $(KERNEL_DIR) M=$(PWD) | ||
35 | +KERNEL_MAKE_OPTS := -C $(KERNEL_DIR) M=$(CURDIR) | ||
36 | ifneq ($(ARCH),) | ||
37 | KERNEL_MAKE_OPTS += ARCH=$(ARCH) | ||
38 | endif | ||
39 | @@ -32,11 +32,11 @@ | ||
40 | install: modules_install | ||
41 | |||
42 | modules_install: | ||
43 | - $(MAKE) -C $(KERNEL_DIR) M=$(PWD) modules_install | ||
44 | + $(MAKE) $(KERNEL_MAKE_OPTS) modules_install | ||
45 | install -m 644 -D crypto/cryptodev.h $(DESTDIR)/$(includedir)/crypto/cryptodev.h | ||
46 | |||
47 | clean: | ||
48 | - $(MAKE) -C $(KERNEL_DIR) M=$(PWD) clean | ||
49 | + $(MAKE) $(KERNEL_MAKE_OPTS) clean | ||
50 | rm -f $(hostprogs) *~ | ||
51 | CFLAGS=$(CRYPTODEV_CFLAGS) KERNEL_DIR=$(KERNEL_DIR) $(MAKE) -C tests clean | ||
52 | |||
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 @@ | |||
1 | From 39f0c5ae656f4b487a0950235e2371e4dd840594 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Wed, 26 Oct 2016 13:11:11 +0300 | ||
4 | Subject: [PATCH 068/104] setting KERNEL_DIR is not necessary to build tests | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/Makefile | 2 -- | ||
9 | 1 file changed, 2 deletions(-) | ||
10 | |||
11 | diff --git a/tests/Makefile b/tests/Makefile | ||
12 | index a27cf9b..e7a60cb 100644 | ||
13 | --- a/tests/Makefile | ||
14 | +++ b/tests/Makefile | ||
15 | @@ -1,6 +1,4 @@ | ||
16 | -KERNEL_DIR ?= /lib/modules/$(shell uname -r)/build | ||
17 | CRYPTODEV_CFLAGS += -DENABLE_ASYNC -Wall -Werror | ||
18 | -KBUILD_CFLAGS += -I.. $(CRYPTODEV_CFLAGS) | ||
19 | CFLAGS += -I.. $(CRYPTODEV_CFLAGS) | ||
20 | |||
21 | comp_progs := cipher_comp hash_comp hmac_comp | ||
22 | -- | ||
23 | 2.10.2 | ||
24 | |||
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 @@ | |||
1 | From 99ce54741ccbbe8581ab83b73ab11d2dae4f01b1 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Wed, 26 Oct 2016 14:55:28 +0300 | ||
4 | Subject: [PATCH 069/104] fix the reported unit | ||
5 | |||
6 | 1GiB = 1024*1024*1024 | ||
7 | 1GB = 1000000000 | ||
8 | |||
9 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
10 | --- | ||
11 | tests/async_speed_multi.sh | 2 +- | ||
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
13 | |||
14 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
15 | index 331158b..bf5f1c6 100755 | ||
16 | --- a/tests/async_speed_multi.sh | ||
17 | +++ b/tests/async_speed_multi.sh | ||
18 | @@ -93,7 +93,7 @@ function run_parallel | ||
19 | echo | ||
20 | echo "buffer size : $nvalue" | ||
21 | echo "running time : $runtime" | ||
22 | - echo "avg_speed : $avg_speed GiB/s" | ||
23 | + echo "avg_speed : $avg_speed GB/s" | ||
24 | echo "all_cpu idle : $cpu_idle %" | ||
25 | echo | ||
26 | } | ||
27 | -- | ||
28 | 2.10.2 | ||
29 | |||
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 @@ | |||
1 | From 73748415251dbf3d6e3fc9531e38b8e61ff63e20 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Wed, 26 Oct 2016 15:09:04 +0300 | ||
4 | Subject: [PATCH 070/104] remove old results to avoid incorrect reports | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed_multi.sh | 3 +++ | ||
9 | 1 file changed, 3 insertions(+) | ||
10 | |||
11 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
12 | index bf5f1c6..10b2348 100755 | ||
13 | --- a/tests/async_speed_multi.sh | ||
14 | +++ b/tests/async_speed_multi.sh | ||
15 | @@ -108,6 +108,9 @@ function main | ||
16 | { | ||
17 | [ ! -e "/dev/crypto" ] && sudo modprobe cryptodev || modprobe cryptodev || exit 1 | ||
18 | |||
19 | + rm -f ${OUT_BASENAME}_* | ||
20 | + rm -f ${MPSTAT_OUT} | ||
21 | + | ||
22 | while getopts hm:t:n: option | ||
23 | do | ||
24 | case "$option" in | ||
25 | -- | ||
26 | 2.10.2 | ||
27 | |||
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 @@ | |||
1 | From d9de6a0f342b2291e2f2d82b594fbb3b8ed7f468 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Thu, 27 Oct 2016 09:29:24 +0300 | ||
4 | Subject: [PATCH 071/104] fix the scale of the runtime value | ||
5 | |||
6 | Subtraction operation does not honor the scale variable. Only | ||
7 | division does. | ||
8 | |||
9 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
10 | --- | ||
11 | tests/async_speed_multi.sh | 2 +- | ||
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
13 | |||
14 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
15 | index 10b2348..659be0e 100755 | ||
16 | --- a/tests/async_speed_multi.sh | ||
17 | +++ b/tests/async_speed_multi.sh | ||
18 | @@ -85,7 +85,7 @@ function run_parallel | ||
19 | |||
20 | wait $MPSTAT_PID | ||
21 | |||
22 | - runtime=$(echo "scale=2; $end - $start" | bc -l ) | ||
23 | + runtime=$(echo "scale=2; ($end - $start) / 1" | bc -l ) | ||
24 | total_data=`cat ${OUT_BASENAME}_* | cut -f 1 | SUM` | ||
25 | avg_speed=$(echo "scale=2; $total_data / $runtime / 1000000000" | bc -l) | ||
26 | cpu_idle=`get_cpu_idle` | ||
27 | -- | ||
28 | 2.10.2 | ||
29 | |||
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 @@ | |||
1 | From abcf5983f6d69c5ff35e77fb79ea7afe2149411a Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Thu, 27 Oct 2016 09:33:11 +0300 | ||
4 | Subject: [PATCH 072/104] use $(...) instead of `...` for consistency | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed_multi.sh | 24 ++++++++++++------------ | ||
9 | 1 file changed, 12 insertions(+), 12 deletions(-) | ||
10 | |||
11 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
12 | index 659be0e..e10dc0d 100755 | ||
13 | --- a/tests/async_speed_multi.sh | ||
14 | +++ b/tests/async_speed_multi.sh | ||
15 | @@ -19,7 +19,7 @@ | ||
16 | |||
17 | # no user-configurable options below this line | ||
18 | |||
19 | -NUM_CORES=`nproc` | ||
20 | +NUM_CORES=$(nproc) | ||
21 | OUT_BASENAME="async_speed" | ||
22 | S_TIME_FORMAT=ISO | ||
23 | MPSTAT_OUT="mpstat_out" | ||
24 | @@ -44,9 +44,9 @@ function SUM { | ||
25 | |||
26 | function get_cpu_idle | ||
27 | { | ||
28 | - header_line=`grep %idle ${MPSTAT_OUT} | head -n 1 | sed 's/\s\+/ /g'` | ||
29 | - idle_column=`echo $header_line | wc -w` | ||
30 | - average_idle=`grep Average ${MPSTAT_OUT} | sed 's/\s\+/ /g' | cut -d' ' -f ${idle_column} | tail -n 1` | ||
31 | + header_line=$(grep %idle ${MPSTAT_OUT} | head -n 1 | sed 's/\s\+/ /g') | ||
32 | + idle_column=$(echo $header_line | wc -w) | ||
33 | + average_idle=$(grep Average ${MPSTAT_OUT} | sed 's/\s\+/ /g' | cut -d' ' -f ${idle_column} | tail -n 1) | ||
34 | |||
35 | echo $average_idle | ||
36 | } | ||
37 | @@ -66,9 +66,9 @@ function run_parallel | ||
38 | MPSTAT_PID=$! | ||
39 | |||
40 | PIDS="" | ||
41 | - start=`date +%s.%N` | ||
42 | + start=$(date +%s.%N) | ||
43 | |||
44 | - for i in `seq 0 $(($mvalue-1))` | ||
45 | + for i in $(seq 0 $(($mvalue-1))) | ||
46 | do | ||
47 | CMD_OUT="${OUT_BASENAME}_${i}" | ||
48 | |||
49 | @@ -81,14 +81,14 @@ function run_parallel | ||
50 | done | ||
51 | |||
52 | wait $PIDS | ||
53 | - end=`date +%s.%N` | ||
54 | + end=$(date +%s.%N) | ||
55 | |||
56 | wait $MPSTAT_PID | ||
57 | |||
58 | runtime=$(echo "scale=2; ($end - $start) / 1" | bc -l ) | ||
59 | - total_data=`cat ${OUT_BASENAME}_* | cut -f 1 | SUM` | ||
60 | + total_data=$(cat ${OUT_BASENAME}_* | cut -f 1 | SUM) | ||
61 | avg_speed=$(echo "scale=2; $total_data / $runtime / 1000000000" | bc -l) | ||
62 | - cpu_idle=`get_cpu_idle` | ||
63 | + cpu_idle=$(get_cpu_idle) | ||
64 | |||
65 | echo | ||
66 | echo "buffer size : $nvalue" | ||
67 | @@ -124,9 +124,9 @@ function main | ||
68 | shift $((OPTIND-1)) | ||
69 | alg_name=$1 | ||
70 | |||
71 | - [ -z "$tvalue" ] && tvalue=10 # 10 seconds per test by default | ||
72 | - [ -z "$mvalue" ] && mvalue=`nproc` # thread count defaults to nproc | ||
73 | - [ -z "$nvalue" ] && nvalue=256 # 256 bytes default buffer size | ||
74 | + [ -z "$tvalue" ] && tvalue=10 # 10 seconds per test by default | ||
75 | + [ -z "$mvalue" ] && mvalue=$NUM_CORES # thread count defaults to nproc | ||
76 | + [ -z "$nvalue" ] && nvalue=256 # 256 bytes default buffer size | ||
77 | |||
78 | [ "$tvalue" -lt 5 ] && tvalue=5 | ||
79 | |||
80 | -- | ||
81 | 2.10.2 | ||
82 | |||
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 @@ | |||
1 | From 787cbdf6b032964df00c4379d9a81ba4384a492e Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Thu, 27 Oct 2016 10:06:08 +0300 | ||
4 | Subject: [PATCH 073/104] really fix (again...) the mpstat issue | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed_multi.sh | 3 +-- | ||
9 | 1 file changed, 1 insertion(+), 2 deletions(-) | ||
10 | |||
11 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
12 | index e10dc0d..22a12cb 100755 | ||
13 | --- a/tests/async_speed_multi.sh | ||
14 | +++ b/tests/async_speed_multi.sh | ||
15 | @@ -21,7 +21,6 @@ | ||
16 | |||
17 | NUM_CORES=$(nproc) | ||
18 | OUT_BASENAME="async_speed" | ||
19 | -S_TIME_FORMAT=ISO | ||
20 | MPSTAT_OUT="mpstat_out" | ||
21 | |||
22 | function usage | ||
23 | @@ -62,7 +61,7 @@ function run_parallel | ||
24 | echo "Running $tvalue seconds $mvalue threads in parallel:" | ||
25 | echo " $CMD" | ||
26 | |||
27 | - (sleep 1; mpstat 1 $(($tvalue-2))) &> $MPSTAT_OUT & | ||
28 | + (sleep 1; S_TIME_FORMAT=ISO mpstat 1 $(($tvalue-2))) &> $MPSTAT_OUT & | ||
29 | MPSTAT_PID=$! | ||
30 | |||
31 | PIDS="" | ||
32 | -- | ||
33 | 2.10.2 | ||
34 | |||
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 @@ | |||
1 | From 826f2feb22f5391e985930af40782b2fb980e028 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Thu, 27 Oct 2016 10:12:25 +0300 | ||
4 | Subject: [PATCH 074/104] make default output tabular | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed_multi.sh | 33 +++++++++++++++++++++++---------- | ||
9 | 1 file changed, 23 insertions(+), 10 deletions(-) | ||
10 | |||
11 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
12 | index 22a12cb..b509c25 100755 | ||
13 | --- a/tests/async_speed_multi.sh | ||
14 | +++ b/tests/async_speed_multi.sh | ||
15 | @@ -31,6 +31,7 @@ Usage: `basename $0` [OPTIONS] <alg_name> | ||
16 | -m <threads> number of threads to run with (defaults to number of cores) | ||
17 | -t <secs> time to run each test (default 10 secs) | ||
18 | -n <bytes> size of the test buffer (default 256 bytes) | ||
19 | + -v make output more verbose (default tabular) | ||
20 | -h show this help | ||
21 | |||
22 | alg_name: null, aes-128-cbc, aes-256-xts, sha1, sha256, crc32c | ||
23 | @@ -57,9 +58,12 @@ function run_parallel | ||
24 | OPTIONS="-t $tvalue -n $nvalue -m" | ||
25 | CMD="async_speed $OPTIONS $alg_name" | ||
26 | |||
27 | - echo | ||
28 | - echo "Running $tvalue seconds $mvalue threads in parallel:" | ||
29 | - echo " $CMD" | ||
30 | + if [ ! -z "$vvalue" ] | ||
31 | + then | ||
32 | + echo | ||
33 | + echo "Running $tvalue seconds $mvalue threads in parallel:" | ||
34 | + echo " $CMD" | ||
35 | + fi | ||
36 | |||
37 | (sleep 1; S_TIME_FORMAT=ISO mpstat 1 $(($tvalue-2))) &> $MPSTAT_OUT & | ||
38 | MPSTAT_PID=$! | ||
39 | @@ -89,12 +93,20 @@ function run_parallel | ||
40 | avg_speed=$(echo "scale=2; $total_data / $runtime / 1000000000" | bc -l) | ||
41 | cpu_idle=$(get_cpu_idle) | ||
42 | |||
43 | - echo | ||
44 | - echo "buffer size : $nvalue" | ||
45 | - echo "running time : $runtime" | ||
46 | - echo "avg_speed : $avg_speed GB/s" | ||
47 | - echo "all_cpu idle : $cpu_idle %" | ||
48 | - echo | ||
49 | + if [ ! -z "$vvalue" ] | ||
50 | + then | ||
51 | + echo | ||
52 | + echo "buffer size : $nvalue" | ||
53 | + echo "running time : $runtime" | ||
54 | + echo "avg_speed : $avg_speed GB/s" | ||
55 | + echo "all_cpu idle : $cpu_idle %" | ||
56 | + echo | ||
57 | + else | ||
58 | + echo -e "algorithm\t""threads\t""runtime\t"\ | ||
59 | + "buf_size\t""GB/s\t""%cpu_idle" | ||
60 | + echo -e "${alg_name}\t${mvalue}\t${runtime}\t"\ | ||
61 | + "${nvalue}\t${avg_speed}\t${cpu_idle}" | ||
62 | + fi | ||
63 | } | ||
64 | |||
65 | function control_c | ||
66 | @@ -110,12 +122,13 @@ function main | ||
67 | rm -f ${OUT_BASENAME}_* | ||
68 | rm -f ${MPSTAT_OUT} | ||
69 | |||
70 | - while getopts hm:t:n: option | ||
71 | + while getopts vhm:t:n: option | ||
72 | do | ||
73 | case "$option" in | ||
74 | m) mvalue="$OPTARG";; | ||
75 | t) tvalue="$OPTARG";; | ||
76 | n) nvalue="$OPTARG";; | ||
77 | + v) vvalue="verbose";; | ||
78 | *) usage $0; exit 1;; | ||
79 | esac | ||
80 | done | ||
81 | -- | ||
82 | 2.10.2 | ||
83 | |||
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 @@ | |||
1 | From fbf88220797a95281457680a18e9241b3af1f3fb Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Thu, 27 Oct 2016 10:27:16 +0300 | ||
4 | Subject: [PATCH 075/104] fix incorrect handling of error cases... | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed_multi.sh | 3 ++- | ||
9 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
10 | |||
11 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
12 | index b509c25..862f39d 100755 | ||
13 | --- a/tests/async_speed_multi.sh | ||
14 | +++ b/tests/async_speed_multi.sh | ||
15 | @@ -117,7 +117,8 @@ function control_c | ||
16 | |||
17 | function main | ||
18 | { | ||
19 | - [ ! -e "/dev/crypto" ] && sudo modprobe cryptodev || modprobe cryptodev || exit 1 | ||
20 | + [ ! -e "/dev/crypto" ] && | ||
21 | + (sudo modprobe cryptodev || modprobe cryptodev || exit 1) | ||
22 | |||
23 | rm -f ${OUT_BASENAME}_* | ||
24 | rm -f ${MPSTAT_OUT} | ||
25 | -- | ||
26 | 2.10.2 | ||
27 | |||
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 @@ | |||
1 | From 87214642cbfc6dbd43948940b5d1ce9528f451bd Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Thu, 27 Oct 2016 10:46:01 +0300 | ||
4 | Subject: [PATCH 076/104] exit early if cryptodev tests are not installed | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed_multi.sh | 10 +++++++++- | ||
9 | 1 file changed, 9 insertions(+), 1 deletion(-) | ||
10 | |||
11 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
12 | index 862f39d..62c4759 100755 | ||
13 | --- a/tests/async_speed_multi.sh | ||
14 | +++ b/tests/async_speed_multi.sh | ||
15 | @@ -20,6 +20,7 @@ | ||
16 | # no user-configurable options below this line | ||
17 | |||
18 | NUM_CORES=$(nproc) | ||
19 | +CMD_BIN="async_speed" | ||
20 | OUT_BASENAME="async_speed" | ||
21 | MPSTAT_OUT="mpstat_out" | ||
22 | |||
23 | @@ -56,7 +57,7 @@ function run_parallel | ||
24 | trap control_c SIGINT | ||
25 | |||
26 | OPTIONS="-t $tvalue -n $nvalue -m" | ||
27 | - CMD="async_speed $OPTIONS $alg_name" | ||
28 | + CMD="$CMD_BIN $OPTIONS $alg_name" | ||
29 | |||
30 | if [ ! -z "$vvalue" ] | ||
31 | then | ||
32 | @@ -120,6 +121,13 @@ function main | ||
33 | [ ! -e "/dev/crypto" ] && | ||
34 | (sudo modprobe cryptodev || modprobe cryptodev || exit 1) | ||
35 | |||
36 | + $(which ${CMD_BIN} &> /dev/null) | ||
37 | + if (($? != 0)) | ||
38 | + then | ||
39 | + echo "${CMD_BIN} test is not installed" | ||
40 | + exit 1 | ||
41 | + fi | ||
42 | + | ||
43 | rm -f ${OUT_BASENAME}_* | ||
44 | rm -f ${MPSTAT_OUT} | ||
45 | |||
46 | -- | ||
47 | 2.10.2 | ||
48 | |||
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 @@ | |||
1 | From 76de6db1bc69b2239d8fb91fd65b74610cb8e22f Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Thu, 27 Oct 2016 16:41:10 +0300 | ||
4 | Subject: [PATCH 077/104] the C standard used by cryptodev is C90 with GNU | ||
5 | extensions | ||
6 | |||
7 | This avoids some problems with gcc>=5.0 which chaged the default to C11. | ||
8 | The choice for gnu90 is based on the C standard used by Linux kernel which | ||
9 | is gnu90 as well. | ||
10 | |||
11 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
12 | --- | ||
13 | Makefile | 6 +++--- | ||
14 | lib/Makefile | 2 +- | ||
15 | tests/Makefile | 2 +- | ||
16 | 3 files changed, 5 insertions(+), 5 deletions(-) | ||
17 | |||
18 | diff --git a/Makefile b/Makefile | ||
19 | index 90e86d9..80439f6 100644 | ||
20 | --- a/Makefile | ||
21 | +++ b/Makefile | ||
22 | @@ -3,7 +3,7 @@ | ||
23 | # disabled by default. To re-enable it uncomment the | ||
24 | # corresponding CFLAG. | ||
25 | # | ||
26 | -CRYPTODEV_CFLAGS += -DENABLE_ASYNC | ||
27 | +CRYPTODEV_CFLAGS += -DENABLE_ASYNC -std=gnu90 | ||
28 | KBUILD_CFLAGS += -I$(src) $(CRYPTODEV_CFLAGS) | ||
29 | KERNEL_DIR ?= /lib/modules/$(shell uname -r)/build | ||
30 | VERSION = 1.8 | ||
31 | @@ -38,10 +38,10 @@ modules_install: | ||
32 | clean: | ||
33 | $(MAKE) $(KERNEL_MAKE_OPTS) clean | ||
34 | rm -f $(hostprogs) *~ | ||
35 | - CFLAGS=$(CRYPTODEV_CFLAGS) KERNEL_DIR=$(KERNEL_DIR) $(MAKE) -C tests clean | ||
36 | + CFLAGS="$(CRYPTODEV_CFLAGS)" KERNEL_DIR="$(KERNEL_DIR)" $(MAKE) -C tests clean | ||
37 | |||
38 | check: | ||
39 | - CFLAGS=$(CRYPTODEV_CFLAGS) KERNEL_DIR=$(KERNEL_DIR) $(MAKE) -C tests check | ||
40 | + CFLAGS="$(CRYPTODEV_CFLAGS)" KERNEL_DIR="$(KERNEL_DIR)" $(MAKE) -C tests check | ||
41 | |||
42 | testprogs: | ||
43 | KERNEL_DIR=$(KERNEL_DIR) $(MAKE) -C tests all | ||
44 | diff --git a/lib/Makefile b/lib/Makefile | ||
45 | index 3bedc34..0044613 100644 | ||
46 | --- a/lib/Makefile | ||
47 | +++ b/lib/Makefile | ||
48 | @@ -1,4 +1,4 @@ | ||
49 | -CFLAGS=-g -O2 -Wall | ||
50 | +CFLAGS=-g -O2 -Wall -std=gnu90 | ||
51 | |||
52 | all: benchmark | ||
53 | |||
54 | diff --git a/tests/Makefile b/tests/Makefile | ||
55 | index e7a60cb..23d67f9 100644 | ||
56 | --- a/tests/Makefile | ||
57 | +++ b/tests/Makefile | ||
58 | @@ -1,4 +1,4 @@ | ||
59 | -CRYPTODEV_CFLAGS += -DENABLE_ASYNC -Wall -Werror | ||
60 | +CRYPTODEV_CFLAGS += -DENABLE_ASYNC -std=gnu90 -Wall -Werror | ||
61 | CFLAGS += -I.. $(CRYPTODEV_CFLAGS) | ||
62 | |||
63 | comp_progs := cipher_comp hash_comp hmac_comp | ||
64 | -- | ||
65 | 2.10.2 | ||
66 | |||
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 @@ | |||
1 | From 0bd3dada58288792f587712c95a1f125a7655535 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Fri, 28 Oct 2016 09:05:26 +0300 | ||
4 | Subject: [PATCH 078/104] remove output line because it does not add clarity to | ||
5 | the results | ||
6 | |||
7 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
8 | --- | ||
9 | tests/async_speed_multi.sh | 7 ------- | ||
10 | 1 file changed, 7 deletions(-) | ||
11 | |||
12 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
13 | index 62c4759..991e190 100755 | ||
14 | --- a/tests/async_speed_multi.sh | ||
15 | +++ b/tests/async_speed_multi.sh | ||
16 | @@ -59,13 +59,6 @@ function run_parallel | ||
17 | OPTIONS="-t $tvalue -n $nvalue -m" | ||
18 | CMD="$CMD_BIN $OPTIONS $alg_name" | ||
19 | |||
20 | - if [ ! -z "$vvalue" ] | ||
21 | - then | ||
22 | - echo | ||
23 | - echo "Running $tvalue seconds $mvalue threads in parallel:" | ||
24 | - echo " $CMD" | ||
25 | - fi | ||
26 | - | ||
27 | (sleep 1; S_TIME_FORMAT=ISO mpstat 1 $(($tvalue-2))) &> $MPSTAT_OUT & | ||
28 | MPSTAT_PID=$! | ||
29 | |||
30 | -- | ||
31 | 2.10.2 | ||
32 | |||
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 @@ | |||
1 | From 9c8d7ce749931de6c7604b3b8be44d4a17bcd7d1 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Fri, 28 Oct 2016 09:11:13 +0300 | ||
4 | Subject: [PATCH 079/104] fix typo, use consistent spacing | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed_multi.sh | 4 ++-- | ||
9 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
10 | |||
11 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
12 | index 991e190..125d45c 100755 | ||
13 | --- a/tests/async_speed_multi.sh | ||
14 | +++ b/tests/async_speed_multi.sh | ||
15 | @@ -96,8 +96,8 @@ function run_parallel | ||
16 | echo "all_cpu idle : $cpu_idle %" | ||
17 | echo | ||
18 | else | ||
19 | - echo -e "algorithm\t""threads\t""runtime\t"\ | ||
20 | - "buf_size\t""GB/s\t""%cpu_idle" | ||
21 | + echo -e "algorithm\t""threads\t""run time\t"\ | ||
22 | + "buffer size\t""GB/s\t""%cpu idle" | ||
23 | echo -e "${alg_name}\t${mvalue}\t${runtime}\t"\ | ||
24 | "${nvalue}\t${avg_speed}\t${cpu_idle}" | ||
25 | fi | ||
26 | -- | ||
27 | 2.10.2 | ||
28 | |||
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 @@ | |||
1 | From 9a486f5ebf648971db9bdbd30f7e52251a659ddd Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Fri, 28 Oct 2016 12:01:00 +0300 | ||
4 | Subject: [PATCH 080/104] graceful exit if cryptodev is not built with ASYNC | ||
5 | flags | ||
6 | |||
7 | --- | ||
8 | tests/async_speed_multi.sh | 7 +++++++ | ||
9 | 1 file changed, 7 insertions(+) | ||
10 | |||
11 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
12 | index 125d45c..f2a8ba6 100755 | ||
13 | --- a/tests/async_speed_multi.sh | ||
14 | +++ b/tests/async_speed_multi.sh | ||
15 | @@ -82,6 +82,13 @@ function run_parallel | ||
16 | |||
17 | wait $MPSTAT_PID | ||
18 | |||
19 | + grep "ioctl" ${OUT_BASENAME}_* &> /dev/null | ||
20 | + if (($? == 0)) | ||
21 | + then | ||
22 | + echo "cryptodev is not built with -DENABLE_ASYNC flag" | ||
23 | + exit 1 | ||
24 | + fi | ||
25 | + | ||
26 | runtime=$(echo "scale=2; ($end - $start) / 1" | bc -l ) | ||
27 | total_data=$(cat ${OUT_BASENAME}_* | cut -f 1 | SUM) | ||
28 | avg_speed=$(echo "scale=2; $total_data / $runtime / 1000000000" | bc -l) | ||
29 | -- | ||
30 | 2.10.2 | ||
31 | |||
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 @@ | |||
1 | From b13160357e683b9d42ba513433b4c09456a8332b Mon Sep 17 00:00:00 2001 | ||
2 | From: Alexe Radu <radu.alexe@nxp.com> | ||
3 | Date: Fri, 28 Oct 2016 13:39:50 +0300 | ||
4 | Subject: [PATCH 081/104] add sync speed tests with the same format as async | ||
5 | ones | ||
6 | |||
7 | The file speed.c was removed because has the same functionality | ||
8 | as sync_speed.c | ||
9 | |||
10 | Signed-off-by: Alexe Radu <radu.alexe@nxp.com> | ||
11 | --- | ||
12 | tests/Makefile | 4 +- | ||
13 | tests/speed.c | 265 ----------------------------------- | ||
14 | tests/sync_speed.c | 399 +++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
15 | 3 files changed, 401 insertions(+), 267 deletions(-) | ||
16 | delete mode 100644 tests/speed.c | ||
17 | create mode 100644 tests/sync_speed.c | ||
18 | |||
19 | diff --git a/tests/Makefile b/tests/Makefile | ||
20 | index 23d67f9..400fb7a 100644 | ||
21 | --- a/tests/Makefile | ||
22 | +++ b/tests/Makefile | ||
23 | @@ -3,14 +3,14 @@ CFLAGS += -I.. $(CRYPTODEV_CFLAGS) | ||
24 | |||
25 | comp_progs := cipher_comp hash_comp hmac_comp | ||
26 | |||
27 | -hostprogs := cipher cipher-aead hmac speed async_cipher async_hmac \ | ||
28 | +hostprogs := cipher cipher-aead hmac sync_speed async_cipher async_hmac \ | ||
29 | async_speed sha_speed hashcrypt_speed fullspeed cipher-gcm \ | ||
30 | cipher-aead-srtp $(comp_progs) | ||
31 | |||
32 | example-cipher-objs := cipher.o | ||
33 | example-cipher-aead-objs := cipher-aead.o | ||
34 | example-hmac-objs := hmac.o | ||
35 | -example-speed-objs := speed.c | ||
36 | +example-speed-objs := sync_speed.o | ||
37 | example-fullspeed-objs := fullspeed.c | ||
38 | example-sha-speed-objs := sha_speed.c | ||
39 | example-async-cipher-objs := async_cipher.o | ||
40 | diff --git a/tests/speed.c b/tests/speed.c | ||
41 | deleted file mode 100644 | ||
42 | index 0e2bbc3..0000000 | ||
43 | --- a/tests/speed.c | ||
44 | +++ /dev/null | ||
45 | @@ -1,265 +0,0 @@ | ||
46 | -/* cryptodev_test - simple benchmark tool for cryptodev | ||
47 | - * | ||
48 | - * Copyright (C) 2010 by Phil Sutter <phil.sutter@viprinet.com> | ||
49 | - * | ||
50 | - * This program is free software; you can redistribute it and/or modify | ||
51 | - * it under the terms of the GNU General Public License as published by | ||
52 | - * the Free Software Foundation; either version 2 of the License, or | ||
53 | - * (at your option) any later version. | ||
54 | - * | ||
55 | - * This program is distributed in the hope that it will be useful, | ||
56 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
57 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
58 | - * GNU General Public License for more details. | ||
59 | - * | ||
60 | - * You should have received a copy of the GNU General Public License | ||
61 | - * along with this program; if not, write to the Free Software | ||
62 | - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
63 | - */ | ||
64 | -#include <fcntl.h> | ||
65 | -#include <stdio.h> | ||
66 | -#include <stdlib.h> | ||
67 | -#include <string.h> | ||
68 | -#include <sys/ioctl.h> | ||
69 | -#include <sys/time.h> | ||
70 | -#include <sys/types.h> | ||
71 | -#include <signal.h> | ||
72 | -#include <unistd.h> | ||
73 | -#include <stdint.h> | ||
74 | - | ||
75 | -#include <crypto/cryptodev.h> | ||
76 | - | ||
77 | -static int si = 1; /* SI by default */ | ||
78 | - | ||
79 | -static double udifftimeval(struct timeval start, struct timeval end) | ||
80 | -{ | ||
81 | - return (double)(end.tv_usec - start.tv_usec) + | ||
82 | - (double)(end.tv_sec - start.tv_sec) * 1000 * 1000; | ||
83 | -} | ||
84 | - | ||
85 | -static int must_finish = 0; | ||
86 | - | ||
87 | -static void alarm_handler(int signo) | ||
88 | -{ | ||
89 | - must_finish = 1; | ||
90 | -} | ||
91 | - | ||
92 | -static char *units[] = { "", "Ki", "Mi", "Gi", "Ti", 0}; | ||
93 | -static char *si_units[] = { "", "K", "M", "G", "T", 0}; | ||
94 | - | ||
95 | -static void value2human(int si, double bytes, double time, double* data, double* speed,char* metric) | ||
96 | -{ | ||
97 | - int unit = 0; | ||
98 | - | ||
99 | - *data = bytes; | ||
100 | - | ||
101 | - if (si) { | ||
102 | - while (*data > 1000 && si_units[unit + 1]) { | ||
103 | - *data /= 1000; | ||
104 | - unit++; | ||
105 | - } | ||
106 | - *speed = *data / time; | ||
107 | - sprintf(metric, "%sB", si_units[unit]); | ||
108 | - } else { | ||
109 | - while (*data > 1024 && units[unit + 1]) { | ||
110 | - *data /= 1024; | ||
111 | - unit++; | ||
112 | - } | ||
113 | - *speed = *data / time; | ||
114 | - sprintf(metric, "%sB", units[unit]); | ||
115 | - } | ||
116 | -} | ||
117 | - | ||
118 | -#define MAX(x,y) ((x)>(y)?(x):(y)) | ||
119 | - | ||
120 | -int encrypt_data(struct session_op *sess, int fdc, int chunksize, int alignmask) | ||
121 | -{ | ||
122 | - struct crypt_op cop; | ||
123 | - char *buffer, iv[32]; | ||
124 | - uint8_t mac[HASH_MAX_LEN]; | ||
125 | - static int val = 23; | ||
126 | - struct timeval start, end; | ||
127 | - double total = 0; | ||
128 | - double secs, ddata, dspeed; | ||
129 | - char metric[16]; | ||
130 | - int min_alignmask = sizeof(void*) - 1; | ||
131 | - | ||
132 | - if (alignmask) { | ||
133 | - alignmask = ((alignmask < min_alignmask) ? min_alignmask : alignmask); | ||
134 | - if (posix_memalign((void **)&buffer, MAX(alignmask + 1, sizeof(void*)), chunksize)) { | ||
135 | - printf("posix_memalign() failed! (mask %x, size: %d)\n", alignmask+1, chunksize); | ||
136 | - return 1; | ||
137 | - } | ||
138 | - } else { | ||
139 | - if (!(buffer = malloc(chunksize))) { | ||
140 | - perror("malloc()"); | ||
141 | - return 1; | ||
142 | - } | ||
143 | - } | ||
144 | - | ||
145 | - memset(iv, 0x23, 32); | ||
146 | - | ||
147 | - printf("\tEncrypting in chunks of %d bytes: ", chunksize); | ||
148 | - fflush(stdout); | ||
149 | - | ||
150 | - memset(buffer, val++, chunksize); | ||
151 | - | ||
152 | - must_finish = 0; | ||
153 | - alarm(5); | ||
154 | - | ||
155 | - gettimeofday(&start, NULL); | ||
156 | - do { | ||
157 | - memset(&cop, 0, sizeof(cop)); | ||
158 | - cop.ses = sess->ses; | ||
159 | - cop.len = chunksize; | ||
160 | - cop.iv = (unsigned char *)iv; | ||
161 | - cop.op = COP_ENCRYPT; | ||
162 | - cop.src = cop.dst = (unsigned char *)buffer; | ||
163 | - cop.mac = mac; | ||
164 | - | ||
165 | - if (ioctl(fdc, CIOCCRYPT, &cop)) { | ||
166 | - perror("ioctl(CIOCCRYPT)"); | ||
167 | - return 1; | ||
168 | - } | ||
169 | - total+=chunksize; | ||
170 | - } while(must_finish==0); | ||
171 | - gettimeofday(&end, NULL); | ||
172 | - | ||
173 | - secs = udifftimeval(start, end)/ 1000000.0; | ||
174 | - | ||
175 | - value2human(si, total, secs, &ddata, &dspeed, metric); | ||
176 | - printf ("done. %.2f %s in %.2f secs: ", ddata, metric, secs); | ||
177 | - printf ("%.2f %s/sec\n", dspeed, metric); | ||
178 | - | ||
179 | - free(buffer); | ||
180 | - return 0; | ||
181 | -} | ||
182 | - | ||
183 | -int main(int argc, char** argv) | ||
184 | -{ | ||
185 | - int fd, i, fdc = -1, alignmask = 0; | ||
186 | - struct session_op sess; | ||
187 | -#ifdef CIOCGSESSINFO | ||
188 | - struct session_info_op siop; | ||
189 | -#endif | ||
190 | - char keybuf[32]; | ||
191 | - | ||
192 | - signal(SIGALRM, alarm_handler); | ||
193 | - | ||
194 | - if (argc > 1) { | ||
195 | - if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0) { | ||
196 | - printf("Usage: speed [--kib]\n"); | ||
197 | - exit(0); | ||
198 | - } | ||
199 | - if (strcmp(argv[1], "--kib") == 0) { | ||
200 | - si = 0; | ||
201 | - } | ||
202 | - } | ||
203 | - | ||
204 | - if ((fd = open("/dev/crypto", O_RDWR, 0)) < 0) { | ||
205 | - perror("open()"); | ||
206 | - return 1; | ||
207 | - } | ||
208 | - if (ioctl(fd, CRIOGET, &fdc)) { | ||
209 | - perror("ioctl(CRIOGET)"); | ||
210 | - return 1; | ||
211 | - } | ||
212 | - | ||
213 | - fprintf(stderr, "Testing NULL cipher: \n"); | ||
214 | - memset(&sess, 0, sizeof(sess)); | ||
215 | - sess.cipher = CRYPTO_NULL; | ||
216 | - sess.keylen = 0; | ||
217 | - sess.key = (unsigned char *)keybuf; | ||
218 | - if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
219 | - perror("ioctl(CIOCGSESSION)"); | ||
220 | - return 1; | ||
221 | - } | ||
222 | -#ifdef CIOCGSESSINFO | ||
223 | - siop.ses = sess.ses; | ||
224 | - if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
225 | - perror("ioctl(CIOCGSESSINFO)"); | ||
226 | - return 1; | ||
227 | - } | ||
228 | - alignmask = siop.alignmask; | ||
229 | -#endif | ||
230 | - | ||
231 | - for (i = 512; i <= (64 * 1024); i *= 2) { | ||
232 | - if (encrypt_data(&sess, fdc, i, alignmask)) | ||
233 | - break; | ||
234 | - } | ||
235 | - | ||
236 | - fprintf(stderr, "\nTesting AES-128-CBC cipher: \n"); | ||
237 | - memset(&sess, 0, sizeof(sess)); | ||
238 | - sess.cipher = CRYPTO_AES_CBC; | ||
239 | - sess.keylen = 16; | ||
240 | - memset(keybuf, 0x42, 16); | ||
241 | - sess.key = (unsigned char *)keybuf; | ||
242 | - if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
243 | - perror("ioctl(CIOCGSESSION)"); | ||
244 | - return 1; | ||
245 | - } | ||
246 | -#ifdef CIOCGSESSINFO | ||
247 | - siop.ses = sess.ses; | ||
248 | - if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
249 | - perror("ioctl(CIOCGSESSINFO)"); | ||
250 | - return 1; | ||
251 | - } | ||
252 | - alignmask = siop.alignmask; | ||
253 | -#endif | ||
254 | - | ||
255 | - for (i = 512; i <= (64 * 1024); i *= 2) { | ||
256 | - if (encrypt_data(&sess, fdc, i, alignmask)) | ||
257 | - break; | ||
258 | - } | ||
259 | - | ||
260 | - fprintf(stderr, "\nTesting AES-256-XTS cipher: \n"); | ||
261 | - memset(&sess, 0, sizeof(sess)); | ||
262 | - sess.cipher = CRYPTO_AES_XTS; | ||
263 | - sess.keylen = 32; | ||
264 | - memset(keybuf, 0x42, sess.keylen); | ||
265 | - sess.key = (unsigned char *)keybuf; | ||
266 | - if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
267 | - perror("ioctl(CIOCGSESSION)"); | ||
268 | - return 1; | ||
269 | - } | ||
270 | -#ifdef CIOCGSESSINFO | ||
271 | - siop.ses = sess.ses; | ||
272 | - if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
273 | - perror("ioctl(CIOCGSESSINFO)"); | ||
274 | - return 1; | ||
275 | - } | ||
276 | - alignmask = siop.alignmask; | ||
277 | -#endif | ||
278 | - | ||
279 | - for (i = 512; i <= (64 * 1024); i *= 2) { | ||
280 | - if (encrypt_data(&sess, fdc, i, alignmask)) | ||
281 | - break; | ||
282 | - } | ||
283 | - | ||
284 | - fprintf(stderr, "\nTesting CRC32C hash: \n"); | ||
285 | - memset(&sess, 0, sizeof(sess)); | ||
286 | - sess.mac = CRYPTO_CRC32C; | ||
287 | - if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
288 | - perror("ioctl(CIOCGSESSION)"); | ||
289 | - return 1; | ||
290 | - } | ||
291 | -#ifdef CIOCGSESSINFO | ||
292 | - siop.ses = sess.ses; | ||
293 | - if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
294 | - perror("ioctl(CIOCGSESSINFO)"); | ||
295 | - return 1; | ||
296 | - } | ||
297 | - printf("requested hash CRYPTO_CRC32C, got %s with driver %s\n", | ||
298 | - siop.hash_info.cra_name, siop.hash_info.cra_driver_name); | ||
299 | - alignmask = siop.alignmask; | ||
300 | -#endif | ||
301 | - | ||
302 | - for (i = 512; i <= (64 * 1024); i *= 2) { | ||
303 | - if (encrypt_data(&sess, fdc, i, alignmask)) | ||
304 | - break; | ||
305 | - } | ||
306 | - | ||
307 | - close(fdc); | ||
308 | - close(fd); | ||
309 | - return 0; | ||
310 | -} | ||
311 | diff --git a/tests/sync_speed.c b/tests/sync_speed.c | ||
312 | new file mode 100644 | ||
313 | index 0000000..b0cb9ad | ||
314 | --- /dev/null | ||
315 | +++ b/tests/sync_speed.c | ||
316 | @@ -0,0 +1,399 @@ | ||
317 | +/* cryptodev_test - simple benchmark tool for cryptodev | ||
318 | + * | ||
319 | + * Copyright (C) 2010 by Phil Sutter <phil.sutter@viprinet.com> | ||
320 | + * | ||
321 | + * This program is free software; you can redistribute it and/or modify | ||
322 | + * it under the terms of the GNU General Public License as published by | ||
323 | + * the Free Software Foundation; either version 2 of the License, or | ||
324 | + * (at your option) any later version. | ||
325 | + * | ||
326 | + * This program is distributed in the hope that it will be useful, | ||
327 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
328 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
329 | + * GNU General Public License for more details. | ||
330 | + * | ||
331 | + * You should have received a copy of the GNU General Public License | ||
332 | + * along with this program; if not, write to the Free Software | ||
333 | + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
334 | + */ | ||
335 | +#include <errno.h> | ||
336 | +#include <fcntl.h> | ||
337 | +#include <poll.h> | ||
338 | +#include <stdio.h> | ||
339 | +#include <stdlib.h> | ||
340 | +#include <string.h> | ||
341 | +#include <sys/ioctl.h> | ||
342 | +#include <sys/time.h> | ||
343 | +#include <sys/types.h> | ||
344 | +#include <signal.h> | ||
345 | +#include <crypto/cryptodev.h> | ||
346 | +#include <stdbool.h> | ||
347 | +#include <unistd.h> | ||
348 | + | ||
349 | +struct test_params { | ||
350 | + bool tflag; | ||
351 | + bool nflag; | ||
352 | + int tvalue; | ||
353 | + int nvalue; | ||
354 | +}; | ||
355 | + | ||
356 | +const char usage_str[] = "Usage: %s [OPTION]... <cipher>|<hash>\n" | ||
357 | + "Run benchmark test for cipher or hash\n\n" | ||
358 | + " -t <secs>\t" "time to run each test (default 10 secs)\n" | ||
359 | + " -n <bytes>\t" "size of the test buffer\n" | ||
360 | + " -h\t\t" "show this help\n" | ||
361 | +; | ||
362 | + | ||
363 | +int run_null(int fdc, struct test_params tp); | ||
364 | +int run_aes_cbc(int fdc, struct test_params tp); | ||
365 | +int run_aes_xts(int fdc, struct test_params tp); | ||
366 | +int run_crc32c(int fdc, struct test_params tp); | ||
367 | +int run_sha1(int fdc, struct test_params tp); | ||
368 | +int run_sha256(int fdc, struct test_params tp); | ||
369 | +int get_alignmask(int fdc, struct session_op *sess); | ||
370 | + | ||
371 | +#define ALG_COUNT 6 | ||
372 | +struct { | ||
373 | + char *name; | ||
374 | + int (*func)(int, struct test_params); | ||
375 | +} ciphers[ALG_COUNT] = { | ||
376 | + {"null", run_null}, | ||
377 | + {"aes-cbc", run_aes_cbc}, | ||
378 | + {"aes-xts", run_aes_xts}, | ||
379 | + {"crc32c", run_crc32c}, | ||
380 | + {"sha1", run_sha1}, | ||
381 | + {"sha256", run_sha256}, | ||
382 | +}; | ||
383 | + | ||
384 | +static double udifftimeval(struct timeval start, struct timeval end) | ||
385 | +{ | ||
386 | + return (double)(end.tv_usec - start.tv_usec) + | ||
387 | + (double)(end.tv_sec - start.tv_sec) * 1000 * 1000; | ||
388 | +} | ||
389 | + | ||
390 | +static int must_finish = 0; | ||
391 | +static int must_exit = 0; | ||
392 | + | ||
393 | +static void alarm_handler(int signo) | ||
394 | +{ | ||
395 | + must_finish = 1; | ||
396 | +} | ||
397 | + | ||
398 | +static void exit_handler(int signo) | ||
399 | +{ | ||
400 | + must_exit = 1; | ||
401 | + printf("\nexit requested by user through ctrl+c \n"); | ||
402 | +} | ||
403 | + | ||
404 | +static char *units[] = { "", "Ki", "Mi", "Gi", "Ti", 0}; | ||
405 | + | ||
406 | +static void value2human(double bytes, double time, double* data, double* speed,char* metric) | ||
407 | +{ | ||
408 | + int unit = 0; | ||
409 | + | ||
410 | + *data = bytes; | ||
411 | + while (*data > 1024 && units[unit + 1]) { | ||
412 | + *data /= 1024; | ||
413 | + unit++; | ||
414 | + } | ||
415 | + *speed = *data / time; | ||
416 | + sprintf(metric, "%sB", units[unit]); | ||
417 | +} | ||
418 | + | ||
419 | +static int encrypt_data(int fdc, struct test_params tp, struct session_op *sess) | ||
420 | +{ | ||
421 | + struct crypt_op cop; | ||
422 | + char *buffer, iv[32]; | ||
423 | + char mac[HASH_MAX_LEN]; | ||
424 | + static int val = 23; | ||
425 | + struct timeval start, end; | ||
426 | + double total = 0; | ||
427 | + double secs, ddata, dspeed; | ||
428 | + char metric[16]; | ||
429 | + int alignmask; | ||
430 | + int min_alignmask = sizeof(void*) - 1; | ||
431 | + | ||
432 | + memset(iv, 0x23, 32); | ||
433 | + | ||
434 | + printf("\tEncrypting in chunks of %d bytes: ", tp.nvalue); | ||
435 | + fflush(stdout); | ||
436 | + | ||
437 | + alignmask = get_alignmask(fdc, sess); | ||
438 | + if (alignmask) { | ||
439 | + alignmask = ((alignmask < min_alignmask) ? min_alignmask : alignmask); | ||
440 | + if (posix_memalign((void **)(&buffer), alignmask + 1, tp.nvalue)) { | ||
441 | + printf("posix_memalign() failed!\n"); | ||
442 | + return 1; | ||
443 | + } | ||
444 | + } else { | ||
445 | + if (!(buffer = malloc(tp.nvalue))) { | ||
446 | + perror("malloc()"); | ||
447 | + return 1; | ||
448 | + } | ||
449 | + } | ||
450 | + memset(buffer, val++, tp.nvalue); | ||
451 | + | ||
452 | + must_finish = 0; | ||
453 | + alarm(tp.tvalue); | ||
454 | + | ||
455 | + gettimeofday(&start, NULL); | ||
456 | + do { | ||
457 | + memset(&cop, 0, sizeof(cop)); | ||
458 | + cop.ses = sess->ses; | ||
459 | + cop.len = tp.nvalue; | ||
460 | + cop.iv = (unsigned char *)iv; | ||
461 | + cop.op = COP_ENCRYPT; | ||
462 | + cop.src = cop.dst = (unsigned char *)buffer; | ||
463 | + cop.mac = (unsigned char *)mac; | ||
464 | + | ||
465 | + if (ioctl(fdc, CIOCCRYPT, &cop)) { | ||
466 | + perror("ioctl(CIOCCRYPT)"); | ||
467 | + return 1; | ||
468 | + } | ||
469 | + total += cop.len; | ||
470 | + } while(!must_finish); | ||
471 | + gettimeofday(&end, NULL); | ||
472 | + | ||
473 | + secs = udifftimeval(start, end)/ 1000000.0; | ||
474 | + | ||
475 | + value2human(total, secs, &ddata, &dspeed, metric); | ||
476 | + printf ("done. %.2f %s in %.2f secs: ", ddata, metric, secs); | ||
477 | + printf ("%.2f %s/sec\n", dspeed, metric); | ||
478 | + | ||
479 | + free(buffer); | ||
480 | + return 0; | ||
481 | +} | ||
482 | + | ||
483 | +void usage(char *cmd_name) | ||
484 | +{ | ||
485 | + printf(usage_str, cmd_name); | ||
486 | +} | ||
487 | + | ||
488 | +int run_test(int id, struct test_params tp) | ||
489 | +{ | ||
490 | + int fd; | ||
491 | + int fdc; | ||
492 | + | ||
493 | + fd = open("/dev/crypto", O_RDWR, 0); | ||
494 | + if (fd < 0) { | ||
495 | + perror("open()"); | ||
496 | + return fd; | ||
497 | + } | ||
498 | + if (ioctl(fd, CRIOGET, &fdc)) { | ||
499 | + perror("ioctl(CRIOGET)"); | ||
500 | + return -EINVAL; | ||
501 | + } | ||
502 | + | ||
503 | + ciphers[id].func(fdc, tp); | ||
504 | + | ||
505 | + close(fdc); | ||
506 | + close(fd); | ||
507 | + | ||
508 | + return 0; | ||
509 | +} | ||
510 | + | ||
511 | +int get_alignmask(int fdc, struct session_op *sess) | ||
512 | +{ | ||
513 | + int alignmask; | ||
514 | + | ||
515 | +#ifdef CIOCGSESSINFO | ||
516 | + struct session_info_op siop; | ||
517 | + | ||
518 | + siop.ses = sess->ses; | ||
519 | + if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
520 | + perror("ioctl(CIOCGSESSINFO)"); | ||
521 | + return -EINVAL; | ||
522 | + } | ||
523 | + alignmask = siop.alignmask; | ||
524 | +#else | ||
525 | + alignmask = 0; | ||
526 | +#endif | ||
527 | + | ||
528 | + return alignmask; | ||
529 | +} | ||
530 | + | ||
531 | +void do_test_vectors(int fdc, struct test_params tp, struct session_op *sess) | ||
532 | +{ | ||
533 | + int i; | ||
534 | + | ||
535 | + if (tp.nflag) { | ||
536 | + encrypt_data(fdc, tp, sess); | ||
537 | + } else { | ||
538 | + for (i = 256; i <= (64 * 1024); i *= 2) { | ||
539 | + if (must_exit) | ||
540 | + break; | ||
541 | + | ||
542 | + tp.nvalue = i; | ||
543 | + if (encrypt_data(fdc, tp, sess)) { | ||
544 | + break; | ||
545 | + } | ||
546 | + } | ||
547 | + } | ||
548 | +} | ||
549 | + | ||
550 | + | ||
551 | +int run_null(int fdc, struct test_params tp) | ||
552 | +{ | ||
553 | + struct session_op sess; | ||
554 | + char keybuf[32]; | ||
555 | + | ||
556 | + fprintf(stderr, "Testing NULL cipher: \n"); | ||
557 | + memset(&sess, 0, sizeof(sess)); | ||
558 | + sess.cipher = CRYPTO_NULL; | ||
559 | + sess.keylen = 0; | ||
560 | + sess.key = (unsigned char *)keybuf; | ||
561 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
562 | + perror("ioctl(CIOCGSESSION)"); | ||
563 | + return -EINVAL; | ||
564 | + } | ||
565 | + | ||
566 | + do_test_vectors(fdc, tp, &sess); | ||
567 | + return 0; | ||
568 | +} | ||
569 | + | ||
570 | +int run_aes_cbc(int fdc, struct test_params tp) | ||
571 | +{ | ||
572 | + struct session_op sess; | ||
573 | + char keybuf[32]; | ||
574 | + | ||
575 | + fprintf(stderr, "\nTesting AES-128-CBC cipher: \n"); | ||
576 | + memset(&sess, 0, sizeof(sess)); | ||
577 | + sess.cipher = CRYPTO_AES_CBC; | ||
578 | + sess.keylen = 16; | ||
579 | + memset(keybuf, 0x42, 16); | ||
580 | + sess.key = (unsigned char *)keybuf; | ||
581 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
582 | + perror("ioctl(CIOCGSESSION)"); | ||
583 | + return -EINVAL; | ||
584 | + } | ||
585 | + | ||
586 | + do_test_vectors(fdc, tp, &sess); | ||
587 | + return 0; | ||
588 | +} | ||
589 | + | ||
590 | +int run_aes_xts(int fdc, struct test_params tp) | ||
591 | +{ | ||
592 | + struct session_op sess; | ||
593 | + char keybuf[32]; | ||
594 | + | ||
595 | + fprintf(stderr, "\nTesting AES-256-XTS cipher: \n"); | ||
596 | + memset(&sess, 0, sizeof(sess)); | ||
597 | + sess.cipher = CRYPTO_AES_XTS; | ||
598 | + sess.keylen = 32; | ||
599 | + memset(keybuf, 0x42, sess.keylen); | ||
600 | + sess.key = (unsigned char *)keybuf; | ||
601 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
602 | + perror("ioctl(CIOCGSESSION)"); | ||
603 | + return -EINVAL; | ||
604 | + } | ||
605 | + | ||
606 | + do_test_vectors(fdc, tp, &sess); | ||
607 | + return 0; | ||
608 | +} | ||
609 | + | ||
610 | +int run_crc32c(int fdc, struct test_params tp) | ||
611 | +{ | ||
612 | + struct session_op sess; | ||
613 | + | ||
614 | + fprintf(stderr, "\nTesting CRC32C hash: \n"); | ||
615 | + memset(&sess, 0, sizeof(sess)); | ||
616 | + sess.mac = CRYPTO_CRC32C; | ||
617 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
618 | + perror("ioctl(CIOCGSESSION)"); | ||
619 | + return 1; | ||
620 | + } | ||
621 | + | ||
622 | + do_test_vectors(fdc, tp, &sess); | ||
623 | + return 0; | ||
624 | +} | ||
625 | + | ||
626 | +int run_sha1(int fdc, struct test_params tp) | ||
627 | +{ | ||
628 | + struct session_op sess; | ||
629 | + | ||
630 | + fprintf(stderr, "\nTesting SHA-1 hash: \n"); | ||
631 | + memset(&sess, 0, sizeof(sess)); | ||
632 | + sess.mac = CRYPTO_SHA1; | ||
633 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
634 | + perror("ioctl(CIOCGSESSION)"); | ||
635 | + return 1; | ||
636 | + } | ||
637 | + | ||
638 | + do_test_vectors(fdc, tp, &sess); | ||
639 | + return 0; | ||
640 | +} | ||
641 | + | ||
642 | +int run_sha256(int fdc, struct test_params tp) | ||
643 | +{ | ||
644 | + struct session_op sess; | ||
645 | + | ||
646 | + fprintf(stderr, "\nTesting SHA2-256 hash: \n"); | ||
647 | + memset(&sess, 0, sizeof(sess)); | ||
648 | + sess.mac = CRYPTO_SHA2_256; | ||
649 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
650 | + perror("ioctl(CIOCGSESSION)"); | ||
651 | + return 1; | ||
652 | + } | ||
653 | + | ||
654 | + do_test_vectors(fdc, tp, &sess); | ||
655 | + return 0; | ||
656 | +} | ||
657 | + | ||
658 | +int main(int argc, char **argv) | ||
659 | +{ | ||
660 | + int i; | ||
661 | + int c; | ||
662 | + bool alg_flag; | ||
663 | + char *alg_name; | ||
664 | + struct test_params tp; | ||
665 | + | ||
666 | + tp.tflag = false; | ||
667 | + tp.nflag = false; | ||
668 | + alg_flag = false; | ||
669 | + opterr = 0; | ||
670 | + while ((c = getopt(argc, argv, "hn:t:")) != -1) { | ||
671 | + switch (c) { | ||
672 | + case 'n': | ||
673 | + tp.nvalue = atoi(optarg); | ||
674 | + tp.nflag = true; | ||
675 | + break; | ||
676 | + case 't': | ||
677 | + tp.tvalue = atoi(optarg); | ||
678 | + tp.tflag = true; | ||
679 | + break; | ||
680 | + case 'h': /* no break */ | ||
681 | + default: | ||
682 | + usage(argv[0]); | ||
683 | + exit(1); | ||
684 | + } | ||
685 | + } | ||
686 | + | ||
687 | + /* the name of a specific test asked on the command line */ | ||
688 | + if (optind < argc) { | ||
689 | + alg_name = argv[optind]; | ||
690 | + alg_flag = true; | ||
691 | + } | ||
692 | + | ||
693 | + /* default test time */ | ||
694 | + if (!tp.tflag) { | ||
695 | + tp.tvalue = 5; | ||
696 | + } | ||
697 | + | ||
698 | + signal(SIGALRM, alarm_handler); | ||
699 | + signal(SIGINT, exit_handler); | ||
700 | + | ||
701 | + for (i = 0; i < ALG_COUNT; i++) { | ||
702 | + if (must_exit) | ||
703 | + break; | ||
704 | + | ||
705 | + if (alg_flag) { | ||
706 | + if (strcmp(alg_name, ciphers[i].name) == 0) { | ||
707 | + run_test(i, tp); | ||
708 | + } | ||
709 | + } else { | ||
710 | + run_test(i, tp); | ||
711 | + } | ||
712 | + } | ||
713 | + | ||
714 | + return 0; | ||
715 | +} | ||
716 | -- | ||
717 | 2.10.2 | ||
718 | |||
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 @@ | |||
1 | From eee8668c6f0e558e77533edb80c1ca7d4dc486e2 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Fri, 28 Oct 2016 17:00:29 +0300 | ||
4 | Subject: [PATCH 082/104] force LC_TIME value to avoid mpstat not using ISO8601 | ||
5 | format | ||
6 | |||
7 | (not everybody has this locale - silent warnings on some systems) | ||
8 | |||
9 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
10 | --- | ||
11 | tests/async_speed_multi.sh | 4 ++++ | ||
12 | 1 file changed, 4 insertions(+) | ||
13 | |||
14 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
15 | index f2a8ba6..1901620 100755 | ||
16 | --- a/tests/async_speed_multi.sh | ||
17 | +++ b/tests/async_speed_multi.sh | ||
18 | @@ -24,6 +24,10 @@ CMD_BIN="async_speed" | ||
19 | OUT_BASENAME="async_speed" | ||
20 | MPSTAT_OUT="mpstat_out" | ||
21 | |||
22 | +# A bigger hammer for mpstat to use ISO8601 time format (fixed in 11.2.2) | ||
23 | +export LC_TIME=en_GB.UTF-8 &> /dev/null | ||
24 | + | ||
25 | + | ||
26 | function usage | ||
27 | { | ||
28 | cat << EOF | ||
29 | -- | ||
30 | 2.10.2 | ||
31 | |||
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 @@ | |||
1 | From a6e777aba434533f726bc9d34b074b7f36429126 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Fri, 28 Oct 2016 17:23:27 +0300 | ||
4 | Subject: [PATCH 083/104] use the same algorithm names in sync_speed as in | ||
5 | async_speed | ||
6 | |||
7 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
8 | --- | ||
9 | tests/sync_speed.c | 12 ++++++------ | ||
10 | 1 file changed, 6 insertions(+), 6 deletions(-) | ||
11 | |||
12 | diff --git a/tests/sync_speed.c b/tests/sync_speed.c | ||
13 | index b0cb9ad..56cd3aa 100644 | ||
14 | --- a/tests/sync_speed.c | ||
15 | +++ b/tests/sync_speed.c | ||
16 | @@ -45,8 +45,8 @@ const char usage_str[] = "Usage: %s [OPTION]... <cipher>|<hash>\n" | ||
17 | ; | ||
18 | |||
19 | int run_null(int fdc, struct test_params tp); | ||
20 | -int run_aes_cbc(int fdc, struct test_params tp); | ||
21 | -int run_aes_xts(int fdc, struct test_params tp); | ||
22 | +int run_aes_128_cbc(int fdc, struct test_params tp); | ||
23 | +int run_aes_256_xts(int fdc, struct test_params tp); | ||
24 | int run_crc32c(int fdc, struct test_params tp); | ||
25 | int run_sha1(int fdc, struct test_params tp); | ||
26 | int run_sha256(int fdc, struct test_params tp); | ||
27 | @@ -58,8 +58,8 @@ struct { | ||
28 | int (*func)(int, struct test_params); | ||
29 | } ciphers[ALG_COUNT] = { | ||
30 | {"null", run_null}, | ||
31 | - {"aes-cbc", run_aes_cbc}, | ||
32 | - {"aes-xts", run_aes_xts}, | ||
33 | + {"aes-128-cbc", run_aes_128_cbc}, | ||
34 | + {"aes-256-xts", run_aes_256_xts}, | ||
35 | {"crc32c", run_crc32c}, | ||
36 | {"sha1", run_sha1}, | ||
37 | {"sha256", run_sha256}, | ||
38 | @@ -251,7 +251,7 @@ int run_null(int fdc, struct test_params tp) | ||
39 | return 0; | ||
40 | } | ||
41 | |||
42 | -int run_aes_cbc(int fdc, struct test_params tp) | ||
43 | +int run_aes_128_cbc(int fdc, struct test_params tp) | ||
44 | { | ||
45 | struct session_op sess; | ||
46 | char keybuf[32]; | ||
47 | @@ -271,7 +271,7 @@ int run_aes_cbc(int fdc, struct test_params tp) | ||
48 | return 0; | ||
49 | } | ||
50 | |||
51 | -int run_aes_xts(int fdc, struct test_params tp) | ||
52 | +int run_aes_256_xts(int fdc, struct test_params tp) | ||
53 | { | ||
54 | struct session_op sess; | ||
55 | char keybuf[32]; | ||
56 | -- | ||
57 | 2.10.2 | ||
58 | |||
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 @@ | |||
1 | From 1bcef054cfc094e51c9c3cb1048b8bf909326082 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Fri, 28 Oct 2016 17:41:09 +0300 | ||
4 | Subject: [PATCH 084/104] fix ignored SIGALRM signals on some platforms | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed.c | 4 ++-- | ||
9 | tests/sync_speed.c | 4 ++-- | ||
10 | 2 files changed, 4 insertions(+), 4 deletions(-) | ||
11 | |||
12 | diff --git a/tests/async_speed.c b/tests/async_speed.c | ||
13 | index d843c02..eb8468d 100644 | ||
14 | --- a/tests/async_speed.c | ||
15 | +++ b/tests/async_speed.c | ||
16 | @@ -76,8 +76,8 @@ static double udifftimeval(struct timeval start, struct timeval end) | ||
17 | (double)(end.tv_sec - start.tv_sec) * 1000 * 1000; | ||
18 | } | ||
19 | |||
20 | -static int must_finish = 0; | ||
21 | -static int must_exit = 0; | ||
22 | +static volatile int must_finish; | ||
23 | +static volatile int must_exit; | ||
24 | static struct pollfd pfd; | ||
25 | |||
26 | static void alarm_handler(int signo) | ||
27 | diff --git a/tests/sync_speed.c b/tests/sync_speed.c | ||
28 | index 56cd3aa..ba1d170 100644 | ||
29 | --- a/tests/sync_speed.c | ||
30 | +++ b/tests/sync_speed.c | ||
31 | @@ -71,8 +71,8 @@ static double udifftimeval(struct timeval start, struct timeval end) | ||
32 | (double)(end.tv_sec - start.tv_sec) * 1000 * 1000; | ||
33 | } | ||
34 | |||
35 | -static int must_finish = 0; | ||
36 | -static int must_exit = 0; | ||
37 | +static volatile int must_finish; | ||
38 | +static volatile int must_exit; | ||
39 | |||
40 | static void alarm_handler(int signo) | ||
41 | { | ||
42 | -- | ||
43 | 2.10.2 | ||
44 | |||
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 @@ | |||
1 | From b682119d432af1190699c56039f6584ac83ae7b9 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Fri, 28 Oct 2016 18:03:07 +0300 | ||
4 | Subject: [PATCH 085/104] add notes about configured limits in SEC driver | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed.c | 3 ++- | ||
9 | tests/async_speed_multi.sh | 2 ++ | ||
10 | tests/sync_speed.c | 3 ++- | ||
11 | 3 files changed, 6 insertions(+), 2 deletions(-) | ||
12 | |||
13 | diff --git a/tests/async_speed.c b/tests/async_speed.c | ||
14 | index eb8468d..d16d17e 100644 | ||
15 | --- a/tests/async_speed.c | ||
16 | +++ b/tests/async_speed.c | ||
17 | @@ -47,7 +47,8 @@ const char usage_str[] = "Usage: %s [OPTION]... <cipher>|<hash>\n" | ||
18 | " -t <secs>\t" "time to run each test (default 10 secs)\n" | ||
19 | " -n <bytes>\t" "size of the test buffer\n" | ||
20 | " -m\t\t" "output in a machine readable format\n" | ||
21 | - " -h\t\t" "show this help\n" | ||
22 | + " -h\t\t" "show this help\n\n" | ||
23 | + "Note: SEC driver is configured to support buffers smaller than 512K\n" | ||
24 | ; | ||
25 | |||
26 | int run_null(int fdc, struct test_params tp); | ||
27 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
28 | index 1901620..f83e362 100755 | ||
29 | --- a/tests/async_speed_multi.sh | ||
30 | +++ b/tests/async_speed_multi.sh | ||
31 | @@ -40,6 +40,8 @@ Usage: `basename $0` [OPTIONS] <alg_name> | ||
32 | -h show this help | ||
33 | |||
34 | alg_name: null, aes-128-cbc, aes-256-xts, sha1, sha256, crc32c | ||
35 | + | ||
36 | +Note: SEC driver is configured to support buffers smaller than 512K | ||
37 | EOF | ||
38 | } | ||
39 | |||
40 | diff --git a/tests/sync_speed.c b/tests/sync_speed.c | ||
41 | index ba1d170..ceae645 100644 | ||
42 | --- a/tests/sync_speed.c | ||
43 | +++ b/tests/sync_speed.c | ||
44 | @@ -41,7 +41,8 @@ const char usage_str[] = "Usage: %s [OPTION]... <cipher>|<hash>\n" | ||
45 | "Run benchmark test for cipher or hash\n\n" | ||
46 | " -t <secs>\t" "time to run each test (default 10 secs)\n" | ||
47 | " -n <bytes>\t" "size of the test buffer\n" | ||
48 | - " -h\t\t" "show this help\n" | ||
49 | + " -h\t\t" "show this help\n\n" | ||
50 | + "Note: SEC driver is configured to support buffers smaller than 512K\n" | ||
51 | ; | ||
52 | |||
53 | int run_null(int fdc, struct test_params tp); | ||
54 | -- | ||
55 | 2.10.2 | ||
56 | |||
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 @@ | |||
1 | From fc04b5a05fd4ab1fc0f581b52d52db7c709dfc6a Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Fri, 28 Oct 2016 18:55:09 +0300 | ||
4 | Subject: [PATCH 086/104] add a wrapper script for running all tests | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/Makefile | 1 + | ||
9 | tests/run_crypto_tests.sh | 25 +++++++++++++++++++++++++ | ||
10 | 2 files changed, 26 insertions(+) | ||
11 | create mode 100644 tests/run_crypto_tests.sh | ||
12 | |||
13 | diff --git a/tests/Makefile b/tests/Makefile | ||
14 | index 400fb7a..51469e8 100644 | ||
15 | --- a/tests/Makefile | ||
16 | +++ b/tests/Makefile | ||
17 | @@ -39,6 +39,7 @@ install: | ||
18 | install -m 755 $$prog $(DESTDIR)/$(bindir)/tests_cryptodev/; \ | ||
19 | done | ||
20 | install -m 755 async_speed_multi.sh $(DESTDIR)/$(bindir) | ||
21 | + install -m 755 run_crypto_tests.sh $(DESTDIR)/$(bindir) | ||
22 | |||
23 | clean: | ||
24 | rm -f *.o *~ $(hostprogs) | ||
25 | diff --git a/tests/run_crypto_tests.sh b/tests/run_crypto_tests.sh | ||
26 | new file mode 100644 | ||
27 | index 0000000..32ab8e2 | ||
28 | --- /dev/null | ||
29 | +++ b/tests/run_crypto_tests.sh | ||
30 | @@ -0,0 +1,25 @@ | ||
31 | +#!/bin/bash | ||
32 | + | ||
33 | + | ||
34 | +BUF_SIZE="8192 16384 65536 131072 262144" | ||
35 | +THREAD_CNT="1 8 12" | ||
36 | +ALG_NAMES="aes-128-cbc aes-256-xts sha1 sha256 crc32c" | ||
37 | + | ||
38 | +#restool dpseci create --num-queues=8 --priorities=1,2,3,4,5,6,7,8 | ||
39 | +#restool dprc assign dprc.1 --object=dpseci.0 --plugged=1 | ||
40 | + | ||
41 | + | ||
42 | +#grep DPIO /proc/interrupts | ||
43 | +for alg_name in ${ALG_NAMES} | ||
44 | +do | ||
45 | + for multi in ${THREAD_CNT} | ||
46 | + do | ||
47 | + for bsize in ${BUF_SIZE} | ||
48 | + do | ||
49 | + async_speed_multi.sh -t 10 -n $bsize -m ${multi} ${alg_name} | | ||
50 | + tail -n 1 | ||
51 | + done | ||
52 | + done | ||
53 | +done | ||
54 | + | ||
55 | +#grep DPIO /proc/interrupts | ||
56 | -- | ||
57 | 2.10.2 | ||
58 | |||
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 @@ | |||
1 | From a2894f645e972b7dfc97b59ea1c1e91e741c04d1 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Fri, 28 Oct 2016 19:07:29 +0300 | ||
4 | Subject: [PATCH 087/104] add % to cpu idle for convenience | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_speed_multi.sh | 2 +- | ||
9 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
10 | |||
11 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
12 | index f83e362..90f9b72 100755 | ||
13 | --- a/tests/async_speed_multi.sh | ||
14 | +++ b/tests/async_speed_multi.sh | ||
15 | @@ -112,7 +112,7 @@ function run_parallel | ||
16 | echo -e "algorithm\t""threads\t""run time\t"\ | ||
17 | "buffer size\t""GB/s\t""%cpu idle" | ||
18 | echo -e "${alg_name}\t${mvalue}\t${runtime}\t"\ | ||
19 | - "${nvalue}\t${avg_speed}\t${cpu_idle}" | ||
20 | + "${nvalue}\t${avg_speed}\t${cpu_idle}%" | ||
21 | fi | ||
22 | } | ||
23 | |||
24 | -- | ||
25 | 2.10.2 | ||
26 | |||
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 @@ | |||
1 | From a7e42a9c9a2cd4b4ffd369ae57dfbd207536766a Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Tue, 1 Nov 2016 12:01:33 +0200 | ||
4 | Subject: [PATCH 088/104] merge sync and async benchmarks into a single program | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/Makefile | 9 +- | ||
9 | tests/async_speed.c | 463 -------------------------------------- | ||
10 | tests/async_speed_multi.sh | 172 -------------- | ||
11 | tests/run_crypto_tests.sh | 2 +- | ||
12 | tests/speed.c | 546 +++++++++++++++++++++++++++++++++++++++++++++ | ||
13 | tests/speed_multi.sh | 174 +++++++++++++++ | ||
14 | tests/sync_speed.c | 400 --------------------------------- | ||
15 | 7 files changed, 725 insertions(+), 1041 deletions(-) | ||
16 | delete mode 100644 tests/async_speed.c | ||
17 | delete mode 100755 tests/async_speed_multi.sh | ||
18 | create mode 100644 tests/speed.c | ||
19 | create mode 100755 tests/speed_multi.sh | ||
20 | delete mode 100644 tests/sync_speed.c | ||
21 | |||
22 | diff --git a/tests/Makefile b/tests/Makefile | ||
23 | index 51469e8..88f5040 100644 | ||
24 | --- a/tests/Makefile | ||
25 | +++ b/tests/Makefile | ||
26 | @@ -3,19 +3,18 @@ CFLAGS += -I.. $(CRYPTODEV_CFLAGS) | ||
27 | |||
28 | comp_progs := cipher_comp hash_comp hmac_comp | ||
29 | |||
30 | -hostprogs := cipher cipher-aead hmac sync_speed async_cipher async_hmac \ | ||
31 | - async_speed sha_speed hashcrypt_speed fullspeed cipher-gcm \ | ||
32 | +hostprogs := cipher cipher-aead hmac async_cipher async_hmac \ | ||
33 | + speed sha_speed hashcrypt_speed fullspeed cipher-gcm \ | ||
34 | cipher-aead-srtp $(comp_progs) | ||
35 | |||
36 | example-cipher-objs := cipher.o | ||
37 | example-cipher-aead-objs := cipher-aead.o | ||
38 | example-hmac-objs := hmac.o | ||
39 | -example-speed-objs := sync_speed.o | ||
40 | example-fullspeed-objs := fullspeed.c | ||
41 | example-sha-speed-objs := sha_speed.c | ||
42 | example-async-cipher-objs := async_cipher.o | ||
43 | example-async-hmac-objs := async_hmac.o | ||
44 | -example-async-speed-objs := async_speed.o | ||
45 | +example-async-speed-objs := speed.o | ||
46 | example-hashcrypt-speed-objs := hashcrypt_speed.c | ||
47 | |||
48 | prefix ?= /usr/local | ||
49 | @@ -38,7 +37,7 @@ install: | ||
50 | for prog in $(hostprogs); do \ | ||
51 | install -m 755 $$prog $(DESTDIR)/$(bindir)/tests_cryptodev/; \ | ||
52 | done | ||
53 | - install -m 755 async_speed_multi.sh $(DESTDIR)/$(bindir) | ||
54 | + install -m 755 speed_multi.sh $(DESTDIR)/$(bindir) | ||
55 | install -m 755 run_crypto_tests.sh $(DESTDIR)/$(bindir) | ||
56 | |||
57 | clean: | ||
58 | diff --git a/tests/async_speed.c b/tests/async_speed.c | ||
59 | deleted file mode 100644 | ||
60 | index d16d17e..0000000 | ||
61 | --- a/tests/async_speed.c | ||
62 | +++ /dev/null | ||
63 | @@ -1,463 +0,0 @@ | ||
64 | -/* cryptodev_test - simple benchmark tool for cryptodev | ||
65 | - * | ||
66 | - * Copyright (C) 2010 by Phil Sutter <phil.sutter@viprinet.com> | ||
67 | - * | ||
68 | - * This program is free software; you can redistribute it and/or modify | ||
69 | - * it under the terms of the GNU General Public License as published by | ||
70 | - * the Free Software Foundation; either version 2 of the License, or | ||
71 | - * (at your option) any later version. | ||
72 | - * | ||
73 | - * This program is distributed in the hope that it will be useful, | ||
74 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
75 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
76 | - * GNU General Public License for more details. | ||
77 | - * | ||
78 | - * You should have received a copy of the GNU General Public License | ||
79 | - * along with this program; if not, write to the Free Software | ||
80 | - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
81 | - */ | ||
82 | -#include <errno.h> | ||
83 | -#include <fcntl.h> | ||
84 | -#include <poll.h> | ||
85 | -#include <stdio.h> | ||
86 | -#include <stdlib.h> | ||
87 | -#include <string.h> | ||
88 | -#include <sys/ioctl.h> | ||
89 | -#include <sys/time.h> | ||
90 | -#include <sys/types.h> | ||
91 | -#include <signal.h> | ||
92 | -#include <crypto/cryptodev.h> | ||
93 | -#include <stdbool.h> | ||
94 | -#include <unistd.h> | ||
95 | -#include <stdint.h> | ||
96 | -#include <inttypes.h> | ||
97 | - | ||
98 | -#ifdef ENABLE_ASYNC | ||
99 | - | ||
100 | -struct test_params { | ||
101 | - bool tflag; | ||
102 | - bool nflag; | ||
103 | - bool mflag; | ||
104 | - int tvalue; | ||
105 | - int nvalue; | ||
106 | -}; | ||
107 | - | ||
108 | -const char usage_str[] = "Usage: %s [OPTION]... <cipher>|<hash>\n" | ||
109 | - "Run benchmark test for cipher or hash\n\n" | ||
110 | - " -t <secs>\t" "time to run each test (default 10 secs)\n" | ||
111 | - " -n <bytes>\t" "size of the test buffer\n" | ||
112 | - " -m\t\t" "output in a machine readable format\n" | ||
113 | - " -h\t\t" "show this help\n\n" | ||
114 | - "Note: SEC driver is configured to support buffers smaller than 512K\n" | ||
115 | -; | ||
116 | - | ||
117 | -int run_null(int fdc, struct test_params tp); | ||
118 | -int run_aes_128_cbc(int fdc, struct test_params tp); | ||
119 | -int run_aes_256_xts(int fdc, struct test_params tp); | ||
120 | -int run_crc32c(int fdc, struct test_params tp); | ||
121 | -int run_sha1(int fdc, struct test_params tp); | ||
122 | -int run_sha256(int fdc, struct test_params tp); | ||
123 | - | ||
124 | -#define ALG_COUNT 6 | ||
125 | -struct { | ||
126 | - char *name; | ||
127 | - int (*func)(int, struct test_params); | ||
128 | -} ciphers[ALG_COUNT] = { | ||
129 | - {"null", run_null}, | ||
130 | - {"aes-128-cbc", run_aes_128_cbc}, | ||
131 | - {"aes-256-xts", run_aes_256_xts}, | ||
132 | - {"crc32c", run_crc32c}, | ||
133 | - {"sha1", run_sha1}, | ||
134 | - {"sha256", run_sha256}, | ||
135 | -}; | ||
136 | - | ||
137 | -static double udifftimeval(struct timeval start, struct timeval end) | ||
138 | -{ | ||
139 | - return (double)(end.tv_usec - start.tv_usec) + | ||
140 | - (double)(end.tv_sec - start.tv_sec) * 1000 * 1000; | ||
141 | -} | ||
142 | - | ||
143 | -static volatile int must_finish; | ||
144 | -static volatile int must_exit; | ||
145 | -static struct pollfd pfd; | ||
146 | - | ||
147 | -static void alarm_handler(int signo) | ||
148 | -{ | ||
149 | - must_finish = 1; | ||
150 | - pfd.events = POLLIN; | ||
151 | -} | ||
152 | - | ||
153 | -static void exit_handler(int signo) | ||
154 | -{ | ||
155 | - must_exit = 1; | ||
156 | - printf("\nexit requested by user through ctrl+c \n"); | ||
157 | -} | ||
158 | - | ||
159 | -static char *units[] = { "", "Ki", "Mi", "Gi", "Ti", 0}; | ||
160 | - | ||
161 | -static void value2human(uint64_t bytes, double time, double* data, double* speed,char* metric) | ||
162 | -{ | ||
163 | - int unit = 0; | ||
164 | - | ||
165 | - *data = bytes; | ||
166 | - while (*data > 1024 && units[unit + 1]) { | ||
167 | - *data /= 1024; | ||
168 | - unit++; | ||
169 | - } | ||
170 | - *speed = *data / time; | ||
171 | - sprintf(metric, "%sB", units[unit]); | ||
172 | -} | ||
173 | - | ||
174 | -static void value2machine(uint64_t bytes, double time, double* speed) | ||
175 | -{ | ||
176 | - *speed = bytes / time; | ||
177 | -} | ||
178 | - | ||
179 | -int get_alignmask(int fdc, struct session_op *sess) | ||
180 | -{ | ||
181 | - int alignmask; | ||
182 | - int min_alignmask = sizeof(void*) - 1; | ||
183 | - | ||
184 | -#ifdef CIOCGSESSINFO | ||
185 | - struct session_info_op siop; | ||
186 | - | ||
187 | - siop.ses = sess->ses; | ||
188 | - if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
189 | - perror("ioctl(CIOCGSESSINFO)"); | ||
190 | - return -EINVAL; | ||
191 | - } | ||
192 | - alignmask = siop.alignmask; | ||
193 | - if (alignmask < min_alignmask) { | ||
194 | - alignmask = min_alignmask; | ||
195 | - } | ||
196 | -#else | ||
197 | - alignmask = 0; | ||
198 | -#endif | ||
199 | - | ||
200 | - return alignmask; | ||
201 | -} | ||
202 | - | ||
203 | -int encrypt_data(int fdc, struct test_params tp, struct session_op *sess) | ||
204 | -{ | ||
205 | - struct crypt_op cop; | ||
206 | - char *buffer[64], iv[32]; | ||
207 | - uint8_t mac[64][HASH_MAX_LEN]; | ||
208 | - static int val = 23; | ||
209 | - struct timeval start, end; | ||
210 | - uint64_t total = 0; | ||
211 | - double secs, ddata, dspeed; | ||
212 | - char metric[16]; | ||
213 | - int rc, wqueue = 0, bufidx = 0; | ||
214 | - int alignmask; | ||
215 | - | ||
216 | - memset(iv, 0x23, 32); | ||
217 | - | ||
218 | - if (!tp.mflag) { | ||
219 | - printf("\tBuffer size %d bytes: ", tp.nvalue); | ||
220 | - fflush(stdout); | ||
221 | - } | ||
222 | - | ||
223 | - alignmask = get_alignmask(fdc, sess); | ||
224 | - for (rc = 0; rc < 64; rc++) { | ||
225 | - if (alignmask) { | ||
226 | - if (posix_memalign((void **)(buffer + rc), alignmask + 1, tp.nvalue)) { | ||
227 | - printf("posix_memalign() failed!\n"); | ||
228 | - return 1; | ||
229 | - } | ||
230 | - } else { | ||
231 | - if (!(buffer[rc] = malloc(tp.nvalue))) { | ||
232 | - perror("malloc()"); | ||
233 | - return 1; | ||
234 | - } | ||
235 | - } | ||
236 | - memset(buffer[rc], val++, tp.nvalue); | ||
237 | - } | ||
238 | - pfd.fd = fdc; | ||
239 | - pfd.events = POLLOUT | POLLIN; | ||
240 | - | ||
241 | - must_finish = 0; | ||
242 | - alarm(tp.tvalue); | ||
243 | - | ||
244 | - gettimeofday(&start, NULL); | ||
245 | - do { | ||
246 | - if ((rc = poll(&pfd, 1, 100)) < 0) { | ||
247 | - if (errno & (ERESTART | EINTR)) | ||
248 | - continue; | ||
249 | - fprintf(stderr, "errno = %d ", errno); | ||
250 | - perror("poll()"); | ||
251 | - return 1; | ||
252 | - } | ||
253 | - | ||
254 | - if (pfd.revents & POLLOUT) { | ||
255 | - memset(&cop, 0, sizeof(cop)); | ||
256 | - cop.ses = sess->ses; | ||
257 | - cop.len = tp.nvalue; | ||
258 | - cop.iv = (unsigned char *)iv; | ||
259 | - cop.op = COP_ENCRYPT; | ||
260 | - cop.src = cop.dst = (unsigned char *)buffer[bufidx]; | ||
261 | - cop.mac = mac[bufidx]; | ||
262 | - bufidx = (bufidx + 1) % 64; | ||
263 | - | ||
264 | - if (ioctl(fdc, CIOCASYNCCRYPT, &cop)) { | ||
265 | - perror("ioctl(CIOCASYNCCRYPT)"); | ||
266 | - return 1; | ||
267 | - } | ||
268 | - wqueue++; | ||
269 | - } | ||
270 | - if (pfd.revents & POLLIN) { | ||
271 | - if (ioctl(fdc, CIOCASYNCFETCH, &cop)) { | ||
272 | - perror("ioctl(CIOCASYNCFETCH)"); | ||
273 | - return 1; | ||
274 | - } | ||
275 | - wqueue--; | ||
276 | - total += cop.len; | ||
277 | - } | ||
278 | - } while(!must_finish || wqueue); | ||
279 | - gettimeofday(&end, NULL); | ||
280 | - | ||
281 | - secs = udifftimeval(start, end)/ 1000000.0; | ||
282 | - | ||
283 | - if (tp.mflag) { | ||
284 | - value2machine(total, secs, &dspeed); | ||
285 | - printf("%" PRIu64 "\t%.2f\t%.2f\n", total, secs, dspeed); | ||
286 | - } else { | ||
287 | - value2human(total, secs, &ddata, &dspeed, metric); | ||
288 | - printf ("done. %.2f %s in %.2f secs: ", ddata, metric, secs); | ||
289 | - printf ("%.2f %s/sec\n", dspeed, metric); | ||
290 | - } | ||
291 | - | ||
292 | - for (rc = 0; rc < 64; rc++) | ||
293 | - free(buffer[rc]); | ||
294 | - return 0; | ||
295 | -} | ||
296 | - | ||
297 | -void usage(char *cmd_name) | ||
298 | -{ | ||
299 | - printf(usage_str, cmd_name); | ||
300 | -} | ||
301 | - | ||
302 | -int run_test(int id, struct test_params tp) | ||
303 | -{ | ||
304 | - int fd; | ||
305 | - int fdc; | ||
306 | - int err; | ||
307 | - | ||
308 | - fd = open("/dev/crypto", O_RDWR, 0); | ||
309 | - if (fd < 0) { | ||
310 | - perror("open()"); | ||
311 | - return fd; | ||
312 | - } | ||
313 | - if (ioctl(fd, CRIOGET, &fdc)) { | ||
314 | - perror("ioctl(CRIOGET)"); | ||
315 | - return -EINVAL; | ||
316 | - } | ||
317 | - | ||
318 | - if (!tp.mflag) { | ||
319 | - fprintf(stderr, "Testing %s:\n", ciphers[id].name); | ||
320 | - } | ||
321 | - err = ciphers[id].func(fdc, tp); | ||
322 | - | ||
323 | - close(fdc); | ||
324 | - close(fd); | ||
325 | - | ||
326 | - return err; | ||
327 | -} | ||
328 | - | ||
329 | -void do_test_vectors(int fdc, struct test_params tp, struct session_op *sess) | ||
330 | -{ | ||
331 | - int i; | ||
332 | - | ||
333 | - if (tp.nflag) { | ||
334 | - encrypt_data(fdc, tp, sess); | ||
335 | - } else { | ||
336 | - for (i = 256; i <= (64 * 1024); i *= 2) { | ||
337 | - if (must_exit) { | ||
338 | - break; | ||
339 | - } | ||
340 | - | ||
341 | - tp.nvalue = i; | ||
342 | - if (encrypt_data(fdc, tp, sess)) { | ||
343 | - break; | ||
344 | - } | ||
345 | - } | ||
346 | - } | ||
347 | -} | ||
348 | - | ||
349 | - | ||
350 | -int run_null(int fdc, struct test_params tp) | ||
351 | -{ | ||
352 | - struct session_op sess; | ||
353 | - char keybuf[32]; | ||
354 | - | ||
355 | - fprintf(stderr, "Testing NULL cipher: \n"); | ||
356 | - memset(&sess, 0, sizeof(sess)); | ||
357 | - sess.cipher = CRYPTO_NULL; | ||
358 | - sess.keylen = 0; | ||
359 | - sess.key = (unsigned char *)keybuf; | ||
360 | - if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
361 | - perror("ioctl(CIOCGSESSION)"); | ||
362 | - return -EINVAL; | ||
363 | - } | ||
364 | - | ||
365 | - do_test_vectors(fdc, tp, &sess); | ||
366 | - return 0; | ||
367 | -} | ||
368 | - | ||
369 | -int run_aes_128_cbc(int fdc, struct test_params tp) | ||
370 | -{ | ||
371 | - struct session_op sess; | ||
372 | - char keybuf[32]; | ||
373 | - | ||
374 | - memset(&sess, 0, sizeof(sess)); | ||
375 | - sess.cipher = CRYPTO_AES_CBC; | ||
376 | - sess.keylen = 16; | ||
377 | - memset(keybuf, 0x42, 16); | ||
378 | - sess.key = (unsigned char *)keybuf; | ||
379 | - if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
380 | - perror("ioctl(CIOCGSESSION)"); | ||
381 | - return -EINVAL; | ||
382 | - } | ||
383 | - | ||
384 | - do_test_vectors(fdc, tp, &sess); | ||
385 | - return 0; | ||
386 | -} | ||
387 | - | ||
388 | -int run_aes_256_xts(int fdc, struct test_params tp) | ||
389 | -{ | ||
390 | - struct session_op sess; | ||
391 | - char keybuf[32]; | ||
392 | - | ||
393 | - memset(&sess, 0, sizeof(sess)); | ||
394 | - sess.cipher = CRYPTO_AES_XTS; | ||
395 | - sess.keylen = 32; | ||
396 | - memset(keybuf, 0x42, sess.keylen); | ||
397 | - sess.key = (unsigned char *)keybuf; | ||
398 | - if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
399 | - perror("ioctl(CIOCGSESSION)"); | ||
400 | - return -EINVAL; | ||
401 | - } | ||
402 | - | ||
403 | - do_test_vectors(fdc, tp, &sess); | ||
404 | - return 0; | ||
405 | -} | ||
406 | - | ||
407 | -int run_crc32c(int fdc, struct test_params tp) | ||
408 | -{ | ||
409 | - struct session_op sess; | ||
410 | - | ||
411 | - memset(&sess, 0, sizeof(sess)); | ||
412 | - sess.mac = CRYPTO_CRC32C; | ||
413 | - if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
414 | - perror("ioctl(CIOCGSESSION)"); | ||
415 | - return 1; | ||
416 | - } | ||
417 | - | ||
418 | - do_test_vectors(fdc, tp, &sess); | ||
419 | - return 0; | ||
420 | -} | ||
421 | - | ||
422 | -int run_sha1(int fdc, struct test_params tp) | ||
423 | -{ | ||
424 | - struct session_op sess; | ||
425 | - | ||
426 | - memset(&sess, 0, sizeof(sess)); | ||
427 | - sess.mac = CRYPTO_SHA1; | ||
428 | - if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
429 | - perror("ioctl(CIOCGSESSION)"); | ||
430 | - return 1; | ||
431 | - } | ||
432 | - | ||
433 | - do_test_vectors(fdc, tp, &sess); | ||
434 | - return 0; | ||
435 | -} | ||
436 | - | ||
437 | -int run_sha256(int fdc, struct test_params tp) | ||
438 | -{ | ||
439 | - struct session_op sess; | ||
440 | - | ||
441 | - memset(&sess, 0, sizeof(sess)); | ||
442 | - sess.mac = CRYPTO_SHA2_256; | ||
443 | - if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
444 | - perror("ioctl(CIOCGSESSION)"); | ||
445 | - return 1; | ||
446 | - } | ||
447 | - | ||
448 | - do_test_vectors(fdc, tp, &sess); | ||
449 | - return 0; | ||
450 | -} | ||
451 | - | ||
452 | -int main(int argc, char **argv) | ||
453 | -{ | ||
454 | - int err = 0; | ||
455 | - int i; | ||
456 | - int c; | ||
457 | - bool alg_flag; | ||
458 | - char *alg_name; | ||
459 | - struct test_params tp; | ||
460 | - | ||
461 | - tp.tflag = false; | ||
462 | - tp.nflag = false; | ||
463 | - tp.mflag = false; | ||
464 | - alg_flag = false; | ||
465 | - opterr = 0; | ||
466 | - while ((c = getopt(argc, argv, "hn:t:m")) != -1) { | ||
467 | - switch (c) { | ||
468 | - case 'n': | ||
469 | - tp.nvalue = atoi(optarg); | ||
470 | - tp.nflag = true; | ||
471 | - break; | ||
472 | - case 't': | ||
473 | - tp.tvalue = atoi(optarg); | ||
474 | - tp.tflag = true; | ||
475 | - break; | ||
476 | - case 'm': | ||
477 | - tp.mflag = true; | ||
478 | - break; | ||
479 | - case 'h': /* no break */ | ||
480 | - default: | ||
481 | - usage(argv[0]); | ||
482 | - exit(1); | ||
483 | - } | ||
484 | - } | ||
485 | - | ||
486 | - /* the name of a specific test asked on the command line */ | ||
487 | - if (optind < argc) { | ||
488 | - alg_name = argv[optind]; | ||
489 | - alg_flag = true; | ||
490 | - } | ||
491 | - | ||
492 | - /* default test time */ | ||
493 | - if (!tp.tflag) { | ||
494 | - tp.tvalue = 5; | ||
495 | - } | ||
496 | - | ||
497 | - signal(SIGALRM, alarm_handler); | ||
498 | - signal(SIGINT, exit_handler); | ||
499 | - | ||
500 | - for (i = 0; i < ALG_COUNT; i++) { | ||
501 | - if (must_exit) { | ||
502 | - break; | ||
503 | - } | ||
504 | - | ||
505 | - if (alg_flag) { | ||
506 | - if (strcmp(alg_name, ciphers[i].name) == 0) { | ||
507 | - err = run_test(i, tp); | ||
508 | - } | ||
509 | - } else { | ||
510 | - err = run_test(i, tp); | ||
511 | - if (err != 0) { | ||
512 | - break; | ||
513 | - } | ||
514 | - } | ||
515 | - } | ||
516 | - | ||
517 | - return err; | ||
518 | -} | ||
519 | - | ||
520 | -#else | ||
521 | -int | ||
522 | -main(int argc, char** argv) | ||
523 | -{ | ||
524 | - return (0); | ||
525 | -} | ||
526 | -#endif | ||
527 | diff --git a/tests/async_speed_multi.sh b/tests/async_speed_multi.sh | ||
528 | deleted file mode 100755 | ||
529 | index 90f9b72..0000000 | ||
530 | --- a/tests/async_speed_multi.sh | ||
531 | +++ /dev/null | ||
532 | @@ -1,172 +0,0 @@ | ||
533 | -#!/bin/bash | ||
534 | -# | ||
535 | -# Copyright 2016 NXP Semiconductors | ||
536 | -# | ||
537 | -# This program is free software: you can redistribute it and/or modify | ||
538 | -# it under the terms of the GNU General Public License as published by | ||
539 | -# the Free Software Foundation, either version 2 of the License, or | ||
540 | -# (at your option) any later version. | ||
541 | -# | ||
542 | -# This program is distributed in the hope that it will be useful, | ||
543 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
544 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
545 | -# GNU General Public License for more details. | ||
546 | -# | ||
547 | -# You should have received a copy of the GNU General Public License | ||
548 | -# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
549 | - | ||
550 | - | ||
551 | - | ||
552 | -# no user-configurable options below this line | ||
553 | - | ||
554 | -NUM_CORES=$(nproc) | ||
555 | -CMD_BIN="async_speed" | ||
556 | -OUT_BASENAME="async_speed" | ||
557 | -MPSTAT_OUT="mpstat_out" | ||
558 | - | ||
559 | -# A bigger hammer for mpstat to use ISO8601 time format (fixed in 11.2.2) | ||
560 | -export LC_TIME=en_GB.UTF-8 &> /dev/null | ||
561 | - | ||
562 | - | ||
563 | -function usage | ||
564 | -{ | ||
565 | -cat << EOF | ||
566 | -Usage: `basename $0` [OPTIONS] <alg_name> | ||
567 | - | ||
568 | - -m <threads> number of threads to run with (defaults to number of cores) | ||
569 | - -t <secs> time to run each test (default 10 secs) | ||
570 | - -n <bytes> size of the test buffer (default 256 bytes) | ||
571 | - -v make output more verbose (default tabular) | ||
572 | - -h show this help | ||
573 | - | ||
574 | -alg_name: null, aes-128-cbc, aes-256-xts, sha1, sha256, crc32c | ||
575 | - | ||
576 | -Note: SEC driver is configured to support buffers smaller than 512K | ||
577 | -EOF | ||
578 | -} | ||
579 | - | ||
580 | -function SUM { | ||
581 | - paste -sd+ - | bc -l | ||
582 | -} | ||
583 | - | ||
584 | -function get_cpu_idle | ||
585 | -{ | ||
586 | - header_line=$(grep %idle ${MPSTAT_OUT} | head -n 1 | sed 's/\s\+/ /g') | ||
587 | - idle_column=$(echo $header_line | wc -w) | ||
588 | - average_idle=$(grep Average ${MPSTAT_OUT} | sed 's/\s\+/ /g' | cut -d' ' -f ${idle_column} | tail -n 1) | ||
589 | - | ||
590 | - echo $average_idle | ||
591 | -} | ||
592 | - | ||
593 | -function run_parallel | ||
594 | -{ | ||
595 | - trap control_c SIGINT | ||
596 | - | ||
597 | - OPTIONS="-t $tvalue -n $nvalue -m" | ||
598 | - CMD="$CMD_BIN $OPTIONS $alg_name" | ||
599 | - | ||
600 | - (sleep 1; S_TIME_FORMAT=ISO mpstat 1 $(($tvalue-2))) &> $MPSTAT_OUT & | ||
601 | - MPSTAT_PID=$! | ||
602 | - | ||
603 | - PIDS="" | ||
604 | - start=$(date +%s.%N) | ||
605 | - | ||
606 | - for i in $(seq 0 $(($mvalue-1))) | ||
607 | - do | ||
608 | - CMD_OUT="${OUT_BASENAME}_${i}" | ||
609 | - | ||
610 | - $CMD &> $CMD_OUT & | ||
611 | - PID=$! | ||
612 | - AFFINITY=$(($i % $NUM_CORES)) | ||
613 | - taskset -pc $AFFINITY $PID > /dev/null | ||
614 | - | ||
615 | - PIDS="$PID $PIDS" | ||
616 | - done | ||
617 | - | ||
618 | - wait $PIDS | ||
619 | - end=$(date +%s.%N) | ||
620 | - | ||
621 | - wait $MPSTAT_PID | ||
622 | - | ||
623 | - grep "ioctl" ${OUT_BASENAME}_* &> /dev/null | ||
624 | - if (($? == 0)) | ||
625 | - then | ||
626 | - echo "cryptodev is not built with -DENABLE_ASYNC flag" | ||
627 | - exit 1 | ||
628 | - fi | ||
629 | - | ||
630 | - runtime=$(echo "scale=2; ($end - $start) / 1" | bc -l ) | ||
631 | - total_data=$(cat ${OUT_BASENAME}_* | cut -f 1 | SUM) | ||
632 | - avg_speed=$(echo "scale=2; $total_data / $runtime / 1000000000" | bc -l) | ||
633 | - cpu_idle=$(get_cpu_idle) | ||
634 | - | ||
635 | - if [ ! -z "$vvalue" ] | ||
636 | - then | ||
637 | - echo | ||
638 | - echo "buffer size : $nvalue" | ||
639 | - echo "running time : $runtime" | ||
640 | - echo "avg_speed : $avg_speed GB/s" | ||
641 | - echo "all_cpu idle : $cpu_idle %" | ||
642 | - echo | ||
643 | - else | ||
644 | - echo -e "algorithm\t""threads\t""run time\t"\ | ||
645 | - "buffer size\t""GB/s\t""%cpu idle" | ||
646 | - echo -e "${alg_name}\t${mvalue}\t${runtime}\t"\ | ||
647 | - "${nvalue}\t${avg_speed}\t${cpu_idle}%" | ||
648 | - fi | ||
649 | -} | ||
650 | - | ||
651 | -function control_c | ||
652 | -{ | ||
653 | - killall async_speed > /dev/null | ||
654 | - killall mpstat > /dev/null | ||
655 | -} | ||
656 | - | ||
657 | -function main | ||
658 | -{ | ||
659 | - [ ! -e "/dev/crypto" ] && | ||
660 | - (sudo modprobe cryptodev || modprobe cryptodev || exit 1) | ||
661 | - | ||
662 | - $(which ${CMD_BIN} &> /dev/null) | ||
663 | - if (($? != 0)) | ||
664 | - then | ||
665 | - echo "${CMD_BIN} test is not installed" | ||
666 | - exit 1 | ||
667 | - fi | ||
668 | - | ||
669 | - rm -f ${OUT_BASENAME}_* | ||
670 | - rm -f ${MPSTAT_OUT} | ||
671 | - | ||
672 | - while getopts vhm:t:n: option | ||
673 | - do | ||
674 | - case "$option" in | ||
675 | - m) mvalue="$OPTARG";; | ||
676 | - t) tvalue="$OPTARG";; | ||
677 | - n) nvalue="$OPTARG";; | ||
678 | - v) vvalue="verbose";; | ||
679 | - *) usage $0; exit 1;; | ||
680 | - esac | ||
681 | - done | ||
682 | - | ||
683 | - shift $((OPTIND-1)) | ||
684 | - alg_name=$1 | ||
685 | - | ||
686 | - [ -z "$tvalue" ] && tvalue=10 # 10 seconds per test by default | ||
687 | - [ -z "$mvalue" ] && mvalue=$NUM_CORES # thread count defaults to nproc | ||
688 | - [ -z "$nvalue" ] && nvalue=256 # 256 bytes default buffer size | ||
689 | - | ||
690 | - [ "$tvalue" -lt 5 ] && tvalue=5 | ||
691 | - | ||
692 | - case "$alg_name" in | ||
693 | - "null" |\ | ||
694 | - "aes-128-cbc" |\ | ||
695 | - "aes-256-xts" |\ | ||
696 | - "sha1" |\ | ||
697 | - "sha256" |\ | ||
698 | - "crc32c" ) run_parallel;; | ||
699 | - * ) usage && exit 1;; | ||
700 | - esac | ||
701 | -} | ||
702 | - | ||
703 | -main "$@" | ||
704 | - | ||
705 | diff --git a/tests/run_crypto_tests.sh b/tests/run_crypto_tests.sh | ||
706 | index 32ab8e2..e128637 100644 | ||
707 | --- a/tests/run_crypto_tests.sh | ||
708 | +++ b/tests/run_crypto_tests.sh | ||
709 | @@ -16,7 +16,7 @@ do | ||
710 | do | ||
711 | for bsize in ${BUF_SIZE} | ||
712 | do | ||
713 | - async_speed_multi.sh -t 10 -n $bsize -m ${multi} ${alg_name} | | ||
714 | + speed_multi.sh -t 10 -n $bsize -m ${multi} ${alg_name} | | ||
715 | tail -n 1 | ||
716 | done | ||
717 | done | ||
718 | diff --git a/tests/speed.c b/tests/speed.c | ||
719 | new file mode 100644 | ||
720 | index 0000000..3b36db1 | ||
721 | --- /dev/null | ||
722 | +++ b/tests/speed.c | ||
723 | @@ -0,0 +1,546 @@ | ||
724 | +/* cryptodev_test - simple benchmark tool for cryptodev | ||
725 | + * | ||
726 | + * Copyright (C) 2010 by Phil Sutter <phil.sutter@viprinet.com> | ||
727 | + * | ||
728 | + * This program is free software; you can redistribute it and/or modify | ||
729 | + * it under the terms of the GNU General Public License as published by | ||
730 | + * the Free Software Foundation; either version 2 of the License, or | ||
731 | + * (at your option) any later version. | ||
732 | + * | ||
733 | + * This program is distributed in the hope that it will be useful, | ||
734 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
735 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
736 | + * GNU General Public License for more details. | ||
737 | + * | ||
738 | + * You should have received a copy of the GNU General Public License | ||
739 | + * along with this program; if not, write to the Free Software | ||
740 | + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
741 | + */ | ||
742 | +#include <errno.h> | ||
743 | +#include <fcntl.h> | ||
744 | +#include <poll.h> | ||
745 | +#include <stdio.h> | ||
746 | +#include <stdlib.h> | ||
747 | +#include <string.h> | ||
748 | +#include <sys/ioctl.h> | ||
749 | +#include <sys/time.h> | ||
750 | +#include <sys/types.h> | ||
751 | +#include <signal.h> | ||
752 | +#include <crypto/cryptodev.h> | ||
753 | +#include <stdbool.h> | ||
754 | +#include <unistd.h> | ||
755 | +#include <stdint.h> | ||
756 | +#include <inttypes.h> | ||
757 | + | ||
758 | + | ||
759 | +struct test_params { | ||
760 | + bool tflag; | ||
761 | + bool nflag; | ||
762 | + bool mflag; | ||
763 | + bool aflag; | ||
764 | + int tvalue; | ||
765 | + int nvalue; | ||
766 | +}; | ||
767 | + | ||
768 | +const char usage_str[] = "Usage: %s [OPTION]... <cipher>|<hash>\n" | ||
769 | + "Run benchmark test for cipher or hash\n\n" | ||
770 | + " -t <secs>\t" "time to run each test (default 10 secs)\n" | ||
771 | + " -n <bytes>\t" "size of the test buffer\n" | ||
772 | + " -m\t\t" "output in a machine readable format\n" | ||
773 | + " -a\t\t" "run the async tests (default sync)\n" | ||
774 | + " -h\t\t" "show this help\n\n" | ||
775 | + "Note: SEC driver is configured to support buffers smaller than 512K\n" | ||
776 | +; | ||
777 | + | ||
778 | +int run_null(int fdc, struct test_params tp); | ||
779 | +int run_aes_128_cbc(int fdc, struct test_params tp); | ||
780 | +int run_aes_256_xts(int fdc, struct test_params tp); | ||
781 | +int run_crc32c(int fdc, struct test_params tp); | ||
782 | +int run_sha1(int fdc, struct test_params tp); | ||
783 | +int run_sha256(int fdc, struct test_params tp); | ||
784 | + | ||
785 | +#define ALG_COUNT 6 | ||
786 | +struct { | ||
787 | + char *name; | ||
788 | + int (*func)(int, struct test_params); | ||
789 | +} ciphers[ALG_COUNT] = { | ||
790 | + {"null", run_null}, | ||
791 | + {"aes-128-cbc", run_aes_128_cbc}, | ||
792 | + {"aes-256-xts", run_aes_256_xts}, | ||
793 | + {"crc32c", run_crc32c}, | ||
794 | + {"sha1", run_sha1}, | ||
795 | + {"sha256", run_sha256}, | ||
796 | +}; | ||
797 | + | ||
798 | +static double udifftimeval(struct timeval start, struct timeval end) | ||
799 | +{ | ||
800 | + return (double)(end.tv_usec - start.tv_usec) + | ||
801 | + (double)(end.tv_sec - start.tv_sec) * 1000 * 1000; | ||
802 | +} | ||
803 | + | ||
804 | +static volatile int must_finish; | ||
805 | +static volatile int must_exit; | ||
806 | +static struct pollfd pfd; | ||
807 | + | ||
808 | +static void alarm_handler(int signo) | ||
809 | +{ | ||
810 | + must_finish = 1; | ||
811 | + pfd.events = POLLIN; | ||
812 | +} | ||
813 | + | ||
814 | +static void exit_handler(int signo) | ||
815 | +{ | ||
816 | + must_exit = 1; | ||
817 | + printf("\nexit requested by user through ctrl+c \n"); | ||
818 | +} | ||
819 | + | ||
820 | +static char *units[] = { "", "Ki", "Mi", "Gi", "Ti", 0}; | ||
821 | + | ||
822 | +static void value2human(uint64_t bytes, double time, double* data, double* speed,char* metric) | ||
823 | +{ | ||
824 | + int unit = 0; | ||
825 | + | ||
826 | + *data = bytes; | ||
827 | + while (*data > 1024 && units[unit + 1]) { | ||
828 | + *data /= 1024; | ||
829 | + unit++; | ||
830 | + } | ||
831 | + *speed = *data / time; | ||
832 | + sprintf(metric, "%sB", units[unit]); | ||
833 | +} | ||
834 | + | ||
835 | +static void value2machine(uint64_t bytes, double time, double* speed) | ||
836 | +{ | ||
837 | + *speed = bytes / time; | ||
838 | +} | ||
839 | + | ||
840 | +int get_alignmask(int fdc, struct session_op *sess) | ||
841 | +{ | ||
842 | + int alignmask; | ||
843 | + int min_alignmask = sizeof(void*) - 1; | ||
844 | + | ||
845 | +#ifdef CIOCGSESSINFO | ||
846 | + struct session_info_op siop; | ||
847 | + | ||
848 | + siop.ses = sess->ses; | ||
849 | + if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
850 | + perror("ioctl(CIOCGSESSINFO)"); | ||
851 | + return -EINVAL; | ||
852 | + } | ||
853 | + alignmask = siop.alignmask; | ||
854 | + if (alignmask < min_alignmask) { | ||
855 | + alignmask = min_alignmask; | ||
856 | + } | ||
857 | +#else | ||
858 | + alignmask = 0; | ||
859 | +#endif | ||
860 | + | ||
861 | + return alignmask; | ||
862 | +} | ||
863 | + | ||
864 | +int encrypt_async(int fdc, struct test_params tp, struct session_op *sess) | ||
865 | +{ | ||
866 | + struct crypt_op cop; | ||
867 | + char *buffer[64], iv[32]; | ||
868 | + uint8_t mac[64][HASH_MAX_LEN]; | ||
869 | + static int val = 23; | ||
870 | + struct timeval start, end; | ||
871 | + uint64_t total = 0; | ||
872 | + double secs, ddata, dspeed; | ||
873 | + char metric[16]; | ||
874 | + int rc, wqueue = 0, bufidx = 0; | ||
875 | + int alignmask; | ||
876 | + | ||
877 | + memset(iv, 0x23, 32); | ||
878 | + | ||
879 | + if (!tp.mflag) { | ||
880 | + printf("\tBuffer size %d bytes: ", tp.nvalue); | ||
881 | + fflush(stdout); | ||
882 | + } | ||
883 | + | ||
884 | + alignmask = get_alignmask(fdc, sess); | ||
885 | + for (rc = 0; rc < 64; rc++) { | ||
886 | + if (alignmask) { | ||
887 | + if (posix_memalign((void **)(buffer + rc), alignmask + 1, tp.nvalue)) { | ||
888 | + printf("posix_memalign() failed!\n"); | ||
889 | + return 1; | ||
890 | + } | ||
891 | + } else { | ||
892 | + if (!(buffer[rc] = malloc(tp.nvalue))) { | ||
893 | + perror("malloc()"); | ||
894 | + return 1; | ||
895 | + } | ||
896 | + } | ||
897 | + memset(buffer[rc], val++, tp.nvalue); | ||
898 | + } | ||
899 | + pfd.fd = fdc; | ||
900 | + pfd.events = POLLOUT | POLLIN; | ||
901 | + | ||
902 | + must_finish = 0; | ||
903 | + alarm(tp.tvalue); | ||
904 | + | ||
905 | + gettimeofday(&start, NULL); | ||
906 | + do { | ||
907 | + if ((rc = poll(&pfd, 1, 100)) < 0) { | ||
908 | + if (errno & (ERESTART | EINTR)) | ||
909 | + continue; | ||
910 | + fprintf(stderr, "errno = %d ", errno); | ||
911 | + perror("poll()"); | ||
912 | + return 1; | ||
913 | + } | ||
914 | + | ||
915 | + if (pfd.revents & POLLOUT) { | ||
916 | + memset(&cop, 0, sizeof(cop)); | ||
917 | + cop.ses = sess->ses; | ||
918 | + cop.len = tp.nvalue; | ||
919 | + cop.iv = (unsigned char *)iv; | ||
920 | + cop.op = COP_ENCRYPT; | ||
921 | + cop.src = cop.dst = (unsigned char *)buffer[bufidx]; | ||
922 | + cop.mac = mac[bufidx]; | ||
923 | + bufidx = (bufidx + 1) % 64; | ||
924 | + | ||
925 | + if (ioctl(fdc, CIOCASYNCCRYPT, &cop)) { | ||
926 | + perror("ioctl(CIOCASYNCCRYPT)"); | ||
927 | + return 1; | ||
928 | + } | ||
929 | + wqueue++; | ||
930 | + } | ||
931 | + if (pfd.revents & POLLIN) { | ||
932 | + if (ioctl(fdc, CIOCASYNCFETCH, &cop)) { | ||
933 | + perror("ioctl(CIOCASYNCFETCH)"); | ||
934 | + return 1; | ||
935 | + } | ||
936 | + wqueue--; | ||
937 | + total += cop.len; | ||
938 | + } | ||
939 | + } while(!must_finish || wqueue); | ||
940 | + gettimeofday(&end, NULL); | ||
941 | + | ||
942 | + secs = udifftimeval(start, end)/ 1000000.0; | ||
943 | + | ||
944 | + if (tp.mflag) { | ||
945 | + value2machine(total, secs, &dspeed); | ||
946 | + printf("%" PRIu64 "\t%.2f\t%.2f\n", total, secs, dspeed); | ||
947 | + } else { | ||
948 | + value2human(total, secs, &ddata, &dspeed, metric); | ||
949 | + printf ("done. %.2f %s in %.2f secs: ", ddata, metric, secs); | ||
950 | + printf ("%.2f %s/sec\n", dspeed, metric); | ||
951 | + } | ||
952 | + | ||
953 | + for (rc = 0; rc < 64; rc++) | ||
954 | + free(buffer[rc]); | ||
955 | + return 0; | ||
956 | +} | ||
957 | + | ||
958 | + | ||
959 | +static int encrypt_sync(int fdc, struct test_params tp, struct session_op *sess) | ||
960 | +{ | ||
961 | + struct crypt_op cop; | ||
962 | + char *buffer, iv[32]; | ||
963 | + char mac[HASH_MAX_LEN]; | ||
964 | + static int val = 23; | ||
965 | + struct timeval start, end; | ||
966 | + uint64_t total = 0; | ||
967 | + double secs, ddata, dspeed; | ||
968 | + char metric[16]; | ||
969 | + int alignmask; | ||
970 | + int min_alignmask = sizeof(void*) - 1; | ||
971 | + | ||
972 | + memset(iv, 0x23, 32); | ||
973 | + | ||
974 | + if (!tp.mflag) { | ||
975 | + printf("\tBuffer size %d bytes: ", tp.nvalue); | ||
976 | + fflush(stdout); | ||
977 | + } | ||
978 | + | ||
979 | + alignmask = get_alignmask(fdc, sess); | ||
980 | + if (alignmask) { | ||
981 | + alignmask = ((alignmask < min_alignmask) ? min_alignmask : alignmask); | ||
982 | + if (posix_memalign((void **)(&buffer), alignmask + 1, tp.nvalue)) { | ||
983 | + printf("posix_memalign() failed!\n"); | ||
984 | + return 1; | ||
985 | + } | ||
986 | + } else { | ||
987 | + if (!(buffer = malloc(tp.nvalue))) { | ||
988 | + perror("malloc()"); | ||
989 | + return 1; | ||
990 | + } | ||
991 | + } | ||
992 | + memset(buffer, val++, tp.nvalue); | ||
993 | + | ||
994 | + must_finish = 0; | ||
995 | + alarm(tp.tvalue); | ||
996 | + | ||
997 | + gettimeofday(&start, NULL); | ||
998 | + do { | ||
999 | + memset(&cop, 0, sizeof(cop)); | ||
1000 | + cop.ses = sess->ses; | ||
1001 | + cop.len = tp.nvalue; | ||
1002 | + cop.iv = (unsigned char *)iv; | ||
1003 | + cop.op = COP_ENCRYPT; | ||
1004 | + cop.src = cop.dst = (unsigned char *)buffer; | ||
1005 | + cop.mac = (unsigned char *)mac; | ||
1006 | + | ||
1007 | + if (ioctl(fdc, CIOCCRYPT, &cop)) { | ||
1008 | + perror("ioctl(CIOCCRYPT)"); | ||
1009 | + return 1; | ||
1010 | + } | ||
1011 | + total += cop.len; | ||
1012 | + } while(!must_finish); | ||
1013 | + gettimeofday(&end, NULL); | ||
1014 | + | ||
1015 | + secs = udifftimeval(start, end)/ 1000000.0; | ||
1016 | + | ||
1017 | + if (tp.mflag) { | ||
1018 | + value2machine(total, secs, &dspeed); | ||
1019 | + printf("%" PRIu64 "\t%.2f\t%.2f\n", total, secs, dspeed); | ||
1020 | + } else { | ||
1021 | + value2human(total, secs, &ddata, &dspeed, metric); | ||
1022 | + printf ("done. %.2f %s in %.2f secs: ", ddata, metric, secs); | ||
1023 | + printf ("%.2f %s/sec\n", dspeed, metric); | ||
1024 | + } | ||
1025 | + | ||
1026 | + free(buffer); | ||
1027 | + return 0; | ||
1028 | +} | ||
1029 | + | ||
1030 | +void usage(char *cmd_name) | ||
1031 | +{ | ||
1032 | + printf(usage_str, cmd_name); | ||
1033 | +} | ||
1034 | + | ||
1035 | +int run_test(int id, struct test_params tp) | ||
1036 | +{ | ||
1037 | + int fd; | ||
1038 | + int fdc; | ||
1039 | + int err; | ||
1040 | + | ||
1041 | + fd = open("/dev/crypto", O_RDWR, 0); | ||
1042 | + if (fd < 0) { | ||
1043 | + perror("open()"); | ||
1044 | + return fd; | ||
1045 | + } | ||
1046 | + if (ioctl(fd, CRIOGET, &fdc)) { | ||
1047 | + perror("ioctl(CRIOGET)"); | ||
1048 | + return -EINVAL; | ||
1049 | + } | ||
1050 | + | ||
1051 | + if (!tp.mflag) { | ||
1052 | + char *type; | ||
1053 | + type = tp.aflag ? "async" : "sync"; | ||
1054 | + | ||
1055 | + fprintf(stderr, "Testing %s %s:\n", type, ciphers[id].name); | ||
1056 | + } | ||
1057 | + err = ciphers[id].func(fdc, tp); | ||
1058 | + | ||
1059 | + close(fdc); | ||
1060 | + close(fd); | ||
1061 | + | ||
1062 | + return err; | ||
1063 | +} | ||
1064 | + | ||
1065 | +void do_test_vectors(int fdc, struct test_params tp, struct session_op *sess) | ||
1066 | +{ | ||
1067 | + int i; | ||
1068 | + int err; | ||
1069 | + | ||
1070 | + if (tp.nflag) { | ||
1071 | + if (tp.aflag) { | ||
1072 | + encrypt_async(fdc, tp, sess); | ||
1073 | + } else { | ||
1074 | + encrypt_sync(fdc, tp, sess); | ||
1075 | + } | ||
1076 | + } else { | ||
1077 | + for (i = 256; i <= (64 * 1024); i *= 2) { | ||
1078 | + if (must_exit) { | ||
1079 | + break; | ||
1080 | + } | ||
1081 | + | ||
1082 | + tp.nvalue = i; | ||
1083 | + if (tp.aflag) { | ||
1084 | + err = encrypt_async(fdc, tp, sess); | ||
1085 | + } else { | ||
1086 | + err = encrypt_sync(fdc, tp, sess); | ||
1087 | + } | ||
1088 | + | ||
1089 | + if (err != 0) { | ||
1090 | + break; | ||
1091 | + } | ||
1092 | + } | ||
1093 | + } | ||
1094 | +} | ||
1095 | + | ||
1096 | + | ||
1097 | +int run_null(int fdc, struct test_params tp) | ||
1098 | +{ | ||
1099 | + struct session_op sess; | ||
1100 | + char keybuf[32]; | ||
1101 | + | ||
1102 | + fprintf(stderr, "Testing NULL cipher: \n"); | ||
1103 | + memset(&sess, 0, sizeof(sess)); | ||
1104 | + sess.cipher = CRYPTO_NULL; | ||
1105 | + sess.keylen = 0; | ||
1106 | + sess.key = (unsigned char *)keybuf; | ||
1107 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
1108 | + perror("ioctl(CIOCGSESSION)"); | ||
1109 | + return -EINVAL; | ||
1110 | + } | ||
1111 | + | ||
1112 | + do_test_vectors(fdc, tp, &sess); | ||
1113 | + return 0; | ||
1114 | +} | ||
1115 | + | ||
1116 | +int run_aes_128_cbc(int fdc, struct test_params tp) | ||
1117 | +{ | ||
1118 | + struct session_op sess; | ||
1119 | + char keybuf[32]; | ||
1120 | + | ||
1121 | + memset(&sess, 0, sizeof(sess)); | ||
1122 | + sess.cipher = CRYPTO_AES_CBC; | ||
1123 | + sess.keylen = 16; | ||
1124 | + memset(keybuf, 0x42, 16); | ||
1125 | + sess.key = (unsigned char *)keybuf; | ||
1126 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
1127 | + perror("ioctl(CIOCGSESSION)"); | ||
1128 | + return -EINVAL; | ||
1129 | + } | ||
1130 | + | ||
1131 | + do_test_vectors(fdc, tp, &sess); | ||
1132 | + return 0; | ||
1133 | +} | ||
1134 | + | ||
1135 | +int run_aes_256_xts(int fdc, struct test_params tp) | ||
1136 | +{ | ||
1137 | + struct session_op sess; | ||
1138 | + char keybuf[32]; | ||
1139 | + | ||
1140 | + memset(&sess, 0, sizeof(sess)); | ||
1141 | + sess.cipher = CRYPTO_AES_XTS; | ||
1142 | + sess.keylen = 32; | ||
1143 | + memset(keybuf, 0x42, sess.keylen); | ||
1144 | + sess.key = (unsigned char *)keybuf; | ||
1145 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
1146 | + perror("ioctl(CIOCGSESSION)"); | ||
1147 | + return -EINVAL; | ||
1148 | + } | ||
1149 | + | ||
1150 | + do_test_vectors(fdc, tp, &sess); | ||
1151 | + return 0; | ||
1152 | +} | ||
1153 | + | ||
1154 | +int run_crc32c(int fdc, struct test_params tp) | ||
1155 | +{ | ||
1156 | + struct session_op sess; | ||
1157 | + | ||
1158 | + memset(&sess, 0, sizeof(sess)); | ||
1159 | + sess.mac = CRYPTO_CRC32C; | ||
1160 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
1161 | + perror("ioctl(CIOCGSESSION)"); | ||
1162 | + return 1; | ||
1163 | + } | ||
1164 | + | ||
1165 | + do_test_vectors(fdc, tp, &sess); | ||
1166 | + return 0; | ||
1167 | +} | ||
1168 | + | ||
1169 | +int run_sha1(int fdc, struct test_params tp) | ||
1170 | +{ | ||
1171 | + struct session_op sess; | ||
1172 | + | ||
1173 | + memset(&sess, 0, sizeof(sess)); | ||
1174 | + sess.mac = CRYPTO_SHA1; | ||
1175 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
1176 | + perror("ioctl(CIOCGSESSION)"); | ||
1177 | + return 1; | ||
1178 | + } | ||
1179 | + | ||
1180 | + do_test_vectors(fdc, tp, &sess); | ||
1181 | + return 0; | ||
1182 | +} | ||
1183 | + | ||
1184 | +int run_sha256(int fdc, struct test_params tp) | ||
1185 | +{ | ||
1186 | + struct session_op sess; | ||
1187 | + | ||
1188 | + memset(&sess, 0, sizeof(sess)); | ||
1189 | + sess.mac = CRYPTO_SHA2_256; | ||
1190 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
1191 | + perror("ioctl(CIOCGSESSION)"); | ||
1192 | + return 1; | ||
1193 | + } | ||
1194 | + | ||
1195 | + do_test_vectors(fdc, tp, &sess); | ||
1196 | + return 0; | ||
1197 | +} | ||
1198 | + | ||
1199 | +int main(int argc, char **argv) | ||
1200 | +{ | ||
1201 | + int err = 0; | ||
1202 | + int i; | ||
1203 | + int c; | ||
1204 | + bool alg_flag; | ||
1205 | + char *alg_name; | ||
1206 | + struct test_params tp; | ||
1207 | + | ||
1208 | + tp.tflag = false; | ||
1209 | + tp.nflag = false; | ||
1210 | + tp.mflag = false; | ||
1211 | + tp.aflag = false; | ||
1212 | + alg_flag = false; | ||
1213 | + opterr = 0; | ||
1214 | + while ((c = getopt(argc, argv, "ahn:t:m")) != -1) { | ||
1215 | + switch (c) { | ||
1216 | + case 'n': | ||
1217 | + tp.nvalue = atoi(optarg); | ||
1218 | + tp.nflag = true; | ||
1219 | + break; | ||
1220 | + case 't': | ||
1221 | + tp.tvalue = atoi(optarg); | ||
1222 | + tp.tflag = true; | ||
1223 | + break; | ||
1224 | + case 'm': | ||
1225 | + tp.mflag = true; | ||
1226 | + break; | ||
1227 | + case 'a': | ||
1228 | + tp.aflag = true; | ||
1229 | + break; | ||
1230 | + case 'h': /* no break */ | ||
1231 | + default: | ||
1232 | + usage(argv[0]); | ||
1233 | + exit(1); | ||
1234 | + } | ||
1235 | + } | ||
1236 | + | ||
1237 | + /* the name of a specific test asked on the command line */ | ||
1238 | + if (optind < argc) { | ||
1239 | + alg_name = argv[optind]; | ||
1240 | + alg_flag = true; | ||
1241 | + } | ||
1242 | + | ||
1243 | + /* default test time */ | ||
1244 | + if (!tp.tflag) { | ||
1245 | + tp.tvalue = 5; | ||
1246 | + } | ||
1247 | + | ||
1248 | + signal(SIGALRM, alarm_handler); | ||
1249 | + signal(SIGINT, exit_handler); | ||
1250 | + | ||
1251 | + for (i = 0; i < ALG_COUNT; i++) { | ||
1252 | + if (must_exit) { | ||
1253 | + break; | ||
1254 | + } | ||
1255 | + | ||
1256 | + if (alg_flag) { | ||
1257 | + if (strcmp(alg_name, ciphers[i].name) == 0) { | ||
1258 | + err = run_test(i, tp); | ||
1259 | + } | ||
1260 | + } else { | ||
1261 | + err = run_test(i, tp); | ||
1262 | + if (err != 0) { | ||
1263 | + break; | ||
1264 | + } | ||
1265 | + } | ||
1266 | + } | ||
1267 | + | ||
1268 | + return err; | ||
1269 | +} | ||
1270 | diff --git a/tests/speed_multi.sh b/tests/speed_multi.sh | ||
1271 | new file mode 100755 | ||
1272 | index 0000000..b116483 | ||
1273 | --- /dev/null | ||
1274 | +++ b/tests/speed_multi.sh | ||
1275 | @@ -0,0 +1,174 @@ | ||
1276 | +#!/bin/bash | ||
1277 | +# | ||
1278 | +# Copyright 2016 NXP Semiconductors | ||
1279 | +# | ||
1280 | +# This program is free software: you can redistribute it and/or modify | ||
1281 | +# it under the terms of the GNU General Public License as published by | ||
1282 | +# the Free Software Foundation, either version 2 of the License, or | ||
1283 | +# (at your option) any later version. | ||
1284 | +# | ||
1285 | +# This program is distributed in the hope that it will be useful, | ||
1286 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1287 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1288 | +# GNU General Public License for more details. | ||
1289 | +# | ||
1290 | +# You should have received a copy of the GNU General Public License | ||
1291 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1292 | + | ||
1293 | + | ||
1294 | + | ||
1295 | +# no user-configurable options below this line | ||
1296 | + | ||
1297 | +NUM_CORES=$(nproc) | ||
1298 | +CMD_BIN="speed" | ||
1299 | +OUT_BASENAME="speed" | ||
1300 | +MPSTAT_OUT="mpstat_out" | ||
1301 | + | ||
1302 | +# A bigger hammer for mpstat to use ISO8601 time format (fixed in 11.2.2) | ||
1303 | +export LC_TIME=en_GB.UTF-8 &> /dev/null | ||
1304 | + | ||
1305 | + | ||
1306 | +function usage | ||
1307 | +{ | ||
1308 | +cat << EOF | ||
1309 | +Usage: `basename $0` [OPTIONS] <alg_name> | ||
1310 | + | ||
1311 | + -m <threads> number of threads to run with (defaults to number of cores) | ||
1312 | + -t <secs> time to run each test (default 10 secs) | ||
1313 | + -n <bytes> size of the test buffer (default 256 bytes) | ||
1314 | + -v make output more verbose (default tabular) | ||
1315 | + -a run async version of the benchmark (default sync) | ||
1316 | + -h show this help | ||
1317 | + | ||
1318 | +alg_name: null, aes-128-cbc, aes-256-xts, sha1, sha256, crc32c | ||
1319 | + | ||
1320 | +Note: SEC driver is configured to support buffers smaller than 512K | ||
1321 | +EOF | ||
1322 | +} | ||
1323 | + | ||
1324 | +function SUM { | ||
1325 | + paste -sd+ - | bc -l | ||
1326 | +} | ||
1327 | + | ||
1328 | +function get_cpu_idle | ||
1329 | +{ | ||
1330 | + header_line=$(grep %idle ${MPSTAT_OUT} | head -n 1 | sed 's/\s\+/ /g') | ||
1331 | + idle_column=$(echo $header_line | wc -w) | ||
1332 | + average_idle=$(grep Average ${MPSTAT_OUT} | sed 's/\s\+/ /g' | cut -d' ' -f ${idle_column} | tail -n 1) | ||
1333 | + | ||
1334 | + echo $average_idle | ||
1335 | +} | ||
1336 | + | ||
1337 | +function run_parallel | ||
1338 | +{ | ||
1339 | + trap control_c SIGINT | ||
1340 | + | ||
1341 | + OPTIONS="-t $tvalue -n $nvalue -m $aflag" | ||
1342 | + CMD="$CMD_BIN $OPTIONS $alg_name" | ||
1343 | + | ||
1344 | + (sleep 1; S_TIME_FORMAT=ISO mpstat 1 $(($tvalue-2))) &> $MPSTAT_OUT & | ||
1345 | + MPSTAT_PID=$! | ||
1346 | + | ||
1347 | + PIDS="" | ||
1348 | + start=$(date +%s.%N) | ||
1349 | + | ||
1350 | + for i in $(seq 0 $(($mvalue-1))) | ||
1351 | + do | ||
1352 | + CMD_OUT="${OUT_BASENAME}_${i}" | ||
1353 | + | ||
1354 | + $CMD &> $CMD_OUT & | ||
1355 | + PID=$! | ||
1356 | + AFFINITY=$(($i % $NUM_CORES)) | ||
1357 | + taskset -pc $AFFINITY $PID > /dev/null | ||
1358 | + | ||
1359 | + PIDS="$PID $PIDS" | ||
1360 | + done | ||
1361 | + | ||
1362 | + wait $PIDS | ||
1363 | + end=$(date +%s.%N) | ||
1364 | + | ||
1365 | + wait $MPSTAT_PID | ||
1366 | + | ||
1367 | + grep "ioctl" ${OUT_BASENAME}_* &> /dev/null | ||
1368 | + if (($? == 0)) | ||
1369 | + then | ||
1370 | + echo "cryptodev is not built with -DENABLE_ASYNC flag" | ||
1371 | + exit 1 | ||
1372 | + fi | ||
1373 | + | ||
1374 | + runtime=$(echo "scale=2; ($end - $start) / 1" | bc -l ) | ||
1375 | + total_data=$(cat ${OUT_BASENAME}_* | cut -f 1 | SUM) | ||
1376 | + avg_speed=$(echo "scale=2; $total_data / $runtime / 1000000000" | bc -l) | ||
1377 | + cpu_idle=$(get_cpu_idle) | ||
1378 | + | ||
1379 | + if [ ! -z "$vflag" ] | ||
1380 | + then | ||
1381 | + echo | ||
1382 | + echo "buffer size : $nvalue" | ||
1383 | + echo "running time : $runtime" | ||
1384 | + echo "avg_speed : $avg_speed GB/s" | ||
1385 | + echo "all_cpu idle : $cpu_idle %" | ||
1386 | + echo | ||
1387 | + else | ||
1388 | + echo -e "algorithm\t""threads\t""run time\t"\ | ||
1389 | + "buffer size\t""GB/s\t""%cpu idle" | ||
1390 | + echo -e "${alg_name}\t${mvalue}\t${runtime}\t"\ | ||
1391 | + "${nvalue}\t${avg_speed}\t${cpu_idle}%" | ||
1392 | + fi | ||
1393 | +} | ||
1394 | + | ||
1395 | +function control_c | ||
1396 | +{ | ||
1397 | + killall $CMD_BIN > /dev/null | ||
1398 | + killall mpstat > /dev/null | ||
1399 | +} | ||
1400 | + | ||
1401 | +function main | ||
1402 | +{ | ||
1403 | + [ ! -e "/dev/crypto" ] && | ||
1404 | + (sudo modprobe cryptodev || modprobe cryptodev || exit 1) | ||
1405 | + | ||
1406 | + $(which ${CMD_BIN} &> /dev/null) | ||
1407 | + if (($? != 0)) | ||
1408 | + then | ||
1409 | + echo "${CMD_BIN} test is not installed" | ||
1410 | + exit 1 | ||
1411 | + fi | ||
1412 | + | ||
1413 | + rm -f ${OUT_BASENAME}_* | ||
1414 | + rm -f ${MPSTAT_OUT} | ||
1415 | + | ||
1416 | + while getopts avhm:t:n: option | ||
1417 | + do | ||
1418 | + case "$option" in | ||
1419 | + m) mvalue="$OPTARG";; | ||
1420 | + t) tvalue="$OPTARG";; | ||
1421 | + n) nvalue="$OPTARG";; | ||
1422 | + v) vflag="verbose";; | ||
1423 | + a) aflag="-a";; | ||
1424 | + *) usage $0; exit 1;; | ||
1425 | + esac | ||
1426 | + done | ||
1427 | + | ||
1428 | + shift $((OPTIND-1)) | ||
1429 | + alg_name=$1 | ||
1430 | + | ||
1431 | + [ -z "$tvalue" ] && tvalue=10 # 10 seconds per test by default | ||
1432 | + [ -z "$mvalue" ] && mvalue=$NUM_CORES # thread count defaults to nproc | ||
1433 | + [ -z "$nvalue" ] && nvalue=256 # 256 bytes default buffer size | ||
1434 | + | ||
1435 | + [ "$tvalue" -lt 5 ] && tvalue=5 | ||
1436 | + | ||
1437 | + case "$alg_name" in | ||
1438 | + "null" |\ | ||
1439 | + "aes-128-cbc" |\ | ||
1440 | + "aes-256-xts" |\ | ||
1441 | + "sha1" |\ | ||
1442 | + "sha256" |\ | ||
1443 | + "crc32c" ) run_parallel;; | ||
1444 | + * ) usage && exit 1;; | ||
1445 | + esac | ||
1446 | +} | ||
1447 | + | ||
1448 | +main "$@" | ||
1449 | + | ||
1450 | diff --git a/tests/sync_speed.c b/tests/sync_speed.c | ||
1451 | deleted file mode 100644 | ||
1452 | index ceae645..0000000 | ||
1453 | --- a/tests/sync_speed.c | ||
1454 | +++ /dev/null | ||
1455 | @@ -1,400 +0,0 @@ | ||
1456 | -/* cryptodev_test - simple benchmark tool for cryptodev | ||
1457 | - * | ||
1458 | - * Copyright (C) 2010 by Phil Sutter <phil.sutter@viprinet.com> | ||
1459 | - * | ||
1460 | - * This program is free software; you can redistribute it and/or modify | ||
1461 | - * it under the terms of the GNU General Public License as published by | ||
1462 | - * the Free Software Foundation; either version 2 of the License, or | ||
1463 | - * (at your option) any later version. | ||
1464 | - * | ||
1465 | - * This program is distributed in the hope that it will be useful, | ||
1466 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1467 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1468 | - * GNU General Public License for more details. | ||
1469 | - * | ||
1470 | - * You should have received a copy of the GNU General Public License | ||
1471 | - * along with this program; if not, write to the Free Software | ||
1472 | - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
1473 | - */ | ||
1474 | -#include <errno.h> | ||
1475 | -#include <fcntl.h> | ||
1476 | -#include <poll.h> | ||
1477 | -#include <stdio.h> | ||
1478 | -#include <stdlib.h> | ||
1479 | -#include <string.h> | ||
1480 | -#include <sys/ioctl.h> | ||
1481 | -#include <sys/time.h> | ||
1482 | -#include <sys/types.h> | ||
1483 | -#include <signal.h> | ||
1484 | -#include <crypto/cryptodev.h> | ||
1485 | -#include <stdbool.h> | ||
1486 | -#include <unistd.h> | ||
1487 | - | ||
1488 | -struct test_params { | ||
1489 | - bool tflag; | ||
1490 | - bool nflag; | ||
1491 | - int tvalue; | ||
1492 | - int nvalue; | ||
1493 | -}; | ||
1494 | - | ||
1495 | -const char usage_str[] = "Usage: %s [OPTION]... <cipher>|<hash>\n" | ||
1496 | - "Run benchmark test for cipher or hash\n\n" | ||
1497 | - " -t <secs>\t" "time to run each test (default 10 secs)\n" | ||
1498 | - " -n <bytes>\t" "size of the test buffer\n" | ||
1499 | - " -h\t\t" "show this help\n\n" | ||
1500 | - "Note: SEC driver is configured to support buffers smaller than 512K\n" | ||
1501 | -; | ||
1502 | - | ||
1503 | -int run_null(int fdc, struct test_params tp); | ||
1504 | -int run_aes_128_cbc(int fdc, struct test_params tp); | ||
1505 | -int run_aes_256_xts(int fdc, struct test_params tp); | ||
1506 | -int run_crc32c(int fdc, struct test_params tp); | ||
1507 | -int run_sha1(int fdc, struct test_params tp); | ||
1508 | -int run_sha256(int fdc, struct test_params tp); | ||
1509 | -int get_alignmask(int fdc, struct session_op *sess); | ||
1510 | - | ||
1511 | -#define ALG_COUNT 6 | ||
1512 | -struct { | ||
1513 | - char *name; | ||
1514 | - int (*func)(int, struct test_params); | ||
1515 | -} ciphers[ALG_COUNT] = { | ||
1516 | - {"null", run_null}, | ||
1517 | - {"aes-128-cbc", run_aes_128_cbc}, | ||
1518 | - {"aes-256-xts", run_aes_256_xts}, | ||
1519 | - {"crc32c", run_crc32c}, | ||
1520 | - {"sha1", run_sha1}, | ||
1521 | - {"sha256", run_sha256}, | ||
1522 | -}; | ||
1523 | - | ||
1524 | -static double udifftimeval(struct timeval start, struct timeval end) | ||
1525 | -{ | ||
1526 | - return (double)(end.tv_usec - start.tv_usec) + | ||
1527 | - (double)(end.tv_sec - start.tv_sec) * 1000 * 1000; | ||
1528 | -} | ||
1529 | - | ||
1530 | -static volatile int must_finish; | ||
1531 | -static volatile int must_exit; | ||
1532 | - | ||
1533 | -static void alarm_handler(int signo) | ||
1534 | -{ | ||
1535 | - must_finish = 1; | ||
1536 | -} | ||
1537 | - | ||
1538 | -static void exit_handler(int signo) | ||
1539 | -{ | ||
1540 | - must_exit = 1; | ||
1541 | - printf("\nexit requested by user through ctrl+c \n"); | ||
1542 | -} | ||
1543 | - | ||
1544 | -static char *units[] = { "", "Ki", "Mi", "Gi", "Ti", 0}; | ||
1545 | - | ||
1546 | -static void value2human(double bytes, double time, double* data, double* speed,char* metric) | ||
1547 | -{ | ||
1548 | - int unit = 0; | ||
1549 | - | ||
1550 | - *data = bytes; | ||
1551 | - while (*data > 1024 && units[unit + 1]) { | ||
1552 | - *data /= 1024; | ||
1553 | - unit++; | ||
1554 | - } | ||
1555 | - *speed = *data / time; | ||
1556 | - sprintf(metric, "%sB", units[unit]); | ||
1557 | -} | ||
1558 | - | ||
1559 | -static int encrypt_data(int fdc, struct test_params tp, struct session_op *sess) | ||
1560 | -{ | ||
1561 | - struct crypt_op cop; | ||
1562 | - char *buffer, iv[32]; | ||
1563 | - char mac[HASH_MAX_LEN]; | ||
1564 | - static int val = 23; | ||
1565 | - struct timeval start, end; | ||
1566 | - double total = 0; | ||
1567 | - double secs, ddata, dspeed; | ||
1568 | - char metric[16]; | ||
1569 | - int alignmask; | ||
1570 | - int min_alignmask = sizeof(void*) - 1; | ||
1571 | - | ||
1572 | - memset(iv, 0x23, 32); | ||
1573 | - | ||
1574 | - printf("\tEncrypting in chunks of %d bytes: ", tp.nvalue); | ||
1575 | - fflush(stdout); | ||
1576 | - | ||
1577 | - alignmask = get_alignmask(fdc, sess); | ||
1578 | - if (alignmask) { | ||
1579 | - alignmask = ((alignmask < min_alignmask) ? min_alignmask : alignmask); | ||
1580 | - if (posix_memalign((void **)(&buffer), alignmask + 1, tp.nvalue)) { | ||
1581 | - printf("posix_memalign() failed!\n"); | ||
1582 | - return 1; | ||
1583 | - } | ||
1584 | - } else { | ||
1585 | - if (!(buffer = malloc(tp.nvalue))) { | ||
1586 | - perror("malloc()"); | ||
1587 | - return 1; | ||
1588 | - } | ||
1589 | - } | ||
1590 | - memset(buffer, val++, tp.nvalue); | ||
1591 | - | ||
1592 | - must_finish = 0; | ||
1593 | - alarm(tp.tvalue); | ||
1594 | - | ||
1595 | - gettimeofday(&start, NULL); | ||
1596 | - do { | ||
1597 | - memset(&cop, 0, sizeof(cop)); | ||
1598 | - cop.ses = sess->ses; | ||
1599 | - cop.len = tp.nvalue; | ||
1600 | - cop.iv = (unsigned char *)iv; | ||
1601 | - cop.op = COP_ENCRYPT; | ||
1602 | - cop.src = cop.dst = (unsigned char *)buffer; | ||
1603 | - cop.mac = (unsigned char *)mac; | ||
1604 | - | ||
1605 | - if (ioctl(fdc, CIOCCRYPT, &cop)) { | ||
1606 | - perror("ioctl(CIOCCRYPT)"); | ||
1607 | - return 1; | ||
1608 | - } | ||
1609 | - total += cop.len; | ||
1610 | - } while(!must_finish); | ||
1611 | - gettimeofday(&end, NULL); | ||
1612 | - | ||
1613 | - secs = udifftimeval(start, end)/ 1000000.0; | ||
1614 | - | ||
1615 | - value2human(total, secs, &ddata, &dspeed, metric); | ||
1616 | - printf ("done. %.2f %s in %.2f secs: ", ddata, metric, secs); | ||
1617 | - printf ("%.2f %s/sec\n", dspeed, metric); | ||
1618 | - | ||
1619 | - free(buffer); | ||
1620 | - return 0; | ||
1621 | -} | ||
1622 | - | ||
1623 | -void usage(char *cmd_name) | ||
1624 | -{ | ||
1625 | - printf(usage_str, cmd_name); | ||
1626 | -} | ||
1627 | - | ||
1628 | -int run_test(int id, struct test_params tp) | ||
1629 | -{ | ||
1630 | - int fd; | ||
1631 | - int fdc; | ||
1632 | - | ||
1633 | - fd = open("/dev/crypto", O_RDWR, 0); | ||
1634 | - if (fd < 0) { | ||
1635 | - perror("open()"); | ||
1636 | - return fd; | ||
1637 | - } | ||
1638 | - if (ioctl(fd, CRIOGET, &fdc)) { | ||
1639 | - perror("ioctl(CRIOGET)"); | ||
1640 | - return -EINVAL; | ||
1641 | - } | ||
1642 | - | ||
1643 | - ciphers[id].func(fdc, tp); | ||
1644 | - | ||
1645 | - close(fdc); | ||
1646 | - close(fd); | ||
1647 | - | ||
1648 | - return 0; | ||
1649 | -} | ||
1650 | - | ||
1651 | -int get_alignmask(int fdc, struct session_op *sess) | ||
1652 | -{ | ||
1653 | - int alignmask; | ||
1654 | - | ||
1655 | -#ifdef CIOCGSESSINFO | ||
1656 | - struct session_info_op siop; | ||
1657 | - | ||
1658 | - siop.ses = sess->ses; | ||
1659 | - if (ioctl(fdc, CIOCGSESSINFO, &siop)) { | ||
1660 | - perror("ioctl(CIOCGSESSINFO)"); | ||
1661 | - return -EINVAL; | ||
1662 | - } | ||
1663 | - alignmask = siop.alignmask; | ||
1664 | -#else | ||
1665 | - alignmask = 0; | ||
1666 | -#endif | ||
1667 | - | ||
1668 | - return alignmask; | ||
1669 | -} | ||
1670 | - | ||
1671 | -void do_test_vectors(int fdc, struct test_params tp, struct session_op *sess) | ||
1672 | -{ | ||
1673 | - int i; | ||
1674 | - | ||
1675 | - if (tp.nflag) { | ||
1676 | - encrypt_data(fdc, tp, sess); | ||
1677 | - } else { | ||
1678 | - for (i = 256; i <= (64 * 1024); i *= 2) { | ||
1679 | - if (must_exit) | ||
1680 | - break; | ||
1681 | - | ||
1682 | - tp.nvalue = i; | ||
1683 | - if (encrypt_data(fdc, tp, sess)) { | ||
1684 | - break; | ||
1685 | - } | ||
1686 | - } | ||
1687 | - } | ||
1688 | -} | ||
1689 | - | ||
1690 | - | ||
1691 | -int run_null(int fdc, struct test_params tp) | ||
1692 | -{ | ||
1693 | - struct session_op sess; | ||
1694 | - char keybuf[32]; | ||
1695 | - | ||
1696 | - fprintf(stderr, "Testing NULL cipher: \n"); | ||
1697 | - memset(&sess, 0, sizeof(sess)); | ||
1698 | - sess.cipher = CRYPTO_NULL; | ||
1699 | - sess.keylen = 0; | ||
1700 | - sess.key = (unsigned char *)keybuf; | ||
1701 | - if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
1702 | - perror("ioctl(CIOCGSESSION)"); | ||
1703 | - return -EINVAL; | ||
1704 | - } | ||
1705 | - | ||
1706 | - do_test_vectors(fdc, tp, &sess); | ||
1707 | - return 0; | ||
1708 | -} | ||
1709 | - | ||
1710 | -int run_aes_128_cbc(int fdc, struct test_params tp) | ||
1711 | -{ | ||
1712 | - struct session_op sess; | ||
1713 | - char keybuf[32]; | ||
1714 | - | ||
1715 | - fprintf(stderr, "\nTesting AES-128-CBC cipher: \n"); | ||
1716 | - memset(&sess, 0, sizeof(sess)); | ||
1717 | - sess.cipher = CRYPTO_AES_CBC; | ||
1718 | - sess.keylen = 16; | ||
1719 | - memset(keybuf, 0x42, 16); | ||
1720 | - sess.key = (unsigned char *)keybuf; | ||
1721 | - if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
1722 | - perror("ioctl(CIOCGSESSION)"); | ||
1723 | - return -EINVAL; | ||
1724 | - } | ||
1725 | - | ||
1726 | - do_test_vectors(fdc, tp, &sess); | ||
1727 | - return 0; | ||
1728 | -} | ||
1729 | - | ||
1730 | -int run_aes_256_xts(int fdc, struct test_params tp) | ||
1731 | -{ | ||
1732 | - struct session_op sess; | ||
1733 | - char keybuf[32]; | ||
1734 | - | ||
1735 | - fprintf(stderr, "\nTesting AES-256-XTS cipher: \n"); | ||
1736 | - memset(&sess, 0, sizeof(sess)); | ||
1737 | - sess.cipher = CRYPTO_AES_XTS; | ||
1738 | - sess.keylen = 32; | ||
1739 | - memset(keybuf, 0x42, sess.keylen); | ||
1740 | - sess.key = (unsigned char *)keybuf; | ||
1741 | - if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
1742 | - perror("ioctl(CIOCGSESSION)"); | ||
1743 | - return -EINVAL; | ||
1744 | - } | ||
1745 | - | ||
1746 | - do_test_vectors(fdc, tp, &sess); | ||
1747 | - return 0; | ||
1748 | -} | ||
1749 | - | ||
1750 | -int run_crc32c(int fdc, struct test_params tp) | ||
1751 | -{ | ||
1752 | - struct session_op sess; | ||
1753 | - | ||
1754 | - fprintf(stderr, "\nTesting CRC32C hash: \n"); | ||
1755 | - memset(&sess, 0, sizeof(sess)); | ||
1756 | - sess.mac = CRYPTO_CRC32C; | ||
1757 | - if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
1758 | - perror("ioctl(CIOCGSESSION)"); | ||
1759 | - return 1; | ||
1760 | - } | ||
1761 | - | ||
1762 | - do_test_vectors(fdc, tp, &sess); | ||
1763 | - return 0; | ||
1764 | -} | ||
1765 | - | ||
1766 | -int run_sha1(int fdc, struct test_params tp) | ||
1767 | -{ | ||
1768 | - struct session_op sess; | ||
1769 | - | ||
1770 | - fprintf(stderr, "\nTesting SHA-1 hash: \n"); | ||
1771 | - memset(&sess, 0, sizeof(sess)); | ||
1772 | - sess.mac = CRYPTO_SHA1; | ||
1773 | - if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
1774 | - perror("ioctl(CIOCGSESSION)"); | ||
1775 | - return 1; | ||
1776 | - } | ||
1777 | - | ||
1778 | - do_test_vectors(fdc, tp, &sess); | ||
1779 | - return 0; | ||
1780 | -} | ||
1781 | - | ||
1782 | -int run_sha256(int fdc, struct test_params tp) | ||
1783 | -{ | ||
1784 | - struct session_op sess; | ||
1785 | - | ||
1786 | - fprintf(stderr, "\nTesting SHA2-256 hash: \n"); | ||
1787 | - memset(&sess, 0, sizeof(sess)); | ||
1788 | - sess.mac = CRYPTO_SHA2_256; | ||
1789 | - if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
1790 | - perror("ioctl(CIOCGSESSION)"); | ||
1791 | - return 1; | ||
1792 | - } | ||
1793 | - | ||
1794 | - do_test_vectors(fdc, tp, &sess); | ||
1795 | - return 0; | ||
1796 | -} | ||
1797 | - | ||
1798 | -int main(int argc, char **argv) | ||
1799 | -{ | ||
1800 | - int i; | ||
1801 | - int c; | ||
1802 | - bool alg_flag; | ||
1803 | - char *alg_name; | ||
1804 | - struct test_params tp; | ||
1805 | - | ||
1806 | - tp.tflag = false; | ||
1807 | - tp.nflag = false; | ||
1808 | - alg_flag = false; | ||
1809 | - opterr = 0; | ||
1810 | - while ((c = getopt(argc, argv, "hn:t:")) != -1) { | ||
1811 | - switch (c) { | ||
1812 | - case 'n': | ||
1813 | - tp.nvalue = atoi(optarg); | ||
1814 | - tp.nflag = true; | ||
1815 | - break; | ||
1816 | - case 't': | ||
1817 | - tp.tvalue = atoi(optarg); | ||
1818 | - tp.tflag = true; | ||
1819 | - break; | ||
1820 | - case 'h': /* no break */ | ||
1821 | - default: | ||
1822 | - usage(argv[0]); | ||
1823 | - exit(1); | ||
1824 | - } | ||
1825 | - } | ||
1826 | - | ||
1827 | - /* the name of a specific test asked on the command line */ | ||
1828 | - if (optind < argc) { | ||
1829 | - alg_name = argv[optind]; | ||
1830 | - alg_flag = true; | ||
1831 | - } | ||
1832 | - | ||
1833 | - /* default test time */ | ||
1834 | - if (!tp.tflag) { | ||
1835 | - tp.tvalue = 5; | ||
1836 | - } | ||
1837 | - | ||
1838 | - signal(SIGALRM, alarm_handler); | ||
1839 | - signal(SIGINT, exit_handler); | ||
1840 | - | ||
1841 | - for (i = 0; i < ALG_COUNT; i++) { | ||
1842 | - if (must_exit) | ||
1843 | - break; | ||
1844 | - | ||
1845 | - if (alg_flag) { | ||
1846 | - if (strcmp(alg_name, ciphers[i].name) == 0) { | ||
1847 | - run_test(i, tp); | ||
1848 | - } | ||
1849 | - } else { | ||
1850 | - run_test(i, tp); | ||
1851 | - } | ||
1852 | - } | ||
1853 | - | ||
1854 | - return 0; | ||
1855 | -} | ||
1856 | -- | ||
1857 | 2.10.2 | ||
1858 | |||
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 @@ | |||
1 | From bccc3add64bfd4a048bf7e5a2935b2fc719d8e13 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Tue, 1 Nov 2016 13:28:40 +0200 | ||
4 | Subject: [PATCH 089/104] add -async option to run_crypto_tests.sh | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/run_crypto_tests.sh | 31 ++++++++++++++++++++++++++++++- | ||
9 | 1 file changed, 30 insertions(+), 1 deletion(-) | ||
10 | |||
11 | diff --git a/tests/run_crypto_tests.sh b/tests/run_crypto_tests.sh | ||
12 | index e128637..321b013 100644 | ||
13 | --- a/tests/run_crypto_tests.sh | ||
14 | +++ b/tests/run_crypto_tests.sh | ||
15 | @@ -4,6 +4,31 @@ | ||
16 | BUF_SIZE="8192 16384 65536 131072 262144" | ||
17 | THREAD_CNT="1 8 12" | ||
18 | ALG_NAMES="aes-128-cbc aes-256-xts sha1 sha256 crc32c" | ||
19 | +TIME=10 | ||
20 | + | ||
21 | +############################ | ||
22 | + | ||
23 | +function usage | ||
24 | +{ | ||
25 | +cat << EOF | ||
26 | +Usage: `basename $0` [OPTIONS] | ||
27 | + | ||
28 | + -a run async version of the benchmark (default sync) | ||
29 | + -h show this help | ||
30 | + | ||
31 | +Run in sequence benchmarks for several crypto algorithms: | ||
32 | +$ALG_NAMES | ||
33 | +EOF | ||
34 | +} | ||
35 | + | ||
36 | +while getopts ah option | ||
37 | +do | ||
38 | + case "$option" in | ||
39 | + a) aflag="-a";; | ||
40 | + *) usage $0; exit 1;; | ||
41 | + esac | ||
42 | +done | ||
43 | + | ||
44 | |||
45 | #restool dpseci create --num-queues=8 --priorities=1,2,3,4,5,6,7,8 | ||
46 | #restool dprc assign dprc.1 --object=dpseci.0 --plugged=1 | ||
47 | @@ -16,7 +41,11 @@ do | ||
48 | do | ||
49 | for bsize in ${BUF_SIZE} | ||
50 | do | ||
51 | - speed_multi.sh -t 10 -n $bsize -m ${multi} ${alg_name} | | ||
52 | + speed_multi.sh -t ${TIME}\ | ||
53 | + -n ${bsize}\ | ||
54 | + -m ${multi}\ | ||
55 | + ${aflag}\ | ||
56 | + ${alg_name} | | ||
57 | tail -n 1 | ||
58 | done | ||
59 | done | ||
60 | -- | ||
61 | 2.10.2 | ||
62 | |||
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 @@ | |||
1 | From d40bcfdfb2c2c5aa4c47b5653fdea3ee317d234b Mon Sep 17 00:00:00 2001 | ||
2 | From: Michael Weiser <michael.weiser@gmx.de> | ||
3 | Date: Fri, 5 Aug 2016 18:43:55 +0200 | ||
4 | Subject: [PATCH 090/104] Adjust to recent user page API changes | ||
5 | |||
6 | 4.6.0 basically renamed get_user_pages() to get_user_pages_remote() and | ||
7 | introduced a new get_user_pages() that always works on the current | ||
8 | task.[1] Distinguish the two APIs based on kernel version we're | ||
9 | compiling for. | ||
10 | |||
11 | Also, there seems to have been a massive cleansing of | ||
12 | page_cache_release(page) in favour of put_page(page)[2] which was an | ||
13 | alias for put_page(page)[3] since 2.6.0. Before that beginning with | ||
14 | 2.4.0 both page_cache_release(page) and put_page(page) have been aliases | ||
15 | for __free_page(page). So using put_page() instead of | ||
16 | page_cache_release(page) will produce identical code for anything after | ||
17 | 2.4.0. | ||
18 | |||
19 | [1] https://lkml.org/lkml/2016/2/10/555 | ||
20 | [2] https://www.spinics.net/lists/linux-fsdevel/msg95923.html | ||
21 | [3] https://www.spinics.net/lists/linux-fsdevel/msg95922.html | ||
22 | --- | ||
23 | zc.c | 9 +++++++-- | ||
24 | 1 file changed, 7 insertions(+), 2 deletions(-) | ||
25 | |||
26 | diff --git a/zc.c b/zc.c | ||
27 | index 29b0501..a97b49f 100644 | ||
28 | --- a/zc.c | ||
29 | +++ b/zc.c | ||
30 | @@ -59,7 +59,12 @@ int __get_userbuf(uint8_t __user *addr, uint32_t len, int write, | ||
31 | } | ||
32 | |||
33 | down_read(&mm->mmap_sem); | ||
34 | - ret = get_user_pages(task, mm, | ||
35 | +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)) | ||
36 | + ret = get_user_pages_remote( | ||
37 | +#else | ||
38 | + ret = get_user_pages( | ||
39 | +#endif | ||
40 | + task, mm, | ||
41 | (unsigned long)addr, pgcount, write, 0, pg, NULL); | ||
42 | up_read(&mm->mmap_sem); | ||
43 | if (ret != pgcount) | ||
44 | @@ -119,7 +124,7 @@ void release_user_pages(struct csession *ses) | ||
45 | else | ||
46 | ses->readonly_pages--; | ||
47 | |||
48 | - page_cache_release(ses->pages[i]); | ||
49 | + put_page(ses->pages[i]); | ||
50 | } | ||
51 | ses->used_pages = 0; | ||
52 | } | ||
53 | -- | ||
54 | 2.10.2 | ||
55 | |||
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 @@ | |||
1 | From a715480416b33b0bacd2b58ec42b9c64bdb21c0c Mon Sep 17 00:00:00 2001 | ||
2 | From: Michael Weiser <michael.weiser@gmx.de> | ||
3 | Date: Fri, 19 Aug 2016 10:24:40 +0100 | ||
4 | Subject: [PATCH 091/104] Fix test compile time warnings | ||
5 | MIME-Version: 1.0 | ||
6 | Content-Type: text/plain; charset=UTF-8 | ||
7 | Content-Transfer-Encoding: 8bit | ||
8 | |||
9 | A number of tests cause compiler warnings like this: | ||
10 | |||
11 | hashcrypt_speed.c: In function ‘hash_data’: | ||
12 | hashcrypt_speed.c:101:2: warning: implicit declaration of function ‘alarm’ [-Wimplicit-function-declaration] | ||
13 | alarm(5); | ||
14 | ^~~~~ | ||
15 | hashcrypt_speed.c: In function ‘main’: | ||
16 | hashcrypt_speed.c:203:2: warning: implicit declaration of function ‘close’ [-Wimplicit-function-declaration] | ||
17 | close(fdc); | ||
18 | ^~~~~ | ||
19 | |||
20 | Fix by including unistd.h. | ||
21 | --- | ||
22 | tests/hashcrypt_speed.c | 1 + | ||
23 | tests/sha_speed.c | 1 + | ||
24 | tests/speed.c | 1 + | ||
25 | 3 files changed, 3 insertions(+) | ||
26 | |||
27 | diff --git a/tests/hashcrypt_speed.c b/tests/hashcrypt_speed.c | ||
28 | index 045bf8e..10c9f00 100644 | ||
29 | --- a/tests/hashcrypt_speed.c | ||
30 | +++ b/tests/hashcrypt_speed.c | ||
31 | @@ -21,6 +21,7 @@ | ||
32 | #include <stdint.h> | ||
33 | #include <stdlib.h> | ||
34 | #include <string.h> | ||
35 | +#include <unistd.h> | ||
36 | #include <sys/ioctl.h> | ||
37 | #include <sys/time.h> | ||
38 | #include <sys/types.h> | ||
39 | diff --git a/tests/sha_speed.c b/tests/sha_speed.c | ||
40 | index 9f2c8cc..30b40f5 100644 | ||
41 | --- a/tests/sha_speed.c | ||
42 | +++ b/tests/sha_speed.c | ||
43 | @@ -21,6 +21,7 @@ | ||
44 | #include <stdint.h> | ||
45 | #include <stdlib.h> | ||
46 | #include <string.h> | ||
47 | +#include <unistd.h> | ||
48 | #include <sys/ioctl.h> | ||
49 | #include <sys/time.h> | ||
50 | #include <sys/types.h> | ||
51 | diff --git a/tests/speed.c b/tests/speed.c | ||
52 | index 3b36db1..fc38a63 100644 | ||
53 | --- a/tests/speed.c | ||
54 | +++ b/tests/speed.c | ||
55 | @@ -22,6 +22,7 @@ | ||
56 | #include <stdio.h> | ||
57 | #include <stdlib.h> | ||
58 | #include <string.h> | ||
59 | +#include <unistd.h> | ||
60 | #include <sys/ioctl.h> | ||
61 | #include <sys/time.h> | ||
62 | #include <sys/types.h> | ||
63 | -- | ||
64 | 2.10.2 | ||
65 | |||
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 @@ | |||
1 | From e41e73551c886366d741b5e401a3c4c661aa3020 Mon Sep 17 00:00:00 2001 | ||
2 | From: Michael Weiser <michael.weiser@gmx.de> | ||
3 | Date: Fri, 5 Aug 2016 17:26:27 +0200 | ||
4 | Subject: [PATCH 092/104] Support skcipher in addition to ablkcipher API | ||
5 | |||
6 | The ablkcipher API is being phased out[1]. The unified skcipher API | ||
7 | seems to have made its entry with 4.3.[3, 4] By what can be seen from | ||
8 | migration patches[1.ff.], it's a drop-in replacement. | ||
9 | |||
10 | Also, deallocators such as crypto_free_skcipher() are NULL-safe now[2]. | ||
11 | |||
12 | Add a new header cipherapi.h to aid migration from ablkcipher to skcipher and | ||
13 | retain support for old kernels. Make it decide which API to use and provide | ||
14 | appropriate function calls and type definitions. Since the ablkcipher and | ||
15 | skcipher APIs are so similar, those are mainly defines for corresponding | ||
16 | pseudo-functions in namespace cryptodev_ derived directly from their API | ||
17 | counterparts. | ||
18 | |||
19 | Compiles and works (i.e. checks pass) with Debian testing 4.6.4 kernel | ||
20 | as well as 4.8-rc2+ Linus git tree as of today. (Both require a fix for | ||
21 | changed page access API[5].) | ||
22 | |||
23 | [1] https://www.spinics.net/lists/linux-crypto/msg18133.html | ||
24 | [2] https://www.spinics.net/lists/linux-crypto/msg18154.html, line 120 | ||
25 | [3] https://www.spinics.net/lists/linux-crypto/msg16373.html | ||
26 | [4] https://www.spinics.net/lists/linux-crypto/msg16294.html | ||
27 | [5] https://github.com/cryptodev-linux/cryptodev-linux/pull/14 | ||
28 | --- | ||
29 | cipherapi.h | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
30 | cryptlib.c | 40 ++++++++++++++++++---------------------- | ||
31 | cryptlib.h | 6 ++++-- | ||
32 | ioctl.c | 4 ++-- | ||
33 | 4 files changed, 84 insertions(+), 26 deletions(-) | ||
34 | create mode 100644 cipherapi.h | ||
35 | |||
36 | diff --git a/cipherapi.h b/cipherapi.h | ||
37 | new file mode 100644 | ||
38 | index 0000000..07d9923 | ||
39 | --- /dev/null | ||
40 | +++ b/cipherapi.h | ||
41 | @@ -0,0 +1,60 @@ | ||
42 | +#ifndef CIPHERAPI_H | ||
43 | +# define CIPHERAPI_H | ||
44 | + | ||
45 | +#include <linux/version.h> | ||
46 | + | ||
47 | +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) | ||
48 | +# include <linux/crypto.h> | ||
49 | + | ||
50 | +typedef struct ablkcipher_alg cryptodev_blkcipher_alg_t; | ||
51 | +typedef struct crypto_ablkcipher cryptodev_crypto_blkcipher_t; | ||
52 | +typedef struct ablkcipher_request cryptodev_blkcipher_request_t; | ||
53 | + | ||
54 | +# define cryptodev_crypto_alloc_blkcipher crypto_alloc_ablkcipher | ||
55 | +# define cryptodev_crypto_blkcipher_alg crypto_ablkcipher_alg | ||
56 | +# define cryptodev_crypto_blkcipher_blocksize crypto_ablkcipher_blocksize | ||
57 | +# define cryptodev_crypto_blkcipher_ivsize crypto_ablkcipher_ivsize | ||
58 | +# define cryptodev_crypto_blkcipher_alignmask crypto_ablkcipher_alignmask | ||
59 | +# define cryptodev_crypto_blkcipher_setkey crypto_ablkcipher_setkey | ||
60 | + | ||
61 | +static inline void cryptodev_crypto_free_blkcipher(cryptodev_crypto_blkcipher_t *c) { | ||
62 | + if (c) | ||
63 | + crypto_free_ablkcipher(c); | ||
64 | +} | ||
65 | + | ||
66 | +# define cryptodev_blkcipher_request_alloc ablkcipher_request_alloc | ||
67 | +# define cryptodev_blkcipher_request_set_callback ablkcipher_request_set_callback | ||
68 | + | ||
69 | +static inline void cryptodev_blkcipher_request_free(cryptodev_blkcipher_request_t *r) { | ||
70 | + if (r) | ||
71 | + ablkcipher_request_free(r); | ||
72 | +} | ||
73 | + | ||
74 | +# define cryptodev_blkcipher_request_set_crypt ablkcipher_request_set_crypt | ||
75 | +# define cryptodev_crypto_blkcipher_encrypt crypto_ablkcipher_encrypt | ||
76 | +# define cryptodev_crypto_blkcipher_decrypt crypto_ablkcipher_decrypt | ||
77 | +# define cryptodev_crypto_blkcipher_tfm crypto_ablkcipher_tfm | ||
78 | +#else | ||
79 | +#include <crypto/skcipher.h> | ||
80 | + | ||
81 | +typedef struct skcipher_alg cryptodev_blkcipher_alg_t; | ||
82 | +typedef struct crypto_skcipher cryptodev_crypto_blkcipher_t; | ||
83 | +typedef struct skcipher_request cryptodev_blkcipher_request_t; | ||
84 | + | ||
85 | +# define cryptodev_crypto_alloc_blkcipher crypto_alloc_skcipher | ||
86 | +# define cryptodev_crypto_blkcipher_alg crypto_skcipher_alg | ||
87 | +# define cryptodev_crypto_blkcipher_blocksize crypto_skcipher_blocksize | ||
88 | +# define cryptodev_crypto_blkcipher_ivsize crypto_skcipher_ivsize | ||
89 | +# define cryptodev_crypto_blkcipher_alignmask crypto_skcipher_alignmask | ||
90 | +# define cryptodev_crypto_blkcipher_setkey crypto_skcipher_setkey | ||
91 | +# define cryptodev_crypto_free_blkcipher crypto_free_skcipher | ||
92 | +# define cryptodev_blkcipher_request_alloc skcipher_request_alloc | ||
93 | +# define cryptodev_blkcipher_request_set_callback skcipher_request_set_callback | ||
94 | +# define cryptodev_blkcipher_request_free skcipher_request_free | ||
95 | +# define cryptodev_blkcipher_request_set_crypt skcipher_request_set_crypt | ||
96 | +# define cryptodev_crypto_blkcipher_encrypt crypto_skcipher_encrypt | ||
97 | +# define cryptodev_crypto_blkcipher_decrypt crypto_skcipher_decrypt | ||
98 | +# define cryptodev_crypto_blkcipher_tfm crypto_skcipher_tfm | ||
99 | +#endif | ||
100 | + | ||
101 | +#endif | ||
102 | diff --git a/cryptlib.c b/cryptlib.c | ||
103 | index 5d1a5a9..558d4b8 100644 | ||
104 | --- a/cryptlib.c | ||
105 | +++ b/cryptlib.c | ||
106 | @@ -24,7 +24,6 @@ | ||
107 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
108 | */ | ||
109 | |||
110 | -#include <linux/crypto.h> | ||
111 | #include <linux/mm.h> | ||
112 | #include <linux/highmem.h> | ||
113 | #include <linux/ioctl.h> | ||
114 | @@ -38,6 +37,7 @@ | ||
115 | #include <linux/rtnetlink.h> | ||
116 | #include <crypto/authenc.h> | ||
117 | #include "cryptodev_int.h" | ||
118 | +#include "cipherapi.h" | ||
119 | |||
120 | |||
121 | static void cryptodev_complete(struct crypto_async_request *req, int err) | ||
122 | @@ -129,15 +129,15 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, | ||
123 | int ret; | ||
124 | |||
125 | if (aead == 0) { | ||
126 | - struct ablkcipher_alg *alg; | ||
127 | + cryptodev_blkcipher_alg_t *alg; | ||
128 | |||
129 | - out->async.s = crypto_alloc_ablkcipher(alg_name, 0, 0); | ||
130 | + out->async.s = cryptodev_crypto_alloc_blkcipher(alg_name, 0, 0); | ||
131 | if (unlikely(IS_ERR(out->async.s))) { | ||
132 | ddebug(1, "Failed to load cipher %s", alg_name); | ||
133 | return -EINVAL; | ||
134 | } | ||
135 | |||
136 | - alg = crypto_ablkcipher_alg(out->async.s); | ||
137 | + alg = cryptodev_crypto_blkcipher_alg(out->async.s); | ||
138 | if (alg != NULL) { | ||
139 | /* Was correct key length supplied? */ | ||
140 | if (alg->max_keysize > 0 && | ||
141 | @@ -150,11 +150,11 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, | ||
142 | } | ||
143 | } | ||
144 | |||
145 | - out->blocksize = crypto_ablkcipher_blocksize(out->async.s); | ||
146 | - out->ivsize = crypto_ablkcipher_ivsize(out->async.s); | ||
147 | - out->alignmask = crypto_ablkcipher_alignmask(out->async.s); | ||
148 | + out->blocksize = cryptodev_crypto_blkcipher_blocksize(out->async.s); | ||
149 | + out->ivsize = cryptodev_crypto_blkcipher_ivsize(out->async.s); | ||
150 | + out->alignmask = cryptodev_crypto_blkcipher_alignmask(out->async.s); | ||
151 | |||
152 | - ret = crypto_ablkcipher_setkey(out->async.s, keyp, keylen); | ||
153 | + ret = cryptodev_crypto_blkcipher_setkey(out->async.s, keyp, keylen); | ||
154 | } else { | ||
155 | out->async.as = crypto_alloc_aead(alg_name, 0, 0); | ||
156 | if (unlikely(IS_ERR(out->async.as))) { | ||
157 | @@ -181,14 +181,14 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, | ||
158 | init_completion(&out->async.result.completion); | ||
159 | |||
160 | if (aead == 0) { | ||
161 | - out->async.request = ablkcipher_request_alloc(out->async.s, GFP_KERNEL); | ||
162 | + out->async.request = cryptodev_blkcipher_request_alloc(out->async.s, GFP_KERNEL); | ||
163 | if (unlikely(!out->async.request)) { | ||
164 | derr(1, "error allocating async crypto request"); | ||
165 | ret = -ENOMEM; | ||
166 | goto error; | ||
167 | } | ||
168 | |||
169 | - ablkcipher_request_set_callback(out->async.request, 0, | ||
170 | + cryptodev_blkcipher_request_set_callback(out->async.request, 0, | ||
171 | cryptodev_complete, &out->async.result); | ||
172 | } else { | ||
173 | out->async.arequest = aead_request_alloc(out->async.as, GFP_KERNEL); | ||
174 | @@ -206,10 +206,8 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, | ||
175 | return 0; | ||
176 | error: | ||
177 | if (aead == 0) { | ||
178 | - if (out->async.request) | ||
179 | - ablkcipher_request_free(out->async.request); | ||
180 | - if (out->async.s) | ||
181 | - crypto_free_ablkcipher(out->async.s); | ||
182 | + cryptodev_blkcipher_request_free(out->async.request); | ||
183 | + cryptodev_crypto_free_blkcipher(out->async.s); | ||
184 | } else { | ||
185 | if (out->async.arequest) | ||
186 | aead_request_free(out->async.arequest); | ||
187 | @@ -224,10 +222,8 @@ void cryptodev_cipher_deinit(struct cipher_data *cdata) | ||
188 | { | ||
189 | if (cdata->init) { | ||
190 | if (cdata->aead == 0) { | ||
191 | - if (cdata->async.request) | ||
192 | - ablkcipher_request_free(cdata->async.request); | ||
193 | - if (cdata->async.s) | ||
194 | - crypto_free_ablkcipher(cdata->async.s); | ||
195 | + cryptodev_blkcipher_request_free(cdata->async.request); | ||
196 | + cryptodev_crypto_free_blkcipher(cdata->async.s); | ||
197 | } else { | ||
198 | if (cdata->async.arequest) | ||
199 | aead_request_free(cdata->async.arequest); | ||
200 | @@ -274,10 +270,10 @@ ssize_t cryptodev_cipher_encrypt(struct cipher_data *cdata, | ||
201 | reinit_completion(&cdata->async.result.completion); | ||
202 | |||
203 | if (cdata->aead == 0) { | ||
204 | - ablkcipher_request_set_crypt(cdata->async.request, | ||
205 | + cryptodev_blkcipher_request_set_crypt(cdata->async.request, | ||
206 | (struct scatterlist *)src, dst, | ||
207 | len, cdata->async.iv); | ||
208 | - ret = crypto_ablkcipher_encrypt(cdata->async.request); | ||
209 | + ret = cryptodev_crypto_blkcipher_encrypt(cdata->async.request); | ||
210 | } else { | ||
211 | aead_request_set_crypt(cdata->async.arequest, | ||
212 | (struct scatterlist *)src, dst, | ||
213 | @@ -296,10 +292,10 @@ ssize_t cryptodev_cipher_decrypt(struct cipher_data *cdata, | ||
214 | |||
215 | reinit_completion(&cdata->async.result.completion); | ||
216 | if (cdata->aead == 0) { | ||
217 | - ablkcipher_request_set_crypt(cdata->async.request, | ||
218 | + cryptodev_blkcipher_request_set_crypt(cdata->async.request, | ||
219 | (struct scatterlist *)src, dst, | ||
220 | len, cdata->async.iv); | ||
221 | - ret = crypto_ablkcipher_decrypt(cdata->async.request); | ||
222 | + ret = cryptodev_crypto_blkcipher_decrypt(cdata->async.request); | ||
223 | } else { | ||
224 | aead_request_set_crypt(cdata->async.arequest, | ||
225 | (struct scatterlist *)src, dst, | ||
226 | diff --git a/cryptlib.h b/cryptlib.h | ||
227 | index d8e8046..8200a1d 100644 | ||
228 | --- a/cryptlib.h | ||
229 | +++ b/cryptlib.h | ||
230 | @@ -11,6 +11,8 @@ struct cryptodev_result { | ||
231 | int err; | ||
232 | }; | ||
233 | |||
234 | +#include "cipherapi.h" | ||
235 | + | ||
236 | struct cipher_data { | ||
237 | int init; /* 0 uninitialized */ | ||
238 | int blocksize; | ||
239 | @@ -20,8 +22,8 @@ struct cipher_data { | ||
240 | int alignmask; | ||
241 | struct { | ||
242 | /* block ciphers */ | ||
243 | - struct crypto_ablkcipher *s; | ||
244 | - struct ablkcipher_request *request; | ||
245 | + cryptodev_crypto_blkcipher_t *s; | ||
246 | + cryptodev_blkcipher_request_t *request; | ||
247 | |||
248 | /* AEAD ciphers */ | ||
249 | struct crypto_aead *as; | ||
250 | diff --git a/ioctl.c b/ioctl.c | ||
251 | index 2e2bdeb..e3b8af1 100644 | ||
252 | --- a/ioctl.c | ||
253 | +++ b/ioctl.c | ||
254 | @@ -35,7 +35,6 @@ | ||
255 | */ | ||
256 | |||
257 | #include <crypto/hash.h> | ||
258 | -#include <linux/crypto.h> | ||
259 | #include <linux/mm.h> | ||
260 | #include <linux/highmem.h> | ||
261 | #include <linux/ioctl.h> | ||
262 | @@ -54,6 +53,7 @@ | ||
263 | #include "cryptodev_int.h" | ||
264 | #include "zc.h" | ||
265 | #include "version.h" | ||
266 | +#include "cipherapi.h" | ||
267 | |||
268 | MODULE_AUTHOR("Nikos Mavrogiannopoulos <nmav@gnutls.org>"); | ||
269 | MODULE_DESCRIPTION("CryptoDev driver"); | ||
270 | @@ -1052,7 +1052,7 @@ static int get_session_info(struct fcrypt *fcr, struct session_info_op *siop) | ||
271 | |||
272 | if (ses_ptr->cdata.init) { | ||
273 | if (ses_ptr->cdata.aead == 0) | ||
274 | - tfm = crypto_ablkcipher_tfm(ses_ptr->cdata.async.s); | ||
275 | + tfm = cryptodev_crypto_blkcipher_tfm(ses_ptr->cdata.async.s); | ||
276 | else | ||
277 | tfm = crypto_aead_tfm(ses_ptr->cdata.async.as); | ||
278 | tfm_info_to_alg_info(&siop->cipher_info, tfm); | ||
279 | -- | ||
280 | 2.10.2 | ||
281 | |||
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 @@ | |||
1 | From 871ecc5c5ebfbb9c6e1b17a7ff7a531ed1fab644 Mon Sep 17 00:00:00 2001 | ||
2 | From: =?UTF-8?q?Horia=20Geant=C4=83?= <horia.geanta@nxp.com> | ||
3 | Date: Wed, 16 Nov 2016 15:38:39 +0200 | ||
4 | Subject: [PATCH 093/104] Fix ablkcipher algorithms usage in v4.8+ kernels | ||
5 | MIME-Version: 1.0 | ||
6 | Content-Type: text/plain; charset=UTF-8 | ||
7 | Content-Transfer-Encoding: 8bit | ||
8 | |||
9 | ablkcipher API is not completely removed from kernels <= v4.9. | ||
10 | Thus it's still valid to use ablkcipher algorithms. | ||
11 | |||
12 | Fix the case when implementers register ablkcipher algorithms | ||
13 | and cryptodev casts them to skcipher without checking their type. | ||
14 | |||
15 | Note: alg returned by crypto_ablkcipher_alg() is no longer checked | ||
16 | to be non-NULL. This is guaranteed by the fact that ablkcipher_tfm | ||
17 | (out->async.s) is valid. | ||
18 | |||
19 | Fixes: cb186f682679 ("Support skcipher in addition to ablkcipher API") | ||
20 | Signed-off-by: Horia Geantă <horia.geanta@nxp.com> | ||
21 | --- | ||
22 | cipherapi.h | 4 ---- | ||
23 | cryptlib.c | 56 ++++++++++++++++++++++++++++++++++++++++++++------------ | ||
24 | 2 files changed, 44 insertions(+), 16 deletions(-) | ||
25 | |||
26 | diff --git a/cipherapi.h b/cipherapi.h | ||
27 | index 07d9923..b6ed6c2 100644 | ||
28 | --- a/cipherapi.h | ||
29 | +++ b/cipherapi.h | ||
30 | @@ -6,12 +6,10 @@ | ||
31 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) | ||
32 | # include <linux/crypto.h> | ||
33 | |||
34 | -typedef struct ablkcipher_alg cryptodev_blkcipher_alg_t; | ||
35 | typedef struct crypto_ablkcipher cryptodev_crypto_blkcipher_t; | ||
36 | typedef struct ablkcipher_request cryptodev_blkcipher_request_t; | ||
37 | |||
38 | # define cryptodev_crypto_alloc_blkcipher crypto_alloc_ablkcipher | ||
39 | -# define cryptodev_crypto_blkcipher_alg crypto_ablkcipher_alg | ||
40 | # define cryptodev_crypto_blkcipher_blocksize crypto_ablkcipher_blocksize | ||
41 | # define cryptodev_crypto_blkcipher_ivsize crypto_ablkcipher_ivsize | ||
42 | # define cryptodev_crypto_blkcipher_alignmask crypto_ablkcipher_alignmask | ||
43 | @@ -37,12 +35,10 @@ static inline void cryptodev_blkcipher_request_free(cryptodev_blkcipher_request_ | ||
44 | #else | ||
45 | #include <crypto/skcipher.h> | ||
46 | |||
47 | -typedef struct skcipher_alg cryptodev_blkcipher_alg_t; | ||
48 | typedef struct crypto_skcipher cryptodev_crypto_blkcipher_t; | ||
49 | typedef struct skcipher_request cryptodev_blkcipher_request_t; | ||
50 | |||
51 | # define cryptodev_crypto_alloc_blkcipher crypto_alloc_skcipher | ||
52 | -# define cryptodev_crypto_blkcipher_alg crypto_skcipher_alg | ||
53 | # define cryptodev_crypto_blkcipher_blocksize crypto_skcipher_blocksize | ||
54 | # define cryptodev_crypto_blkcipher_ivsize crypto_skcipher_ivsize | ||
55 | # define cryptodev_crypto_blkcipher_alignmask crypto_skcipher_alignmask | ||
56 | diff --git a/cryptlib.c b/cryptlib.c | ||
57 | index 558d4b8..dcac3ec 100644 | ||
58 | --- a/cryptlib.c | ||
59 | +++ b/cryptlib.c | ||
60 | @@ -39,6 +39,7 @@ | ||
61 | #include "cryptodev_int.h" | ||
62 | #include "cipherapi.h" | ||
63 | |||
64 | +extern const struct crypto_type crypto_givcipher_type; | ||
65 | |||
66 | static void cryptodev_complete(struct crypto_async_request *req, int err) | ||
67 | { | ||
68 | @@ -122,6 +123,19 @@ error: | ||
69 | return ret; | ||
70 | } | ||
71 | |||
72 | +/* Was correct key length supplied? */ | ||
73 | +static int check_key_size(size_t keylen, const char *alg_name, | ||
74 | + unsigned int min_keysize, unsigned int max_keysize) | ||
75 | +{ | ||
76 | + if (max_keysize > 0 && unlikely((keylen < min_keysize) || | ||
77 | + (keylen > max_keysize))) { | ||
78 | + ddebug(1, "Wrong keylen '%zu' for algorithm '%s'. Use %u to %u.", | ||
79 | + keylen, alg_name, min_keysize, max_keysize); | ||
80 | + return -EINVAL; | ||
81 | + } | ||
82 | + | ||
83 | + return 0; | ||
84 | +} | ||
85 | |||
86 | int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, | ||
87 | uint8_t *keyp, size_t keylen, int stream, int aead) | ||
88 | @@ -129,7 +143,12 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, | ||
89 | int ret; | ||
90 | |||
91 | if (aead == 0) { | ||
92 | - cryptodev_blkcipher_alg_t *alg; | ||
93 | + unsigned int min_keysize, max_keysize; | ||
94 | +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) | ||
95 | + struct crypto_tfm *tfm; | ||
96 | +#else | ||
97 | + struct ablkcipher_alg *alg; | ||
98 | +#endif | ||
99 | |||
100 | out->async.s = cryptodev_crypto_alloc_blkcipher(alg_name, 0, 0); | ||
101 | if (unlikely(IS_ERR(out->async.s))) { | ||
102 | @@ -137,18 +156,31 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, | ||
103 | return -EINVAL; | ||
104 | } | ||
105 | |||
106 | - alg = cryptodev_crypto_blkcipher_alg(out->async.s); | ||
107 | - if (alg != NULL) { | ||
108 | - /* Was correct key length supplied? */ | ||
109 | - if (alg->max_keysize > 0 && | ||
110 | - unlikely((keylen < alg->min_keysize) || | ||
111 | - (keylen > alg->max_keysize))) { | ||
112 | - ddebug(1, "Wrong keylen '%zu' for algorithm '%s'. Use %u to %u.", | ||
113 | - keylen, alg_name, alg->min_keysize, alg->max_keysize); | ||
114 | - ret = -EINVAL; | ||
115 | - goto error; | ||
116 | - } | ||
117 | +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) | ||
118 | + tfm = crypto_skcipher_tfm(out->async.s); | ||
119 | + if ((tfm->__crt_alg->cra_type == &crypto_ablkcipher_type) || | ||
120 | + (tfm->__crt_alg->cra_type == &crypto_givcipher_type)) { | ||
121 | + struct ablkcipher_alg *alg; | ||
122 | + | ||
123 | + alg = &tfm->__crt_alg->cra_ablkcipher; | ||
124 | + min_keysize = alg->min_keysize; | ||
125 | + max_keysize = alg->max_keysize; | ||
126 | + } else { | ||
127 | + struct skcipher_alg *alg; | ||
128 | + | ||
129 | + alg = crypto_skcipher_alg(out->async.s); | ||
130 | + min_keysize = alg->min_keysize; | ||
131 | + max_keysize = alg->max_keysize; | ||
132 | } | ||
133 | +#else | ||
134 | + alg = crypto_ablkcipher_alg(out->async.s); | ||
135 | + min_keysize = alg->min_keysize; | ||
136 | + max_keysize = alg->max_keysize; | ||
137 | +#endif | ||
138 | + ret = check_key_size(keylen, alg_name, min_keysize, | ||
139 | + max_keysize); | ||
140 | + if (ret) | ||
141 | + goto error; | ||
142 | |||
143 | out->blocksize = cryptodev_crypto_blkcipher_blocksize(out->async.s); | ||
144 | out->ivsize = cryptodev_crypto_blkcipher_ivsize(out->async.s); | ||
145 | -- | ||
146 | 2.10.2 | ||
147 | |||
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 @@ | |||
1 | From b7783948df06674da12352ff4f55c6e7c4213026 Mon Sep 17 00:00:00 2001 | ||
2 | From: Michael Weiser <michael.weiser@gmx.de> | ||
3 | Date: Fri, 11 Nov 2016 18:09:32 +0100 | ||
4 | Subject: [PATCH 094/104] Adjust to another change in the user page API | ||
5 | |||
6 | 4.9.0 will replace the write and force flags of get_user_pages_remote() | ||
7 | with a gup_flags parameter[1]. Distinguish the two APIs based on kernel | ||
8 | version we're compiling for. | ||
9 | |||
10 | [1] https://github.com/torvalds/linux/commit/9beae1ea89305a9667ceaab6d0bf46a045ad71e7 | ||
11 | --- | ||
12 | zc.c | 8 +++++++- | ||
13 | 1 file changed, 7 insertions(+), 1 deletion(-) | ||
14 | |||
15 | diff --git a/zc.c b/zc.c | ||
16 | index a97b49f..e766ee3 100644 | ||
17 | --- a/zc.c | ||
18 | +++ b/zc.c | ||
19 | @@ -65,7 +65,13 @@ int __get_userbuf(uint8_t __user *addr, uint32_t len, int write, | ||
20 | ret = get_user_pages( | ||
21 | #endif | ||
22 | task, mm, | ||
23 | - (unsigned long)addr, pgcount, write, 0, pg, NULL); | ||
24 | + (unsigned long)addr, pgcount, | ||
25 | +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)) | ||
26 | + write ? FOLL_WRITE : 0, | ||
27 | +#else | ||
28 | + write, 0, | ||
29 | +#endif | ||
30 | + pg, NULL); | ||
31 | up_read(&mm->mmap_sem); | ||
32 | if (ret != pgcount) | ||
33 | return -EINVAL; | ||
34 | -- | ||
35 | 2.10.2 | ||
36 | |||
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 @@ | |||
1 | From 1fff269afd1925f4e4c7e37cc8c52187c407bc56 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Tue, 29 Nov 2016 13:37:21 +0200 | ||
4 | Subject: [PATCH 095/104] rename header file to clarify purpose | ||
5 | |||
6 | testhelper.h suggests a common repository of utility functions but | ||
7 | current content targets only async tests. If we include it in non-async | ||
8 | tests we are forced to include <poll.h> as well. | ||
9 | |||
10 | Rename this header file to clarify that it targets only async tests | ||
11 | |||
12 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
13 | --- | ||
14 | tests/async_cipher.c | 2 +- | ||
15 | tests/async_hmac.c | 2 +- | ||
16 | tests/asynchelper.h | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ | ||
17 | tests/testhelper.h | 57 ---------------------------------------------------- | ||
18 | 4 files changed, 56 insertions(+), 59 deletions(-) | ||
19 | create mode 100644 tests/asynchelper.h | ||
20 | delete mode 100644 tests/testhelper.h | ||
21 | |||
22 | diff --git a/tests/async_cipher.c b/tests/async_cipher.c | ||
23 | index dd08403..db6fb06 100644 | ||
24 | --- a/tests/async_cipher.c | ||
25 | +++ b/tests/async_cipher.c | ||
26 | @@ -13,7 +13,7 @@ | ||
27 | #include <sys/ioctl.h> | ||
28 | #include <crypto/cryptodev.h> | ||
29 | |||
30 | -#include "testhelper.h" | ||
31 | +#include "asynchelper.h" | ||
32 | |||
33 | #ifdef ENABLE_ASYNC | ||
34 | |||
35 | diff --git a/tests/async_hmac.c b/tests/async_hmac.c | ||
36 | index 85d19c6..1bdaad3 100644 | ||
37 | --- a/tests/async_hmac.c | ||
38 | +++ b/tests/async_hmac.c | ||
39 | @@ -14,7 +14,7 @@ | ||
40 | #include <sys/ioctl.h> | ||
41 | #include <crypto/cryptodev.h> | ||
42 | |||
43 | -#include "testhelper.h" | ||
44 | +#include "asynchelper.h" | ||
45 | |||
46 | #ifdef ENABLE_ASYNC | ||
47 | |||
48 | diff --git a/tests/asynchelper.h b/tests/asynchelper.h | ||
49 | new file mode 100644 | ||
50 | index 0000000..b5ab16c | ||
51 | --- /dev/null | ||
52 | +++ b/tests/asynchelper.h | ||
53 | @@ -0,0 +1,54 @@ | ||
54 | +#ifndef __ASYNCHELPER_H | ||
55 | +#define __ASYNCHELPER_H | ||
56 | + | ||
57 | +/* poll until POLLOUT, then call CIOCASYNCCRYPT */ | ||
58 | +inline int do_async_crypt(int cfd, struct crypt_op *cryp) | ||
59 | +{ | ||
60 | + struct pollfd pfd; | ||
61 | + | ||
62 | + pfd.fd = cfd; | ||
63 | + pfd.events = POLLOUT; | ||
64 | + | ||
65 | + if (poll(&pfd, 1, -1) < 1) { | ||
66 | + perror("poll()"); | ||
67 | + return 1; | ||
68 | + } | ||
69 | + | ||
70 | + if (ioctl(cfd, CIOCASYNCCRYPT, cryp)) { | ||
71 | + perror("ioctl(CIOCCRYPT)"); | ||
72 | + return 1; | ||
73 | + } | ||
74 | + return 0; | ||
75 | +} | ||
76 | + | ||
77 | +/* poll until POLLIN, then call CIOCASYNCFETCH */ | ||
78 | +inline int do_async_fetch(int cfd, struct crypt_op *cryp) | ||
79 | +{ | ||
80 | + struct pollfd pfd; | ||
81 | + | ||
82 | + pfd.fd = cfd; | ||
83 | + pfd.events = POLLIN; | ||
84 | + | ||
85 | + if (poll(&pfd, 1, -1) < 1) { | ||
86 | + perror("poll()"); | ||
87 | + return 1; | ||
88 | + } | ||
89 | + | ||
90 | + if (ioctl(cfd, CIOCASYNCFETCH, cryp)) { | ||
91 | + perror("ioctl(CIOCCRYPT)"); | ||
92 | + return 1; | ||
93 | + } | ||
94 | + return 0; | ||
95 | +} | ||
96 | + | ||
97 | +/* Check return value of stmt for identity with goodval. If they | ||
98 | + * don't match, call return with the value of stmt. */ | ||
99 | +#define DO_OR_DIE(stmt, goodval) { \ | ||
100 | + int __rc_val; \ | ||
101 | + if ((__rc_val = stmt) != goodval) { \ | ||
102 | + perror("DO_OR_DIE(" #stmt "," #goodval ")"); \ | ||
103 | + return __rc_val; \ | ||
104 | + } \ | ||
105 | +} | ||
106 | + | ||
107 | +#endif /* __ASYNCHELPER_H */ | ||
108 | diff --git a/tests/testhelper.h b/tests/testhelper.h | ||
109 | deleted file mode 100644 | ||
110 | index ea0b100..0000000 | ||
111 | --- a/tests/testhelper.h | ||
112 | +++ /dev/null | ||
113 | @@ -1,57 +0,0 @@ | ||
114 | -/* | ||
115 | - * Some helper stuff shared between the sample programs. | ||
116 | - */ | ||
117 | -#ifndef _TESTHELPER_H | ||
118 | -#define _TESTHELPER_H | ||
119 | - | ||
120 | -/* poll until POLLOUT, then call CIOCASYNCCRYPT */ | ||
121 | -inline int do_async_crypt(int cfd, struct crypt_op *cryp) | ||
122 | -{ | ||
123 | - struct pollfd pfd; | ||
124 | - | ||
125 | - pfd.fd = cfd; | ||
126 | - pfd.events = POLLOUT; | ||
127 | - | ||
128 | - if (poll(&pfd, 1, -1) < 1) { | ||
129 | - perror("poll()"); | ||
130 | - return 1; | ||
131 | - } | ||
132 | - | ||
133 | - if (ioctl(cfd, CIOCASYNCCRYPT, cryp)) { | ||
134 | - perror("ioctl(CIOCCRYPT)"); | ||
135 | - return 1; | ||
136 | - } | ||
137 | - return 0; | ||
138 | -} | ||
139 | - | ||
140 | -/* poll until POLLIN, then call CIOCASYNCFETCH */ | ||
141 | -inline int do_async_fetch(int cfd, struct crypt_op *cryp) | ||
142 | -{ | ||
143 | - struct pollfd pfd; | ||
144 | - | ||
145 | - pfd.fd = cfd; | ||
146 | - pfd.events = POLLIN; | ||
147 | - | ||
148 | - if (poll(&pfd, 1, -1) < 1) { | ||
149 | - perror("poll()"); | ||
150 | - return 1; | ||
151 | - } | ||
152 | - | ||
153 | - if (ioctl(cfd, CIOCASYNCFETCH, cryp)) { | ||
154 | - perror("ioctl(CIOCCRYPT)"); | ||
155 | - return 1; | ||
156 | - } | ||
157 | - return 0; | ||
158 | -} | ||
159 | - | ||
160 | -/* Check return value of stmt for identity with goodval. If they | ||
161 | - * don't match, call return with the value of stmt. */ | ||
162 | -#define DO_OR_DIE(stmt, goodval) { \ | ||
163 | - int __rc_val; \ | ||
164 | - if ((__rc_val = stmt) != goodval) { \ | ||
165 | - perror("DO_OR_DIE(" #stmt "," #goodval ")"); \ | ||
166 | - return __rc_val; \ | ||
167 | - } \ | ||
168 | -} | ||
169 | - | ||
170 | -#endif /* _TESTHELPER_H */ | ||
171 | -- | ||
172 | 2.10.2 | ||
173 | |||
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 @@ | |||
1 | From 6f4589ae57d141ea6257ae16df1709781d0fb8e4 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Tue, 29 Nov 2016 13:37:22 +0200 | ||
4 | Subject: [PATCH 096/104] use buf_align macro to reduce code duplication | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/async_cipher.c | 9 +++++---- | ||
9 | tests/cipher-aead-srtp.c | 13 +++++++------ | ||
10 | tests/cipher-aead.c | 13 +++++++------ | ||
11 | tests/cipher-gcm.c | 17 +++++------------ | ||
12 | tests/cipher.c | 9 +++++---- | ||
13 | tests/testhelper.h | 9 +++++++++ | ||
14 | 6 files changed, 38 insertions(+), 32 deletions(-) | ||
15 | create mode 100644 tests/testhelper.h | ||
16 | |||
17 | diff --git a/tests/async_cipher.c b/tests/async_cipher.c | ||
18 | index db6fb06..7a184e5 100644 | ||
19 | --- a/tests/async_cipher.c | ||
20 | +++ b/tests/async_cipher.c | ||
21 | @@ -14,6 +14,7 @@ | ||
22 | #include <crypto/cryptodev.h> | ||
23 | |||
24 | #include "asynchelper.h" | ||
25 | +#include "testhelper.h" | ||
26 | |||
27 | #ifdef ENABLE_ASYNC | ||
28 | |||
29 | @@ -62,8 +63,8 @@ test_crypto(int cfd) | ||
30 | perror("ioctl(CIOCGSESSINFO)"); | ||
31 | return 1; | ||
32 | } | ||
33 | - plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
34 | - ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
35 | + plaintext = buf_align(plaintext_raw, siop.alignmask); | ||
36 | + ciphertext = buf_align(ciphertext_raw, siop.alignmask); | ||
37 | #else | ||
38 | plaintext = plaintext_raw; | ||
39 | ciphertext = ciphertext_raw; | ||
40 | @@ -162,7 +163,7 @@ static int test_aes(int cfd) | ||
41 | perror("ioctl(CIOCGSESSINFO)"); | ||
42 | return 1; | ||
43 | } | ||
44 | - plaintext1 = (uint8_t *)(((unsigned long)plaintext1_raw + siop1.alignmask) & ~siop1.alignmask); | ||
45 | + plaintext1 = buf_align(plaintext1_raw, siop1.alignmask); | ||
46 | #else | ||
47 | plaintext1 = plaintext1_raw; | ||
48 | #endif | ||
49 | @@ -185,7 +186,7 @@ static int test_aes(int cfd) | ||
50 | perror("ioctl(CIOCGSESSINFO)"); | ||
51 | return 1; | ||
52 | } | ||
53 | - plaintext2 = (uint8_t *)(((unsigned long)plaintext2_raw + siop2.alignmask) & ~siop2.alignmask); | ||
54 | + plaintext2 = buf_align(plaintext2_raw, siop2.alignmask); | ||
55 | #else | ||
56 | plaintext2 = plaintext2_raw; | ||
57 | #endif | ||
58 | diff --git a/tests/cipher-aead-srtp.c b/tests/cipher-aead-srtp.c | ||
59 | index c44877d..578d2f7 100644 | ||
60 | --- a/tests/cipher-aead-srtp.c | ||
61 | +++ b/tests/cipher-aead-srtp.c | ||
62 | @@ -12,6 +12,7 @@ | ||
63 | |||
64 | #include <sys/ioctl.h> | ||
65 | #include <crypto/cryptodev.h> | ||
66 | +#include "testhelper.h" | ||
67 | |||
68 | #define DATA_SIZE (8*1024) | ||
69 | #define HEADER_SIZE 193 | ||
70 | @@ -122,8 +123,8 @@ test_crypto(int cfd) | ||
71 | printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", | ||
72 | siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
73 | |||
74 | - plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
75 | - ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
76 | + plaintext = buf_align(plaintext_raw, siop.alignmask); | ||
77 | + ciphertext = buf_align(ciphertext_raw, siop.alignmask); | ||
78 | |||
79 | memset(plaintext, 0x15, HEADER_SIZE); /* header */ | ||
80 | memset(&plaintext[HEADER_SIZE], 0x17, PLAINTEXT_SIZE); /* payload */ | ||
81 | @@ -265,8 +266,8 @@ test_encrypt_decrypt(int cfd) | ||
82 | // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", | ||
83 | // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
84 | |||
85 | - plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
86 | - ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
87 | + plaintext = buf_align(plaintext_raw, siop.alignmask); | ||
88 | + ciphertext = buf_align(ciphertext_raw, siop.alignmask); | ||
89 | |||
90 | memset(plaintext, 0x15, HEADER_SIZE); /* header */ | ||
91 | memset(&plaintext[HEADER_SIZE], 0x17, PLAINTEXT_SIZE); /* payload */ | ||
92 | @@ -407,8 +408,8 @@ test_encrypt_decrypt_error(int cfd, int err) | ||
93 | // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", | ||
94 | // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
95 | |||
96 | - plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
97 | - ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
98 | + plaintext = buf_align(plaintext_raw, siop.alignmask); | ||
99 | + ciphertext = buf_align(ciphertext_raw, siop.alignmask); | ||
100 | |||
101 | memset(plaintext, 0x15, HEADER_SIZE); /* header */ | ||
102 | memset(&plaintext[HEADER_SIZE], 0x17, PLAINTEXT_SIZE); /* payload */ | ||
103 | diff --git a/tests/cipher-aead.c b/tests/cipher-aead.c | ||
104 | index da43aa6..b329d12 100644 | ||
105 | --- a/tests/cipher-aead.c | ||
106 | +++ b/tests/cipher-aead.c | ||
107 | @@ -12,6 +12,7 @@ | ||
108 | |||
109 | #include <sys/ioctl.h> | ||
110 | #include <crypto/cryptodev.h> | ||
111 | +#include "testhelper.h" | ||
112 | |||
113 | #define DATA_SIZE (8*1024) | ||
114 | #define AUTH_SIZE 31 | ||
115 | @@ -133,8 +134,8 @@ test_crypto(int cfd) | ||
116 | printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", | ||
117 | siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
118 | |||
119 | - plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
120 | - ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
121 | + plaintext = buf_align(plaintext_raw, siop.alignmask); | ||
122 | + ciphertext = buf_align(ciphertext_raw, siop.alignmask); | ||
123 | memset(plaintext, 0x15, DATA_SIZE); | ||
124 | |||
125 | if (get_sha1_hmac(cfd, sess.mackey, sess.mackeylen, auth, sizeof(auth), plaintext, DATA_SIZE, sha1mac) != 0) { | ||
126 | @@ -285,8 +286,8 @@ test_encrypt_decrypt(int cfd) | ||
127 | // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", | ||
128 | // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
129 | |||
130 | - plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
131 | - ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
132 | + plaintext = buf_align(plaintext_raw, siop.alignmask); | ||
133 | + ciphertext = buf_align(ciphertext_raw, siop.alignmask); | ||
134 | |||
135 | memset(plaintext, 0x15, DATA_SIZE); | ||
136 | |||
137 | @@ -434,8 +435,8 @@ test_encrypt_decrypt_error(int cfd, int err) | ||
138 | // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", | ||
139 | // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
140 | |||
141 | - plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
142 | - ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
143 | + plaintext = buf_align(plaintext_raw, siop.alignmask); | ||
144 | + ciphertext = buf_align(ciphertext_raw, siop.alignmask); | ||
145 | memset(plaintext, 0x15, DATA_SIZE); | ||
146 | |||
147 | if (get_sha1_hmac(cfd, sess.mackey, sess.mackeylen, auth, sizeof(auth), plaintext, DATA_SIZE, sha1mac) != 0) { | ||
148 | diff --git a/tests/cipher-gcm.c b/tests/cipher-gcm.c | ||
149 | index 3f6cc7b..d5f8486 100644 | ||
150 | --- a/tests/cipher-gcm.c | ||
151 | +++ b/tests/cipher-gcm.c | ||
152 | @@ -12,6 +12,7 @@ | ||
153 | |||
154 | #include <sys/ioctl.h> | ||
155 | #include <crypto/cryptodev.h> | ||
156 | +#include "testhelper.h" | ||
157 | |||
158 | #define DATA_SIZE (8*1024) | ||
159 | #define AUTH_SIZE 31 | ||
160 | @@ -232,12 +233,8 @@ static int test_encrypt_decrypt(int cfd) | ||
161 | // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", | ||
162 | // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
163 | |||
164 | - plaintext = | ||
165 | - (uint8_t *) (((unsigned long) plaintext_raw + siop.alignmask) & | ||
166 | - ~siop.alignmask); | ||
167 | - ciphertext = | ||
168 | - (uint8_t *) (((unsigned long) ciphertext_raw + siop.alignmask) & | ||
169 | - ~siop.alignmask); | ||
170 | + plaintext = (__u8 *)buf_align(plaintext_raw, siop.alignmask); | ||
171 | + ciphertext = (__u8 *)buf_align(ciphertext_raw, siop.alignmask); | ||
172 | |||
173 | memset(plaintext, 0x15, DATA_SIZE); | ||
174 | |||
175 | @@ -385,12 +382,8 @@ static int test_encrypt_decrypt_error(int cfd, int err) | ||
176 | // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", | ||
177 | // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
178 | |||
179 | - plaintext = | ||
180 | - (uint8_t *) (((unsigned long) plaintext_raw + siop.alignmask) & | ||
181 | - ~siop.alignmask); | ||
182 | - ciphertext = | ||
183 | - (uint8_t *) (((unsigned long) ciphertext_raw + siop.alignmask) & | ||
184 | - ~siop.alignmask); | ||
185 | + plaintext = (__u8 *)buf_align(plaintext_raw, siop.alignmask); | ||
186 | + ciphertext = (__u8 *)buf_align(ciphertext_raw, siop.alignmask); | ||
187 | |||
188 | memset(plaintext, 0x15, DATA_SIZE); | ||
189 | memcpy(ciphertext, plaintext, DATA_SIZE); | ||
190 | diff --git a/tests/cipher.c b/tests/cipher.c | ||
191 | index f3ca2f0..222f095 100644 | ||
192 | --- a/tests/cipher.c | ||
193 | +++ b/tests/cipher.c | ||
194 | @@ -12,6 +12,7 @@ | ||
195 | |||
196 | #include <sys/ioctl.h> | ||
197 | #include <crypto/cryptodev.h> | ||
198 | +#include "testhelper.h" | ||
199 | |||
200 | static int debug = 0; | ||
201 | |||
202 | @@ -58,8 +59,8 @@ test_crypto(int cfd) | ||
203 | printf("requested cipher CRYPTO_AES_CBC, got %s with driver %s\n", | ||
204 | siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
205 | |||
206 | - plaintext = (uint8_t *)(((unsigned long)plaintext_raw + siop.alignmask) & ~siop.alignmask); | ||
207 | - ciphertext = (uint8_t *)(((unsigned long)ciphertext_raw + siop.alignmask) & ~siop.alignmask); | ||
208 | + plaintext = buf_align(plaintext_raw, siop.alignmask); | ||
209 | + ciphertext = buf_align(ciphertext_raw, siop.alignmask); | ||
210 | #else | ||
211 | plaintext = plaintext_raw; | ||
212 | ciphertext = ciphertext_raw; | ||
213 | @@ -177,7 +178,7 @@ static int test_aes(int cfd) | ||
214 | perror("ioctl(CIOCGSESSINFO)"); | ||
215 | return 1; | ||
216 | } | ||
217 | - plaintext1 = (uint8_t *)(((unsigned long)plaintext1_raw + siop.alignmask) & ~siop.alignmask); | ||
218 | + plaintext1 = buf_align(plaintext1_raw, siop.alignmask); | ||
219 | #else | ||
220 | plaintext1 = plaintext1_raw; | ||
221 | #endif | ||
222 | @@ -227,7 +228,7 @@ static int test_aes(int cfd) | ||
223 | printf("requested cipher CRYPTO_AES_CBC, got %s with driver %s\n", | ||
224 | siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
225 | |||
226 | - plaintext2 = (uint8_t *)(((unsigned long)plaintext2_raw + siop.alignmask) & ~siop.alignmask); | ||
227 | + plaintext2 = buf_align(plaintext2_raw, siop.alignmask); | ||
228 | #else | ||
229 | plaintext2 = plaintext2_raw; | ||
230 | #endif | ||
231 | diff --git a/tests/testhelper.h b/tests/testhelper.h | ||
232 | new file mode 100644 | ||
233 | index 0000000..800d10d | ||
234 | --- /dev/null | ||
235 | +++ b/tests/testhelper.h | ||
236 | @@ -0,0 +1,9 @@ | ||
237 | +/* | ||
238 | + * Some helper stuff shared between the sample programs. | ||
239 | + */ | ||
240 | +#ifndef __TESTHELPER_H | ||
241 | +#define __TESTHELPER_H | ||
242 | + | ||
243 | +#define buf_align(buf, align) (void *)(((unsigned long)(buf) + (align)) & ~(align)) | ||
244 | + | ||
245 | +#endif /* __TESTHELPER_H */ | ||
246 | -- | ||
247 | 2.10.2 | ||
248 | |||
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 @@ | |||
1 | From 4843f76a74558b85944dbf923cf699bfd5b354eb Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Tue, 29 Nov 2016 13:37:23 +0200 | ||
4 | Subject: [PATCH 097/104] avoid implicit conversion between signed and unsigned | ||
5 | char | ||
6 | |||
7 | Use uint8_t type for all variables with this problem and avoid casting | ||
8 | from char in assignments. With uint8_t we also convey the information | ||
9 | that we're using small numbers rather than strings. | ||
10 | |||
11 | Although cryptodev.h uses the synonym type __u8, we use uint8_t | ||
12 | for consistency with other files in tests directory and also because it | ||
13 | is a standard POSIX type. | ||
14 | |||
15 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
16 | --- | ||
17 | tests/async_hmac.c | 12 ++++++------ | ||
18 | tests/cipher-aead.c | 10 +++++----- | ||
19 | tests/cipher-gcm.c | 40 ++++++++++++++++++++-------------------- | ||
20 | tests/cipher.c | 1 - | ||
21 | tests/fullspeed.c | 1 + | ||
22 | tests/hmac.c | 12 ++++++------ | ||
23 | 6 files changed, 38 insertions(+), 38 deletions(-) | ||
24 | |||
25 | diff --git a/tests/async_hmac.c b/tests/async_hmac.c | ||
26 | index 1bdaad3..014b8ed 100644 | ||
27 | --- a/tests/async_hmac.c | ||
28 | +++ b/tests/async_hmac.c | ||
29 | @@ -61,7 +61,7 @@ test_crypto(int cfd) | ||
30 | |||
31 | cryp.ses = sess.ses; | ||
32 | cryp.len = sizeof("what do ya want for nothing?")-1; | ||
33 | - cryp.src = (uint8_t*)"what do ya want for nothing?"; | ||
34 | + cryp.src = (uint8_t *)"what do ya want for nothing?"; | ||
35 | cryp.mac = mac; | ||
36 | cryp.op = COP_ENCRYPT; | ||
37 | |||
38 | @@ -88,7 +88,7 @@ test_crypto(int cfd) | ||
39 | memset(mac, 0, sizeof(mac)); | ||
40 | |||
41 | sess.cipher = 0; | ||
42 | - sess.mackey = (uint8_t*)"Jefe"; | ||
43 | + sess.mackey = (uint8_t *)"Jefe"; | ||
44 | sess.mackeylen = 4; | ||
45 | sess.mac = CRYPTO_MD5_HMAC; | ||
46 | if (ioctl(cfd, CIOCGSESSION, &sess)) { | ||
47 | @@ -98,7 +98,7 @@ test_crypto(int cfd) | ||
48 | |||
49 | cryp.ses = sess.ses; | ||
50 | cryp.len = sizeof("what do ya want for nothing?")-1; | ||
51 | - cryp.src = (uint8_t*)"what do ya want for nothing?"; | ||
52 | + cryp.src = (uint8_t *)"what do ya want for nothing?"; | ||
53 | cryp.mac = mac; | ||
54 | cryp.op = COP_ENCRYPT; | ||
55 | |||
56 | @@ -127,7 +127,7 @@ test_crypto(int cfd) | ||
57 | sess.keylen = KEY_SIZE; | ||
58 | sess.key = data.key; | ||
59 | sess.mackeylen = 16; | ||
60 | - sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
61 | + sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
62 | if (ioctl(cfd, CIOCGSESSION, &sess)) { | ||
63 | perror("ioctl(CIOCGSESSION)"); | ||
64 | return 1; | ||
65 | @@ -206,7 +206,7 @@ test_extras(int cfd) | ||
66 | |||
67 | cryp.ses = sess.ses; | ||
68 | cryp.len = sizeof("what do")-1; | ||
69 | - cryp.src = (uint8_t*)"what do"; | ||
70 | + cryp.src = (uint8_t *)"what do"; | ||
71 | cryp.mac = mac; | ||
72 | cryp.op = COP_ENCRYPT; | ||
73 | cryp.flags = COP_FLAG_UPDATE; | ||
74 | @@ -216,7 +216,7 @@ test_extras(int cfd) | ||
75 | |||
76 | cryp.ses = sess.ses; | ||
77 | cryp.len = sizeof(" ya want for nothing?")-1; | ||
78 | - cryp.src = (uint8_t*)" ya want for nothing?"; | ||
79 | + cryp.src = (uint8_t *)" ya want for nothing?"; | ||
80 | cryp.mac = mac; | ||
81 | cryp.op = COP_ENCRYPT; | ||
82 | cryp.flags = COP_FLAG_FINAL; | ||
83 | diff --git a/tests/cipher-aead.c b/tests/cipher-aead.c | ||
84 | index b329d12..305b720 100644 | ||
85 | --- a/tests/cipher-aead.c | ||
86 | +++ b/tests/cipher-aead.c | ||
87 | @@ -118,7 +118,7 @@ test_crypto(int cfd) | ||
88 | |||
89 | sess.mac = CRYPTO_SHA1_HMAC; | ||
90 | sess.mackeylen = 16; | ||
91 | - sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
92 | + sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
93 | |||
94 | if (ioctl(cfd, CIOCGSESSION, &sess)) { | ||
95 | perror("ioctl(CIOCGSESSION)"); | ||
96 | @@ -271,7 +271,7 @@ test_encrypt_decrypt(int cfd) | ||
97 | |||
98 | sess.mac = CRYPTO_SHA1_HMAC; | ||
99 | sess.mackeylen = 16; | ||
100 | - sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
101 | + sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
102 | |||
103 | if (ioctl(cfd, CIOCGSESSION, &sess)) { | ||
104 | perror("ioctl(CIOCGSESSION)"); | ||
105 | @@ -329,7 +329,7 @@ test_encrypt_decrypt(int cfd) | ||
106 | sess.key = key; | ||
107 | sess.mac = CRYPTO_SHA1_HMAC; | ||
108 | sess.mackeylen = 16; | ||
109 | - sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
110 | + sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
111 | |||
112 | if (ioctl(cfd, CIOCGSESSION, &sess)) { | ||
113 | perror("ioctl(CIOCGSESSION)"); | ||
114 | @@ -420,7 +420,7 @@ test_encrypt_decrypt_error(int cfd, int err) | ||
115 | |||
116 | sess.mac = CRYPTO_SHA1_HMAC; | ||
117 | sess.mackeylen = 16; | ||
118 | - sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
119 | + sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
120 | |||
121 | if (ioctl(cfd, CIOCGSESSION, &sess)) { | ||
122 | perror("ioctl(CIOCGSESSION)"); | ||
123 | @@ -477,7 +477,7 @@ test_encrypt_decrypt_error(int cfd, int err) | ||
124 | sess.key = key; | ||
125 | sess.mac = CRYPTO_SHA1_HMAC; | ||
126 | sess.mackeylen = 16; | ||
127 | - sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
128 | + sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
129 | |||
130 | if (ioctl(cfd, CIOCGSESSION, &sess)) { | ||
131 | perror("ioctl(CIOCGSESSION)"); | ||
132 | diff --git a/tests/cipher-gcm.c b/tests/cipher-gcm.c | ||
133 | index d5f8486..36c827a 100644 | ||
134 | --- a/tests/cipher-gcm.c | ||
135 | +++ b/tests/cipher-gcm.c | ||
136 | @@ -46,45 +46,45 @@ struct aes_gcm_vectors_st { | ||
137 | |||
138 | struct aes_gcm_vectors_st aes_gcm_vectors[] = { | ||
139 | { | ||
140 | - .key = (uint8_t*) | ||
141 | + .key = (uint8_t *) | ||
142 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", | ||
143 | .auth = NULL, | ||
144 | .auth_size = 0, | ||
145 | - .plaintext = (uint8_t*) | ||
146 | + .plaintext = (uint8_t *) | ||
147 | "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", | ||
148 | .plaintext_size = 16, | ||
149 | - .ciphertext = (uint8_t*) | ||
150 | + .ciphertext = (uint8_t *) | ||
151 | "\x03\x88\xda\xce\x60\xb6\xa3\x92\xf3\x28\xc2\xb9\x71\xb2\xfe\x78", | ||
152 | - .iv = (uint8_t*)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", | ||
153 | - .tag = (uint8_t*) | ||
154 | + .iv = (uint8_t *)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", | ||
155 | + .tag = (uint8_t *) | ||
156 | "\xab\x6e\x47\xd4\x2c\xec\x13\xbd\xf5\x3a\x67\xb2\x12\x57\xbd\xdf" | ||
157 | }, | ||
158 | { | ||
159 | - .key = (uint8_t*) | ||
160 | + .key = (uint8_t *) | ||
161 | "\xfe\xff\xe9\x92\x86\x65\x73\x1c\x6d\x6a\x8f\x94\x67\x30\x83\x08", | ||
162 | .auth = NULL, | ||
163 | .auth_size = 0, | ||
164 | - .plaintext = (uint8_t*) | ||
165 | + .plaintext = (uint8_t *) | ||
166 | "\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", | ||
167 | .plaintext_size = 64, | ||
168 | - .ciphertext = (uint8_t*) | ||
169 | + .ciphertext = (uint8_t *) | ||
170 | "\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", | ||
171 | - .iv = (uint8_t*)"\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88", | ||
172 | - .tag = (uint8_t*)"\x4d\x5c\x2a\xf3\x27\xcd\x64\xa6\x2c\xf3\x5a\xbd\x2b\xa6\xfa\xb4" | ||
173 | + .iv = (uint8_t *)"\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88", | ||
174 | + .tag = (uint8_t *)"\x4d\x5c\x2a\xf3\x27\xcd\x64\xa6\x2c\xf3\x5a\xbd\x2b\xa6\xfa\xb4" | ||
175 | }, | ||
176 | { | ||
177 | - .key = (uint8_t*) | ||
178 | + .key = (uint8_t *) | ||
179 | "\xfe\xff\xe9\x92\x86\x65\x73\x1c\x6d\x6a\x8f\x94\x67\x30\x83\x08", | ||
180 | - .auth = (uint8_t*) | ||
181 | + .auth = (uint8_t *) | ||
182 | "\xfe\xed\xfa\xce\xde\xad\xbe\xef\xfe\xed\xfa\xce\xde\xad\xbe\xef\xab\xad\xda\xd2", | ||
183 | .auth_size = 20, | ||
184 | - .plaintext = (uint8_t*) | ||
185 | + .plaintext = (uint8_t *) | ||
186 | "\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", | ||
187 | .plaintext_size = 60, | ||
188 | - .ciphertext = (uint8_t*) | ||
189 | + .ciphertext = (uint8_t *) | ||
190 | "\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", | ||
191 | - .iv = (uint8_t*)"\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88", | ||
192 | - .tag = (uint8_t*) | ||
193 | + .iv = (uint8_t *)"\xca\xfe\xba\xbe\xfa\xce\xdb\xad\xde\xca\xf8\x88", | ||
194 | + .tag = (uint8_t *) | ||
195 | "\x5b\xc9\x4f\xbc\x32\x21\xa5\xdb\x94\xfa\xe9\x5a\xe7\x12\x1a\x47" | ||
196 | } | ||
197 | }; | ||
198 | @@ -233,8 +233,8 @@ static int test_encrypt_decrypt(int cfd) | ||
199 | // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", | ||
200 | // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
201 | |||
202 | - plaintext = (__u8 *)buf_align(plaintext_raw, siop.alignmask); | ||
203 | - ciphertext = (__u8 *)buf_align(ciphertext_raw, siop.alignmask); | ||
204 | + plaintext = (uint8_t *)buf_align(plaintext_raw, siop.alignmask); | ||
205 | + ciphertext = (uint8_t *)buf_align(ciphertext_raw, siop.alignmask); | ||
206 | |||
207 | memset(plaintext, 0x15, DATA_SIZE); | ||
208 | |||
209 | @@ -382,8 +382,8 @@ static int test_encrypt_decrypt_error(int cfd, int err) | ||
210 | // printf("requested cipher CRYPTO_AES_CBC/HMAC-SHA1, got %s with driver %s\n", | ||
211 | // siop.cipher_info.cra_name, siop.cipher_info.cra_driver_name); | ||
212 | |||
213 | - plaintext = (__u8 *)buf_align(plaintext_raw, siop.alignmask); | ||
214 | - ciphertext = (__u8 *)buf_align(ciphertext_raw, siop.alignmask); | ||
215 | + plaintext = (uint8_t *)buf_align(plaintext_raw, siop.alignmask); | ||
216 | + ciphertext = (uint8_t *)buf_align(ciphertext_raw, siop.alignmask); | ||
217 | |||
218 | memset(plaintext, 0x15, DATA_SIZE); | ||
219 | memcpy(ciphertext, plaintext, DATA_SIZE); | ||
220 | diff --git a/tests/cipher.c b/tests/cipher.c | ||
221 | index 222f095..fab3de6 100644 | ||
222 | --- a/tests/cipher.c | ||
223 | +++ b/tests/cipher.c | ||
224 | @@ -9,7 +9,6 @@ | ||
225 | #include <unistd.h> | ||
226 | #include <fcntl.h> | ||
227 | #include <stdint.h> | ||
228 | - | ||
229 | #include <sys/ioctl.h> | ||
230 | #include <crypto/cryptodev.h> | ||
231 | #include "testhelper.h" | ||
232 | diff --git a/tests/fullspeed.c b/tests/fullspeed.c | ||
233 | index c025130..ae873e2 100644 | ||
234 | --- a/tests/fullspeed.c | ||
235 | +++ b/tests/fullspeed.c | ||
236 | @@ -24,6 +24,7 @@ | ||
237 | #include <sys/time.h> | ||
238 | #include <sys/types.h> | ||
239 | #include <signal.h> | ||
240 | +#include <stdint.h> | ||
241 | #include <unistd.h> | ||
242 | #include <stdint.h> | ||
243 | |||
244 | diff --git a/tests/hmac.c b/tests/hmac.c | ||
245 | index 3b248f3..8d6492e 100644 | ||
246 | --- a/tests/hmac.c | ||
247 | +++ b/tests/hmac.c | ||
248 | @@ -69,7 +69,7 @@ test_crypto(int cfd) | ||
249 | |||
250 | cryp.ses = sess.ses; | ||
251 | cryp.len = sizeof("what do ya want for nothing?")-1; | ||
252 | - cryp.src = (uint8_t*)"what do ya want for nothing?"; | ||
253 | + cryp.src = (uint8_t *)"what do ya want for nothing?"; | ||
254 | cryp.mac = mac; | ||
255 | cryp.op = COP_ENCRYPT; | ||
256 | if (ioctl(cfd, CIOCCRYPT, &cryp)) { | ||
257 | @@ -92,7 +92,7 @@ test_crypto(int cfd) | ||
258 | memset(mac, 0, sizeof(mac)); | ||
259 | |||
260 | sess.cipher = 0; | ||
261 | - sess.mackey = (uint8_t*)"Jefe"; | ||
262 | + sess.mackey = (uint8_t *)"Jefe"; | ||
263 | sess.mackeylen = 4; | ||
264 | sess.mac = CRYPTO_MD5_HMAC; | ||
265 | if (ioctl(cfd, CIOCGSESSION, &sess)) { | ||
266 | @@ -113,7 +113,7 @@ test_crypto(int cfd) | ||
267 | |||
268 | cryp.ses = sess.ses; | ||
269 | cryp.len = sizeof("what do ya want for nothing?")-1; | ||
270 | - cryp.src = (uint8_t*)"what do ya want for nothing?"; | ||
271 | + cryp.src = (uint8_t *)"what do ya want for nothing?"; | ||
272 | cryp.mac = mac; | ||
273 | cryp.op = COP_ENCRYPT; | ||
274 | if (ioctl(cfd, CIOCCRYPT, &cryp)) { | ||
275 | @@ -138,7 +138,7 @@ test_crypto(int cfd) | ||
276 | sess.keylen = KEY_SIZE; | ||
277 | sess.key = data.key; | ||
278 | sess.mackeylen = 16; | ||
279 | - sess.mackey = (uint8_t*)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
280 | + sess.mackey = (uint8_t *)"\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"; | ||
281 | if (ioctl(cfd, CIOCGSESSION, &sess)) { | ||
282 | perror("ioctl(CIOCGSESSION)"); | ||
283 | return 1; | ||
284 | @@ -244,7 +244,7 @@ test_extras(int cfd) | ||
285 | |||
286 | cryp.ses = sess.ses; | ||
287 | cryp.len = sizeof("what do")-1; | ||
288 | - cryp.src = (uint8_t*)"what do"; | ||
289 | + cryp.src = (uint8_t *)"what do"; | ||
290 | cryp.mac = mac; | ||
291 | cryp.op = COP_ENCRYPT; | ||
292 | cryp.flags = COP_FLAG_UPDATE; | ||
293 | @@ -255,7 +255,7 @@ test_extras(int cfd) | ||
294 | |||
295 | cryp.ses = sess.ses; | ||
296 | cryp.len = sizeof(" ya want for nothing?")-1; | ||
297 | - cryp.src = (uint8_t*)" ya want for nothing?"; | ||
298 | + cryp.src = (uint8_t *)" ya want for nothing?"; | ||
299 | cryp.mac = mac; | ||
300 | cryp.op = COP_ENCRYPT; | ||
301 | cryp.flags = COP_FLAG_FINAL; | ||
302 | -- | ||
303 | 2.10.2 | ||
304 | |||
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 @@ | |||
1 | From badd002fe5bdcaf7a7d856f174e2abb10b939467 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Tue, 29 Nov 2016 13:37:24 +0200 | ||
4 | Subject: [PATCH 098/104] reduce tests/Makefile distance with upstream | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/Makefile | 4 ++-- | ||
9 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
10 | |||
11 | diff --git a/tests/Makefile b/tests/Makefile | ||
12 | index 88f5040..5a09414 100644 | ||
13 | --- a/tests/Makefile | ||
14 | +++ b/tests/Makefile | ||
15 | @@ -1,5 +1,5 @@ | ||
16 | -CRYPTODEV_CFLAGS += -DENABLE_ASYNC -std=gnu90 -Wall -Werror | ||
17 | -CFLAGS += -I.. $(CRYPTODEV_CFLAGS) | ||
18 | +CRYPTODEV_CFLAGS += -DENABLE_ASYNC -std=gnu90 | ||
19 | +CFLAGS += -I.. $(CRYPTODEV_CFLAGS) -Wall -Werror | ||
20 | |||
21 | comp_progs := cipher_comp hash_comp hmac_comp | ||
22 | |||
23 | -- | ||
24 | 2.10.2 | ||
25 | |||
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 @@ | |||
1 | From d2cb6745bb166818b6bd9e9011990453fedbccef Mon Sep 17 00:00:00 2001 | ||
2 | From: Alexe Radu <radu.alexe@nxp.com> | ||
3 | Date: Fri, 9 Dec 2016 15:25:20 +0200 | ||
4 | Subject: [PATCH 099/104] add support for authenc(hmac(sha1), cbc(aes)) speed | ||
5 | tests | ||
6 | |||
7 | Signed-off-by: Alexe Radu <radu.alexe@nxp.com> | ||
8 | --- | ||
9 | crypto/cryptodev.h | 1 + | ||
10 | ioctl.c | 5 ++ | ||
11 | tests/speed.c | 155 +++++++++++++++++++++++++++++++++++++++++++++++------ | ||
12 | 3 files changed, 146 insertions(+), 15 deletions(-) | ||
13 | |||
14 | diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h | ||
15 | index 05221a4..05dc57b 100644 | ||
16 | --- a/crypto/cryptodev.h | ||
17 | +++ b/crypto/cryptodev.h | ||
18 | @@ -62,6 +62,7 @@ enum cryptodev_crypto_op_t { | ||
19 | CRYPTO_TLS12_3DES_CBC_HMAC_SHA1, | ||
20 | CRYPTO_TLS12_AES_CBC_HMAC_SHA1, | ||
21 | CRYPTO_TLS12_AES_CBC_HMAC_SHA256, | ||
22 | + CRYPTO_AUTHENC_HMAC_SHA1_CBC_AES, | ||
23 | CRYPTO_ALGORITHM_ALL, /* Keep updated - see below */ | ||
24 | }; | ||
25 | |||
26 | diff --git a/ioctl.c b/ioctl.c | ||
27 | index e3b8af1..7288ffc 100644 | ||
28 | --- a/ioctl.c | ||
29 | +++ b/ioctl.c | ||
30 | @@ -222,6 +222,11 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) | ||
31 | stream = 0; | ||
32 | aead = 1; | ||
33 | break; | ||
34 | + case CRYPTO_AUTHENC_HMAC_SHA1_CBC_AES: | ||
35 | + alg_name = "authenc(hmac(sha1),cbc(aes))"; | ||
36 | + stream = 0; | ||
37 | + aead = 1; | ||
38 | + break; | ||
39 | case CRYPTO_NULL: | ||
40 | alg_name = "ecb(cipher_null)"; | ||
41 | stream = 1; | ||
42 | diff --git a/tests/speed.c b/tests/speed.c | ||
43 | index fc38a63..61259b9 100644 | ||
44 | --- a/tests/speed.c | ||
45 | +++ b/tests/speed.c | ||
46 | @@ -33,12 +33,15 @@ | ||
47 | #include <stdint.h> | ||
48 | #include <inttypes.h> | ||
49 | |||
50 | +#define AUTH_SIZE 31 | ||
51 | +#define TAG_LEN 20 | ||
52 | |||
53 | struct test_params { | ||
54 | bool tflag; | ||
55 | bool nflag; | ||
56 | bool mflag; | ||
57 | bool aflag; | ||
58 | + bool authflag; | ||
59 | int tvalue; | ||
60 | int nvalue; | ||
61 | }; | ||
62 | @@ -59,8 +62,9 @@ int run_aes_256_xts(int fdc, struct test_params tp); | ||
63 | int run_crc32c(int fdc, struct test_params tp); | ||
64 | int run_sha1(int fdc, struct test_params tp); | ||
65 | int run_sha256(int fdc, struct test_params tp); | ||
66 | +int run_authenc(int fdc, struct test_params tp); | ||
67 | |||
68 | -#define ALG_COUNT 6 | ||
69 | +#define ALG_COUNT 7 | ||
70 | struct { | ||
71 | char *name; | ||
72 | int (*func)(int, struct test_params); | ||
73 | @@ -71,6 +75,7 @@ struct { | ||
74 | {"crc32c", run_crc32c}, | ||
75 | {"sha1", run_sha1}, | ||
76 | {"sha256", run_sha256}, | ||
77 | + {"authenc", run_authenc}, | ||
78 | }; | ||
79 | |||
80 | static double udifftimeval(struct timeval start, struct timeval end) | ||
81 | @@ -269,7 +274,7 @@ static int encrypt_sync(int fdc, struct test_params tp, struct session_op *sess) | ||
82 | } | ||
83 | memset(buffer, val++, tp.nvalue); | ||
84 | |||
85 | - must_finish = 0; | ||
86 | + must_finish = 1; | ||
87 | alarm(tp.tvalue); | ||
88 | |||
89 | gettimeofday(&start, NULL); | ||
90 | @@ -305,6 +310,84 @@ static int encrypt_sync(int fdc, struct test_params tp, struct session_op *sess) | ||
91 | return 0; | ||
92 | } | ||
93 | |||
94 | +static int encrypt_auth(int fdc, struct test_params tp, struct session_op *sess) | ||
95 | +{ | ||
96 | + struct crypt_auth_op cao; | ||
97 | + char *buffer, iv[32]; | ||
98 | + uint8_t auth[AUTH_SIZE]; | ||
99 | + static int val = 23; | ||
100 | + struct timeval start, end; | ||
101 | + uint64_t total = 0; | ||
102 | + double secs, ddata, dspeed; | ||
103 | + char metric[16]; | ||
104 | + int alignmask; | ||
105 | + int min_alignmask = sizeof(void*) - 1; | ||
106 | + int alloc_size; | ||
107 | + | ||
108 | + memset(iv, 0x23, 32); | ||
109 | + memset(auth, 0xf1, sizeof(auth)); | ||
110 | + | ||
111 | + if (!tp.mflag) { | ||
112 | + printf("\tBuffer size %d bytes: ", tp.nvalue); | ||
113 | + fflush(stdout); | ||
114 | + } | ||
115 | + | ||
116 | + alloc_size = tp.nvalue + TAG_LEN; | ||
117 | + alignmask = get_alignmask(fdc, sess); | ||
118 | + if (alignmask) { | ||
119 | + alignmask = ((alignmask < min_alignmask) ? min_alignmask : alignmask); | ||
120 | + if (posix_memalign((void **)(&buffer), alignmask + 1, alloc_size)) { | ||
121 | + printf("posix_memalign() failed!\n"); | ||
122 | + return 1; | ||
123 | + } | ||
124 | + } else { | ||
125 | + if (!(buffer = malloc(alloc_size))) { | ||
126 | + perror("malloc()"); | ||
127 | + return 1; | ||
128 | + } | ||
129 | + } | ||
130 | + memset(buffer, val++, tp.nvalue); | ||
131 | + | ||
132 | + must_finish = 0; | ||
133 | + alarm(tp.tvalue); | ||
134 | + | ||
135 | + gettimeofday(&start, NULL); | ||
136 | + do { | ||
137 | + memset(&cao, 0, sizeof(cao)); | ||
138 | + cao.ses = sess->ses; | ||
139 | + cao.auth_src = auth; | ||
140 | + cao.auth_len = sizeof(auth); | ||
141 | + cao.len = tp.nvalue; | ||
142 | + cao.iv = (unsigned char *)iv; | ||
143 | + cao.op = COP_ENCRYPT; | ||
144 | + cao.src = (unsigned char *)buffer; | ||
145 | + cao.dst = cao.src; | ||
146 | + cao.tag_len = TAG_LEN; | ||
147 | + cao.flags = COP_FLAG_AEAD_TLS_TYPE; | ||
148 | + | ||
149 | + if (ioctl(fdc, CIOCAUTHCRYPT, &cao)) { | ||
150 | + perror("ioctl(CIOCAUTHCRYPT)"); | ||
151 | + return 1; | ||
152 | + } | ||
153 | + total += cao.len; | ||
154 | + } while(!must_finish); | ||
155 | + gettimeofday(&end, NULL); | ||
156 | + | ||
157 | + secs = udifftimeval(start, end)/ 1000000.0; | ||
158 | + | ||
159 | + if (tp.mflag) { | ||
160 | + value2machine(total, secs, &dspeed); | ||
161 | + printf("%" PRIu64 "\t%.2f\t%.2f\n", total, secs, dspeed); | ||
162 | + } else { | ||
163 | + value2human(total, secs, &ddata, &dspeed, metric); | ||
164 | + printf ("done. %.2f %s in %.2f secs: ", ddata, metric, secs); | ||
165 | + printf ("%.2f %s/sec\n", dspeed, metric); | ||
166 | + } | ||
167 | + | ||
168 | + free(buffer); | ||
169 | + return 0; | ||
170 | +} | ||
171 | + | ||
172 | void usage(char *cmd_name) | ||
173 | { | ||
174 | printf(usage_str, cmd_name); | ||
175 | @@ -326,11 +409,19 @@ int run_test(int id, struct test_params tp) | ||
176 | return -EINVAL; | ||
177 | } | ||
178 | |||
179 | + if (strcmp("authenc", ciphers[id].name) == 0) { | ||
180 | + tp.authflag = true; | ||
181 | + } | ||
182 | + | ||
183 | if (!tp.mflag) { | ||
184 | - char *type; | ||
185 | - type = tp.aflag ? "async" : "sync"; | ||
186 | + if (tp.authflag) { | ||
187 | + fprintf(stderr, "Testing %s:\n", ciphers[id].name); | ||
188 | + } else { | ||
189 | + char *type; | ||
190 | + type = tp.aflag ? "async" : "sync"; | ||
191 | |||
192 | - fprintf(stderr, "Testing %s %s:\n", type, ciphers[id].name); | ||
193 | + fprintf(stderr, "Testing %s %s:\n", type, ciphers[id].name); | ||
194 | + } | ||
195 | } | ||
196 | err = ciphers[id].func(fdc, tp); | ||
197 | |||
198 | @@ -340,17 +431,30 @@ int run_test(int id, struct test_params tp) | ||
199 | return err; | ||
200 | } | ||
201 | |||
202 | -void do_test_vectors(int fdc, struct test_params tp, struct session_op *sess) | ||
203 | +static int start_test (int fdc, struct test_params tp, struct session_op *sess) | ||
204 | { | ||
205 | - int i; | ||
206 | int err; | ||
207 | |||
208 | - if (tp.nflag) { | ||
209 | + if (tp.authflag) { | ||
210 | + err = encrypt_auth(fdc, tp, sess); | ||
211 | + } else { | ||
212 | if (tp.aflag) { | ||
213 | - encrypt_async(fdc, tp, sess); | ||
214 | + err = encrypt_async(fdc, tp, sess); | ||
215 | } else { | ||
216 | - encrypt_sync(fdc, tp, sess); | ||
217 | + err = encrypt_sync(fdc, tp, sess); | ||
218 | } | ||
219 | + } | ||
220 | + | ||
221 | + return err; | ||
222 | +} | ||
223 | + | ||
224 | +void do_test_vectors(int fdc, struct test_params tp, struct session_op *sess) | ||
225 | +{ | ||
226 | + int i; | ||
227 | + int err; | ||
228 | + | ||
229 | + if (tp.nflag) { | ||
230 | + err = start_test(fdc, tp, sess); | ||
231 | } else { | ||
232 | for (i = 256; i <= (64 * 1024); i *= 2) { | ||
233 | if (must_exit) { | ||
234 | @@ -358,11 +462,7 @@ void do_test_vectors(int fdc, struct test_params tp, struct session_op *sess) | ||
235 | } | ||
236 | |||
237 | tp.nvalue = i; | ||
238 | - if (tp.aflag) { | ||
239 | - err = encrypt_async(fdc, tp, sess); | ||
240 | - } else { | ||
241 | - err = encrypt_sync(fdc, tp, sess); | ||
242 | - } | ||
243 | + err = start_test(fdc, tp, sess); | ||
244 | |||
245 | if (err != 0) { | ||
246 | break; | ||
247 | @@ -474,6 +574,30 @@ int run_sha256(int fdc, struct test_params tp) | ||
248 | return 0; | ||
249 | } | ||
250 | |||
251 | +int run_authenc(int fdc, struct test_params tp) | ||
252 | +{ | ||
253 | + struct session_op sess; | ||
254 | + char *mkeybuf = "\x00\x00\x00\x00\x00\x00\x00\x00" | ||
255 | + "\x00\x00\x00\x00\x00\x00\x00\x00" | ||
256 | + "\x00\x00\x00\x00"; | ||
257 | + char *ckeybuf = "\x06\xa9\x21\x40\x36\xb8\xa1\x5b" | ||
258 | + "\x51\x2e\x03\xd5\x34\x12\x00\x06"; | ||
259 | + | ||
260 | + memset(&sess, 0, sizeof(sess)); | ||
261 | + sess.cipher = CRYPTO_AUTHENC_HMAC_SHA1_CBC_AES; | ||
262 | + sess.keylen = 16; | ||
263 | + sess.key = (unsigned char *)ckeybuf; | ||
264 | + sess.mackeylen = 20; | ||
265 | + sess.mackey = (unsigned char *)mkeybuf; | ||
266 | + if (ioctl(fdc, CIOCGSESSION, &sess)) { | ||
267 | + perror("ioctl(CIOCGSESSION)"); | ||
268 | + return -EINVAL; | ||
269 | + } | ||
270 | + | ||
271 | + do_test_vectors(fdc, tp, &sess); | ||
272 | + return 0; | ||
273 | +} | ||
274 | + | ||
275 | int main(int argc, char **argv) | ||
276 | { | ||
277 | int err = 0; | ||
278 | @@ -487,6 +611,7 @@ int main(int argc, char **argv) | ||
279 | tp.nflag = false; | ||
280 | tp.mflag = false; | ||
281 | tp.aflag = false; | ||
282 | + tp.authflag = false; | ||
283 | alg_flag = false; | ||
284 | opterr = 0; | ||
285 | while ((c = getopt(argc, argv, "ahn:t:m")) != -1) { | ||
286 | -- | ||
287 | 2.10.2 | ||
288 | |||
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 @@ | |||
1 | From 3ca93181fbcaa0acac01588738eb50270cf4999a Mon Sep 17 00:00:00 2001 | ||
2 | From: Alexe Radu <radu.alexe@nxp.com> | ||
3 | Date: Fri, 9 Dec 2016 16:05:56 +0200 | ||
4 | Subject: [PATCH 100/104] close the session after every test | ||
5 | |||
6 | Signed-off-by: Alexe Radu <radu.alexe@nxp.com> | ||
7 | --- | ||
8 | tests/speed.c | 42 ++++++++++++++++++++++++++++++++++++++++++ | ||
9 | 1 file changed, 42 insertions(+) | ||
10 | |||
11 | diff --git a/tests/speed.c b/tests/speed.c | ||
12 | index 61259b9..99ef75b 100644 | ||
13 | --- a/tests/speed.c | ||
14 | +++ b/tests/speed.c | ||
15 | @@ -488,6 +488,12 @@ int run_null(int fdc, struct test_params tp) | ||
16 | } | ||
17 | |||
18 | do_test_vectors(fdc, tp, &sess); | ||
19 | + | ||
20 | + if (ioctl(fdc, CIOCFSESSION, &sess)) { | ||
21 | + perror("ioctl(CIOCFSESSION)"); | ||
22 | + return -EINVAL; | ||
23 | + } | ||
24 | + | ||
25 | return 0; | ||
26 | } | ||
27 | |||
28 | @@ -507,6 +513,12 @@ int run_aes_128_cbc(int fdc, struct test_params tp) | ||
29 | } | ||
30 | |||
31 | do_test_vectors(fdc, tp, &sess); | ||
32 | + | ||
33 | + if (ioctl(fdc, CIOCFSESSION, &sess)) { | ||
34 | + perror("ioctl(CIOCFSESSION)"); | ||
35 | + return -EINVAL; | ||
36 | + } | ||
37 | + | ||
38 | return 0; | ||
39 | } | ||
40 | |||
41 | @@ -526,6 +538,12 @@ int run_aes_256_xts(int fdc, struct test_params tp) | ||
42 | } | ||
43 | |||
44 | do_test_vectors(fdc, tp, &sess); | ||
45 | + | ||
46 | + if (ioctl(fdc, CIOCFSESSION, &sess)) { | ||
47 | + perror("ioctl(CIOCFSESSION)"); | ||
48 | + return -EINVAL; | ||
49 | + } | ||
50 | + | ||
51 | return 0; | ||
52 | } | ||
53 | |||
54 | @@ -541,6 +559,12 @@ int run_crc32c(int fdc, struct test_params tp) | ||
55 | } | ||
56 | |||
57 | do_test_vectors(fdc, tp, &sess); | ||
58 | + | ||
59 | + if (ioctl(fdc, CIOCFSESSION, &sess)) { | ||
60 | + perror("ioctl(CIOCFSESSION)"); | ||
61 | + return -EINVAL; | ||
62 | + } | ||
63 | + | ||
64 | return 0; | ||
65 | } | ||
66 | |||
67 | @@ -556,6 +580,12 @@ int run_sha1(int fdc, struct test_params tp) | ||
68 | } | ||
69 | |||
70 | do_test_vectors(fdc, tp, &sess); | ||
71 | + | ||
72 | + if (ioctl(fdc, CIOCFSESSION, &sess)) { | ||
73 | + perror("ioctl(CIOCFSESSION)"); | ||
74 | + return -EINVAL; | ||
75 | + } | ||
76 | + | ||
77 | return 0; | ||
78 | } | ||
79 | |||
80 | @@ -571,6 +601,12 @@ int run_sha256(int fdc, struct test_params tp) | ||
81 | } | ||
82 | |||
83 | do_test_vectors(fdc, tp, &sess); | ||
84 | + | ||
85 | + if (ioctl(fdc, CIOCFSESSION, &sess)) { | ||
86 | + perror("ioctl(CIOCFSESSION)"); | ||
87 | + return -EINVAL; | ||
88 | + } | ||
89 | + | ||
90 | return 0; | ||
91 | } | ||
92 | |||
93 | @@ -595,6 +631,12 @@ int run_authenc(int fdc, struct test_params tp) | ||
94 | } | ||
95 | |||
96 | do_test_vectors(fdc, tp, &sess); | ||
97 | + | ||
98 | + if (ioctl(fdc, CIOCFSESSION, &sess)) { | ||
99 | + perror("ioctl(CIOCFSESSION)"); | ||
100 | + return -EINVAL; | ||
101 | + } | ||
102 | + | ||
103 | return 0; | ||
104 | } | ||
105 | |||
106 | -- | ||
107 | 2.10.2 | ||
108 | |||
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 @@ | |||
1 | From d67b28fb68f1ea56fdf794f516816b6c3ef5649a Mon Sep 17 00:00:00 2001 | ||
2 | From: Radu Alexe <radu.alexe@nxp.com> | ||
3 | Date: Thu, 12 Jan 2017 19:44:57 +0200 | ||
4 | Subject: [PATCH 101/104] add support for rsa speed tests | ||
5 | |||
6 | Tests are only for rsa 1024 and 2048 and only sync variant. | ||
7 | |||
8 | Signed-off-by: Radu Alexe <radu.alexe@nxp.com> | ||
9 | --- | ||
10 | tests/speed.c | 138 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- | ||
11 | 1 file changed, 137 insertions(+), 1 deletion(-) | ||
12 | |||
13 | diff --git a/tests/speed.c b/tests/speed.c | ||
14 | index 99ef75b..b52938c 100644 | ||
15 | --- a/tests/speed.c | ||
16 | +++ b/tests/speed.c | ||
17 | @@ -63,8 +63,9 @@ int run_crc32c(int fdc, struct test_params tp); | ||
18 | int run_sha1(int fdc, struct test_params tp); | ||
19 | int run_sha256(int fdc, struct test_params tp); | ||
20 | int run_authenc(int fdc, struct test_params tp); | ||
21 | +int run_rsa(int fdc, struct test_params tp); | ||
22 | |||
23 | -#define ALG_COUNT 7 | ||
24 | +#define ALG_COUNT 8 | ||
25 | struct { | ||
26 | char *name; | ||
27 | int (*func)(int, struct test_params); | ||
28 | @@ -76,6 +77,7 @@ struct { | ||
29 | {"sha1", run_sha1}, | ||
30 | {"sha256", run_sha256}, | ||
31 | {"authenc", run_authenc}, | ||
32 | + {"rsa", run_rsa}, | ||
33 | }; | ||
34 | |||
35 | static double udifftimeval(struct timeval start, struct timeval end) | ||
36 | @@ -640,6 +642,140 @@ int run_authenc(int fdc, struct test_params tp) | ||
37 | return 0; | ||
38 | } | ||
39 | |||
40 | +char *n_2048 = "\xFA\xBE\x23\x01\x5D\x11\x50\xAA\xAB\xED\x50\xA7\x9B\x93\x7B\xCE" | ||
41 | + "\x1E\x11\xAE\xC1\x05\xAF\xBA\x57\x18\x6B\xE3\x27\x85\x3A\xFA\xB9" | ||
42 | + "\x15\x5A\x39\xB2\x38\x60\xB8\x5B\xDF\xD0\x8F\xA3\x37\xEE\xE5\xFD" | ||
43 | + "\xE2\x98\xF9\x40\xD2\x0A\xE9\x15\x69\x8A\x9D\xBC\x1F\x00\x0B\x95" | ||
44 | + "\x5A\x19\x14\x4C\x14\x19\x38\x47\x30\x96\x17\xCB\x28\x1C\x1C\x09" | ||
45 | + "\x14\x79\x55\x26\xAF\x6E\x38\x41\x91\x9D\xF5\x31\x6C\xFB\xCC\x68" | ||
46 | + "\x08\xA2\x60\xA2\xA4\xE0\x68\x59\x24\xF5\xEB\x57\x88\x5C\x3D\xA3" | ||
47 | + "\x41\x95\xFF\xD1\x03\xBA\xAE\x18\x55\x5D\xF4\x93\x57\x4D\x02\x11" | ||
48 | + "\x66\xD8\x44\xF8\x63\x9D\x70\xBE\x98\x93\x43\xE0\x1F\x80\x7A\xE1" | ||
49 | + "\x6D\xA0\x5D\xC3\xE5\x56\x1C\xDA\x96\x16\xB1\xD8\xBD\x62\x1E\x51" | ||
50 | + "\x28\xF7\x06\xB7\x6D\xB0\x5A\x5F\x09\x28\xEF\x9B\x33\xA3\x04\x02" | ||
51 | + "\x08\x4D\xD7\x2C\x22\x77\x3D\x9B\x2E\x45\xE7\x78\x5C\x64\x50\xF3" | ||
52 | + "\x5B\x98\x6E\x0F\xDE\xA6\xDC\x19\x4D\xFF\xAB\xBE\x6D\xC7\xB1\x55" | ||
53 | + "\x36\xDD\x40\x07\xEF\x78\xCC\xA1\x8D\x96\x6B\xDA\x48\x4C\x40\x29" | ||
54 | + "\x46\x7C\xF0\x1A\x6B\xC5\xBB\x8B\xD1\xB0\x6F\x9B\xB7\xC0\x06\xF5" | ||
55 | + "\x3B\x6F\x2B\x45\xEA\x17\x4C\x16\x2A\xC5\x5E\xB6\x1C\xCB\x3B\xFB"; | ||
56 | + | ||
57 | +char *f_2048 = "\x69\xeb\xb3\xb3\x68\xc1\xbf\x17\x57\x63\xca\xa2\x21\xee\x1f\x56" | ||
58 | + "\x8c\xee\x58\x96\x86\x86\x95\x44\xc7\xff\x75\xeb\xb4\xe8\xf6\x55" | ||
59 | + "\x20\xa0\xad\x62\x50\xe4\x83\x07\x31\xe9\x41\x03\xf3\x69\x9b\x9b" | ||
60 | + "\x0d\x68\xf3\x6e\x21\x02\x79\xc5\xa4\xd1\xe5\x11\x56\x9a\x2c\xb8" | ||
61 | + "\xf5\x76\xab\x04\x03\xcc\x6d\xa3\xf1\xa3\x6a\x57\xfd\x6e\x87\x82" | ||
62 | + "\xcf\x19\xf8\x0f\x97\x4d\x6e\xb5\xa0\x10\x27\x40\x12\x8b\x9f\x24" | ||
63 | + "\xb4\x4a\x95\xbe\x6a\x49\x49\x67\xb0\x8f\x77\x5f\x1d\x56\x22\xc6" | ||
64 | + "\x7d\xb3\x2f\x9e\x62\x4a\x0b\xf2\xca\x9e\xd1\x57\xf8\xf4\x25\x36" | ||
65 | + "\x54\xe9\x4a\xcd\x4d\x9b\x14\xd5\xe5\x35\x59\x6b\xf5\xd0\x50\x69" | ||
66 | + "\x5c\xde\x21\x32\xc9\x31\x8f\x21\x66\xda\x32\xb8\x45\x18\x18\x57" | ||
67 | + "\xb0\x37\xff\xea\xee\x7a\xd5\x01\x36\x72\xb3\xfb\x23\xe2\x5c\xa2" | ||
68 | + "\x10\xb9\xf3\x8b\xda\x37\x46\x7e\xac\xf5\x6c\xae\x18\x69\xbc\x9d" | ||
69 | + "\x6e\xd7\x61\x7c\x85\x63\x41\x5e\x8b\xab\x12\xbe\x37\x1a\x67\xdd" | ||
70 | + "\x86\xf2\xf9\xc8\x3a\xd7\xcd\x92\x72\xaf\xad\x46\xb0\x5b\x33\xd9" | ||
71 | + "\x1c\x32\x02\x3c\xae\xe0\x5d\x87\xde\x95\x59\x10\x4e\xa7\xdf\x7f" | ||
72 | + "\x94\x2d\xea\x9b\x7a\x53\x54\xc7\xf9\x66\xd1\x14\x0b\xd7\xef\x00"; | ||
73 | + | ||
74 | +char *n_1024 = "\xF8\x99\x5E\xC7\xED\x60\x4B\xBA\x77\x0A\x52\xD0\xFF\xE6\x45\x47" | ||
75 | + "\x04\xDE\xB3\x40\x16\x23\xB4\x58\x0A\xFF\xAF\x0D\x26\x1B\x5E\x0D" | ||
76 | + "\x61\xA2\x4A\x7B\x2E\x70\x2A\x54\x21\xCB\x01\x31\xBC\xBE\xAE\xC9" | ||
77 | + "\x5B\x3B\x20\x0B\x95\x06\x41\x03\xDB\xEF\x81\xE2\xFB\x42\xE8\x02" | ||
78 | + "\x1D\xD2\xA7\xFD\xC3\xA0\x3F\x74\x6D\x99\x8D\x60\xBA\x43\x82\x6C" | ||
79 | + "\x96\x24\x1D\xE5\xE3\x2C\xB7\x66\xAB\x2B\x4C\xFD\x23\xFF\xE0\x09" | ||
80 | + "\x17\x3E\x01\xCB\xDC\xB2\xD2\xA9\x98\x99\x01\x91\x16\xAB\x77\xD7" | ||
81 | + "\x97\x52\xBD\x49\xB2\xAF\x61\x95\xE8\xA2\x34\x9C\xC4\x00\xCC\x17"; | ||
82 | + | ||
83 | +char *f_1024 = "\x8f\x2d\x06\x83\xee\x08\x97\xa4\x86\x3a\xf2\xa3\xd1\x6d\x33\x10" | ||
84 | + "\x49\x1d\xb6\xd0\xe3\x7b\x16\x5a\x1a\x5c\x98\x36\xab\xd2\xa9\x82" | ||
85 | + "\x5c\x1b\xc1\x9e\xdc\x50\x45\x05\xe0\x2e\x14\x83\x86\x47\x21\xc5" | ||
86 | + "\x27\xad\xb1\x74\x5d\x7b\xe2\x92\xfc\x15\xf0\x14\x6c\x8d\x80\xe5" | ||
87 | + "\x85\x72\x26\xc7\xa3\xd8\xc7\x5a\x10\xcd\x64\xde\x5d\x82\xc1\x53" | ||
88 | + "\xd7\x2e\x03\xe0\xe2\xe6\xc6\x85\xcc\x07\x25\xa9\x61\xf7\x52\x3f" | ||
89 | + "\x63\xb1\x54\x6e\x23\xbe\xf0\x6c\xa4\x93\x8c\x39\xe2\xdb\xcb\x1c" | ||
90 | + "\x4b\x95\x3d\x57\x06\xc9\xce\x44\xe5\xaf\xac\x6b\x67\xdb\x92\x00"; | ||
91 | + | ||
92 | +int run_rsa(int fdc, struct test_params tp) | ||
93 | +{ | ||
94 | + struct timeval start, end; | ||
95 | + double secs, ddata, dspeed; | ||
96 | + uint64_t total = 0; | ||
97 | + char metric[16]; | ||
98 | + struct crypt_kop kop; | ||
99 | + char *n, *f; | ||
100 | + char *e = "\x01\x00\x01"; | ||
101 | + char g[256]; | ||
102 | + | ||
103 | + if (!tp.nflag) | ||
104 | + tp.nvalue = 2048; | ||
105 | + | ||
106 | + switch (tp.nvalue) { | ||
107 | + case 2048: | ||
108 | + n = n_2048; | ||
109 | + f = f_2048; | ||
110 | + break; | ||
111 | + | ||
112 | + case 1024: | ||
113 | + n = n_1024; | ||
114 | + f = f_1024; | ||
115 | + break; | ||
116 | + | ||
117 | + default: | ||
118 | + if (!tp.mflag) { | ||
119 | + printf("Error: rsa-%d not supported\n", tp.nvalue); | ||
120 | + fflush(stdout); | ||
121 | + } | ||
122 | + | ||
123 | + return 1; | ||
124 | + } | ||
125 | + | ||
126 | + kop.crk_op = CRK_MOD_EXP; | ||
127 | + kop.crk_iparams = 3; | ||
128 | + kop.crk_oparams = 1; | ||
129 | + | ||
130 | + kop.crk_param[0].crp_p = (__u8*)f; | ||
131 | + kop.crk_param[0].crp_nbits = tp.nvalue; | ||
132 | + | ||
133 | + kop.crk_param[1].crp_p = (__u8*)e; | ||
134 | + kop.crk_param[1].crp_nbits = 24; | ||
135 | + | ||
136 | + kop.crk_param[2].crp_p = (__u8*)n; | ||
137 | + kop.crk_param[2].crp_nbits = tp.nvalue; | ||
138 | + | ||
139 | + kop.crk_param[3].crp_p = (__u8*)g; | ||
140 | + kop.crk_param[3].crp_nbits = sizeof(g) << 3; | ||
141 | + | ||
142 | + if (!tp.mflag) { | ||
143 | + printf("\trsa %d: ", tp.nvalue); | ||
144 | + fflush(stdout); | ||
145 | + } | ||
146 | + | ||
147 | + must_finish = 0; | ||
148 | + alarm(tp.tvalue); | ||
149 | + | ||
150 | + gettimeofday(&start, NULL); | ||
151 | + do { | ||
152 | + if (ioctl(fdc, CIOCKEY, &kop)) { | ||
153 | + perror("ioctl(CIOCKEY)"); | ||
154 | + return -EINVAL; | ||
155 | + } | ||
156 | + total += (tp.nvalue >> 3); | ||
157 | + } while (!must_finish); | ||
158 | + gettimeofday(&end, NULL); | ||
159 | + | ||
160 | + secs = udifftimeval(start, end)/ 1000000.0; | ||
161 | + | ||
162 | + if (tp.mflag) { | ||
163 | + value2machine(total, secs, &dspeed); | ||
164 | + printf("%" PRIu64 "\t%.2f\t%.2f\n", total, secs, dspeed); | ||
165 | + } else { | ||
166 | + value2human(total, secs, &ddata, &dspeed, metric); | ||
167 | + printf ("done. %.2f %s in %.2f secs: ", ddata, metric, secs); | ||
168 | + printf ("%.2f %s/sec\n", dspeed, metric); | ||
169 | + } | ||
170 | + | ||
171 | + return 0; | ||
172 | +} | ||
173 | + | ||
174 | int main(int argc, char **argv) | ||
175 | { | ||
176 | int err = 0; | ||
177 | -- | ||
178 | 2.10.2 | ||
179 | |||
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 @@ | |||
1 | From 008516c6a1dd0afe0eadff3ad00c1200c198983f Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Wed, 8 Feb 2017 10:19:34 +0200 | ||
4 | Subject: [PATCH 102/104] adjust to API changes in kernel >=4.10 | ||
5 | |||
6 | There are many changes related to get_user_pages and the code is rewritten | ||
7 | for clarity. | ||
8 | |||
9 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
10 | --- | ||
11 | zc.c | 28 +++++++++++++++++----------- | ||
12 | 1 file changed, 17 insertions(+), 11 deletions(-) | ||
13 | |||
14 | diff --git a/zc.c b/zc.c | ||
15 | index e766ee3..2f4ea99 100644 | ||
16 | --- a/zc.c | ||
17 | +++ b/zc.c | ||
18 | @@ -59,19 +59,25 @@ int __get_userbuf(uint8_t __user *addr, uint32_t len, int write, | ||
19 | } | ||
20 | |||
21 | down_read(&mm->mmap_sem); | ||
22 | -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)) | ||
23 | - ret = get_user_pages_remote( | ||
24 | +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)) | ||
25 | + ret = get_user_pages(task, mm, | ||
26 | + (unsigned long)addr, pgcount, write, 0, pg, NULL); | ||
27 | #else | ||
28 | - ret = get_user_pages( | ||
29 | -#endif | ||
30 | - task, mm, | ||
31 | - (unsigned long)addr, pgcount, | ||
32 | -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)) | ||
33 | - write ? FOLL_WRITE : 0, | ||
34 | -#else | ||
35 | - write, 0, | ||
36 | -#endif | ||
37 | +# if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)) | ||
38 | + ret = get_user_pages_remote(task, mm, | ||
39 | + (unsigned long)addr, pgcount, write, 0, pg, NULL); | ||
40 | +# else | ||
41 | +# if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)) | ||
42 | + ret = get_user_pages_remote(task, mm, | ||
43 | + (unsigned long)addr, pgcount, write ? FOLL_WRITE : 0, | ||
44 | pg, NULL); | ||
45 | +# else | ||
46 | + ret = get_user_pages_remote(task, mm, | ||
47 | + (unsigned long)addr, pgcount, write ? FOLL_WRITE : 0, | ||
48 | + pg, NULL, NULL); | ||
49 | +# endif | ||
50 | +# endif | ||
51 | +#endif | ||
52 | up_read(&mm->mmap_sem); | ||
53 | if (ret != pgcount) | ||
54 | return -EINVAL; | ||
55 | -- | ||
56 | 2.10.2 | ||
57 | |||
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 @@ | |||
1 | From e2fa367d968926500584912e98cf7b17bd9487a6 Mon Sep 17 00:00:00 2001 | ||
2 | From: Phil Sutter <phil@nwl.cc> | ||
3 | Date: Thu, 9 Feb 2017 11:40:46 +0100 | ||
4 | Subject: [PATCH 103/104] zc: Use the power of #elif | ||
5 | |||
6 | While here, get rid of that trailing newline as well. | ||
7 | |||
8 | Fixes: 2b29be8ac4141 ("adjust to API changes in kernel >=4.10") | ||
9 | Suggested-by: Frediano Ziglio <freddy77@gmail.com> | ||
10 | Signed-off-by: Phil Sutter <phil@nwl.cc> | ||
11 | --- | ||
12 | zc.c | 11 +++-------- | ||
13 | 1 file changed, 3 insertions(+), 8 deletions(-) | ||
14 | |||
15 | diff --git a/zc.c b/zc.c | ||
16 | index 2f4ea99..ae464ff 100644 | ||
17 | --- a/zc.c | ||
18 | +++ b/zc.c | ||
19 | @@ -62,21 +62,17 @@ int __get_userbuf(uint8_t __user *addr, uint32_t len, int write, | ||
20 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)) | ||
21 | ret = get_user_pages(task, mm, | ||
22 | (unsigned long)addr, pgcount, write, 0, pg, NULL); | ||
23 | -#else | ||
24 | -# if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)) | ||
25 | +#elif (LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)) | ||
26 | ret = get_user_pages_remote(task, mm, | ||
27 | (unsigned long)addr, pgcount, write, 0, pg, NULL); | ||
28 | -# else | ||
29 | -# if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)) | ||
30 | +#elif (LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)) | ||
31 | ret = get_user_pages_remote(task, mm, | ||
32 | (unsigned long)addr, pgcount, write ? FOLL_WRITE : 0, | ||
33 | pg, NULL); | ||
34 | -# else | ||
35 | +#else | ||
36 | ret = get_user_pages_remote(task, mm, | ||
37 | (unsigned long)addr, pgcount, write ? FOLL_WRITE : 0, | ||
38 | pg, NULL, NULL); | ||
39 | -# endif | ||
40 | -# endif | ||
41 | #endif | ||
42 | up_read(&mm->mmap_sem); | ||
43 | if (ret != pgcount) | ||
44 | @@ -222,4 +218,3 @@ int get_userbuf(struct csession *ses, | ||
45 | } | ||
46 | return 0; | ||
47 | } | ||
48 | - | ||
49 | -- | ||
50 | 2.10.2 | ||
51 | |||
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 @@ | |||
1 | From a4b33ea30c86fb727c1d3ac3531c5548b6c194ba Mon Sep 17 00:00:00 2001 | ||
2 | From: Radu Alexe <radu.alexe@nxp.com> | ||
3 | Date: Tue, 14 Feb 2017 12:52:33 +0200 | ||
4 | Subject: [PATCH 104/104] fix: reset finish condition before test start | ||
5 | |||
6 | Typo from previous commit: ba494703 | ||
7 | "add support for authenc(hmac(sha1), cbc(aes)) speed tests" | ||
8 | |||
9 | Signed-off-by: Radu Alexe <radu.alexe@nxp.com> | ||
10 | --- | ||
11 | tests/speed.c | 2 +- | ||
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
13 | |||
14 | diff --git a/tests/speed.c b/tests/speed.c | ||
15 | index b52938c..ae0b658 100644 | ||
16 | --- a/tests/speed.c | ||
17 | +++ b/tests/speed.c | ||
18 | @@ -276,7 +276,7 @@ static int encrypt_sync(int fdc, struct test_params tp, struct session_op *sess) | ||
19 | } | ||
20 | memset(buffer, val++, tp.nvalue); | ||
21 | |||
22 | - must_finish = 1; | ||
23 | + must_finish = 0; | ||
24 | alarm(tp.tvalue); | ||
25 | |||
26 | gettimeofday(&start, NULL); | ||
27 | -- | ||
28 | 2.10.2 | ||
29 | |||
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 @@ | |||
1 | From 6c2b61c17681d0e6ddc44b0438c9712fb2810ba6 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Tue, 28 Mar 2017 13:16:14 +0300 | ||
4 | Subject: [PATCH] update copyright notes | ||
5 | |||
6 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
7 | --- | ||
8 | tests/run_crypto_tests.sh | 16 ++++++++++++++++ | ||
9 | tests/sha_speed.c | 1 + | ||
10 | tests/speed.c | 1 + | ||
11 | zc.c | 1 + | ||
12 | 4 files changed, 19 insertions(+) | ||
13 | |||
14 | diff --git a/tests/run_crypto_tests.sh b/tests/run_crypto_tests.sh | ||
15 | index 321b013..225ad7a 100644 | ||
16 | --- a/tests/run_crypto_tests.sh | ||
17 | +++ b/tests/run_crypto_tests.sh | ||
18 | @@ -1,4 +1,20 @@ | ||
19 | #!/bin/bash | ||
20 | +# | ||
21 | +# Copyright 2016 NXP Semiconductors | ||
22 | +# | ||
23 | +# This program is free software: you can redistribute it and/or modify | ||
24 | +# it under the terms of the GNU General Public License as published by | ||
25 | +# the Free Software Foundation, either version 2 of the License, or | ||
26 | +# (at your option) any later version. | ||
27 | +# | ||
28 | +# This program is distributed in the hope that it will be useful, | ||
29 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
30 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
31 | +# GNU General Public License for more details. | ||
32 | +# | ||
33 | +# You should have received a copy of the GNU General Public License | ||
34 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
35 | + | ||
36 | |||
37 | |||
38 | BUF_SIZE="8192 16384 65536 131072 262144" | ||
39 | diff --git a/tests/sha_speed.c b/tests/sha_speed.c | ||
40 | index 30b40f5..e6a2ac5 100644 | ||
41 | --- a/tests/sha_speed.c | ||
42 | +++ b/tests/sha_speed.c | ||
43 | @@ -1,6 +1,7 @@ | ||
44 | /* sha_speed - simple SHA benchmark tool for cryptodev | ||
45 | * | ||
46 | * Copyright (C) 2011 by Phil Sutter <phil.sutter@viprinet.com> | ||
47 | + * Copyright 2016 NXP | ||
48 | * | ||
49 | * This program is free software; you can redistribute it and/or modify | ||
50 | * it under the terms of the GNU General Public License as published by | ||
51 | diff --git a/tests/speed.c b/tests/speed.c | ||
52 | index ae0b658..6e18960 100644 | ||
53 | --- a/tests/speed.c | ||
54 | +++ b/tests/speed.c | ||
55 | @@ -1,6 +1,7 @@ | ||
56 | /* cryptodev_test - simple benchmark tool for cryptodev | ||
57 | * | ||
58 | * Copyright (C) 2010 by Phil Sutter <phil.sutter@viprinet.com> | ||
59 | + * Copyright 2016-2017 NXP | ||
60 | * | ||
61 | * This program is free software; you can redistribute it and/or modify | ||
62 | * it under the terms of the GNU General Public License as published by | ||
63 | diff --git a/zc.c b/zc.c | ||
64 | index ae464ff..63e7c23 100644 | ||
65 | --- a/zc.c | ||
66 | +++ b/zc.c | ||
67 | @@ -4,6 +4,7 @@ | ||
68 | * Copyright (c) 2009-2013 Nikos Mavrogiannopoulos <nmav@gnutls.org> | ||
69 | * Copyright (c) 2010 Phil Sutter | ||
70 | * Copyright (c) 2011, 2012 OpenSSL Software Foundation, Inc. | ||
71 | + * Copyright 2017 NXP | ||
72 | * | ||
73 | * This file is part of linux cryptodev. | ||
74 | * | ||
75 | -- | ||
76 | 1.9.2 | ||
77 | |||