]>
git.proxmox.com Git - mirror_edk2.git/blob - CryptoPkg/Library/BaseCryptLibOnProtocolPpi/PeiCryptLib.c
2 Implements the GetCryptoServices() API that retuns a pointer to the EDK II
5 Copyright (C) Microsoft Corporation. All rights reserved.
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include <Library/BaseLib.h>
11 #include <Library/DebugLib.h>
12 #include <Library/PeiServicesLib.h>
13 #include <Ppi/Crypto.h>
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
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
32 EDKII_CRYPTO_PPI
*CryptoPpi
;
36 Status
= PeiServicesLocatePpi (
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
);
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
);
56 return (VOID
*)CryptoPpi
;