From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753368AbdEJN5D (ORCPT ); Wed, 10 May 2017 09:57:03 -0400 Received: from mail.eperm.de ([89.247.134.16]:59432 "EHLO mail.eperm.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752615AbdEJN5C (ORCPT ); Wed, 10 May 2017 09:57:02 -0400 From: Stephan =?ISO-8859-1?Q?M=FCller?= To: Srikanth Jampala Cc: herbert@gondor.apana.org.au, davem@davemloft.net, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, George.Cherian@cavium.com, Nidadavolu.Murthy@cavium.com, Sreerama.Gadam@cavium.com, Ram.Kumar@cavium.com Subject: Re: [PATCH v1 3/3] crypto: cavium - Register the CNN55XX supported crypto algorithms. Date: Wed, 10 May 2017 15:56:56 +0200 Message-ID: <3575749.J6klBtBYWh@tauon.chronox.de> In-Reply-To: <20170510130640.5838-4-Jampala.Srikanth@cavium.com> References: <20170510130640.5838-1-Jampala.Srikanth@cavium.com> <20170510130640.5838-4-Jampala.Srikanth@cavium.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id v4ADwv66019331 Am Mittwoch, 10. Mai 2017, 15:06:40 CEST schrieb Srikanth Jampala: Hi Srikanth, In general: you are using the ablkcipher API. I think it is on its way out and being replaced with skcipher. Maybe it makes sense to replace it here too. It could be as simple as s/ ablkcipher/skcipher/g > +static inline int nitrox_ablkcipher_setkey(struct crypto_ablkcipher > *cipher, > + int aes_keylen, const u8 *key, > + unsigned int keylen) > +{ > + struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher); > + struct nitrox_crypto_instance *inst = crypto_tfm_ctx(tfm); > + struct flexi_crypto_context *fctx; > + enum flexi_cipher cipher_type; > + const char *name; > + > + name = crypto_tfm_alg_name(tfm); > + cipher_type = flexi_cipher_type(name); > + if (cipher_type == CIPHER_INVALID) { > + pr_err("unsupported cipher: %s\n", name); > + return -EINVAL; > + } > + > + /* fill crypto context */ > + fctx = inst->u.fctx; > + fctx->flags = 0; > + fctx->w0.cipher_type = cipher_type; > + fctx->w0.aes_keylen = aes_keylen; > + fctx->w0.iv_source = IV_FROM_DPTR; > + fctx->flags = cpu_to_be64(*(u64 *)&fctx->w0); > + /* copy the key to context */ > + memcpy(fctx->crypto.u.key, key, keylen); Could you help me finding the location where this memory is zeroized upon release? > + > + return 0; > +} > + > +static int nitrox_3des_setkey(struct crypto_ablkcipher *cipher, const u8 > *key, + unsigned int keylen) > +{ > + if (keylen != DES3_EDE_KEY_SIZE) { > + crypto_ablkcipher_set_flags(cipher, CRYPTO_TFM_RES_BAD_KEY_LEN); > + return -EINVAL; > + } Please import the check from __des3_ede_setkey (or better, extract that key check into a generic function like xts_check_key). Ciao Stephan