From patchwork Sun Nov 16 02:25:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephan Mueller X-Patchwork-Id: 5312821 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E0291C11AC for ; Sun, 16 Nov 2014 02:48:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 26AE92020E for ; Sun, 16 Nov 2014 02:48:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 44245201FA for ; Sun, 16 Nov 2014 02:48:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932414AbaKPCst (ORCPT ); Sat, 15 Nov 2014 21:48:49 -0500 Received: from mail.eperm.de ([89.247.134.16]:54597 "EHLO mail.eperm.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932337AbaKPCst (ORCPT ); Sat, 15 Nov 2014 21:48:49 -0500 X-AuthUser: sm@eperm.de Received: from tachyon.chronox.de by mail.eperm.de with [XMail 1.27 ESMTP Server] id for from ; Sun, 16 Nov 2014 03:48:46 +0100 From: Stephan Mueller To: Herbert Xu Cc: Daniel Borkmann , quentin.gouchet@gmail.com, LKML , linux-crypto@vger.kernel.org, ABI/API Subject: [PATCH v2 03/10] crypto: AF_ALG: extend data structuers for AEAD Date: Sun, 16 Nov 2014 03:25:07 +0100 Message-ID: <3559156.AeU3gNGqyG@tachyon.chronox.de> User-Agent: KMail/4.14.2 (Linux/3.17.2-300.fc21.x86_64; KDE/4.14.2; x86_64; ; ) In-Reply-To: <5365136.g8vbXlhRyC@tachyon.chronox.de> References: <5365136.g8vbXlhRyC@tachyon.chronox.de> MIME-Version: 1.0 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 The data structure holding the state of an ongoing symmetric cipher operation is extended by the data variables needed for AEAD. The request data structures are encapsulated by a union as the symmetric cipher implementation is either exclusively used for "normal" symmetric ciphers or for AEAD ciphers. The define MAX_AEAD_ASSOCLEN restricts the size of the associated authentication data. The kernel must allocate memory for this data to be stored for the cipher operation. To prevent an excessive use of memory, it is limited to 128 bytes, which is considered to be a sensible size. Signed-off-by: Stephan Mueller --- crypto/algif_skcipher.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c index 2f5d663..483ff97 100644 --- a/crypto/algif_skcipher.c +++ b/crypto/algif_skcipher.c @@ -46,7 +46,15 @@ struct skcipher_ctx { bool merge; bool enc; - struct ablkcipher_request req; + bool aead; + void *aead_assoc; + /* define arbitrary maximum length of associated data */ + #define MAX_AEAD_ASSOCLEN 128 + struct scatterlist sg_aead_assoc; + union { + struct ablkcipher_request ablkcipher_req; + struct aead_request aead_req; + } u; }; #define MAX_SGL_ENTS ((4096 - sizeof(struct skcipher_sg_list)) / \