From patchwork Wed Mar 23 15:05:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 8650771 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3C5B29F44D for ; Wed, 23 Mar 2016 15:05:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4D2AE20211 for ; Wed, 23 Mar 2016 15:05:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DE5542025A for ; Wed, 23 Mar 2016 15:05:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753574AbcCWPFu (ORCPT ); Wed, 23 Mar 2016 11:05:50 -0400 Received: from mail-bl2on0074.outbound.protection.outlook.com ([65.55.169.74]:6615 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753113AbcCWPFs (ORCPT ); Wed, 23 Mar 2016 11:05:48 -0400 Received: from BLUPR0301CA0020.namprd03.prod.outlook.com (10.162.113.158) by BLUPR0301MB1585.namprd03.prod.outlook.com (10.162.214.19) with Microsoft SMTP Server (TLS) id 15.1.447.10; Wed, 23 Mar 2016 15:05:46 +0000 Received: from BN1BFFO11FD019.protection.gbl (2a01:111:f400:7c10::1:185) by BLUPR0301CA0020.outlook.office365.com (2a01:111:e400:5259::30) with Microsoft SMTP Server (TLS) id 15.1.443.12 via Frontend Transport; Wed, 23 Mar 2016 15:05:46 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=none action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1BFFO11FD019.mail.protection.outlook.com (10.58.144.82) with Microsoft SMTP Server (TLS) id 15.1.443.6 via Frontend Transport; Wed, 23 Mar 2016 15:05:46 +0000 Received: from enigma.ea.freescale.net (enigma.ea.freescale.net [10.171.77.120]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id u2NF5fsh030921; Wed, 23 Mar 2016 08:05:44 -0700 From: Tudor Ambarus To: CC: , , , , Tudor Ambarus Subject: [PATCH v2 1/3] crypto: scatterwak - Add scatterwalk_sg_copychunks Date: Wed, 23 Mar 2016 17:05:37 +0200 Message-ID: <1458745539-1252-2-git-send-email-tudor-dan.ambarus@nxp.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1458745539-1252-1-git-send-email-tudor-dan.ambarus@nxp.com> References: <1458745539-1252-1-git-send-email-tudor-dan.ambarus@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131032191466591654; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(77096005)(1220700001)(81166005)(1096002)(85426001)(87936001)(11100500001)(47776003)(105606002)(104016004)(586003)(50226001)(50466002)(48376002)(2906002)(33646002)(229853001)(189998001)(36756003)(6806005)(50986999)(4326007)(76176999)(110136002)(2351001)(2950100001)(5003940100001)(19580395003)(5008740100001)(106466001)(86362001)(19580405001)(92566002)(7059030)(4720700001); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR0301MB1585; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD019; 1:pgx5nCDKkjXmFnbxcR0lukuFZTyAFYktwa+yq9eUYKe8oWkL9Jk8m1os+6v+KRSCoJbn5ox61k0ijIn7U2VJxilpZIHmJWHVZ+qXEolDcHqLbhUgWooTeGmDTTpcI1uxQbOeP5JwRW6HbHYOokeX+ofR7rn/xc5N0wivo0cEIFeZPqBmT7mojuCuPs6IFW7pL4ar7vlwDJMsskiia52HQONiR9AjD3BNQPeLouYwPiKrsgStK3XNDR05xEaKjNdq8JzZlZ76vha+ei1PCxrx6NC6+HQ7xgpxGKJ2ccNi+zv7q5zLAX2OaG76mlHQibgqq8os3iB4NHj/HcYk+4a9+3PH4U4bJsWsh9z41kmMFvmyfCeV+inRbjwSGiPIyacxqSXRY99TowzHZy9EFlxO+riTqu75gRlBnOa+66kqk8MPqnv6p1bRPpw/2voF8MO4Rd0lYLi6+HmcV/JbkYgPMuwU+GSI53i8tePxk3oo5FwXoqEiq5+CM0YkoNNEqlK7eAiCO0qC1Q34Em08M9yfm3QzldOiUtTb55WMBC2XvYYAjcOusNNXKx37nC6mZlkwyf5MEhhY6Gm0sBqgM5TT9JiTFE864A0syViRgBxV8doLeYd5m0fdzcOEPYmFpP1ZZm8z07E+L7xtaZqZSyqRcrNuG4W7AFkps6he/aErBV8= MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 3383297b-72f2-413b-7447-08d3532c9cf6 X-Microsoft-Exchange-Diagnostics: 1; BLUPR0301MB1585; 2:Pc1j6O7TrD1Z84XeIr/YA/L/PvCRMaLPobc0Y+NX7+0j+83uIZ9gnzPRoj5F9Eu4DM+8OUVu8slsKSz3vRheYPcifaHMJaNxntv5FWgFfLR8OETacrkzz9xpIlF+sFk/ixrwk3HZbRUSmNuQjWy82cGmiC3r1MOiCY7JX2b/anzdh0z75n16mQ9Erpvy5fGZ; 3:WcMkC5yIHO10T2Bui8m132TDkzIxe4Yr9muf8PcqdYCxv+iX8BWiGBReay7K88e2nEjX7qwvMCLO6OkNNgqhLgV+FX+i/d+g5Vue7o4gA+LCbiZNFZSiTykv3obDCW74DHqB3byrCsHgL02jJOKhrTiyW24oZobBl/KIYeNu/LB/ovsL7YnCL6Q1CDIuAXE8ka/eweTtPBaMFKb8lcfeSs2jqyX+Vvp7Dbd/cAbFfzI= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR0301MB1585; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0301MB1585; 25:rBtGEw7U8MdfuEdAHWR6XNz3fsWeNb4DCcwmGePFkW44olZZUHiKhH6LG2z6w42j4A8pru7th1OZm8Kj4BwuWIAo26hMPIa+4BUl/+G2BO1lkUzBXHOqs37/WEUIZMmN97cbYwKFApNzAFVV50TZRfqixsVIRsLdpr+oB4ahEfQd20yG+zAfU4eGHiucNqO2Nf5s+lAyzsVSMUfJW9Ml2ekhjmNzQr4al3lNmLPxNP7+FbJTUP16QWVek+5KevuLU10UXrH+gnI4XrT5FFQ9z5g77s5OdWuKEcojMWlzWQVmLt4jtpPL/Ed4WS/Kbh8tOnRWobzF685H7G2dVoVCxDtWPgQ6LJ04x88oUyVBwFJ8ozvYZQ9nuHi3BgND/DAZkT48pKe7Bd0j4kGaqAOVqJOdp8JNq/sbFEOjJbfAjcbOlfD1eQ3b5Mu1uHEx0VUCxgXN2nJFIZToZW339MeydxjFOL0FLF0MTfGTK+CjkPBQeqCXjiZvtmXgkIR+Nmq0JxyIwFOt00hrdrTP+Wc9d2mE3/MHplHW8rHqjqRWmT8= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13015025)(13024025)(5005006)(13023025)(13017025)(13018025)(8121501046)(3002001)(10201501046); SRVR:BLUPR0301MB1585; BCL:0; PCL:0; RULEID:(400006); SRVR:BLUPR0301MB1585; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0301MB1585; 4:fyU9YZBg0BqicHnKsBH+scnEgySp/e4COE+lfkYEupV/ceqYpRHJ+Qs9ag58sf6MhWq7c5HhxaKexmxyJl/FYgMWTGItcbea74frBc9tV9bed9FQXloLtLj9ApYZDTRHYwy1eQLfBWuLzemNmuxvgfq+RCUlVDf80WNgup+46v9UxcOnFo9Xt0Fl1fPXEI+b4CaAB+f+K2i49Yv9hEWbFJ2Q7X9v3LMaG4Nq7WH/pldg7QQzpn6tf283IOrkKz+OZui4i40B+Gece06LOLwUx/WWVRXqC8IJ5UbajwgJTGnJxSsr0c0xqVGyBQh2s+4NQhUIBf/q3G0rLLKERJHtWpILa9XhrSBKt5N3Qg1xpK9KIwdSMwuY+6sJ3zXa0bFeFE/E13EX6uU35syyhDpo4kUHw9D5t8uQYO0reLy8N1TDiCqqWsqewrgJ02z5UqZRGdFsZufpp1nsqeYDRouNow== X-Forefront-PRVS: 08902E536D X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR0301MB1585; 23:iSs9B3+qLwMLwqIdCQwga5FUHSh/BUuAypTeO13?= =?us-ascii?Q?C9mqMSczPXNmosyW8ISm7MLncc2T4033/cQXzdtg1qJl3oxond3CeI2FXjCi?= =?us-ascii?Q?nkclp8Ys2cjlzhWFM2s5GUsypbgSlnKGvuiYZHDwpqQqJ7ikqsYQekJrt6bS?= =?us-ascii?Q?vbOX2aq5EOhxkAcsdgTLGR/EmnkcA4kVGdLJ3aEPzoCPPPeT9IyI9TDx3Xyo?= =?us-ascii?Q?c17k9wOmG97bQ9IoQmcGxm39IUx+baVCCEoaQzLmSXz24slMU0cq1EXe7vfe?= =?us-ascii?Q?CUrhEP5AtkY1xniRbaGetCgAEmNKaqPVFsZuB8YBxb1lupNZJGtQNaaOzqJx?= =?us-ascii?Q?6/yXb3tLxOq5qAhnGjVxkJEUPK1/w0ujzMHq+pr+kvd6pUIOgACq2prd6ZLs?= =?us-ascii?Q?3BHktQL87bXnySEwj5/EwtY93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sS4eUtZZ5Ppvnk+rzgMaMPBJxGMfBd3FUWRf1kZ9GyiQ+Y1TjdA2G/ohn9lIe7IHPO6eM7pFxDmZRIFY+Ayaq39YX2SgDzYJJSJs= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2016 15:05:46.4563 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0301MB1585 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds the function scatterwalk_sg_copychunks which writes a chunk of data from a scatterwalk to another scatterwalk. It will be used by caam driver to remove the leading zeros of RSA's algorithm output. Signed-off-by: Tudor Ambarus Acked-by: Cristian Stoica --- crypto/scatterwalk.c | 26 ++++++++++++++++++++++++++ include/crypto/scatterwalk.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/crypto/scatterwalk.c b/crypto/scatterwalk.c index ea5815c..bc3222d 100644 --- a/crypto/scatterwalk.c +++ b/crypto/scatterwalk.c @@ -125,6 +125,32 @@ void scatterwalk_map_and_copy(void *buf, struct scatterlist *sg, } EXPORT_SYMBOL_GPL(scatterwalk_map_and_copy); +void scatterwalk_sg_copychunks(struct scatter_walk *dest, + struct scatter_walk *src, size_t nbytes) +{ + for (;;) { + unsigned int len_this_page = scatterwalk_pagelen(dest); + u8 *vaddr; + + if (len_this_page > nbytes) + len_this_page = nbytes; + + vaddr = scatterwalk_map(dest); + scatterwalk_copychunks(vaddr, src, len_this_page, 0); + scatterwalk_unmap(vaddr); + + scatterwalk_advance(dest, len_this_page); + + if (nbytes == len_this_page) + break; + + nbytes -= len_this_page; + + scatterwalk_pagedone(dest, 0, 1); + } +} +EXPORT_SYMBOL_GPL(scatterwalk_sg_copychunks); + int scatterwalk_bytes_sglen(struct scatterlist *sg, int num_bytes) { int offset = 0, n = 0; diff --git a/include/crypto/scatterwalk.h b/include/crypto/scatterwalk.h index 35f99b6..8b799c5 100644 --- a/include/crypto/scatterwalk.h +++ b/include/crypto/scatterwalk.h @@ -86,6 +86,8 @@ static inline void scatterwalk_unmap(void *vaddr) void scatterwalk_start(struct scatter_walk *walk, struct scatterlist *sg); void scatterwalk_copychunks(void *buf, struct scatter_walk *walk, size_t nbytes, int out); +void scatterwalk_sg_copychunks(struct scatter_walk *dest, + struct scatter_walk *src, size_t nbytes); void *scatterwalk_map(struct scatter_walk *walk); void scatterwalk_done(struct scatter_walk *walk, int out, int more);