1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
/** @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
|