Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1035693AbdDUFrj (ORCPT ); Fri, 21 Apr 2017 01:47:39 -0400 Received: from mail-dm3nam03on0076.outbound.protection.outlook.com ([104.47.41.76]:12096 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1035655AbdDUFr1 (ORCPT ); Fri, 21 Apr 2017 01:47:27 -0400 Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=cavium.com; From: George Cherian To: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Cc: george.cherian@cavium.com, herbert@gondor.apana.org.au, davem@davemloft.net Subject: [PATCH 2/3] crypto: cavium: Remove the individual encrypt/decrypt function for each algorithm Date: Fri, 21 Apr 2017 11:16:05 +0000 Message-Id: <1492773366-17899-3-git-send-email-george.cherian@cavium.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1492773366-17899-1-git-send-email-george.cherian@cavium.com> References: <1492773366-17899-1-git-send-email-george.cherian@cavium.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: PN1PR01CA0063.INDPRD01.PROD.OUTLOOK.COM (10.164.136.163) To BLUPR0701MB1699.namprd07.prod.outlook.com (10.163.85.13) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 81563f13-b06d-414f-e1b0-08d48879e341 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131423075)(201703031133081);SRVR:BLUPR0701MB1699; X-Microsoft-Exchange-Diagnostics: 1;BLUPR0701MB1699;3:fgjyxDqnBj9Bymk6yU5kaPaOs0d3tdfAMIS8PDR1Y6lZovE+ejyPUITtPRRIPL+OretL2gGHUvdPG5q4zwgWjzPvnhwvBq2Eke5BAT4ZBXptXN0XEQsbvuQilKOImwClYitxlHZlPB17keL2qwbXKfpH2yD1tAkSBRNPbLNo0rC8jpkoiixhSmZL7vyXCRySqwSuQOop+4DU+JWmFrZcyE7+x9YG3oiY0BUufrjb0BKQvrMkF5TdyL4YUh5YRIBDAAts6oWaP3ULI4x5GQY6H5B5e9PMyxhzK0gUdMxKfv/dWJk2cvuu26C6DsXUgwOz6CFp07sZ1XJMHY6AHYJmDA==;25:3N/2ImZr/rrvU6PMVe36VxkoyLxpgS446lP/FkGq+itEyMon8xSDmVdZWRu3DrkYSd/3qrLalSalo7lVWXtjOD4Ny2nGx9fNHdAoar5bbSnNLF3enPh5GsQP+cUVHhlv6x5QtiPcTkRGrauGDMbgwViwz8Uimr8G2A5Y/6yXTzLo17Q5YWd8/FKPV3bBeTDsCPImGquCtMht1aqFHjkwq1OhppSJaVIvKf1wmCnePNzZoZP3DVmzGUNk6fuKZvSNP/c7glQMScQC1X914SXK0JtPebw8T46Tj3ok3QMoupUu/l57IFn9bqLgNHNPN6PqC9QE61uM2vzv4bi3sKsyY28wRXynCiLZJJ31eF5CSTX06xikuNSOpChYpEdXVzcuN+YWtmCpJRaC1KrukRVM4PdxBcw/XYs1erqyWSgRGz+ia0OdAvOME8EB3+v6ssYR+Pp1Et0YJK3w9V8LrffEjg== X-Microsoft-Exchange-Diagnostics: 1;BLUPR0701MB1699;31:GhSz6EZbprUCWFDHiCRXDILE1FWYmofC/BJDCFVEjRyfluDN2apbm/W+x4/Fg95PHhDy/AXJBQFymBTAZ2+m95JHxOSetcNnFUv6Kf19RoXBFZkin9an9B6omZw66z86fzWdaycmZ+gzNMJqSBkmIQkH1IIxzHM5n2vEpBDz0Eh6qC89iqtabZdyZ0kpEumFVaLsMka0Reomrgrq5p9RScKFVDGzZnIC9mhgUgcov8o=;20:AhexxMLvLG2yQncktm86X/908Cd1dEidC2QUHZ+914DRi4n/sI6Rj3YOBf82PRQpRpS5u3CLHPXovjVqJIslUi+4mx2zh94A7Mo1Hkcup5Z7D7/MIk1gNs/tLpJ5H/t0JxT/UaXz6qm5q2g25xbLoLJD1G+pM2/SY3LcOP0j7yzThLDcWfk3VMEVeICCp9KkIaTX/ayFFr++PQidq7WVs9FUfSDzTD4ImQW8tHncMBwJAB2l/kswfDqQxDeTMTJRoItWaWA/Ww5+zm7Mr31T9/7WCTh5avbMOfwMTdrybnd2XbkwukHgiRIL92v3HXq3wCJxngM4sWGUI7hsV/mllNmQvOAnmz4SCHKmF1SavVRolZkzSkbPjgXywEFg3cwnNcy+lklL+vniNc7ywkqW5IlneKPca6wmt0b7EIfHekpJiix3IoFxyIHs20012yKS2kc46yNAhoXfXc2h0TgMcw8USnAD3W46AGZI8GtxH+ppMzmXfrPOeGQUoTfneTgQ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(6041248)(20161123560025)(20161123555025)(20161123564025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(6072148);SRVR:BLUPR0701MB1699;BCL:0;PCL:0;RULEID:;SRVR:BLUPR0701MB1699; X-Microsoft-Exchange-Diagnostics: 1;BLUPR0701MB1699;4:vtEi+MfSAyqtG2DCjkMcoJ5BOCEAyRpqxovlIVf0lf4NqboONBFBINpsmDi9jUkIp53g9hBtW+BZGyY+HvKxYXddZ1QLesHNjzdDLGRxhRg0y8NDBh767o8ZpqcFzywTN3MnI9FqpwmUyKPR/2bHFH2NhhSGCd2CgswidMQyGHOFfH0mJYOmn3OPAglpraIgppHncBVt90/B0nb92maQTFwkwth9FbHQPMdJJquUp0pbM3Len3Mj6v5/cDkYG08+4sMGX+KZiG+dw86NKCwcO5zZpEE/zBnoe2L3Zibwu0r/TmX0RVlKqEGBVr2ZSmEU0fLW0WnJOVXib3fVT837rDAWb9iKKDFMfuYWYurkSuzXX8HcmKbIzThg96pzoaK3yyEVESMXbSdHWZRtjx9o8H9YFE3NOQYfQUQ/wDGYVcS5VGva8UmuO2BVlI4dlGkovOF9G8DK9rnQw6qCvm5H2h9atOqBkGloUx+sd2LsFuZ29+lW16uEEko31X0CQ1NdtoPHWXYzBzV2LsE/QoTRKap+Upw+pl86wevrnB52gwS0RhB8EW1Vc/A5nw6eekpu8OFjUsqUEEhtJnt4qgi3BisvjhpR1l9vvRPoSE8Yl/zA2TiXt30qlOL4s+b2AUMqDX1eOgu+SU+Y/i+kFTkrX74MMVpecUoYNa3QsSvspBgI2aufDZ98Ts+gFLqszZJGxoETwb9x5qUW5Lic60Ma5A== X-Forefront-PRVS: 02843AA9E0 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(39840400002)(39850400002)(39400400002)(39410400002)(39450400003)(6506006)(8676002)(305945005)(42186005)(7736002)(48376002)(86362001)(189998001)(53936002)(53416004)(6486002)(3846002)(50466002)(6512007)(6116002)(50226002)(5009440100003)(36756003)(66066001)(6666003)(50986999)(5003940100001)(33646002)(2906002)(25786009)(2950100002)(76176999)(47776003)(5660300001)(4326008)(38730400002)(110136004);DIR:OUT;SFP:1101;SCL:1;SRVR:BLUPR0701MB1699;H:ubuntu.caveonetworks.com;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BLUPR0701MB1699;23:lyA7pkc6wrQKr1Bgnkc/YYddKI5AYHFuDF5lR3I?= =?us-ascii?Q?1XqcOvU2C8EUsTqEPEOTn6tkg10UV768T4ZFKWePvR1Y+2TrflTpbH8yt1Hk?= =?us-ascii?Q?HHin/xrr7tEinC0dg7FXrxhuL38LGLBn7Jmn86RCmEI+Hw0fU7UrD+bav7eu?= =?us-ascii?Q?iCxB0czf3YDqM3+xOABMcfbPONU1ir2aShOWrBxCgREo58qxcBaSdiSuhVHw?= =?us-ascii?Q?VNZnUt1wrgNDduEPxJbLvpq2rlejRd3dpyjTRGPsdYMuSWbJMTnqc6vkl6A6?= =?us-ascii?Q?E8qUeaYPUGW3o0iJJ8/GM3aZPvL19G479//QWjoD0MAjLcNcjFxnAn2m3qU5?= =?us-ascii?Q?yVlShR2/H38iqpzHB8eJibPwgKFg/G2Pa2gHdy9qlEFtcf+FGGQk8hle5IxY?= =?us-ascii?Q?RhMshq3zBZomm6vwqknvznBPpMQDBzk+GQNADCHcqTF23APbPVVJTrR/fUMX?= =?us-ascii?Q?rCKDni0R36BryisBoEozny7Crx0CNL+rTr0DClat/UslMf+6CWqTgfRSewRw?= =?us-ascii?Q?VQ6SFXsXucyDa7E84JJFeommHgrC9NM/lcJQlwejTxDtb9NBz54AwcCJnKo2?= =?us-ascii?Q?p4snf68NEqYQyG6XXqQtNk/w2HSv9O9wBUBBEo01BCXFTiPkeJNWJpqrl/wk?= =?us-ascii?Q?GxAjNJB4pgb8RfKATAcOgFyKCSbkPVz7qunzRE8g1Y8YEA+FF+Y9P4jUKLGH?= =?us-ascii?Q?lLP8Gy3gPKjpYIYouiz0rlLFe7ptyQslITL9eMTXuLM2d9EFL1CJfreWK1uK?= =?us-ascii?Q?b2JT/tJdfAc22MXJ/Cux5RZQlmiUUoppXt9u9I49E34EsHIkUa6ptOUTwCKB?= =?us-ascii?Q?Jx4JIUwkqQ/FBVlOOhu9OQCbrP3Z1ADocTscoXO9Ua1ntvAJY4hl7H9m5oeG?= =?us-ascii?Q?oBatv8jsAT+A78bz0IzRtMLyN9ABRC1VVPOjfxScrNGdv7l0NpxrV5gTed90?= =?us-ascii?Q?jy9roBJj79FNo/DuGWQMRzZxmxhdXm5yaLam94VJhv1J7kzHCSBjd2rFUjje?= =?us-ascii?Q?2aAWBDI6KB4vxHpBcX9NVVNqW?= X-Microsoft-Exchange-Diagnostics: 1;BLUPR0701MB1699;6:V59RcWvSGeKKgKsSnj3eTIEBggwJIxe1Qh+lzw8upl6peQzvnVBzl1dwdGcK87+ClIRxKZyOjOdwHBYWJRP62QN/e8RyU5WNHTSmvxpif/gOUWl8thv6MPJLndDPPt/eFsHDQ6Qy+2cMkhOSLOUQj4O/KGMjsAO0eK50dcVnOHJ6L/2bjucokicWAfer5pNdqtb0UxrGSylZMU8IYGZMhaRznorebIec2rcBccwkPmKbMoB4vDKrGHrlvSBDqFbbW79d37COS/QiUsiflmrXALCyzeWlJ9AFIjp9IuWmfpaYKXQplB7DLFQPLn/w6ztr0F5VojKKW9G6HXT0SJxWSozf1bCUDy4RA0oN9flaCISGcaez8LQ1VrLASRHffCWoUBdb7ZCeHrUU9msTvJytTiHhzgHQ8M7bPxruWvJPeaoBMtrWIuaToFBNbwx7VaAX/cAkfv7MpIxa7C/KGSO7SCKz0pkvEe1/ulKwrP+1J02UgBmsbdLESHm21R0zM6pBwmL99b703/LWppVdLWWsWg==;5:mN0iqoeFJCA+Yw/D0P3etB1Rs/Y0KLd05JcQ5iaYjLBt4bKcRTD/vPYPrsImpYbnJCnOs82S65NbglRSV2IasJk40aU3rk0nrkSxLV3+BPxKZzjKLGvwodGHwKkIBqsfulBCkfwfPGi0N0KkRmtGVg==;24:lysmPdjsYUrR9ppxqLBlHdepMeRPasA7mMqu7NL1s7iGRMpcTgEApJW/aeMI551ndPzGERAWOFNmEx8sXWLeZ92Oqc3qqemg0ctcw+JjZ4k= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BLUPR0701MB1699;7:eqePZTrS48RJO24uR2tyX5xeFhHjQXOsbPtEdsRECx5zRguejazgwYfLjQ5/L+oHYIv8SrfniMZBviyHA9w/VArTMziIOJp0cMVwPSeTefwe/Ga+AF95mwcwcqbDHWHgyUKMKCj+jg7dPqyjVhSbvKmaWTdcj215TignjBLc9j2R7xLKRiJ6cUR8Q5e2Jm/bmGPae3+M5HlLU8HCHDCd99N8CY+6p8cmSa7P6a8sdUnLx8AeIJdawiIl641cBIDwRrfC5RMxZ5yCSHwKOFxYSXyg6DTfQTt73cLHuO8Jy8ID7g3LSYbw+7kvKQmcafoTW9T/hGbXkLK/6qJgLV3oKw== X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Apr 2017 05:47:23.5394 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0701MB1699 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 8490 Lines: 287 Remove the individual encrypt/decrypt function for easch algorithm. This is in prepration of adding more crypto algorithms supported by hardware. While at that simplify create_ctx_hdr/create_input_list function interfaces. Signed-off-by: George Cherian --- drivers/crypto/cavium/cpt/cptvf_algs.c | 133 +++++++++++++++++---------------- drivers/crypto/cavium/cpt/cptvf_algs.h | 7 ++ 2 files changed, 77 insertions(+), 63 deletions(-) diff --git a/drivers/crypto/cavium/cpt/cptvf_algs.c b/drivers/crypto/cavium/cpt/cptvf_algs.c index cc853f9..c365fc6 100644 --- a/drivers/crypto/cavium/cpt/cptvf_algs.c +++ b/drivers/crypto/cavium/cpt/cptvf_algs.c @@ -98,7 +98,6 @@ static inline void update_output_data(struct cpt_request_info *req_info, } static inline u32 create_ctx_hdr(struct ablkcipher_request *req, u32 enc, - u32 cipher_type, u32 aes_key_type, u32 *argcnt) { struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(req); @@ -124,11 +123,11 @@ static inline u32 create_ctx_hdr(struct ablkcipher_request *req, u32 enc, req_info->req.param1 = req->nbytes; /* Encryption Data length */ req_info->req.param2 = 0; /*Auth data length */ - fctx->enc.enc_ctrl.e.enc_cipher = cipher_type; - fctx->enc.enc_ctrl.e.aes_key = aes_key_type; + fctx->enc.enc_ctrl.e.enc_cipher = ctx->cipher_type; + fctx->enc.enc_ctrl.e.aes_key = ctx->key_type; fctx->enc.enc_ctrl.e.iv_source = FROM_DPTR; - if (cipher_type == AES_XTS) + if (ctx->cipher_type == AES_XTS) memcpy(fctx->enc.encr_key, ctx->enc_key, ctx->key_len * 2); else memcpy(fctx->enc.encr_key, ctx->enc_key, ctx->key_len); @@ -154,14 +153,13 @@ static inline u32 create_ctx_hdr(struct ablkcipher_request *req, u32 enc, } static inline u32 create_input_list(struct ablkcipher_request *req, u32 enc, - u32 cipher_type, u32 aes_key_type, u32 enc_iv_len) { struct cvm_req_ctx *rctx = ablkcipher_request_ctx(req); struct cpt_request_info *req_info = &rctx->cpt_req; u32 argcnt = 0; - create_ctx_hdr(req, enc, cipher_type, aes_key_type, &argcnt); + create_ctx_hdr(req, enc, &argcnt); update_input_iv(req_info, req->info, enc_iv_len, &argcnt); update_input_data(req_info, req->src, req->nbytes, &argcnt); req_info->incnt = argcnt; @@ -177,7 +175,6 @@ static inline void store_cb_info(struct ablkcipher_request *req, } static inline void create_output_list(struct ablkcipher_request *req, - u32 cipher_type, u32 enc_iv_len) { struct cvm_req_ctx *rctx = ablkcipher_request_ctx(req); @@ -197,12 +194,9 @@ static inline void create_output_list(struct ablkcipher_request *req, req_info->outcnt = argcnt; } -static inline int cvm_enc_dec(struct ablkcipher_request *req, u32 enc, - u32 cipher_type) +static inline int cvm_enc_dec(struct ablkcipher_request *req, u32 enc) { struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(req); - struct cvm_enc_ctx *ctx = crypto_ablkcipher_ctx(tfm); - u32 key_type = AES_128_BIT; struct cvm_req_ctx *rctx = ablkcipher_request_ctx(req); u32 enc_iv_len = crypto_ablkcipher_ivsize(tfm); struct fc_context *fctx = &rctx->fctx; @@ -210,36 +204,10 @@ static inline int cvm_enc_dec(struct ablkcipher_request *req, u32 enc, void *cdev = NULL; int status; - switch (ctx->key_len) { - case 16: - key_type = AES_128_BIT; - break; - case 24: - key_type = AES_192_BIT; - break; - case 32: - if (cipher_type == AES_XTS) - key_type = AES_128_BIT; - else - key_type = AES_256_BIT; - break; - case 64: - if (cipher_type == AES_XTS) - key_type = AES_256_BIT; - else - return -EINVAL; - break; - default: - return -EINVAL; - } - - if (cipher_type == DES3_CBC) - key_type = 0; - memset(req_info, 0, sizeof(struct cpt_request_info)); memset(fctx, 0, sizeof(struct fc_context)); - create_input_list(req, enc, cipher_type, key_type, enc_iv_len); - create_output_list(req, cipher_type, enc_iv_len); + create_input_list(req, enc, enc_iv_len); + create_output_list(req, enc_iv_len); store_cb_info(req, req_info); cdev = dev_handle.cdev[smp_processor_id()]; status = cptvf_do_request(cdev, req_info); @@ -254,34 +222,41 @@ static inline int cvm_enc_dec(struct ablkcipher_request *req, u32 enc, return -EINPROGRESS; } -int cvm_des3_encrypt_cbc(struct ablkcipher_request *req) +int cvm_encrypt(struct ablkcipher_request *req) { - return cvm_enc_dec(req, true, DES3_CBC); + return cvm_enc_dec(req, true); } -int cvm_des3_decrypt_cbc(struct ablkcipher_request *req) +int cvm_decrypt(struct ablkcipher_request *req) { - return cvm_enc_dec(req, false, DES3_CBC); + return cvm_enc_dec(req, false); } -int cvm_aes_encrypt_xts(struct ablkcipher_request *req) -{ - return cvm_enc_dec(req, true, AES_XTS); -} +static const struct cvm_cipher cvm_cipher_table[] = { + { "cbc(des3_ede)", DES3_CBC }, + { "ecb(des3_ede)", DES3_ECB}, + { "cbc(aes)", AES_CBC}, + { "ecb(aes)", AES_ECB}, + { "cfb(aes)", AES_CFB}, + { "rfc3686(ctr(aes))", AES_CTR}, + { "xts(aes)", AES_XTS}, + { "cts(cbc(aes))", AES_GCM}, + { NULL, -1} +}; -int cvm_aes_decrypt_xts(struct ablkcipher_request *req) -{ - return cvm_enc_dec(req, false, AES_XTS); -} -int cvm_aes_encrypt_cbc(struct ablkcipher_request *req) +static inline u32 cvm_cipher_type(const char *name) { - return cvm_enc_dec(req, true, AES_CBC); -} -int cvm_aes_decrypt_cbc(struct ablkcipher_request *req) -{ - return cvm_enc_dec(req, false, AES_CBC); + const struct cvm_cipher *cipher = cvm_cipher_table; + + while (cipher->name) { + if (!strcmp(cipher->name, name)) + break; + cipher++; + } + + return cipher->value; } int cvm_xts_setkey(struct crypto_ablkcipher *cipher, const u8 *key, @@ -299,6 +274,17 @@ int cvm_xts_setkey(struct crypto_ablkcipher *cipher, const u8 *key, ctx->key_len = keylen; memcpy(ctx->enc_key, key1, keylen / 2); memcpy(ctx->enc_key + KEY2_OFFSET, key2, keylen / 2); + ctx->cipher_type = AES_XTS; + switch (ctx->key_len) { + case 32: + ctx->key_type = AES_128_BIT; + break; + case 64: + ctx->key_type = AES_256_BIT; + break; + default: + return -EINVAL; + } return 0; } @@ -308,12 +294,33 @@ int cvm_enc_dec_setkey(struct crypto_ablkcipher *cipher, const u8 *key, { struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher); struct cvm_enc_ctx *ctx = crypto_tfm_ctx(tfm); + const char *name; + name = crypto_tfm_alg_name(tfm); + ctx->cipher_type = cvm_cipher_type(name); if ((keylen == 16) || (keylen == 24) || (keylen == 32)) { ctx->key_len = keylen; memcpy(ctx->enc_key, key, keylen); + switch (ctx->key_len) { + case 16: + ctx->key_type = AES_128_BIT; + break; + case 24: + ctx->key_type = AES_192_BIT; + break; + case 32: + ctx->key_type = AES_256_BIT; + break; + default: + return -EINVAL; + } + + if (ctx->cipher_type == DES3_CBC) + ctx->key_type = 0; + return 0; } + crypto_ablkcipher_set_flags(cipher, CRYPTO_TFM_RES_BAD_KEY_LEN); return -EINVAL; @@ -349,8 +356,8 @@ struct crypto_alg algs[] = { { .min_keysize = 2 * AES_MIN_KEY_SIZE, .max_keysize = 2 * AES_MAX_KEY_SIZE, .setkey = cvm_xts_setkey, - .encrypt = cvm_aes_encrypt_xts, - .decrypt = cvm_aes_decrypt_xts, + .encrypt = cvm_encrypt, + .decrypt = cvm_decrypt, }, }, .cra_init = cvm_enc_dec_init, @@ -370,8 +377,8 @@ struct crypto_alg algs[] = { { .min_keysize = AES_MIN_KEY_SIZE, .max_keysize = AES_MAX_KEY_SIZE, .setkey = cvm_enc_dec_setkey, - .encrypt = cvm_aes_encrypt_cbc, - .decrypt = cvm_aes_decrypt_cbc, + .encrypt = cvm_encrypt, + .decrypt = cvm_decrypt, }, }, .cra_init = cvm_enc_dec_init, @@ -391,8 +398,8 @@ struct crypto_alg algs[] = { { .max_keysize = DES3_EDE_KEY_SIZE, .ivsize = DES_BLOCK_SIZE, .setkey = cvm_enc_dec_setkey, - .encrypt = cvm_des3_encrypt_cbc, - .decrypt = cvm_des3_decrypt_cbc, + .encrypt = cvm_encrypt, + .decrypt = cvm_decrypt, }, }, .cra_init = cvm_enc_dec_init, diff --git a/drivers/crypto/cavium/cpt/cptvf_algs.h b/drivers/crypto/cavium/cpt/cptvf_algs.h index a12050d..902f257 100644 --- a/drivers/crypto/cavium/cpt/cptvf_algs.h +++ b/drivers/crypto/cavium/cpt/cptvf_algs.h @@ -77,6 +77,11 @@ union encr_ctrl { } e; }; +struct cvm_cipher { + const char *name; + u8 value; +}; + struct enc_context { union encr_ctrl enc_ctrl; u8 encr_key[32]; @@ -96,6 +101,8 @@ struct fc_context { struct cvm_enc_ctx { u32 key_len; u8 enc_key[MAX_KEY_SIZE]; + u8 cipher_type:4; + u8 key_type:2; }; struct cvm_des3_ctx { -- 2.1.4