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/UefiBootServicesTableLib.h>
13 #include <Protocol/Crypto.h>
15 EDKII_CRYPTO_PROTOCOL
*mCryptoProtocol
= NULL
;
18 Internal worker function that returns the pointer to an EDK II Crypto
19 Protocol/PPI. The layout of the PPI, DXE Protocol, and SMM Protocol are
20 identical which allows the implementation of the BaseCryptLib functions that
21 call through a Protocol/PPI to be shared for the PEI, DXE, and SMM
24 This DXE implementation returns the pointer to the EDK II Crypto Protocol
25 that was found in the library constructor DxeCryptLibConstructor().
32 return (VOID
*)mCryptoProtocol
;
37 DxeCryptLibConstructor (
38 IN EFI_HANDLE ImageHandle
,
39 IN EFI_SYSTEM_TABLE
*SystemTable
45 Status
= gBS
->LocateProtocol (
46 &gEdkiiCryptoProtocolGuid
,
48 (VOID
**)&mCryptoProtocol
51 if (EFI_ERROR (Status
) || mCryptoProtocol
== NULL
) {
52 DEBUG((DEBUG_ERROR
, "[DxeCryptLib] Failed to locate Crypto Protocol. Status = %r\n", Status
));
53 ASSERT_EFI_ERROR (Status
);
54 ASSERT (mCryptoProtocol
!= NULL
);
55 mCryptoProtocol
= NULL
;
59 Version
= mCryptoProtocol
->GetVersion ();
60 if (Version
< EDKII_CRYPTO_VERSION
) {
61 DEBUG((DEBUG_ERROR
, "[DxeCryptLib] Crypto Protocol unsupported version %d\n", Version
));
62 ASSERT (Version
>= EDKII_CRYPTO_VERSION
);
63 mCryptoProtocol
= NULL
;