1 /** @file 2 Basic TPM command functions. 3 4 Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR> 5 This program and the accompanying materials 6 are licensed and made available under the terms and conditions of the BSD License 7 which accompanies this distribution. The full text of the license may be found at 8 http://opensource.org/licenses/bsd-license.php 9 10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 12 13 **/ 14 15 #include "CommonHeader.h" 16 17 /** 18 Single function calculates SHA1 digest value for all raw data. It 19 combines Sha1Init(), Sha1Update() and Sha1Final(). 20 21 @param[in] Data Raw data to be digested. 22 @param[in] DataLen Size of the raw data. 23 @param[out] Digest Pointer to a buffer that stores the final digest. 24 25 @retval EFI_SUCCESS Always successfully calculate the final digest. 26 **/ 27 EFI_STATUS 28 EFIAPI 29 TpmCommHashAll ( 30 IN CONST UINT8 *Data, 31 IN UINTN DataLen, 32 OUT TPM_DIGEST *Digest 33 ) 34 { 35 VOID *Sha1Ctx; 36 UINTN CtxSize; 37 38 CtxSize = Sha1GetContextSize (); 39 Sha1Ctx = AllocatePool (CtxSize); 40 ASSERT (Sha1Ctx != NULL); 41 42 Sha1Init (Sha1Ctx); 43 Sha1Update (Sha1Ctx, Data, DataLen); 44 Sha1Final (Sha1Ctx, (UINT8 *)Digest); 45 46 FreePool (Sha1Ctx); 47 48 return EFI_SUCCESS; 49 } 50 51