From patchwork Thu Mar 21 07:00:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akshay Saraswat X-Patchwork-Id: 229568 X-Patchwork-Delegate: promsoft@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 859E02C00C3 for ; Thu, 21 Mar 2013 17:41:49 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AF19F4A088; Thu, 21 Mar 2013 07:41:41 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wSgWj+0h2-ma; Thu, 21 Mar 2013 07:41:41 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 567914A08B; Thu, 21 Mar 2013 07:41:24 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A55B44A04B for ; Thu, 21 Mar 2013 07:41:19 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vc04u+0PH8Bm for ; Thu, 21 Mar 2013 07:41:18 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by theia.denx.de (Postfix) with ESMTP id 61E264A044 for ; Thu, 21 Mar 2013 07:41:08 +0100 (CET) Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MJZ00EI3ZWH2AO0@mailout2.samsung.com> for u-boot@lists.denx.de; Thu, 21 Mar 2013 15:41:05 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.125]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id 1D.95.07735.18BAA415; Thu, 21 Mar 2013 15:41:05 +0900 (KST) X-AuditID: cbfee68e-b7f946d000001e37-82-514aab81f202 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id A0.EC.13494.18BAA415; Thu, 21 Mar 2013 15:41:05 +0900 (KST) Received: from chrome-ubuntu.sisodomain.com ([107.108.73.106]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MJZ008JZZW5QX20@mmp2.samsung.com>; Thu, 21 Mar 2013 15:41:05 +0900 (KST) From: Akshay Saraswat To: u-boot@lists.denx.de Date: Thu, 21 Mar 2013 03:00:58 -0400 Message-id: <1363849259-2007-4-git-send-email-akshay.s@samsung.com> X-Mailer: git-send-email 1.8.0 In-reply-to: <1363849259-2007-1-git-send-email-akshay.s@samsung.com> References: <1363849259-2007-1-git-send-email-akshay.s@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrNLMWRmVeSWpSXmKPExsWyRsSkVrdxtVegwZ+pWhZbn/5mt1h1eAO7 xdQH5xgtvm3Zxmjxdm8nuwOrx+yGiywe/w73M3nsnHWX3ePsnR2MHn1bVjEGsEZx2aSk5mSW pRbp2yVwZdxsrC74oVAxZeUFxgbGiVJdjBwcEgImEh27VboYOYFMMYkL99azdTFycQgJLGWU mD31KjtEwkSiZ1kLC0RiOqPE+pNfWSGcXiaJTbc3soJUsQnoSGxf8h2sQ0RAQuJX/1VGkA3M AvESM9+ngYSFBWwl9u7fxwZiswioSqx8v5kZxOYVcJa4+7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0hNLUrNTUwtSi2C2MHFwSjUw Lixr6z7zzG5CxqQkAe1nK7Q5rexmKd710LMV2H2W7cSnMtZf907qmv+bvURXye/EBcmaOllZ Y5mljseqW3Uf/pqwK0Hk+yPHo6kyrIzqhmxLl/XvSw5+umVClsP3qXZM4UtmP79qeslxvqPG H7Mds0vXVMcvvC9wgJ3zlOCy3BOMm1/kuzT8V2Ipzkg01GIuKk4EAMMOxmHcAgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Cc: prashanth.g@samsung.com, kim.phillips@freescale.com Subject: [U-Boot] [PATCH 3/4 v8] gen: Add sha h/w acceleration to hash X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Adding H/W acceleration support to hash which can be used to test SHA 256 hash algorithm. Signed-off-by: ARUN MANKUZHI Signed-off-by: Akshay Saraswat Acked-by: Simon Glass --- Changes since v1: - Added sha256 support to "hash" command instead of new sha256 command. Changes sice v2: - Added new nodes for SHA1 and SHA256 in struct hash_algo for the case when ACE is enabled. - Added new declaration for function pointer hash_func_ws with different return type. Changes sice v3: - Changed command names to lower case in algo struct. - Added generic ace_sha config. Changes sice v4: - Changed function names in struct algo. - Replaced ACE_SHA_TYPE to CHUNSZ in struct algo. Changes sice v5: - Added file hw_sha.h. - Changed CONFIG_ACE_SHA to CONFIG_SHA_HW_ACCEL. - Renamed function names ace_sha1 and ace_sha256 to hw_sha1 and hw_sha256 respectively. Changes sice v6: - Changed position of "hw_sha.h" among includes (alpha order). - Rebased patch. Changes sice v7: - Added "Acked-by: Simon Glass ". common/hash.c | 18 ++++++++++++++++++ include/hw_sha.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 include/hw_sha.h diff --git a/common/hash.c b/common/hash.c index f5badcb..c9ac33e 100644 --- a/common/hash.c +++ b/common/hash.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -37,6 +38,23 @@ */ static struct hash_algo hash_algo[] = { /* + * CONFIG_SHA_HW_ACCEL is defined if hardware acceleration is + * available. + */ +#ifdef CONFIG_SHA_HW_ACCEL + { + "sha1", + SHA1_SUM_LEN, + hw_sha1, + CHUNKSZ_SHA1, + }, { + "sha256", + SHA256_SUM_LEN, + hw_sha256, + CHUNKSZ_SHA256, + }, +#endif + /* * This is CONFIG_CMD_SHA1SUM instead of CONFIG_SHA1 since otherwise * it bloats the code for boards which use SHA1 but not the 'hash' * or 'sha1sum' commands. diff --git a/include/hw_sha.h b/include/hw_sha.h new file mode 100644 index 0000000..264936c --- /dev/null +++ b/include/hw_sha.h @@ -0,0 +1,50 @@ +/* + * Header file for SHA hardware acceleration + * + * Copyright (c) 2012 Samsung Electronics + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +#ifndef __HW_SHA_H +#define __HW_SHA_H + + +/** + * Computes hash value of input pbuf using h/w acceleration + * + * @param in_addr A pointer to the input buffer + * @param bufleni Byte length of input buffer + * @param out_addr A pointer to the output buffer. When complete + * 32 bytes are copied to pout[0]...pout[31]. Thus, a user + * should allocate at least 32 bytes at pOut in advance. + * @param chunk_size chunk size for sha256 + */ +void hw_sha256(const uchar * in_addr, uint buflen, + uchar * out_addr, uint chunk_size); + +/** + * Computes hash value of input pbuf using h/w acceleration + * + * @param in_addr A pointer to the input buffer + * @param bufleni Byte length of input buffer + * @param out_addr A pointer to the output buffer. When complete + * 32 bytes are copied to pout[0]...pout[31]. Thus, a user + * should allocate at least 32 bytes at pOut in advance. + * @param chunk_size chunk_size for sha1 + */ +void hw_sha1(const uchar * in_addr, uint buflen, + uchar * out_addr, uint chunk_size); +#endif