summaryrefslogtreecommitdiff
path: root/EDK/MiniSetup/PasswordEncode
diff options
context:
space:
mode:
Diffstat (limited to 'EDK/MiniSetup/PasswordEncode')
-rw-r--r--EDK/MiniSetup/PasswordEncode/PasswordEncode.c217
-rw-r--r--EDK/MiniSetup/PasswordEncode/PasswordEncode.h71
-rw-r--r--EDK/MiniSetup/PasswordEncode/PasswordEncodeBin.cif13
-rw-r--r--EDK/MiniSetup/PasswordEncode/PasswordEncodeBin.mak98
-rw-r--r--EDK/MiniSetup/PasswordEncode/PasswordEncodeBin.sdl34
-rw-r--r--EDK/MiniSetup/PasswordEncode/TsePasswordEncode.libbin0 -> 1568 bytes
-rw-r--r--EDK/MiniSetup/PasswordEncode/TsePasswordEncodex64.libbin0 -> 1776 bytes
7 files changed, 433 insertions, 0 deletions
diff --git a/EDK/MiniSetup/PasswordEncode/PasswordEncode.c b/EDK/MiniSetup/PasswordEncode/PasswordEncode.c
new file mode 100644
index 0000000..8af67e9
--- /dev/null
+++ b/EDK/MiniSetup/PasswordEncode/PasswordEncode.c
@@ -0,0 +1,217 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/BIN/Modules/AMITSE2_0/AMITSE/PasswordEncode/PasswordEncode.c $
+//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: PasswordEncode.c
+//
+// Description: This file contains code to handle password encoding feature
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+//
+
+
+#include "PasswordEncode.h"
+
+INTN MemCmp(VOID* pDestination, VOID* pSource, UINTN Length);
+
+BOOLEAN TseEfiCompareGuid (IN EFI_GUID *Guid1,IN EFI_GUID *Guid2)
+{
+ return !MemCmp(Guid1,Guid2,sizeof(EFI_GUID));
+}
+
+VOID
+TseMemCopy (
+ IN VOID *Destination,
+ IN VOID *Source,
+ IN UINTN Length
+ )
+/*++
+
+Routine Description:
+
+ Copy Length bytes from Source to Destination.
+
+Arguments:
+
+ Destination - Target of copy
+
+ Source - Place to copy from
+
+ Length - Number of bytes to copy
+
+Returns:
+
+ None
+
+--*/
+{
+ CHAR8 *Destination8;
+ CHAR8 *Source8;
+
+ if (Source < Destination) {
+ Destination8 = (CHAR8 *) Destination + Length - 1;
+ Source8 = (CHAR8 *) Source + Length - 1;
+ while (Length--) {
+ *(Destination8--) = *(Source8--);
+ }
+ } else {
+ Destination8 = (CHAR8 *) Destination;
+ Source8 = (CHAR8 *) Source;
+ while (Length--) {
+ *(Destination8++) = *(Source8++);
+ }
+ }
+}
+
+
+//**********************************************************************
+//<AMI_PHDR_START>
+//
+// Procedure: Hash
+//
+// Description: Allows creating a hash of an arbitrary message digest using one or more hash algorithms
+//
+// Input:
+// This Pointer to the AMI_DIGITAL_SIGNATURE_PROTOCOL instance.
+// HashAlgorithm Points to the EFI_GUID which identifies the algorithm to use.
+// num_elem Number of blocks to be passed via next argument:addr[]
+// addr[] Pointer to array of UINT8* addresses of data blocks to be hashed
+// len Pointer to array of integers containing length of each block listed by addr[]
+// Hash Holds the resulting hash computed from the message.
+//
+// Output:
+// EFI_SUCCESS Hash returned successfully.
+// EFI_INVALID_PARAMETER Message or Hash is NULL
+// EFI_UNSUPPORTED The algorithm specified by HashAlgorithm is not supported by this
+// driver. Or extend is TRUE and the algorithm doesn't support extending the hash.
+//
+//<AMI_PHDR_END>
+//**********************************************************************
+#if TSE_HASH_PASSWORD
+EFI_STATUS Hash(
+ IN CONST EFI_GUID *HashAlgorithm,
+ IN UINTN num_elem,
+ IN CONST UINT8 *stringToHash[],
+ IN CONST UINTN *HashSize,
+ OUT UINT8 *HashOutput
+ )
+{
+ BOOLEAN bSha1 = FALSE, bSha256 = FALSE;
+ UINT32 HashLen=SHA256_DIGEST_SIZE;
+
+ // Support only SHA1 & SHA256 hashes
+ if(TseEfiCompareGuid((EFI_GUID*)HashAlgorithm, &gEfiHashAlgorithmSha1Guid))
+ {
+ bSha1 = TRUE;
+ HashLen = SHA1_DIGEST_SIZE;
+ }
+ else
+ if(TseEfiCompareGuid((EFI_GUID*)HashAlgorithm, &gEfiHashAlgorithmSha256Guid))
+ {
+ bSha256 = TRUE;
+ HashLen = SHA256_DIGEST_SIZE;
+ }
+ else
+ return EFI_UNSUPPORTED;
+
+ MemSet(HashOutput, HashLen, 0);
+
+ if(bSha1)
+ sha1_vector(num_elem, stringToHash, HashSize, HashOutput);
+ else
+ sha256_vector(num_elem, stringToHash, HashSize, HashOutput);
+
+ return EFI_SUCCESS;
+}
+#endif
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PasswordEncodeLocal
+//
+// Description: Encodes the input string
+//
+// Input: Password : Password array to be encrypted. Encryped
+// password is returned in the same array.
+// MaxSize : Max size of Password
+//
+// Output: VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT8 HashOutput[20];
+VOID TsePasswordEncodeLocal( CHAR16 *Password, UINTN MaxSize);
+VOID PasswordEncode( CHAR16 *Password, UINTN MaxSize)
+{
+#if TSE_HASH_PASSWORD
+ UINTN ii;
+ EFI_STATUS Status;
+ UINTN HashSize = SHA1_DIGEST_SIZE;
+
+ if (IsPasswordSupportNonCaseSensitive ())
+ {
+ for ( ii = 0; ii < MaxSize/2; ii++ )
+ Password[ii] = ((Password[ii]>=L'a')&&(Password[ii]<=L'z'))?(Password[ii]+L'A'-L'a'):Password[ii];
+ }
+
+ Status = Hash(&gEfiHashAlgorithmSha1Guid, TRUE, (CONST UINT8**)&Password, (CONST UINTN*)&MaxSize, (UINT8*)&HashOutput);
+ if (!EFI_ERROR (Status))
+ {
+ MemSet (Password, MaxSize, 0);
+ TseMemCopy ((UINT8*)Password, (UINT8*)HashOutput, HashSize);
+ }
+#else
+ TsePasswordEncodeLocal (Password, MaxSize);
+#endif
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: IsPasswordSupportNonCaseSensitive
+//
+// Description: Returns SETUP_PASSWORD_NON_CASE_SENSITIVE token value
+//
+// Input: void
+//
+// Output: BOOLEAN
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+BOOLEAN IsPasswordSupportNonCaseSensitive()
+{
+#if SETUP_PASSWORD_NON_CASE_SENSITIVE
+ return TRUE;
+#endif
+ return FALSE;
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/PasswordEncode/PasswordEncode.h b/EDK/MiniSetup/PasswordEncode/PasswordEncode.h
new file mode 100644
index 0000000..4103c51
--- /dev/null
+++ b/EDK/MiniSetup/PasswordEncode/PasswordEncode.h
@@ -0,0 +1,71 @@
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+//** **//
+//** (C)Copyright 2010, American Megatrends, Inc. **//
+//** **//
+//** All Rights Reserved. **//
+//** **//
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **//
+//** **//
+//** Phone (770)-246-8600 **//
+//** **//
+//*****************************************************************//
+//*****************************************************************//
+//*****************************************************************//
+// $Archive: /Alaska/BIN/Modules/AMITSE2_0/AMITSE/PasswordEncode/PasswordEncode.h $
+//
+//*****************************************************************//
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: password.h
+//
+// Description: Header file for code to handle password operations
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef _PASSWORDENCODE_H_
+#define _PASSWORDENCODE_H_
+
+#if TSE_USE_EDK_LIBRARY
+#include "Tiano.h"
+#else
+#include "Efi.h"
+#endif
+
+#include "token.h"
+
+#if TSE_HASH_PASSWORD
+#include "Protocol\Hash.h"
+#include "Protocol\AmiDigitalSignature.h"
+#include "Include\CryptLib.h"
+#endif
+
+///////////////////////////////////////////////////////
+// EXTERN FUNCTIONS AND VARIABLES
+//////////////////////////////////////////////////////
+extern BOOLEAN IsPasswordSupportNonCaseSensitive ();
+extern BOOLEAN IsHashingSupported (VOID);
+extern BOOLEAN EfiCompareGuid (IN EFI_GUID *Guid1,IN EFI_GUID *Guid2);
+extern VOID * EfiLibAllocateZeroPool (IN UINTN AllocationSize);
+extern VOID MemCopy( VOID *dest, VOID *src, UINTN size );
+extern VOID MemSet( VOID *buffer, UINTN size, UINT8 value );
+
+#endif /* _PASSWORDENCODE_H_ */
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/EDK/MiniSetup/PasswordEncode/PasswordEncodeBin.cif b/EDK/MiniSetup/PasswordEncode/PasswordEncodeBin.cif
new file mode 100644
index 0000000..42b209f
--- /dev/null
+++ b/EDK/MiniSetup/PasswordEncode/PasswordEncodeBin.cif
@@ -0,0 +1,13 @@
+<component>
+ name = "TSE Binary - PasswordEncode"
+ category = ModulePart
+ LocalRoot = "EDK\MiniSetup\PasswordEncode"
+ RefName = "PasswordEncodeBin"
+[files]
+"PasswordEncodeBin.sdl"
+"PasswordEncodeBin.mak"
+"PasswordEncode.c"
+"PasswordEncode.h"
+"TsePasswordEncode.lib"
+"TsePasswordEncodex64.lib"
+<endComponent>
diff --git a/EDK/MiniSetup/PasswordEncode/PasswordEncodeBin.mak b/EDK/MiniSetup/PasswordEncode/PasswordEncodeBin.mak
new file mode 100644
index 0000000..c50cb89
--- /dev/null
+++ b/EDK/MiniSetup/PasswordEncode/PasswordEncodeBin.mak
@@ -0,0 +1,98 @@
+##*****************************************************************##
+##*****************************************************************##
+##*****************************************************************##
+##** **##
+##** (C)Copyright 2004, American Megatrends, Inc. **##
+##** **##
+##** All Rights Reserved. **##
+##** **##
+##** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **##
+##** **##
+##** Phone (770)-246-8600 **##
+##** **##
+##*****************************************************************##
+##*****************************************************************##
+##*****************************************************************##
+## $Archive: /Alaska/BIN/Modules/AMITSE2_0/AMITSE/PasswordEncode/PasswordEncodeBin.mak $
+##
+## $Author: Arunsb $
+##
+## $Revision: 3 $
+##
+## $Date: 5/08/14 4:46p $
+##
+##*****************************************************************##
+##*****************************************************************##
+## Revision History
+## ----------------
+## $Log: /Alaska/BIN/Modules/AMITSE2_0/AMITSE/PasswordEncode/PasswordEncodeBin.mak $
+#
+# 3 5/08/14 4:46p Arunsb
+# [TAG] EIP162197
+# [Category] Improvement
+# [Description] Password encode feature. Modify to encode using Hashing
+# based on token.
+#
+# 2 5/02/14 10:42p Arunsb
+# If TSE_HASH_PASSWORD is not supported then CRYPTOLIB wont be linked
+#
+# 1 5/01/14 6:33p Arunsb
+# [TAG] EIP162197
+# [Category] Improvement
+# [Description] Password Encode Feature using hash algorithm
+# [Files] PasswordEncode.c, PasswordEncode.h, PasswordEncodeBin.cif,
+# PasswordEncodeBin.mak and PasswordEncodeBin.sdl
+#
+## Intial version of TSE PassworEncodeBin file sources
+##*****************************************************************##
+
+# MAK file for the eModule:PasswordEncode
+
+!if "$(TSE_HASH_PASSWORD)" == "1"
+CRYPTOLIB_TEMP = $(CRYPTOLIB)
+!else
+CRYPTOLIB_TEMP =
+!endif
+
+
+PASSWORDENCODE_INCLUDES = \
+!if "$(TSE_BOARD_SOURCE_SUPPORT)" == "1"
+ -I $(TSE_BOARD_DIR)\
+!endif
+ -I $(TSEBIN_DIR) \
+ -I $(TSEBIN_DIR)\Inc \
+ -I $(PROJECT_DIR)\Include\Protocol \
+ -I $(PROJECT_DIR) \
+ -I $(PROJECT_DIR)\Include \
+ -I $(BUILD_DIR) \
+ -I $(TSESRC_DIR)\AMILOGO \
+ -I $(TSE_STYLE_DIR) \
+ -I $(TSELITESRC_DIR) \
+ -I $(TSE_PWD_ENCODE_DIR) \
+!if "$(UEFI_SOURCES_SUPPORT)" == "1"
+ -I $(UEFISRC_DIR) \
+!endif
+
+
+All: $(BUILD_DIR)\$(TSE_PWD_ENCODE_DIR)\PasswordEncodeBin.obj
+
+$(BUILD_DIR)\$(TSE_PWD_ENCODE_DIR)\PasswordEncodeBin.obj: $(PROJECT_DIR)\$(TSE_PWD_ENCODE_DIR)\PasswordEncode.c
+ if not exist $(BUILD_DIR)\$(TSE_PWD_ENCODE_DIR) mkdir $(BUILD_DIR)\$(TSE_PWD_ENCODE_DIR)
+ $(CC) $(CFLAGS) $(PASSWORDENCODE_INCLUDES) /DTSE_FOR_APTIO_4_50 /Fo$(BUILD_DIR)\$(TSE_PWD_ENCODE_DIR)\PasswordEncodeBin.obj $(PROJECT_DIR)\$(TSE_PWD_ENCODE_DIR)\PasswordEncode.c
+
+# MAK file for the eModule:PasswordEncodeBin
+AMITSEBin: $(BUILD_DIR)\$(TSE_PWD_ENCODE_DIR)\PasswordEncodeBin.obj $(CRYPTOLIB_TEMP)
+
+##*****************************************************************##
+##*****************************************************************##
+##** **##
+##** (C)Copyright 2010, American Megatrends, Inc. **##
+##** **##
+##** All Rights Reserved. **##
+##** **##
+##** 5555 Oakbrook Pkwy, Building 200,Norcross, Georgia 30093 **##
+##** **##
+##** Phone (770)-246-8600 **##
+##** **##
+##*****************************************************************##
+##*****************************************************************##
diff --git a/EDK/MiniSetup/PasswordEncode/PasswordEncodeBin.sdl b/EDK/MiniSetup/PasswordEncode/PasswordEncodeBin.sdl
new file mode 100644
index 0000000..319678e
--- /dev/null
+++ b/EDK/MiniSetup/PasswordEncode/PasswordEncodeBin.sdl
@@ -0,0 +1,34 @@
+TOKEN
+ Name = "PASSWORDENCODE_Bin_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable PasswordEncode binary support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+PATH
+ Name = "TSE_PWD_ENCODE_DIR"
+End
+
+TOKEN
+ Name = "PASSWORDENCODELIB"
+ Value = "$(TSE_PWD_ENCODE_DIR)/TsePasswordEncode$(ARCH).lib"
+ Help = "Password encode library"
+ TokenType = Expression
+ TargetMAK = Yes
+ TargetH = Yes
+End
+
+
+MODULE
+ Help = "Includes PasswordEncodeBin.mak to Project"
+ File = "PasswordEncodeBin.mak"
+End
+
+ELINK
+ Name = "$(TSE_PWD_ENCODE_DIR)/TsePasswordEncode$(ARCH).lib"
+ Parent = "MINISETUPLIB"
+ InvokeOrder = AfterParent
+End \ No newline at end of file
diff --git a/EDK/MiniSetup/PasswordEncode/TsePasswordEncode.lib b/EDK/MiniSetup/PasswordEncode/TsePasswordEncode.lib
new file mode 100644
index 0000000..2f365de
--- /dev/null
+++ b/EDK/MiniSetup/PasswordEncode/TsePasswordEncode.lib
Binary files differ
diff --git a/EDK/MiniSetup/PasswordEncode/TsePasswordEncodex64.lib b/EDK/MiniSetup/PasswordEncode/TsePasswordEncodex64.lib
new file mode 100644
index 0000000..b69b4d9
--- /dev/null
+++ b/EDK/MiniSetup/PasswordEncode/TsePasswordEncodex64.lib
Binary files differ