⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sps_hc.c

📁 RMI的处理器au1200系列所用的BOOTLOAD,包括SD卡启动USB启动硬盘启动网络启动,并初始化硬件的所有参数,支持内核调试.
💻 C
字号:
/** * \file * Secure Patch System - Hash Chain for concatenating patches (just stubs) * * \version $Revision$ $State$ * * \date $Date$ * * \author <a href="mailto:Axel.Wachtler@amd.com">Axel Wachtler</a> * * \par Last changed by: * $Author$ * *****************************************************************************//* * Copyright 2002 ADVANCED MICRO DEVICES, INC. All Rights Reserved. * * This software and any related documentation (the "Materials") are the * confidential proprietary information of AMD. Unless otherwise provided * in an agreement specifically licensing the Materials, the Materials are * provided in confidence and may not to be used, distributed, modified, or * reproduced in whole or in part by any means. * * LIMITATION OF LIABILITY: THE MATERIALS ARE PROVIDED "AS IS" WITHOUT ANY * EXPRESS OR IMPLIED WARRANTY OF ANY KIND, INCLUDING BUT NOT LIMITED TO * WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, TITLE, FITNESS FOR ANY * PARTICULAR PURPOSE, OR WARRANTIES ARISING FORM CONDUCT, COURSE OF * DEALING, OR USAGE OF TRADE.  IN NO EVENT SHALL AMD OR ITS LICENSORS BE * LIABLE FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, * DAMAGES FOR LOSS OF PROFITS, BUSINESS INTERRUPTION, OR LOSS OF * INFORMATION) ARISING OUT OF THE USE OF OR INABILITY TO USE THE * MATERIALS, EVEN IF AMD HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH * DAMAGES.  BECAUSE SOME JURISDICTIONS PROHIBIT THE EXCLUSION OR * LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE * ABOVE LIMITATION MAY NOT APPLY TO YOU. * * AMD does not assume any responsibility for any errors which may appear * in the Materials nor any responsibility to support or update the * Materials.  AMD retains the right to modify the Materials at any time, * without notice, and is not obligated to provide such modified Materials * to you. * * NO SUPPORT OBLIGATION: AMD is not obligated to furnish, support, or make * any further information, software, technical information, know-how, or * show-how available to you. * *//******************************************************************************  Includes*****************************************************************************/#include "sec.h"#include "ssfif.h"#include "sps.h"#include "sps_hc.h"#ifdef MSDOS#include "sha1.h"#else#include "Sha/sha1.h"#endif/******************************************************************************  Data*****************************************************************************//******************************************************************************  Static Function Declarations*****************************************************************************//** \defgroup SpsFunctions SPS Hash Chain Functions*//**\{*//** * @brief * * @param * * @return */SpsSuccess_t SpsHashChainInit(SpsHashChainWorkspace_t * pHcWs){    SpsSuccess_t ret;    ret = SPS_UNSUCCESSFUL;    DP0(("SPS: Init Hash Chain pHcWs=0x%08x", pHcWs));    if (pHcWs != NULL) {	/* ssf_memset(pHcWs, 0,sizeof(SpsHashChainWorkspace_t)); */	/* can not set whole struct to 0, this would overwrite	 * next Digest	 */	SHA1Init(&(pHcWs->Sha1Ctx));	ret = SPS_SUCCESSFUL;    }    return ret;}SpsSuccess_t SpsHashChainProcess(SpsHashChainWorkspace_t * pHcWs,				 Int8 * pData, Int32 Size){    SpsSuccess_t ret;    ret = SPS_UNSUCCESSFUL;    do {	DP0(("SPS: Update Hash Chain pData=0x%08x, Size=%d", pData, Size));	if ((pHcWs == NULL) || (pData == NULL) || (Size < 1)) {	    ret = SPS_NULL_PTR_FAIL;	    break;	}	/* With our modified sha, there is no more destroying of buffers,	   so we need not to copy the payload */	SHA1Update(&(pHcWs->Sha1Ctx),		   (unsigned char *) pData, (uint32) Size);	ret = SPS_SUCCESSFUL;    } while (0);    return ret;}Int8 SpsHashChainCheckHash(SpsHashChainWorkspace_t * pHcWs){    Int8 Digest[PP_SHA1_LENGTH];    Int8 ret;    Int8 i;    ret = 0x0;    do {	if (pHcWs == NULL) {	    break;	}	ssf_memset(Digest, 0, PP_SHA1_LENGTH);	SHA1Final(Digest, &(pHcWs->Sha1Ctx));#ifdef VERBOSE	printf	    ("\ngot Digest: %02x %02x %02x %02x  %02x %02x %02x %02x  %02x %02x %02x %02x  %02x %02x %02x %02x  %02x %02x %02x %02x",	     Digest[0], Digest[1], Digest[2], Digest[3], Digest[4],	     Digest[5], Digest[6], Digest[7], Digest[8], Digest[9],	     Digest[10], Digest[11], Digest[12], Digest[13], Digest[14],	     Digest[15], Digest[16], Digest[17], Digest[18], Digest[19]	    );	printf	    ("\nexp Digest: %02x %02x %02x %02x  %02x %02x %02x %02x  %02x %02x %02x %02x  %02x %02x %02x %02x  %02x %02x %02x %02x\n",	     pHcWs->NextDigest[0], pHcWs->NextDigest[1],	     pHcWs->NextDigest[2], pHcWs->NextDigest[3],	     pHcWs->NextDigest[4], pHcWs->NextDigest[5],	     pHcWs->NextDigest[6], pHcWs->NextDigest[7],	     pHcWs->NextDigest[8], pHcWs->NextDigest[9],	     pHcWs->NextDigest[10], pHcWs->NextDigest[11],	     pHcWs->NextDigest[12], pHcWs->NextDigest[13],	     pHcWs->NextDigest[14], pHcWs->NextDigest[15],	     pHcWs->NextDigest[16], pHcWs->NextDigest[17],	     pHcWs->NextDigest[18], pHcWs->NextDigest[19]	    );#endif	for (i = 0; i < PP_SHA1_LENGTH; i++) {	    if (Digest[i] != pHcWs->NextDigest[i]) {		DP0(("SPS: Digest Check Failed at pos. %d", i));		break;	    }	}	if (i == PP_SHA1_LENGTH) {	    ret = 3;	}    }    while (0);    return ret;}SpsSuccess_t SpsHashChainReset(SpsHashChainWorkspace_t * pHcWs,			       Int8 * pHashData){    SpsSuccess_t ret;    ret = SPS_UNSUCCESSFUL;    if (pHcWs != NULL) {	ssf_memset(pHcWs, 0, sizeof(SpsHashChainWorkspace_t));	if (pHashData != NULL) {#ifdef VERBOSE	    printf		("\nnext Digest: %02x %02x %02x %02x  %02x %02x %02x %02x  %02x %02x %02x %02x  %02x %02x %02x %02x  %02x %02x %02x %02x\n",		 pHashData[0], pHashData[1], pHashData[2], pHashData[3],		 pHashData[4], pHashData[5], pHashData[6], pHashData[7],		 pHashData[8], pHashData[9], pHashData[10], pHashData[11],		 pHashData[12], pHashData[13], pHashData[14],		 pHashData[15], pHashData[16], pHashData[17],		 pHashData[18], pHashData[19]		);#endif	    ssf_memcpy(pHcWs->NextDigest, pHashData, PP_SHA1_LENGTH);	} else {	    DP0(("next Digest: NONE"));	}	SHA1Init(&(pHcWs->Sha1Ctx));	ret = SPS_SUCCESSFUL;    }    return ret;}/**\}*//* ------------------------------------------------------------------------- *//**\}*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -