From patchwork Tue May 14 21:53:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gary R Hook X-Patchwork-Id: 10943805 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 951CA924 for ; Tue, 14 May 2019 21:53:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 842592883A for ; Tue, 14 May 2019 21:53:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7733528852; Tue, 14 May 2019 21:53:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62BF22883A for ; Tue, 14 May 2019 21:53:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726201AbfENVxZ (ORCPT ); Tue, 14 May 2019 17:53:25 -0400 Received: from mail-eopbgr730042.outbound.protection.outlook.com ([40.107.73.42]:37024 "EHLO NAM05-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726134AbfENVxZ (ORCPT ); Tue, 14 May 2019 17:53:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1C0YuYwulnin0xUQwSoM8/2OwcjJ9GJ/npgXWcKxxbY=; b=yJFI+YN2sNK4HXJAbMxlrCzHTvloBdobE+bB0CTXZ+95yIy9ZN2nFJVU3Ua1kGcC1Q+H4I8u9sBBYMr7nOLZx6IRRunmjcJxPUYwzr0Ncd8pT3tZnV/VKsKI7FSFcCMwTc8PdyaSwHS9WNqrmOkANdB+ibCcpJARcxGEX4xHUEU= Received: from DM5PR12MB1449.namprd12.prod.outlook.com (10.172.40.14) by DM5PR12MB1659.namprd12.prod.outlook.com (10.172.40.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1878.24; Tue, 14 May 2019 21:53:17 +0000 Received: from DM5PR12MB1449.namprd12.prod.outlook.com ([fe80::11db:1b41:d1e6:c6dc]) by DM5PR12MB1449.namprd12.prod.outlook.com ([fe80::11db:1b41:d1e6:c6dc%11]) with mapi id 15.20.1878.024; Tue, 14 May 2019 21:53:16 +0000 From: "Hook, Gary" To: "linux-crypto@vger.kernel.org" CC: "Lendacky, Thomas" , "herbert@gondor.apana.org.au" , "davem@davemloft.net" Subject: [PATCH 1/3] crypto: ccp - AES CFB mode is a stream cipher Thread-Topic: [PATCH 1/3] crypto: ccp - AES CFB mode is a stream cipher Thread-Index: AQHVCp9vP3X3FAGv00iGOz/WeHJs8Q== Date: Tue, 14 May 2019 21:53:16 +0000 Message-ID: <155787079494.29723.7921582980150013941.stgit@taos> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SN1PR12CA0098.namprd12.prod.outlook.com (2603:10b6:802:21::33) To DM5PR12MB1449.namprd12.prod.outlook.com (2603:10b6:4:10::14) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Gary.Hook@amd.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [165.204.78.1] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e05955c2-85f4-4da5-eea8-08d6d8b691ca x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(4618075)(2017052603328)(7193020);SRVR:DM5PR12MB1659; x-ms-traffictypediagnostic: DM5PR12MB1659: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1091; x-forefront-prvs: 0037FD6480 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(7916004)(396003)(346002)(376002)(366004)(39860400002)(136003)(189003)(199004)(4326008)(9686003)(305945005)(25786009)(6486002)(5640700003)(6436002)(6512007)(73956011)(66446008)(66476007)(66556008)(64756008)(66946007)(186003)(7736002)(476003)(8936002)(72206003)(26005)(81166006)(8676002)(14454004)(81156014)(103116003)(486006)(478600001)(6916009)(66066001)(53936002)(86362001)(316002)(2351001)(2906002)(68736007)(33716001)(71190400001)(3846002)(6116002)(99286004)(71200400001)(2501003)(5660300002)(386003)(52116002)(6506007)(256004)(54906003)(102836004);DIR:OUT;SFP:1101;SCL:1;SRVR:DM5PR12MB1659;H:DM5PR12MB1449.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: MDWoPevmGfFZ5d+LSKKBugQXR5HeJnO5SRE3FTWAlgZoEkAksZiQiYwuklOJ8nn7cYU/h5XU/vez+U3PrRZhj9rtK+TioAlk0PBn94Bqczm8s739uJ2MiuSqLEiOAlh4aIvdQtQVOlYtvFtkBtCyKogQJ1/PuvTBjIcr9AdQw98jFYL7/H+mGIyEjSVbHh25vEMvfQBRtWAkh3J1U58/TXXpv9/P/IRQxrSDxfGYmZGjaijuO736BWuExvJCbVXjyZvOLX2k0jNNTKjP5imz+TPqo+ZSoGKJdbzxzwdxR/CwSKQFTX8SFESZ4P8h5jGPTZOBw3TVOBSssRq6GdF+RxrSEGc2YTQI2f8uHc19FSzRhdwJa1e1a9bjTBnonkxLAC4TYBs7PKEwwWSKZOkMMg9s9YAK15+5au8wTLyAtJY= Content-ID: MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: e05955c2-85f4-4da5-eea8-08d6d8b691ca X-MS-Exchange-CrossTenant-originalarrivaltime: 14 May 2019 21:53:16.7272 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1659 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP CFB mode should be treated as a stream cipher, not block. Fixes: 63b945091a07 ('crypto: ccp - CCP device driver and interface support') Signed-off-by: Gary R Hook --- drivers/crypto/ccp/ccp-ops.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/ccp/ccp-ops.c b/drivers/crypto/ccp/ccp-ops.c index 267a367bd076..3ecadeab919c 100644 --- a/drivers/crypto/ccp/ccp-ops.c +++ b/drivers/crypto/ccp/ccp-ops.c @@ -1,7 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /* * AMD Cryptographic Coprocessor (CCP) driver * - * Copyright (C) 2013,2018 Advanced Micro Devices, Inc. + * Copyright (C) 2013-2019 Advanced Micro Devices, Inc. * * Author: Tom Lendacky * Author: Gary R Hook @@ -893,8 +894,7 @@ static int ccp_run_aes_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) return -EINVAL; if (((aes->mode == CCP_AES_MODE_ECB) || - (aes->mode == CCP_AES_MODE_CBC) || - (aes->mode == CCP_AES_MODE_CFB)) && + (aes->mode == CCP_AES_MODE_CBC)) && (aes->src_len & (AES_BLOCK_SIZE - 1))) return -EINVAL; From patchwork Tue May 14 21:53:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gary R Hook X-Patchwork-Id: 10943807 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 65F6C924 for ; Tue, 14 May 2019 21:53:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 540BE2883A for ; Tue, 14 May 2019 21:53:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 484EC28852; Tue, 14 May 2019 21:53:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E403C2883A for ; Tue, 14 May 2019 21:53:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726211AbfENVx2 (ORCPT ); Tue, 14 May 2019 17:53:28 -0400 Received: from mail-eopbgr680075.outbound.protection.outlook.com ([40.107.68.75]:24207 "EHLO NAM04-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726134AbfENVx1 (ORCPT ); Tue, 14 May 2019 17:53:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hhrVvPG3cbYjZWIxrZT8cU3JGBhstOo9x1QesHGy6rU=; b=1NsL+8fh9Uo144sUhP8mRt/5LogKDcuDe6h30pzPghlqDedNRR4yaF0uikekDOUTLEVQKIPFBiQEAgfJHsIrJjquB4qadc2GcqKR3v36cEcqYrsU9lBHF+XxyoFj37y2Rtkimlv3gVFPJROW6ovSss3sWONB0ay5DYwZ7xpYwPc= Received: from DM5PR12MB1449.namprd12.prod.outlook.com (10.172.40.14) by DM5PR12MB2566.namprd12.prod.outlook.com (52.132.141.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1878.27; Tue, 14 May 2019 21:53:23 +0000 Received: from DM5PR12MB1449.namprd12.prod.outlook.com ([fe80::11db:1b41:d1e6:c6dc]) by DM5PR12MB1449.namprd12.prod.outlook.com ([fe80::11db:1b41:d1e6:c6dc%11]) with mapi id 15.20.1878.024; Tue, 14 May 2019 21:53:23 +0000 From: "Hook, Gary" To: "linux-crypto@vger.kernel.org" CC: "Lendacky, Thomas" , "herbert@gondor.apana.org.au" , "davem@davemloft.net" Subject: [PATCH 2/3] crypto: ccp - fix AES CFB error exposed by new test vectors Thread-Topic: [PATCH 2/3] crypto: ccp - fix AES CFB error exposed by new test vectors Thread-Index: AQHVCp9zNLfGOoWOpk6u1cgJIdU0ow== Date: Tue, 14 May 2019 21:53:23 +0000 Message-ID: <155787080186.29723.9592711756895297498.stgit@taos> References: <155787079494.29723.7921582980150013941.stgit@taos> In-Reply-To: <155787079494.29723.7921582980150013941.stgit@taos> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SN1PR12CA0079.namprd12.prod.outlook.com (2603:10b6:802:21::14) To DM5PR12MB1449.namprd12.prod.outlook.com (2603:10b6:4:10::14) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Gary.Hook@amd.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [165.204.78.1] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 827767f1-f9c8-483a-8e90-08d6d8b695ef x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(4618075)(2017052603328)(7193020);SRVR:DM5PR12MB2566; x-ms-traffictypediagnostic: DM5PR12MB2566: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3383; x-forefront-prvs: 0037FD6480 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(7916004)(396003)(366004)(136003)(39860400002)(346002)(376002)(199004)(189003)(6512007)(86362001)(52116002)(9686003)(99286004)(53936002)(6916009)(81156014)(76176011)(102836004)(72206003)(6116002)(3846002)(2906002)(6506007)(66556008)(66476007)(26005)(386003)(186003)(66946007)(73956011)(66446008)(64756008)(6486002)(6436002)(5640700003)(446003)(11346002)(476003)(71190400001)(71200400001)(486006)(4326008)(25786009)(14454004)(68736007)(256004)(14444005)(5660300002)(2501003)(8676002)(81166006)(103116003)(33716001)(54906003)(316002)(478600001)(7736002)(305945005)(66066001)(8936002)(2351001)(31153001);DIR:OUT;SFP:1101;SCL:1;SRVR:DM5PR12MB2566;H:DM5PR12MB1449.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:3; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 1wO9xOH+W8bJ1zrlKs/Ut9T27xFLUIyQbE16qm4SU3ykXxu+FV6I+TcDzPLosN5ZAlG6tNTS1tBk30yEbamp87sgzfxBFhJL6QhotQeEqDJaQOAkP2vcKFqCbxQYjwm5KYrBVjeJa54d5JEEMX8bYxv6yCGPWRjd4tCS1nEA15gIMBjX6/fIV/s0L/7msZdd3eoZ1akEbDaSsgxBA1dBMDLAUCCefQy9XTTPkIie3MQZ/O9IdyEAWcDcWfm/uQ0nmfoH5b0a4+ASWk243Hd6KzBmQFcTNJpMmJvXIw2QSUByQxSz1iIoZzlieORCV3jzLF9gnXuNjBlkPM5cM+o6AlK3Ztv2W/9RSxRSmR129kFd+pj+Nwl5QveROKnB45rjC6+7Ae9OdAygyrgbii85B5srC3XwPBqfRXCblcUyN20= Content-ID: MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 827767f1-f9c8-483a-8e90-08d6d8b695ef X-MS-Exchange-CrossTenant-originalarrivaltime: 14 May 2019 21:53:23.4209 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB2566 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Updated testmgr will exhibit this error message when loading the ccp-crypto module: alg: skcipher: cfb-aes-ccp encryption failed with err -22 on test vector 3, cfg="in-place" Update the CCP crypto driver to correctly treat CFB as a streaming mode cipher (instead of block mode). Update the configuration for CFB to specify the block size as a single byte; Fixes: 2b789435d7f3 ('crypto: ccp - CCP AES crypto API support') Signed-off-by: Gary R Hook --- drivers/crypto/ccp/ccp-crypto-aes.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/ccp/ccp-crypto-aes.c b/drivers/crypto/ccp/ccp-crypto-aes.c index 89291c15015c..3f768699332b 100644 --- a/drivers/crypto/ccp/ccp-crypto-aes.c +++ b/drivers/crypto/ccp/ccp-crypto-aes.c @@ -1,7 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /* * AMD Cryptographic Coprocessor (CCP) AES crypto API support * - * Copyright (C) 2013,2016 Advanced Micro Devices, Inc. + * Copyright (C) 2013-2019 Advanced Micro Devices, Inc. * * Author: Tom Lendacky * @@ -79,8 +80,7 @@ static int ccp_aes_crypt(struct ablkcipher_request *req, bool encrypt) return -EINVAL; if (((ctx->u.aes.mode == CCP_AES_MODE_ECB) || - (ctx->u.aes.mode == CCP_AES_MODE_CBC) || - (ctx->u.aes.mode == CCP_AES_MODE_CFB)) && + (ctx->u.aes.mode == CCP_AES_MODE_CBC)) && (req->nbytes & (AES_BLOCK_SIZE - 1))) return -EINVAL; @@ -291,7 +291,7 @@ static struct ccp_aes_def aes_algs[] = { .version = CCP_VERSION(3, 0), .name = "cfb(aes)", .driver_name = "cfb-aes-ccp", - .blocksize = AES_BLOCK_SIZE, + .blocksize = 1, .ivsize = AES_BLOCK_SIZE, .alg_defaults = &ccp_aes_defaults, }, From patchwork Tue May 14 21:53:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gary R Hook X-Patchwork-Id: 10943809 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 32C46924 for ; Tue, 14 May 2019 21:53:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 225CA2883A for ; Tue, 14 May 2019 21:53:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 167CB28885; Tue, 14 May 2019 21:53:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B19E02883A for ; Tue, 14 May 2019 21:53:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726221AbfENVxg (ORCPT ); Tue, 14 May 2019 17:53:36 -0400 Received: from mail-eopbgr730042.outbound.protection.outlook.com ([40.107.73.42]:28208 "EHLO NAM05-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726134AbfENVxg (ORCPT ); Tue, 14 May 2019 17:53:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=v8zIiscsNW/l6vUizBLG26l67LIgELNCWYIvq7S8Ff0=; b=x5bUxAHFvGiRy3Qp5RGzYsXWzaO7QSmGdOVHGgfODo5MrfK1fKfSKMn33SymK71/MunV28ovWbqYNz75oShND5KZztSueajH2RfGEPHlz//fbtAHzZ4Xhbq5eh3Lke7WK9QUsN3jw5hUpLfll2btld6ayjtCvKZSZHgy1YaoGaM= Received: from DM5PR12MB1449.namprd12.prod.outlook.com (10.172.40.14) by DM5PR12MB1659.namprd12.prod.outlook.com (10.172.40.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1878.24; Tue, 14 May 2019 21:53:30 +0000 Received: from DM5PR12MB1449.namprd12.prod.outlook.com ([fe80::11db:1b41:d1e6:c6dc]) by DM5PR12MB1449.namprd12.prod.outlook.com ([fe80::11db:1b41:d1e6:c6dc%11]) with mapi id 15.20.1878.024; Tue, 14 May 2019 21:53:30 +0000 From: "Hook, Gary" To: "linux-crypto@vger.kernel.org" CC: "Lendacky, Thomas" , "herbert@gondor.apana.org.au" , "davem@davemloft.net" Subject: [PATCH 3/3] crypto: ccp - Fix 3DES complaint from ccp-crypto module Thread-Topic: [PATCH 3/3] crypto: ccp - Fix 3DES complaint from ccp-crypto module Thread-Index: AQHVCp93X8zbRVwZX0udVbmBLT+j3g== Date: Tue, 14 May 2019 21:53:30 +0000 Message-ID: <155787080856.29723.18218380163821644624.stgit@taos> References: <155787079494.29723.7921582980150013941.stgit@taos> In-Reply-To: <155787079494.29723.7921582980150013941.stgit@taos> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SN1PR12CA0110.namprd12.prod.outlook.com (2603:10b6:802:21::45) To DM5PR12MB1449.namprd12.prod.outlook.com (2603:10b6:4:10::14) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Gary.Hook@amd.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [165.204.78.1] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 6b6dbe61-eb6d-4f13-a472-08d6d8b699ea x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600141)(711020)(4605104)(4618075)(2017052603328)(7193020);SRVR:DM5PR12MB1659; x-ms-traffictypediagnostic: DM5PR12MB1659: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 0037FD6480 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(7916004)(396003)(346002)(376002)(366004)(39860400002)(136003)(189003)(199004)(4326008)(9686003)(305945005)(25786009)(6486002)(5640700003)(6436002)(6512007)(11346002)(73956011)(66446008)(66476007)(66556008)(64756008)(66946007)(186003)(7736002)(476003)(8936002)(72206003)(26005)(81166006)(8676002)(14454004)(81156014)(103116003)(486006)(478600001)(446003)(6916009)(66066001)(53936002)(86362001)(316002)(2351001)(2906002)(68736007)(33716001)(71190400001)(3846002)(6116002)(99286004)(71200400001)(76176011)(2501003)(5660300002)(386003)(52116002)(6506007)(256004)(54906003)(102836004);DIR:OUT;SFP:1101;SCL:1;SRVR:DM5PR12MB1659;H:DM5PR12MB1449.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: O5xV5ylYkAeuzdNb1Io5ou3yVJbJrw3eW9zabprkmYnGRv94FEwz77nvyB/Z9pbjZ39u1Gkd6EUhxWeSRqw7jl1iQotx/zAyn3UWAijYGZtRLz92m367eqsz9pFjFJQFV1c29sENw6KX8n9tXj33r+kF4N5fp7sbm2+YSRK8bKAAEayT0ognN+yQvhQncXm1n2IqUwa4ElogUdi8MeJVLj7C2ue0arlWjVpwLwJI0t3t3UX8zl+SGZpktb7K1tK4mcsa+V5NMrheXIqskLeDDRUqrGid1T51ABBomfrMbRTgxxNtC7HHO3sIYu+GFG328l8szpfscXiRIh+/97nX9/wucE4kHk69YA87RyXTkwtBF0yW3wNETGJDM/PTayw9yv2pnORTH31GNtNhFGb9YznIATOE7DN2J7qsZYW6sSY= Content-ID: <5DBB0773084CDF4DAAB44796365EA5D2@namprd12.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6b6dbe61-eb6d-4f13-a472-08d6d8b699ea X-MS-Exchange-CrossTenant-originalarrivaltime: 14 May 2019 21:53:30.1916 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1659 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Crypto self-tests reveal an error: alg: skcipher: cbc-des3-ccp encryption test failed (wrong output IV) on test vector 0, cfg="in-place" The offset value should not be recomputed when retrieving the context. Also, a code path exists which makes decisions based on older (version 3) hardware; a v3 device deosn't support 3DES so remove this check. Fixes: 990672d48515 ('crypto: ccp - Enable 3DES function on v5 CCPs') Signed-off-by: Gary R Hook --- drivers/crypto/ccp/ccp-ops.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/crypto/ccp/ccp-ops.c b/drivers/crypto/ccp/ccp-ops.c index 3ecadeab919c..b116d62991c6 100644 --- a/drivers/crypto/ccp/ccp-ops.c +++ b/drivers/crypto/ccp/ccp-ops.c @@ -1267,6 +1267,9 @@ static int ccp_run_des3_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) int ret; /* Error checks */ + if (cmd_q->ccp->vdata->version < CCP_VERSION(5, 0)) + return -EINVAL; + if (!cmd_q->ccp->vdata->perform->des3) return -EINVAL; @@ -1349,8 +1352,6 @@ static int ccp_run_des3_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) * passthru option to convert from big endian to little endian. */ if (des3->mode != CCP_DES3_MODE_ECB) { - u32 load_mode; - op.sb_ctx = cmd_q->sb_ctx; ret = ccp_init_dm_workarea(&ctx, cmd_q, @@ -1366,12 +1367,8 @@ static int ccp_run_des3_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) if (ret) goto e_ctx; - if (cmd_q->ccp->vdata->version == CCP_VERSION(3, 0)) - load_mode = CCP_PASSTHRU_BYTESWAP_NOOP; - else - load_mode = CCP_PASSTHRU_BYTESWAP_256BIT; ret = ccp_copy_to_sb(cmd_q, &ctx, op.jobid, op.sb_ctx, - load_mode); + CCP_PASSTHRU_BYTESWAP_256BIT); if (ret) { cmd->engine_error = cmd_q->cmd_error; goto e_ctx; @@ -1433,10 +1430,6 @@ static int ccp_run_des3_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) } /* ...but we only need the last DES3_EDE_BLOCK_SIZE bytes */ - if (cmd_q->ccp->vdata->version == CCP_VERSION(3, 0)) - dm_offset = CCP_SB_BYTES - des3->iv_len; - else - dm_offset = 0; ccp_get_dm_area(&ctx, dm_offset, des3->iv, 0, DES3_EDE_BLOCK_SIZE); }