From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ECA6FC433E1 for ; Tue, 23 Mar 2021 16:41:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CD82C619C7 for ; Tue, 23 Mar 2021 16:41:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233341AbhCWQlS (ORCPT ); Tue, 23 Mar 2021 12:41:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233336AbhCWQlJ (ORCPT ); Tue, 23 Mar 2021 12:41:09 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DE74C061763 for ; Tue, 23 Mar 2021 09:41:09 -0700 (PDT) Received: from gallifrey.ext.pengutronix.de ([2001:67c:670:201:5054:ff:fe8d:eefb] helo=[IPv6:::1]) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1lOk5c-0005iX-20; Tue, 23 Mar 2021 17:41:08 +0100 Subject: Re: [PATCH v1 1/3] crypto: caam - add in-kernel interface for blob generator To: =?UTF-8?Q?Horia_Geant=c4=83?= , Aymen Sghaier , Herbert Xu , "David S. Miller" Cc: "kernel@pengutronix.de" , James Bottomley , Jarkko Sakkinen , Mimi Zohar , David Howells , James Morris , "Serge E. Hallyn" , Udit Agarwal , Jan Luebbe , David Gstir , Franck Lenormand , Sumit Garg , "linux-integrity@vger.kernel.org" , "keyrings@vger.kernel.org" , "linux-crypto@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-security-module@vger.kernel.org" References: <420d2319e533ac97965fb826a70bdb023af2a844.1615914058.git-series.a.fatoum@pengutronix.de> <76cd2a74-f522-34c0-eb8c-3047e3cab5cd@nxp.com> From: Ahmad Fatoum Message-ID: <880516db-5939-d4cd-100c-69cd85532d39@pengutronix.de> Date: Tue, 23 Mar 2021 17:41:06 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: <76cd2a74-f522-34c0-eb8c-3047e3cab5cd@nxp.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2001:67c:670:201:5054:ff:fe8d:eefb X-SA-Exim-Mail-From: a.fatoum@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-security-module@vger.kernel.org Precedence: bulk List-ID: Hello Horia, On 21.03.21 21:46, Horia Geantă wrote: > On 3/16/2021 7:01 PM, Ahmad Fatoum wrote: >> + init_job_desc(desc, 0); >> + append_key_as_imm(desc, keymod, keymod_len, keymod_len, >> + CLASS_2 | KEY_DEST_CLASS_REG); >> + append_seq_in_ptr(desc, dma_in, length - CAAM_BLOB_OVERHEAD, 0); >> + append_seq_out_ptr(desc, dma_out, length, 0); > In case length is known to be < 2^16, it's recommended to use instead > append_seq_in_ptr_intlen, append_seq_out_ptr_intlen. Didn't know about this one. Will look into using it for v2. >> +#define CAAM_BLOB_KEYMOD_LENGTH 16 > The define isn't used here or on patch 3/3. Will drop and adjust the function docs to note the maximum modifier length. >> +#define CAAM_BLOB_OVERHEAD (32 + 16) >> +#define CAAM_BLOB_MAX_LEN 4096 >> + >> +struct caam_blob_priv; >> + >> +/** caam_blob_gen_init - initialize blob generation >> + * >> + * returns either pointer to new caam_blob_priv instance >> + * or error pointer >> + */ >> +struct caam_blob_priv *caam_blob_gen_init(void); >> + >> +/** caam_blob_gen_init - free blob generation resources >> + * >> + * @priv: instance returned by caam_blob_gen_init >> + */ >> +void caam_blob_gen_exit(struct caam_blob_priv *priv); >> + >> +/** caam_encap_blob - encapsulate blob >> + * >> + * @priv: instance returned by caam_blob_gen_init >> + * @keymod: string to use as key modifier for blob encapsulation >> + * @input: buffer which CAAM will DMA from >> + * @output: buffer which CAAM will DMA to > Is it guaranteed that input, output can be DMA-mapped? It's expected callers ensure that this is the case. Trusted key buffers are allocated with kmalloc and can be DMA-mapped. Thanks for the review, Ahmad -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |