summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDandan Bi <dandan.bi@intel.com>2016-11-25 14:39:32 +0800
committerStar Zeng <star.zeng@intel.com>2016-11-25 14:56:01 +0800
commit52e7754ed0a1edd5fa853fa52c37ec9fb1d06a5f (patch)
tree3a65e95bbb6adcc4282cd3509789eef967205669
parentff0a57ffde87b1ea6c68535081e4d5e407afb9df (diff)
downloadedk2-52e7754ed0a1edd5fa853fa52c37ec9fb1d06a5f.tar.gz
MdeModulePkg/DriverSample: Remove the password related codes
In current DriverSampleDxe, the sample code of password is not a good example, so we plan to remove it. Cc: Liming Gao <liming.gao@intel.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
-rw-r--r--MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c265
-rw-r--r--MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h3
-rw-r--r--MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h4
-rw-r--r--MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr21
-rw-r--r--MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.unibin61414 -> 59550 bytes
5 files changed, 4 insertions, 289 deletions
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
index 204c043ff4..e2fda580b7 100644
--- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
+++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
@@ -2,7 +2,7 @@
This is an example of how a driver might export data to the HII protocol to be
later utilized by the Setup Protocol
-Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -219,233 +219,6 @@ InternalStopMonitor(
return EFI_SUCCESS;
}
-
-/**
- Encode the password using a simple algorithm.
-
- @param Password The string to be encoded.
- @param MaxSize The size of the string.
-
-**/
-VOID
-EncodePassword (
- IN CHAR16 *Password,
- IN UINTN MaxSize
- )
-{
- UINTN Index;
- UINTN Loop;
- CHAR16 *Buffer;
- CHAR16 *Key;
-
- Key = L"MAR10648567";
- Buffer = AllocateZeroPool (MaxSize);
- ASSERT (Buffer != NULL);
-
- for (Index = 0; Key[Index] != 0; Index++) {
- for (Loop = 0; Loop < (UINT8) (MaxSize / 2); Loop++) {
- Buffer[Loop] = (CHAR16) (Password[Loop] ^ Key[Index]);
- }
- }
-
- CopyMem (Password, Buffer, MaxSize);
-
- FreePool (Buffer);
- return ;
-}
-
-/**
- Validate the user's password.
-
- @param PrivateData This driver's private context data.
- @param StringId The user's input.
-
- @retval EFI_SUCCESS The user's input matches the password.
- @retval EFI_NOT_READY The user's input does not match the password.
-**/
-EFI_STATUS
-ValidatePassword (
- IN DRIVER_SAMPLE_PRIVATE_DATA *PrivateData,
- IN EFI_STRING_ID StringId
- )
-{
- EFI_STATUS Status;
- UINTN Index;
- UINTN BufferSize;
- UINTN PasswordMaxSize;
- CHAR16 *Password;
- CHAR16 *EncodedPassword;
- BOOLEAN OldPassword;
-
- //
- // Get encoded password first
- //
- BufferSize = sizeof (DRIVER_SAMPLE_CONFIGURATION);
- Status = gRT->GetVariable (
- VariableName,
- &gDriverSampleFormSetGuid,
- NULL,
- &BufferSize,
- &PrivateData->Configuration
- );
- if (EFI_ERROR (Status)) {
- //
- // Old password not exist, prompt for new password
- //
- return EFI_SUCCESS;
- }
-
- OldPassword = FALSE;
- PasswordMaxSize = sizeof (PrivateData->Configuration.WhatIsThePassword2);
- //
- // Check whether we have any old password set
- //
- for (Index = 0; Index < PasswordMaxSize / sizeof (UINT16); Index++) {
- if (PrivateData->Configuration.WhatIsThePassword2[Index] != 0) {
- OldPassword = TRUE;
- break;
- }
- }
- if (!OldPassword) {
- //
- // Old password not exist, return EFI_SUCCESS to prompt for new password
- //
- return EFI_SUCCESS;
- }
-
- //
- // Get user input password
- //
- Password = HiiGetString (PrivateData->HiiHandle[0], StringId, NULL);
- if (Password == NULL) {
- return EFI_NOT_READY;
- }
- if (StrSize (Password) > PasswordMaxSize) {
- FreePool (Password);
- return EFI_NOT_READY;
- }
-
- //
- // Validate old password
- //
- EncodedPassword = AllocateZeroPool (PasswordMaxSize);
- ASSERT (EncodedPassword != NULL);
- StrnCpy (EncodedPassword, Password, StrLen (Password));
- EncodePassword (EncodedPassword, StrLen (EncodedPassword) * sizeof (CHAR16));
- if (CompareMem (EncodedPassword, PrivateData->Configuration.WhatIsThePassword2, PasswordMaxSize) != 0) {
- //
- // Old password mismatch, return EFI_NOT_READY to prompt for error message
- //
- Status = EFI_NOT_READY;
- } else {
- Status = EFI_SUCCESS;
- }
-
- FreePool (Password);
- FreePool (EncodedPassword);
-
- return Status;
-}
-
-/**
- Encode the password using a simple algorithm.
-
- @param PrivateData This driver's private context data.
- @param StringId The password from User.
-
- @retval EFI_SUCESS The operation is successful.
- @return Other value if gRT->SetVariable () fails.
-
-**/
-EFI_STATUS
-SetPassword (
- IN DRIVER_SAMPLE_PRIVATE_DATA *PrivateData,
- IN EFI_STRING_ID StringId
- )
-{
- EFI_STATUS Status;
- CHAR16 *Password;
- CHAR16 *TempPassword;
- UINTN PasswordSize;
- DRIVER_SAMPLE_CONFIGURATION *Configuration;
- UINTN BufferSize;
-
- //
- // Get Buffer Storage data from EFI variable
- //
- BufferSize = sizeof (DRIVER_SAMPLE_CONFIGURATION);
- Status = gRT->GetVariable (
- VariableName,
- &gDriverSampleFormSetGuid,
- NULL,
- &BufferSize,
- &PrivateData->Configuration
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Get user input password
- //
- Password = PrivateData->Configuration.WhatIsThePassword2;
- PasswordSize = sizeof (PrivateData->Configuration.WhatIsThePassword2);
- ZeroMem (Password, PasswordSize);
-
- TempPassword = HiiGetString (PrivateData->HiiHandle[0], StringId, NULL);
- if (TempPassword == NULL) {
- return EFI_NOT_READY;
- }
- if (StrSize (TempPassword) > PasswordSize) {
- FreePool (TempPassword);
- return EFI_NOT_READY;
- }
- StrnCpy (Password, TempPassword, StrLen (TempPassword));
- FreePool (TempPassword);
-
- //
- // Retrive uncommitted data from Browser
- //
- Configuration = AllocateZeroPool (sizeof (DRIVER_SAMPLE_CONFIGURATION));
- ASSERT (Configuration != NULL);
- if (HiiGetBrowserData (&gDriverSampleFormSetGuid, VariableName, sizeof (DRIVER_SAMPLE_CONFIGURATION), (UINT8 *) Configuration)) {
- //
- // Update password's clear text in the screen
- //
- CopyMem (Configuration->PasswordClearText, Password, StrSize (Password));
-
- //
- // Update uncommitted data of Browser
- //
- HiiSetBrowserData (
- &gDriverSampleFormSetGuid,
- VariableName,
- sizeof (DRIVER_SAMPLE_CONFIGURATION),
- (UINT8 *) Configuration,
- NULL
- );
- }
-
- //
- // Free Configuration Buffer
- //
- FreePool (Configuration);
-
-
- //
- // Set password
- //
- EncodePassword (Password, StrLen (Password) * 2);
- Status = gRT->SetVariable(
- VariableName,
- &gDriverSampleFormSetGuid,
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
- sizeof (DRIVER_SAMPLE_CONFIGURATION),
- &PrivateData->Configuration
- );
- return Status;
-}
-
/**
Update names of Name/Value storage to current language.
@@ -1667,41 +1440,6 @@ DriverCallback (
FreePool (EfiData);
}
break;
-
- case 0x2000:
- //
- // Only used to update the state.
- //
- if ((Type == EFI_IFR_TYPE_STRING) && (Value->string == 0) &&
- (PrivateData->PasswordState == BROWSER_STATE_SET_PASSWORD)) {
- PrivateData->PasswordState = BROWSER_STATE_VALIDATE_PASSWORD;
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // When try to set a new password, user will be chanlleged with old password.
- // The Callback is responsible for validating old password input by user,
- // If Callback return EFI_SUCCESS, it indicates validation pass.
- //
- switch (PrivateData->PasswordState) {
- case BROWSER_STATE_VALIDATE_PASSWORD:
- Status = ValidatePassword (PrivateData, Value->string);
- if (Status == EFI_SUCCESS) {
- PrivateData->PasswordState = BROWSER_STATE_SET_PASSWORD;
- }
- break;
-
- case BROWSER_STATE_SET_PASSWORD:
- Status = SetPassword (PrivateData, Value->string);
- PrivateData->PasswordState = BROWSER_STATE_VALIDATE_PASSWORD;
- break;
-
- default:
- break;
- }
-
- break;
-
default:
break;
}
@@ -1829,7 +1567,6 @@ DriverSampleInit (
PrivateData->ConfigAccess.ExtractConfig = ExtractConfig;
PrivateData->ConfigAccess.RouteConfig = RouteConfig;
PrivateData->ConfigAccess.Callback = DriverCallback;
- PrivateData->PasswordState = BROWSER_STATE_VALIDATE_PASSWORD;
//
// Locate Hii Database protocol
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h
index 29870c0f1f..a1e3e4571d 100644
--- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h
+++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -83,7 +83,6 @@ typedef struct {
EFI_HII_HANDLE HiiHandle[2];
DRIVER_SAMPLE_CONFIGURATION Configuration;
MY_EFI_VARSTORE_DATA VarStoreConfig;
- UINT8 PasswordState;
//
// Name/Value storage Name list
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h b/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h
index 49242ad5ef..4752b85132 100644
--- a/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h
+++ b/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -34,9 +34,7 @@ Revision History:
#pragma pack(1)
typedef struct {
- UINT16 WhatIsThePassword2[20];
UINT16 MyStringData[40];
- UINT16 PasswordClearText[20];
UINT16 SomethingHiddenForHtml;
UINT8 HowOldAreYouInYearsManual;
UINT16 HowTallAreYouManual;
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr b/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr
index 4e90abece4..87e0b78b70 100644
--- a/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr
+++ b/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr
@@ -2,7 +2,7 @@
//
// Sample Setup formset.
//
-// Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
+// Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
// This program and the accompanying materials
// are licensed and made available under the terms and conditions of the BSD License
// which accompanies this distribution. The full text of the license may be found at
@@ -443,25 +443,6 @@ formset
help = STRING_TOKEN(STR_MANUFACTURE_DEFAULT_HELP),
endresetbutton;
- string varid = MyIfrNVData.PasswordClearText,
- prompt = STRING_TOKEN(STR_MY_STRING_PROMPT),
- help = STRING_TOKEN(STR_MY_STRING_HELP),
- minsize = 6,
- maxsize = 0x14,
- endstring;
-
- //
- // Interactive password, validate via ConfigAccess.Callback()
- //
- password varid = MyIfrNVData.WhatIsThePassword2,
- prompt = STRING_TOKEN(STR_PASSWORD_CALLBACK_PROMPT),
- help = STRING_TOKEN(STR_PASSWORD_HELP),
- flags = INTERACTIVE,
- key = 0x2000,
- minsize = 6,
- maxsize = 20,
- endpassword;
-
//
// Sample use case for IFR Security op-code
//
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni b/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni
index 05dba38b9e..571a6cd9d4 100644
--- a/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni
+++ b/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni
Binary files differ