Hash2DxeCrypto.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. /** @file
  2. This module implements Hash2 Protocol.
  3. (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
  4. Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. #include <Uefi.h>
  8. #include <Protocol/Hash2.h>
  9. #include <Library/BaseLib.h>
  10. #include <Library/UefiBootServicesTableLib.h>
  11. #include <Library/MemoryAllocationLib.h>
  12. #include <Library/BaseMemoryLib.h>
  13. #include <Library/DebugLib.h>
  14. #include <Library/BaseCryptLib.h>
  15. #include "Driver.h"
  16. /**
  17. Retrieves the size, in bytes, of the context buffer required for hash operations.
  18. If this interface is not supported, then return zero.
  19. @return The size, in bytes, of the context buffer required for hash operations.
  20. @retval 0 This interface is not supported.
  21. **/
  22. typedef
  23. UINTN
  24. (EFIAPI *EFI_HASH_GET_CONTEXT_SIZE)(
  25. VOID
  26. );
  27. /**
  28. Initializes user-supplied memory pointed by Sha1Context as hash context for
  29. subsequent use.
  30. If HashContext is NULL, then return FALSE.
  31. If this interface is not supported, then return FALSE.
  32. @param[out] HashContext Pointer to Hashcontext being initialized.
  33. @retval TRUE Hash context initialization succeeded.
  34. @retval FALSE Hash context initialization failed.
  35. @retval FALSE This interface is not supported.
  36. **/
  37. typedef
  38. BOOLEAN
  39. (EFIAPI *EFI_HASH_INIT)(
  40. OUT VOID *HashContext
  41. );
  42. /**
  43. Digests the input data and updates Hash context.
  44. This function performs Hash digest on a data buffer of the specified size.
  45. It can be called multiple times to compute the digest of long or discontinuous data streams.
  46. Hash context should be already correctly initialized by HashInit(), and should not be finalized
  47. by HashFinal(). Behavior with invalid context is undefined.
  48. If HashContext is NULL, then return FALSE.
  49. If this interface is not supported, then return FALSE.
  50. @param[in, out] HashContext Pointer to the Hash context.
  51. @param[in] Data Pointer to the buffer containing the data to be hashed.
  52. @param[in] DataSize Size of Data buffer in bytes.
  53. @retval TRUE SHA-1 data digest succeeded.
  54. @retval FALSE SHA-1 data digest failed.
  55. @retval FALSE This interface is not supported.
  56. **/
  57. typedef
  58. BOOLEAN
  59. (EFIAPI *EFI_HASH_UPDATE)(
  60. IN OUT VOID *HashContext,
  61. IN CONST VOID *Data,
  62. IN UINTN DataSize
  63. );
  64. /**
  65. Completes computation of the Hash digest value.
  66. This function completes hash computation and retrieves the digest value into
  67. the specified memory. After this function has been called, the Hash context cannot
  68. be used again.
  69. Hash context should be already correctly initialized by HashInit(), and should not be
  70. finalized by HashFinal(). Behavior with invalid Hash context is undefined.
  71. If HashContext is NULL, then return FALSE.
  72. If HashValue is NULL, then return FALSE.
  73. If this interface is not supported, then return FALSE.
  74. @param[in, out] HashContext Pointer to the Hash context.
  75. @param[out] HashValue Pointer to a buffer that receives the Hash digest
  76. value.
  77. @retval TRUE Hash digest computation succeeded.
  78. @retval FALSE Hash digest computation failed.
  79. @retval FALSE This interface is not supported.
  80. **/
  81. typedef
  82. BOOLEAN
  83. (EFIAPI *EFI_HASH_FINAL)(
  84. IN OUT VOID *HashContext,
  85. OUT UINT8 *HashValue
  86. );
  87. typedef struct {
  88. EFI_GUID *Guid;
  89. UINT32 HashSize;
  90. EFI_HASH_GET_CONTEXT_SIZE GetContextSize;
  91. EFI_HASH_INIT Init;
  92. EFI_HASH_UPDATE Update;
  93. EFI_HASH_FINAL Final;
  94. } EFI_HASH_INFO;
  95. EFI_HASH_INFO mHashInfo[] = {
  96. { &gEfiHashAlgorithmSha256Guid, sizeof (EFI_SHA256_HASH2), Sha256GetContextSize, Sha256Init, Sha256Update, Sha256Final },
  97. { &gEfiHashAlgorithmSha384Guid, sizeof (EFI_SHA384_HASH2), Sha384GetContextSize, Sha384Init, Sha384Update, Sha384Final },
  98. { &gEfiHashAlgorithmSha512Guid, sizeof (EFI_SHA512_HASH2), Sha512GetContextSize, Sha512Init, Sha512Update, Sha512Final },
  99. };
  100. /**
  101. Returns the size of the hash which results from a specific algorithm.
  102. @param[in] This Points to this instance of EFI_HASH2_PROTOCOL.
  103. @param[in] HashAlgorithm Points to the EFI_GUID which identifies the algorithm to use.
  104. @param[out] HashSize Holds the returned size of the algorithm's hash.
  105. @retval EFI_SUCCESS Hash size returned successfully.
  106. @retval EFI_INVALID_PARAMETER This or HashSize is NULL.
  107. @retval EFI_UNSUPPORTED The algorithm specified by HashAlgorithm is not supported by this driver
  108. or HashAlgorithm is null.
  109. **/
  110. EFI_STATUS
  111. EFIAPI
  112. BaseCrypto2GetHashSize (
  113. IN CONST EFI_HASH2_PROTOCOL *This,
  114. IN CONST EFI_GUID *HashAlgorithm,
  115. OUT UINTN *HashSize
  116. );
  117. /**
  118. Creates a hash for the specified message text. The hash is not extendable.
  119. The output is final with any algorithm-required padding added by the function.
  120. @param[in] This Points to this instance of EFI_HASH2_PROTOCOL.
  121. @param[in] HashAlgorithm Points to the EFI_GUID which identifies the algorithm to use.
  122. @param[in] Message Points to the start of the message.
  123. @param[in] MessageSize The size of Message, in bytes.
  124. @param[in,out] Hash On input, points to a caller-allocated buffer of the size
  125. returned by GetHashSize() for the specified HashAlgorithm.
  126. On output, the buffer holds the resulting hash computed from the message.
  127. @retval EFI_SUCCESS Hash returned successfully.
  128. @retval EFI_INVALID_PARAMETER This or Hash is NULL.
  129. @retval EFI_UNSUPPORTED The algorithm specified by HashAlgorithm is not supported by this driver
  130. or HashAlgorithm is Null.
  131. @retval EFI_OUT_OF_RESOURCES Some resource required by the function is not available
  132. or MessageSize is greater than platform maximum.
  133. **/
  134. EFI_STATUS
  135. EFIAPI
  136. BaseCrypto2Hash (
  137. IN CONST EFI_HASH2_PROTOCOL *This,
  138. IN CONST EFI_GUID *HashAlgorithm,
  139. IN CONST UINT8 *Message,
  140. IN UINTN MessageSize,
  141. IN OUT EFI_HASH2_OUTPUT *Hash
  142. );
  143. /**
  144. This function must be called to initialize a digest calculation to be subsequently performed using the
  145. EFI_HASH2_PROTOCOL functions HashUpdate() and HashFinal().
  146. @param[in] This Points to this instance of EFI_HASH2_PROTOCOL.
  147. @param[in] HashAlgorithm Points to the EFI_GUID which identifies the algorithm to use.
  148. @retval EFI_SUCCESS Initialized successfully.
  149. @retval EFI_INVALID_PARAMETER This is NULL.
  150. @retval EFI_UNSUPPORTED The algorithm specified by HashAlgorithm is not supported by this driver
  151. or HashAlgorithm is Null.
  152. @retval EFI_OUT_OF_RESOURCES Process failed due to lack of required resource.
  153. @retval EFI_ALREADY_STARTED This function is called when the operation in progress is still in processing Hash(),
  154. or HashInit() is already called before and not terminated by HashFinal() yet on the same instance.
  155. **/
  156. EFI_STATUS
  157. EFIAPI
  158. BaseCrypto2HashInit (
  159. IN CONST EFI_HASH2_PROTOCOL *This,
  160. IN CONST EFI_GUID *HashAlgorithm
  161. );
  162. /**
  163. Updates the hash of a computation in progress by adding a message text.
  164. @param[in] This Points to this instance of EFI_HASH2_PROTOCOL.
  165. @param[in] Message Points to the start of the message.
  166. @param[in] MessageSize The size of Message, in bytes.
  167. @retval EFI_SUCCESS Digest in progress updated successfully.
  168. @retval EFI_INVALID_PARAMETER This or Hash is NULL.
  169. @retval EFI_OUT_OF_RESOURCES Some resource required by the function is not available
  170. or MessageSize is greater than platform maximum.
  171. @retval EFI_NOT_READY This call was not preceded by a valid call to HashInit(),
  172. or the operation in progress was terminated by a call to Hash() or HashFinal() on the same instance.
  173. **/
  174. EFI_STATUS
  175. EFIAPI
  176. BaseCrypto2HashUpdate (
  177. IN CONST EFI_HASH2_PROTOCOL *This,
  178. IN CONST UINT8 *Message,
  179. IN UINTN MessageSize
  180. );
  181. /**
  182. Finalizes a hash operation in progress and returns calculation result.
  183. The output is final with any necessary padding added by the function.
  184. The hash may not be further updated or extended after HashFinal().
  185. @param[in] This Points to this instance of EFI_HASH2_PROTOCOL.
  186. @param[in,out] Hash On input, points to a caller-allocated buffer of the size
  187. returned by GetHashSize() for the specified HashAlgorithm specified in preceding HashInit().
  188. On output, the buffer holds the resulting hash computed from the message.
  189. @retval EFI_SUCCESS Hash returned successfully.
  190. @retval EFI_INVALID_PARAMETER This or Hash is NULL.
  191. @retval EFI_NOT_READY This call was not preceded by a valid call to HashInit() and at least one call to HashUpdate(),
  192. or the operation in progress was canceled by a call to Hash() on the same instance.
  193. **/
  194. EFI_STATUS
  195. EFIAPI
  196. BaseCrypto2HashFinal (
  197. IN CONST EFI_HASH2_PROTOCOL *This,
  198. IN OUT EFI_HASH2_OUTPUT *Hash
  199. );
  200. EFI_HASH2_PROTOCOL mHash2Protocol = {
  201. BaseCrypto2GetHashSize,
  202. BaseCrypto2Hash,
  203. BaseCrypto2HashInit,
  204. BaseCrypto2HashUpdate,
  205. BaseCrypto2HashFinal,
  206. };
  207. /**
  208. Returns hash information.
  209. @param[in] HashAlgorithm Points to the EFI_GUID which identifies the algorithm to use.
  210. @return Hash information.
  211. **/
  212. EFI_HASH_INFO *
  213. GetHashInfo (
  214. IN CONST EFI_GUID *HashAlgorithm
  215. )
  216. {
  217. UINTN Index;
  218. for (Index = 0; Index < sizeof (mHashInfo)/sizeof (mHashInfo[0]); Index++) {
  219. if (CompareGuid (HashAlgorithm, mHashInfo[Index].Guid)) {
  220. return &mHashInfo[Index];
  221. }
  222. }
  223. return NULL;
  224. }
  225. /**
  226. Returns the size of the hash which results from a specific algorithm.
  227. @param[in] This Points to this instance of EFI_HASH2_PROTOCOL.
  228. @param[in] HashAlgorithm Points to the EFI_GUID which identifies the algorithm to use.
  229. @param[out] HashSize Holds the returned size of the algorithm's hash.
  230. @retval EFI_SUCCESS Hash size returned successfully.
  231. @retval EFI_INVALID_PARAMETER This or HashSize is NULL.
  232. @retval EFI_UNSUPPORTED The algorithm specified by HashAlgorithm is not supported by this driver
  233. or HashAlgorithm is null.
  234. **/
  235. EFI_STATUS
  236. EFIAPI
  237. BaseCrypto2GetHashSize (
  238. IN CONST EFI_HASH2_PROTOCOL *This,
  239. IN CONST EFI_GUID *HashAlgorithm,
  240. OUT UINTN *HashSize
  241. )
  242. {
  243. EFI_HASH_INFO *HashInfo;
  244. if ((This == NULL) || (HashSize == NULL)) {
  245. return EFI_INVALID_PARAMETER;
  246. }
  247. if (HashAlgorithm == NULL) {
  248. return EFI_UNSUPPORTED;
  249. }
  250. HashInfo = GetHashInfo (HashAlgorithm);
  251. if (HashInfo == NULL) {
  252. return EFI_UNSUPPORTED;
  253. }
  254. *HashSize = HashInfo->HashSize;
  255. return EFI_SUCCESS;
  256. }
  257. /**
  258. Creates a hash for the specified message text. The hash is not extendable.
  259. The output is final with any algorithm-required padding added by the function.
  260. @param[in] This Points to this instance of EFI_HASH2_PROTOCOL.
  261. @param[in] HashAlgorithm Points to the EFI_GUID which identifies the algorithm to use.
  262. @param[in] Message Points to the start of the message.
  263. @param[in] MessageSize The size of Message, in bytes.
  264. @param[in,out] Hash On input, points to a caller-allocated buffer of the size
  265. returned by GetHashSize() for the specified HashAlgorithm.
  266. On output, the buffer holds the resulting hash computed from the message.
  267. @retval EFI_SUCCESS Hash returned successfully.
  268. @retval EFI_INVALID_PARAMETER This or Hash is NULL.
  269. @retval EFI_UNSUPPORTED The algorithm specified by HashAlgorithm is not supported by this driver
  270. or HashAlgorithm is Null.
  271. @retval EFI_OUT_OF_RESOURCES Some resource required by the function is not available
  272. or MessageSize is greater than platform maximum.
  273. **/
  274. EFI_STATUS
  275. EFIAPI
  276. BaseCrypto2Hash (
  277. IN CONST EFI_HASH2_PROTOCOL *This,
  278. IN CONST EFI_GUID *HashAlgorithm,
  279. IN CONST UINT8 *Message,
  280. IN UINTN MessageSize,
  281. IN OUT EFI_HASH2_OUTPUT *Hash
  282. )
  283. {
  284. EFI_HASH_INFO *HashInfo;
  285. VOID *HashCtx;
  286. UINTN CtxSize;
  287. BOOLEAN Ret;
  288. EFI_STATUS Status;
  289. HASH2_INSTANCE_DATA *Instance;
  290. Status = EFI_SUCCESS;
  291. if ((This == NULL) || (Hash == NULL)) {
  292. return EFI_INVALID_PARAMETER;
  293. }
  294. if (HashAlgorithm == NULL) {
  295. return EFI_UNSUPPORTED;
  296. }
  297. HashInfo = GetHashInfo (HashAlgorithm);
  298. if (HashInfo == NULL) {
  299. return EFI_UNSUPPORTED;
  300. }
  301. Instance = HASH2_INSTANCE_DATA_FROM_THIS (This);
  302. if (Instance->HashContext != NULL) {
  303. FreePool (Instance->HashContext);
  304. }
  305. Instance->HashInfoContext = NULL;
  306. Instance->HashContext = NULL;
  307. //
  308. // Start hash sequence
  309. //
  310. CtxSize = HashInfo->GetContextSize ();
  311. if (CtxSize == 0) {
  312. return EFI_UNSUPPORTED;
  313. }
  314. HashCtx = AllocatePool (CtxSize);
  315. if (HashCtx == NULL) {
  316. return EFI_OUT_OF_RESOURCES;
  317. }
  318. Ret = HashInfo->Init (HashCtx);
  319. if (!Ret) {
  320. Status = EFI_OUT_OF_RESOURCES;
  321. goto Done;
  322. }
  323. //
  324. // Setup the context
  325. //
  326. Instance->HashContext = HashCtx;
  327. Instance->HashInfoContext = HashInfo;
  328. Ret = HashInfo->Update (HashCtx, Message, MessageSize);
  329. if (!Ret) {
  330. Status = EFI_OUT_OF_RESOURCES;
  331. goto Done;
  332. }
  333. Ret = HashInfo->Final (HashCtx, (UINT8 *)Hash->Sha1Hash);
  334. if (!Ret) {
  335. Status = EFI_OUT_OF_RESOURCES;
  336. goto Done;
  337. }
  338. Done:
  339. //
  340. // Cleanup the context
  341. //
  342. FreePool (HashCtx);
  343. Instance->HashInfoContext = NULL;
  344. Instance->HashContext = NULL;
  345. return Status;
  346. }
  347. /**
  348. This function must be called to initialize a digest calculation to be subsequently performed using the
  349. EFI_HASH2_PROTOCOL functions HashUpdate() and HashFinal().
  350. @param[in] This Points to this instance of EFI_HASH2_PROTOCOL.
  351. @param[in] HashAlgorithm Points to the EFI_GUID which identifies the algorithm to use.
  352. @retval EFI_SUCCESS Initialized successfully.
  353. @retval EFI_INVALID_PARAMETER This is NULL.
  354. @retval EFI_UNSUPPORTED The algorithm specified by HashAlgorithm is not supported by this driver
  355. or HashAlgorithm is Null.
  356. @retval EFI_OUT_OF_RESOURCES Process failed due to lack of required resource.
  357. @retval EFI_ALREADY_STARTED This function is called when the operation in progress is still in processing Hash(),
  358. or HashInit() is already called before and not terminated by HashFinal() yet on the same instance.
  359. **/
  360. EFI_STATUS
  361. EFIAPI
  362. BaseCrypto2HashInit (
  363. IN CONST EFI_HASH2_PROTOCOL *This,
  364. IN CONST EFI_GUID *HashAlgorithm
  365. )
  366. {
  367. EFI_HASH_INFO *HashInfo;
  368. VOID *HashCtx;
  369. UINTN CtxSize;
  370. BOOLEAN Ret;
  371. HASH2_INSTANCE_DATA *Instance;
  372. if (This == NULL) {
  373. return EFI_INVALID_PARAMETER;
  374. }
  375. if (HashAlgorithm == NULL) {
  376. return EFI_UNSUPPORTED;
  377. }
  378. HashInfo = GetHashInfo (HashAlgorithm);
  379. if (HashInfo == NULL) {
  380. return EFI_UNSUPPORTED;
  381. }
  382. //
  383. // Consistency Check
  384. //
  385. Instance = HASH2_INSTANCE_DATA_FROM_THIS (This);
  386. if ((Instance->HashContext != NULL) || (Instance->HashInfoContext != NULL)) {
  387. return EFI_ALREADY_STARTED;
  388. }
  389. //
  390. // Start hash sequence
  391. //
  392. CtxSize = HashInfo->GetContextSize ();
  393. if (CtxSize == 0) {
  394. return EFI_UNSUPPORTED;
  395. }
  396. HashCtx = AllocatePool (CtxSize);
  397. if (HashCtx == NULL) {
  398. return EFI_OUT_OF_RESOURCES;
  399. }
  400. Ret = HashInfo->Init (HashCtx);
  401. if (!Ret) {
  402. FreePool (HashCtx);
  403. return EFI_OUT_OF_RESOURCES;
  404. }
  405. //
  406. // Setup the context
  407. //
  408. Instance->HashContext = HashCtx;
  409. Instance->HashInfoContext = HashInfo;
  410. Instance->Updated = FALSE;
  411. return EFI_SUCCESS;
  412. }
  413. /**
  414. Updates the hash of a computation in progress by adding a message text.
  415. @param[in] This Points to this instance of EFI_HASH2_PROTOCOL.
  416. @param[in] Message Points to the start of the message.
  417. @param[in] MessageSize The size of Message, in bytes.
  418. @retval EFI_SUCCESS Digest in progress updated successfully.
  419. @retval EFI_INVALID_PARAMETER This or Hash is NULL.
  420. @retval EFI_OUT_OF_RESOURCES Some resource required by the function is not available
  421. or MessageSize is greater than platform maximum.
  422. @retval EFI_NOT_READY This call was not preceded by a valid call to HashInit(),
  423. or the operation in progress was terminated by a call to Hash() or HashFinal() on the same instance.
  424. **/
  425. EFI_STATUS
  426. EFIAPI
  427. BaseCrypto2HashUpdate (
  428. IN CONST EFI_HASH2_PROTOCOL *This,
  429. IN CONST UINT8 *Message,
  430. IN UINTN MessageSize
  431. )
  432. {
  433. EFI_HASH_INFO *HashInfo;
  434. VOID *HashCtx;
  435. BOOLEAN Ret;
  436. HASH2_INSTANCE_DATA *Instance;
  437. if (This == NULL) {
  438. return EFI_INVALID_PARAMETER;
  439. }
  440. //
  441. // Consistency Check
  442. //
  443. Instance = HASH2_INSTANCE_DATA_FROM_THIS (This);
  444. if ((Instance->HashContext == NULL) || (Instance->HashInfoContext == NULL)) {
  445. return EFI_NOT_READY;
  446. }
  447. HashInfo = Instance->HashInfoContext;
  448. HashCtx = Instance->HashContext;
  449. Ret = HashInfo->Update (HashCtx, Message, MessageSize);
  450. if (!Ret) {
  451. return EFI_OUT_OF_RESOURCES;
  452. }
  453. Instance->Updated = TRUE;
  454. return EFI_SUCCESS;
  455. }
  456. /**
  457. Finalizes a hash operation in progress and returns calculation result.
  458. The output is final with any necessary padding added by the function.
  459. The hash may not be further updated or extended after HashFinal().
  460. @param[in] This Points to this instance of EFI_HASH2_PROTOCOL.
  461. @param[in,out] Hash On input, points to a caller-allocated buffer of the size
  462. returned by GetHashSize() for the specified HashAlgorithm specified in preceding HashInit().
  463. On output, the buffer holds the resulting hash computed from the message.
  464. @retval EFI_SUCCESS Hash returned successfully.
  465. @retval EFI_INVALID_PARAMETER This or Hash is NULL.
  466. @retval EFI_NOT_READY This call was not preceded by a valid call to HashInit() and at least one call to HashUpdate(),
  467. or the operation in progress was canceled by a call to Hash() on the same instance.
  468. **/
  469. EFI_STATUS
  470. EFIAPI
  471. BaseCrypto2HashFinal (
  472. IN CONST EFI_HASH2_PROTOCOL *This,
  473. IN OUT EFI_HASH2_OUTPUT *Hash
  474. )
  475. {
  476. EFI_HASH_INFO *HashInfo;
  477. VOID *HashCtx;
  478. BOOLEAN Ret;
  479. HASH2_INSTANCE_DATA *Instance;
  480. if ((This == NULL) || (Hash == NULL)) {
  481. return EFI_INVALID_PARAMETER;
  482. }
  483. //
  484. // Consistency Check
  485. //
  486. Instance = HASH2_INSTANCE_DATA_FROM_THIS (This);
  487. if ((Instance->HashContext == NULL) || (Instance->HashInfoContext == NULL) ||
  488. (!Instance->Updated))
  489. {
  490. return EFI_NOT_READY;
  491. }
  492. HashInfo = Instance->HashInfoContext;
  493. HashCtx = Instance->HashContext;
  494. Ret = HashInfo->Final (HashCtx, (UINT8 *)Hash->Sha1Hash);
  495. //
  496. // Cleanup the context
  497. //
  498. FreePool (HashCtx);
  499. Instance->HashInfoContext = NULL;
  500. Instance->HashContext = NULL;
  501. Instance->Updated = FALSE;
  502. if (!Ret) {
  503. return EFI_OUT_OF_RESOURCES;
  504. }
  505. return EFI_SUCCESS;
  506. }