MeterPwdFile: - Validated findings on wrong password generation,
CUST: - Used MeterPwdFile instead of PasswordController for hashedPasswordFile generation including the validation checks.
This commit is contained in:
@@ -10,6 +10,7 @@ using Xylem.Common.CommonCore.Configuration;
|
||||
using Xylem.Common.CommonCore.Consts;
|
||||
using Xylem.Common.Cryptology.Security;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisPwd;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
|
||||
using Xylem.Common.Logic.ProductionOrderCore;
|
||||
@@ -386,6 +387,10 @@ namespace Xylem.ServiceFwUpdate.Common.FwUpdateDb
|
||||
/// - Used the <see cref="MeterPwdHandlerDb"/> as common interface to request the password container,
|
||||
/// if the password container does not exist, it will be generated.
|
||||
/// </remarks>
|
||||
/// <remarks date="2023-Oct-17" author="Thomas Wiedebusch">
|
||||
/// - Used the <see cref="MeterPwdFile.BuildPwdFile"/> as common routine for password hash file generation out of
|
||||
/// the raw text passwords. This routine verifies the password container.
|
||||
/// </remarks>
|
||||
public Boolean DownloadCordonelPwdFromDb(String pcbId, out PasswordContainer passwordContainer)
|
||||
{
|
||||
passwordContainer = new PasswordContainer();
|
||||
@@ -404,14 +409,34 @@ namespace Xylem.ServiceFwUpdate.Common.FwUpdateDb
|
||||
Encoding.UTF8.GetString(meterPwdDb.ListOfPasswords[MeterPwdDb.SkeletonKeyIdx]);
|
||||
passwordContainer.PasswordLvl8 =
|
||||
Encoding.UTF8.GetString(meterPwdDb.ListOfPasswords[MeterPwdDb.PwdLevel8Idx]);
|
||||
|
||||
// Use the standard constructor as writing to meter is not necessary
|
||||
var meterPwdFile = new MeterPwdFile();
|
||||
// The BuildPwdFile has an extended validation check
|
||||
var retBol = meterPwdFile.BuildPwdFile(meterPwdDb.ListOfPasswords, 1, passwordContainer.SkeletonKey);
|
||||
|
||||
if (!retBol)
|
||||
{
|
||||
DbIsConnected = false;
|
||||
return false;
|
||||
}
|
||||
passwordContainer.EncryptedPasswordFile = new Byte[MeterPwdDb.PwdFileLength];
|
||||
passwordContainer.EncryptedPasswordFile = meterPwdFile.HashedPasswordFile;
|
||||
|
||||
var hashList = new List<Byte>();
|
||||
foreach (var hash in meterPwdDb.ListOfHashes)
|
||||
{
|
||||
hashList.AddRange(hash);
|
||||
}
|
||||
passwordContainer.EncryptedPasswordFile = hashList.ToArray();
|
||||
var pwdControllerPwdFile = hashList.ToArray();
|
||||
//passwordContainer.EncryptedPasswordFile = hashList.ToArray();
|
||||
|
||||
// Compare password controller hashed password file with this generated new one
|
||||
for (var c = 0; c < MeterPwdDb.PwdFileLength; c++)
|
||||
{
|
||||
if (passwordContainer.EncryptedPasswordFile[c] != pwdControllerPwdFile[c])
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the password file is written, the "Password" from meterPwdDb is overwritten from Skeleton-key
|
||||
// to the "level 8 password" form the LuDB server. The DB password column is the current login password
|
||||
@@ -428,12 +453,13 @@ namespace Xylem.ServiceFwUpdate.Common.FwUpdateDb
|
||||
|
||||
return !string.IsNullOrEmpty(passwordContainer.SkeletonKey) &&
|
||||
!string.IsNullOrEmpty(passwordContainer.PasswordLvl8) &&
|
||||
passwordContainer.EncryptedPasswordFile.Length >= MeterPwdDb.PwdFileLength;
|
||||
passwordContainer.EncryptedPasswordFile.Length == MeterPwdDb.PwdFileLength;
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception ex)
|
||||
{
|
||||
DbIsConnected = false;
|
||||
return false;
|
||||
throw new ApplicationException(ex.Message);
|
||||
//return false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
|
||||
@@ -105,6 +105,10 @@
|
||||
<Project>{04201E95-90A0-4B73-A72F-379739B2A3AE}</Project>
|
||||
<Name>GenesisCore</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\Common\Hardware\WaterMeter\Genesis\GenesisFile\GenesisFile.csproj">
|
||||
<Project>{2C6378C6-6BA1-4CEE-8992-8404D8369A90}</Project>
|
||||
<Name>GenesisFile</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\..\Common\Hardware\WaterMeter\Genesis\GenesisPwd\GenesisPwd.csproj">
|
||||
<Project>{AC434B18-4D7B-49BA-9AD5-0527C79E8297}</Project>
|
||||
<Name>GenesisPwd</Name>
|
||||
|
||||
Reference in New Issue
Block a user