Files
system76-edk2/RedfishPkg/Library/RedfishPlatformCredentialIpmiLib/RedfishPlatformCredentialIpmiLib.h
Nickle Wang 6f0c65cdb0 RedfishPkg/RedfishPlatformCredentialIpmiLib: IPMI implementation
This library follows Redfish Host Interface specification and use IPMI
command to get bootstrap account credential(NetFn 2Ch, Command 02h)
from BMC. RedfishHostInterfaceDxe will use this credential for the
following communication between BIOS and BMC.

Signed-off-by: Nickle Wang <nicklew@nvidia.com>
Cc: Abner Chang <abner.chang@amd.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Cc: Nick Ramirez <nramirez@nvidia.com>
Reviewed-by: Igor Kulchytskyy <igork@ami.com>
2023-03-30 13:42:53 +00:00

90 lines
3.9 KiB
C

/** @file
Header file for RedfishPlatformCredentialIpmiLib.
Copyright (c) 2022-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef REDFISH_PLATFORM_CREDENTIAL_IPMI_LIB_H_
#define REDFISH_PLATFORM_CREDENTIAL_IPMI_LIB_H_
#include <Uefi.h>
#include <IndustryStandard/Ipmi.h>
#include <IndustryStandard/RedfishHostInterfaceIpmi.h>
#include <Protocol/EdkIIRedfishCredential.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/IpmiLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/RedfishCredentialLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#define CREDENTIAL_VARIABLE_NAME L"Partstooblaitnederc"
///
/// The bootstrap credential keeping in UEFI variable
///
typedef struct {
CHAR8 Username[USERNAME_MAX_SIZE];
CHAR8 Password[PASSWORD_MAX_SIZE];
} BOOTSTRAP_CREDENTIALS_VARIABLE;
/**
Function to retrieve temporary user credentials for the UEFI redfish client. This function can
also disable bootstrap credential service in BMC.
@param[in] DisableBootstrapControl TRUE - Tell the BMC to disable the bootstrap credential
service to ensure no one else gains credentials
FALSE Allow the bootstrap credential service to continue
@param[in,out] BootstrapUsername A pointer to a Ascii encoded string for the credential username
When DisableBootstrapControl is TRUE, this pointer can be NULL
@param[in] BootstrapUsernameSize The size of BootstrapUsername including NULL terminator in bytes.
Per specification, the size is USERNAME_MAX_SIZE.
@param[in,out] BootstrapPassword A pointer to a Ascii encoded string for the credential password
When DisableBootstrapControl is TRUE, this pointer can be NULL
@param[in] BootstrapPasswordSize The size of BootstrapPassword including NULL terminator in bytes.
Per specification, the size is PASSWORD_MAX_SIZE.
@retval EFI_SUCCESS Credentials were successfully fetched and returned. When DisableBootstrapControl
is set to TRUE, the bootstrap credential service is disabled successfully.
@retval EFI_INVALID_PARAMETER BootstrapUsername or BootstrapPassword is NULL when DisableBootstrapControl
is set to FALSE. BootstrapUsernameSize or BootstrapPasswordSize is incorrect when
DisableBootstrapControl is set to FALSE.
@retval EFI_DEVICE_ERROR An IPMI failure occurred
**/
EFI_STATUS
GetBootstrapAccountCredentials (
IN BOOLEAN DisableBootstrapControl,
IN OUT CHAR8 *BootstrapUsername, OPTIONAL
IN UINTN BootstrapUsernameSize,
IN OUT CHAR8 *BootstrapPassword, OPTIONAL
IN UINTN BootstrapPasswordSize
);
/**
Function to save temporary user credentials into boot time variable. When DeleteVariable is True,
this function delete boot time variable.
@param[in] BootstrapUsername A pointer to a Ascii encoded string for the credential username.
@param[in] BootstrapPassword A pointer to a Ascii encoded string for the credential password.
@param[in] DeleteVariable True to remove boot time variable. False otherwise.
@retval EFI_SUCCESS Credentials were successfully saved.
@retval EFI_INVALID_PARAMETER BootstrapUsername or BootstrapPassword is NULL
@retval Others Error occurs
**/
EFI_STATUS
SetBootstrapAccountCredentialsToVariable (
IN CHAR8 *BootstrapUsername, OPTIONAL
IN CHAR8 *BootstrapPassword, OPTIONAL
IN BOOLEAN DeleteVariable
);
#endif