Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752084AbbEFLbs (ORCPT ); Wed, 6 May 2015 07:31:48 -0400 Received: from mail-bl2on0112.outbound.protection.outlook.com ([65.55.169.112]:21024 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751384AbbEFLbp (ORCPT ); Wed, 6 May 2015 07:31:45 -0400 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; intel.com; dkim=none (message not signed) header.d=none; Message-ID: <5549FB94.6020601@freescale.com> Date: Wed, 6 May 2015 14:31:32 +0300 From: =?UTF-8?B?SG9yaWEgR2VhbnTEgw==?= User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Tadeusz Struk , CC: , , , , , , , , , , , , , , , Subject: Re: [PATCH RFC 0/2] crypto: Introduce Public Key Encryption API References: <20150430223647.10157.82156.stgit@tstruk-mobl1> <55477111.2050803@freescale.com> <5547D9A3.9060800@intel.com> In-Reply-To: <5547D9A3.9060800@intel.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.88.158.2;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(339900001)(189002)(51704005)(199003)(164054003)(377454003)(24454002)(479174004)(65816999)(5001960100002)(6806004)(36756003)(120886001)(50466002)(50986999)(76176999)(87266999)(54356999)(5001770100001)(65956001)(65806001)(4001350100001)(92566002)(86362001)(23676002)(189998001)(47776003)(33656002)(2950100001)(83506001)(46102003)(105606002)(64126003)(106466001)(77156002)(62966003)(104016003)(77096005)(85426001)(85182001)(87936001)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:BL2PR03MB385;H:az84smr01.freescale.net;FPR:;SPF:Fail;MLV:sfv;MX:1;A:1;LANG:en; X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BL2PR03MB385; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:BL2PR03MB385;BCL:0;PCL:0;RULEID:;SRVR:BL2PR03MB385; X-Forefront-PRVS: 0568F32D91 X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2015 11:31:42.8688 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.158.2];Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2PR03MB385 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2008 Lines: 51 On 5/4/2015 11:42 PM, Tadeusz Struk wrote: > Hi Horia, > On 05/04/2015 06:16 AM, Horia Geantă wrote: >>> int (*sign)(struct pke_request *pkereq); >>>> int (*verify)(struct pke_request *pkereq); >>>> int (*encrypt)(struct pke_request *pkereq); >>>> int (*decrypt)(struct pke_request *pkereq); >> Where would be the proper place for keygen operation? > > This will need to be extended to support keygen. > >> >> AFAICT algorithms currently map to primitives + encoding methods, which >> is not flexible. For e.g. current RSA implementation hardcodes the >> PKCS1-v1_5 encoding method, making it hard to add OAEP(+) etc. >> >> One solution would be to map algorithms to primitives only. Encoding >> methods need to be abstracted somehow, maybe using templates to wrap the >> algorithms. > > So far there is only one rsa implementation in kernel and it is only used > by module signing code. > Later we can add templates or simply one can register "oaep-rsa" algorithm. I am thinking that it would be more logical for "rsa" to represent only the *primitives*, for e.g. RSASP1, RSAVP1, RSAEP, RSADP (in rfc3447 terminology). Then pkcs1_v15(rsa), oaep(rsa), pss(rsa) (i.e. RSAES-PKCS1-v1_5, RSAES-OAEP, RSASSA-PSS encryption and/or signature schemes) would share the primitives implementation, the only thing that would differ being the encoding/padding method. This is similar to symmetric ciphers convention of having the mode defined as a wrapper: we have cbc(aes), ctr(aes), gcm(aes) and not cbc-aes, ctr-aes, gcm-aes. Another thing to consider is that there might be crypto engines which are able to perform only "textbook" rsa. This would allow for the primitives to be offloaded, while the encoding methods would be performed in SW. Thanks, Horia -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/