1 /*++
2 
3   Copyright (c) 2004  - 2014, Intel Corporation. All rights reserved.<BR>
4 
5 
6   This program and the accompanying materials are licensed and made available under
7 
8   the terms and conditions of the BSD License that accompanies this distribution.
9 
10   The full text of the license may be found at
11 
12   http://opensource.org/licenses/bsd-license.php.
13 
14 
15 
16   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
17 
18   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 
20 
21 
22 
23 Module Name:
24 
25   Speaker.h
26 
27 Abstract:
28 
29   EFI Speaker Interface Protocol
30 
31 
32 
33 --*/
34 
35 #ifndef _PEI_SHA256_HASH_H
36 #define _PEI_SHA256_HASH_H
37 
38 //
39 // Global ID Speaker Interface
40 //
41 #define PEI_SHA256_HASH_PPI_GUID \
42   { \
43     0x950e191b, 0x8524, 0x4f51,  0x80, 0xa1, 0x5c, 0x4f, 0x1b, 0x3, 0xf3, 0x5c  \
44   }
45 
46 typedef struct _PEI_SHA256_HASH_PPI PEI_SHA256_HASH_PPI;
47 
48 /**
49   @return  The size, in bytes, of the context buffer required for hash operations.
50 
51 **/
52 typedef
53 UINTN
54 (EFIAPI *HASH_GET_CONTEXT_SIZE)(
55   VOID
56   );
57 
58 /**
59   Initializes user-supplied memory pointed by HashContext as hash context for
60   subsequent use.
61 
62   If HashContext is NULL, then ASSERT().
63 
64   @param[in, out]  HashContext  Pointer to  Context being initialized.
65 
66   @retval TRUE   HASH context initialization succeeded.
67   @retval FALSE  HASH context initialization failed.
68 
69 **/
70 typedef
71 BOOLEAN
72 (EFIAPI *HASH_INIT)(
73   IN OUT  VOID  *HashContext
74   );
75 
76 /**
77   Performs digest on a data buffer of the specified length. This function can
78   be called multiple times to compute the digest of long or discontinuous data streams.
79 
80   If HashContext is NULL, then ASSERT().
81 
82   @param[in, out]  HashContext  Pointer to the MD5 context.
83   @param[in]       Data         Pointer to the buffer containing the data to be hashed.
84   @param[in]       DataLength   Length of Data buffer in bytes.
85 
86   @retval TRUE     HASH data digest succeeded.
87   @retval FALSE    Invalid HASH context. After HashFinal function has been called, the
88                    HASH context cannot be reused.
89 
90 **/
91 typedef
92 BOOLEAN
93 (EFIAPI *HASH_UPDATE)(
94   IN OUT  VOID        *HashContext,
95   IN      CONST VOID  *Data,
96   IN      UINTN       DataLength
97   );
98 
99 /**
100   Completes hash computation and retrieves the digest value into the specified
101   memory. After this function has been called, the context cannot be used again.
102 
103   If HashContext is NULL, then ASSERT().
104   If HashValue is NULL, then ASSERT().
105 
106   @param[in, out]  HashContext  Pointer to the MD5 context
107   @param[out]      HashValue    Pointer to a buffer that receives the HASH digest
108                                 value.
109 
110   @retval TRUE   HASH digest computation succeeded.
111   @retval FALSE  HASH digest computation failed.
112 
113 **/
114 typedef
115 BOOLEAN
116 (EFIAPI *HASH_FINAL)(
117   IN OUT  VOID   *HashContext,
118   OUT     UINT8  *HashValue
119   );
120 
121 //
122 // Ppi definition
123 //
124 typedef struct _PEI_SHA256_HASH_PPI {
125   //
126   // Pointer to Hash GetContentSize function
127   //
128   HASH_GET_CONTEXT_SIZE    GetContextSize;
129   //
130   // Pointer to Hash Init function
131   //
132   HASH_INIT                HashInit;
133   //
134   // Pointer to Hash Update function
135   //
136   HASH_UPDATE              HashUpdate;
137   //
138   // Pointer to Hash Final function
139   //
140   HASH_FINAL               HashFinal;
141 
142 } PEI_SHA256_HASH_PPI;
143 
144 extern EFI_GUID gPeiSha256HashPpiGuid;
145 #endif
146