VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/CryptoPkg/Library/BaseCryptLibOnProtocolPpi/PeiCryptLib.c@ 107040

Last change on this file since 107040 was 99404, checked in by vboxsync, 2 years ago

Devices/EFI/FirmwareNew: Update to edk2-stable202302 and make it build, bugref:4643

  • Property svn:eol-style set to native
File size: 1.6 KB
Line 
1/** @file
2 Implements the GetCryptoServices() API that retuns a pointer to the EDK II
3 Crypto PPI.
4
5 Copyright (C) Microsoft Corporation. All rights reserved.
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8**/
9#include <PiPei.h>
10#include <Library/BaseLib.h>
11#include <Library/DebugLib.h>
12#include <Library/PeiServicesLib.h>
13#include <Ppi/Crypto.h>
14
15/**
16 Internal worker function that returns the pointer to an EDK II Crypto
17 Protocol/PPI. The layout of the PPI, DXE Protocol, and SMM Protocol are
18 identical which allows the implementation of the BaseCryptLib functions that
19 call through a Protocol/PPI to be shared for the PEI, DXE, and SMM
20 implementations.
21
22 This PEI implementation looks up the EDK II Crypto PPI and verifies the
23 version each time a crypto service is called, so it is compatible with XIP
24 PEIMs.
25**/
26VOID *
27GetCryptoServices (
28 VOID
29 )
30{
31 EFI_STATUS Status;
32 EDKII_CRYPTO_PPI *CryptoPpi;
33 UINTN Version;
34
35 CryptoPpi = NULL;
36 Status = PeiServicesLocatePpi (
37 &gEdkiiCryptoPpiGuid,
38 0,
39 NULL,
40 (VOID **)&CryptoPpi
41 );
42 if (EFI_ERROR (Status) || (CryptoPpi == NULL)) {
43 DEBUG ((DEBUG_ERROR, "[PeiCryptLib] Failed to locate Crypto PPI. Status = %r\n", Status));
44 ASSERT_EFI_ERROR (Status);
45 ASSERT (CryptoPpi != NULL);
46 return NULL;
47 }
48
49 Version = CryptoPpi->GetVersion ();
50 if (Version < EDKII_CRYPTO_VERSION) {
51 DEBUG ((DEBUG_ERROR, "[PeiCryptLib] Crypto PPI unsupported version %d\n", Version));
52 ASSERT (Version >= EDKII_CRYPTO_VERSION);
53 return NULL;
54 }
55
56 return (VOID *)CryptoPpi;
57}
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette