From patchwork Tue Jul 20 08:55:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 12387861 Return-Path: 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 F4042C07E95 for ; Tue, 20 Jul 2021 09:00:13 +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 B43C261209 for ; Tue, 20 Jul 2021 09:00:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B43C261209 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=O3CT4hkGPV8a98Y1wuqbED7JZjxObm162i03W+7giKU=; b=DZLJTsFOaGbRZU BdAto8397r/WrD0IhEA0R+0XMbFGnzv8sabde/MrZBtwuPTStpPhbuQKCWBr2BZokv3rHHirqIvHX sKYLqnJ6AW8k0uZktf+iGIaFA6EepKYbQ6MxuIekgQm3K3MYtmlhGaFaiBysmZgS1EOX+r5wQSgr+ PdmjG4r4LBqUvT1fMTmjzANU1sen92ojC3KeIi56y4PXNtaQBG+6fmxs6enrdSXUjYBC3UUpUq4Xv Ms4lI+wQeQXHwrTeHsMT+OfguGaiuW9ROUv38Fwu19E4EZJAc3/RCRd6w8ArV00M610iTsToKQBtv ZRIAlWpa8SXhtRMWcu6g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5lZt-00CJqI-Ny; Tue, 20 Jul 2021 08:58:14 +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 1m5lXl-00CIvs-2Y for linux-arm-kernel@lists.infradead.org; Tue, 20 Jul 2021 08:56:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1626771360; x=1658307360; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hMQlggUrirVIcSbH7jafoxnVILBXmaSZMhuayGiT/58=; b=FlU4GAob1nB/JgEMShqQubPNvqKuZ+ezlnSKo+720XQIRNpkejvCgNr2 ceHgcxZBLwbAfvJt48nxUiN9r9sacZetrFGJUyD6l6uLL9CwFtWmWeu9b N7bSv/fZISBw3JLlECzLNwF+nbiM0aSCWVl7FoSg30OlyK4rK6TaYXpg+ 0E08QpMLuCWwVcTamZPJ8C95Bn7fsB64UkPQylNJeO7YnJrSi+t8kP7T8 WlaW1N2B6itf5QIIW5+5ugNqqJS84WwzvZAYiFUFjikAP9Qr+uP4UxBmp l1tloVT8ee+6m7CUTuveqp50Lj/VYMuGy8rrEpoIQ7yu0maUvh3RrYOMh A==; IronPort-SDR: 6zlPvAO0PXHEnOgBYb5IhEiV4a84h/kTVO6NUlwikapZKe+zPAJoSrZdkIjJm5LI/aZQ8+0PCj m1iAPQowDoX1yteEBc0FeT2K7DqyT5nm5MFizGdje/NU7vKbNjRv3W4QpOJ0yfKf8XsSD6Na3d yWdqKvLTsq6LXUJSE06xWaGoTkczRToaKMx58bmLIPSab6eDzSTEhalA4+UhTYo/Y5JHSGrPxp WFwCePewssEORB1jeCLIr/JXoJQubjwqL0mUkISjhAmRMfqZD64EkPgltw4EppwGNNgqM/zuWd Y20Mlxy1fwJ37wGxfttjf84Q X-IronPort-AV: E=Sophos;i="5.84,254,1620716400"; d="scan'208";a="122687352" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 20 Jul 2021 01:56:00 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex04.mchp-main.com (10.10.85.152) 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:54 -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:51 -0700 From: Tudor Ambarus To: Subject: [PATCH 6/9] crypto: atmel-tdes: Add FIPS81's zero length cryptlen constraint Date: Tue, 20 Jul 2021 11:55:32 +0300 Message-ID: <20210720085535.141486-7-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_015601_237668_ACBF06F8 X-CRM114-Status: UNSURE ( 9.10 ) 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alexandre.belloni@bootlin.com, Tudor Ambarus , linux-kernel@vger.kernel.org, ludovic.desroches@microchip.com, linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org FIPS81 requires for the ECB, CBC, CFB, and OFB modes that the plaintext and ciphertext to have a positive integer length. Add this constraint and just return 0 for a zero length cryptlen. Signed-off-by: Tudor Ambarus --- drivers/crypto/atmel-tdes.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/crypto/atmel-tdes.c b/drivers/crypto/atmel-tdes.c index abbf1b7a75ab..8380e0ab149a 100644 --- a/drivers/crypto/atmel-tdes.c +++ b/drivers/crypto/atmel-tdes.c @@ -682,6 +682,9 @@ static int atmel_tdes_crypt(struct skcipher_request *req, unsigned long mode) struct atmel_tdes_reqctx *rctx = skcipher_request_ctx(req); struct device *dev = ctx->dd->dev; + if (!req->cryptlen) + return 0; + switch (mode & TDES_FLAGS_OPMODE_MASK) { case TDES_FLAGS_CFB8: if (!IS_ALIGNED(req->cryptlen, CFB8_BLOCK_SIZE)) {