TianoCore EDK2 master
Loading...
Searching...
No Matches
SmmCryptLib.c
Go to the documentation of this file.
1
10#include <PiSmm.h>
11#include <Library/BaseLib.h>
12#include <Library/DebugLib.h>
14#include <Protocol/SmmCrypto.h>
15
16EDKII_SMM_CRYPTO_PROTOCOL *mSmmCryptoProtocol = NULL;
17
28VOID *
30 VOID
31 )
32{
33 return (VOID *)mSmmCryptoProtocol;
34}
35
48EFIAPI
50 IN EFI_HANDLE ImageHandle,
51 IN EFI_SYSTEM_TABLE *SystemTable
52 )
53{
54 EFI_STATUS Status;
55 UINTN Version;
56
57 Status = gSmst->SmmLocateProtocol (
58 &gEdkiiSmmCryptoProtocolGuid,
59 NULL,
60 (VOID **)&mSmmCryptoProtocol
61 );
62 if (EFI_ERROR (Status) || (mSmmCryptoProtocol == NULL)) {
63 DEBUG ((DEBUG_ERROR, "[SmmCryptLib] Failed to locate Crypto SMM Protocol. Status = %r\n", Status));
64 ASSERT_EFI_ERROR (Status);
65 ASSERT (mSmmCryptoProtocol != NULL);
66 mSmmCryptoProtocol = NULL;
67 return EFI_NOT_FOUND;
68 }
69
70 Version = mSmmCryptoProtocol->GetVersion ();
71 if (Version < EDKII_CRYPTO_VERSION) {
72 DEBUG ((DEBUG_ERROR, "[SmmCryptLib] Crypto SMM Protocol unsupported version %d\n", Version));
73 ASSERT (Version >= EDKII_CRYPTO_VERSION);
74 mSmmCryptoProtocol = NULL;
75 return EFI_NOT_FOUND;
76 }
77
78 return EFI_SUCCESS;
79}
UINT64 UINTN
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
#define DEBUG(Expression)
Definition: DebugLib.h:434
EFI_SMM_SYSTEM_TABLE2 * gSmst
#define EDKII_CRYPTO_VERSION
Definition: Crypto.h:24
EFI_STATUS EFIAPI SmmCryptLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition: SmmCryptLib.c:49
VOID * GetCryptoServices(VOID)
Definition: SmmCryptLib.c:29
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EDKII_CRYPTO_GET_VERSION GetVersion
Version.
Definition: Crypto.h:5432