From patchwork Fri Mar 15 08:52:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akshay Saraswat X-Patchwork-Id: 227878 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 0A8332C00C4 for ; Fri, 15 Mar 2013 19:33:28 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 28CEF4A19C; Fri, 15 Mar 2013 09:33:10 +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 cNJDFRCvX+6j; Fri, 15 Mar 2013 09:33:09 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8E2454A19D; Fri, 15 Mar 2013 09:32:59 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DC2794A15E for ; Fri, 15 Mar 2013 09:32:34 +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 UMCdOwyKWzpl for ; Fri, 15 Mar 2013 09:32:30 +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 mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by theia.denx.de (Postfix) with ESMTP id 44BD64A15B for ; Fri, 15 Mar 2013 09:32:25 +0100 (CET) Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MJP000Y211B79N0@mailout3.samsung.com> for u-boot@lists.denx.de; Fri, 15 Mar 2013 17:32:13 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.126]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id 33.01.07735.D8CD2415; Fri, 15 Mar 2013 17:32:13 +0900 (KST) X-AuditID: cbfee68e-b7f946d000001e37-09-5142dc8dc126 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 0E.22.13494.D8CD2415; Fri, 15 Mar 2013 17:32:13 +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 <0MJP00F3511DO080@mmp2.samsung.com>; Fri, 15 Mar 2013 17:32:13 +0900 (KST) From: Akshay Saraswat To: u-boot@lists.denx.de Date: Fri, 15 Mar 2013 04:52:16 -0400 Message-id: <1363337537-2941-4-git-send-email-akshay.s@samsung.com> X-Mailer: git-send-email 1.8.0 In-reply-to: <1363337537-2941-1-git-send-email-akshay.s@samsung.com> References: <1363337537-2941-1-git-send-email-akshay.s@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRmVeSWpSXmKPExsWyRsSkTrf3jlOgwef/WharDm9gt5j64Byj xbct2xgt3u7tZHdg8ZjdcJHFY+esu+weZ+/sYPTo27KKMYAlissmJTUnsyy1SN8ugSujc8ND xoJWuYqeZe9YGxjfincxcnJICJhIfJ77iRXCFpO4cG89WxcjF4eQwFJGibbfk9lgir5e380E kZjOKPH5aheU08skcepLNyNIFZuAjsT2Jd/ZQWwRAQmJX/1XweLMAo4S+458YwKxhQVsJdZ8 6gCrYRFQlbi+pwdsNa+As8Ss0z/ZIbbJSXzY8wjM5hRwkejaPoeli5ED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6 SueXTF9zWWHD1cBVthsmWG10m3Vz4f5Jupd/JO53YcyxfPKj6/fFaM8Fa07snDxr3W+p+nxp 0R2yJ/OX/s57LS3weU6Jx/GLLS8+ZjMIxCQ072veuMM50HrloZxSD4amtx3cp2LWzIxZF+C7 f13czs2JL6affPx1Ya7489NKLMUZiYZazEXFiQBKgWnW0wIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Cc: prashanth.g@samsung.com Subject: [U-Boot] [PATCH 3/4 v6] 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 --- 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. common/hash.c | 14 ++++++++++++++ include/hw_sha.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 include/hw_sha.h diff --git a/common/hash.c b/common/hash.c index e3a6e43..23b1334 100644 --- a/common/hash.c +++ b/common/hash.c @@ -28,12 +28,26 @@ #include #include #include +#include /* * These are the hash algorithms we support. Chips which support accelerated * crypto could perhaps add named version of these algorithms here. */ static struct hash_algo hash_algo[] = { +#ifdef CONFIG_SHA_HW_ACCEL + { + "sha1", + SHA1_SUM_LEN, + hw_sha1, + CHUNKSZ_SHA1, + }, { + "sha256", + SHA256_SUM_LEN, + hw_sha256, + CHUNKSZ_SHA256, + }, +#endif #ifdef CONFIG_SHA1 { "SHA1", diff --git a/include/hw_sha.h b/include/hw_sha.h new file mode 100644 index 0000000..565e5a0 --- /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