From patchwork Fri Oct 14 19:36:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gary R Hook X-Patchwork-Id: 9377341 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.web.codeaurora.org (Postfix) with ESMTP id 5B5FF607FD for ; Fri, 14 Oct 2016 19:36:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 458082A7DE for ; Fri, 14 Oct 2016 19:36:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 351CD2A835; Fri, 14 Oct 2016 19:36:11 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 0C06E2A7DE for ; Fri, 14 Oct 2016 19:36:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756079AbcJNTgI (ORCPT ); Fri, 14 Oct 2016 15:36:08 -0400 Received: from mail-sn1nam01on0040.outbound.protection.outlook.com ([104.47.32.40]:44688 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755821AbcJNTgH (ORCPT ); Fri, 14 Oct 2016 15:36:07 -0400 X-Greylist: delayed 84390 seconds by postgrey-1.27 at vger.kernel.org; Fri, 14 Oct 2016 15:36:07 EDT 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; bh=UYppOZey5LzRFr54hgR5Po346edP+16JmiPhkft2xz0=; b=2y+8NszdDvypSjWjPxGFWkovm46rVDHf2Kpqy/5NZWA8qHhUh1WnSymJv7Z30qUlsoQb9FBaLFu2GMezvy3CSojdpEH0hZ1UeCyN5FPwFgzDkYRfhvzKCOprj8SMCh4tvYalFDtKOPbVqcVEHAZBrSmzOs7tATKBx4ZZ7dIKvBo= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Gary.Hook@amd.com; Received: from [10.236.19.42] (165.204.77.1) by MWHPR12MB1407.namprd12.prod.outlook.com (10.169.206.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.649.16; Fri, 14 Oct 2016 19:36:04 +0000 Subject: [PATCH] crypto: Move RSA+MPI constructs into an #include file From: Gary R Hook To: CC: , , Date: Fri, 14 Oct 2016 14:36:00 -0500 Message-ID: <20161014193559.4342.74036.stgit@taos> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BN6PR03CA0059.namprd03.prod.outlook.com (10.173.137.21) To MWHPR12MB1407.namprd12.prod.outlook.com (10.169.206.18) X-MS-Office365-Filtering-Correlation-Id: 69c64c1b-db79-4777-96c1-08d3f46956bc X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1407; 2:jKA3VkCzCWN47Jm3iGZE69uoMBxb0fG823dowVoIQl7VHUEvg8GALapEjY+8423iUdQSSo2MfTaOP9RlGnQmKEPAwH5AhqCbMVjv03LxZDAsgBD8EU+AotwdUs/O99LM8e99K+PULQpfY67a26ZTGMDilhL9bFJLXZp+duLyI8OCFQ7HhoFlFP1tlShe6s398mQb78HtnXh3DOcN54OCRA==; 3:D6+P+irSw4KOLFll7sVA2hV1ws0s24gfHNniv56cHE4jf3ritjaedZHPsdtPBz8mOGO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ESdIT61DuZG0lRnw5ysNPrZOfwLGL2NWofa7d1BdnHu3nnh23zy79QaV9PC8kHhZ9n54SFuvbUG19D+HYlrU1v6gKrBn7GzeP7etdSqoS78J05W8hjgACocI9AK9H015irbEGnc5ms8BEHlGsxxGuzTOPmCzxcNBJmZ/nncYsimbeuB4TBPDcO/ev/E5mGRenqm7MkhhWIk5UMO65OfJN7D9yFXEdZO0Mjxi9FrfgKwd5boeS3DL0Re1loDTdjz+Ivj1qPrhYqeY7wdQ0vjLTMm/L71zdUWEzalq8JdU62kb5eIxKQA4OmLMR+1dgy8MvqyS4sAiJ86m+C4+3Ec+siDTXfua9j8oS3/A X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026); SRVR:MWHPR12MB1407; BCL:0; PCL:0; RULEID:; SRVR:MWHPR12MB1407; X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1407; 4:Xrz2zdz3b4sCJIwl2oV799o/jy/uHpK4bwBrg+XVdCVf312OuRcYPqDC/+3BZho74kUGks2iCJhUwV2sTY+//5eWqglv4sSidSQQF9f9ulmZvpxbV49fPOxkWecjvFS/Tfh98wEGa2uRiNerVeTQ3/fTo+c7URhBMmzNOQB9Ll0x3JGJd5B8QnGr0ZP9jxrxc72LgTW37Srsu2XerwOoXxUVyu1UGZdnL2LrJomdrOjZjpCJrG9qVVE8M1LZmu3eEsBf51TUO+21h5WBULtkrDQYq41uVz9jWa1VkqBZ7R8Ugx5htzY+4aG6/JP9VAeTuwKpR2iwE5cMgGxpkaMqdARizOfarRz4z9P+TtejSwj0dpmZwuAPqJv9tYdYYSIayp2AMrJ4EkOcyb12/uKatPG9S/QPGy4fYg9JWqL0qh1oWlik2VTe80pSycb4jBYIjKx2flFoKWW7r+sddwoSfQ== X-Forefront-PRVS: 0095BCF226 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(6049001)(7916002)(199003)(189002)(81166006)(81156014)(33646002)(1076002)(110136003)(3846002)(77096005)(189998001)(6116002)(586003)(50466002)(33716001)(4001350100001)(2906002)(8676002)(86362001)(4326007)(83506001)(19580405001)(97736004)(19580395003)(42186005)(106356001)(54356999)(105586002)(229853001)(7846002)(6666003)(2351001)(47776003)(9686002)(50986999)(66066001)(97746001)(7736002)(103116003)(305945005)(68736007)(101416001)(5660300001)(6916009)(23676002)(230700001)(92566002); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR12MB1407; H:[10.236.19.42]; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtNV0hQUjEyTUIxNDA3OzIzOkcxdDcreTdhSDNucUVYY0xnalVwbjlwSCtM?= =?utf-8?B?SE5IUEZvUFRsNjBFVWhoTHg2UkkvT3B3eFlRM0ZuNnJ6dG4xUkF4WTRSTC9Y?= =?utf-8?B?RENMWllxVDRaSlg2cVQxc2taeENxN2xIeFJiQnhDWnd3RE9waERrM2t6TWh2?= =?utf-8?B?RlNOcGlUZXU0cmkwV25sT0FTTUN2SGMyT0NHdnRLQ2hSU1gwVW9xTlU2N2VZ?= =?utf-8?B?bkpSb2kwY1V1TEZ0YzdBdzFBSVB0cGIzMllVNFFWelM5MVlBRWpwOFFtd1lN?= =?utf-8?B?QzkwS3YyeGVTWGNwTTkrMVNhUFIrVlc1V0lqanRSSWFaL21GK21OVVNqcTVx?= =?utf-8?B?SnJ3Ky9jQ0NDTE8wNUsrdVF2d0tNWXlLR1dZSk1PWVc2bEtDZDFhM1lOOHJK?= =?utf-8?B?WGNMenFqeEZmTU03ZXBWdUhYTys3RlY1Y0I4VGxqdFVrZm1tQ2FONTZoRU5I?= =?utf-8?B?OFdWZkEySEZqSkxxOEdDMys3dGptalBFckR5ZnR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diagnostics: 1; MWHPR12MB1407; 7:lZ5PrTsJcHf2tllSgNBKk0nnVS3ztcgqKJqr+x0sFLwI3bQJL+OZxYF7D/i9nm3kWqKQdOeB8ogxirvk7G3IOUFmQCEfheqNRI88u3AWFikb1kBx0VflmoGML5KELDGUHT3zEJYxCsRHiZjz2TrOkKu1dXpBFr/KTWbMx/1PGg/vJ/XJ5iaaqT0PGEsmxG1rzj3BeA7FWG4j61brro+dZref4wgOeEMwwA5P5U2alEYPhsz/bFGDoKx3vL4UyH4oGRG4xocn9lG56Ldz0CLgwTryJRe5gJupktS5Oz2Ha/HoEp6rrXqfTJEYmEY358MbptAPfEjbR8uoJRFFDT1Nu8Awfu2j6SBNU4pMgAzRXHM=; 20:5ZCedVAbM0C8+iG9xMTuLFZ+jRDNZ9DwwChDHTR/eFD+6O0hishDCmQhUZO8WsVlalscRPu9JMNq6hwKgjMit7A6wn8UlQ9iEnnoUb3tOlGMQhQF2YdV8umw7ZWA4yu1VP90nqdp9AuGW5Hcy0AaPrNAQavO/cDDK0EPM5JKOUnEb97XGLFBBI3fRjpl6gNZgXAfAQkJPP1is8wos24Pjg+WR4cc9ZlxbHwJwTFXSInm7emzxDXNe04/UcFSxX6k X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2016 19:36:04.6459 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1407 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 Move RSA support of general use into internal/rsa.h. This allows reuse of, e.g. RSA MPI keys and support functions. Signed-off-by: Gary R Hook --- crypto/rsa.c | 16 ---------------- include/crypto/internal/rsa.h | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 16 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-crypto" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/crypto/rsa.c b/crypto/rsa.c index 4c280b6..15e9220 100644 --- a/crypto/rsa.c +++ b/crypto/rsa.c @@ -16,12 +16,6 @@ #include #include -struct rsa_mpi_key { - MPI n; - MPI e; - MPI d; -}; - /* * RSAEP function [RFC3447 sec 5.1.1] * c = m^e mod n; @@ -240,16 +234,6 @@ err_free_m: return ret; } -static void rsa_free_mpi_key(struct rsa_mpi_key *key) -{ - mpi_free(key->d); - mpi_free(key->e); - mpi_free(key->n); - key->d = NULL; - key->e = NULL; - key->n = NULL; -} - static int rsa_check_key_length(unsigned int len) { switch (len) { diff --git a/include/crypto/internal/rsa.h b/include/crypto/internal/rsa.h index 9e8f159..253b275 100644 --- a/include/crypto/internal/rsa.h +++ b/include/crypto/internal/rsa.h @@ -13,6 +13,7 @@ #ifndef _RSA_HELPER_ #define _RSA_HELPER_ #include +#include /** * rsa_key - RSA key structure @@ -52,6 +53,22 @@ struct rsa_key { size_t qinv_sz; }; +struct rsa_mpi_key { + MPI n; + MPI e; + MPI d; +}; + +static inline void rsa_free_mpi_key(struct rsa_mpi_key *key) +{ + mpi_free(key->d); + mpi_free(key->e); + mpi_free(key->n); + key->d = NULL; + key->e = NULL; + key->n = NULL; +} + int rsa_parse_pub_key(struct rsa_key *rsa_key, const void *key, unsigned int key_len);