Skip to content
This repository has been archived by the owner on May 21, 2021. It is now read-only.

Commit

Permalink
SEBWIN-351: Implemented utter hack in attempt to make legacy configur…
Browse files Browse the repository at this point in the history
…ation tool calculate the same configuration key in versions 2.x and 3.x.
  • Loading branch information
dbuechel authored and danschlet committed Apr 8, 2020
1 parent c70d2c3 commit 5ccbffd
Showing 1 changed file with 21 additions and 10 deletions.
Expand Up @@ -413,14 +413,18 @@ public static DictObj DecryptSEBSettings(byte[] sebData, bool forEditing, ref st

// Get preferences dictionary from decrypted data
DictObj sebPreferencesDict = GetPreferencesDictFromConfigData(sebData, forEditing);
// If we didn't get a preferences dict back, we abort reading settings
if (sebPreferencesDict == null) return null;
DictObj sebPreferencesDictOriginal = GetPreferencesDictFromConfigData(sebData, false);
// If we didn't get a preferences dict back, we abort reading settings
if (sebPreferencesDict == null) return null;

// We need to set the right value for the key sebConfigPurpose to know later where to store the new settings
sebPreferencesDict[SEBSettings.KeySebConfigPurpose] = (int)SEBSettings.sebConfigPurposes.sebConfigPurposeStartingExam;
sebPreferencesDictOriginal[SEBSettings.KeySebConfigPurpose] = (int)SEBSettings.sebConfigPurposes.sebConfigPurposeStartingExam;

// Reading preferences was successful!
return sebPreferencesDict;
SEBSettings.settingsCurrentOriginal = sebPreferencesDictOriginal;

// Reading preferences was successful!
return sebPreferencesDict;
}

/// ----------------------------------------------------------------------------------------
Expand All @@ -445,7 +449,8 @@ private static DictObj DecryptDataWithPasswordForConfiguringClient(byte[] sebDat
// We use always uppercase letters in the base16 hashed admin password used for encrypting
hashedAdminPassword = hashedAdminPassword.ToUpper();
DictObj sebPreferencesDict = null;
byte[] decryptedSebData = SEBProtectionController.DecryptDataWithPassword(sebData, hashedAdminPassword);
DictObj sebPreferencesDictOriginal = null;
byte[] decryptedSebData = SEBProtectionController.DecryptDataWithPassword(sebData, hashedAdminPassword);
if (decryptedSebData == null)
{
// If decryption with admin password didn't work, try it with an empty password
Expand Down Expand Up @@ -500,7 +505,8 @@ private static DictObj DecryptDataWithPasswordForConfiguringClient(byte[] sebDat
try
{
sebPreferencesDict = (DictObj)Plist.readPlist(decryptedSebData);
}
sebPreferencesDictOriginal = (DictObj)Plist.readPlist(decryptedSebData);
}
catch (Exception readPlistException)
{
// Error when deserializing the decrypted configuration data
Expand Down Expand Up @@ -575,9 +581,12 @@ private static DictObj DecryptDataWithPasswordForConfiguringClient(byte[] sebDat

// We need to set the right value for the key sebConfigPurpose to know later where to store the new settings
sebPreferencesDict[SEBSettings.KeySebConfigPurpose] = (int)SEBSettings.sebConfigPurposes.sebConfigPurposeConfiguringClient;
sebPreferencesDictOriginal[SEBSettings.KeySebConfigPurpose] = (int)SEBSettings.sebConfigPurposes.sebConfigPurposeConfiguringClient;

// Reading preferences was successful!
return sebPreferencesDict;
SEBSettings.settingsCurrentOriginal = sebPreferencesDictOriginal;

// Reading preferences was successful!
return sebPreferencesDict;
}


Expand Down Expand Up @@ -806,8 +815,10 @@ public static byte[] GetPrefixDataFromData(ref byte[] data, int prefixLength)

public static byte[] EncryptSEBSettingsWithCredentials(string settingsPassword, bool passwordIsHash, X509Certificate2 certificateRef, bool useAsymmetricOnlyEncryption, SEBSettings.sebConfigPurposes configPurpose, bool forEditing)
{
// Get current settings dictionary and clean it from empty arrays and dictionaries
//DictObj cleanedCurrentSettings = SEBSettings.CleanSettingsDictionary();
// Get current settings dictionary and clean it from empty arrays and dictionaries
//DictObj cleanedCurrentSettings = SEBSettings.CleanSettingsDictionary();

SEBSettings.settingsCurrentOriginal = SEBSettings.settingsCurrent;

// Serialize preferences dictionary to an XML string
string sebXML = Plist.writeXml(SEBSettings.settingsCurrent);
Expand Down

0 comments on commit 5ccbffd

Please sign in to comment.