From patchwork Tue Mar 4 05:28:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 25649 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qg0-f72.google.com (mail-qg0-f72.google.com [209.85.192.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2F99620540 for ; Tue, 4 Mar 2014 05:29:05 +0000 (UTC) Received: by mail-qg0-f72.google.com with SMTP id q107sf12240320qgd.3 for ; Mon, 03 Mar 2014 21:29:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=Fmis0YOXi1T3gIGCc056Pkefl2nJtUt9K06jhoUXuuw=; b=mY9DqiHVz0B1nF8TmaAkDfKwyBy8q2HYt5xptjq5rm1MIHcbSqboJsHy5Ieagym6zw 17A+OnengOgLyL9GNvh7b2lzd0iQFMt/SKaxTVaWoHk4pzvGM1ouNDX8TMqkPI7h5mI1 KNpvhBgswoDwdzzN3TpMwdQbWUKyfm77o3j6UvqT6wcIlV7DT6eX9eqY8EtlxjW/1xQL LMAqZ+L14HMxGKMgegiMXTgZH8ghAigULR33wTObFjO3i5Zn4ilL3JW+GEXXI1j6BisB E+uF/+44osH9o8G5XFNkt9TwLS2t4q+0xlSg4AA13iP+nAA3Aw6Gi0Zb600VAe3FflOu N/WA== X-Gm-Message-State: ALoCoQm+g5IGvIQ+5OknadjaOfmwVsH6VO7LgkpGkIzfJW2QPv2AJIoh5NN0CrsNvxQ1zCJCrLiw X-Received: by 10.236.102.8 with SMTP id c8mr9792774yhg.5.1393910944971; Mon, 03 Mar 2014 21:29:04 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.36.7 with SMTP id o7ls2480358qgo.15.gmail; Mon, 03 Mar 2014 21:29:04 -0800 (PST) X-Received: by 10.52.164.39 with SMTP id yn7mr2386914vdb.25.1393910944918; Mon, 03 Mar 2014 21:29:04 -0800 (PST) Received: from mail-ve0-f170.google.com (mail-ve0-f170.google.com [209.85.128.170]) by mx.google.com with ESMTPS id dc20si3958394vec.118.2014.03.03.21.29.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 03 Mar 2014 21:29:04 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.170; Received: by mail-ve0-f170.google.com with SMTP id pa12so5061517veb.29 for ; Mon, 03 Mar 2014 21:29:04 -0800 (PST) X-Received: by 10.52.101.135 with SMTP id fg7mr2374373vdb.17.1393910944829; Mon, 03 Mar 2014 21:29:04 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.130.193 with SMTP id u1csp103116vcs; Mon, 3 Mar 2014 21:29:04 -0800 (PST) X-Received: by 10.68.137.136 with SMTP id qi8mr23913898pbb.79.1393910943803; Mon, 03 Mar 2014 21:29:03 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id io5si12854712pbc.324.2014.03.03.21.29.03; Mon, 03 Mar 2014 21:29:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751323AbaCDF3C (ORCPT + 1 other); Tue, 4 Mar 2014 00:29:02 -0500 Received: from mail-pd0-f173.google.com ([209.85.192.173]:36975 "EHLO mail-pd0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751185AbaCDF3B (ORCPT ); Tue, 4 Mar 2014 00:29:01 -0500 Received: by mail-pd0-f173.google.com with SMTP id z10so4658893pdj.18 for ; Mon, 03 Mar 2014 21:29:01 -0800 (PST) X-Received: by 10.66.228.201 with SMTP id sk9mr3813282pac.134.1393910941272; Mon, 03 Mar 2014 21:29:01 -0800 (PST) Received: from ards-macbook-pro.local (z88l218.static.ctm.net. [202.175.88.218]) by mx.google.com with ESMTPSA id sy2sm42964161pbc.28.2014.03.03.21.28.58 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 03 Mar 2014 21:29:00 -0800 (PST) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org, herbert@gondor.apana.org.au Cc: Ard Biesheuvel Subject: [RFC PATCH 2/3] crypto: allow blkcipher walks over AEAD data Date: Tue, 4 Mar 2014 13:28:39 +0800 Message-Id: <1393910920-5796-3-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1393910920-5796-1-git-send-email-ard.biesheuvel@linaro.org> References: <1393910920-5796-1-git-send-email-ard.biesheuvel@linaro.org> Sender: linux-crypto-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This adds the function blkcipher_aead_walk_virt_block, which allows the caller to use the blkcipher walk API to handle the input and output scatterlists. Signed-off-by: Ard Biesheuvel --- crypto/blkcipher.c | 14 ++++++++++++++ include/crypto/algapi.h | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/crypto/blkcipher.c b/crypto/blkcipher.c index 46fdab5e9cc7..0122bec38564 100644 --- a/crypto/blkcipher.c +++ b/crypto/blkcipher.c @@ -357,6 +357,20 @@ int blkcipher_walk_virt_block(struct blkcipher_desc *desc, } EXPORT_SYMBOL_GPL(blkcipher_walk_virt_block); +int blkcipher_aead_walk_virt_block(struct blkcipher_desc *desc, + struct blkcipher_walk *walk, + struct crypto_aead *tfm, + unsigned int blocksize) +{ + walk->flags &= ~BLKCIPHER_WALK_PHYS; + walk->walk_blocksize = blocksize; + walk->cipher_blocksize = crypto_aead_blocksize(tfm); + walk->ivsize = crypto_aead_ivsize(tfm); + walk->alignmask = crypto_aead_alignmask(tfm); + return blkcipher_walk_first(desc, walk); +} +EXPORT_SYMBOL_GPL(blkcipher_aead_walk_virt_block); + static int setkey_unaligned(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) { diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h index d9d14a0f0653..016c2f110f63 100644 --- a/include/crypto/algapi.h +++ b/include/crypto/algapi.h @@ -195,6 +195,10 @@ int blkcipher_walk_phys(struct blkcipher_desc *desc, int blkcipher_walk_virt_block(struct blkcipher_desc *desc, struct blkcipher_walk *walk, unsigned int blocksize); +int blkcipher_aead_walk_virt_block(struct blkcipher_desc *desc, + struct blkcipher_walk *walk, + struct crypto_aead *tfm, + unsigned int blocksize); int ablkcipher_walk_done(struct ablkcipher_request *req, struct ablkcipher_walk *walk, int err);