Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5983052pxv; Thu, 29 Jul 2021 03:33:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+L2Hfc76+ABm3o95Aqo3RNvE8OiZSIOVc7XyZueJXhtbx0C3h2gr32zgZYu7/6n61QQfb X-Received: by 2002:aa7:c541:: with SMTP id s1mr5240370edr.327.1627554783885; Thu, 29 Jul 2021 03:33:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627554783; cv=none; d=google.com; s=arc-20160816; b=0JqtecJaeoG29AL0oQafgRDSfM8rtJ2A+Gx+XpSxqShT29BsU7RtoXW1sSrxaXaeGK iyYU4BwINsBFFvdQSr4xHx0YLwWWW7M6wTHmysV7Qyws0zXgE/sDyauKzW3dPUAWsWWn KwtRqXDdnadISilYO6nyjddDJTWhNKpju3QXvPphBRKYdAid7kjM9wrxcfugkVk0lkqZ H2+DkHNz3ykvjHu0YCUGanbddCGt3fOv+st3LXnu8iTyyETaR2XRyS/Ruwm/q5P1Q1Ew KbVP7Ts+Zh7RPxA6fXlSA/jrfEu4/F55PNyxJ8nA+vw1qW7dqt6FTjEypZnpVqfNhsR5 XArA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=zj4291g6uOrD0xUvEsbbSf9Ldg6TqIVT4PmrCRUC1Ig=; b=yCttCiRAb6CeISQrusUs2PECDfI1q79WBWNuFKmyHIaFlkjvxap8Fsz3516Q9n5s7P 1zZhXHSpHl0okSbA4ODQzREYlm4PLG+AbUTZUQ6u/CMZPYmuz4oMASTEFTgv4m0l5uZl +2j4ipD4P3vQuqkpnGHTqJwoLCDxh0oJQivRa4YkLITMfTCyEuYAeDTVEQrr+0Sf1ftC lki9r4oGyZUAeCRBYdSIg/Er0QkjP6MBaphYvt2rdcUM34lexYhvPemjbNzv7IhjL6Kc 77NuKtyB+D8nodcCzgAIBn5P5zgy8o1unVCyp1S6W/I6T3aWKY0kFsVUr5CTqIVJLIrA h9sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fcDrWUYN; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n3si2409256edt.249.2021.07.29.03.32.29; Thu, 29 Jul 2021 03:33:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fcDrWUYN; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235445AbhG2KcN (ORCPT + 99 others); Thu, 29 Jul 2021 06:32:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235309AbhG2KcM (ORCPT ); Thu, 29 Jul 2021 06:32:12 -0400 Received: from mail-qv1-xf2f.google.com (mail-qv1-xf2f.google.com [IPv6:2607:f8b0:4864:20::f2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D603CC061765 for ; Thu, 29 Jul 2021 03:32:08 -0700 (PDT) Received: by mail-qv1-xf2f.google.com with SMTP id kj19so2382558qvb.0 for ; Thu, 29 Jul 2021 03:32:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=zj4291g6uOrD0xUvEsbbSf9Ldg6TqIVT4PmrCRUC1Ig=; b=fcDrWUYN+hcOHoboPhHeZT4zGRcYLLueHREHhfA0vJz7dk6jNfENA5Cn72Kn32I4R7 UX4rXXwJ9MrM0/VqjpCob1ottBoiJLh0tKeNOkcM57XT1xGA3slHkjrrveettlZlCch4 Vdh6v0qFwtD91+yD9kIbydTKFQB5VwDhUY7w9OPfTJAesUpYkT5LSEwAAFQUxfyfDFvt ZFt3mnrP6kMiiHHaDKo+F5wL/ZoxOhdd6gXBEJ5wzI2eA7aCGuoj8YEXOhOObOUqgaht zaexJ6EzQbBLprlwugBViC07htgPfOpf8w43F7lwoyuWnWp0tIKaziWaq7TSCkliyvBb 1mdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=zj4291g6uOrD0xUvEsbbSf9Ldg6TqIVT4PmrCRUC1Ig=; b=UOqywiyZ1DBH7iTSFfHk5AiHqdStzGtaJ+wXRw0ISReIq/wA19DOR2FfaKUV1oUdJ6 Aw6id7MYfmdik0zlf1+T0X/oAjPG8JGPpVJWxPwMad9ANxJRgWti1W3VKKVrzL+rMN/U R/K9zEdIL4iGIwzpn2XesUfrS4BvF4H3pJjsVzeI0ooibQl/IuizbR3S1C8Cdp452vcR h52y4SYRxW83ThzzjeVG93KVKoy9jeOR4koJJkytXttyfFR5qbMzSvzz4r7k6kzSNKiI 6uRfph0RGEzPGox1eLbedG1seyoiQv+djyg8yYsjt26f5A/FwvXcPBEDEBSxZnvy9fyE Jk4Q== X-Gm-Message-State: AOAM531wZNu8J2AvwampqWnbf87azD3sHF5BrV8M72wJ6wObw3/9xFzz 0m8QPMR25m1EXKNrzJYzvBlpxV+ufRJWeQ== X-Received: by 2002:ad4:5bec:: with SMTP id k12mr4536985qvc.5.1627554727541; Thu, 29 Jul 2021 03:32:07 -0700 (PDT) Received: from [192.168.1.93] (pool-71-163-245-5.washdc.fios.verizon.net. [71.163.245.5]) by smtp.gmail.com with ESMTPSA id o15sm1061935qtp.25.2021.07.29.03.32.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Jul 2021 03:32:07 -0700 (PDT) Subject: Re: Extending CRYPTO_ALG_OPTIONAL_KEY for cipher algorithms To: Gilad Ben-Yossef , Eric Biggers Cc: Herbert Xu , Linux Crypto Mailing List References: From: Thara Gopinath Message-ID: <42d22781-be50-174d-033a-bac0ed5efffb@linaro.org> Date: Thu, 29 Jul 2021 06:32:06 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On 7/24/21 5:42 AM, Gilad Ben-Yossef wrote: > On Fri, Jul 23, 2021 at 7:20 PM Eric Biggers wrote: >> >> On Fri, Jul 23, 2021 at 06:13:50AM -0400, Thara Gopinath wrote: >>> Hi >>> >>> I have a requirement where the keys for the crypto cipher algorithms are >>> already programmed in the h/w pipes/channels and thus the ->encrypt() >>> and ->decrypt() can be called without set_key being called first. >>> I see that CRYPTO_ALG_OPTIONAL_KEY has been added to take care of >>> such requirements for CRC-32. My question is can the usage of this flag >>> be extended for cipher and other crypto algorithms as well. Can setting of >>> this flag indicate that the algorithm can be used without calling set_key >>> first and then the individual drivers can handle cases where >>> both h/w keys and s/w keys need to be supported. >> >> CRYPTO_ALG_OPTIONAL_KEY isn't meant for this use case, but rather for algorithms >> that have both keyed and unkeyed versions such as BLAKE2b and BLAKE2s, and also >> for algorithms where the "key" isn't actually a key but rather is an initial >> value that has a default value, such as CRC-32 and xxHash. >> >> It appears that that the case you're asking about is handled by using a >> different algorithm name, e.g. see the "paes" algorithms in >> drivers/crypto/ccree/cc_cipher.c. > > Yeap, seems like another use case for "protected keys" like CryptoCell > and the IBM mainframe. > I gave a talk about this you might find useful - > https://www.youtube.com/watch?v=GbcpwUBFGDw > > Feel free to contact me if you have questions. Thanks Eric and Gilad for the pointers. Gilad, the talk is great. I wish I had seen it prior to telling my manager that we will have to "invent" something new for this! This should mostly suffice for my use-case. Although, I see that all the protected implementations are for aes algorithms. Is it fair to say that it can be extended to other cipher algorithms and/or hash algorithms if needed ? > > Cheers, > Gilad > -- Warm Regards Thara (She/Her/Hers)