Commit d5e6b48f authored by Herbert Xu's avatar Herbert Xu

crypto: stm32 - Use new crypto_engine_op interface

Use the new crypto_engine_op interface where the callback is stored
in the algorithm object.
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 982213e4
...@@ -5,22 +5,24 @@ ...@@ -5,22 +5,24 @@
* Ux500 support taken from snippets in the old Ux500 cryp driver * Ux500 support taken from snippets in the old Ux500 cryp driver
*/ */
#include <crypto/aes.h>
#include <crypto/engine.h>
#include <crypto/internal/aead.h>
#include <crypto/internal/des.h>
#include <crypto/internal/skcipher.h>
#include <crypto/scatterwalk.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/interrupt.h> #include <linux/err.h>
#include <linux/iopoll.h> #include <linux/iopoll.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/reset.h> #include <linux/reset.h>
#include <linux/string.h>
#include <crypto/aes.h>
#include <crypto/internal/des.h>
#include <crypto/engine.h>
#include <crypto/scatterwalk.h>
#include <crypto/internal/aead.h>
#include <crypto/internal/skcipher.h>
#define DRIVER_NAME "stm32-cryp" #define DRIVER_NAME "stm32-cryp"
...@@ -156,7 +158,6 @@ struct stm32_cryp_caps { ...@@ -156,7 +158,6 @@ struct stm32_cryp_caps {
}; };
struct stm32_cryp_ctx { struct stm32_cryp_ctx {
struct crypto_engine_ctx enginectx;
struct stm32_cryp *cryp; struct stm32_cryp *cryp;
int keylen; int keylen;
__be32 key[AES_KEYSIZE_256 / sizeof(u32)]; __be32 key[AES_KEYSIZE_256 / sizeof(u32)];
...@@ -828,11 +829,8 @@ static int stm32_cryp_cipher_one_req(struct crypto_engine *engine, void *areq); ...@@ -828,11 +829,8 @@ static int stm32_cryp_cipher_one_req(struct crypto_engine *engine, void *areq);
static int stm32_cryp_init_tfm(struct crypto_skcipher *tfm) static int stm32_cryp_init_tfm(struct crypto_skcipher *tfm)
{ {
struct stm32_cryp_ctx *ctx = crypto_skcipher_ctx(tfm);
crypto_skcipher_set_reqsize(tfm, sizeof(struct stm32_cryp_reqctx)); crypto_skcipher_set_reqsize(tfm, sizeof(struct stm32_cryp_reqctx));
ctx->enginectx.op.do_one_request = stm32_cryp_cipher_one_req;
return 0; return 0;
} }
...@@ -840,12 +838,8 @@ static int stm32_cryp_aead_one_req(struct crypto_engine *engine, void *areq); ...@@ -840,12 +838,8 @@ static int stm32_cryp_aead_one_req(struct crypto_engine *engine, void *areq);
static int stm32_cryp_aes_aead_init(struct crypto_aead *tfm) static int stm32_cryp_aes_aead_init(struct crypto_aead *tfm)
{ {
struct stm32_cryp_ctx *ctx = crypto_aead_ctx(tfm);
tfm->reqsize = sizeof(struct stm32_cryp_reqctx); tfm->reqsize = sizeof(struct stm32_cryp_reqctx);
ctx->enginectx.op.do_one_request = stm32_cryp_aead_one_req;
return 0; return 0;
} }
...@@ -1686,8 +1680,9 @@ static irqreturn_t stm32_cryp_irq(int irq, void *arg) ...@@ -1686,8 +1680,9 @@ static irqreturn_t stm32_cryp_irq(int irq, void *arg)
return IRQ_WAKE_THREAD; return IRQ_WAKE_THREAD;
} }
static struct skcipher_alg crypto_algs[] = { static struct skcipher_engine_alg crypto_algs[] = {
{ {
.base = {
.base.cra_name = "ecb(aes)", .base.cra_name = "ecb(aes)",
.base.cra_driver_name = "stm32-ecb-aes", .base.cra_driver_name = "stm32-ecb-aes",
.base.cra_priority = 200, .base.cra_priority = 200,
...@@ -1703,8 +1698,13 @@ static struct skcipher_alg crypto_algs[] = { ...@@ -1703,8 +1698,13 @@ static struct skcipher_alg crypto_algs[] = {
.setkey = stm32_cryp_aes_setkey, .setkey = stm32_cryp_aes_setkey,
.encrypt = stm32_cryp_aes_ecb_encrypt, .encrypt = stm32_cryp_aes_ecb_encrypt,
.decrypt = stm32_cryp_aes_ecb_decrypt, .decrypt = stm32_cryp_aes_ecb_decrypt,
},
.op = {
.do_one_request = stm32_cryp_cipher_one_req,
},
}, },
{ {
.base = {
.base.cra_name = "cbc(aes)", .base.cra_name = "cbc(aes)",
.base.cra_driver_name = "stm32-cbc-aes", .base.cra_driver_name = "stm32-cbc-aes",
.base.cra_priority = 200, .base.cra_priority = 200,
...@@ -1721,8 +1721,13 @@ static struct skcipher_alg crypto_algs[] = { ...@@ -1721,8 +1721,13 @@ static struct skcipher_alg crypto_algs[] = {
.setkey = stm32_cryp_aes_setkey, .setkey = stm32_cryp_aes_setkey,
.encrypt = stm32_cryp_aes_cbc_encrypt, .encrypt = stm32_cryp_aes_cbc_encrypt,
.decrypt = stm32_cryp_aes_cbc_decrypt, .decrypt = stm32_cryp_aes_cbc_decrypt,
},
.op = {
.do_one_request = stm32_cryp_cipher_one_req,
},
}, },
{ {
.base = {
.base.cra_name = "ctr(aes)", .base.cra_name = "ctr(aes)",
.base.cra_driver_name = "stm32-ctr-aes", .base.cra_driver_name = "stm32-ctr-aes",
.base.cra_priority = 200, .base.cra_priority = 200,
...@@ -1739,8 +1744,13 @@ static struct skcipher_alg crypto_algs[] = { ...@@ -1739,8 +1744,13 @@ static struct skcipher_alg crypto_algs[] = {
.setkey = stm32_cryp_aes_setkey, .setkey = stm32_cryp_aes_setkey,
.encrypt = stm32_cryp_aes_ctr_encrypt, .encrypt = stm32_cryp_aes_ctr_encrypt,
.decrypt = stm32_cryp_aes_ctr_decrypt, .decrypt = stm32_cryp_aes_ctr_decrypt,
},
.op = {
.do_one_request = stm32_cryp_cipher_one_req,
},
}, },
{ {
.base = {
.base.cra_name = "ecb(des)", .base.cra_name = "ecb(des)",
.base.cra_driver_name = "stm32-ecb-des", .base.cra_driver_name = "stm32-ecb-des",
.base.cra_priority = 200, .base.cra_priority = 200,
...@@ -1756,8 +1766,13 @@ static struct skcipher_alg crypto_algs[] = { ...@@ -1756,8 +1766,13 @@ static struct skcipher_alg crypto_algs[] = {
.setkey = stm32_cryp_des_setkey, .setkey = stm32_cryp_des_setkey,
.encrypt = stm32_cryp_des_ecb_encrypt, .encrypt = stm32_cryp_des_ecb_encrypt,
.decrypt = stm32_cryp_des_ecb_decrypt, .decrypt = stm32_cryp_des_ecb_decrypt,
},
.op = {
.do_one_request = stm32_cryp_cipher_one_req,
},
}, },
{ {
.base = {
.base.cra_name = "cbc(des)", .base.cra_name = "cbc(des)",
.base.cra_driver_name = "stm32-cbc-des", .base.cra_driver_name = "stm32-cbc-des",
.base.cra_priority = 200, .base.cra_priority = 200,
...@@ -1774,8 +1789,13 @@ static struct skcipher_alg crypto_algs[] = { ...@@ -1774,8 +1789,13 @@ static struct skcipher_alg crypto_algs[] = {
.setkey = stm32_cryp_des_setkey, .setkey = stm32_cryp_des_setkey,
.encrypt = stm32_cryp_des_cbc_encrypt, .encrypt = stm32_cryp_des_cbc_encrypt,
.decrypt = stm32_cryp_des_cbc_decrypt, .decrypt = stm32_cryp_des_cbc_decrypt,
},
.op = {
.do_one_request = stm32_cryp_cipher_one_req,
},
}, },
{ {
.base = {
.base.cra_name = "ecb(des3_ede)", .base.cra_name = "ecb(des3_ede)",
.base.cra_driver_name = "stm32-ecb-des3", .base.cra_driver_name = "stm32-ecb-des3",
.base.cra_priority = 200, .base.cra_priority = 200,
...@@ -1791,8 +1811,13 @@ static struct skcipher_alg crypto_algs[] = { ...@@ -1791,8 +1811,13 @@ static struct skcipher_alg crypto_algs[] = {
.setkey = stm32_cryp_tdes_setkey, .setkey = stm32_cryp_tdes_setkey,
.encrypt = stm32_cryp_tdes_ecb_encrypt, .encrypt = stm32_cryp_tdes_ecb_encrypt,
.decrypt = stm32_cryp_tdes_ecb_decrypt, .decrypt = stm32_cryp_tdes_ecb_decrypt,
},
.op = {
.do_one_request = stm32_cryp_cipher_one_req,
},
}, },
{ {
.base = {
.base.cra_name = "cbc(des3_ede)", .base.cra_name = "cbc(des3_ede)",
.base.cra_driver_name = "stm32-cbc-des3", .base.cra_driver_name = "stm32-cbc-des3",
.base.cra_priority = 200, .base.cra_priority = 200,
...@@ -1809,20 +1834,24 @@ static struct skcipher_alg crypto_algs[] = { ...@@ -1809,20 +1834,24 @@ static struct skcipher_alg crypto_algs[] = {
.setkey = stm32_cryp_tdes_setkey, .setkey = stm32_cryp_tdes_setkey,
.encrypt = stm32_cryp_tdes_cbc_encrypt, .encrypt = stm32_cryp_tdes_cbc_encrypt,
.decrypt = stm32_cryp_tdes_cbc_decrypt, .decrypt = stm32_cryp_tdes_cbc_decrypt,
},
.op = {
.do_one_request = stm32_cryp_cipher_one_req,
},
}, },
}; };
static struct aead_alg aead_algs[] = { static struct aead_engine_alg aead_algs[] = {
{ {
.setkey = stm32_cryp_aes_aead_setkey, .base.setkey = stm32_cryp_aes_aead_setkey,
.setauthsize = stm32_cryp_aes_gcm_setauthsize, .base.setauthsize = stm32_cryp_aes_gcm_setauthsize,
.encrypt = stm32_cryp_aes_gcm_encrypt, .base.encrypt = stm32_cryp_aes_gcm_encrypt,
.decrypt = stm32_cryp_aes_gcm_decrypt, .base.decrypt = stm32_cryp_aes_gcm_decrypt,
.init = stm32_cryp_aes_aead_init, .base.init = stm32_cryp_aes_aead_init,
.ivsize = 12, .base.ivsize = 12,
.maxauthsize = AES_BLOCK_SIZE, .base.maxauthsize = AES_BLOCK_SIZE,
.base = { .base.base = {
.cra_name = "gcm(aes)", .cra_name = "gcm(aes)",
.cra_driver_name = "stm32-gcm-aes", .cra_driver_name = "stm32-gcm-aes",
.cra_priority = 200, .cra_priority = 200,
...@@ -1832,17 +1861,20 @@ static struct aead_alg aead_algs[] = { ...@@ -1832,17 +1861,20 @@ static struct aead_alg aead_algs[] = {
.cra_alignmask = 0, .cra_alignmask = 0,
.cra_module = THIS_MODULE, .cra_module = THIS_MODULE,
}, },
.op = {
.do_one_request = stm32_cryp_aead_one_req,
},
}, },
{ {
.setkey = stm32_cryp_aes_aead_setkey, .base.setkey = stm32_cryp_aes_aead_setkey,
.setauthsize = stm32_cryp_aes_ccm_setauthsize, .base.setauthsize = stm32_cryp_aes_ccm_setauthsize,
.encrypt = stm32_cryp_aes_ccm_encrypt, .base.encrypt = stm32_cryp_aes_ccm_encrypt,
.decrypt = stm32_cryp_aes_ccm_decrypt, .base.decrypt = stm32_cryp_aes_ccm_decrypt,
.init = stm32_cryp_aes_aead_init, .base.init = stm32_cryp_aes_aead_init,
.ivsize = AES_BLOCK_SIZE, .base.ivsize = AES_BLOCK_SIZE,
.maxauthsize = AES_BLOCK_SIZE, .base.maxauthsize = AES_BLOCK_SIZE,
.base = { .base.base = {
.cra_name = "ccm(aes)", .cra_name = "ccm(aes)",
.cra_driver_name = "stm32-ccm-aes", .cra_driver_name = "stm32-ccm-aes",
.cra_priority = 200, .cra_priority = 200,
...@@ -1852,6 +1884,9 @@ static struct aead_alg aead_algs[] = { ...@@ -1852,6 +1884,9 @@ static struct aead_alg aead_algs[] = {
.cra_alignmask = 0, .cra_alignmask = 0,
.cra_module = THIS_MODULE, .cra_module = THIS_MODULE,
}, },
.op = {
.do_one_request = stm32_cryp_aead_one_req,
},
}, },
}; };
...@@ -2013,14 +2048,14 @@ static int stm32_cryp_probe(struct platform_device *pdev) ...@@ -2013,14 +2048,14 @@ static int stm32_cryp_probe(struct platform_device *pdev)
goto err_engine2; goto err_engine2;
} }
ret = crypto_register_skciphers(crypto_algs, ARRAY_SIZE(crypto_algs)); ret = crypto_engine_register_skciphers(crypto_algs, ARRAY_SIZE(crypto_algs));
if (ret) { if (ret) {
dev_err(dev, "Could not register algs\n"); dev_err(dev, "Could not register algs\n");
goto err_algs; goto err_algs;
} }
if (cryp->caps->aeads_support) { if (cryp->caps->aeads_support) {
ret = crypto_register_aeads(aead_algs, ARRAY_SIZE(aead_algs)); ret = crypto_engine_register_aeads(aead_algs, ARRAY_SIZE(aead_algs));
if (ret) if (ret)
goto err_aead_algs; goto err_aead_algs;
} }
...@@ -2032,7 +2067,7 @@ static int stm32_cryp_probe(struct platform_device *pdev) ...@@ -2032,7 +2067,7 @@ static int stm32_cryp_probe(struct platform_device *pdev)
return 0; return 0;
err_aead_algs: err_aead_algs:
crypto_unregister_skciphers(crypto_algs, ARRAY_SIZE(crypto_algs)); crypto_engine_unregister_skciphers(crypto_algs, ARRAY_SIZE(crypto_algs));
err_algs: err_algs:
err_engine2: err_engine2:
crypto_engine_exit(cryp->engine); crypto_engine_exit(cryp->engine);
...@@ -2062,8 +2097,8 @@ static int stm32_cryp_remove(struct platform_device *pdev) ...@@ -2062,8 +2097,8 @@ static int stm32_cryp_remove(struct platform_device *pdev)
return ret; return ret;
if (cryp->caps->aeads_support) if (cryp->caps->aeads_support)
crypto_unregister_aeads(aead_algs, ARRAY_SIZE(aead_algs)); crypto_engine_unregister_aeads(aead_algs, ARRAY_SIZE(aead_algs));
crypto_unregister_skciphers(crypto_algs, ARRAY_SIZE(crypto_algs)); crypto_engine_unregister_skciphers(crypto_algs, ARRAY_SIZE(crypto_algs));
crypto_engine_exit(cryp->engine); crypto_engine_exit(cryp->engine);
......
...@@ -6,12 +6,18 @@ ...@@ -6,12 +6,18 @@
* Author(s): Lionel DEBIEVE <lionel.debieve@st.com> for STMicroelectronics. * Author(s): Lionel DEBIEVE <lionel.debieve@st.com> for STMicroelectronics.
*/ */
#include <crypto/engine.h>
#include <crypto/internal/hash.h>
#include <crypto/md5.h>
#include <crypto/scatterwalk.h>
#include <crypto/sha1.h>
#include <crypto/sha2.h>
#include <crypto/sha3.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/dmaengine.h> #include <linux/dmaengine.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/iopoll.h> #include <linux/iopoll.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -19,15 +25,7 @@ ...@@ -19,15 +25,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/reset.h> #include <linux/reset.h>
#include <linux/string.h>
#include <crypto/engine.h>
#include <crypto/hash.h>
#include <crypto/md5.h>
#include <crypto/scatterwalk.h>
#include <crypto/sha1.h>
#include <crypto/sha2.h>
#include <crypto/sha3.h>
#include <crypto/internal/hash.h>
#define HASH_CR 0x00 #define HASH_CR 0x00
#define HASH_DIN 0x04 #define HASH_DIN 0x04
...@@ -133,7 +131,6 @@ enum ux500_hash_algo { ...@@ -133,7 +131,6 @@ enum ux500_hash_algo {
#define HASH_AUTOSUSPEND_DELAY 50 #define HASH_AUTOSUSPEND_DELAY 50
struct stm32_hash_ctx { struct stm32_hash_ctx {
struct crypto_engine_ctx enginectx;
struct stm32_hash_dev *hdev; struct stm32_hash_dev *hdev;
struct crypto_shash *xtfm; struct crypto_shash *xtfm;
unsigned long flags; unsigned long flags;
...@@ -177,7 +174,7 @@ struct stm32_hash_request_ctx { ...@@ -177,7 +174,7 @@ struct stm32_hash_request_ctx {
}; };
struct stm32_hash_algs_info { struct stm32_hash_algs_info {
struct ahash_alg *algs_list; struct ahash_engine_alg *algs_list;
size_t size; size_t size;
}; };
...@@ -1194,8 +1191,6 @@ static int stm32_hash_cra_init_algs(struct crypto_tfm *tfm, u32 algs_flags) ...@@ -1194,8 +1191,6 @@ static int stm32_hash_cra_init_algs(struct crypto_tfm *tfm, u32 algs_flags)
if (algs_flags) if (algs_flags)
ctx->flags |= algs_flags; ctx->flags |= algs_flags;
ctx->enginectx.op.do_one_request = stm32_hash_one_request;
return stm32_hash_init_fallback(tfm); return stm32_hash_init_fallback(tfm);
} }
...@@ -1268,16 +1263,16 @@ static irqreturn_t stm32_hash_irq_handler(int irq, void *dev_id) ...@@ -1268,16 +1263,16 @@ static irqreturn_t stm32_hash_irq_handler(int irq, void *dev_id)
return IRQ_NONE; return IRQ_NONE;
} }
static struct ahash_alg algs_md5[] = { static struct ahash_engine_alg algs_md5[] = {
{ {
.init = stm32_hash_init, .base.init = stm32_hash_init,
.update = stm32_hash_update, .base.update = stm32_hash_update,
.final = stm32_hash_final, .base.final = stm32_hash_final,
.finup = stm32_hash_finup, .base.finup = stm32_hash_finup,
.digest = stm32_hash_digest, .base.digest = stm32_hash_digest,
.export = stm32_hash_export, .base.export = stm32_hash_export,
.import = stm32_hash_import, .base.import = stm32_hash_import,
.halg = { .base.halg = {
.digestsize = MD5_DIGEST_SIZE, .digestsize = MD5_DIGEST_SIZE,
.statesize = sizeof(struct stm32_hash_state), .statesize = sizeof(struct stm32_hash_state),
.base = { .base = {
...@@ -1293,18 +1288,21 @@ static struct ahash_alg algs_md5[] = { ...@@ -1293,18 +1288,21 @@ static struct ahash_alg algs_md5[] = {
.cra_exit = stm32_hash_cra_exit, .cra_exit = stm32_hash_cra_exit,
.cra_module = THIS_MODULE, .cra_module = THIS_MODULE,
} }
} },
.op = {
.do_one_request = stm32_hash_one_request,
},
}, },
{ {
.init = stm32_hash_init, .base.init = stm32_hash_init,
.update = stm32_hash_update, .base.update = stm32_hash_update,
.final = stm32_hash_final, .base.final = stm32_hash_final,
.finup = stm32_hash_finup, .base.finup = stm32_hash_finup,
.digest = stm32_hash_digest, .base.digest = stm32_hash_digest,
.export = stm32_hash_export, .base.export = stm32_hash_export,
.import = stm32_hash_import, .base.import = stm32_hash_import,
.setkey = stm32_hash_setkey, .base.setkey = stm32_hash_setkey,
.halg = { .base.halg = {
.digestsize = MD5_DIGEST_SIZE, .digestsize = MD5_DIGEST_SIZE,
.statesize = sizeof(struct stm32_hash_state), .statesize = sizeof(struct stm32_hash_state),
.base = { .base = {
...@@ -1320,20 +1318,23 @@ static struct ahash_alg algs_md5[] = { ...@@ -1320,20 +1318,23 @@ static struct ahash_alg algs_md5[] = {
.cra_exit = stm32_hash_cra_exit, .cra_exit = stm32_hash_cra_exit,
.cra_module = THIS_MODULE, .cra_module = THIS_MODULE,
} }
} },
.op = {
.do_one_request = stm32_hash_one_request,
},
} }
}; };
static struct ahash_alg algs_sha1[] = { static struct ahash_engine_alg algs_sha1[] = {
{ {
.init = stm32_hash_init, .base.init = stm32_hash_init,
.update = stm32_hash_update, .base.update = stm32_hash_update,
.final = stm32_hash_final, .base.final = stm32_hash_final,
.finup = stm32_hash_finup, .base.finup = stm32_hash_finup,
.digest = stm32_hash_digest, .base.digest = stm32_hash_digest,
.export = stm32_hash_export, .base.export = stm32_hash_export,
.import = stm32_hash_import, .base.import = stm32_hash_import,
.halg = { .base.halg = {
.digestsize = SHA1_DIGEST_SIZE, .digestsize = SHA1_DIGEST_SIZE,
.statesize = sizeof(struct stm32_hash_state), .statesize = sizeof(struct stm32_hash_state),
.base = { .base = {
...@@ -1349,18 +1350,21 @@ static struct ahash_alg algs_sha1[] = { ...@@ -1349,18 +1350,21 @@ static struct ahash_alg algs_sha1[] = {
.cra_exit = stm32_hash_cra_exit, .cra_exit = stm32_hash_cra_exit,
.cra_module = THIS_MODULE, .cra_module = THIS_MODULE,
} }
} },
.op = {
.do_one_request = stm32_hash_one_request,
},
}, },
{ {
.init = stm32_hash_init, .base.init = stm32_hash_init,
.update = stm32_hash_update, .base.update = stm32_hash_update,
.final = stm32_hash_final, .base.final = stm32_hash_final,
.finup = stm32_hash_finup, .base.finup = stm32_hash_finup,
.digest = stm32_hash_digest, .base.digest = stm32_hash_digest,
.export = stm32_hash_export, .base.export = stm32_hash_export,
.import = stm32_hash_import, .base.import = stm32_hash_import,
.setkey = stm32_hash_setkey, .base.setkey = stm32_hash_setkey,
.halg = { .base.halg = {
.digestsize = SHA1_DIGEST_SIZE, .digestsize = SHA1_DIGEST_SIZE,
.statesize = sizeof(struct stm32_hash_state), .statesize = sizeof(struct stm32_hash_state),
.base = { .base = {
...@@ -1376,20 +1380,23 @@ static struct ahash_alg algs_sha1[] = { ...@@ -1376,20 +1380,23 @@ static struct ahash_alg algs_sha1[] = {
.cra_exit = stm32_hash_cra_exit, .cra_exit = stm32_hash_cra_exit,
.cra_module = THIS_MODULE, .cra_module = THIS_MODULE,
} }
} },
.op = {
.do_one_request = stm32_hash_one_request,
},
}, },
}; };
static struct ahash_alg algs_sha224[] = { static struct ahash_engine_alg algs_sha224[] = {
{ {
.init = stm32_hash_init, .base.init = stm32_hash_init,
.update = stm32_hash_update, .base.update = stm32_hash_update,
.final = stm32_hash_final, .base.final = stm32_hash_final,
.finup = stm32_hash_finup, .base.finup = stm32_hash_finup,
.digest = stm32_hash_digest, .base.digest = stm32_hash_digest,
.export = stm32_hash_export, .base.export = stm32_hash_export,
.import = stm32_hash_import, .base.import = stm32_hash_import,
.halg = { .base.halg = {
.digestsize = SHA224_DIGEST_SIZE, .digestsize = SHA224_DIGEST_SIZE,
.statesize = sizeof(struct stm32_hash_state), .statesize = sizeof(struct stm32_hash_state),
.base = { .base = {
...@@ -1405,18 +1412,21 @@ static struct ahash_alg algs_sha224[] = { ...@@ -1405,18 +1412,21 @@ static struct ahash_alg algs_sha224[] = {
.cra_exit = stm32_hash_cra_exit, .cra_exit = stm32_hash_cra_exit,
.cra_module = THIS_MODULE, .cra_module = THIS_MODULE,
} }
} },
.op = {
.do_one_request = stm32_hash_one_request,
},
}, },
{ {
.init = stm32_hash_init, .base.init = stm32_hash_init,
.update = stm32_hash_update, .base.update = stm32_hash_update,
.final = stm32_hash_final, .base.final = stm32_hash_final,
.finup = stm32_hash_finup, .base.finup = stm32_hash_finup,
.digest = stm32_hash_digest, .base.digest = stm32_hash_digest,
.setkey = stm32_hash_setkey, .base.setkey = stm32_hash_setkey,
.export = stm32_hash_export, .base.export = stm32_hash_export,
.import = stm32_hash_import, .base.import = stm32_hash_import,
.halg = { .base.halg = {
.digestsize = SHA224_DIGEST_SIZE, .digestsize = SHA224_DIGEST_SIZE,
.statesize = sizeof(struct stm32_hash_state), .statesize = sizeof(struct stm32_hash_state),
.base = { .base = {
...@@ -1432,20 +1442,23 @@ static struct ahash_alg algs_sha224[] = { ...@@ -1432,20 +1442,23 @@ static struct ahash_alg algs_sha224[] = {
.cra_exit = stm32_hash_cra_exit, .cra_exit = stm32_hash_cra_exit,
.cra_module = THIS_MODULE, .cra_module = THIS_MODULE,
} }
} },
.op = {
.do_one_request = stm32_hash_one_request,
},
}, },
}; };
static struct ahash_alg algs_sha256[] = { static struct ahash_engine_alg algs_sha256[] = {
{ {
.init = stm32_hash_init, .base.init = stm32_hash_init,
.update = stm32_hash_update, .base.update = stm32_hash_update,
.final = stm32_hash_final, .base.final = stm32_hash_final,
.finup = stm32_hash_finup, .base.finup = stm32_hash_finup,
.digest = stm32_hash_digest, .base.digest = stm32_hash_digest,
.export = stm32_hash_export, .base.export = stm32_hash_export,
.import = stm32_hash_import, .base.import = stm32_hash_import,
.halg = { .base.halg = {
.digestsize = SHA256_DIGEST_SIZE, .digestsize = SHA256_DIGEST_SIZE,
.statesize = sizeof(struct stm32_hash_state), .statesize = sizeof(struct stm32_hash_state),
.base = { .base = {
...@@ -1461,18 +1474,21 @@ static struct ahash_alg algs_sha256[] = { ...@@ -1461,18 +1474,21 @@ static struct ahash_alg algs_sha256[] = {
.cra_exit = stm32_hash_cra_exit, .cra_exit = stm32_hash_cra_exit,
.cra_module = THIS_MODULE, .cra_module = THIS_MODULE,
} }
} },
.op = {
.do_one_request = stm32_hash_one_request,
},
}, },
{ {
.init = stm32_hash_init, .base.init = stm32_hash_init,
.update = stm32_hash_update, .base.update = stm32_hash_update,
.final = stm32_hash_final, .base.final = stm32_hash_final,
.finup = stm32_hash_finup, .base.finup = stm32_hash_finup,
.digest = stm32_hash_digest, .base.digest = stm32_hash_digest,
.export = stm32_hash_export, .base.export = stm32_hash_export,
.import = stm32_hash_import, .base.import = stm32_hash_import,
.setkey = stm32_hash_setkey, .base.setkey = stm32_hash_setkey,
.halg = { .base.halg = {
.digestsize = SHA256_DIGEST_SIZE, .digestsize = SHA256_DIGEST_SIZE,
.statesize = sizeof(struct stm32_hash_state), .statesize = sizeof(struct stm32_hash_state),
.base = { .base = {
...@@ -1488,20 +1504,23 @@ static struct ahash_alg algs_sha256[] = { ...@@ -1488,20 +1504,23 @@ static struct ahash_alg algs_sha256[] = {
.cra_exit = stm32_hash_cra_exit, .cra_exit = stm32_hash_cra_exit,
.cra_module = THIS_MODULE, .cra_module = THIS_MODULE,
} }
} },
.op = {
.do_one_request = stm32_hash_one_request,
},
}, },
}; };
static struct ahash_alg algs_sha384_sha512[] = { static struct ahash_engine_alg algs_sha384_sha512[] = {
{ {
.init = stm32_hash_init, .base.init = stm32_hash_init,
.update = stm32_hash_update, .base.update = stm32_hash_update,
.final = stm32_hash_final, .base.final = stm32_hash_final,
.finup = stm32_hash_finup, .base.finup = stm32_hash_finup,
.digest = stm32_hash_digest, .base.digest = stm32_hash_digest,
.export = stm32_hash_export, .base.export = stm32_hash_export,
.import = stm32_hash_import, .base.import = stm32_hash_import,
.halg = { .base.halg = {
.digestsize = SHA384_DIGEST_SIZE, .digestsize = SHA384_DIGEST_SIZE,
.statesize = sizeof(struct stm32_hash_state), .statesize = sizeof(struct stm32_hash_state),
.base = { .base = {
...@@ -1517,18 +1536,21 @@ static struct ahash_alg algs_sha384_sha512[] = { ...@@ -1517,18 +1536,21 @@ static struct ahash_alg algs_sha384_sha512[] = {
.cra_exit = stm32_hash_cra_exit, .cra_exit = stm32_hash_cra_exit,
.cra_module = THIS_MODULE, .cra_module = THIS_MODULE,
} }
} },
.op = {
.do_one_request = stm32_hash_one_request,
},
}, },
{ {
.init = stm32_hash_init, .base.init = stm32_hash_init,
.update = stm32_hash_update, .base.update = stm32_hash_update,
.final = stm32_hash_final, .base.final = stm32_hash_final,
.finup = stm32_hash_finup, .base.finup = stm32_hash_finup,
.digest = stm32_hash_digest, .base.digest = stm32_hash_digest,
.setkey = stm32_hash_setkey, .base.setkey = stm32_hash_setkey,
.export = stm32_hash_export, .base.export = stm32_hash_export,
.import = stm32_hash_import, .base.import = stm32_hash_import,
.halg = { .base.halg = {
.digestsize = SHA384_DIGEST_SIZE, .digestsize = SHA384_DIGEST_SIZE,
.statesize = sizeof(struct stm32_hash_state), .statesize = sizeof(struct stm32_hash_state),
.base = { .base = {
...@@ -1544,17 +1566,20 @@ static struct ahash_alg algs_sha384_sha512[] = { ...@@ -1544,17 +1566,20 @@ static struct ahash_alg algs_sha384_sha512[] = {
.cra_exit = stm32_hash_cra_exit, .cra_exit = stm32_hash_cra_exit,
.cra_module = THIS_MODULE, .cra_module = THIS_MODULE,
} }
} },
.op = {
.do_one_request = stm32_hash_one_request,
},
}, },
{ {
.init = stm32_hash_init, .base.init = stm32_hash_init,
.update = stm32_hash_update, .base.update = stm32_hash_update,
.final = stm32_hash_final, .base.final = stm32_hash_final,
.finup = stm32_hash_finup, .base.finup = stm32_hash_finup,
.digest = stm32_hash_digest, .base.digest = stm32_hash_digest,
.export = stm32_hash_export, .base.export = stm32_hash_export,
.import = stm32_hash_import, .base.import = stm32_hash_import,
.halg = { .base.halg = {
.digestsize = SHA512_DIGEST_SIZE, .digestsize = SHA512_DIGEST_SIZE,
.statesize = sizeof(struct stm32_hash_state), .statesize = sizeof(struct stm32_hash_state),
.base = { .base = {
...@@ -1570,18 +1595,21 @@ static struct ahash_alg algs_sha384_sha512[] = { ...@@ -1570,18 +1595,21 @@ static struct ahash_alg algs_sha384_sha512[] = {
.cra_exit = stm32_hash_cra_exit, .cra_exit = stm32_hash_cra_exit,
.cra_module = THIS_MODULE, .cra_module = THIS_MODULE,
} }
} },
.op = {
.do_one_request = stm32_hash_one_request,
},
}, },
{ {
.init = stm32_hash_init, .base.init = stm32_hash_init,
.update = stm32_hash_update, .base.update = stm32_hash_update,
.final = stm32_hash_final, .base.final = stm32_hash_final,
.finup = stm32_hash_finup, .base.finup = stm32_hash_finup,
.digest = stm32_hash_digest, .base.digest = stm32_hash_digest,
.export = stm32_hash_export, .base.export = stm32_hash_export,
.import = stm32_hash_import, .base.import = stm32_hash_import,
.setkey = stm32_hash_setkey, .base.setkey = stm32_hash_setkey,
.halg = { .base.halg = {
.digestsize = SHA512_DIGEST_SIZE, .digestsize = SHA512_DIGEST_SIZE,
.statesize = sizeof(struct stm32_hash_state), .statesize = sizeof(struct stm32_hash_state),
.base = { .base = {
...@@ -1597,20 +1625,23 @@ static struct ahash_alg algs_sha384_sha512[] = { ...@@ -1597,20 +1625,23 @@ static struct ahash_alg algs_sha384_sha512[] = {
.cra_exit = stm32_hash_cra_exit, .cra_exit = stm32_hash_cra_exit,
.cra_module = THIS_MODULE, .cra_module = THIS_MODULE,
} }
} },
.op = {
.do_one_request = stm32_hash_one_request,
},
}, },
}; };
static struct ahash_alg algs_sha3[] = { static struct ahash_engine_alg algs_sha3[] = {
{ {
.init = stm32_hash_init, .base.init = stm32_hash_init,
.update = stm32_hash_update, .base.update = stm32_hash_update,
.final = stm32_hash_final, .base.final = stm32_hash_final,
.finup = stm32_hash_finup, .base.finup = stm32_hash_finup,
.digest = stm32_hash_digest, .base.digest = stm32_hash_digest,
.export = stm32_hash_export, .base.export = stm32_hash_export,
.import = stm32_hash_import, .base.import = stm32_hash_import,
.halg = { .base.halg = {
.digestsize = SHA3_224_DIGEST_SIZE, .digestsize = SHA3_224_DIGEST_SIZE,
.statesize = sizeof(struct stm32_hash_state), .statesize = sizeof(struct stm32_hash_state),
.base = { .base = {
...@@ -1626,18 +1657,21 @@ static struct ahash_alg algs_sha3[] = { ...@@ -1626,18 +1657,21 @@ static struct ahash_alg algs_sha3[] = {
.cra_exit = stm32_hash_cra_exit, .cra_exit = stm32_hash_cra_exit,
.cra_module = THIS_MODULE, .cra_module = THIS_MODULE,
} }
} },
.op = {
.do_one_request = stm32_hash_one_request,
},
}, },
{ {
.init = stm32_hash_init, .base.init = stm32_hash_init,
.update = stm32_hash_update, .base.update = stm32_hash_update,
.final = stm32_hash_final, .base.final = stm32_hash_final,
.finup = stm32_hash_finup, .base.finup = stm32_hash_finup,
.digest = stm32_hash_digest, .base.digest = stm32_hash_digest,
.export = stm32_hash_export, .base.export = stm32_hash_export,
.import = stm32_hash_import, .base.import = stm32_hash_import,
.setkey = stm32_hash_setkey, .base.setkey = stm32_hash_setkey,
.halg = { .base.halg = {
.digestsize = SHA3_224_DIGEST_SIZE, .digestsize = SHA3_224_DIGEST_SIZE,
.statesize = sizeof(struct stm32_hash_state), .statesize = sizeof(struct stm32_hash_state),
.base = { .base = {
...@@ -1653,17 +1687,20 @@ static struct ahash_alg algs_sha3[] = { ...@@ -1653,17 +1687,20 @@ static struct ahash_alg algs_sha3[] = {
.cra_exit = stm32_hash_cra_exit, .cra_exit = stm32_hash_cra_exit,
.cra_module = THIS_MODULE, .cra_module = THIS_MODULE,
} }
} },
.op = {
.do_one_request = stm32_hash_one_request,
},
}, },
{ {
.init = stm32_hash_init, .base.init = stm32_hash_init,
.update = stm32_hash_update, .base.update = stm32_hash_update,
.final = stm32_hash_final, .base.final = stm32_hash_final,
.finup = stm32_hash_finup, .base.finup = stm32_hash_finup,
.digest = stm32_hash_digest, .base.digest = stm32_hash_digest,
.export = stm32_hash_export, .base.export = stm32_hash_export,
.import = stm32_hash_import, .base.import = stm32_hash_import,
.halg = { .base.halg = {
.digestsize = SHA3_256_DIGEST_SIZE, .digestsize = SHA3_256_DIGEST_SIZE,
.statesize = sizeof(struct stm32_hash_state), .statesize = sizeof(struct stm32_hash_state),
.base = { .base = {
...@@ -1679,18 +1716,21 @@ static struct ahash_alg algs_sha3[] = { ...@@ -1679,18 +1716,21 @@ static struct ahash_alg algs_sha3[] = {
.cra_exit = stm32_hash_cra_exit, .cra_exit = stm32_hash_cra_exit,
.cra_module = THIS_MODULE, .cra_module = THIS_MODULE,
} }
} },
.op = {
.do_one_request = stm32_hash_one_request,
},
}, },
{ {
.init = stm32_hash_init, .base.init = stm32_hash_init,
.update = stm32_hash_update, .base.update = stm32_hash_update,
.final = stm32_hash_final, .base.final = stm32_hash_final,
.finup = stm32_hash_finup, .base.finup = stm32_hash_finup,
.digest = stm32_hash_digest, .base.digest = stm32_hash_digest,
.export = stm32_hash_export, .base.export = stm32_hash_export,
.import = stm32_hash_import, .base.import = stm32_hash_import,
.setkey = stm32_hash_setkey, .base.setkey = stm32_hash_setkey,
.halg = { .base.halg = {
.digestsize = SHA3_256_DIGEST_SIZE, .digestsize = SHA3_256_DIGEST_SIZE,
.statesize = sizeof(struct stm32_hash_state), .statesize = sizeof(struct stm32_hash_state),
.base = { .base = {
...@@ -1706,17 +1746,20 @@ static struct ahash_alg algs_sha3[] = { ...@@ -1706,17 +1746,20 @@ static struct ahash_alg algs_sha3[] = {
.cra_exit = stm32_hash_cra_exit, .cra_exit = stm32_hash_cra_exit,
.cra_module = THIS_MODULE, .cra_module = THIS_MODULE,
} }
} },
.op = {
.do_one_request = stm32_hash_one_request,
},
}, },
{ {
.init = stm32_hash_init, .base.init = stm32_hash_init,
.update = stm32_hash_update, .base.update = stm32_hash_update,
.final = stm32_hash_final, .base.final = stm32_hash_final,
.finup = stm32_hash_finup, .base.finup = stm32_hash_finup,
.digest = stm32_hash_digest, .base.digest = stm32_hash_digest,
.export = stm32_hash_export, .base.export = stm32_hash_export,
.import = stm32_hash_import, .base.import = stm32_hash_import,
.halg = { .base.halg = {
.digestsize = SHA3_384_DIGEST_SIZE, .digestsize = SHA3_384_DIGEST_SIZE,
.statesize = sizeof(struct stm32_hash_state), .statesize = sizeof(struct stm32_hash_state),
.base = { .base = {
...@@ -1732,18 +1775,21 @@ static struct ahash_alg algs_sha3[] = { ...@@ -1732,18 +1775,21 @@ static struct ahash_alg algs_sha3[] = {
.cra_exit = stm32_hash_cra_exit, .cra_exit = stm32_hash_cra_exit,
.cra_module = THIS_MODULE, .cra_module = THIS_MODULE,
} }
} },
.op = {
.do_one_request = stm32_hash_one_request,
},
}, },
{ {
.init = stm32_hash_init, .base.init = stm32_hash_init,
.update = stm32_hash_update, .base.update = stm32_hash_update,
.final = stm32_hash_final, .base.final = stm32_hash_final,
.finup = stm32_hash_finup, .base.finup = stm32_hash_finup,
.digest = stm32_hash_digest, .base.digest = stm32_hash_digest,
.export = stm32_hash_export, .base.export = stm32_hash_export,
.import = stm32_hash_import, .base.import = stm32_hash_import,
.setkey = stm32_hash_setkey, .base.setkey = stm32_hash_setkey,
.halg = { .base.halg = {
.digestsize = SHA3_384_DIGEST_SIZE, .digestsize = SHA3_384_DIGEST_SIZE,
.statesize = sizeof(struct stm32_hash_state), .statesize = sizeof(struct stm32_hash_state),
.base = { .base = {
...@@ -1759,17 +1805,20 @@ static struct ahash_alg algs_sha3[] = { ...@@ -1759,17 +1805,20 @@ static struct ahash_alg algs_sha3[] = {
.cra_exit = stm32_hash_cra_exit, .cra_exit = stm32_hash_cra_exit,
.cra_module = THIS_MODULE, .cra_module = THIS_MODULE,
} }
} },
.op = {
.do_one_request = stm32_hash_one_request,
},
}, },
{ {
.init = stm32_hash_init, .base.init = stm32_hash_init,
.update = stm32_hash_update, .base.update = stm32_hash_update,
.final = stm32_hash_final, .base.final = stm32_hash_final,
.finup = stm32_hash_finup, .base.finup = stm32_hash_finup,
.digest = stm32_hash_digest, .base.digest = stm32_hash_digest,
.export = stm32_hash_export, .base.export = stm32_hash_export,
.import = stm32_hash_import, .base.import = stm32_hash_import,
.halg = { .base.halg = {
.digestsize = SHA3_512_DIGEST_SIZE, .digestsize = SHA3_512_DIGEST_SIZE,
.statesize = sizeof(struct stm32_hash_state), .statesize = sizeof(struct stm32_hash_state),
.base = { .base = {
...@@ -1785,18 +1834,21 @@ static struct ahash_alg algs_sha3[] = { ...@@ -1785,18 +1834,21 @@ static struct ahash_alg algs_sha3[] = {
.cra_exit = stm32_hash_cra_exit, .cra_exit = stm32_hash_cra_exit,
.cra_module = THIS_MODULE, .cra_module = THIS_MODULE,
} }
} },
.op = {
.do_one_request = stm32_hash_one_request,
},
}, },
{ {
.init = stm32_hash_init, .base.init = stm32_hash_init,
.update = stm32_hash_update, .base.update = stm32_hash_update,
.final = stm32_hash_final, .base.final = stm32_hash_final,
.finup = stm32_hash_finup, .base.finup = stm32_hash_finup,
.digest = stm32_hash_digest, .base.digest = stm32_hash_digest,
.export = stm32_hash_export, .base.export = stm32_hash_export,
.import = stm32_hash_import, .base.import = stm32_hash_import,
.setkey = stm32_hash_setkey, .base.setkey = stm32_hash_setkey,
.halg = { .base.halg = {
.digestsize = SHA3_512_DIGEST_SIZE, .digestsize = SHA3_512_DIGEST_SIZE,
.statesize = sizeof(struct stm32_hash_state), .statesize = sizeof(struct stm32_hash_state),
.base = { .base = {
...@@ -1812,7 +1864,10 @@ static struct ahash_alg algs_sha3[] = { ...@@ -1812,7 +1864,10 @@ static struct ahash_alg algs_sha3[] = {
.cra_exit = stm32_hash_cra_exit, .cra_exit = stm32_hash_cra_exit,
.cra_module = THIS_MODULE, .cra_module = THIS_MODULE,
} }
} },
.op = {
.do_one_request = stm32_hash_one_request,
},
} }
}; };
...@@ -1823,7 +1878,7 @@ static int stm32_hash_register_algs(struct stm32_hash_dev *hdev) ...@@ -1823,7 +1878,7 @@ static int stm32_hash_register_algs(struct stm32_hash_dev *hdev)
for (i = 0; i < hdev->pdata->algs_info_size; i++) { for (i = 0; i < hdev->pdata->algs_info_size; i++) {
for (j = 0; j < hdev->pdata->algs_info[i].size; j++) { for (j = 0; j < hdev->pdata->algs_info[i].size; j++) {
err = crypto_register_ahash( err = crypto_engine_register_ahash(
&hdev->pdata->algs_info[i].algs_list[j]); &hdev->pdata->algs_info[i].algs_list[j]);
if (err) if (err)
goto err_algs; goto err_algs;
...@@ -1835,7 +1890,7 @@ static int stm32_hash_register_algs(struct stm32_hash_dev *hdev) ...@@ -1835,7 +1890,7 @@ static int stm32_hash_register_algs(struct stm32_hash_dev *hdev)
dev_err(hdev->dev, "Algo %d : %d failed\n", i, j); dev_err(hdev->dev, "Algo %d : %d failed\n", i, j);
for (; i--; ) { for (; i--; ) {
for (; j--;) for (; j--;)
crypto_unregister_ahash( crypto_engine_unregister_ahash(
&hdev->pdata->algs_info[i].algs_list[j]); &hdev->pdata->algs_info[i].algs_list[j]);
} }
...@@ -1848,7 +1903,7 @@ static int stm32_hash_unregister_algs(struct stm32_hash_dev *hdev) ...@@ -1848,7 +1903,7 @@ static int stm32_hash_unregister_algs(struct stm32_hash_dev *hdev)
for (i = 0; i < hdev->pdata->algs_info_size; i++) { for (i = 0; i < hdev->pdata->algs_info_size; i++) {
for (j = 0; j < hdev->pdata->algs_info[i].size; j++) for (j = 0; j < hdev->pdata->algs_info[i].size; j++)
crypto_unregister_ahash( crypto_engine_unregister_ahash(
&hdev->pdata->algs_info[i].algs_list[j]); &hdev->pdata->algs_info[i].algs_list[j]);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment