Message ID | 20210720085535.141486-6-tudor.ambarus@microchip.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <SRS0=8gqr=MM=lists.infradead.org=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@kernel.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93971C07E95 for <linux-arm-kernel@archiver.kernel.org>; Tue, 20 Jul 2021 08:58:23 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 67C0761209 for <linux-arm-kernel@archiver.kernel.org>; Tue, 20 Jul 2021 08:58:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 67C0761209 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+iKKmpyFqGR2KoopJOi5TAoGYhrhdhqwB4yLoYeCsw8=; b=PaLRlykPjdZCK3 2hIjwUsLjpWk1Lx2Vc/Hkn95R1hop+GA1Xo+hhyfcqQeYNbVAmXY9VWA0dkhoS28XPWmg14eFCof8 0QKguGqbix8fnthmwKm3rd+m0jJvYeP86LwbT68KVJ/MUg9WERgX62PArPbmP0OLvU5XsWTLLCLLD M2+pOYp6aFsQKOAH2PsHTqhpPCRleJIulracPa64A1zqRSMlcMIuyHgXckYTDxr+fS/ZMmgHHJ0OK z5um8s+3avEjDJGbz0MJs6fVWcDuij4Lx/yPTxR3P+IVBvPq4UbP9cqtefOefjMBgF9urzBudytiS uGQ6gRJs7i6uygKU8PQg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5lYM-00CJ8J-39; Tue, 20 Jul 2021 08:56:38 +0000 Received: from esa.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5lXc-00CIuK-Lm for linux-arm-kernel@lists.infradead.org; Tue, 20 Jul 2021 08:55:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1626771352; x=1658307352; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vcvACObpRITMXDzDHLitiZnMlmUTJastzPuxvVsqhm0=; b=DAWENFlHg0cxVLGivqGCcXKF9zctlUK7o27q6Thluzmw/OWYzqemiApp ExbORxXyiOrY+TtKxOpbKxCBcDx/K0N4fO2zd4ZtF6Wn41iyVHuTkREnI 8Fxcd416TYvv1RWJcros/DFMe8EgISukAL/fcvZs+xVx46PCrHhIZ5X3h emBYgkRBBUujO3CQ/Vu1EkK8mbBgTCN9hCdB7pb8lopu8QQluYKv781YU XPubRQtIHAoZ6wkml7J2s9RNL6KVpIplSOyjxyFJ5j6o1jzDoe/2glmFt nTqeyo3InMWUNgas8Qv5rgfokp4Bz1ddXMVVSNOtIfVrtdaS1Jk1TV3mB g==; IronPort-SDR: bDCKq+Uxxp+ORoo7I6MyAx8+kB3nGCL4yyy58aljvKBIC6FEjsv5MG23o+xcOlYXhfx65FpfWo oLNzhry+Pdn5zuGFO0jesGCuCEVP/iocJIc0U8oEV2+3+uJmjAG2pnvZW1soIfQ4tOvWMwl4Ng YS1Xd7M1faJ8+oH9k4vMXNqMgNTI5clSgZHal+d+0CbM0XSGwPhzotLDhf1CHfzUpXJu/0jlHj 7lAVIQI8CXqlj3r16sGuV2Kl1kQZK+5wpEWVufTp0a5EIypmRqvDYArJcEnMG4oWjW/n+7Z6qU fnjJ6oTf1C/0X6iEHM81nCad X-IronPort-AV: E=Sophos;i="5.84,254,1620716400"; d="scan'208";a="125187431" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 20 Jul 2021 01:55:51 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 20 Jul 2021 01:55:51 -0700 Received: from ROB-ULT-M18064N.mchp-main.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2176.2 via Frontend Transport; Tue, 20 Jul 2021 01:55:49 -0700 From: Tudor Ambarus <tudor.ambarus@microchip.com> To: <herbert@gondor.apana.org.au> Subject: [PATCH 5/9] crypto: atmel-aes: Add NIST 800-38A's zero length cryptlen constraint Date: Tue, 20 Jul 2021 11:55:31 +0300 Message-ID: <20210720085535.141486-6-tudor.ambarus@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210720085535.141486-1-tudor.ambarus@microchip.com> References: <20210720085535.141486-1-tudor.ambarus@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210720_015552_823394_4D74BE8E X-CRM114-Status: UNSURE ( 9.24 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: <linux-arm-kernel.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/> List-Post: <mailto:linux-arm-kernel@lists.infradead.org> List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe> Cc: alexandre.belloni@bootlin.com, Tudor Ambarus <tudor.ambarus@microchip.com>, linux-kernel@vger.kernel.org, ludovic.desroches@microchip.com, linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org> Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org |
Series |
crypto: atmel-{aes, tdes}: Fix corner cases - crypto self tests
|
expand
|
diff --git a/drivers/crypto/atmel-aes.c b/drivers/crypto/atmel-aes.c index 4e9515e8dd25..8ea873bf6b86 100644 --- a/drivers/crypto/atmel-aes.c +++ b/drivers/crypto/atmel-aes.c @@ -1094,6 +1094,13 @@ static int atmel_aes_crypt(struct skcipher_request *req, unsigned long mode) if (opmode == AES_FLAGS_XTS && req->cryptlen < XTS_BLOCK_SIZE) return -EINVAL; + /* + * ECB, CBC, CFB, OFB or CTR mode require the plaintext and ciphertext + * to have a positve integer length. + */ + if (!req->cryptlen && opmode != AES_FLAGS_XTS) + return 0; + if ((opmode == AES_FLAGS_ECB || opmode == AES_FLAGS_CBC) && !IS_ALIGNED(req->cryptlen, crypto_skcipher_blocksize(skcipher))) return -EINVAL;
NIST 800-38A requires for the ECB, CBC, CFB, OFB and CTR modes that the plaintext and ciphertext to have a positive integer length. Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com> --- drivers/crypto/atmel-aes.c | 7 +++++++ 1 file changed, 7 insertions(+)