3be3e1a111e428f96f4ace21fc68bfff4b93114c
[oweals/openwrt.git] / target / linux / mxs / patches-4.14 / 110-crypto-mxsdcp-provide-importexport.patch
1 --- a/drivers/crypto/mxs-dcp.c
2 +++ b/drivers/crypto/mxs-dcp.c
3 @@ -777,6 +777,24 @@ static void dcp_sha_cra_exit(struct cryp
4  {
5  }
6  
7 +static int dcp_sha_export(struct ahash_request *req, void *out)
8 +{
9 +       struct dcp_sha_req_ctx *rctx = ahash_request_ctx(req);
10 +
11 +       memcpy(out, rctx, sizeof(struct dcp_sha_req_ctx));
12 +
13 +       return 0;
14 +}
15 +
16 +static int dcp_sha_import(struct ahash_request *req, const void *in)
17 +{
18 +       struct dcp_sha_req_ctx *rctx = ahash_request_ctx(req);
19 +
20 +       memcpy(rctx, in, sizeof(struct dcp_sha_req_ctx));
21 +
22 +       return 0;
23 +}
24 +
25  /* AES 128 ECB and AES 128 CBC */
26  static struct crypto_alg dcp_aes_algs[] = {
27         {
28 @@ -836,8 +854,11 @@ static struct ahash_alg dcp_sha1_alg = {
29         .final  = dcp_sha_final,
30         .finup  = dcp_sha_finup,
31         .digest = dcp_sha_digest,
32 +       .import = dcp_sha_import,
33 +       .export = dcp_sha_export,
34         .halg   = {
35                 .digestsize     = SHA1_DIGEST_SIZE,
36 +               .statesize      = sizeof(struct dcp_sha_req_ctx),
37                 .base           = {
38                         .cra_name               = "sha1",
39                         .cra_driver_name        = "sha1-dcp",
40 @@ -860,8 +881,11 @@ static struct ahash_alg dcp_sha256_alg =
41         .final  = dcp_sha_final,
42         .finup  = dcp_sha_finup,
43         .digest = dcp_sha_digest,
44 +       .import = dcp_sha_import,
45 +       .export = dcp_sha_export,
46         .halg   = {
47                 .digestsize     = SHA256_DIGEST_SIZE,
48 +               .statesize      = sizeof(struct dcp_sha_req_ctx),
49                 .base           = {
50                         .cra_name               = "sha256",
51                         .cra_driver_name        = "sha256-dcp",