diff options
| author | Cristian Stoica <cristian.stoica@nxp.com> | 2016-01-25 11:19:43 +0200 |
|---|---|---|
| committer | Otavio Salvador <otavio@ossystems.com.br> | 2016-08-12 11:41:02 -0300 |
| commit | b8e3085e4e9608b301121c7065c84a3e51b94c74 (patch) | |
| tree | 27dd6761bb8a8b9a3ce311bab1155a15badaec5e /recipes-kernel/cryptodev/files/0008-Add-RSA-Key-generation-offloading.patch | |
| parent | 578ab5d071729c9677d928467a2b48bcb0017139 (diff) | |
| download | meta-freescale-b8e3085e4e9608b301121c7065c84a3e51b94c74.tar.gz | |
cryptodev-qoriq: upgrade to 1.8 plus fsl patches
upstream commit: 87b56e04b24c6d4be145483477eff7d3153290e9
Also:
- move all fsl patches on top of cryptodev-1.8
- add CIOCHASH ioctl
- fix incorrect tests initializations
- modify yocto patches to match updated Makefiles
Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com>
Diffstat (limited to 'recipes-kernel/cryptodev/files/0008-Add-RSA-Key-generation-offloading.patch')
| -rw-r--r-- | recipes-kernel/cryptodev/files/0008-Add-RSA-Key-generation-offloading.patch | 170 |
1 files changed, 0 insertions, 170 deletions
diff --git a/recipes-kernel/cryptodev/files/0008-Add-RSA-Key-generation-offloading.patch b/recipes-kernel/cryptodev/files/0008-Add-RSA-Key-generation-offloading.patch deleted file mode 100644 index d251c660e..000000000 --- a/recipes-kernel/cryptodev/files/0008-Add-RSA-Key-generation-offloading.patch +++ /dev/null | |||
| @@ -1,170 +0,0 @@ | |||
| 1 | From 5127db3483a2e4f6dc13330bea7237931c5f15a0 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/15] 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.3.5 | ||
| 170 | |||
