]> git.proxmox.com Git - mirror_edk2.git/blob - SecurityPkg/Library/TpmCommLib/TpmComm.c
SecurityPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / SecurityPkg / Library / TpmCommLib / TpmComm.c
1 /** @file
2 Basic TPM command functions.
3
4 Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #include "CommonHeader.h"
10
11 /**
12 Single function calculates SHA1 digest value for all raw data. It
13 combines Sha1Init(), Sha1Update() and Sha1Final().
14
15 @param[in] Data Raw data to be digested.
16 @param[in] DataLen Size of the raw data.
17 @param[out] Digest Pointer to a buffer that stores the final digest.
18
19 @retval EFI_SUCCESS Always successfully calculate the final digest.
20 **/
21 EFI_STATUS
22 EFIAPI
23 TpmCommHashAll (
24 IN CONST UINT8 *Data,
25 IN UINTN DataLen,
26 OUT TPM_DIGEST *Digest
27 )
28 {
29 VOID *Sha1Ctx;
30 UINTN CtxSize;
31
32 CtxSize = Sha1GetContextSize ();
33 Sha1Ctx = AllocatePool (CtxSize);
34 ASSERT (Sha1Ctx != NULL);
35
36 Sha1Init (Sha1Ctx);
37 Sha1Update (Sha1Ctx, Data, DataLen);
38 Sha1Final (Sha1Ctx, (UINT8 *)Digest);
39
40 FreePool (Sha1Ctx);
41
42 return EFI_SUCCESS;
43 }
44