]> git.proxmox.com Git - mirror_edk2.git/blame - CryptoPkg/Library/BaseCryptLibOnProtocolPpi/DxeCryptLib.c
Revert "TlsAuthConfigDxe: fix TlsCaCertificate attributes retrieval"
[mirror_edk2.git] / CryptoPkg / Library / BaseCryptLibOnProtocolPpi / DxeCryptLib.c
CommitLineData
cd70de1c
MK
1/** @file\r
2 Implements the GetCryptoServices() API that retuns a pointer to the EDK II\r
3 Crypto Protocol.\r
4\r
5 Copyright (C) Microsoft Corporation. All rights reserved.\r
6 SPDX-License-Identifier: BSD-2-Clause-Patent\r
7\r
8**/\r
9#include <PiDxe.h>\r
10#include <Library/BaseLib.h>\r
11#include <Library/DebugLib.h>\r
12#include <Library/UefiBootServicesTableLib.h>\r
13#include <Protocol/Crypto.h>\r
14\r
15EDKII_CRYPTO_PROTOCOL *mCryptoProtocol = NULL;\r
16\r
17/**\r
18 Internal worker function that returns the pointer to an EDK II Crypto\r
19 Protocol/PPI. The layout of the PPI, DXE Protocol, and SMM Protocol are\r
20 identical which allows the implementation of the BaseCryptLib functions that\r
21 call through a Protocol/PPI to be shared for the PEI, DXE, and SMM\r
22 implementations.\r
23\r
24 This DXE implementation returns the pointer to the EDK II Crypto Protocol\r
25 that was found in the library constructor DxeCryptLibConstructor().\r
26**/\r
27VOID *\r
28GetCryptoServices (\r
29 VOID\r
30 )\r
31{\r
32 return (VOID *)mCryptoProtocol;\r
33}\r
34\r
35EFI_STATUS\r
36EFIAPI\r
37DxeCryptLibConstructor (\r
38 IN EFI_HANDLE ImageHandle,\r
39 IN EFI_SYSTEM_TABLE *SystemTable\r
40 )\r
41{\r
42 EFI_STATUS Status;\r
43 UINTN Version;\r
44\r
45 Status = gBS->LocateProtocol (\r
46 &gEdkiiCryptoProtocolGuid,\r
47 NULL,\r
48 (VOID **)&mCryptoProtocol\r
49 );\r
50\r
51 if (EFI_ERROR (Status) || mCryptoProtocol == NULL) {\r
52 DEBUG((DEBUG_ERROR, "[DxeCryptLib] Failed to locate Crypto Protocol. Status = %r\n", Status));\r
53 ASSERT_EFI_ERROR (Status);\r
54 ASSERT (mCryptoProtocol != NULL);\r
55 mCryptoProtocol = NULL;\r
56 return EFI_NOT_FOUND;\r
57 }\r
58\r
59 Version = mCryptoProtocol->GetVersion ();\r
60 if (Version < EDKII_CRYPTO_VERSION) {\r
61 DEBUG((DEBUG_ERROR, "[DxeCryptLib] Crypto Protocol unsupported version %d\n", Version));\r
62 ASSERT (Version >= EDKII_CRYPTO_VERSION);\r
63 mCryptoProtocol = NULL;\r
64 return EFI_NOT_FOUND;\r
65 }\r
66\r
67 return EFI_SUCCESS;\r
68}\r