octeon: get rid of /lib/functions/octeon.sh hackery, use sysinfo directly
[openwrt/openwrt.git] / target / linux / mxs / patches-4.4 / 100-crypto-mxsdcp-provide-importexport.patch
1 From: Fabio Estevam <fabio.estevam@nxp.com>
2
3 Currently the mxs-dcp driver fails to probe:
4
5 mxs-dcp 80028000.dcp: Failed to register sha1 hash!
6 mxs-dcp: probe of 80028000.dcp failed with error -22
7
8 This happens since commit 8996eafdcbad ("crypto: ahash - ensure statesize
9 is non-zero"), which requires statesize to be filled.
10
11 Other than filling statesize, we also need to provide the import/export
12 functions.
13
14 Based on the implementation of the sahara and caam drivers.
15
16 Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
17 ---
18 Changes since v2:
19 - Newly introduced in this series
20
21 drivers/crypto/mxs-dcp.c | 24 ++++++++++++++++++++++++
22 1 file changed, 24 insertions(+)
23
24 diff --git a/drivers/crypto/mxs-dcp.c b/drivers/crypto/mxs-dcp.c
25 index 59ed54e..1e2017f 100644
26 --- a/drivers/crypto/mxs-dcp.c
27 +++ b/drivers/crypto/mxs-dcp.c
28 @@ -775,6 +775,24 @@ static void dcp_sha_cra_exit(struct crypto_tfm *tfm)
29 {
30 }
31
32 +static int dcp_sha_export(struct ahash_request *req, void *out)
33 +{
34 + struct dcp_sha_req_ctx *rctx = ahash_request_ctx(req);
35 +
36 + memcpy(out, rctx, sizeof(struct dcp_sha_req_ctx));
37 +
38 + return 0;
39 +}
40 +
41 +static int dcp_sha_import(struct ahash_request *req, const void *in)
42 +{
43 + struct dcp_sha_req_ctx *rctx = ahash_request_ctx(req);
44 +
45 + memcpy(rctx, in, sizeof(struct dcp_sha_req_ctx));
46 +
47 + return 0;
48 +}
49 +
50 /* AES 128 ECB and AES 128 CBC */
51 static struct crypto_alg dcp_aes_algs[] = {
52 {
53 @@ -834,8 +852,11 @@ static struct ahash_alg dcp_sha1_alg = {
54 .final = dcp_sha_final,
55 .finup = dcp_sha_finup,
56 .digest = dcp_sha_digest,
57 + .import = dcp_sha_import,
58 + .export = dcp_sha_export,
59 .halg = {
60 .digestsize = SHA1_DIGEST_SIZE,
61 + .statesize = sizeof(struct dcp_sha_req_ctx),
62 .base = {
63 .cra_name = "sha1",
64 .cra_driver_name = "sha1-dcp",
65 @@ -858,8 +879,11 @@ static struct ahash_alg dcp_sha256_alg = {
66 .final = dcp_sha_final,
67 .finup = dcp_sha_finup,
68 .digest = dcp_sha_digest,
69 + .import = dcp_sha_import,
70 + .export = dcp_sha_export,
71 .halg = {
72 .digestsize = SHA256_DIGEST_SIZE,
73 + .statesize = sizeof(struct dcp_sha_req_ctx),
74 .base = {
75 .cra_name = "sha256",
76 .cra_driver_name = "sha256-dcp",
77 --
78 1.9.1
79
80 --